syslogd: Adopt FreeBSD -F instead of -n to run in foreground

This change will probably break most installations.  We do this to free
up '-n' for use as disabling DNS lookups, from FreeBSD *and* NetBSD.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-13 17:05:42 +01:00
parent 9d415f313f
commit cf9d281e5b
5 changed files with 19 additions and 18 deletions

View File

@ -27,12 +27,13 @@ and a replacement for `syslog.h` to enable new features in RFC5424.
- New tool `logger` from the Finit project, BSD licensed - New tool `logger` from the Finit project, BSD licensed
- New `syslogp()` API from NetBSD, for applications wanting to use - New `syslogp()` API from NetBSD, for applications wanting to use
RFC5424 features like MsgID or structured data RFC5424 features like MsgID or structured data
- Incompatible changes to command line options for `syslogd` and - Incompatible changes to command line options in `syslogd` and `klogd`
`klogd`, e.g; for compatiblity with FreeBSD and NetBSD syslogd:
- In syslogd: `-b` and `-c` have been replaced with `-r` for global - In syslogd: `-b` and `-c` have been replaced with `-r` for global
log rotation, `-a` has been replaced with the new `-p` support. The log rotation, `-a` has been replaced with the new `-p` support. The
`-r` flag and `-s HOST` has also been dropped in favor of the BSD `-r` flag and `-s HOST` has also been dropped in favor of the BSD
`-s` flag to control two levels of _secure mode_ `-s` flag to control two levels of _secure mode_. The `-n` flag is
now `-F` and `-n` means something else entirely ...
- In klogd: `-i` and `-I` have been removed - In klogd: `-i` and `-I` have been removed
- Update COPYING file to GPL 2 rev 2, with new FSF address and other minor stuff - Update COPYING file to GPL 2 rev 2, with new FSF address and other minor stuff
- Update license header in all files: - Update license header in all files:

View File

@ -13,7 +13,7 @@
.Nd System Log Daemon .Nd System Log Daemon
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl ?46AdknsTv .Op Fl ?46AdFksTv
.Op Fl a Ar addr[/len][:port] .Op Fl a Ar addr[/len][:port]
.Op Fl a Ar name[:port] .Op Fl a Ar name[:port]
.Op Fl b Ar addr[:port] .Op Fl b Ar addr[:port]
@ -169,6 +169,11 @@ TTY. SIGUSR1 is required to confirm continued debug messages when the
daemon has finished starting up. See the daemon has finished starting up. See the
.Sx DEBUGGING .Sx DEBUGGING
section for more information. section for more information.
.It Fl F
Run in foreground, required when run from a modern init/supervisor. See
your system
.Xr init 1
for details.
.It Fl f Ar file .It Fl f Ar file
Specify an alternative configuration file instead of the default Specify an alternative configuration file instead of the default
.Pa /etc/syslog.conf . .Pa /etc/syslog.conf .
@ -198,11 +203,6 @@ facility is reserved for kernel log messages. When the
daemon runs alongside daemon runs alongside
.Nm , .Nm ,
this option is always set. this option is always set.
.It Fl n
Run in foreground, required when run from a modern init/supervisor. See
your system
.Xr init 1
for details.
.It Fl P Ar file .It Fl P Ar file
Specify an alternate file in which to store the process ID. Specify an alternate file in which to store the process ID.
The default is The default is

View File

@ -194,7 +194,7 @@ static int addpeer(struct peer *pe0)
int usage(int code) int usage(int code)
{ {
printf("Usage:\n" printf("Usage:\n"
" syslogd [-46Adknrsv?] [-a PEER] [-b :PORT] [-b ADDR[:PORT]] [-f FILE] [-m SEC]\n" " syslogd [-46AdFkrsv?] [-a PEER] [-b :PORT] [-b ADDR[:PORT]] [-f FILE] [-m SEC]\n"
" [-P PID_FILE] [-p SOCK_PATH] [-R SIZE[:NUM]]\n" " [-P PID_FILE] [-p SOCK_PATH] [-R SIZE[:NUM]]\n"
"Options:\n" "Options:\n"
" -4 Force IPv4 only\n" " -4 Force IPv4 only\n"
@ -221,10 +221,10 @@ int usage(int code)
" service name, default is 'syslog', port 514.\n" " service name, default is 'syslog', port 514.\n"
"\n" "\n"
" -d Enable debug mode\n" " -d Enable debug mode\n"
" -F Run in foreground, required when run from a modern init/supervisor\n"
" -f FILE Alternate .conf file, default: /etc/syslog.conf\n" " -f FILE Alternate .conf file, default: /etc/syslog.conf\n"
" -k Allow logging with facility 'kernel', otherwise remapped to 'user'.\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" " -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" " -P FILE File to store the process ID, default: %s\n"
" -p PATH Path to UNIX domain socket, multiple -p create multiple sockets. If\n" " -p PATH Path to UNIX domain socket, multiple -p create multiple sockets. If\n"
" no -p argument is given the default %s is used\n" " no -p argument is given the default %s is used\n"
@ -263,7 +263,7 @@ int main(int argc, char *argv[])
KeepKernFac = 1; KeepKernFac = 1;
#endif #endif
while ((ch = getopt(argc, argv, "46Aa:b:dHf:m:nP:p:r:sv?")) != EOF) { while ((ch = getopt(argc, argv, "46Aa:b:dHFf:m:P:p:r:sv?")) != EOF) {
switch ((char)ch) { switch ((char)ch) {
case '4': case '4':
family = PF_INET; family = PF_INET;
@ -297,6 +297,10 @@ int main(int argc, char *argv[])
Debug = 1; Debug = 1;
break; break;
case 'F': /* don't fork */
Foreground = 1;
break;
case 'f': /* configuration file */ case 'f': /* configuration file */
ConfFile = optarg; ConfFile = optarg;
break; break;
@ -313,10 +317,6 @@ int main(int argc, char *argv[])
MarkInterval = atoi(optarg) * 60; MarkInterval = atoi(optarg) * 60;
break; break;
case 'n': /* don't fork */
Foreground = 1;
break;
case 'P': case 'P':
PidFile = optarg; PidFile = optarg;
break; break;

View File

@ -6,7 +6,7 @@ Requires=syslog.socket
[Service] [Service]
Type=simple Type=simple
ExecStart=@SBINDIR@/syslogd -sn ExecStart=@SBINDIR@/syslogd -sF
StandardOutput=null StandardOutput=null
Restart=on-failure Restart=on-failure

View File

@ -20,7 +20,7 @@ cat <<EOF > ${CONFD}/bar.conf
*.* @127.0.0.2 *.* @127.0.0.2
EOF EOF
../src/syslogd -b :${PORT} -d -sn -f ${CONF} -p ${SOCK} -p ${ALTSOCK} & ../src/syslogd -b :${PORT} -d -sF -f ${CONF} -p ${SOCK} -p ${ALTSOCK} &
echo "$!" > ${PID} echo "$!" > ${PID}
sleep 2 sleep 2