aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorIan Dowse <iedowse@FreeBSD.org>2004-01-26 00:46:46 +0000
committerIan Dowse <iedowse@FreeBSD.org>2004-01-26 00:46:46 +0000
commitff96c77dc40bd28cb74baeb1acb79535fb928044 (patch)
treeed870542c76896b525b926dba8de9d4a48e9a5df /usr.sbin
parente7245381b9488fd2429b3397239fbec9c8882bd9 (diff)
downloadsrc-ff96c77dc40bd28cb74baeb1acb79535fb928044.tar.gz
src-ff96c77dc40bd28cb74baeb1acb79535fb928044.zip
Be much more strict about parsing tagged log messages from /dev/klog;
if the line doesn't match ^<%d>, then treat it as a regular kernel printf line. Previously if a kernel printf message started with "<" it would be interpreted as a log message, often with LOG_EMERG level. This was triggered by some printfs in sys/dev/aic7xxx/, and can also happen with the partial lines that result if syslogd cannot keep up with the rate of arrival of kernel messages. Reviewed by: dwmalone MFC after: 1 week
Notes
Notes: svn path=/head/; revision=124992
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/syslogd/syslogd.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index c47dfa9e91de..0acb9ffcc478 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -734,24 +734,34 @@ readklog(void)
* Take a raw input line from /dev/klog, format similar to syslog().
*/
static void
-printsys(char *p)
+printsys(char *msg)
{
- int pri, flags;
+ char *p;
+ int flags, isprintf, n, pri;
flags = ISKERNEL | SYNC_FILE | ADDDATE; /* fsync after write */
pri = DEFSPRI;
+ p = msg;
+ isprintf = 1;
if (*p == '<') {
- pri = 0;
+ n = 0;
while (isdigit(*++p))
- pri = 10 * pri + (*p - '0');
- if (*p == '>')
+ n = 10 * n + (*p - '0');
+ if (*p == '>') {
++p;
- if ((pri & LOG_FACMASK) == LOG_CONSOLE)
- flags |= IGN_CONS;
- } else {
- /* kernel printf's come out on console */
- flags |= IGN_CONS;
+ pri = n;
+ isprintf = 0;
+ } else {
+ /* It wasn't actually a syslog message. */
+ p = msg;
+ }
}
+ /*
+ * Kernel printf's and LOG_CONSOLE messages have been displayed
+ * on the console already.
+ */
+ if (isprintf || (pri & LOG_FACMASK) == LOG_CONSOLE)
+ flags |= IGN_CONS;
if (pri &~ (LOG_FACMASK|LOG_PRIMASK))
pri = DEFSPRI;
logmsg(pri, p, LocalHostName, flags);