syslogd: Drop -a SOCK support, replaced with multiple -p SOCK args

The -p SOCK syntax is what NetBSD syslogd use, so this is more of an
alignment with upstream.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-07 17:46:15 +01:00
parent d723574eee
commit f8e87f143d
2 changed files with 40 additions and 35 deletions

View File

@ -14,7 +14,6 @@
.Sh SYNOPSIS
.Nm
.Op Fl ?46Adhnrv
.Op Fl a Ar SOCK
.Op Fl b Ar :SVC
.Op Fl f Ar FILE
.Op Fl l Ar HOST[:HOST]
@ -94,18 +93,6 @@ tries to send the message to only one address even if the host has
more than one A or AAAA record. If this option is specified,
.Nm
tries to send the message to all addresses.
.It Fl a Ar SOCK
Using this argument you can specify additional sockets from that
.Nm
has to listen to. This is needed if you're going to let some daemon
run within a
.Xr chroot 8
environment. You can use up to 19 additional sockets. If your
environment needs even more, you have to increase the symbol
.Ql MAXFUNIX
within the
.Pa syslogd.c
source file.
.It Fl b Ar :service
Bind to a specific port. The port can be specified as a service name or
number. The default service is
@ -159,6 +146,16 @@ The default is
.It Fl p Ar SOCK
Specify an alternate UNIX domain socket instead of the default
.Pa /dev/log .
When a single
.Fl p
option is specified, the default pathname is replaced with the specified
one. When two or more
.Fl p
options are specified, the remaining pathnames are treated as additional
log sockets. This might be needed when running applications in
containers or a
.Xr chroot 8
environment. In total 20 UNIX domain sockets are supported.
.It Fl R Ar size[:count]
Enable built-in support for log rotation of files listed in
.Pa /etc/syslog.conf .

View File

@ -110,11 +110,9 @@ static int restart = 0;
#define MAXFUNIX 20
int nfunix = 1;
char *funixn[MAXFUNIX] = { _PATH_LOG };
int funix[MAXFUNIX] = {
-1,
};
int nfunix;
char *funixn[MAXFUNIX];
int funix[MAXFUNIX];
/*
* Intervals at which we flush out "message repeated" messages,
@ -199,12 +197,12 @@ int main(int argc, char *argv[])
int num_fds, maxfds;
int i, ch;
for (i = 1; i < MAXFUNIX; i++) {
funixn[i] = "";
for (i = 0; i < MAXFUNIX; i++) {
funixn[i] = NULL;
funix[i] = -1;
}
while ((ch = getopt(argc, argv, "46Aa:b: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) {
case '4':
family = PF_INET;
@ -218,13 +216,6 @@ int main(int argc, char *argv[])
send_to_all++;
break;
case 'a':
if (nfunix < MAXFUNIX)
funixn[nfunix++] = optarg;
else
fprintf(stderr, "Out of descriptors, ignoring %s\n", optarg);
break;
case 'b':
ptr = strchr(optarg, ':');
if (ptr)
@ -269,7 +260,10 @@ int main(int argc, char *argv[])
break;
case 'p': /* path to regular log socket */
funixn[0] = optarg;
if (nfunix < MAXFUNIX)
funixn[nfunix++] = optarg;
else
fprintf(stderr, "Max log sockets reached, ignoring %s\n", optarg);
break;
case 'R':
@ -306,6 +300,10 @@ int main(int argc, char *argv[])
if ((argc -= optind))
usage(1);
/* Default to _PATH_LOG for the UNIX domain socket */
if (!nfunix)
funixn[nfunix++] = _PATH_LOG;
if ((!Foreground) && (!Debug)) {
signal(SIGTERM, doexit);
chdir("/");
@ -2295,13 +2293,23 @@ void init(void)
fhead = newf;
for (i = 0; i < nfunix; i++) {
if (funix[i] != -1)
/* Don't close the socket, preserve it instead
close(funix[i]);
*/
/*
* UNIX domain sockets are given on the command line, so
* there's no need to close them if they're already
* open. Doing so would only cause loss of any already
* buffered messages
*/
logit("Checking if we should open UNIX socket %s ...", funixn[i]);
if (funix[i] != -1) {
logit(" nope, already open.\n");
continue;
if ((funix[i] = create_unix_socket(funixn[i])) != -1)
logit("Opened UNIX socket `%s'.\n", funixn[i]);
}
funix[i] = create_unix_socket(funixn[i]);
if (funix[i] == -1)
logit(" failed, error %d: %s\n", strerror(errno));
else
logit(" opened successfully\n", funixn[i]);
}
if (cffwd() || AcceptRemote) {