]> arthur.barton.de Git - netatalk.git/commitdiff
SIGINT enables max_debug logging to /tmp/afpd.PID.XXXXXX
authorfranklahm <franklahm>
Mon, 8 Feb 2010 13:39:56 +0000 (13:39 +0000)
committerfranklahm <franklahm>
Mon, 8 Feb 2010 13:39:56 +0000 (13:39 +0000)
etc/afpd/afp_dsi.c
libatalk/util/logger.c
man/man8/afpd.8.tmpl

index 041db2ce7a0b3fa901eface873dc278aa5135277..d0eec32ec55475bd10c02188bfe1f37236c77ab2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_dsi.c,v 1.49 2010-01-18 12:55:28 franklahm Exp $
+ * $Id: afp_dsi.c,v 1.50 2010-02-08 13:39:56 franklahm Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -170,6 +170,16 @@ static void afp_dsi_reload(int sig _U_)
     reload_request = 1;
 }
 
+/* ---------------------------------
+ * SIGINT: enable max_debug LOGging
+ */
+volatile static sig_atomic_t debug_request = 0;
+
+static void afp_dsi_debug(int sig _U_)
+{
+    debug_request = 1;
+}
+
 /* ---------------------- */
 #ifdef SERVERTEXT
 static void afp_dsi_getmesg (int sig _U_)
@@ -266,6 +276,7 @@ void afp_over_dsi(AFPObj *obj)
     sigaddset(&action.sa_mask, SIGALRM);
     sigaddset(&action.sa_mask, SIGTERM);
     sigaddset(&action.sa_mask, SIGUSR1);
+    sigaddset(&action.sa_mask, SIGINT);
 #ifdef SERVERTEXT
     sigaddset(&action.sa_mask, SIGUSR2);
 #endif    
@@ -281,6 +292,7 @@ void afp_over_dsi(AFPObj *obj)
     sigaddset(&action.sa_mask, SIGALRM);
     sigaddset(&action.sa_mask, SIGHUP);
     sigaddset(&action.sa_mask, SIGUSR1);
+    sigaddset(&action.sa_mask, SIGINT);
 #ifdef SERVERTEXT
     sigaddset(&action.sa_mask, SIGUSR2);
 #endif    
@@ -298,6 +310,7 @@ void afp_over_dsi(AFPObj *obj)
     sigaddset(&action.sa_mask, SIGTERM);
     sigaddset(&action.sa_mask, SIGUSR1);
     sigaddset(&action.sa_mask, SIGHUP);
+    sigaddset(&action.sa_mask, SIGINT);
     action.sa_flags = SA_RESTART;
     if ( sigaction( SIGUSR2, &action, NULL) < 0 ) {
         LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
@@ -311,6 +324,7 @@ void afp_over_dsi(AFPObj *obj)
     sigaddset(&action.sa_mask, SIGALRM);
     sigaddset(&action.sa_mask, SIGHUP);
     sigaddset(&action.sa_mask, SIGTERM);
+    sigaddset(&action.sa_mask, SIGINT);
 #ifdef SERVERTEXT
     sigaddset(&action.sa_mask, SIGUSR2);
 #endif    
@@ -320,6 +334,15 @@ void afp_over_dsi(AFPObj *obj)
         afp_dsi_die(EXITERR_SYS);
     }
 
+    /*  SIGINT - enable max_debug LOGging to /tmp/afpd.PID.XXXXXX */
+    action.sa_handler = afp_dsi_debug;
+    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);
+    }
+
 #ifndef DEBUGGING
     /* tickle handler */
     action.sa_handler = alarm_handler;
@@ -327,6 +350,7 @@ void afp_over_dsi(AFPObj *obj)
     sigaddset(&action.sa_mask, SIGHUP);
     sigaddset(&action.sa_mask, SIGTERM);
     sigaddset(&action.sa_mask, SIGUSR1);
+    sigaddset(&action.sa_mask, SIGINT);
 #ifdef SERVERTEXT
     sigaddset(&action.sa_mask, SIGUSR2);
 #endif    
@@ -342,11 +366,29 @@ void afp_over_dsi(AFPObj *obj)
         child.tickle = 0;
         child.flags &= ~CHILD_SLEEPING;
         dsi_sleep(dsi, 0); /* wake up */
+
         if (reload_request) {
             reload_request = 0;
             load_volumes(child.obj);
         }
 
+        if (debug_request) {
+            char logstr[50];
+            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);
+            }
+
+            sprintf(logstr, "default log_maxdebug /tmp/afpd.%u.XXXXXX", getpid());
+            setuplog(logstr);
+        }
+
         if (cmd == DSIFUNC_TICKLE) {
             /* timer is not every 30 seconds anymore, so we don't get killed on the client side. */
             if ((child.flags & CHILD_DIE))
index deb308a010a3068135b15086a828ac2547561c24..b116bdeb4aa8561f36af89568d5bef7665e4220c 100644 (file)
@@ -358,9 +358,15 @@ void log_setup(const char *filename, enum loglevels loglevel, enum logtypes logt
 
 
     /* Open log file as OPEN_LOGS_AS_UID*/
+
     /* Is it /dev/tty ? */
     if (strcmp(file_configs[logtype].filename, "/dev/tty") == 0) {
         file_configs[logtype].fd = 1; /* stdout */
+
+        /* Does it end in "XXXXXX" ? */
+    } else if (strcmp(file_configs[logtype].filename + strlen(file_configs[logtype].filename) - 6, "XXXXXX") == 0) {
+        /* debug reguest via SIGINT */
+        file_configs[logtype].fd = mkstemp(file_configs[logtype].filename);
     } else {
         process_uid = geteuid();
         if (process_uid) {
index 10cb7277aefaad9f5b2183221fe65c057390bf02..0e735a9d39119104daa90b4af036073214184ba1 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: afpd
 .\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
 .\" Generator: DocBook XSL Stylesheets v1.74.3 <http://docbook.sf.net/>
-.\"      Date: 06 Jan 2004
+.\"      Date: 08 Feb 2010
 .\"    Manual: Netatalk 2.1beta
 .\"    Source: Netatalk 2.1beta
 .\"  Language: English
 .\"
-.TH "AFPD" "8" "06 Jan 2004" "Netatalk 2.1beta" "Netatalk 2.1beta"
+.TH "AFPD" "8" "08 Feb 2010" "Netatalk 2.1beta" "Netatalk 2.1beta"
 .\" -----------------------------------------------------------------
 .\" * set default formatting
 .\" -----------------------------------------------------------------
@@ -190,7 +190,25 @@ SIGHUP
 .RS 4
 Sending a
 \fBSIGHUP\fR
-to afpd will cause it to reload its configuration files\&.
+to afpd will cause it to reload its configuration files\&. The master
+\fBafpd\fR
+process will reread all files while the children
+\fBafpd\fR
+processes will only reread the volume configuration\&.
+.RE
+.PP
+SIGINT
+.RS 4
+Sending a
+\fBSIGINT\fR
+to a child
+\fBafpd\fR
+enables
+\fImax_debug\fR
+logging for this process\&. The log is sent to fhe file
+/tmp/afpd\&.PID\&.XXXXXX\&. Sending another
+\fBSIGINT\fR
+will terminate the process\&.
 .RE
 .PP
 SIGUSR1
@@ -205,9 +223,7 @@ SIGUSR2
 The
 \fBafpd\fR
 process will look in the message directory configured at build time for a file named message\&.pid\&. For each one found, a the contents will be sent as a message to the associated AFP client\&. The file is removed after the message is sent\&. This should only be sent to a child
-\fBafpd\fR\&. Warning: If the \-\-with\-message\-dir option was not used, this will kill the
-\fBafpd\fR
-process
+\fBafpd\fR\&.
 .sp
 To shut down a user\'s
 \fBafpd\fR