]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_options.c
Import FCE
[netatalk.git] / etc / afpd / afp_options.c
index 2a73678566e8683fc7434ed671ca6b5cc8f86354..ff807404b36df7955379934ff0738544446bf3da 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: afp_options.c,v 1.44 2009-07-21 13:41:16 didg Exp $
- *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -49,6 +47,7 @@ char *strchr (), *strrchr ();
 #include "globals.h"
 #include "status.h"
 #include "auth.h"
+#include "fce_api.h"
 
 #include <atalk/compat.h>
 
@@ -62,8 +61,8 @@ char *strchr (), *strrchr ();
 #endif /* MIN */
 
 /* FIXME CNID */
-char             Cnid_srv[MAXHOSTNAMELEN + 1] = "localhost";
-int              Cnid_port = 4700;
+const char *Cnid_srv = "localhost";
+const char *Cnid_port = "4700";
 
 #define OPTIONS "dn:f:s:uc:g:P:ptDS:TL:F:U:hIvVm:"
 #define LENGTH 512
@@ -127,6 +126,8 @@ void afp_options_free(struct afp_options *opt,
         free(opt->server);
     if (opt->ipaddr && (opt->ipaddr != save->ipaddr))
         free(opt->ipaddr);
+    if (opt->port && (opt->port != save->port))
+        free(opt->port);
     if (opt->fqdn && (opt->fqdn != save->fqdn))
         free(opt->fqdn);
     if (opt->uampath && (opt->uampath != save->uampath))
@@ -135,8 +136,8 @@ void afp_options_free(struct afp_options *opt,
         free(opt->uamlist);
     if (opt->passwdfile && (opt->passwdfile != save->passwdfile))
         free(opt->passwdfile);
-    if (opt->signature && (opt->signature != save->signature))
-       free(opt->signature);
+    if (opt->signatureopt && (opt->signatureopt != save->signatureopt))
+       free(opt->signatureopt);
     if (opt->k5service && (opt->k5service != save->k5service))
        free(opt->k5service);
     if (opt->k5realm && (opt->k5realm != save->k5realm))
@@ -163,18 +164,19 @@ void afp_options_init(struct afp_options *options)
     options->defaultvol.name = _PATH_AFPDDEFVOL;
     options->systemvol.name = _PATH_AFPDSYSVOL;
     options->configfile = _PATH_AFPDCONF;
+    options->sigconffile = _PATH_AFPDSIGCONF;
     options->uampath = _PATH_AFPDUAMPATH;
     options->uamlist = "uams_dhx.so,uams_dhx2.so";
     options->guest = "nobody";
     options->loginmesg = "";
-    options->transports = AFPTRANS_ALL;
+    options->transports = AFPTRANS_TCP; /*  TCP only */
     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";
+    options->signatureopt = "auto";
     options->umask = 0;
 #ifdef ADMIN_GRP
     options->admingid = 0;
@@ -189,6 +191,10 @@ void afp_options_init(struct afp_options *options)
     options->volnamelen = 80; /* spec: 255, 10.1: 73, 10.4/10.5: 80 */
     options->ntdomain = NULL;
     options->ntseparator = NULL;
+#ifdef USE_SRVLOC
+    /* don't advertize slp by default */
+    options->flags |= OPTION_NOSLP;
+#endif
 }
 
 /* parse an afpd.conf line. i'm doing it this way because it's
@@ -211,9 +217,9 @@ int afp_options_parseline(char *buf, struct afp_options *options)
     if (strstr(buf, " -nodebug"))
         options->flags &= ~OPTION_DEBUG;
 #ifdef USE_SRVLOC
-    if (strstr(buf, " -noslp"))
-        options->flags |= OPTION_NOSLP;
-#endif /* USE_SRVLOC */
+    if (strstr(buf, " -slp"))
+        options->flags &= ~OPTION_NOSLP;
+#endif
 
     if (strstr(buf, " -nouservolfirst"))
         options->flags &= ~OPTION_USERVOLFIRST;
@@ -363,6 +369,7 @@ int afp_options_parseline(char *buf, struct afp_options *options)
         options->uamlist = opt;
 
     if ((c = getoption(buf, "-ipaddr"))) {
+#if 0
         struct in_addr inaddr;
         if (inet_aton(c, &inaddr) && (opt = strdup(c))) {
             if (!gethostbyaddr((const char *) &inaddr, sizeof(inaddr), AF_INET))
@@ -372,26 +379,27 @@ int afp_options_parseline(char *buf, struct afp_options *options)
         else {
             LOG(log_error, logtype_afpd, "Error parsing -ipaddr, is %s in numbers-and-dots notation?", c);
         }
+#endif
+        options->ipaddr = strdup(c);
     }
 
     /* 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);
-       }
+        char *p = strrchr(c, ':');
+        if (p)
+            *p = 0;
+        Cnid_srv = strdup(c);
+        if (p)
+            Cnid_port = strdup(p + 1);
+        LOG(log_debug, logtype_afpd, "CNID Server: %s:%s", Cnid_srv, Cnid_port);
     }
 
     if ((c = getoption(buf, "-port")))
-        options->port = atoi(c);
+        options->port = strdup(c);
     if ((c = getoption(buf, "-ddpaddr")))
         atalk_aton(c, &options->ddpaddr);
     if ((c = getoption(buf, "-signature")) && (opt = strdup(c)))
-        options->signature = opt;
+        options->signatureopt = opt;
 
     /* do a little checking for the domain name. */
     if ((c = getoption(buf, "-fqdn"))) {
@@ -440,7 +448,17 @@ int afp_options_parseline(char *buf, struct afp_options *options)
 
     if ((c = getoption(buf, "-ntseparator")) && (opt = strdup(c)))
        options->ntseparator = opt;
-     
+
+       if ((c = getoption(buf, "-fcelistener"))) {
+               LOG(log_note, logtype_afpd, "Adding fce listener \"%s\"", c);
+               fce_add_udp_socket(c);
+       }
+       if ((c = getoption(buf, "-fcecoalesce"))) {
+               LOG(log_ote, logtype_afpd, "Fce coalesce: %s", c);
+               fce_set_coalesce(c);
+       }
+
+
     return 1;
 }
 
@@ -448,7 +466,7 @@ int afp_options_parseline(char *buf, struct afp_options *options)
  * Show version information about afpd.
  * Used by "afp -v".
  */
-void show_version( )
+static void show_version( void )
 {
        printf( "afpd %s - Apple Filing Protocol (AFP) daemon of Netatalk\n\n", VERSION );
 
@@ -459,7 +477,7 @@ void show_version( )
 
        puts( "afpd has been compiled with support for these features:\n" );
 
-       printf( "        AFP3.1 support:\t" );
+       printf( "        AFP3.x support:\t" );
 #ifdef AFP3x
        puts( "Yes" );
 #else
@@ -506,7 +524,7 @@ void show_version( )
  * Show extended version information about afpd and Netatalk.
  * Used by "afp -V".
  */
-void show_version_extended( )
+static void show_version_extended(void )
 {
        show_version( );
 
@@ -570,22 +588,24 @@ void show_version_extended( )
 /*
  * Display compiled-in default paths
  */
-void show_paths( void )
+static void show_paths( void )
 {
        printf( "             afpd.conf:\t%s\n", _PATH_AFPDCONF );
+       printf( "    afp_signature.conf:\t%s\n", _PATH_AFPDSIGCONF );
        printf( "   AppleVolumes.system:\t%s\n", _PATH_AFPDSYSVOL );
        printf( "  AppleVolumes.default:\t%s\n", _PATH_AFPDDEFVOL );
        printf( "       UAM search path:\t%s\n", _PATH_AFPDUAMPATH );
+    printf( "  Server messages path:\t%s\n", SERVERTEXT);
 }
 
 /*
- * Display usage information about adpd.
+ * Display usage information about afpd.
  */
-void show_usage( char *name )
+static void show_usage( char *name )
 {
-       fprintf( stderr, "Usage:\t%s [-dDIptTu] [-c maxconnections] [-f defaultvolumes] [-F config]\n", name );
-       fprintf( stderr, "\t     [-g guest] [-L message] [-m umask][-n nbpname] [-P pidfile]\n" );
-       fprintf( stderr, "\t     [-s systemvolumes] [-S port] [-U uams]\n" );
+       fprintf( stderr, "Usage:\t%s [-duptDTI] [-f defaultvolumes] [-s systemvolumes] [-n nbpname]\n", name );
+       fprintf( stderr, "\t     [-c maxconnections] [-g guest] [-P pidfile] [-S port] [-L message]\n" );
+       fprintf( stderr, "\t     [-F configfile] [-U uams] [-m umask]\n" );
        fprintf( stderr, "\t%s -h|-v|-V\n", name );
 }
 
@@ -651,7 +671,7 @@ int afp_options_parse(int ac, char **av, struct afp_options *options)
             options->transports &= ~AFPTRANS_DDP;
             break;
         case 'S':
-            options->port = atoi(optarg);
+            options->port = optarg;
             break;
         case 'T':
             options->transports &= ~AFPTRANS_TCP;