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 `syslogp()` API from NetBSD, for applications wanting to use
RFC5424 features like MsgID or structured data
- Incompatible changes to command line options for `syslogd` and
`klogd`, e.g;
- Incompatible changes to command line options in `syslogd` and `klogd`
for compatiblity with FreeBSD and NetBSD syslogd:
- In syslogd: `-b` and `-c` have been replaced with `-r` for global
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
`-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
- Update COPYING file to GPL 2 rev 2, with new FSF address and other minor stuff
- Update license header in all files:

View File

@ -13,7 +13,7 @@
.Nd System Log Daemon
.Sh SYNOPSIS
.Nm
.Op Fl ?46AdknsTv
.Op Fl ?46AdFksTv
.Op Fl a Ar addr[/len][:port]
.Op Fl a Ar name[: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
.Sx DEBUGGING
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
Specify an alternative configuration file instead of the default
.Pa /etc/syslog.conf .
@ -198,11 +203,6 @@ facility is reserved for kernel log messages. When the
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
.Xr init 1
for details.
.It Fl P Ar file
Specify an alternate file in which to store the process ID.
The default is

View File

@ -194,7 +194,7 @@ static int addpeer(struct peer *pe0)
int usage(int code)
{
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"
"Options:\n"
" -4 Force IPv4 only\n"
@ -221,10 +221,10 @@ int usage(int code)
" service name, default is 'syslog', port 514.\n"
"\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"
" -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"
" -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"
@ -263,7 +263,7 @@ int main(int argc, char *argv[])
KeepKernFac = 1;
#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) {
case '4':
family = PF_INET;
@ -297,6 +297,10 @@ int main(int argc, char *argv[])
Debug = 1;
break;
case 'F': /* don't fork */
Foreground = 1;
break;
case 'f': /* configuration file */
ConfFile = optarg;
break;
@ -313,10 +317,6 @@ int main(int argc, char *argv[])
MarkInterval = atoi(optarg) * 60;
break;
case 'n': /* don't fork */
Foreground = 1;
break;
case 'P':
PidFile = optarg;
break;

View File

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

View File

@ -20,7 +20,7 @@ cat <<EOF > ${CONFD}/bar.conf
*.* @127.0.0.2
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}
sleep 2