blob: cacb629e9fcb446070c85fa4f8e678a50862184f [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Eric Andersen3843e961999-11-25 07:30:46 +00002/*
3 * Mini syslogd implementation for busybox
4 *
Erik Andersen61677fe2000-04-13 01:18:56 +00005 * Copyright (C) 1999,2000 by Lineo, inc.
Eric Andersen3843e961999-11-25 07:30:46 +00006 * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
7 *
Erik Andersenf13df372000-04-18 23:51:51 +00008 * Copyright (C) 2000 by Karl M. Hegbloom <karlheg@debian.org>
9 *
Eric Andersen3843e961999-11-25 07:30:46 +000010 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
Eric Andersenb99df0f1999-11-24 09:04:33 +000025
Eric Andersen3843e961999-11-25 07:30:46 +000026#include "internal.h"
Eric Andersen3843e961999-11-25 07:30:46 +000027#include <ctype.h>
Eric Andersenb186d981999-12-03 09:19:54 +000028#include <errno.h>
Erik Andersen983b51b2000-04-04 18:14:25 +000029#include <fcntl.h>
30#include <netdb.h>
Eric Andersenb186d981999-12-03 09:19:54 +000031#include <paths.h>
Erik Andersen983b51b2000-04-04 18:14:25 +000032#include <signal.h>
33#include <stdarg.h>
34#include <stdio.h>
35#include <sys/klog.h>
36#include <sys/socket.h>
37#include <sys/stat.h>
38#include <sys/types.h>
39#include <sys/un.h>
Erik Andersen7d6ba572000-04-19 20:02:50 +000040#include <sys/param.h>
Erik Andersen983b51b2000-04-04 18:14:25 +000041#include <time.h>
42#include <unistd.h>
Eric Andersenb186d981999-12-03 09:19:54 +000043
44#define ksyslog klogctl
45extern int ksyslog(int type, char *buf, int len);
Eric Andersenb99df0f1999-11-24 09:04:33 +000046
47
Eric Andersen3843e961999-11-25 07:30:46 +000048/* SYSLOG_NAMES defined to pull some extra junk from syslog.h */
49#define SYSLOG_NAMES
50#include <sys/syslog.h>
51
52/* Path for the file where all log messages are written */
Erik Andersen983b51b2000-04-04 18:14:25 +000053#define __LOG_FILE "/var/log/messages"
Eric Andersen3843e961999-11-25 07:30:46 +000054
Erik Andersen983b51b2000-04-04 18:14:25 +000055/* Path to the unix socket */
Erik Andersen4f3f7572000-04-28 00:18:56 +000056char lfile[BUFSIZ] = "";
Eric Andersen3843e961999-11-25 07:30:46 +000057
Erik Andersene49d5ec2000-02-08 19:58:47 +000058static char *logFilePath = __LOG_FILE;
59
Eric Andersen3843e961999-11-25 07:30:46 +000060/* interval between marks in seconds */
Erik Andersene49d5ec2000-02-08 19:58:47 +000061static int MarkInterval = 20 * 60;
62
Eric Andersen3843e961999-11-25 07:30:46 +000063/* localhost's name */
64static char LocalHostName[32];
65
66static const char syslogd_usage[] =
Erik Andersene49d5ec2000-02-08 19:58:47 +000067 "syslogd [OPTION]...\n\n"
68 "Linux system and kernel (provides klogd) logging utility.\n"
69 "Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n"
70 "Options:\n"
71 "\t-m\tChange the mark timestamp interval. default=20min. 0=off\n"
72 "\t-n\tDo not fork into the background (for when run by init)\n"
Eric Andersen2cb55071999-12-10 08:25:07 +000073#ifdef BB_KLOGD
Erik Andersene49d5ec2000-02-08 19:58:47 +000074 "\t-K\tDo not start up the klogd process (by default syslogd spawns klogd).\n"
Eric Andersen2cb55071999-12-10 08:25:07 +000075#endif
Erik Andersene49d5ec2000-02-08 19:58:47 +000076 "\t-O\tSpecify an alternate log file. default=/var/log/messages\n";
Eric Andersen3843e961999-11-25 07:30:46 +000077
Erik Andersenc053e412000-03-21 01:31:24 +000078/* Note: There is also a function called "message()" in init.c */
Erik Andersen983b51b2000-04-04 18:14:25 +000079/* Print a message to the log file. */
Erik Andersenf13df372000-04-18 23:51:51 +000080static void message (char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
81static void message (char *fmt, ...)
Eric Andersen3843e961999-11-25 07:30:46 +000082{
Erik Andersene49d5ec2000-02-08 19:58:47 +000083 int fd;
Erik Andersene3ed1562000-04-19 18:52:56 +000084 struct flock fl;
Erik Andersene49d5ec2000-02-08 19:58:47 +000085 va_list arguments;
Eric Andersen3843e961999-11-25 07:30:46 +000086
Erik Andersene3ed1562000-04-19 18:52:56 +000087 fl.l_whence = SEEK_SET;
88 fl.l_start = 0;
89 fl.l_len = 1;
90
Erik Andersenf13df372000-04-18 23:51:51 +000091 if ((fd = device_open (logFilePath,
92 O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND |
93 O_NONBLOCK)) >= 0) {
Erik Andersene3ed1562000-04-19 18:52:56 +000094 fl.l_type = F_WRLCK;
95 fcntl (fd, F_SETLKW, &fl);
Erik Andersenf13df372000-04-18 23:51:51 +000096 va_start (arguments, fmt);
97 vdprintf (fd, fmt, arguments);
98 va_end (arguments);
Erik Andersene3ed1562000-04-19 18:52:56 +000099 fl.l_type = F_UNLCK;
100 fcntl (fd, F_SETLKW, &fl);
Erik Andersenf13df372000-04-18 23:51:51 +0000101 close (fd);
Eric Andersen3843e961999-11-25 07:30:46 +0000102 } else {
Erik Andersene49d5ec2000-02-08 19:58:47 +0000103 /* Always send console messages to /dev/console so people will see them. */
Erik Andersenf13df372000-04-18 23:51:51 +0000104 if ((fd = device_open (_PATH_CONSOLE,
105 O_WRONLY | O_NOCTTY | O_NONBLOCK)) >= 0) {
106 va_start (arguments, fmt);
107 vdprintf (fd, fmt, arguments);
108 va_end (arguments);
109 close (fd);
Erik Andersene49d5ec2000-02-08 19:58:47 +0000110 } else {
Erik Andersenf13df372000-04-18 23:51:51 +0000111 fprintf (stderr, "Bummer, can't print: ");
112 va_start (arguments, fmt);
113 vfprintf (stderr, fmt, arguments);
114 fflush (stderr);
115 va_end (arguments);
Erik Andersene49d5ec2000-02-08 19:58:47 +0000116 }
Eric Andersen3843e961999-11-25 07:30:46 +0000117 }
Eric Andersenb99df0f1999-11-24 09:04:33 +0000118}
119
Erik Andersenf13df372000-04-18 23:51:51 +0000120static void logMessage (int pri, char *msg)
Eric Andersen3843e961999-11-25 07:30:46 +0000121{
Erik Andersene49d5ec2000-02-08 19:58:47 +0000122 time_t now;
123 char *timestamp;
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000124 static char res[20] = "";
Erik Andersene49d5ec2000-02-08 19:58:47 +0000125 CODE *c_pri, *c_fac;
Eric Andersenb99df0f1999-11-24 09:04:33 +0000126
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000127 if (pri != 0) {
128 for (c_fac = facilitynames;
129 c_fac->c_name && !(c_fac->c_val == LOG_FAC(pri) << 3); c_fac++);
130 for (c_pri = prioritynames;
131 c_pri->c_name && !(c_pri->c_val == LOG_PRI(pri)); c_pri++);
132 if (*c_fac->c_name == '\0' || *c_pri->c_name == '\0')
133 snprintf(res, sizeof(res), "<%d>", pri);
134 else
135 snprintf(res, sizeof(res), "%s.%s", c_fac->c_name, c_pri->c_name);
136 }
Eric Andersen3843e961999-11-25 07:30:46 +0000137
Erik Andersene49d5ec2000-02-08 19:58:47 +0000138 if (strlen(msg) < 16 || msg[3] != ' ' || msg[6] != ' ' ||
139 msg[9] != ':' || msg[12] != ':' || msg[15] != ' ') {
140 time(&now);
141 timestamp = ctime(&now) + 4;
142 timestamp[15] = '\0';
143 } else {
144 timestamp = msg;
145 timestamp[15] = '\0';
146 msg += 16;
147 }
Eric Andersen3843e961999-11-25 07:30:46 +0000148
Erik Andersene49d5ec2000-02-08 19:58:47 +0000149 /* todo: supress duplicates */
Eric Andersen3843e961999-11-25 07:30:46 +0000150
Erik Andersene49d5ec2000-02-08 19:58:47 +0000151 /* now spew out the message to wherever it is supposed to go */
152 message("%s %s %s %s\n", timestamp, LocalHostName, res, msg);
Eric Andersen3843e961999-11-25 07:30:46 +0000153}
154
155static void quit_signal(int sig)
156{
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000157 logMessage(0, "System log daemon exiting.");
Erik Andersen983b51b2000-04-04 18:14:25 +0000158 unlink(lfile);
Erik Andersene49d5ec2000-02-08 19:58:47 +0000159 exit(TRUE);
Eric Andersen3843e961999-11-25 07:30:46 +0000160}
161
Eric Andersen3843e961999-11-25 07:30:46 +0000162static void domark(int sig)
163{
Erik Andersene49d5ec2000-02-08 19:58:47 +0000164 if (MarkInterval > 0) {
165 logMessage(LOG_SYSLOG | LOG_INFO, "-- MARK --");
166 alarm(MarkInterval);
167 }
Eric Andersen3843e961999-11-25 07:30:46 +0000168}
169
Erik Andersen983b51b2000-04-04 18:14:25 +0000170static void doSyslogd (void) __attribute__ ((noreturn));
171static void doSyslogd (void)
Eric Andersen3843e961999-11-25 07:30:46 +0000172{
Erik Andersene49d5ec2000-02-08 19:58:47 +0000173 struct sockaddr_un sunx;
Erik Andersen1d1d9502000-04-21 01:26:49 +0000174 socklen_t addrLength;
175
Erik Andersenf13df372000-04-18 23:51:51 +0000176
Erik Andersen983b51b2000-04-04 18:14:25 +0000177 int sock_fd;
Erik Andersenf13df372000-04-18 23:51:51 +0000178 fd_set fds;
179
Erik Andersen4f3f7572000-04-28 00:18:56 +0000180 char lfile[BUFSIZ];
Eric Andersenb99df0f1999-11-24 09:04:33 +0000181
Erik Andersenf13df372000-04-18 23:51:51 +0000182 /* Set up signal handlers. */
Erik Andersen983b51b2000-04-04 18:14:25 +0000183 signal (SIGINT, quit_signal);
184 signal (SIGTERM, quit_signal);
185 signal (SIGQUIT, quit_signal);
186 signal (SIGHUP, SIG_IGN);
Erik Andersene3ed1562000-04-19 18:52:56 +0000187 signal (SIGCLD, SIG_IGN);
Erik Andersen983b51b2000-04-04 18:14:25 +0000188 signal (SIGALRM, domark);
189 alarm (MarkInterval);
Eric Andersenb99df0f1999-11-24 09:04:33 +0000190
Erik Andersenf13df372000-04-18 23:51:51 +0000191 /* Create the syslog file so realpath() can work. */
192 close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644));
193 if (realpath (_PATH_LOG, lfile) == NULL)
194 fatalError ("Could not resolv path to " _PATH_LOG ": %s", strerror (errno));
Eric Andersen14ec6cf1999-12-05 22:17:02 +0000195
Erik Andersen983b51b2000-04-04 18:14:25 +0000196 unlink (lfile);
197
Erik Andersenf13df372000-04-18 23:51:51 +0000198 memset (&sunx, 0, sizeof (sunx));
Erik Andersen983b51b2000-04-04 18:14:25 +0000199 sunx.sun_family = AF_UNIX;
Erik Andersenf13df372000-04-18 23:51:51 +0000200 strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path));
201 if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
202 fatalError ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s", strerror (errno));
Eric Andersenb99df0f1999-11-24 09:04:33 +0000203
Erik Andersen983b51b2000-04-04 18:14:25 +0000204 addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path);
Erik Andersenf13df372000-04-18 23:51:51 +0000205 if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5)))
206 fatalError ("Could not connect to socket " _PATH_LOG ": %s", strerror (errno));
Erik Andersene49d5ec2000-02-08 19:58:47 +0000207
Erik Andersenf13df372000-04-18 23:51:51 +0000208 if (chmod (lfile, 0666) < 0)
209 fatalError ("Could not set permission on " _PATH_LOG ": %s", strerror (errno));
Erik Andersene49d5ec2000-02-08 19:58:47 +0000210
Erik Andersenf13df372000-04-18 23:51:51 +0000211 FD_ZERO (&fds);
212 FD_SET (sock_fd, &fds);
Erik Andersene49d5ec2000-02-08 19:58:47 +0000213
Erik Andersen983b51b2000-04-04 18:14:25 +0000214 logMessage (0, "syslogd started: BusyBox v" BB_VER " (" BB_BT ")");
Erik Andersene49d5ec2000-02-08 19:58:47 +0000215
Erik Andersen983b51b2000-04-04 18:14:25 +0000216 for (;;) {
Erik Andersenf13df372000-04-18 23:51:51 +0000217
218 fd_set readfds;
219 int n_ready;
220 int fd;
221
222 memcpy (&readfds, &fds, sizeof (fds));
Erik Andersene49d5ec2000-02-08 19:58:47 +0000223
Erik Andersen983b51b2000-04-04 18:14:25 +0000224 if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) {
225 if (errno == EINTR) continue; /* alarm may have happened. */
Erik Andersenf13df372000-04-18 23:51:51 +0000226 fatalError ("select error: %s\n", strerror (errno));
Erik Andersene49d5ec2000-02-08 19:58:47 +0000227 }
Erik Andersene49d5ec2000-02-08 19:58:47 +0000228
Erik Andersenf13df372000-04-18 23:51:51 +0000229 for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) {
Erik Andersen983b51b2000-04-04 18:14:25 +0000230 if (FD_ISSET (fd, &readfds)) {
Erik Andersene3ed1562000-04-19 18:52:56 +0000231
Erik Andersenf13df372000-04-18 23:51:51 +0000232 --n_ready;
Erik Andersene3ed1562000-04-19 18:52:56 +0000233
Erik Andersen983b51b2000-04-04 18:14:25 +0000234 if (fd == sock_fd) {
Erik Andersene3ed1562000-04-19 18:52:56 +0000235
236 int conn;
237 pid_t pid;
238
Erik Andersenf13df372000-04-18 23:51:51 +0000239 if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) {
240 fatalError ("accept error: %s\n", strerror (errno));
Erik Andersen983b51b2000-04-04 18:14:25 +0000241 }
Erik Andersena6c75222000-04-18 00:00:52 +0000242
Erik Andersene3ed1562000-04-19 18:52:56 +0000243 pid = fork();
Erik Andersen983b51b2000-04-04 18:14:25 +0000244
Erik Andersene3ed1562000-04-19 18:52:56 +0000245 if (pid < 0) {
246 perror ("syslogd: fork");
247 close (conn);
248 continue;
Erik Andersen983b51b2000-04-04 18:14:25 +0000249 }
Erik Andersene3ed1562000-04-19 18:52:56 +0000250
251 if (pid > 0) {
252
253# define BUFSIZE 1023
254 char buf[ BUFSIZE + 1 ];
255 int n_read;
256
257 while ((n_read = read (conn, buf, BUFSIZE )) > 0) {
258
259 int pri = (LOG_USER | LOG_NOTICE);
260 char line[ BUFSIZE + 1 ];
261 unsigned char c;
262
263 char *p = buf, *q = line;
264
265 buf[ n_read - 1 ] = '\0';
266
267 while (p && (c = *p) && q < &line[ sizeof (line) - 1 ]) {
268 if (c == '<') {
269 /* Parse the magic priority number. */
270 pri = 0;
271 while (isdigit (*(++p))) {
272 pri = 10 * pri + (*p - '0');
273 }
274 if (pri & ~(LOG_FACMASK | LOG_PRIMASK))
275 pri = (LOG_USER | LOG_NOTICE);
276 } else if (c == '\n') {
277 *q++ = ' ';
278 } else if (iscntrl (c) && (c < 0177)) {
279 *q++ = '^';
280 *q++ = c ^ 0100;
281 } else {
282 *q++ = c;
283 }
284 p++;
285 }
286 *q = '\0';
287 /* Now log it */
288 logMessage (pri, line);
289 }
290 exit (0);
291 }
292 close (conn);
Erik Andersen983b51b2000-04-04 18:14:25 +0000293 }
294 }
295 }
296 }
Eric Andersenb99df0f1999-11-24 09:04:33 +0000297}
298
Eric Andersen2cb55071999-12-10 08:25:07 +0000299#ifdef BB_KLOGD
300
Eric Andersenb186d981999-12-03 09:19:54 +0000301static void klogd_signal(int sig)
302{
Erik Andersene49d5ec2000-02-08 19:58:47 +0000303 ksyslog(7, NULL, 0);
304 ksyslog(0, 0, 0);
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000305 logMessage(0, "Kernel log daemon exiting.");
Erik Andersene49d5ec2000-02-08 19:58:47 +0000306 exit(TRUE);
Eric Andersenb186d981999-12-03 09:19:54 +0000307}
308
Erik Andersen983b51b2000-04-04 18:14:25 +0000309static void doKlogd (void) __attribute__ ((noreturn));
310static void doKlogd (void)
Eric Andersenb186d981999-12-03 09:19:54 +0000311{
Erik Andersene49d5ec2000-02-08 19:58:47 +0000312 int priority = LOG_INFO;
313 char log_buffer[4096];
314 char *logp;
Eric Andersenb186d981999-12-03 09:19:54 +0000315
Erik Andersene49d5ec2000-02-08 19:58:47 +0000316 /* Set up sig handlers */
317 signal(SIGINT, klogd_signal);
318 signal(SIGKILL, klogd_signal);
319 signal(SIGTERM, klogd_signal);
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000320 signal(SIGHUP, SIG_IGN);
321 logMessage(0, "klogd started: "
Erik Andersene49d5ec2000-02-08 19:58:47 +0000322 "BusyBox v" BB_VER " (" BB_BT ")");
Eric Andersenb186d981999-12-03 09:19:54 +0000323
Erik Andersene49d5ec2000-02-08 19:58:47 +0000324 ksyslog(1, NULL, 0);
Eric Andersen0ecb54a1999-12-05 23:24:55 +0000325
Erik Andersene49d5ec2000-02-08 19:58:47 +0000326 while (1) {
327 /* Use kernel syscalls */
328 memset(log_buffer, '\0', sizeof(log_buffer));
329 if (ksyslog(2, log_buffer, sizeof(log_buffer)) < 0) {
330 char message[80];
331
332 if (errno == EINTR)
333 continue;
334 snprintf(message, 79, "klogd: Error return from sys_sycall: " \
335 "%d - %s.\n", errno, strerror(errno));
336 logMessage(LOG_SYSLOG | LOG_ERR, message);
337 exit(1);
338 }
339 logp = log_buffer;
340 if (*log_buffer == '<') {
341 switch (*(log_buffer + 1)) {
342 case '0':
343 priority = LOG_EMERG;
344 break;
345 case '1':
346 priority = LOG_ALERT;
347 break;
348 case '2':
349 priority = LOG_CRIT;
350 break;
351 case '3':
352 priority = LOG_ERR;
353 break;
354 case '4':
355 priority = LOG_WARNING;
356 break;
357 case '5':
358 priority = LOG_NOTICE;
359 break;
360 case '6':
361 priority = LOG_INFO;
362 break;
363 case '7':
364 default:
365 priority = LOG_DEBUG;
366 }
367 logp += 3;
368 }
369 logMessage(LOG_KERN | priority, logp);
Eric Andersenb186d981999-12-03 09:19:54 +0000370 }
Eric Andersenb186d981999-12-03 09:19:54 +0000371
372}
373
Eric Andersen2cb55071999-12-10 08:25:07 +0000374#endif
Eric Andersenb99df0f1999-11-24 09:04:33 +0000375
Erik Andersen983b51b2000-04-04 18:14:25 +0000376static void daemon_init (char **argv, char *dz, void fn (void))
377{
378 setsid();
379 chdir ("/");
380 strncpy(argv[0], dz, strlen(argv[0]));
381 fn();
382 exit(0);
383}
384
Eric Andersen3843e961999-11-25 07:30:46 +0000385extern int syslogd_main(int argc, char **argv)
386{
Erik Andersene49d5ec2000-02-08 19:58:47 +0000387 int pid, klogd_pid;
388 int doFork = TRUE;
389
Eric Andersen2cb55071999-12-10 08:25:07 +0000390#ifdef BB_KLOGD
Erik Andersene49d5ec2000-02-08 19:58:47 +0000391 int startKlogd = TRUE;
Eric Andersen2cb55071999-12-10 08:25:07 +0000392#endif
Erik Andersene49d5ec2000-02-08 19:58:47 +0000393 int stopDoingThat = FALSE;
394 char *p;
395 char **argv1 = argv;
396
397 while (--argc > 0 && **(++argv1) == '-') {
398 stopDoingThat = FALSE;
399 while (stopDoingThat == FALSE && *(++(*argv1))) {
400 switch (**argv1) {
401 case 'm':
402 if (--argc == 0) {
403 usage(syslogd_usage);
404 }
405 MarkInterval = atoi(*(++argv1)) * 60;
406 break;
407 case 'n':
408 doFork = FALSE;
409 break;
410#ifdef BB_KLOGD
411 case 'K':
412 startKlogd = FALSE;
413 break;
414#endif
415 case 'O':
416 if (--argc == 0) {
417 usage(syslogd_usage);
418 }
419 logFilePath = *(++argv1);
420 stopDoingThat = TRUE;
421 break;
422 default:
423 usage(syslogd_usage);
424 }
Eric Andersen3843e961999-11-25 07:30:46 +0000425 }
Erik Andersene49d5ec2000-02-08 19:58:47 +0000426 }
427
428 /* Store away localhost's name before the fork */
429 gethostname(LocalHostName, sizeof(LocalHostName));
430 if ((p = strchr(LocalHostName, '.'))) {
431 *p++ = '\0';
432 }
433
Erik Andersen983b51b2000-04-04 18:14:25 +0000434 umask(0);
435
Erik Andersene2729152000-02-18 21:34:17 +0000436#ifdef BB_KLOGD
437 /* Start up the klogd process */
438 if (startKlogd == TRUE) {
439 klogd_pid = fork();
440 if (klogd_pid == 0) {
Erik Andersen983b51b2000-04-04 18:14:25 +0000441 daemon_init (argv, "klogd", doKlogd);
Erik Andersene2729152000-02-18 21:34:17 +0000442 }
443 }
444#endif
445
Erik Andersene49d5ec2000-02-08 19:58:47 +0000446 if (doFork == TRUE) {
447 pid = fork();
448 if (pid < 0)
449 exit(pid);
450 else if (pid == 0) {
Erik Andersen983b51b2000-04-04 18:14:25 +0000451 daemon_init (argv, "syslogd", doSyslogd);
Eric Andersen3843e961999-11-25 07:30:46 +0000452 }
Erik Andersene49d5ec2000-02-08 19:58:47 +0000453 } else {
454 doSyslogd();
Eric Andersen3843e961999-11-25 07:30:46 +0000455 }
Eric Andersenb186d981999-12-03 09:19:54 +0000456
Erik Andersene49d5ec2000-02-08 19:58:47 +0000457 exit(TRUE);
Eric Andersen3843e961999-11-25 07:30:46 +0000458}
Erik Andersen983b51b2000-04-04 18:14:25 +0000459
460/*
Erik Andersene3ed1562000-04-19 18:52:56 +0000461Local Variables
462c-file-style: "linux"
463c-basic-offset: 4
464tab-width: 4
465End:
466*/