]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/afp_dsi.c
General fixes for logging, error reporting, this, that, and the other thing.
[netatalk.git] / etc / afpd / afp_dsi.c
index 79cbc8993cf6a241b3392a5e96b0e1e600050d01..7903e5113ba4de8e30cf733ceec0f938cc90c7e2 100644 (file)
@@ -50,6 +50,9 @@ static __inline__ void afp_dsi_close(AFPObj *obj)
       (*obj->logout)();
                      
     dsi_close(dsi);
+
+    /* UAM had syslog control; afpd needs to reassert itself */
+    openlog( "afpd", LOG_NDELAY|LOG_PID, LOG_DAEMON);
     syslog(LOG_INFO, "%.2fKB read, %.2fKB written",
           dsi->read_count/1024.0, dsi->write_count/1024.0);
 }
@@ -59,10 +62,15 @@ static void afp_dsi_die(int sig)
 {
     dsi_attention(child.obj->handle, AFPATTN_SHUTDOWN);
     afp_dsi_close(child.obj);
-    if (sig == SIGTERM || sig == SIGALRM)
+    if (sig) /* if no signal, assume dieing because logins are disabled &
+       don't log it (maintenance mode)*/
+      syslog (LOG_INFO, "Connection terminated");
+    if (sig == SIGTERM || sig == SIGALRM) {
       exit( 0 );
-    else
+    }
+    else {
       exit(sig);
+    }
 }
 
 static void afp_dsi_timedown()
@@ -97,6 +105,14 @@ static void afp_dsi_timedown()
     }
 }
 
+#ifdef SERVERTEXT
+static void afp_dsi_getmesg (int sig)
+{
+      readmessage();
+      dsi_attention(child.obj->handle, AFPATTN_MESG | AFPATTN_TIME(5));
+}
+#endif
+
 static void alarm_handler()
 {
   /* if we're in the midst of processing something,
@@ -146,6 +162,18 @@ void afp_over_dsi(AFPObj *obj)
     afp_dsi_die(1);
   }
 
+#ifdef SERVERTEXT
+  /* Added for server message support */
+  action.sa_handler = afp_dsi_getmesg;
+  sigemptyset( &action.sa_mask );
+  sigaddset(&action.sa_mask, SIGUSR2);
+  action.sa_flags = SA_RESTART;
+  if ( sigaction( SIGUSR2, &action, 0) < 0 ) {
+    syslog( LOG_ERR, "afp_over_dsi: sigaction: %m" );
+    afp_dsi_die(1);
+  }
+#endif
+
   /* tickle handler */
   action.sa_handler = alarm_handler;
   sigemptyset(&action.sa_mask);