syslogd: support for extracting user level messages from /dev/kmsg
It is well established practise on Linux to use /dev/kmsg (old or new API) before syslogd is up (and /dev/log exists). This patch enables support for extracting non-kernel log messages and logging them with their proper facility and priority. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
parent
7ce44f5b9e
commit
fc5096f1c2
@ -1230,6 +1230,33 @@ void printsys(char *msg)
|
||||
if (buffer.pri & ~(LOG_FACMASK | LOG_PRIMASK))
|
||||
buffer.pri = DEFSPRI;
|
||||
|
||||
/*
|
||||
* Check for user writing to /dev/kmsg before /dev/log
|
||||
* is up. Syntax to write: <PRI>APP_NAME[PROC_ID]:msg
|
||||
*/
|
||||
if (buffer.pri & LOG_FACMASK) {
|
||||
for (q = p; *q && !isspace(*q) && *q != '['; q++)
|
||||
;
|
||||
|
||||
if (*q == '[') {
|
||||
char *ptr = &q[1];
|
||||
|
||||
while (*ptr && isdigit(*ptr))
|
||||
ptr++;
|
||||
|
||||
if (ptr[0] == ']' && ptr[1] == ':') {
|
||||
*ptr++ = 0;
|
||||
*q++ = 0;
|
||||
|
||||
buffer.app_name = p;
|
||||
buffer.proc_id = q;
|
||||
|
||||
/* user log message cont. here */
|
||||
p = &ptr[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
q = lp;
|
||||
while (*p != '\0' && (c = *p++) != '\n' && q < &line[MAXLINE]) {
|
||||
/* Linux /dev/kmsg C-style hex encoding. */
|
||||
|
Loading…
Reference in New Issue
Block a user