#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>
+#ifdef HAVE_KRB4
#include <des.h>
+#endif
#include "update.h"
RCSID("$Header$");
char *whoami, *hostname;
int have_authorization = 0;
+#ifdef HAVE_KRB4
des_cblock session;
+#endif
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 },
struct _dt *d;
struct utsname name;
int s, conn;
+ struct sigaction sa;
whoami = strrchr(argv[0], '/');
if (whoami)
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.
*/
exit(1);
}
+ set_com_err_hook(syslog_com_err_proc);
+ openlog(whoami, LOG_PID, LOG_DAEMON);
+
/* now loop waiting for connections */
while (1)
{
if (config_lookup("nofork") || (fork() <= 0))
break;
+
+ close(conn);
}
/* If the config file contains a line "chroot /dir/name", the
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[BUFSIZ + 1];
+
+ buf[BUFSIZ] = '\0';
+
+ vsnprintf(buf, BUFSIZ, fmt, args);
+ syslog(LOG_NOTICE, "%s: %s %s", progname ? progname : "",
+ code ? error_message(code) : "", buf);
+}