syslogd: Improve handling of configuration errors
Make parse_selector() print a warning to stderr and continue parsing the
config if it encounters an invalid facility or priority. Note that
because the parsing is done from a casper service, there isn't a good
mechanism to log errors; the warnings are visible only when syslogd is
started in debug mode.
Reported by: Doug Hardie <bc979@lafn.org>
MFC after: 1 week
Fixes: f4b4a10abb ("syslogd: Move selector parsing into its own function")
Reviewed by: jfree, jlduran, eugen, delphij
Differential Revision: https://reviews.freebsd.org/D55033
This commit is contained in:
@@ -2932,8 +2932,9 @@ parse_selector(const char *p, struct filed *f)
|
||||
|
||||
pri = decode(buf, prioritynames);
|
||||
if (pri < 0) {
|
||||
dprintf("unknown priority name \"%s\"", buf);
|
||||
return (NULL);
|
||||
warnx("unknown priority name \"%s\", setting to 'info'",
|
||||
buf);
|
||||
pri = LOG_INFO;
|
||||
}
|
||||
}
|
||||
if (!pri_cmp)
|
||||
@@ -2955,11 +2956,12 @@ parse_selector(const char *p, struct filed *f)
|
||||
} else {
|
||||
i = decode(buf, facilitynames);
|
||||
if (i < 0) {
|
||||
dprintf("unknown facility name \"%s\"", buf);
|
||||
return (NULL);
|
||||
warnx("unknown facility name \"%s\", ignoring",
|
||||
buf);
|
||||
} else {
|
||||
f->f_pmask[i >> 3] = pri;
|
||||
f->f_pcmp[i >> 3] = pri_cmp;
|
||||
}
|
||||
f->f_pmask[i >> 3] = pri;
|
||||
f->f_pcmp[i >> 3] = pri_cmp;
|
||||
}
|
||||
while (*p == ',' || *p == ' ')
|
||||
p++;
|
||||
|
||||
Reference in New Issue
Block a user