]> arthur.barton.de Git - netatalk.git/commitdiff
MFH:
authorjmarcus <jmarcus>
Mon, 5 Aug 2002 18:45:22 +0000 (18:45 +0000)
committerjmarcus <jmarcus>
Mon, 5 Aug 2002 18:45:22 +0000 (18:45 +0000)
* Allow afpd debugging to be enabled at runtime by sending the afpd
  process 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
* Use server name (if not NULL) for the SLP URL
* Update documentation accordingly.
* Add corresponding NEWS entries.

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 a562bac1a93904467ab7b6c1afa831940df2023c..af6945bc932a1181a2195520e50b6e18bddb642d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,11 @@ Changes from 1.5.3
 * FIX: Problems with unexpected EOF when reading files on a ddp connection
        Photoshop, old finder.
 * FIX: --with-nls-dir option does now work
+* NEW: Allow afpd debugging to be enabled by sending the afpd process
+       a SIGUSR1.
+* NEW: Allow SLP to be disabled per afpd process by adding a new -noslp flag
+       to afpd.conf.
+* FIX: Use server name (if not NULL) for the SLP URL.
 
 Changes from 1.5.2
 ==================
index 7c1313811a91569f311b9788e19e9d2fdfb7546a..5a3b8b4e22050dd1377e25f6ce6dc62c882adc25 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 989cdb6091adcbb18f3ce00ac973ef181666d17e..3ec40a11cfbc30eb83c8bea9dd9fa082701ae803 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_config.c,v 1.7.2.4 2002-03-12 14:19:46 srittau Exp $
+ * $Id: afp_config.c,v 1.7.2.5 2002-08-05 18:45:24 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) {
         syslog(LOG_ERR, "dsi_cleanup: Error opening SRVLOC handle");
@@ -281,6 +286,7 @@ static AFPConfig *DSIConfigInit(const struct afp_options *options,
     SLPHandle hslp;
     struct servent *afpovertcp;
     int afp_port = 548;
+    char *srvloc_hostname;
 #endif /* USE_SRVLOC */
 
     if ((config = (AFPConfig *) calloc(1, sizeof(AFPConfig))) == NULL) {
@@ -308,53 +314,61 @@ static AFPConfig *DSIConfigInit(const struct afp_options *options,
     }
 
 #ifdef USE_SRVLOC
-    err = SLPOpen("en", SLP_FALSE, &hslp);
-    if (err != SLP_OK) {
-        syslog(LOG_ERR, "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");
-    if (afpovertcp != NULL) {
-       afp_port = afpovertcp->s_port;
-    }
-    if (strlen(options->hostname) > (sizeof(srvloc_url) - strlen(inet_ntoa(dsi->server.sin_addr)) - 21)) {
-        syslog(LOG_ERR, "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), options->hostname);
-    }
-    else {
-        sprintf(srvloc_url, "afp://%s:%d/?NAME=%s", inet_ntoa(dsi->server.sin_addr), ntohs(dsi->server.sin_port), options->hostname);
-    }
-
-    err = SLPReg(hslp,
-                 srvloc_url,
-                 SLP_LIFETIME_MAXIMUM,
-                 "",
-                 "",
-                 SLP_TRUE,
-                 SRVLOC_callback,
-                 &callbackerr);
-    if (err != SLP_OK) {
-        syslog(LOG_ERR, "DSIConfigInit: Error registering %s with SRVLOC", srvloc_url);
-        goto srvloc_reg_err;
-    }
-
-    if (callbackerr != SLP_OK) {
-        syslog(LOG_ERR, "DSIConfigInit: Error in callback trying to register %s with SRVLOC", srvloc_url);
-        goto srvloc_reg_err;
-    }
-
-    syslog(LOG_INFO, "Sucessfully registered %s with SRVLOC", srvloc_url);
+    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) {
+           syslog( LOG_ERR, "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 : (char *)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)) {
+           syslog( LOG_ERR, "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) {
+           syslog( LOG_ERR, "DSIConfigInit: Error registering %s with SRVLOC", srvloc_url);
+           srvloc_url[0] = '\0';
+           goto srvloc_reg_err;
+       }
+
+       if (callbackerr != SLP_OK) {
+           syslog( LOG_ERR, "DSIConfigInit: Error in callback trying to register %s with SRVLOC", srvloc_url);
+           srvloc_url[0] = '\0';
+           goto srvloc_reg_err;
+       }
+
+       syslog(LOG_INFO, "Sucessfully registered %s with SRVLOC", srvloc_url);
 
 srvloc_reg_err:
-    SLPClose(hslp);
+       SLPClose(hslp);
+    }
 #endif /* USE_SRVLOC */
 
 
index d79068d7a7f8870cefa5b7acdce0b72563aca844..55bc9d7f97b13e1856ccdbc65c94866354014376 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_dsi.c,v 1.9.2.4 2002-01-23 18:34:14 jmarcus Exp $
+ * $Id: afp_dsi.c,v 1.9.2.5 2002-08-05 18:45:24 jmarcus Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -133,6 +133,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)
 {
@@ -182,6 +199,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 ) {
+        syslog( LOG_ERR, "afp_over_dsi: sigaction: %s", strerror(errno) );
+        afp_dsi_die(1);
+    }
+
     /* tickle handler */
     action.sa_handler = alarm_handler;
     sigemptyset(&action.sa_mask);
index 2af63d6b1b782ddb155f58bf6390669363e1946b..edd859f89ddf153b0db3025883838f3fb73cb790 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_options.c,v 1.13.2.7 2002-03-12 14:21:18 srittau Exp $
+ * $Id: afp_options.c,v 1.13.2.8 2002-08-05 18:45:24 jmarcus Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -169,7 +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;
     if (strstr(buf, " -uservolfirst"))
index 5e020f4243c2e8d3247fe46e41de1416f105000f..2f4a24c6c2b4f35088863d34538f802b65e8e9f8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: globals.h,v 1.6.2.5 2002-02-11 17:46:40 jmarcus Exp $
+ * $Id: globals.h,v 1.6.2.6 2002-08-05 18:45:24 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..c622e32f6d17ccc9cfb6ae3f205535ba9cf5c56d 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.2.2.1 2002-08-05 18:45:24 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.