blob: 4ebd2a28a48be0964ac6356c4e3d3fa27efbf5ab [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 */
56char lfile[PATH_MAX] = "";
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 Andersene49d5ec2000-02-08 19:58:47 +0000174 size_t addrLength;
Erik Andersenf13df372000-04-18 23:51:51 +0000175
Erik Andersen983b51b2000-04-04 18:14:25 +0000176 int sock_fd;
Erik Andersenf13df372000-04-18 23:51:51 +0000177 fd_set fds;
178
Erik Andersen983b51b2000-04-04 18:14:25 +0000179 char lfile[PATH_MAX];
Eric Andersenb99df0f1999-11-24 09:04:33 +0000180
Erik Andersenf13df372000-04-18 23:51:51 +0000181 /* Set up signal handlers. */
Erik Andersen983b51b2000-04-04 18:14:25 +0000182 signal (SIGINT, quit_signal);
183 signal (SIGTERM, quit_signal);
184 signal (SIGQUIT, quit_signal);
185 signal (SIGHUP, SIG_IGN);
Erik Andersene3ed1562000-04-19 18:52:56 +0000186 signal (SIGCLD, SIG_IGN);
Erik Andersen983b51b2000-04-04 18:14:25 +0000187 signal (SIGALRM, domark);
188 alarm (MarkInterval);
Eric Andersenb99df0f1999-11-24 09:04:33 +0000189
Erik Andersenf13df372000-04-18 23:51:51 +0000190 /* Create the syslog file so realpath() can work. */
191 close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644));
192 if (realpath (_PATH_LOG, lfile) == NULL)
193 fatalError ("Could not resolv path to " _PATH_LOG ": %s", strerror (errno));
Eric Andersen14ec6cf1999-12-05 22:17:02 +0000194
Erik Andersen983b51b2000-04-04 18:14:25 +0000195 unlink (lfile);
196
Erik Andersenf13df372000-04-18 23:51:51 +0000197 memset (&sunx, 0, sizeof (sunx));
Erik Andersen983b51b2000-04-04 18:14:25 +0000198 sunx.sun_family = AF_UNIX;
Erik Andersenf13df372000-04-18 23:51:51 +0000199 strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path));
200 if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
201 fatalError ("Couldn't obtain descriptor for socket " _PATH_LOG ": %s", strerror (errno));
Eric Andersenb99df0f1999-11-24 09:04:33 +0000202
Erik Andersen983b51b2000-04-04 18:14:25 +0000203 addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path);
Erik Andersenf13df372000-04-18 23:51:51 +0000204 if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5)))
205 fatalError ("Could not connect to socket " _PATH_LOG ": %s", strerror (errno));
Erik Andersene49d5ec2000-02-08 19:58:47 +0000206
Erik Andersenf13df372000-04-18 23:51:51 +0000207 if (chmod (lfile, 0666) < 0)
208 fatalError ("Could not set permission on " _PATH_LOG ": %s", strerror (errno));
Erik Andersene49d5ec2000-02-08 19:58:47 +0000209
Erik Andersenf13df372000-04-18 23:51:51 +0000210 FD_ZERO (&fds);
211 FD_SET (sock_fd, &fds);
Erik Andersene49d5ec2000-02-08 19:58:47 +0000212
Erik Andersen983b51b2000-04-04 18:14:25 +0000213 logMessage (0, "syslogd started: BusyBox v" BB_VER " (" BB_BT ")");
Erik Andersene49d5ec2000-02-08 19:58:47 +0000214
Erik Andersen983b51b2000-04-04 18:14:25 +0000215 for (;;) {
Erik Andersenf13df372000-04-18 23:51:51 +0000216
217 fd_set readfds;
218 int n_ready;
219 int fd;
220
221 memcpy (&readfds, &fds, sizeof (fds));
Erik Andersene49d5ec2000-02-08 19:58:47 +0000222
Erik Andersen983b51b2000-04-04 18:14:25 +0000223 if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) {
224 if (errno == EINTR) continue; /* alarm may have happened. */
Erik Andersenf13df372000-04-18 23:51:51 +0000225 fatalError ("select error: %s\n", strerror (errno));
Erik Andersene49d5ec2000-02-08 19:58:47 +0000226 }
Erik Andersene49d5ec2000-02-08 19:58:47 +0000227
Erik Andersenf13df372000-04-18 23:51:51 +0000228 for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) {
Erik Andersen983b51b2000-04-04 18:14:25 +0000229 if (FD_ISSET (fd, &readfds)) {
Erik Andersene3ed1562000-04-19 18:52:56 +0000230
Erik Andersenf13df372000-04-18 23:51:51 +0000231 --n_ready;
Erik Andersene3ed1562000-04-19 18:52:56 +0000232
Erik Andersen983b51b2000-04-04 18:14:25 +0000233 if (fd == sock_fd) {
Erik Andersene3ed1562000-04-19 18:52:56 +0000234
235 int conn;
236 pid_t pid;
237
Erik Andersenf13df372000-04-18 23:51:51 +0000238 if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) {
239 fatalError ("accept error: %s\n", strerror (errno));
Erik Andersen983b51b2000-04-04 18:14:25 +0000240 }
Erik Andersena6c75222000-04-18 00:00:52 +0000241
Erik Andersene3ed1562000-04-19 18:52:56 +0000242 pid = fork();
Erik Andersen983b51b2000-04-04 18:14:25 +0000243
Erik Andersene3ed1562000-04-19 18:52:56 +0000244 if (pid < 0) {
245 perror ("syslogd: fork");
246 close (conn);
247 continue;
Erik Andersen983b51b2000-04-04 18:14:25 +0000248 }
Erik Andersene3ed1562000-04-19 18:52:56 +0000249
250 if (pid > 0) {
251
252# define BUFSIZE 1023
253 char buf[ BUFSIZE + 1 ];
254 int n_read;
255
256 while ((n_read = read (conn, buf, BUFSIZE )) > 0) {
257
258 int pri = (LOG_USER | LOG_NOTICE);
259 char line[ BUFSIZE + 1 ];
260 unsigned char c;
261
262 char *p = buf, *q = line;
263
264 buf[ n_read - 1 ] = '\0';
265
266 while (p && (c = *p) && q < &line[ sizeof (line) - 1 ]) {
267 if (c == '<') {
268 /* Parse the magic priority number. */
269 pri = 0;
270 while (isdigit (*(++p))) {
271 pri = 10 * pri + (*p - '0');
272 }
273 if (pri & ~(LOG_FACMASK | LOG_PRIMASK))
274 pri = (LOG_USER | LOG_NOTICE);
275 } else if (c == '\n') {
276 *q++ = ' ';
277 } else if (iscntrl (c) && (c < 0177)) {
278 *q++ = '^';
279 *q++ = c ^ 0100;
280 } else {
281 *q++ = c;
282 }
283 p++;
284 }
285 *q = '\0';
286 /* Now log it */
287 logMessage (pri, line);
288 }
289 exit (0);
290 }
291 close (conn);
Erik Andersen983b51b2000-04-04 18:14:25 +0000292 }
293 }
294 }
295 }
Eric Andersenb99df0f1999-11-24 09:04:33 +0000296}
297
Eric Andersen2cb55071999-12-10 08:25:07 +0000298#ifdef BB_KLOGD
299
Eric Andersenb186d981999-12-03 09:19:54 +0000300static void klogd_signal(int sig)
301{
Erik Andersene49d5ec2000-02-08 19:58:47 +0000302 ksyslog(7, NULL, 0);
303 ksyslog(0, 0, 0);
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000304 logMessage(0, "Kernel log daemon exiting.");
Erik Andersene49d5ec2000-02-08 19:58:47 +0000305 exit(TRUE);
Eric Andersenb186d981999-12-03 09:19:54 +0000306}
307
Erik Andersen983b51b2000-04-04 18:14:25 +0000308static void doKlogd (void) __attribute__ ((noreturn));
309static void doKlogd (void)
Eric Andersenb186d981999-12-03 09:19:54 +0000310{
Erik Andersene49d5ec2000-02-08 19:58:47 +0000311 int priority = LOG_INFO;
312 char log_buffer[4096];
313 char *logp;
Eric Andersenb186d981999-12-03 09:19:54 +0000314
Erik Andersene49d5ec2000-02-08 19:58:47 +0000315 /* Set up sig handlers */
316 signal(SIGINT, klogd_signal);
317 signal(SIGKILL, klogd_signal);
318 signal(SIGTERM, klogd_signal);
Erik Andersen9ffdaa62000-02-11 21:55:04 +0000319 signal(SIGHUP, SIG_IGN);
320 logMessage(0, "klogd started: "
Erik Andersene49d5ec2000-02-08 19:58:47 +0000321 "BusyBox v" BB_VER " (" BB_BT ")");
Eric Andersenb186d981999-12-03 09:19:54 +0000322
Erik Andersene49d5ec2000-02-08 19:58:47 +0000323 ksyslog(1, NULL, 0);
Eric Andersen0ecb54a1999-12-05 23:24:55 +0000324
Erik Andersene49d5ec2000-02-08 19:58:47 +0000325 while (1) {
326 /* Use kernel syscalls */
327 memset(log_buffer, '\0', sizeof(log_buffer));
328 if (ksyslog(2, log_buffer, sizeof(log_buffer)) < 0) {
329 char message[80];
330
331 if (errno == EINTR)
332 continue;
333 snprintf(message, 79, "klogd: Error return from sys_sycall: " \
334 "%d - %s.\n", errno, strerror(errno));
335 logMessage(LOG_SYSLOG | LOG_ERR, message);
336 exit(1);
337 }
338 logp = log_buffer;
339 if (*log_buffer == '<') {
340 switch (*(log_buffer + 1)) {
341 case '0':
342 priority = LOG_EMERG;
343 break;
344 case '1':
345 priority = LOG_ALERT;
346 break;
347 case '2':
348 priority = LOG_CRIT;
349 break;
350 case '3':
351 priority = LOG_ERR;
352 break;
353 case '4':
354 priority = LOG_WARNING;
355 break;
356 case '5':
357 priority = LOG_NOTICE;
358 break;
359 case '6':
360 priority = LOG_INFO;
361 break;
362 case '7':
363 default:
364 priority = LOG_DEBUG;
365 }
366 logp += 3;
367 }
368 logMessage(LOG_KERN | priority, logp);
Eric Andersenb186d981999-12-03 09:19:54 +0000369 }
Eric Andersenb186d981999-12-03 09:19:54 +0000370
371}
372
Eric Andersen2cb55071999-12-10 08:25:07 +0000373#endif
Eric Andersenb99df0f1999-11-24 09:04:33 +0000374
Erik Andersen983b51b2000-04-04 18:14:25 +0000375static void daemon_init (char **argv, char *dz, void fn (void))
376{
377 setsid();
378 chdir ("/");
379 strncpy(argv[0], dz, strlen(argv[0]));
380 fn();
381 exit(0);
382}
383
Eric Andersen3843e961999-11-25 07:30:46 +0000384extern int syslogd_main(int argc, char **argv)
385{
Erik Andersene49d5ec2000-02-08 19:58:47 +0000386 int pid, klogd_pid;
387 int doFork = TRUE;
388
Eric Andersen2cb55071999-12-10 08:25:07 +0000389#ifdef BB_KLOGD
Erik Andersene49d5ec2000-02-08 19:58:47 +0000390 int startKlogd = TRUE;
Eric Andersen2cb55071999-12-10 08:25:07 +0000391#endif
Erik Andersene49d5ec2000-02-08 19:58:47 +0000392 int stopDoingThat = FALSE;
393 char *p;
394 char **argv1 = argv;
395
396 while (--argc > 0 && **(++argv1) == '-') {
397 stopDoingThat = FALSE;
398 while (stopDoingThat == FALSE && *(++(*argv1))) {
399 switch (**argv1) {
400 case 'm':
401 if (--argc == 0) {
402 usage(syslogd_usage);
403 }
404 MarkInterval = atoi(*(++argv1)) * 60;
405 break;
406 case 'n':
407 doFork = FALSE;
408 break;
409#ifdef BB_KLOGD
410 case 'K':
411 startKlogd = FALSE;
412 break;
413#endif
414 case 'O':
415 if (--argc == 0) {
416 usage(syslogd_usage);
417 }
418 logFilePath = *(++argv1);
419 stopDoingThat = TRUE;
420 break;
421 default:
422 usage(syslogd_usage);
423 }
Eric Andersen3843e961999-11-25 07:30:46 +0000424 }
Erik Andersene49d5ec2000-02-08 19:58:47 +0000425 }
426
427 /* Store away localhost's name before the fork */
428 gethostname(LocalHostName, sizeof(LocalHostName));
429 if ((p = strchr(LocalHostName, '.'))) {
430 *p++ = '\0';
431 }
432
Erik Andersen983b51b2000-04-04 18:14:25 +0000433 umask(0);
434
Erik Andersene2729152000-02-18 21:34:17 +0000435#ifdef BB_KLOGD
436 /* Start up the klogd process */
437 if (startKlogd == TRUE) {
438 klogd_pid = fork();
439 if (klogd_pid == 0) {
Erik Andersen983b51b2000-04-04 18:14:25 +0000440 daemon_init (argv, "klogd", doKlogd);
Erik Andersene2729152000-02-18 21:34:17 +0000441 }
442 }
443#endif
444
Erik Andersene49d5ec2000-02-08 19:58:47 +0000445 if (doFork == TRUE) {
446 pid = fork();
447 if (pid < 0)
448 exit(pid);
449 else if (pid == 0) {
Erik Andersen983b51b2000-04-04 18:14:25 +0000450 daemon_init (argv, "syslogd", doSyslogd);
Eric Andersen3843e961999-11-25 07:30:46 +0000451 }
Erik Andersene49d5ec2000-02-08 19:58:47 +0000452 } else {
453 doSyslogd();
Eric Andersen3843e961999-11-25 07:30:46 +0000454 }
Eric Andersenb186d981999-12-03 09:19:54 +0000455
Erik Andersene49d5ec2000-02-08 19:58:47 +0000456 exit(TRUE);
Eric Andersen3843e961999-11-25 07:30:46 +0000457}
Erik Andersen983b51b2000-04-04 18:14:25 +0000458
459/*
Erik Andersene3ed1562000-04-19 18:52:56 +0000460Local Variables
461c-file-style: "linux"
462c-basic-offset: 4
463tab-width: 4
464End:
465*/