]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_options.c
add -advertise_ssh flag to afpd.conf, if set announce SSH tunneling capabilities.
[netatalk.git] / etc / afpd / afp_options.c
index ef6ddc144e2e12c4102b672e2ecce06cad5dee4c..ae4265282c9867e8f06ecdcb40d64c91f363972a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_options.c,v 1.30.2.1 2003-05-26 11:17:25 didg Exp $
+ * $Id: afp_options.c,v 1.30.2.2.2.8 2004-06-09 02:07:15 bfernhomberg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -61,6 +61,10 @@ char *strchr (), *strrchr ();
 #define MIN(a, b)  ((a) < (b) ? (a) : (b))
 #endif /* MIN */
 
+/* FIXME CNID */
+char             Cnid_srv[MAXHOSTNAMELEN + 1] = "localhost";
+int              Cnid_port = 4700;
+
 #define OPTIONS "dn:f:s:uc:g:P:ptDS:TL:F:U:Ivm:"
 #define LENGTH 512
 
@@ -129,8 +133,6 @@ void afp_options_free(struct afp_options *opt,
         free(opt->uampath);
     if (opt->uamlist && (opt->uamlist != save->uamlist))
         free(opt->uamlist);
-    if (opt->nlspath && (opt->nlspath != save->nlspath))
-        free(opt->nlspath);
     if (opt->passwdfile && (opt->passwdfile != save->passwdfile))
         free(opt->passwdfile);
     if (opt->signature && (opt->signature != save->signature))
@@ -139,6 +141,12 @@ void afp_options_free(struct afp_options *opt,
        free(opt->k5service);
     if (opt->k5realm && (opt->k5realm != save->k5realm))
        free(opt->k5realm);
+    if (opt->k5keytab && (opt->k5keytab != save->k5keytab))
+       free(opt->k5keytab);
+    if (opt->unixcodepage && (opt->unixcodepage != save->unixcodepage))
+       free(opt->unixcodepage);
+    if (opt->maccodepage && (opt->maccodepage != save->maccodepage))
+       free(opt->maccodepage);
 }
 
 /* initialize options */
@@ -150,7 +158,6 @@ void afp_options_init(struct afp_options *options)
     options->defaultvol.name = _PATH_AFPDDEFVOL;
     options->systemvol.name = _PATH_AFPDSYSVOL;
     options->configfile = _PATH_AFPDCONF;
-    options->nlspath = _PATH_AFPDNLSPATH;
     options->uampath = _PATH_AFPDUAMPATH;
     options->uamlist = "uams_clrtxt.so,uams_dhx.so";
     options->guest = "nobody";
@@ -159,6 +166,7 @@ void afp_options_init(struct afp_options *options)
     options->passwdfile = _PATH_AFPDPWFILE;
     options->tickleval = 30;
     options->timeout = 4;
+    options->sleep = 10* 120; /* 10 h in 30 seconds tick */
     options->server_notif = 1;
     options->authprintdir = NULL;
     options->signature = "host";
@@ -168,6 +176,11 @@ void afp_options_init(struct afp_options *options)
 #endif /* ADMIN_GRP */
     options->k5service = NULL;
     options->k5realm = NULL;
+    options->k5keytab = NULL;
+    options->unixcharset = CH_UNIX;
+    options->unixcodepage = "LOCALE";
+    options->maccharset = CH_MAC;
+    options->maccodepage = "MAC_ROMAN";
 }
 
 /* parse an afpd.conf line. i'm doing it this way because it's
@@ -208,6 +221,8 @@ int afp_options_parseline(char *buf, struct afp_options *options)
         options->flags &= ~OPTION_CUSTOMICON;
     if (strstr(buf, " -icon"))
         options->flags |= OPTION_CUSTOMICON;
+    if (strstr(buf, " -advertise_ssh"))
+        options->flags |= OPTION_ANNOUNCESSH;
 
     /* passwd bits */
     if (strstr(buf, " -nosavepassword"))
@@ -264,6 +279,13 @@ int afp_options_parseline(char *buf, struct afp_options *options)
         }
     }
 
+    if ((c = getoption(buf, "-sleep"))) {
+        options->sleep = atoi(c) *120;
+        if (options->sleep <= 4) {
+            options->sleep = 4;
+        }
+    }
+
     if ((c = getoption(buf, "-server_quantum")))
         options->server_quantum = strtoul(c, NULL, 0);
 
@@ -395,26 +417,43 @@ int afp_options_parseline(char *buf, struct afp_options *options)
        options->k5service = opt;
     if ((c = getoption(buf, "-k5realm")) && (opt = strdup(c)))
        options->k5realm = opt;
-    if ((c = getoption(buf, "-k5keytab")))
-       setenv( "KRB5_KTNAME", c, 1 );
+    if ((c = getoption(buf, "-k5keytab"))) {
+       if ( NULL == (options->k5keytab = (char *) malloc(sizeof(char)*(strlen(c)+14)) )) {
+               LOG(log_error, logtype_afpd, "malloc failed");
+               exit(-1);
+       }
+       snprintf(options->k5keytab, strlen(c)+14, "KRB5_KTNAME=%s", c);
+       putenv(options->k5keytab);
+       /* setenv( "KRB5_KTNAME", c, 1 ); */
+    }
     if ((c = getoption(buf, "-authprintdir")) && (opt = strdup(c)))
         options->authprintdir = opt;
     if ((c = getoption(buf, "-uampath")) && (opt = strdup(c)))
         options->uampath = opt;
     if ((c = getoption(buf, "-uamlist")) && (opt = strdup(c)))
         options->uamlist = opt;
-    if ((c = getoption(buf, "-nlspath")) && (opt = strdup(c)))
-        options->nlspath = opt;
 
     if ((c = getoption(buf, "-ipaddr"))) {
         struct in_addr inaddr;
         if (inet_aton(c, &inaddr) && (opt = strdup(c))) {
             if (!gethostbyaddr((const char *) &inaddr, sizeof(inaddr), AF_INET))
-                LOG(log_info, logtype_afpd, "WARNING: can't find %s\n", opt);
+                LOG(log_info, logtype_afpd, "WARNING: can't find %s", opt);
             options->ipaddr = opt;
         }
     }
 
+    /* FIXME CNID Cnid_srv is a server attribute */
+    if ((c = getoption(buf, "-cnidserver"))) {
+        char *p;
+       int len;        
+        p = strchr(c, ':');
+       if (p != NULL && (len = p - c) <= MAXHOSTNAMELEN) {
+           memcpy(Cnid_srv, c, len);
+           Cnid_srv[len] = 0;
+           Cnid_port = atoi(p +1);
+       }
+    }
+
     if ((c = getoption(buf, "-port")))
         options->port = atoi(c);
     if ((c = getoption(buf, "-ddpaddr")))
@@ -433,6 +472,31 @@ int afp_options_parseline(char *buf, struct afp_options *options)
             if ((opt = strdup(c)))
                 options->fqdn = opt;
         }
+       else {
+            LOG(log_error, logtype_afpd, "error parsing -fqdn, gethostbyname failed for: %s", c);
+       }
+    }
+
+    if ((c = getoption(buf, "-unixcodepage"))) {
+       if ((charset_t)-1  == ( options->unixcharset = add_charset(c)) ) {
+            options->unixcharset = CH_UNIX;
+            LOG(log_warning, logtype_afpd, "setting Unix codepage to '%s' failed", c);
+       }
+       else {
+            if ((opt = strdup(c)))
+                options->unixcodepage = opt;
+       }
+    }
+       
+    if ((c = getoption(buf, "-maccodepage"))) {
+       if ((charset_t)-1 == ( options->maccharset = add_charset(c)) ) {
+            options->maccharset = CH_MAC;
+            LOG(log_warning, logtype_afpd, "setting Mac codepage to '%s' failed", c);
+       }
+       else {
+            if ((opt = strdup(c)))
+                options->maccodepage = opt;
+       }
     }
 
     return 1;