]> arthur.barton.de Git - netatalk.git/commitdiff
second sigint restores default logging instead of killing afpd
authorFrank Lahm <franklahm@googlemail.com>
Sun, 26 Sep 2010 16:10:38 +0000 (18:10 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Sun, 26 Sep 2010 16:10:38 +0000 (18:10 +0200)
etc/afpd/afp_dsi.c
etc/afpd/afp_options.c
etc/afpd/globals.h
etc/afpd/main.c

index 54e5c4b66ea594603ca3596c2abb04d2aa3ef3f2..90facbee6508d41606d67df95035897378a7dade 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: afp_dsi.c,v 1.53 2010/03/30 12:55:26 franklahm Exp $
- *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -392,21 +390,23 @@ void afp_over_dsi(AFPObj *obj)
             dircache_dump();
         }
 
+        /* The first SIGINT enables debugging, the next restores the config */
         if (debug_request) {
-            char logstr[50];
+            static int debugging = 0;
             debug_request = 0;
 
-            /* The first SIGINT enables debugging, the second one kills us */
-            action.sa_handler = afp_dsi_die;
-            sigfillset( &action.sa_mask );
-            action.sa_flags = SA_RESTART;
-            if ( sigaction( SIGINT, &action, NULL ) < 0 ) {
-                LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
-                afp_dsi_die(EXITERR_SYS);
+            if (debugging) {
+                if (obj->options.logconfig)
+                    setuplog(obj->options.logconfig);
+                else
+                    setuplog("default log_note");
+                debugging = 0;
+            } else {
+                char logstr[50];
+                debugging = 1;
+                sprintf(logstr, "default log_maxdebug /tmp/afpd.%u.XXXXXX", getpid());
+                setuplog(logstr);
             }
-
-            sprintf(logstr, "default log_maxdebug /tmp/afpd.%u.XXXXXX", getpid());
-            setuplog(logstr);
         }
 
         if (cmd == DSIFUNC_TICKLE) {
index c1ce4bc98b24970a2e8c0076564733b96e60a365..3b16a067e8b7ecd1ab17854c9db6bf1c981b0133 100644 (file)
@@ -153,6 +153,8 @@ void afp_options_free(struct afp_options *opt,
        free(opt->ntdomain);
     if (opt->ntseparator && (opt->ntseparator != save->ntseparator))
        free(opt->ntseparator);
+    if (opt->logconfig && (opt->logconfig != save->logconfig))
+       free(opt->logconfig);
 }
 
 /* initialize options */
@@ -339,6 +341,7 @@ int afp_options_parseline(char *buf, struct afp_options *options)
         char *optstr;
         if ((optstr = getoption(c, "-setuplog"))) {
             setuplog(optstr);
+            options->logconfig = optstr; /* at least store the last (possibly only) one */
             c += sizeof("-setuplog");
         }
     }
index 5fbb048b1bde766f2304fc59499db22bcdb91763..6ce22a8ae146f9991383efe5f528f8861a1a0e3c 100644 (file)
@@ -86,6 +86,7 @@ struct afp_options {
 
     /* default value for winbind authentication */
     char *ntdomain, *ntseparator;
+    char *logconfig;
 };
 
 #define AFPOBJ_TMPSIZ (MAXPATHLEN)
index 32d44d95614f4fa91d17d9e1ef546f5395180a19..30a32346238aefc4425c0ba14062ef18dd21aa26 100644 (file)
@@ -150,6 +150,9 @@ int main(int ac, char **av)
     /* Log SIGBUS/SIGSEGV SBT */
     fault_setup(NULL);
 
+    /* Default log setup: log to syslog */
+    setuplog("default log_note");
+
     afp_options_init(&default_options);
     if (!afp_options_parse(ac, av, &default_options))
         exit(EXITERR_CONF);