]> andersk Git - moira.git/blobdiff - update/update_server.c
Use krb5_error_code for return value of krb5 library functions.
[moira.git] / update / update_server.c
index d93a5dbdb20681d668afb24e4a8cb9c00db24d9f..eeab92cdadda2f29d485d43fd29b1aae47011cdf 100644 (file)
 
 #include <sys/stat.h>
 #include <sys/utsname.h>
+#include <sys/wait.h>
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
 #include <errno.h>
 #include <pwd.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <syslog.h>
 
 #include <des.h>
 #include "update.h"
@@ -33,11 +36,16 @@ int have_authorization = 0;
 des_cblock session;
 int uid = 0;
 
+void child_handler(int signal);
+static void syslog_com_err_proc(const char *progname, long code,
+                               const char *fmt, va_list args);
+
 struct _dt {
   char *str;
   void (*proc)(int, char *);
 } dispatch_table[] = {
   { "AUTH_002", auth_002 },
+  { "AUTH_003", auth_003 },
   { "XFER_002", xfer_002 },
   { "XFER_003", xfer_003 },
   { "EXEC_002", exec_002 },
@@ -52,6 +60,7 @@ int main(int argc, char **argv)
   struct _dt *d;
   struct utsname name;
   int s, conn;
+  struct sigaction sa;
 
   whoami = strrchr(argv[0], '/');
   if (whoami)
@@ -79,6 +88,11 @@ int main(int argc, char **argv)
   umask(0022);
   mr_init();
 
+  sigemptyset(&sa.sa_mask);
+  sa.sa_flags = SA_RESTART;
+  sa.sa_handler = child_handler;
+  sigaction(SIGCHLD, &sa, NULL);
+
   /* If the config file contains a line "user username", the
    * daemon will run with that user's UID.
    */
@@ -107,6 +121,9 @@ int main(int argc, char **argv)
       exit(1);
     }
 
+  set_com_err_hook(syslog_com_err_proc);
+  openlog(whoami, LOG_PID, LOG_DAEMON);
+
   /* now loop waiting for connections */
   while (1)
     {
@@ -210,3 +227,24 @@ void fail(int conn, int err, char *msg)
   close(conn);
   exit(1);
 }
+
+void child_handler(int signal)
+{
+  int status;
+
+  while (waitpid(-1, &status, WNOHANG) > 0)
+    ;
+}
+
+static void syslog_com_err_proc(const char *progname, long code,
+                               const char *fmt, va_list args)
+{
+  char *buf;
+  int bufsiz = 1024;
+
+  buf = malloc(bufsiz + 1);
+  buf[bufsiz] = '\0';
+
+  vsnprintf(buf, bufsiz, fmt, args);
+  syslog(LOG_NOTICE, "%s", buf);
+}
This page took 0.120147 seconds and 4 git commands to generate.