diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/syslogd/syslog.conf.5 | 12 | ||||
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 33 |
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; } /* |