]> arthur.barton.de Git - netatalk.git/commitdiff
* Allow afpd debugging to be enabled at runtime by sending the afpd process
authorjmarcus <jmarcus>
Fri, 3 May 2002 22:51:32 +0000 (22:51 +0000)
committerjmarcus <jmarcus>
Fri, 3 May 2002 22:51:32 +0000 (22:51 +0000)
  a SIGUSR1.  stdout will be redirected to a temp file.

* Allow SLP to be disabled per afpd process by adding a new -noslp flag to
  afpd.conf

* Update documentation accordingly.

Submitted by: Glenn Trewitt <glenn@trewitt.org>

NEWS
config/afpd.conf.tmpl
etc/afpd/afp_config.c
etc/afpd/afp_dsi.c
etc/afpd/afp_options.c
etc/afpd/globals.h
man/man5/afpd.conf.5.tmpl
man/man8/afpd.8.tmpl

diff --git a/NEWS b/NEWS
index d7e08b7dd1148b384587ae52d7cee081f8e9e864..dc6be34cbc596c6512a3cdb58bbcbcf3720c0df9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+Changes from 1.5.3
+==================
+
+* NEW: Add the ability to enable debugging at runtime by sending afpd a
+       SIGUSR1.
+* NEW: Add a -noslp option to disable SLP per afpd instance.
+      
 Changes from 1.5.2
 ==================
 
index 7c1313811a91569f311b9788e19e9d2fdfb7546a..7a2b19ae3989c7cfcfb442752f89c89b2b84cb6d 100644 (file)
@@ -49,6 +49,8 @@
 #                         if you don't want the proxy server to act as
 #                         a ddp server as well, set -uamlist to an
 #                        empty string.
+#     -noslp              Don't register this server with the Service
+#                        Location Protocol.
 #
 #
 #   Authentication Methods:
index e5f1f63362a7e9890934e4d9d5e981177fb9a3e6..6842f54bfdf3843e93de9a444b80186a1fc95983 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_config.c,v 1.19 2002-04-02 02:41:40 sibaz Exp $
+ * $Id: afp_config.c,v 1.20 2002-05-03 22:51:33 jmarcus Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
@@ -107,6 +107,11 @@ static void dsi_cleanup(const AFPConfig *config)
     SLPError err;
     SLPError callbackerr;
     SLPHandle hslp;
+
+    /*  Do nothing if we didn't register.  */
+    if (srvloc_url[0] == '\0')
+        return;
+
     err = SLPOpen("en", SLP_FALSE, &hslp);
     if (err != SLP_OK) {
         LOG(log_error, logtype_afpd, "dsi_cleanup: Error opening SRVLOC handle");
@@ -309,54 +314,62 @@ static AFPConfig *DSIConfigInit(const struct afp_options *options,
     }
 
 #ifdef USE_SRVLOC
-    err = SLPOpen("en", SLP_FALSE, &hslp);
-    if (err != SLP_OK) {
-        LOG(log_error, logtype_afpd, "DSIConfigInit: Error opening SRVLOC handle");
-        goto srvloc_reg_err;
-    }
-
-    /* XXX We don't want to tack on the port number if we don't have to.  Why?
-     * Well, this seems to break MacOS < 10.  If the user _really_ wants to
-     * use a non-default port, they can, but be aware, this server might not
-     * show up int the Network Browser. */
-    afpovertcp = getservbyname("afpovertcp", "tcp");
+    srvloc_url[0] = '\0';      /*  Mark that we haven't registered.  */
+    if (!(options->flags & OPTION_NOSLP)) {
+       err = SLPOpen("en", SLP_FALSE, &hslp);
+       if (err != SLP_OK) {
+           LOG(log_error, logtype_afpd, "DSIConfigInit: Error opening SRVLOC handle");
+           goto srvloc_reg_err;
+       }
+
+       /* XXX We don't want to tack on the port number if we don't have to.
+        * Why?
+        * Well, this seems to break MacOS < 10.  If the user _really_ wants to
+        * use a non-default port, they can, but be aware, this server might
+        * not show up int the Network Browser.
+        */
+       afpovertcp = getservbyname("afpovertcp", "tcp");
        srvloc_hostname = (options->server ? options->server : options->hostname);
-    if (afpovertcp != NULL) {
-        afp_port = afpovertcp->s_port;
-    }
-    if (strlen(srvloc_hostname) > (sizeof(srvloc_url) - strlen(inet_ntoa(dsi->server.sin_addr)) - 21)) {
-        LOG(log_error, logtype_afpd, "DSIConfigInit: Hostname is too long for SRVLOC");
-        goto srvloc_reg_err;
-    }
-    if (dsi->server.sin_port == afp_port) {
-        sprintf(srvloc_url, "afp://%s/?NAME=%s", inet_ntoa(dsi->server.sin_addr), srvloc_hostname);
-    }
-    else {
-        sprintf(srvloc_url, "afp://%s:%d/?NAME=%s", inet_ntoa(dsi->server.sin_addr), ntohs(dsi->server.sin_port), srvloc_hostname);
-    }
-
-    err = SLPReg(hslp,
-                 srvloc_url,
-                 SLP_LIFETIME_MAXIMUM,
-                 "",
-                 "",
-                 SLP_TRUE,
-                 SRVLOC_callback,
-                 &callbackerr);
-    if (err != SLP_OK) {
-        LOG(log_error, logtype_afpd, "DSIConfigInit: Error registering %s with SRVLOC", srvloc_url);
-        goto srvloc_reg_err;
-    }
-
-    if (callbackerr != SLP_OK) {
-        LOG(log_error, logtype_afpd, "DSIConfigInit: Error in callback trying to register %s with SRVLOC", srvloc_url);
-        goto srvloc_reg_err;
-    }
-
-    LOG(log_info, logtype_afpd, "Sucessfully registered %s with SRVLOC", srvloc_url);
+       if (afpovertcp != NULL) {
+           afp_port = afpovertcp->s_port;
+       }
+       if (strlen(srvloc_hostname) > (sizeof(srvloc_url) - strlen(inet_ntoa(dsi->server.sin_addr)) - 21)) {
+           LOG(log_error, logtype_afpd, "DSIConfigInit: Hostname is too long for SRVLOC");
+           srvloc_url[0] = '\0';
+           goto srvloc_reg_err;
+       }
+       if (dsi->server.sin_port == afp_port) {
+           sprintf(srvloc_url, "afp://%s/?NAME=%s", inet_ntoa(dsi->server.sin_addr), srvloc_hostname);
+       }
+       else {
+           sprintf(srvloc_url, "afp://%s:%d/?NAME=%s", inet_ntoa(dsi->server.sin_addr), ntohs(dsi->server.sin_port), srvloc_hostname);
+       }
+
+       err = SLPReg(hslp,
+                    srvloc_url,
+                    SLP_LIFETIME_MAXIMUM,
+                    "",
+                    "",
+                    SLP_TRUE,
+                    SRVLOC_callback,
+                    &callbackerr);
+       if (err != SLP_OK) {
+           LOG(log_error, logtype_afpd, "DSIConfigInit: Error registering %s with SRVLOC", srvloc_url);
+           srvloc_url[0] = '\0';
+           goto srvloc_reg_err;
+       }
+
+       if (callbackerr != SLP_OK) {
+           LOG(log_error, logtype_afpd, "DSIConfigInit: Error in callback trying to register %s with SRVLOC", srvloc_url);
+           srvloc_url[0] = '\0';
+           goto srvloc_reg_err;
+       }
+
+       LOG(log_info, logtype_afpd, "Sucessfully registered %s with SRVLOC", srvloc_url);
 
 srvloc_reg_err:
-    SLPClose(hslp);
+       SLPClose(hslp);
+    }
 #endif /* USE_SRVLOC */
 
 
index 5c6ef680f7db0ed49a0938eec67c5d8a79996f95..97f3d312a6478936e157cc334350f8f0f0f99d5f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_dsi.c,v 1.20 2002-03-24 01:23:40 sibaz Exp $
+ * $Id: afp_dsi.c,v 1.21 2002-05-03 22:51:33 jmarcus Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -134,6 +134,23 @@ static void alarm_handler()
     }
 }
 
+
+/*
+ *  Signal handler for SIGUSR1 - set the debug flag and 
+ *  redirect stdout to <tmpdir>/afpd-debug-<pid>.
+ */
+void afp_set_debug (int sig)
+{
+    char       fname[MAXPATHLEN];
+
+    snprintf(fname, MAXPATHLEN-1, "%safpd-debug-%d", P_tmpdir, getpid());
+    freopen(fname, "w", stdout);
+    child.obj->options.flags |= OPTION_DEBUG;
+
+    return;
+}
+
+
 /* afp over dsi. this never returns. */
 void afp_over_dsi(AFPObj *obj)
 {
@@ -183,6 +200,16 @@ void afp_over_dsi(AFPObj *obj)
     }
 #endif /* SERVERTEXT */
 
+    /*  SIGUSR1 - set "debug" flag on this process.  */
+    action.sa_handler = afp_set_debug;
+    sigemptyset( &action.sa_mask );
+    sigaddset(&action.sa_mask, SIGUSR1);
+    action.sa_flags = SA_RESTART;
+    if ( sigaction( SIGUSR1, &action, 0) < 0 ) {
+        LOG(log_error, logtype_afpd, "afp_over_dsi: sigaction: %s", strerror(errno) );
+        afp_dsi_die(1);
+    }
+
     /* tickle handler */
     action.sa_handler = alarm_handler;
     sigemptyset(&action.sa_mask);
index 36e7c35fbaa282c5712a5a3eeda40ea1399288f2..0bc77f3520ee290c3957e222fa5a52de13d28a1b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_options.c,v 1.23 2002-04-02 02:45:28 sibaz Exp $
+ * $Id: afp_options.c,v 1.24 2002-05-03 22:51:34 jmarcus Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -169,6 +169,10 @@ int afp_options_parseline(char *buf, struct afp_options *options)
     /* parse toggles */
     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, " -nouservolfirst"))
         options->flags &= ~OPTION_USERVOLFIRST;
index 3afcff9dc1f38686c4685e1b654120fc20910ded..173930df13251848648a47966e68ec9bcbaec232 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: globals.h,v 1.11 2002-03-16 20:38:09 jmarcus Exp $
+ * $Id: globals.h,v 1.12 2002-05-03 22:51:34 jmarcus Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -36,6 +36,7 @@
 #define OPTION_NOUSERVOL     (1 << 2)
 #define OPTION_PROXY         (1 << 3)
 #define OPTION_CUSTOMICON    (1 << 4)
+#define OPTION_NOSLP         (1 << 5)
 
 /* a couple of these options could get stuck in unions to save
  * space. */
index 18a2aa89e6b765cf421327b091635ca9def89374..ce20135ae656b9d00342e2c820e6088a2ba26e77 100644 (file)
@@ -1,4 +1,4 @@
-.\" $Id: afpd.conf.5.tmpl,v 1.2 2001-06-26 23:58:32 srittau Exp $
+.\" $Id: afpd.conf.5.tmpl,v 1.3 2002-05-03 22:51:34 jmarcus Exp $
 .TH afpd.conf 5 "28 September 2000" "netatalk 1.5"
 .UC 4
 .SH NAME
@@ -164,6 +164,12 @@ This specifoes the DSI server quantum. The minimum value is 1 MB. The
 maximum value is 0xFFFFFFFFF. If you specify a value that is out of
 range, the default value will be set (which is the minimum).
 
+.TP
+.B -noslp
+Do not register this server using the Service Location Protocol (if SLP
+support was compiled in).  This is useful if you are running multiple
+servers and want one to be hidden, perhaps because it is advertised elsewhere.
+
 .TP
 .I Miscellaneous Options
 
index be235032950a1ae8c89dddaadca2428cc056a3b7..8fb097df4224b6111449fa392a0d4e1ac2e5f9f1 100644 (file)
@@ -246,6 +246,51 @@ parses the files with either end of line character.
 .LP
 Unix filenames that are longer than 31 characters are inaccessible from
 the Macintosh.
+
+.SH SIGNALS
+Signals that are sent to the main
+.B afpd
+process are propagated to the children, so all will be affected.
+.TP 13
+.B SIGHUP
+The
+.B afpd
+process will send the message "The server is going down for maintenance."
+to the client and shut itself down in 5 minutes.  New connections are not
+allowed.  If this is sent to a child
+.BR afpd ,
+the other children are not affected.  However, the main process will still
+exit, disabling all new connections.
+.TP 13
+.B SIGUSR1
+If the
+.B --with-message-dir
+configure option was used, the
+.B afpd
+process will set the
+.B debug
+option and redirect the messages to
+.RI /var/tmp/afpd-debug- pid .
+This should only be sent to a child
+.BR afpd .
+.B Warning:
+If the
+.B --with-message-dir
+option was not used, this will kill the
+.B afpd
+process.
+
+.TP 13
+.B SIGUSR2
+The
+.B afpd
+process will look in the
+.I msg
+directory for a file named
+.RI 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.
+
 .SH FILES
 .TP 20
 .B :ETCDIR:/AppleVolumes.default
@@ -256,6 +301,12 @@ list of volumes to offer all users
 .TP 20
 .B ~/AppleVolumes
 user's list of volumes to mount
+.TP 20
+.BI :ETCDIR:/msg/message. pid
+contains messages to be sent to users.
+.TP 20
+.BI /var/tmp/afpd-debug- pid
+contains debug output, if triggered.
 .SH BUGS
 A few calls from the AFP specification are not implemented, because the
 Macintosh does not use them.