Allow klogd to send LOG_KERN messages to syslogd
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
b15420fdc5
commit
a2feba69e2
15
src/klogd.c
15
src/klogd.c
@ -43,6 +43,8 @@
|
|||||||
#define LOG_BUFFER_SIZE 4096
|
#define LOG_BUFFER_SIZE 4096
|
||||||
#define LOG_LINE_LENGTH 1000
|
#define LOG_LINE_LENGTH 1000
|
||||||
|
|
||||||
|
static struct syslog_data log = SYSLOG_DATA_INIT;
|
||||||
|
|
||||||
static char *PidFile = _PATH_VARRUN "klogd.pid";
|
static char *PidFile = _PATH_VARRUN "klogd.pid";
|
||||||
|
|
||||||
static int kmsg;
|
static int kmsg;
|
||||||
@ -147,7 +149,7 @@ static void Terminate(void)
|
|||||||
|
|
||||||
if (output_file != NULL)
|
if (output_file != NULL)
|
||||||
fclose(output_file);
|
fclose(output_file);
|
||||||
closelog();
|
closelog_r(&log);
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -303,13 +305,13 @@ extern void Syslog(int priority, char *fmt, ...)
|
|||||||
}
|
}
|
||||||
argl += 3;
|
argl += 3;
|
||||||
}
|
}
|
||||||
syslog(priority, fmt, argl);
|
syslog_r(priority, &log, fmt, argl);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsyslog(priority, fmt, ap);
|
vsyslog_r(priority, &log, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,8 +765,11 @@ int main(int argc, char *argv[])
|
|||||||
output, strerror(errno));
|
output, strerror(errno));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
openlog("kernel", 0, LOG_KERN);
|
/* No, I really want to use LOG_KERN */
|
||||||
|
log.log_fac = LOG_KERN;
|
||||||
|
openlog_r("kernel", 0, LOG_KERN, &log);
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle one-shot logging. */
|
/* Handle one-shot logging. */
|
||||||
if (one_shot) {
|
if (one_shot) {
|
||||||
|
@ -233,6 +233,15 @@ int main(int argc, char *argv[])
|
|||||||
funix[i] = -1;
|
funix[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WITHOUT_KLOGD
|
||||||
|
/*
|
||||||
|
* When building with klogd enabled this works around filtering
|
||||||
|
* of LOG_KERN messages in parsemsg(). Otherwise it needs to be
|
||||||
|
* actively enabled to allow logging of remote kernel messages.
|
||||||
|
*/
|
||||||
|
KeepKernFac = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "46Ab:dhHf:l:m:nP:p:R:rs:v?")) != EOF) {
|
while ((ch = getopt(argc, argv, "46Ab:dhHf:l:m:nP:p:R:rs:v?")) != EOF) {
|
||||||
switch ((char)ch) {
|
switch ((char)ch) {
|
||||||
case '4':
|
case '4':
|
||||||
|
Loading…
Reference in New Issue
Block a user