Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Mini syslogd implementation for busybox |
| 4 | * |
Erik Andersen | 61677fe | 2000-04-13 01:18:56 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999,2000 by Lineo, inc. |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 6 | * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> |
| 7 | * |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 8 | * Copyright (C) 2000 by Karl M. Hegbloom <karlheg@debian.org> |
| 9 | * |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 10 | * 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 Andersen | b99df0f | 1999-11-24 09:04:33 +0000 | [diff] [blame] | 25 | |
Eric Andersen | 3570a34 | 2000-09-25 21:45:58 +0000 | [diff] [blame] | 26 | #include "busybox.h" |
Eric Andersen | 67e3230 | 2000-06-19 17:48:02 +0000 | [diff] [blame] | 27 | #include <stdio.h> |
| 28 | #include <stdlib.h> |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 29 | #include <ctype.h> |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 30 | #include <errno.h> |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 31 | #include <fcntl.h> |
| 32 | #include <netdb.h> |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 33 | #include <paths.h> |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 34 | #include <signal.h> |
| 35 | #include <stdarg.h> |
Eric Andersen | 67e3230 | 2000-06-19 17:48:02 +0000 | [diff] [blame] | 36 | #include <time.h> |
| 37 | #include <unistd.h> |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 38 | #include <sys/socket.h> |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 39 | #include <sys/types.h> |
| 40 | #include <sys/un.h> |
Erik Andersen | 7d6ba57 | 2000-04-19 20:02:50 +0000 | [diff] [blame] | 41 | #include <sys/param.h> |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 42 | |
Eric Andersen | 999bf72 | 2000-07-09 06:59:58 +0000 | [diff] [blame] | 43 | #if ! defined __GLIBC__ && ! defined __UCLIBC__ |
Eric Andersen | 67e3230 | 2000-06-19 17:48:02 +0000 | [diff] [blame] | 44 | |
Eric Andersen | a15cd0b | 2000-06-19 18:14:20 +0000 | [diff] [blame] | 45 | typedef unsigned int socklen_t; |
| 46 | |
Eric Andersen | 67e3230 | 2000-06-19 17:48:02 +0000 | [diff] [blame] | 47 | #ifndef __alpha__ |
| 48 | # define __NR_klogctl __NR_syslog |
| 49 | static inline _syscall3(int, klogctl, int, type, char *, b, int, len); |
| 50 | #else /* __alpha__ */ |
| 51 | #define klogctl syslog |
| 52 | #endif |
| 53 | |
| 54 | #else |
| 55 | # include <sys/klog.h> |
| 56 | #endif |
| 57 | |
Eric Andersen | b99df0f | 1999-11-24 09:04:33 +0000 | [diff] [blame] | 58 | |
| 59 | |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 60 | /* SYSLOG_NAMES defined to pull some extra junk from syslog.h */ |
| 61 | #define SYSLOG_NAMES |
| 62 | #include <sys/syslog.h> |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 63 | #include <sys/uio.h> |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 64 | |
| 65 | /* Path for the file where all log messages are written */ |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 66 | #define __LOG_FILE "/var/log/messages" |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 67 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 68 | /* Path to the unix socket */ |
Erik Andersen | 4f3f757 | 2000-04-28 00:18:56 +0000 | [diff] [blame] | 69 | char lfile[BUFSIZ] = ""; |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 70 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 71 | static char *logFilePath = __LOG_FILE; |
| 72 | |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 73 | /* interval between marks in seconds */ |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 74 | static int MarkInterval = 20 * 60; |
| 75 | |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 76 | /* localhost's name */ |
| 77 | static char LocalHostName[32]; |
| 78 | |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 79 | #ifdef BB_FEATURE_REMOTE_LOG |
| 80 | #include <netinet/in.h> |
| 81 | /* udp socket for logging to remote host */ |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 82 | static int remotefd = -1; |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 83 | /* where do we log? */ |
| 84 | static char *RemoteHost; |
| 85 | /* what port to log to? */ |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 86 | static int RemotePort = 514; |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 87 | /* To remote log or not to remote log, that is the question. */ |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 88 | static int doRemoteLog = FALSE; |
Eric Andersen | 70d09ed | 2000-12-11 16:24:16 +0000 | [diff] [blame] | 89 | static int local_logging = FALSE; |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 90 | #endif |
| 91 | |
Erik Andersen | c053e41 | 2000-03-21 01:31:24 +0000 | [diff] [blame] | 92 | /* Note: There is also a function called "message()" in init.c */ |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 93 | /* Print a message to the log file. */ |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 94 | static void message (char *fmt, ...) __attribute__ ((format (printf, 1, 2))); |
| 95 | static void message (char *fmt, ...) |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 96 | { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 97 | int fd; |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 98 | struct flock fl; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 99 | va_list arguments; |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 100 | |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 101 | fl.l_whence = SEEK_SET; |
| 102 | fl.l_start = 0; |
| 103 | fl.l_len = 1; |
| 104 | |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 105 | if ((fd = device_open (logFilePath, |
| 106 | O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND | |
| 107 | O_NONBLOCK)) >= 0) { |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 108 | fl.l_type = F_WRLCK; |
| 109 | fcntl (fd, F_SETLKW, &fl); |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 110 | va_start (arguments, fmt); |
| 111 | vdprintf (fd, fmt, arguments); |
| 112 | va_end (arguments); |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 113 | fl.l_type = F_UNLCK; |
| 114 | fcntl (fd, F_SETLKW, &fl); |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 115 | close (fd); |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 116 | } else { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 117 | /* Always send console messages to /dev/console so people will see them. */ |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 118 | if ((fd = device_open (_PATH_CONSOLE, |
| 119 | O_WRONLY | O_NOCTTY | O_NONBLOCK)) >= 0) { |
| 120 | va_start (arguments, fmt); |
| 121 | vdprintf (fd, fmt, arguments); |
| 122 | va_end (arguments); |
| 123 | close (fd); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 124 | } else { |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 125 | fprintf (stderr, "Bummer, can't print: "); |
| 126 | va_start (arguments, fmt); |
| 127 | vfprintf (stderr, fmt, arguments); |
| 128 | fflush (stderr); |
| 129 | va_end (arguments); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 130 | } |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 131 | } |
Eric Andersen | b99df0f | 1999-11-24 09:04:33 +0000 | [diff] [blame] | 132 | } |
| 133 | |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 134 | static void logMessage (int pri, char *msg) |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 135 | { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 136 | time_t now; |
| 137 | char *timestamp; |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 138 | static char res[20] = ""; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 139 | CODE *c_pri, *c_fac; |
Eric Andersen | b99df0f | 1999-11-24 09:04:33 +0000 | [diff] [blame] | 140 | |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 141 | if (pri != 0) { |
| 142 | for (c_fac = facilitynames; |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 143 | c_fac->c_name && !(c_fac->c_val == LOG_FAC(pri) << 3); c_fac++); |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 144 | for (c_pri = prioritynames; |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 145 | c_pri->c_name && !(c_pri->c_val == LOG_PRI(pri)); c_pri++); |
Matt Kraai | 5a964f9 | 2000-12-11 20:13:37 +0000 | [diff] [blame] | 146 | if (c_fac->c_name == NULL || c_pri->c_name == NULL) |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 147 | snprintf(res, sizeof(res), "<%d>", pri); |
| 148 | else |
| 149 | snprintf(res, sizeof(res), "%s.%s", c_fac->c_name, c_pri->c_name); |
| 150 | } |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 151 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 152 | if (strlen(msg) < 16 || msg[3] != ' ' || msg[6] != ' ' || |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 153 | msg[9] != ':' || msg[12] != ':' || msg[15] != ' ') { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 154 | time(&now); |
| 155 | timestamp = ctime(&now) + 4; |
| 156 | timestamp[15] = '\0'; |
| 157 | } else { |
| 158 | timestamp = msg; |
| 159 | timestamp[15] = '\0'; |
| 160 | msg += 16; |
| 161 | } |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 162 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 163 | /* todo: supress duplicates */ |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 164 | |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 165 | #ifdef BB_FEATURE_REMOTE_LOG |
| 166 | /* send message to remote logger */ |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 167 | if ( -1 != remotefd){ |
Mark Whitley | 59ab025 | 2001-01-23 22:30:04 +0000 | [diff] [blame] | 168 | static const int IOV_COUNT = 2; |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 169 | struct iovec iov[IOV_COUNT]; |
| 170 | struct iovec *v = iov; |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 171 | |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 172 | bzero(&res, sizeof(res)); |
| 173 | snprintf(res, sizeof(res), "<%d>", pri); |
| 174 | v->iov_base = res ; |
| 175 | v->iov_len = strlen(res); |
| 176 | v++; |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 177 | |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 178 | v->iov_base = msg; |
| 179 | v->iov_len = strlen(msg); |
| 180 | |
| 181 | if ( -1 == writev(remotefd,iov, IOV_COUNT)){ |
| 182 | error_msg_and_die("syslogd: cannot write to remote file handle on" |
| 183 | "%s:%d\n",RemoteHost,RemotePort); |
| 184 | } |
| 185 | } |
| 186 | if (local_logging == TRUE) |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 187 | #endif |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 188 | /* now spew out the message to wherever it is supposed to go */ |
| 189 | message("%s %s %s %s\n", timestamp, LocalHostName, res, msg); |
Eric Andersen | 76fef0a | 2000-12-08 19:41:21 +0000 | [diff] [blame] | 190 | |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 191 | |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | static void quit_signal(int sig) |
| 195 | { |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 196 | logMessage(0, "System log daemon exiting."); |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 197 | unlink(lfile); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 198 | exit(TRUE); |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 199 | } |
| 200 | |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 201 | static void domark(int sig) |
| 202 | { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 203 | if (MarkInterval > 0) { |
| 204 | logMessage(LOG_SYSLOG | LOG_INFO, "-- MARK --"); |
| 205 | alarm(MarkInterval); |
| 206 | } |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Mark Whitley | 59ab025 | 2001-01-23 22:30:04 +0000 | [diff] [blame] | 209 | static const int BUFSIZE = 1023; |
Eric Andersen | 67e3230 | 2000-06-19 17:48:02 +0000 | [diff] [blame] | 210 | static int serveConnection (int conn) |
Pavel Roskin | da10ec0 | 2000-06-07 21:08:25 +0000 | [diff] [blame] | 211 | { |
Eric Andersen | d35c215 | 2001-01-25 23:49:09 +0000 | [diff] [blame^] | 212 | RESERVE_BB_BUFFER(buf, BUFSIZE + 1); |
Pavel Roskin | da10ec0 | 2000-06-07 21:08:25 +0000 | [diff] [blame] | 213 | int n_read; |
| 214 | |
| 215 | while ((n_read = read (conn, buf, BUFSIZE )) > 0) { |
| 216 | |
| 217 | int pri = (LOG_USER | LOG_NOTICE); |
| 218 | char line[ BUFSIZE + 1 ]; |
| 219 | unsigned char c; |
| 220 | |
| 221 | char *p = buf, *q = line; |
| 222 | |
| 223 | buf[ n_read - 1 ] = '\0'; |
| 224 | |
| 225 | while (p && (c = *p) && q < &line[ sizeof (line) - 1 ]) { |
| 226 | if (c == '<') { |
| 227 | /* Parse the magic priority number. */ |
| 228 | pri = 0; |
| 229 | while (isdigit (*(++p))) { |
| 230 | pri = 10 * pri + (*p - '0'); |
| 231 | } |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 232 | if (pri & ~(LOG_FACMASK | LOG_PRIMASK)){ |
Pavel Roskin | da10ec0 | 2000-06-07 21:08:25 +0000 | [diff] [blame] | 233 | pri = (LOG_USER | LOG_NOTICE); |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 234 | } |
Pavel Roskin | da10ec0 | 2000-06-07 21:08:25 +0000 | [diff] [blame] | 235 | } else if (c == '\n') { |
| 236 | *q++ = ' '; |
| 237 | } else if (iscntrl (c) && (c < 0177)) { |
| 238 | *q++ = '^'; |
| 239 | *q++ = c ^ 0100; |
| 240 | } else { |
| 241 | *q++ = c; |
| 242 | } |
| 243 | p++; |
| 244 | } |
| 245 | *q = '\0'; |
| 246 | /* Now log it */ |
| 247 | logMessage (pri, line); |
| 248 | } |
Eric Andersen | 67e3230 | 2000-06-19 17:48:02 +0000 | [diff] [blame] | 249 | return (0); |
Pavel Roskin | da10ec0 | 2000-06-07 21:08:25 +0000 | [diff] [blame] | 250 | } |
| 251 | |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 252 | |
| 253 | #ifdef BB_FEATURE_REMOTE_LOG |
| 254 | static void init_RemoteLog (void){ |
| 255 | |
| 256 | struct sockaddr_in remoteaddr; |
| 257 | struct hostent *hostinfo; |
| 258 | int len = sizeof(remoteaddr); |
| 259 | |
| 260 | bzero(&remoteaddr, len); |
| 261 | |
| 262 | remotefd = socket(AF_INET, SOCK_DGRAM, 0); |
| 263 | |
| 264 | if (remotefd < 0) { |
Mark Whitley | f57c944 | 2000-12-07 19:56:48 +0000 | [diff] [blame] | 265 | error_msg_and_die("syslogd: cannot create socket\n"); |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | hostinfo = (struct hostent *) gethostbyname(RemoteHost); |
| 269 | |
| 270 | if (!hostinfo) { |
Mark Whitley | f57c944 | 2000-12-07 19:56:48 +0000 | [diff] [blame] | 271 | error_msg_and_die("syslogd: cannot resolve remote host name [%s]\n", RemoteHost); |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | remoteaddr.sin_family = AF_INET; |
| 275 | remoteaddr.sin_addr = *(struct in_addr *) *hostinfo->h_addr_list; |
| 276 | remoteaddr.sin_port = htons(RemotePort); |
| 277 | |
| 278 | /* |
| 279 | Since we are using UDP sockets, connect just sets the default host and port |
| 280 | for future operations |
| 281 | */ |
| 282 | if ( 0 != (connect(remotefd, (struct sockaddr *) &remoteaddr, len))){ |
Mark Whitley | f57c944 | 2000-12-07 19:56:48 +0000 | [diff] [blame] | 283 | error_msg_and_die("syslogd: cannot connect to remote host %s:%d\n", RemoteHost, RemotePort); |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | } |
| 287 | #endif |
| 288 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 289 | static void doSyslogd (void) __attribute__ ((noreturn)); |
| 290 | static void doSyslogd (void) |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 291 | { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 292 | struct sockaddr_un sunx; |
Erik Andersen | 1d1d950 | 2000-04-21 01:26:49 +0000 | [diff] [blame] | 293 | socklen_t addrLength; |
| 294 | |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 295 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 296 | int sock_fd; |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 297 | fd_set fds; |
| 298 | |
Eric Andersen | d35c215 | 2001-01-25 23:49:09 +0000 | [diff] [blame^] | 299 | RESERVE_BB_BUFFER(lfile, BUFSIZ); |
Eric Andersen | b99df0f | 1999-11-24 09:04:33 +0000 | [diff] [blame] | 300 | |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 301 | /* Set up signal handlers. */ |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 302 | signal (SIGINT, quit_signal); |
| 303 | signal (SIGTERM, quit_signal); |
| 304 | signal (SIGQUIT, quit_signal); |
| 305 | signal (SIGHUP, SIG_IGN); |
Pavel Roskin | d39d120 | 2000-09-13 14:14:29 +0000 | [diff] [blame] | 306 | signal (SIGCHLD, SIG_IGN); |
| 307 | #ifdef SIGCLD |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 308 | signal (SIGCLD, SIG_IGN); |
Pavel Roskin | d39d120 | 2000-09-13 14:14:29 +0000 | [diff] [blame] | 309 | #endif |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 310 | signal (SIGALRM, domark); |
| 311 | alarm (MarkInterval); |
Eric Andersen | b99df0f | 1999-11-24 09:04:33 +0000 | [diff] [blame] | 312 | |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 313 | /* Create the syslog file so realpath() can work. */ |
| 314 | close (open (_PATH_LOG, O_RDWR | O_CREAT, 0644)); |
| 315 | if (realpath (_PATH_LOG, lfile) == NULL) |
Matt Kraai | 1fa1ade | 2000-12-18 03:57:16 +0000 | [diff] [blame] | 316 | perror_msg_and_die ("Could not resolve path to " _PATH_LOG); |
Eric Andersen | 14ec6cf | 1999-12-05 22:17:02 +0000 | [diff] [blame] | 317 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 318 | unlink (lfile); |
| 319 | |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 320 | memset (&sunx, 0, sizeof (sunx)); |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 321 | sunx.sun_family = AF_UNIX; |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 322 | strncpy (sunx.sun_path, lfile, sizeof (sunx.sun_path)); |
| 323 | if ((sock_fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) |
Matt Kraai | 1fa1ade | 2000-12-18 03:57:16 +0000 | [diff] [blame] | 324 | perror_msg_and_die ("Couldn't obtain descriptor for socket " _PATH_LOG); |
Eric Andersen | b99df0f | 1999-11-24 09:04:33 +0000 | [diff] [blame] | 325 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 326 | addrLength = sizeof (sunx.sun_family) + strlen (sunx.sun_path); |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 327 | if ((bind (sock_fd, (struct sockaddr *) &sunx, addrLength)) || (listen (sock_fd, 5))) |
Matt Kraai | 1fa1ade | 2000-12-18 03:57:16 +0000 | [diff] [blame] | 328 | perror_msg_and_die ("Could not connect to socket " _PATH_LOG); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 329 | |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 330 | if (chmod (lfile, 0666) < 0) |
Matt Kraai | 1fa1ade | 2000-12-18 03:57:16 +0000 | [diff] [blame] | 331 | perror_msg_and_die ("Could not set permission on " _PATH_LOG); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 332 | |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 333 | FD_ZERO (&fds); |
| 334 | FD_SET (sock_fd, &fds); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 335 | |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 336 | #ifdef BB_FEATURE_REMOTE_LOG |
| 337 | if (doRemoteLog == TRUE){ |
| 338 | init_RemoteLog(); |
| 339 | } |
| 340 | #endif |
| 341 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 342 | logMessage (0, "syslogd started: BusyBox v" BB_VER " (" BB_BT ")"); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 343 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 344 | for (;;) { |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 345 | |
| 346 | fd_set readfds; |
| 347 | int n_ready; |
| 348 | int fd; |
| 349 | |
| 350 | memcpy (&readfds, &fds, sizeof (fds)); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 351 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 352 | if ((n_ready = select (FD_SETSIZE, &readfds, NULL, NULL, NULL)) < 0) { |
| 353 | if (errno == EINTR) continue; /* alarm may have happened. */ |
Matt Kraai | 1fa1ade | 2000-12-18 03:57:16 +0000 | [diff] [blame] | 354 | perror_msg_and_die ("select error"); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 355 | } |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 356 | |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 357 | for (fd = 0; (n_ready > 0) && (fd < FD_SETSIZE); fd++) { |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 358 | if (FD_ISSET (fd, &readfds)) { |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 359 | |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 360 | --n_ready; |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 361 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 362 | if (fd == sock_fd) { |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 363 | |
| 364 | int conn; |
| 365 | pid_t pid; |
| 366 | |
Erik Andersen | f13df37 | 2000-04-18 23:51:51 +0000 | [diff] [blame] | 367 | if ((conn = accept (sock_fd, (struct sockaddr *) &sunx, &addrLength)) < 0) { |
Matt Kraai | 1fa1ade | 2000-12-18 03:57:16 +0000 | [diff] [blame] | 368 | perror_msg_and_die ("accept error"); |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 369 | } |
Erik Andersen | a6c7522 | 2000-04-18 00:00:52 +0000 | [diff] [blame] | 370 | |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 371 | pid = fork(); |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 372 | |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 373 | if (pid < 0) { |
| 374 | perror ("syslogd: fork"); |
| 375 | close (conn); |
| 376 | continue; |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 377 | } |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 378 | |
Eric Andersen | b2fc5a0 | 2000-08-20 06:11:32 +0000 | [diff] [blame] | 379 | if (pid == 0) { |
Pavel Roskin | da10ec0 | 2000-06-07 21:08:25 +0000 | [diff] [blame] | 380 | serveConnection (conn); |
Eric Andersen | b2fc5a0 | 2000-08-20 06:11:32 +0000 | [diff] [blame] | 381 | close (conn); |
| 382 | exit( TRUE); |
| 383 | } |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 384 | close (conn); |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 385 | } |
| 386 | } |
| 387 | } |
| 388 | } |
Eric Andersen | b99df0f | 1999-11-24 09:04:33 +0000 | [diff] [blame] | 389 | } |
| 390 | |
Eric Andersen | 03f4c27 | 2000-07-06 23:10:29 +0000 | [diff] [blame] | 391 | #ifdef BB_FEATURE_KLOGD |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 392 | |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 393 | static void klogd_signal(int sig) |
| 394 | { |
Eric Andersen | 67e3230 | 2000-06-19 17:48:02 +0000 | [diff] [blame] | 395 | klogctl(7, NULL, 0); |
| 396 | klogctl(0, 0, 0); |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 397 | logMessage(0, "Kernel log daemon exiting."); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 398 | exit(TRUE); |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 399 | } |
| 400 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 401 | static void doKlogd (void) __attribute__ ((noreturn)); |
| 402 | static void doKlogd (void) |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 403 | { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 404 | int priority = LOG_INFO; |
| 405 | char log_buffer[4096]; |
Eric Andersen | cf7982e | 2000-12-11 16:31:11 +0000 | [diff] [blame] | 406 | int i, n, lastc; |
| 407 | char *start; |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 408 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 409 | /* Set up sig handlers */ |
| 410 | signal(SIGINT, klogd_signal); |
| 411 | signal(SIGKILL, klogd_signal); |
| 412 | signal(SIGTERM, klogd_signal); |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 413 | signal(SIGHUP, SIG_IGN); |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 414 | |
| 415 | #ifdef BB_FEATURE_REMOTE_LOG |
| 416 | if (doRemoteLog == TRUE){ |
| 417 | init_RemoteLog(); |
| 418 | } |
| 419 | #endif |
| 420 | |
Erik Andersen | 9ffdaa6 | 2000-02-11 21:55:04 +0000 | [diff] [blame] | 421 | logMessage(0, "klogd started: " |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 422 | "BusyBox v" BB_VER " (" BB_BT ")"); |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 423 | |
Eric Andersen | cf7982e | 2000-12-11 16:31:11 +0000 | [diff] [blame] | 424 | /* "Open the log. Currently a NOP." */ |
Eric Andersen | 67e3230 | 2000-06-19 17:48:02 +0000 | [diff] [blame] | 425 | klogctl(1, NULL, 0); |
Eric Andersen | 0ecb54a | 1999-12-05 23:24:55 +0000 | [diff] [blame] | 426 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 427 | while (1) { |
| 428 | /* Use kernel syscalls */ |
| 429 | memset(log_buffer, '\0', sizeof(log_buffer)); |
Eric Andersen | cf7982e | 2000-12-11 16:31:11 +0000 | [diff] [blame] | 430 | n = klogctl(2, log_buffer, sizeof(log_buffer)); |
| 431 | if (n < 0) { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 432 | char message[80]; |
| 433 | |
| 434 | if (errno == EINTR) |
| 435 | continue; |
| 436 | snprintf(message, 79, "klogd: Error return from sys_sycall: " \ |
| 437 | "%d - %s.\n", errno, strerror(errno)); |
| 438 | logMessage(LOG_SYSLOG | LOG_ERR, message); |
| 439 | exit(1); |
| 440 | } |
Eric Andersen | cf7982e | 2000-12-11 16:31:11 +0000 | [diff] [blame] | 441 | |
| 442 | /* klogctl buffer parsing modelled after code in dmesg.c */ |
| 443 | start=&log_buffer[0]; |
| 444 | lastc='\0'; |
| 445 | for (i=0; i<n; i++) { |
| 446 | if (lastc == '\0' && log_buffer[i] == '<') { |
| 447 | priority = 0; |
| 448 | i++; |
| 449 | while (isdigit(log_buffer[i])) { |
| 450 | priority = priority*10+(log_buffer[i]-'0'); |
| 451 | i++; |
| 452 | } |
| 453 | if (log_buffer[i] == '>') i++; |
| 454 | start = &log_buffer[i]; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 455 | } |
Eric Andersen | cf7982e | 2000-12-11 16:31:11 +0000 | [diff] [blame] | 456 | if (log_buffer[i] == '\n') { |
| 457 | log_buffer[i] = '\0'; /* zero terminate this message */ |
| 458 | logMessage(LOG_KERN | priority, start); |
| 459 | start = &log_buffer[i+1]; |
| 460 | priority = LOG_INFO; |
| 461 | } |
| 462 | lastc = log_buffer[i]; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 463 | } |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 464 | } |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 465 | |
| 466 | } |
| 467 | |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 468 | #endif |
Eric Andersen | b99df0f | 1999-11-24 09:04:33 +0000 | [diff] [blame] | 469 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 470 | static void daemon_init (char **argv, char *dz, void fn (void)) |
| 471 | { |
| 472 | setsid(); |
| 473 | chdir ("/"); |
| 474 | strncpy(argv[0], dz, strlen(argv[0])); |
| 475 | fn(); |
| 476 | exit(0); |
| 477 | } |
| 478 | |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 479 | extern int syslogd_main(int argc, char **argv) |
| 480 | { |
Eric Andersen | 394cf22 | 2000-12-11 16:48:50 +0000 | [diff] [blame] | 481 | int opt, pid, klogd_pid; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 482 | int doFork = TRUE; |
| 483 | |
Eric Andersen | 03f4c27 | 2000-07-06 23:10:29 +0000 | [diff] [blame] | 484 | #ifdef BB_FEATURE_KLOGD |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 485 | int startKlogd = TRUE; |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 486 | #endif |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 487 | char *p; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 488 | |
Eric Andersen | 394cf22 | 2000-12-11 16:48:50 +0000 | [diff] [blame] | 489 | /* do normal option parsing */ |
| 490 | while ((opt = getopt(argc, argv, "m:nKO:R:L")) > 0) { |
| 491 | switch (opt) { |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 492 | case 'm': |
Eric Andersen | 394cf22 | 2000-12-11 16:48:50 +0000 | [diff] [blame] | 493 | MarkInterval = atoi(optarg) * 60; |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 494 | break; |
| 495 | case 'n': |
| 496 | doFork = FALSE; |
| 497 | break; |
Eric Andersen | 03f4c27 | 2000-07-06 23:10:29 +0000 | [diff] [blame] | 498 | #ifdef BB_FEATURE_KLOGD |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 499 | case 'K': |
| 500 | startKlogd = FALSE; |
| 501 | break; |
| 502 | #endif |
| 503 | case 'O': |
Eric Andersen | 394cf22 | 2000-12-11 16:48:50 +0000 | [diff] [blame] | 504 | logFilePath = strdup(optarg); |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 505 | break; |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 506 | #ifdef BB_FEATURE_REMOTE_LOG |
| 507 | case 'R': |
Eric Andersen | 394cf22 | 2000-12-11 16:48:50 +0000 | [diff] [blame] | 508 | RemoteHost = strdup(optarg); |
| 509 | if ( (p = strchr(RemoteHost, ':'))){ |
| 510 | RemotePort = atoi(p+1); |
| 511 | *p = '\0'; |
| 512 | } |
| 513 | doRemoteLog = TRUE; |
| 514 | break; |
Eric Andersen | 70d09ed | 2000-12-11 16:24:16 +0000 | [diff] [blame] | 515 | case 'L': |
| 516 | local_logging = TRUE; |
Eric Andersen | bf2b8ae | 2000-12-08 19:52:01 +0000 | [diff] [blame] | 517 | break; |
Eric Andersen | ced2cef | 2000-07-20 23:41:24 +0000 | [diff] [blame] | 518 | #endif |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 519 | default: |
| 520 | usage(syslogd_usage); |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 521 | } |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 522 | } |
| 523 | |
Eric Andersen | 4ed1782 | 2000-12-11 19:28:29 +0000 | [diff] [blame] | 524 | #ifdef BB_FEATURE_REMOTE_LOG |
| 525 | /* If they have not specified remote logging, then log locally */ |
| 526 | if (doRemoteLog == FALSE) |
| 527 | local_logging = TRUE; |
| 528 | #endif |
| 529 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 530 | /* Store away localhost's name before the fork */ |
| 531 | gethostname(LocalHostName, sizeof(LocalHostName)); |
| 532 | if ((p = strchr(LocalHostName, '.'))) { |
| 533 | *p++ = '\0'; |
| 534 | } |
| 535 | |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 536 | umask(0); |
| 537 | |
Eric Andersen | 03f4c27 | 2000-07-06 23:10:29 +0000 | [diff] [blame] | 538 | #ifdef BB_FEATURE_KLOGD |
Erik Andersen | e272915 | 2000-02-18 21:34:17 +0000 | [diff] [blame] | 539 | /* Start up the klogd process */ |
| 540 | if (startKlogd == TRUE) { |
| 541 | klogd_pid = fork(); |
| 542 | if (klogd_pid == 0) { |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 543 | daemon_init (argv, "klogd", doKlogd); |
Erik Andersen | e272915 | 2000-02-18 21:34:17 +0000 | [diff] [blame] | 544 | } |
| 545 | } |
| 546 | #endif |
| 547 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 548 | if (doFork == TRUE) { |
| 549 | pid = fork(); |
| 550 | if (pid < 0) |
| 551 | exit(pid); |
| 552 | else if (pid == 0) { |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 553 | daemon_init (argv, "syslogd", doSyslogd); |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 554 | } |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 555 | } else { |
| 556 | doSyslogd(); |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 557 | } |
Eric Andersen | b186d98 | 1999-12-03 09:19:54 +0000 | [diff] [blame] | 558 | |
Matt Kraai | 3e856ce | 2000-12-01 02:55:13 +0000 | [diff] [blame] | 559 | return EXIT_SUCCESS; |
Eric Andersen | 3843e96 | 1999-11-25 07:30:46 +0000 | [diff] [blame] | 560 | } |
Erik Andersen | 983b51b | 2000-04-04 18:14:25 +0000 | [diff] [blame] | 561 | |
| 562 | /* |
Erik Andersen | e3ed156 | 2000-04-19 18:52:56 +0000 | [diff] [blame] | 563 | Local Variables |
| 564 | c-file-style: "linux" |
| 565 | c-basic-offset: 4 |
| 566 | tab-width: 4 |
| 567 | End: |
| 568 | */ |