syslogd: Add FreeBSD -k option to allow LOG_KERNEL facility messages

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-13 16:44:51 +01:00
parent c465f340bc
commit 9d415f313f
4 changed files with 22 additions and 8 deletions

View File

@ -13,7 +13,7 @@
.Nd System Log Daemon
.Sh SYNOPSIS
.Nm
.Op Fl ?46AdnsTv
.Op Fl ?46AdknsTv
.Op Fl a Ar addr[/len][:port]
.Op Fl a Ar name[:port]
.Op Fl b Ar addr[:port]
@ -185,6 +185,19 @@ consecutively. The
message is only written if the log file hasn't been touched in
.Ar (seconds * 60) / 2
minutes.
.It Fl k
Disable the translation of messages received with facility
.Ql kern
to
facility
.Ql user .
Usually the
.Ql kern
facility is reserved for kernel log messages. When the
.Nm klogd
daemon runs alongside
.Nm ,
this option is always set.
.It Fl n
Run in foreground, required when run from a modern init/supervisor. See
your system

View File

@ -35,7 +35,7 @@ syslogd_CPPFLAGS = $(AM_CPPFLAGS) -D_XOPEN_SOURCE=600
syslogd_LDADD = $(LIBS) $(LIBOBJS)
klogd_SOURCES = klogd.c klogd.h syslog.h compat.h ksym.c ksyms.h ksym_mod.c module.h
klogd_CPPFLAGS = $(AM_CPPFLAGS) -DALLOW_KERNEL_LOGGING
klogd_CPPFLAGS = $(AM_CPPFLAGS)
klogd_LDADD = $(LIBS) $(LIBOBJS)
klogd_LDADD += libsyslog.la

View File

@ -526,11 +526,7 @@ openlog_unlocked_r(const char *ident, int logstat, int logfac,
if (ident != NULL)
data->log_tag = ident;
data->log_stat = logstat;
#ifdef ALLOW_KERNEL_LOGGING
if ((logfac & ~LOG_FACMASK) == 0)
#else
if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
#endif
data->log_fac = logfac;
if (data->log_stat & LOG_NDELAY) /* open immediately */

View File

@ -194,8 +194,8 @@ static int addpeer(struct peer *pe0)
int usage(int code)
{
printf("Usage:\n"
" syslogd [-46Adnrsv?] [-a PEER] [-b :PORT] [-b ADDR[:PORT]] [-f FILE] [-m SEC]\n"
" [-P PID_FILE] [-p SOCK_PATH] [-R SIZE[:NUM]]\n"
" syslogd [-46Adknrsv?] [-a PEER] [-b :PORT] [-b ADDR[:PORT]] [-f FILE] [-m SEC]\n"
" [-P PID_FILE] [-p SOCK_PATH] [-R SIZE[:NUM]]\n"
"Options:\n"
" -4 Force IPv4 only\n"
" -6 Force IPv6 only\n"
@ -222,6 +222,7 @@ int usage(int code)
"\n"
" -d Enable debug mode\n"
" -f FILE Alternate .conf file, default: /etc/syslog.conf\n"
" -k Allow logging with facility 'kernel', otherwise remapped to 'user'.\n"
" -m SEC Interval between MARK messages in log, 0 to disable, default: 20 min\n"
" -n Run in foreground, required when run from a modern init/supervisor\n"
" -P FILE File to store the process ID, default: %s\n"
@ -304,6 +305,10 @@ int main(int argc, char *argv[])
RemoteHostname = 1;
break;
case 'k': /* keep remote kern fac */
KeepKernFac = 1;
break;
case 'm': /* mark interval */
MarkInterval = atoi(optarg) * 60;
break;