]> arthur.barton.de Git - netatalk.git/commitdiff
Fixes
authorFrank Lahm <franklahm@googlemail.com>
Sat, 11 Feb 2012 14:40:03 +0000 (15:40 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Sat, 11 Feb 2012 14:40:03 +0000 (15:40 +0100)
etc/afpd/Makefile.am
etc/afpd/afp_config.c
etc/afpd/afp_options.c
etc/afpd/main.c
include/atalk/globals.h
libatalk/util/logger.c

index 1a2dd95c40087af4b0a1355ed057e2518430e255..544c5843af52bc44af886e8601e8e87bf712eee2 100644 (file)
@@ -56,10 +56,7 @@ afpd_CFLAGS = \
        -DAPPLCNAME \
        -DSERVERTEXT=\"$(SERVERTEXT)/\" \
        -D_PATH_AFPDPWFILE=\"$(pkgconfdir)/afppasswd\" \
-       -D_PATH_AFPDCONF=\"$(pkgconfdir)/afpd.conf\" \
-       -D_PATH_AFPDSIGCONF=\"$(pkgconfdir)/afp_signature.conf\" \
        -D_PATH_AFPDUAMPATH=\"$(UAMS_PATH)/\" \
-       -D_PATH_AFPDUUIDCONF=\"$(pkgconfdir)/afp_voluuid.conf\" \
        -D_PATH_CONFDIR=\"$(pkgconfdir)\"
 
 if HAVE_ACLS
index cd332a94715e66c5321f85761715c645dee2050d..c07b2e9272229cdd4b0743967d304f0cf0b19487 100644 (file)
@@ -171,21 +171,10 @@ static AFPConfig *AFPConfigInit(struct afp_options *options,
 }
 
 /*!
- * Parse configfile and build AFPObj
+ * Get everything running
  */
-int configinit(AFPObj *AFPObj, const struct afp_options *defoptions)
+int configinit(AFPObj *AFPObj)
 {
-    int have_option = 0;
-
-    afp_options_duplicate(&AFPObj->options, defoptions);
-
-    if ((AFPObj->iniconfig = iniparser_load(AFPObj->options.configfile)) == NULL)
-        /* if config file doesn't exist, load defaults */
-        return AFPConfigInit(AFPObj);
-
-    if (afp_options_parse(AFPObj) != 0)
-        return -1;
-
     AFPConfigInit(AFPObj);
 
 #ifdef HAVE_LDAP
@@ -193,8 +182,6 @@ int configinit(AFPObj *AFPObj, const struct afp_options *defoptions)
     acl_ldap_readconfig(AFPObj->iniconfig);
 #endif /* HAVE_LDAP */
 
-    LOG(log_debug, logtype_afpd, "Finished parsing Config File");
-
     /* Now register with zeroconf, we also need the volumes for that */
     if (! (AFPObj->options.flags & OPTION_NOZEROCONF)) {
         load_volumes(AFPObj);
index 65710c1082f91bd434f6b3c43c754c54ecedcb4b..79b4df07206fdcd8976954cb4f640cc4e7b3ed0d 100644 (file)
 #include "auth.h"
 #include "dircache.h"
 
-#define OPTIONS "dn:uc:g:P:ptS:L:F:U:hIvVm:"
 #define LENGTH 512
 
-/* initialize options */
-void afp_options_init(struct afp_options *options)
-{
-    memset(options, 0, sizeof(struct afp_options));
-
-    options->pidfile = _PATH_AFPDLOCK;
-    options->configfile = D_PATH_CONFDIR "afp.conf";
-    options->sigconffile = _PATH_AFPDSIGCONF;
-    options->uuidconf = _PATH_AFPDUUIDCONF;
-    options->server_notif = 1;
-    options->dsireadbuf = 12;
-}
-
 /* get rid of any allocated afp_option buffers. */
 void afp_options_free(struct afp_options *opt)
 {
@@ -104,27 +90,8 @@ void afp_options_free(struct afp_options *opt)
         free(opt->unixcodepage);
 }
 
-void afp_options_duplicate(struct afp_options *options, const struct afp_options *soptions)
-{
-    memcpy(options, soptions, sizeof(struct afp_options));
-
-    options->pidfile = NULL;
-    options->uuidconf = NULL;
-
-    options->configfile = strdup(options->configfile);
-    options->guest = strdup(options->guest);
-    options->loginmesg = strdup(options->loginmesg);
-    options->maccodepage = strdup(options->maccodepage);
-    options->passwdfile = strdup(options->passwdfile);
-    options->sigconffile = strdup(options->sigconffile);
-    options->signatureopt = strdup(options->signatureopt);
-    options->uamlist = strdup(options->uamlist);
-    options->uampath = strdup(options->uampath);
-    options->unixcodepage = strdup(options->unixcodepage);
-}
-
-#define MAXVAL
-int afp_options_parse(AFPObj *AFPObj)
+#define MAXVAL 1024
+int afp_config_parse(AFPObj *AFPObj)
 {
     dictionary *config = AFPObj->iniconfig;
     struct afp_options *options = &AFPObj->options;
@@ -132,15 +99,38 @@ int afp_options_parse(AFPObj *AFPObj)
     const char *p, *tmp;
     char val[MAXVAL];
 
-    /* [Global] */
+    memset(options, 0, sizeof(struct afp_options));
+    options->configfile  = strdup(_PATH_CONFDIR "afp.conf");
+    options->sigconffile = strdup(_PATH_CONFDIR "afp_signature.conf");
+    options->uuidconf    = strdup(_PATH_CONFDIR "afp_voluuid.conf");
+    options->flags |= OPTION_ACL2MACCESS | OPTION_UUID | OPTION_SERVERNOTIF;
+
+    while (EOF != (p = getopt(AFPObj->argc, AFPObj->argv, "dF:"))) {
+        switch (p) {
+        case 'd':
+            options->flags |= OPTION_DEBUG;
+            break;
+        case 'F':
+            if (options->configfile)
+                free(options->configfile);
+            options->configfile = optarg;
+            break;
+        default :
+            break;
+        }
+    }
 
-    options->logconfig      = iniparser_getstring(config, INISEC_GLOBAL, "loglevel",       "default:note");
-    options->logfile        = iniparser_getstring(config, INISEC_GLOBAL, "logfile",        NULL);
+    if ((config = iniparser_load(AFPObj->options.configfile)) == NULL)
+        return -1;
+    AFPObj->iniconfig = config;
+
+    /* [Global] */
+    options->logconfig = iniparser_getstring(config, INISEC_GLOBAL, "loglevel", "default:note");
+    options->logfile   = iniparser_getstring(config, INISEC_GLOBAL, "logfile",  NULL);
+    set_processname("afpd");
     setuplog(logconfig, logfile);
 
     /* [AFP] "options" options wo values */
-    options->flags |= OPTION_ACL2MACCESS | OPTION_UUID;
-
     p = iniparser_getstring(config, INISEC_AFP, "options", "");
     strcpy(val, " ");
     strlcat(val, p, MAXVAL);
@@ -159,6 +149,8 @@ int afp_options_parse(AFPObj *AFPObj)
         options->flags |= OPTION_KEEPSESSIONS;
     if (strstr(val, " keepsessions"))
         options->flags |= OPTION_CLOSEVOL;
+    if (strstr(val, " client_polling"))
+        options->flags &= ~OPTION_SERVERNOTIF;
     if (strstr(val, " nosavepassword"))
         options->passwdbits |= PASSWD_NOSAVE;
     if (strstr(val, " savepassword"))
@@ -167,8 +159,6 @@ int afp_options_parse(AFPObj *AFPObj)
         options->passwdbits &= ~PASSWD_SET;
     if (strstr(val, " setpassword"))
         options->passwdbits |= PASSWD_SET;
-    if (strstr(val, " client_polling"))
-        options->server_notif = 0;
 
     /* figure out options w values */
 
@@ -441,11 +431,8 @@ static void show_usage( char *name )
        fprintf( stderr, "\t%s -h|-v|-V\n", name );
 }
 
-int afp_options_parse_cmdline(int ac, char **av, struct afp_options *options)
+int afp_options_parse_cmdline(int ac, char **av)
 {
-    extern char *optarg;
-    extern int optind;
-
     char *p;
     char *tmp; /* Used for error checking the result of strtol */
     int c, err = 0;
@@ -459,14 +446,8 @@ int afp_options_parse_cmdline(int ac, char **av, struct afp_options *options)
         *p = '\0';
     options->hostname = strdup(buf);
 
-    while (EOF != ( c = getopt( ac, av, OPTIONS )) ) {
+    while (EOF != ( c = getopt( ac, av, "vVh" )) ) {
         switch ( c ) {
-        case 'd' :
-            options->flags |= OPTION_DEBUG;
-            break;
-        case 'F':
-            options->configfile = optarg;
-            break;
         case 'v':      /* version */
             show_version( ); puts( "" );
             show_paths( ); puts( "" );
index 43b8d080767b5fc9a031cfd053cb166809bb9210..80b475b17e897690b05e9c22b1e28225a4875321 100644 (file)
@@ -217,39 +217,34 @@ int main(int ac, char **av)
     struct sigaction   sv;
     sigset_t            sigs;
     int                 ret;
-    struct afp_options default_options = {0};
 
     /* Parse argv args and initialize default options */
-    afp_options_init(&default_options);
-    if (!afp_options_parse_cmdline(ac, av, &default_options))
+    AFPObj.argc = ac;
+    AFPObj.argv = av;
+    if (!afp_config_parse(&AFPObj))
         exit(EXITERR_CONF);
 
-    if (check_lockfile("afpd", default_options.pidfile) != 0)
+    if (check_lockfile("afpd", _PATH_AFPDLOCK) != 0)
         exit(EXITERR_SYS);
 
-    if (!(default_options.flags & OPTION_DEBUG) && (daemonize(0, 0) != 0))
+    if (!(AFPObj.options.flags & OPTION_DEBUG) && (daemonize(0, 0) != 0))
         exit(EXITERR_SYS);
 
-    if (create_lockfile("afpd", default_options.pidfile) != 0)
+    if (create_lockfile("afpd", _PATH_AFPDLOCK) != 0)
         exit(EXITERR_SYS);
 
     /* Log SIGBUS/SIGSEGV SBT */
     fault_setup(NULL);
-
-    /* Default log setup: log to syslog */
-    set_processname("afpd");
-    setuplog("default log_note");
+    atexit(afp_exit);
 
     /* Save the user's current umask */
-    default_options.save_mask = umask( default_options.umask );
-
-    atexit(afp_exit);
+    AFPObj.options.save_mask = umask(AFPObj.options.umask);
 
     /* install child handler for asp and dsi. we do this before afp_goaway
      * as afp_goaway references stuff from here. 
      * XXX: this should really be setup after the initial connections. */
-    if (!(server_children = server_child_alloc(default_options.connections,
-                            CHILD_NFORKS))) {
+    if (!(server_children = server_child_alloc(AFPObj.options.connections,
+                                               CHILD_NFORKS))) {
         LOG(log_error, logtype_afpd, "main: server_child alloc: %s", strerror(errno) );
         exit(EXITERR_SYS);
     }
@@ -304,7 +299,6 @@ int main(int ac, char **av)
         exit(EXITERR_SYS);
     }
 
-
     sigemptyset( &sv.sa_mask );
     sigaddset(&sv.sa_mask, SIGALRM);
     sigaddset(&sv.sa_mask, SIGHUP);
@@ -348,7 +342,7 @@ int main(int ac, char **av)
     sigaddset(&sigs, SIGCHLD);
 
     pthread_sigmask(SIG_BLOCK, &sigs, NULL);
-    if (!(AFPObj = configinit(&default_options))) {
+    if (configinit(&AFPObj) != 0) {
         LOG(log_error, logtype_afpd, "main: no servers configured");
         exit(EXITERR_CONF);
     }
@@ -399,12 +393,11 @@ int main(int ac, char **av)
             fd_reset_listening_sockets(&AFPObj);
 
             LOG(log_info, logtype_afpd, "re-reading configuration file");
-            dsi_cleanup(&AFPObj);
 
             /* configfree close atp socket used for DDP tickle, there's an issue
              * with atp tid. */
             configfree(&AFPObj);
-            if (!(AFPObj = configinit(&default_options))) {
+            if (configinit(&AFPObj) != 0) {
                 LOG(log_error, logtype_afpd, "config re-read: no servers configured");
                 exit(EXITERR_CONF);
             }
index 62e754a4a8de6ee1d97689aac174cbc4440711b0..716c60382eb36e33b47fdd54ca982425d466dbad 100644 (file)
@@ -34,6 +34,7 @@
 
 #define OPTION_DEBUG         (1 << 0)
 #define OPTION_CLOSEVOL      (1 << 1)
+#define OPTION_SERVERNOTIF   (1 << 2)
 #define OPTION_CUSTOMICON    (1 << 4)
 #define OPTION_ANNOUNCESSH   (1 << 6)
 #define OPTION_UUID          (1 << 7)
@@ -61,10 +62,11 @@ struct afp_volume_name {
 };
 
 struct afp_options {
+    int argc;
+    char **argv;
     int connections;            /* Maximum number of possible AFP connections */
     int tickleval;
     int timeout;
-    int server_notif;
     int flags;
     int dircachesize;
     int sleep;                  /* Maximum time allowed to sleep (in tickles) */
@@ -79,7 +81,6 @@ struct afp_options {
     char *Cnid_srv, *Cnid_port;
     char *configfile;
     char *uampath, *fqdn;
-    char *pidfile;
     char *sigconffile;
     char *uuidconf;
     char *guest, *loginmesg, *keyfile, *passwdfile;
index 3f26c45789ea4452783d4928bd5195d09544cb0a..c1e981dd417d5bf8473a1764ad2cef98c1802291 100644 (file)
@@ -39,18 +39,18 @@ Netatalk 2001 (c)
 #define MAXLOGSIZE 512
 
 #define LOGLEVEL_STRING_IDENTIFIERS { \
-  "LOG_NOTHING",                      \
-  "LOG_SEVERE",                       \
-  "LOG_ERROR",                        \
-  "LOG_WARN",                         \
-  "LOG_NOTE",                         \
-  "LOG_INFO",                         \
-  "LOG_DEBUG",                        \
-  "LOG_DEBUG6",                       \
-  "LOG_DEBUG7",                       \
-  "LOG_DEBUG8",                       \
-  "LOG_DEBUG9",                       \
-  "LOG_MAXDEBUG"}                        
+  "NOTHING",                      \
+  "SEVERE",                       \
+  "ERROR",                        \
+  "WARN",                         \
+  "NOTE",                         \
+  "INFO",                         \
+  "DEBUG",                        \
+  "DEBUG6",                       \
+  "DEBUG7",                       \
+  "DEBUG8",                       \
+  "DEBUG9",                       \
+  "MAXDEBUG"}                        
 
 /* these are the string identifiers corresponding to each logtype */
 #define LOGTYPE_STRING_IDENTIFIERS { \