diff options
author | Pavel Roskin <proski@gnu.org> | 2000-06-07 21:08:25 +0000 |
---|---|---|
committer | Pavel Roskin <proski@gnu.org> | 2000-06-07 21:08:25 +0000 |
commit | da10ec0eaaaaacbbd9dfb1b7ff84aab5a2de9e37 (patch) | |
tree | aecf83ac0c40ee2d7d14df0008fed0e2c6a18a70 | |
parent | 0024abcbbc633f4493b97c4b344ed636ea176f3c (diff) | |
download | busybox-w32-da10ec0eaaaaacbbd9dfb1b7ff84aab5a2de9e37.tar.gz busybox-w32-da10ec0eaaaaacbbd9dfb1b7ff84aab5a2de9e37.tar.bz2 busybox-w32-da10ec0eaaaaacbbd9dfb1b7ff84aab5a2de9e37.zip |
Syslogd will not go to background if "-n" is given. Better help
and argument checking
-rw-r--r-- | Changelog | 2 | ||||
-rw-r--r-- | docs/busybox.pod | 11 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 97 | ||||
-rw-r--r-- | syslogd.c | 97 |
4 files changed, 111 insertions, 96 deletions
@@ -65,6 +65,8 @@ | |||
65 | * Implemented 'ls -R' (enabled by enabling BB_FEATURE_LS_RECURSIVE) | 65 | * Implemented 'ls -R' (enabled by enabling BB_FEATURE_LS_RECURSIVE) |
66 | * Implemented "ping -s", fixed error messages and argument parsing - | 66 | * Implemented "ping -s", fixed error messages and argument parsing - |
67 | Pavel Roskin | 67 | Pavel Roskin |
68 | * Syslogd will not go to background if "-n" is given. Better help | ||
69 | and argument checking -- Pavel Roskin | ||
68 | * More doc updates | 70 | * More doc updates |
69 | 71 | ||
70 | 72 | ||
diff --git a/docs/busybox.pod b/docs/busybox.pod index 7a04b8f10..c792444b1 100644 --- a/docs/busybox.pod +++ b/docs/busybox.pod | |||
@@ -1530,11 +1530,10 @@ Linux system and kernel (provides klogd) logging utility. | |||
1530 | Note that this version of syslogd/klogd ignores /etc/syslog.conf. | 1530 | Note that this version of syslogd/klogd ignores /etc/syslog.conf. |
1531 | 1531 | ||
1532 | Options: | 1532 | Options: |
1533 | 1533 | -m NUM Interval between MARK lines (default=20min, 0=off) | |
1534 | -m Change the mark timestamp interval. default=20min. 0=off | 1534 | -n Run as a foreground process |
1535 | -n Do not fork into the background (for when run by init) | 1535 | -K Do not start up the klogd process |
1536 | -K Do not start up the klogd process (by default syslogd spawns klogd). | 1536 | -O FILE Use an alternate log file (default=/var/log/messages) |
1537 | -O Specify an alternate log file. default=/var/log/messages | ||
1538 | 1537 | ||
1539 | ------------------------------- | 1538 | ------------------------------- |
1540 | 1539 | ||
@@ -1949,4 +1948,4 @@ Enrique Zanardi <ezanardi@ull.es> | |||
1949 | 1948 | ||
1950 | =cut | 1949 | =cut |
1951 | 1950 | ||
1952 | # $Id: busybox.pod,v 1.37 2000/06/07 20:38:15 proski Exp $ | 1951 | # $Id: busybox.pod,v 1.38 2000/06/07 21:08:25 proski Exp $ |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 9a4af4926..c7906368d 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -69,12 +69,12 @@ static const char syslogd_usage[] = | |||
69 | "\nLinux system and kernel (provides klogd) logging utility.\n" | 69 | "\nLinux system and kernel (provides klogd) logging utility.\n" |
70 | "Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n" | 70 | "Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n" |
71 | "Options:\n" | 71 | "Options:\n" |
72 | "\t-m\tChange the mark timestamp interval. default=20min. 0=off\n" | 72 | "\t-m NUM\t\tInterval between MARK lines (default=20min, 0=off)\n" |
73 | "\t-n\tDo not fork into the background (for when run by init)\n" | 73 | "\t-n\t\tRun as a foreground process\n" |
74 | #ifdef BB_KLOGD | 74 | #ifdef BB_KLOGD |
75 | "\t-K\tDo not start up the klogd process (by default syslogd spawns klogd).\n" | 75 | "\t-K\t\tDo not start up the klogd process\n" |
76 | #endif | 76 | #endif |
77 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n" | 77 | "\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" |
78 | #endif | 78 | #endif |
79 | ; | 79 | ; |
80 | 80 | ||
@@ -170,6 +170,49 @@ static void domark(int sig) | |||
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | #define BUFSIZE 1023 | ||
174 | static void serveConnection (int conn) __attribute__ ((noreturn)); | ||
175 | static void serveConnection (int conn) | ||
176 | { | ||
177 | char buf[ BUFSIZE + 1 ]; | ||
178 | int n_read; | ||
179 | |||
180 | while ((n_read = read (conn, buf, BUFSIZE )) > 0) { | ||
181 | |||
182 | int pri = (LOG_USER | LOG_NOTICE); | ||
183 | char line[ BUFSIZE + 1 ]; | ||
184 | unsigned char c; | ||
185 | |||
186 | char *p = buf, *q = line; | ||
187 | |||
188 | buf[ n_read - 1 ] = '\0'; | ||
189 | |||
190 | while (p && (c = *p) && q < &line[ sizeof (line) - 1 ]) { | ||
191 | if (c == '<') { | ||
192 | /* Parse the magic priority number. */ | ||
193 | pri = 0; | ||
194 | while (isdigit (*(++p))) { | ||
195 | pri = 10 * pri + (*p - '0'); | ||
196 | } | ||
197 | if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) | ||
198 | pri = (LOG_USER | LOG_NOTICE); | ||
199 | } else if (c == '\n') { | ||
200 | *q++ = ' '; | ||
201 | } else if (iscntrl (c) && (c < 0177)) { | ||
202 | *q++ = '^'; | ||
203 | *q++ = c ^ 0100; | ||
204 | } else { | ||
205 | *q++ = c; | ||
206 | } | ||
207 | p++; | ||
208 | } | ||
209 | *q = '\0'; | ||
210 | /* Now log it */ | ||
211 | logMessage (pri, line); | ||
212 | } | ||
213 | exit (0); | ||
214 | } | ||
215 | |||
173 | static void doSyslogd (void) __attribute__ ((noreturn)); | 216 | static void doSyslogd (void) __attribute__ ((noreturn)); |
174 | static void doSyslogd (void) | 217 | static void doSyslogd (void) |
175 | { | 218 | { |
@@ -251,47 +294,8 @@ static void doSyslogd (void) | |||
251 | continue; | 294 | continue; |
252 | } | 295 | } |
253 | 296 | ||
254 | if (pid > 0) { | 297 | if (pid == 0) |
255 | 298 | serveConnection (conn); | |
256 | # define BUFSIZE 1023 | ||
257 | char buf[ BUFSIZE + 1 ]; | ||
258 | int n_read; | ||
259 | |||
260 | while ((n_read = read (conn, buf, BUFSIZE )) > 0) { | ||
261 | |||
262 | int pri = (LOG_USER | LOG_NOTICE); | ||
263 | char line[ BUFSIZE + 1 ]; | ||
264 | unsigned char c; | ||
265 | |||
266 | char *p = buf, *q = line; | ||
267 | |||
268 | buf[ n_read - 1 ] = '\0'; | ||
269 | |||
270 | while (p && (c = *p) && q < &line[ sizeof (line) - 1 ]) { | ||
271 | if (c == '<') { | ||
272 | /* Parse the magic priority number. */ | ||
273 | pri = 0; | ||
274 | while (isdigit (*(++p))) { | ||
275 | pri = 10 * pri + (*p - '0'); | ||
276 | } | ||
277 | if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) | ||
278 | pri = (LOG_USER | LOG_NOTICE); | ||
279 | } else if (c == '\n') { | ||
280 | *q++ = ' '; | ||
281 | } else if (iscntrl (c) && (c < 0177)) { | ||
282 | *q++ = '^'; | ||
283 | *q++ = c ^ 0100; | ||
284 | } else { | ||
285 | *q++ = c; | ||
286 | } | ||
287 | p++; | ||
288 | } | ||
289 | *q = '\0'; | ||
290 | /* Now log it */ | ||
291 | logMessage (pri, line); | ||
292 | } | ||
293 | exit (0); | ||
294 | } | ||
295 | close (conn); | 299 | close (conn); |
296 | } | 300 | } |
297 | } | 301 | } |
@@ -428,6 +432,9 @@ extern int syslogd_main(int argc, char **argv) | |||
428 | } | 432 | } |
429 | } | 433 | } |
430 | 434 | ||
435 | if (argc > 0) | ||
436 | usage(syslogd_usage); | ||
437 | |||
431 | /* Store away localhost's name before the fork */ | 438 | /* Store away localhost's name before the fork */ |
432 | gethostname(LocalHostName, sizeof(LocalHostName)); | 439 | gethostname(LocalHostName, sizeof(LocalHostName)); |
433 | if ((p = strchr(LocalHostName, '.'))) { | 440 | if ((p = strchr(LocalHostName, '.'))) { |
@@ -69,12 +69,12 @@ static const char syslogd_usage[] = | |||
69 | "\nLinux system and kernel (provides klogd) logging utility.\n" | 69 | "\nLinux system and kernel (provides klogd) logging utility.\n" |
70 | "Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n" | 70 | "Note that this version of syslogd/klogd ignores /etc/syslog.conf.\n\n" |
71 | "Options:\n" | 71 | "Options:\n" |
72 | "\t-m\tChange the mark timestamp interval. default=20min. 0=off\n" | 72 | "\t-m NUM\t\tInterval between MARK lines (default=20min, 0=off)\n" |
73 | "\t-n\tDo not fork into the background (for when run by init)\n" | 73 | "\t-n\t\tRun as a foreground process\n" |
74 | #ifdef BB_KLOGD | 74 | #ifdef BB_KLOGD |
75 | "\t-K\tDo not start up the klogd process (by default syslogd spawns klogd).\n" | 75 | "\t-K\t\tDo not start up the klogd process\n" |
76 | #endif | 76 | #endif |
77 | "\t-O\tSpecify an alternate log file. default=/var/log/messages\n" | 77 | "\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" |
78 | #endif | 78 | #endif |
79 | ; | 79 | ; |
80 | 80 | ||
@@ -170,6 +170,49 @@ static void domark(int sig) | |||
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | #define BUFSIZE 1023 | ||
174 | static void serveConnection (int conn) __attribute__ ((noreturn)); | ||
175 | static void serveConnection (int conn) | ||
176 | { | ||
177 | char buf[ BUFSIZE + 1 ]; | ||
178 | int n_read; | ||
179 | |||
180 | while ((n_read = read (conn, buf, BUFSIZE )) > 0) { | ||
181 | |||
182 | int pri = (LOG_USER | LOG_NOTICE); | ||
183 | char line[ BUFSIZE + 1 ]; | ||
184 | unsigned char c; | ||
185 | |||
186 | char *p = buf, *q = line; | ||
187 | |||
188 | buf[ n_read - 1 ] = '\0'; | ||
189 | |||
190 | while (p && (c = *p) && q < &line[ sizeof (line) - 1 ]) { | ||
191 | if (c == '<') { | ||
192 | /* Parse the magic priority number. */ | ||
193 | pri = 0; | ||
194 | while (isdigit (*(++p))) { | ||
195 | pri = 10 * pri + (*p - '0'); | ||
196 | } | ||
197 | if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) | ||
198 | pri = (LOG_USER | LOG_NOTICE); | ||
199 | } else if (c == '\n') { | ||
200 | *q++ = ' '; | ||
201 | } else if (iscntrl (c) && (c < 0177)) { | ||
202 | *q++ = '^'; | ||
203 | *q++ = c ^ 0100; | ||
204 | } else { | ||
205 | *q++ = c; | ||
206 | } | ||
207 | p++; | ||
208 | } | ||
209 | *q = '\0'; | ||
210 | /* Now log it */ | ||
211 | logMessage (pri, line); | ||
212 | } | ||
213 | exit (0); | ||
214 | } | ||
215 | |||
173 | static void doSyslogd (void) __attribute__ ((noreturn)); | 216 | static void doSyslogd (void) __attribute__ ((noreturn)); |
174 | static void doSyslogd (void) | 217 | static void doSyslogd (void) |
175 | { | 218 | { |
@@ -251,47 +294,8 @@ static void doSyslogd (void) | |||
251 | continue; | 294 | continue; |
252 | } | 295 | } |
253 | 296 | ||
254 | if (pid > 0) { | 297 | if (pid == 0) |
255 | 298 | serveConnection (conn); | |
256 | # define BUFSIZE 1023 | ||
257 | char buf[ BUFSIZE + 1 ]; | ||
258 | int n_read; | ||
259 | |||
260 | while ((n_read = read (conn, buf, BUFSIZE )) > 0) { | ||
261 | |||
262 | int pri = (LOG_USER | LOG_NOTICE); | ||
263 | char line[ BUFSIZE + 1 ]; | ||
264 | unsigned char c; | ||
265 | |||
266 | char *p = buf, *q = line; | ||
267 | |||
268 | buf[ n_read - 1 ] = '\0'; | ||
269 | |||
270 | while (p && (c = *p) && q < &line[ sizeof (line) - 1 ]) { | ||
271 | if (c == '<') { | ||
272 | /* Parse the magic priority number. */ | ||
273 | pri = 0; | ||
274 | while (isdigit (*(++p))) { | ||
275 | pri = 10 * pri + (*p - '0'); | ||
276 | } | ||
277 | if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) | ||
278 | pri = (LOG_USER | LOG_NOTICE); | ||
279 | } else if (c == '\n') { | ||
280 | *q++ = ' '; | ||
281 | } else if (iscntrl (c) && (c < 0177)) { | ||
282 | *q++ = '^'; | ||
283 | *q++ = c ^ 0100; | ||
284 | } else { | ||
285 | *q++ = c; | ||
286 | } | ||
287 | p++; | ||
288 | } | ||
289 | *q = '\0'; | ||
290 | /* Now log it */ | ||
291 | logMessage (pri, line); | ||
292 | } | ||
293 | exit (0); | ||
294 | } | ||
295 | close (conn); | 299 | close (conn); |
296 | } | 300 | } |
297 | } | 301 | } |
@@ -428,6 +432,9 @@ extern int syslogd_main(int argc, char **argv) | |||
428 | } | 432 | } |
429 | } | 433 | } |
430 | 434 | ||
435 | if (argc > 0) | ||
436 | usage(syslogd_usage); | ||
437 | |||
431 | /* Store away localhost's name before the fork */ | 438 | /* Store away localhost's name before the fork */ |
432 | gethostname(LocalHostName, sizeof(LocalHostName)); | 439 | gethostname(LocalHostName, sizeof(LocalHostName)); |
433 | if ((p = strchr(LocalHostName, '.'))) { | 440 | if ((p = strchr(LocalHostName, '.'))) { |