summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorthomas <thomas@FreeBSD.org>2003-02-13 00:08:56 +0000
committerthomas <thomas@FreeBSD.org>2003-02-13 00:08:56 +0000
commit946eac9366509b6c6dd690b9b601e8d63b7ddcc8 (patch)
treedab802923d0e868bff1d1b5901b6e07ab47192a6 /usr.sbin
parent77b0e93625ad7dc5c4db4ad10125b8162e458e8c (diff)
downloadFreeBSD-src-946eac9366509b6c6dd690b9b601e8d63b7ddcc8.zip
FreeBSD-src-946eac9366509b6c6dd690b9b601e8d63b7ddcc8.tar.gz
Allow multiple hosts or programs to be named in program
or host specifications, eg: !foo,bar *.* /var/log/only_foo_or_bar.log !-foo,bar *.* /var/log/all_except_foo_or_bar.log Reviewed by: roberto Not objected to by: arch@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/syslogd/syslog.conf.512
-rw-r--r--usr.sbin/syslogd/syslogd.c33
2 files changed, 39 insertions, 6 deletions
diff --git a/usr.sbin/syslogd/syslog.conf.5 b/usr.sbin/syslogd/syslog.conf.5
index 328e3a6..f13f1bf 100644
--- a/usr.sbin/syslogd/syslog.conf.5
+++ b/usr.sbin/syslogd/syslog.conf.5
@@ -196,6 +196,15 @@ or
.Ql !-prog
specification will match any message but the ones from that
program.
+Multiple programs may be listed, separated by commas:
+.Ql !prog1,prog2
+matches messages from either program, while
+.Ql !-prog1,prog2
+matches all messages but those from
+.Ql prog1
+or
+.Ql prog2 .
+.Pp
A
.Em hostname
specification of the form
@@ -215,6 +224,9 @@ from any host but the one specified.
If the hostname is given as
.Ql @ ,
the local hostname will be used.
+As for program specifications, multiple comma-seprarated
+values may be specified for hostname specifications.
+.Pp
A
.Em program
or
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index f8fb385..92d1605 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -764,17 +764,38 @@ static time_t now;
*/
static int
skip_message(const char *name, const char *spec) {
+ const char *s;
+ char prev, next;
+ int exclude = 0;
+ /* Behaviour on explicit match */
+
if (spec == NULL)
return 0;
-
- switch (spec[0]) {
- case '+':
- return (strcmp(name, spec + 1) != 0);
+ switch (*spec) {
case '-':
- return (strcmp(name, spec + 1) == 0);
+ exclude = 1;
+ /*FALLTHROUGH*/
+ case '+':
+ spec++;
+ break;
default:
- return (strcmp(name, spec) != 0);
+ break;
}
+ s = strstr (spec, name);
+
+ if (s != NULL) {
+ prev = (s == spec ? ',' : *(s - 1));
+ next = *(s + strlen (name));
+
+ if (prev == ',' && (next == '\0' || next == ','))
+ /* Explicit match: skip iff the spec is an
+ exclusive one. */
+ return exclude;
+ }
+
+ /* No explicit match for this name: skip the message iff
+ the spec is an inclusive one. */
+ return !exclude;
}
/*
OpenPOWER on IntegriCloud