53cb4ba5e9c329864143304908e1374bd40dbd73
[oweals/busybox.git] / sysklogd / syslogd.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * Mini syslogd implementation for busybox
4  *
5  * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6  *
7  * Copyright (C) 2000 by Karl M. Hegbloom <karlheg@debian.org>
8  *
9  * "circular buffer" Copyright (C) 2001 by Gennady Feldman <gfeldman@gena01.com>
10  *
11  * Maintainer: Gennady Feldman <gfeldman@gena01.com> as of Mar 12, 2001
12  *
13  * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
14  */
15
16 #include "busybox.h"
17 #include <paths.h>
18 #include <sys/un.h>
19
20 /* SYSLOG_NAMES defined to pull some extra junk from syslog.h */
21 #define SYSLOG_NAMES
22 #include <sys/syslog.h>
23 #include <sys/uio.h>
24
25 #define DEBUG 0
26
27 /* Path for the file where all log messages are written */
28 static const char *logFilePath = "/var/log/messages";
29 static int logFD = -1;
30
31 /* This is not very useful, is bloat, and broken:
32  * can deadlock if alarmed to make MARK while writing to IPC buffer
33  * (semaphores are down but do_mark routine tries to down them again) */
34 #ifdef SYSLOGD_MARK
35 /* interval between marks in seconds */
36 static int markInterval = 20 * 60;
37 #endif
38
39 /* level of messages to be locally logged */
40 static int logLevel = 8;
41
42 /* localhost's name */
43 static char localHostName[64];
44
45 #if ENABLE_FEATURE_ROTATE_LOGFILE
46 /* max size of message file before being rotated */
47 static unsigned logFileSize = 200 * 1024;
48 /* number of rotated message files */
49 static unsigned logFileRotate = 1;
50 static unsigned curFileSize;
51 static smallint isRegular;
52 #endif
53
54 #if ENABLE_FEATURE_REMOTE_LOG
55 #include <netinet/in.h>
56 /* udp socket for logging to remote host */
57 static int remoteFD = -1;
58 static len_and_sockaddr* remoteAddr;
59 #endif
60
61 /* We are using bb_common_bufsiz1 for buffering: */
62 enum { MAX_READ = (BUFSIZ/6) & ~0xf };
63 /* We recv into RECVBUF... (size: MAX_READ ~== BUFSIZ/6) */
64 #define RECVBUF  bb_common_bufsiz1
65 /* ...then copy to PARSEBUF, escaping control chars */
66 /* (can grow x2 max ~== BUFSIZ/3) */
67 #define PARSEBUF (bb_common_bufsiz1 + MAX_READ)
68 /* ...then sprintf into PRINTBUF, adding timestamp (15 chars),
69  * host (64), fac.prio (20) to the message */
70 /* (growth by: 15 + 64 + 20 + delims = ~110) */
71 #define PRINTBUF (bb_common_bufsiz1 + 3*MAX_READ)
72 /* totals: BUFSIZ == BUFSIZ/6 + BUFSIZ/3 + (BUFSIZ/3+BUFSIZ/6)
73  * -- we have BUFSIZ/6 extra at the ent of PRINTBUF
74  * which covers needed ~110 extra bytes (and much more) */
75
76
77 /* Options */
78 enum {
79         OPTBIT_mark = 0, // -m
80         OPTBIT_nofork, // -n
81         OPTBIT_outfile, // -O
82         OPTBIT_loglevel, // -l
83         OPTBIT_small, // -S
84         USE_FEATURE_ROTATE_LOGFILE(OPTBIT_filesize   ,) // -s
85         USE_FEATURE_ROTATE_LOGFILE(OPTBIT_rotatecnt  ,) // -b
86         USE_FEATURE_REMOTE_LOG(    OPTBIT_remote     ,) // -R
87         USE_FEATURE_REMOTE_LOG(    OPTBIT_localtoo   ,) // -L
88         USE_FEATURE_IPC_SYSLOG(    OPTBIT_circularlog,) // -C
89
90         OPT_mark        = 1 << OPTBIT_mark    ,
91         OPT_nofork      = 1 << OPTBIT_nofork  ,
92         OPT_outfile     = 1 << OPTBIT_outfile ,
93         OPT_loglevel    = 1 << OPTBIT_loglevel,
94         OPT_small       = 1 << OPTBIT_small   ,
95         OPT_filesize    = USE_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_filesize   )) + 0,
96         OPT_rotatecnt   = USE_FEATURE_ROTATE_LOGFILE((1 << OPTBIT_rotatecnt  )) + 0,
97         OPT_remotelog   = USE_FEATURE_REMOTE_LOG(    (1 << OPTBIT_remote     )) + 0,
98         OPT_locallog    = USE_FEATURE_REMOTE_LOG(    (1 << OPTBIT_localtoo   )) + 0,
99         OPT_circularlog = USE_FEATURE_IPC_SYSLOG(    (1 << OPTBIT_circularlog)) + 0,
100 };
101 #define OPTION_STR "m:nO:l:S" \
102         USE_FEATURE_ROTATE_LOGFILE("s:" ) \
103         USE_FEATURE_ROTATE_LOGFILE("b:" ) \
104         USE_FEATURE_REMOTE_LOG(    "R:" ) \
105         USE_FEATURE_REMOTE_LOG(    "L"  ) \
106         USE_FEATURE_IPC_SYSLOG(    "C::")
107 #define OPTION_DECL *opt_m, *opt_l \
108         USE_FEATURE_ROTATE_LOGFILE(,*opt_s) \
109         USE_FEATURE_ROTATE_LOGFILE(,*opt_b) \
110         USE_FEATURE_REMOTE_LOG(    ,*opt_R) \
111         USE_FEATURE_IPC_SYSLOG(    ,*opt_C = NULL)
112 #define OPTION_PARAM &opt_m, &logFilePath, &opt_l \
113         USE_FEATURE_ROTATE_LOGFILE(,&opt_s) \
114         USE_FEATURE_ROTATE_LOGFILE(,&opt_b) \
115         USE_FEATURE_REMOTE_LOG(    ,&opt_R) \
116         USE_FEATURE_IPC_SYSLOG(    ,&opt_C)
117
118
119 /* circular buffer variables/structures */
120 #if ENABLE_FEATURE_IPC_SYSLOG
121
122
123 #if CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE < 4
124 #error Sorry, you must set the syslogd buffer size to at least 4KB.
125 #error Please check CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE
126 #endif
127
128 #include <sys/ipc.h>
129 #include <sys/sem.h>
130 #include <sys/shm.h>
131
132 /* our shared key */
133 #define KEY_ID ((long)0x414e4547) /* "GENA" */
134
135 // Semaphore operation structures
136 static struct shbuf_ds {
137         int32_t size;   // size of data written
138         int32_t head;   // start of message list
139         int32_t tail;   // end of message list
140         char data[1];   // data/messages
141 } *shbuf;               // shared memory pointer
142
143 static int shmid = -1;   // ipc shared memory id
144 static int s_semid = -1; // ipc semaphore id
145 static int shm_size = ((CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE)*1024);   // default shm size
146
147 static void ipcsyslog_cleanup(void)
148 {
149         if (shmid != -1) {
150                 shmdt(shbuf);
151         }
152         if (shmid != -1) {
153                 shmctl(shmid, IPC_RMID, NULL);
154         }
155         if (s_semid != -1) {
156                 semctl(s_semid, 0, IPC_RMID, 0);
157         }
158 }
159
160 static void ipcsyslog_init(void)
161 {
162         if (DEBUG)
163                 printf("shmget(%lx, %d,...)\n", KEY_ID, shm_size);
164
165         shmid = shmget(KEY_ID, shm_size, IPC_CREAT | 1023);
166         if (shmid == -1) {
167                 bb_perror_msg_and_die("shmget");
168         }
169
170         shbuf = shmat(shmid, NULL, 0);
171         if (!shbuf) {
172                 bb_perror_msg_and_die("shmat");
173         }
174
175         shbuf->size = shm_size - offsetof(struct shbuf_ds, data);
176         shbuf->head = shbuf->tail = 0;
177
178         // we'll trust the OS to set initial semval to 0 (let's hope)
179         s_semid = semget(KEY_ID, 2, IPC_CREAT | IPC_EXCL | 1023);
180         if (s_semid == -1) {
181                 if (errno == EEXIST) {
182                         s_semid = semget(KEY_ID, 2, 0);
183                         if (s_semid != -1)
184                                 return;
185                 }
186                 bb_perror_msg_and_die("semget");
187         }
188 }
189
190 /* Write message to shared mem buffer */
191 static void log_to_shmem(const char *msg, int len)
192 {
193         /* Why libc insists on these being rw? */
194         static struct sembuf SMwup[1] = { {1, -1, IPC_NOWAIT} };
195         static struct sembuf SMwdn[3] = { {0, 0}, {1, 0}, {1, +1} };
196
197         int old_tail, new_tail;
198         char *c;
199
200         if (semop(s_semid, SMwdn, 3) == -1) {
201                 bb_perror_msg_and_die("SMwdn");
202         }
203
204         /* Circular Buffer Algorithm:
205          * --------------------------
206          * tail == position where to store next syslog message.
207          * head == position of next message to retrieve ("print").
208          * if head == tail, there is no "unprinted" messages left.
209          * head is typically advanced by separate "reader" program,
210          * but if there isn't one, we have to do it ourself.
211          * messages are NUL-separated.
212          */
213         len++; /* length with NUL included */
214  again:
215         old_tail = shbuf->tail;
216         new_tail = old_tail + len;
217         if (new_tail < shbuf->size) {
218                 /* No need to move head if shbuf->head <= old_tail,
219                  * else... */
220                 if (old_tail < shbuf->head && shbuf->head <= new_tail) {
221                         /* ...need to move head forward */
222                         c = memchr(shbuf->data + new_tail, '\0',
223                                            shbuf->size - new_tail);
224                         if (!c) /* no NUL ahead of us, wrap around */
225                                 c = memchr(shbuf->data, '\0', old_tail);
226                         if (!c) { /* still nothing? point to this msg... */
227                                 shbuf->head = old_tail;
228                         } else {
229                                 /* convert pointer to offset + skip NUL */
230                                 shbuf->head = c - shbuf->data + 1;
231                         }
232                 }
233                 /* store message, set new tail */
234                 memcpy(shbuf->data + old_tail, msg, len);
235                 shbuf->tail = new_tail;
236         } else {
237                 /* we need to break up the message and wrap it around */
238                 /* k == available buffer space ahead of old tail */
239                 int k = shbuf->size - old_tail - 1;
240                 if (shbuf->head > old_tail) {
241                         /* we are going to overwrite head, need to
242                          * move it out of the way */
243                         c = memchr(shbuf->data, '\0', old_tail);
244                         if (!c) { /* nothing? point to this msg... */
245                                 shbuf->head = old_tail;
246                         } else { /* convert pointer to offset + skip NUL */
247                                 shbuf->head = c - shbuf->data + 1;
248                         }
249                 }
250                 /* copy what fits to the end of buffer, and repeat */
251                 memcpy(shbuf->data + old_tail, msg, k);
252                 msg += k;
253                 len -= k;
254                 shbuf->tail = 0;
255                 goto again;
256         }
257         if (semop(s_semid, SMwup, 1) == -1) {
258                 bb_perror_msg_and_die("SMwup");
259         }
260         if (DEBUG)
261                 printf("head:%d tail:%d\n", shbuf->head, shbuf->tail);
262 }
263 #else
264 void ipcsyslog_cleanup(void);
265 void ipcsyslog_init(void);
266 void log_to_shmem(const char *msg);
267 #endif /* FEATURE_IPC_SYSLOG */
268
269
270 /* Print a message to the log file. */
271 static void log_locally(char *msg)
272 {
273         static time_t last;
274         struct flock fl;
275         int len = strlen(msg);
276
277 #if ENABLE_FEATURE_IPC_SYSLOG
278         if ((option_mask32 & OPT_circularlog) && shbuf) {
279                 log_to_shmem(msg, len);
280                 return;
281         }
282 #endif
283         if (logFD >= 0) {
284                 time_t cur;
285                 time(&cur);
286                 if (last != cur) {
287                         last = cur; /* reopen log file every second */
288                         close(logFD);
289                         goto reopen;
290                 }
291         } else {
292  reopen:
293                 logFD = device_open(logFilePath, O_WRONLY | O_CREAT
294                                         | O_NOCTTY | O_APPEND | O_NONBLOCK);
295                 if (logFD < 0) {
296                         /* cannot open logfile? - print to /dev/console then */
297                         int fd = device_open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK);
298                         if (fd < 0)
299                                 fd = 2; /* then stderr, dammit */
300                         full_write(fd, msg, len);
301                         if (fd != 2)
302                                 close(fd);
303                         return;
304                 }
305 #if ENABLE_FEATURE_ROTATE_LOGFILE
306                 {
307                 struct stat statf;
308
309                 isRegular = (fstat(logFD, &statf) == 0 && (statf.st_mode & S_IFREG));
310                 /* bug (mostly harmless): can wrap around if file > 4gb */
311                 curFileSize = statf.st_size;
312                 }
313 #endif
314         }
315
316         fl.l_whence = SEEK_SET;
317         fl.l_start = 0;
318         fl.l_len = 1;
319         fl.l_type = F_WRLCK;
320         fcntl(logFD, F_SETLKW, &fl);
321
322 #if ENABLE_FEATURE_ROTATE_LOGFILE
323         if (logFileSize && isRegular && curFileSize > logFileSize) {
324                 if (logFileRotate) { /* always 0..99 */
325                         int i = strlen(logFilePath) + 3 + 1;
326                         char oldFile[i];
327                         char newFile[i];
328                         i = logFileRotate - 1;
329                         /* rename: f.8 -> f.9; f.7 -> f.8; ... */
330                         while (1) {
331                                 sprintf(newFile, "%s.%d", logFilePath, i);
332                                 if (i == 0) break;
333                                 sprintf(oldFile, "%s.%d", logFilePath, --i);
334                                 rename(oldFile, newFile);
335                         }
336                         /* newFile == "f.0" now */
337                         rename(logFilePath, newFile);
338                         fl.l_type = F_UNLCK;
339                         fcntl(logFD, F_SETLKW, &fl);
340                         close(logFD);
341                         goto reopen;
342                 }
343                 ftruncate(logFD, 0);
344         }
345         curFileSize +=
346 #endif
347                         full_write(logFD, msg, len);
348         fl.l_type = F_UNLCK;
349         fcntl(logFD, F_SETLKW, &fl);
350 }
351
352 static void parse_fac_prio_20(int pri, char *res20)
353 {
354         CODE *c_pri, *c_fac;
355
356         if (pri != 0) {
357                 c_fac = facilitynames;
358                 while (c_fac->c_name) {
359                         if (c_fac->c_val != (LOG_FAC(pri) << 3)) {
360                                 c_fac++; continue;
361                         }
362                         /* facility is found, look for prio */
363                         c_pri = prioritynames;
364                         while (c_pri->c_name) {
365                                 if (c_pri->c_val != LOG_PRI(pri)) {
366                                         c_pri++; continue;
367                                 }
368                                 snprintf(res20, 20, "%s.%s",
369                                                 c_fac->c_name, c_pri->c_name);
370                                 return;
371                         }
372                         /* prio not found, bail out */
373                         break;
374                 }
375                 snprintf(res20, 20, "<%d>", pri);
376         }
377 }
378
379 /* len parameter is used only for "is there a timestamp?" check.
380  * NB: some callers cheat and supply 0 when they know
381  * that there is no timestamp, short-cutting the test. */
382 static void timestamp_and_log(int pri, char *msg, int len)
383 {
384         char *timestamp;
385
386         if (len < 16 || msg[3] != ' ' || msg[6] != ' '
387          || msg[9] != ':' || msg[12] != ':' || msg[15] != ' '
388         ) {
389                 time_t now;
390                 time(&now);
391                 timestamp = ctime(&now) + 4;
392         } else {
393                 timestamp = msg;
394                 msg += 16;
395         }
396         timestamp[15] = '\0';
397
398         /* Log message locally (to file or shared mem) */
399         if (!ENABLE_FEATURE_REMOTE_LOG || (option_mask32 & OPT_locallog)) {
400                 if (LOG_PRI(pri) < logLevel) {
401                         if (option_mask32 & OPT_small)
402                                 sprintf(PRINTBUF, "%s %s\n", timestamp, msg);
403                         else {
404                                 char res[20];
405                                 parse_fac_prio_20(pri, res);
406                                 sprintf(PRINTBUF, "%s %s %s %s\n", timestamp, localHostName, res, msg);
407                         }
408                         log_locally(PRINTBUF);
409                 }
410         }
411 }
412
413 static void split_escape_and_log(char *tmpbuf, int len)
414 {
415         char *p = tmpbuf;
416
417         tmpbuf += len;
418         while (p < tmpbuf) {
419                 char c;
420                 char *q = PARSEBUF;
421                 int pri = (LOG_USER | LOG_NOTICE);
422
423                 if (*p == '<') {
424                         /* Parse the magic priority number */
425                         pri = bb_strtou(p + 1, &p, 10);
426                         if (*p == '>') p++;
427                         if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) {
428                                 pri = (LOG_USER | LOG_NOTICE);
429                         }
430                 }
431
432                 while ((c = *p++)) {
433                         if (c == '\n')
434                                 c = ' ';
435                         if (!(c & ~0x1f)) {
436                                 *q++ = '^';
437                                 c += '@'; /* ^@, ^A, ^B... */
438                         }
439                         *q++ = c;
440                 }
441                 *q = '\0';
442                 /* Now log it */
443                 timestamp_and_log(pri, PARSEBUF, q - PARSEBUF);
444         }
445 }
446
447 static void quit_signal(int sig)
448 {
449         timestamp_and_log(LOG_SYSLOG | LOG_INFO, (char*)"syslogd exiting", 0);
450         puts("syslogd exiting");
451         if (ENABLE_FEATURE_IPC_SYSLOG)
452                 ipcsyslog_cleanup();
453         exit(1);
454 }
455
456 #ifdef SYSLOGD_MARK
457 static void do_mark(int sig)
458 {
459         if (markInterval) {
460                 timestamp_and_log(LOG_SYSLOG | LOG_INFO, (char*)"-- MARK --", 0);
461                 alarm(markInterval);
462         }
463 }
464 #endif
465
466 static void do_syslogd(void) ATTRIBUTE_NORETURN;
467 static void do_syslogd(void)
468 {
469         struct sockaddr_un sunx;
470         int sock_fd;
471         fd_set fds;
472         char *dev_log_name;
473
474         /* Set up signal handlers */
475         signal(SIGINT, quit_signal);
476         signal(SIGTERM, quit_signal);
477         signal(SIGQUIT, quit_signal);
478         signal(SIGHUP, SIG_IGN);
479         signal(SIGCHLD, SIG_IGN);
480 #ifdef SIGCLD
481         signal(SIGCLD, SIG_IGN);
482 #endif
483 #ifdef SYSLOGD_MARK
484         signal(SIGALRM, do_mark);
485         alarm(markInterval);
486 #endif
487
488         memset(&sunx, 0, sizeof(sunx));
489         sunx.sun_family = AF_UNIX;
490         strcpy(sunx.sun_path, "/dev/log");
491
492         /* Unlink old /dev/log or object it points to. */
493         /* (if it exists, bind will fail) */
494         logmode = LOGMODE_NONE;
495         dev_log_name = xmalloc_readlink_or_warn("/dev/log");
496         logmode = LOGMODE_STDIO;
497         if (dev_log_name) {
498                 int fd = xopen(".", O_NONBLOCK);
499                 xchdir("/dev");
500                 /* we do not check whether this is a link also */
501                 unlink(dev_log_name);
502                 fchdir(fd);
503                 close(fd);
504                 safe_strncpy(sunx.sun_path, dev_log_name, sizeof(sunx.sun_path));
505                 free(dev_log_name);
506         } else {
507                 unlink("/dev/log");
508         }
509
510         sock_fd = xsocket(AF_UNIX, SOCK_DGRAM, 0);
511         xbind(sock_fd, (struct sockaddr *) &sunx, sizeof(sunx));
512
513         if (chmod("/dev/log", 0666) < 0) {
514                 bb_perror_msg_and_die("cannot set permission on /dev/log");
515         }
516         if (ENABLE_FEATURE_IPC_SYSLOG && (option_mask32 & OPT_circularlog)) {
517                 ipcsyslog_init();
518         }
519
520         timestamp_and_log(LOG_SYSLOG | LOG_INFO,
521                         (char*)"syslogd started: BusyBox v" BB_VER, 0);
522
523         for (;;) {
524                 FD_ZERO(&fds);
525                 FD_SET(sock_fd, &fds);
526
527                 if (select(sock_fd + 1, &fds, NULL, NULL, NULL) < 0) {
528                         if (errno == EINTR) {
529                                 /* alarm may have happened */
530                                 continue;
531                         }
532                         bb_perror_msg_and_die("select");
533                 }
534
535                 if (FD_ISSET(sock_fd, &fds)) {
536                         int i;
537                         i = recv(sock_fd, RECVBUF, MAX_READ - 1, 0);
538                         if (i <= 0)
539                                 bb_perror_msg_and_die("UNIX socket error");
540                         /* TODO: maybe suppress duplicates? */
541 #if ENABLE_FEATURE_REMOTE_LOG
542                         /* We are not modifying log messages in any way before send */
543                         /* Remote site cannot trust _us_ anyway and need to do validation again */
544                         if (remoteAddr) {
545                                 if (-1 == remoteFD) {
546                                         remoteFD = socket(remoteAddr->sa.sa_family, SOCK_DGRAM, 0);
547                                 }
548                                 if (-1 != remoteFD) {
549                                         /* send message to remote logger, ignore possible error */
550                                         sendto(remoteFD, RECVBUF, i, MSG_DONTWAIT,
551                                                 &remoteAddr->sa, remoteAddr->len);
552                                 }
553                         }
554 #endif
555                         RECVBUF[i] = '\0';
556                         split_escape_and_log(RECVBUF, i);
557                 } /* FD_ISSET() */
558         } /* for */
559 }
560
561 int syslogd_main(int argc, char **argv);
562 int syslogd_main(int argc, char **argv)
563 {
564         char OPTION_DECL;
565         char *p;
566
567         /* do normal option parsing */
568         opt_complementary = "=0"; /* no non-option params */
569         getopt32(argc, argv, OPTION_STR, OPTION_PARAM);
570 #ifdef SYSLOGD_MARK
571         if (option_mask32 & OPT_mark) // -m
572                 markInterval = xatou_range(opt_m, 0, INT_MAX/60) * 60;
573 #endif
574         //if (option_mask32 & OPT_nofork) // -n
575         //if (option_mask32 & OPT_outfile) // -O
576         if (option_mask32 & OPT_loglevel) // -l
577                 logLevel = xatou_range(opt_l, 1, 8);
578         //if (option_mask32 & OPT_small) // -S
579 #if ENABLE_FEATURE_ROTATE_LOGFILE
580         if (option_mask32 & OPT_filesize) // -s
581                 logFileSize = xatou_range(opt_s, 0, INT_MAX/1024) * 1024;
582         if (option_mask32 & OPT_rotatecnt) // -b
583                 logFileRotate = xatou_range(opt_b, 0, 99);
584 #endif
585 #if ENABLE_FEATURE_REMOTE_LOG
586         if (option_mask32 & OPT_remotelog) { // -R
587                 remoteAddr = xhost2sockaddr(opt_R, 514);
588         }
589         //if (option_mask32 & OPT_locallog) // -L
590 #endif
591 #if ENABLE_FEATURE_IPC_SYSLOG
592         if (opt_C) // -Cn
593                 shm_size = xatoul_range(opt_C, 4, INT_MAX/1024) * 1024;
594 #endif
595
596         /* If they have not specified remote logging, then log locally */
597         if (ENABLE_FEATURE_REMOTE_LOG && !(option_mask32 & OPT_remotelog))
598                 option_mask32 |= OPT_locallog;
599
600         /* Store away localhost's name before the fork */
601         gethostname(localHostName, sizeof(localHostName));
602         p = strchr(localHostName, '.');
603         if (p) {
604                 *p = '\0';
605         }
606
607         if (!(option_mask32 & OPT_nofork)) {
608 #ifdef BB_NOMMU
609                 vfork_daemon_rexec(0, 1, argc, argv, "-n");
610 #else
611                 bb_daemonize();
612 #endif
613         }
614         umask(0);
615         do_syslogd();
616         /* return EXIT_SUCCESS; */
617 }