start_stop_daemon: NOMMU fixes, round 2 by Alex Landau <landau_alex@yahoo.com>
[oweals/busybox.git] / networking / isrv_identd.c
index e757d7c29f62eef2d97774a69a98332705cca4b2..84cf6da6a05dab7cd533c9061a57b73b0cd437b9 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 #include <syslog.h>
-#include "busybox.h"
+#include "libbb.h"
 #include "isrv.h"
 
 enum { TIMEOUT = 20 };
@@ -19,7 +19,7 @@ typedef struct identd_buf_t {
        char buf[64 - 2*sizeof(int)];
 } identd_buf_t;
 
-static const char *bogouser = "nobody";
+#define bogouser bb_common_bufsiz1
 
 static int new_peer(isrv_state_t *state, int fd)
 {
@@ -92,6 +92,7 @@ static void inetd_mode(void)
        while (do_rd(0, (void*)&buf) == 0);
 }
 
+int fakeidentd_main(int argc, char **argv);
 int fakeidentd_main(int argc, char **argv)
 {
        enum {
@@ -107,11 +108,14 @@ int fakeidentd_main(int argc, char **argv)
        int fd;
 
        opt = getopt32(argc, argv, "fiwb:", &bind_address);
-       if (optind < argc)
-               bogouser = argv[optind];
+       strcpy(bogouser, "nobody");
+       if (argv[optind])
+               strncpy(bogouser, argv[optind], sizeof(bogouser));
 
        /* Daemonize if no -f and no -i and no -w */
-       bb_sanitize_server_stdio(!(opt & OPT_fiw));
+       if (!(opt & OPT_fiw));
+               bb_daemonize_or_rexec(0, argv);
+
        /* Where to log in inetd modes? "Classic" inetd
         * probably has its stderr /dev/null'ed (we need log to syslog?),
         * but daemontools-like utilities usually expect that children