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
This commit is contained in:
David Malone 2002-09-04 21:11:25 +00:00
parent 7718f45c22
commit ef21d92fcf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=102940
2 changed files with 24 additions and 6 deletions

View File

@ -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

View File

@ -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)) {