small fixes atop syslog config patch
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
89b3cbaa97
commit
0288b27ad8
28
docs/syslog.conf.txt
Normal file
28
docs/syslog.conf.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
If syslogd applet compiled with FEATURE_SYSLOGD_CFG=y, then it supports restricted syslog.conf.
|
||||||
|
The config resembles rsyslog.conf in RULES part:
|
||||||
|
|
||||||
|
LINE = DELIM [RULE | COMMENT]
|
||||||
|
COMMENT = #.*
|
||||||
|
DELIM = SPACE TAB
|
||||||
|
RULE = SELECTOR [;SELECTOR]* DELIM* ACTION DELIM*
|
||||||
|
SELECTOR = FACILITY [,FACILITY]* .[[!]=] PRIORITY
|
||||||
|
FACILITY = * | kern | user ... (see syslog.h)
|
||||||
|
PRIORITY = * | emerg | alert ... (see syslog.h)
|
||||||
|
ACTION = FILE
|
||||||
|
|
||||||
|
"mark" facility is NOT supported.
|
||||||
|
"none" priority is supported.
|
||||||
|
In FACILITY and PRIORITY "*" stands for "any".
|
||||||
|
FILE is a regular file or tty device.
|
||||||
|
|
||||||
|
Here is an example:
|
||||||
|
|
||||||
|
#syslog.conf
|
||||||
|
kern,user.* /var/log/messages #all messages of kern and user facilities
|
||||||
|
kern.!err /var/log/critical #all messages of kern facility with priorities lower than err (warn, notice ...)
|
||||||
|
*.*;auth,authpriv.none /var/log/noauth #all messages except ones with auth and authpriv facilities
|
||||||
|
kern,user.*;kern.!=notice;*.err;syslog.none /var/log/OMG #some whicked rule just as an example =)
|
||||||
|
*.* /dev/null #this prevents from logging to default log file (-O FILE or /var/log/messages)
|
||||||
|
|
||||||
|
Even in the case of match with some rule another rules will be tried too.
|
||||||
|
If there was no match with any of the rules, logging to default log file or shared memory will be performed.
|
@ -44,8 +44,12 @@ char* FAST_FUNC bb_get_chunk_with_continuation(FILE *file, int *end, int *lineno
|
|||||||
idx -= 2;
|
idx -= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (end)
|
if (end) {
|
||||||
*end = idx;
|
*end = idx;
|
||||||
|
/* handle corner case when the file is not ended with '\n' */
|
||||||
|
if (ch == EOF && lineno != NULL)
|
||||||
|
(*lineno)++;
|
||||||
|
}
|
||||||
if (linebuf) {
|
if (linebuf) {
|
||||||
// huh, does fgets discard prior data on error like this?
|
// huh, does fgets discard prior data on error like this?
|
||||||
// I don't think so....
|
// I don't think so....
|
||||||
|
@ -57,7 +57,7 @@ config FEATURE_SYSLOGD_CFG
|
|||||||
default y
|
default y
|
||||||
depends on SYSLOGD
|
depends on SYSLOGD
|
||||||
help
|
help
|
||||||
Supports restricted syslogd config.
|
Supports restricted syslogd config. See docs/syslog.conf.txt
|
||||||
|
|
||||||
config FEATURE_SYSLOGD_READ_BUFFER_SIZE
|
config FEATURE_SYSLOGD_READ_BUFFER_SIZE
|
||||||
int "Read buffer size in bytes"
|
int "Read buffer size in bytes"
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
//usage: "\n -D Drop duplicates")
|
//usage: "\n -D Drop duplicates")
|
||||||
//usage: IF_FEATURE_IPC_SYSLOG(
|
//usage: IF_FEATURE_IPC_SYSLOG(
|
||||||
//usage: "\n -C[size(KiB)] Log to shared mem buffer (read it using logread)")
|
//usage: "\n -C[size(KiB)] Log to shared mem buffer (read it using logread)")
|
||||||
|
//usage: IF_FEATURE_SYSLOGD_CFG(
|
||||||
|
//usage: "\n -f FILE Use FILE as config (default is /etc/syslog.conf)")
|
||||||
/* NB: -Csize shouldn't have space (because size is optional) */
|
/* NB: -Csize shouldn't have space (because size is optional) */
|
||||||
/* //usage: "\n -m MIN Minutes between MARK lines (default:20, 0=off)" */
|
/* //usage: "\n -m MIN Minutes between MARK lines (default:20, 0=off)" */
|
||||||
//usage:
|
//usage:
|
||||||
@ -284,10 +286,8 @@ static void parse_syslogdcfg(const char *file)
|
|||||||
logRule_t *cur_rule;
|
logRule_t *cur_rule;
|
||||||
|
|
||||||
/* unexpected trailing token? */
|
/* unexpected trailing token? */
|
||||||
if (tok[2]) {
|
if (tok[2])
|
||||||
t = tok[2];
|
|
||||||
goto cfgerr;
|
goto cfgerr;
|
||||||
}
|
|
||||||
|
|
||||||
cur_rule = *pp_rule = xzalloc(sizeof(*cur_rule));
|
cur_rule = *pp_rule = xzalloc(sizeof(*cur_rule));
|
||||||
|
|
||||||
@ -307,10 +307,8 @@ static void parse_syslogdcfg(const char *file)
|
|||||||
*next_selector++ = '\0';
|
*next_selector++ = '\0';
|
||||||
|
|
||||||
t = strchr(cur_selector, '.');
|
t = strchr(cur_selector, '.');
|
||||||
if (!t) {
|
if (!t)
|
||||||
t = cur_selector;
|
|
||||||
goto cfgerr;
|
goto cfgerr;
|
||||||
}
|
|
||||||
*t++ = '\0'; /* separate facility from priority */
|
*t++ = '\0'; /* separate facility from priority */
|
||||||
|
|
||||||
negated_prio = 0;
|
negated_prio = 0;
|
||||||
@ -414,7 +412,7 @@ static void parse_syslogdcfg(const char *file)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
cfgerr:
|
cfgerr:
|
||||||
bb_error_msg_and_die("bad line %d: wrong token '%s'", parser->lineno, t);
|
bb_error_msg_and_die("error in '%s' at line %d", file, parser->lineno);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user