diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2002-09-04 21:11:25 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2002-09-04 21:11:25 +0000 |
commit | 1f58f0ce9d1143460cc873b7efc47a383cc8dda4 (patch) | |
tree | fc971c3ee029d907f0ef1ee3bd7d9fe99ca6b515 /usr.sbin | |
parent | 31656d5090302f29415b0e07edf932feab5d7de2 (diff) | |
download | FreeBSD-src-1f58f0ce9d1143460cc873b7efc47a383cc8dda4.zip FreeBSD-src-1f58f0ce9d1143460cc873b7efc47a383cc8dda4.tar.gz |
Make syslogd -u treat "*" as all levels by explictly setting pri_cmp
for it.
While I'm here, add a the ability to say "!level" in a way which
should be compatible with Linux's syslogd.
PR: 28935
No objections: audit
MFC after: 2 weeks
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/syslogd/syslog.conf.5 | 11 | ||||
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 19 |
2 files changed, 24 insertions, 6 deletions
diff --git a/usr.sbin/syslogd/syslog.conf.5 b/usr.sbin/syslogd/syslog.conf.5 index acf6ebc..18579a3 100644 --- a/usr.sbin/syslogd/syslog.conf.5 +++ b/usr.sbin/syslogd/syslog.conf.5 @@ -85,7 +85,7 @@ are encoded as a a period .Pq Dq \&. , an optional set of comparison flags -.Pq Bq <=> , +.Pq Bo ! Bc Bq <=> , and a .Em level , with no intervening white-space. @@ -123,6 +123,15 @@ list of a priority level equal or greater than .Em level will be logged. +Comparison flags beginning with +.Do ! Dc +will have their logical sense inverted. +Thus +.Dq !=info +means all levels except info and +.Dq !notice +has the same meaning as +.Dq <notice . .Pp The .Em level diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index b269387..999254a 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1608,6 +1608,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) for (p = line; *p && *p != '\t' && *p != ' ';) { int pri_done; int pri_cmp; + int pri_invert; /* find the end of this facility name list */ for (q = p; *q && *q != '\t' && *q != ' ' && *q++ != '.'; ) @@ -1616,6 +1617,11 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) /* get the priority comparison */ pri_cmp = 0; pri_done = 0; + pri_invert = 0; + if (*q == '!') { + pri_invert = 1; + q++; + } while (!pri_done) { switch (*q) { case '<': @@ -1635,11 +1641,6 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) break; } } - if (!pri_cmp) - pri_cmp = (UniquePriority) - ? (PRI_EQ) - : (PRI_EQ | PRI_GT) - ; /* collect priority name */ for (bp = buf; *q && !strchr("\t,; ", *q); ) @@ -1653,6 +1654,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) /* decode priority name */ if (*buf == '*') { pri = LOG_PRIMASK + 1; + pri_cmp = PRI_LT | PRI_EQ | PRI_GT; } else { pri = decode(buf, prioritynames); if (pri < 0) { @@ -1662,6 +1664,13 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) return; } } + if (!pri_cmp) + pri_cmp = (UniquePriority) + ? (PRI_EQ) + : (PRI_EQ | PRI_GT) + ; + if (pri_invert) + pri_cmp ^= PRI_LT | PRI_EQ | PRI_GT; /* scan facilities */ while (*p && !strchr("\t.; ", *p)) { |