diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-04-16 20:15:14 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-04-16 20:15:14 +0200 |
commit | 0288b27ad870adc437c370c262b7b41990ae0118 (patch) | |
tree | faa0c0dd84073b77b233d933c8cd39aa1d60ccc3 | |
parent | 89b3cbaa97d715ac27e9558ea73a1221925f589b (diff) | |
download | busybox-w32-0288b27ad870adc437c370c262b7b41990ae0118.tar.gz busybox-w32-0288b27ad870adc437c370c262b7b41990ae0118.tar.bz2 busybox-w32-0288b27ad870adc437c370c262b7b41990ae0118.zip |
small fixes atop syslog config patch
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | docs/syslog.conf.txt | 28 | ||||
-rw-r--r-- | libbb/get_line_from_file.c | 6 | ||||
-rw-r--r-- | sysklogd/Config.src | 2 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 12 |
4 files changed, 39 insertions, 9 deletions
diff --git a/docs/syslog.conf.txt b/docs/syslog.conf.txt new file mode 100644 index 000000000..6d9c4a173 --- /dev/null +++ b/docs/syslog.conf.txt | |||
@@ -0,0 +1,28 @@ | |||
1 | If syslogd applet compiled with FEATURE_SYSLOGD_CFG=y, then it supports restricted syslog.conf. | ||
2 | The config resembles rsyslog.conf in RULES part: | ||
3 | |||
4 | LINE = DELIM [RULE | COMMENT] | ||
5 | COMMENT = #.* | ||
6 | DELIM = SPACE TAB | ||
7 | RULE = SELECTOR [;SELECTOR]* DELIM* ACTION DELIM* | ||
8 | SELECTOR = FACILITY [,FACILITY]* .[[!]=] PRIORITY | ||
9 | FACILITY = * | kern | user ... (see syslog.h) | ||
10 | PRIORITY = * | emerg | alert ... (see syslog.h) | ||
11 | ACTION = FILE | ||
12 | |||
13 | "mark" facility is NOT supported. | ||
14 | "none" priority is supported. | ||
15 | In FACILITY and PRIORITY "*" stands for "any". | ||
16 | FILE is a regular file or tty device. | ||
17 | |||
18 | Here is an example: | ||
19 | |||
20 | #syslog.conf | ||
21 | kern,user.* /var/log/messages #all messages of kern and user facilities | ||
22 | kern.!err /var/log/critical #all messages of kern facility with priorities lower than err (warn, notice ...) | ||
23 | *.*;auth,authpriv.none /var/log/noauth #all messages except ones with auth and authpriv facilities | ||
24 | kern,user.*;kern.!=notice;*.err;syslog.none /var/log/OMG #some whicked rule just as an example =) | ||
25 | *.* /dev/null #this prevents from logging to default log file (-O FILE or /var/log/messages) | ||
26 | |||
27 | Even in the case of match with some rule another rules will be tried too. | ||
28 | If there was no match with any of the rules, logging to default log file or shared memory will be performed. | ||
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c index a0ed9193f..9be10687b 100644 --- a/libbb/get_line_from_file.c +++ b/libbb/get_line_from_file.c | |||
@@ -44,8 +44,12 @@ char* FAST_FUNC bb_get_chunk_with_continuation(FILE *file, int *end, int *lineno | |||
44 | idx -= 2; | 44 | idx -= 2; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | if (end) | 47 | if (end) { |
48 | *end = idx; | 48 | *end = idx; |
49 | /* handle corner case when the file is not ended with '\n' */ | ||
50 | if (ch == EOF && lineno != NULL) | ||
51 | (*lineno)++; | ||
52 | } | ||
49 | if (linebuf) { | 53 | if (linebuf) { |
50 | // huh, does fgets discard prior data on error like this? | 54 | // huh, does fgets discard prior data on error like this? |
51 | // I don't think so.... | 55 | // I don't think so.... |
diff --git a/sysklogd/Config.src b/sysklogd/Config.src index b3e13d7c0..b7a494eff 100644 --- a/sysklogd/Config.src +++ b/sysklogd/Config.src | |||
@@ -57,7 +57,7 @@ config FEATURE_SYSLOGD_CFG | |||
57 | default y | 57 | default y |
58 | depends on SYSLOGD | 58 | depends on SYSLOGD |
59 | help | 59 | help |
60 | Supports restricted syslogd config. | 60 | Supports restricted syslogd config. See docs/syslog.conf.txt |
61 | 61 | ||
62 | config FEATURE_SYSLOGD_READ_BUFFER_SIZE | 62 | config FEATURE_SYSLOGD_READ_BUFFER_SIZE |
63 | int "Read buffer size in bytes" | 63 | int "Read buffer size in bytes" |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 0799038e9..b6f409f41 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -33,6 +33,8 @@ | |||
33 | //usage: "\n -D Drop duplicates") | 33 | //usage: "\n -D Drop duplicates") |
34 | //usage: IF_FEATURE_IPC_SYSLOG( | 34 | //usage: IF_FEATURE_IPC_SYSLOG( |
35 | //usage: "\n -C[size(KiB)] Log to shared mem buffer (read it using logread)") | 35 | //usage: "\n -C[size(KiB)] Log to shared mem buffer (read it using logread)") |
36 | //usage: IF_FEATURE_SYSLOGD_CFG( | ||
37 | //usage: "\n -f FILE Use FILE as config (default is /etc/syslog.conf)") | ||
36 | /* NB: -Csize shouldn't have space (because size is optional) */ | 38 | /* NB: -Csize shouldn't have space (because size is optional) */ |
37 | /* //usage: "\n -m MIN Minutes between MARK lines (default:20, 0=off)" */ | 39 | /* //usage: "\n -m MIN Minutes between MARK lines (default:20, 0=off)" */ |
38 | //usage: | 40 | //usage: |
@@ -284,10 +286,8 @@ static void parse_syslogdcfg(const char *file) | |||
284 | logRule_t *cur_rule; | 286 | logRule_t *cur_rule; |
285 | 287 | ||
286 | /* unexpected trailing token? */ | 288 | /* unexpected trailing token? */ |
287 | if (tok[2]) { | 289 | if (tok[2]) |
288 | t = tok[2]; | ||
289 | goto cfgerr; | 290 | goto cfgerr; |
290 | } | ||
291 | 291 | ||
292 | cur_rule = *pp_rule = xzalloc(sizeof(*cur_rule)); | 292 | cur_rule = *pp_rule = xzalloc(sizeof(*cur_rule)); |
293 | 293 | ||
@@ -307,10 +307,8 @@ static void parse_syslogdcfg(const char *file) | |||
307 | *next_selector++ = '\0'; | 307 | *next_selector++ = '\0'; |
308 | 308 | ||
309 | t = strchr(cur_selector, '.'); | 309 | t = strchr(cur_selector, '.'); |
310 | if (!t) { | 310 | if (!t) |
311 | t = cur_selector; | ||
312 | goto cfgerr; | 311 | goto cfgerr; |
313 | } | ||
314 | *t++ = '\0'; /* separate facility from priority */ | 312 | *t++ = '\0'; /* separate facility from priority */ |
315 | 313 | ||
316 | negated_prio = 0; | 314 | negated_prio = 0; |
@@ -414,7 +412,7 @@ static void parse_syslogdcfg(const char *file) | |||
414 | return; | 412 | return; |
415 | 413 | ||
416 | cfgerr: | 414 | cfgerr: |
417 | bb_error_msg_and_die("bad line %d: wrong token '%s'", parser->lineno, t); | 415 | bb_error_msg_and_die("error in '%s' at line %d", file, parser->lineno); |
418 | } | 416 | } |
419 | #endif | 417 | #endif |
420 | 418 | ||