summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r--usr.sbin/syslogd/syslogd.84
-rw-r--r--usr.sbin/syslogd/syslogd.c48
2 files changed, 44 insertions, 8 deletions
diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8
index b2e8818..3074d08 100644
--- a/usr.sbin/syslogd/syslogd.8
+++ b/usr.sbin/syslogd/syslogd.8
@@ -28,7 +28,7 @@
.\" @(#)syslogd.8 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd March 3, 2015
+.Dd June 16, 2015
.Dt SYSLOGD 8
.Os
.Sh NAME
@@ -194,6 +194,8 @@ The default
.Ar service
is
.Ql syslog .
+This option can be specified multiple times to bind to
+multiple addresses and/or ports.
.It Fl C
Create log files that do not exist (permission is set to
.Li 0600 ) .
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index baa79c8..55c0379 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -124,6 +124,15 @@ const char ctty[] = _PATH_CONSOLE;
#define MAXUNAMES 20 /* maximum number of user names */
/*
+ * List of hosts for binding.
+ */
+static STAILQ_HEAD(, host) hqueue;
+struct host {
+ char *name;
+ STAILQ_ENTRY(host) next;
+};
+
+/*
* Unix sockets.
* We have two default sockets, one with 666 permissions,
* and one for privileged programs.
@@ -275,7 +284,7 @@ static int Foreground = 0; /* Run in foreground, instead of daemonizing */
static int resolve = 1; /* resolve hostname */
static char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */
static const char *LocalDomain; /* our local domain name */
-static int *finet; /* Internet datagram socket */
+static int *finet; /* Internet datagram sockets */
static int fklog = -1; /* /dev/klog */
static int Initialized; /* set when we have initialized ourselves */
static int MarkInterval = 20 * 60; /* interval between marks in seconds */
@@ -348,10 +357,10 @@ main(int argc, char *argv[])
struct sockaddr_storage frominet;
fd_set *fdsr = NULL;
char line[MAXLINE + 1];
- char *bindhostname;
const char *hname;
struct timeval tv, *tvp;
struct sigaction sact;
+ struct host *host;
struct funix *fx, *fx1;
sigset_t mask;
pid_t ppid = 1, spid;
@@ -360,7 +369,8 @@ main(int argc, char *argv[])
if (madvise(NULL, 0, MADV_PROTECT) != 0)
dprintf("madvise() failed: %s\n", strerror(errno));
- bindhostname = NULL;
+ STAILQ_INIT(&hqueue);
+
while ((ch = getopt(argc, argv, "468Aa:b:cCdf:Fkl:m:nNop:P:sS:Tuv"))
!= -1)
switch (ch) {
@@ -383,8 +393,13 @@ main(int argc, char *argv[])
usage();
break;
case 'b':
- bindhostname = optarg;
+ {
+ if ((host = malloc(sizeof(struct host))) == NULL)
+ err(1, "malloc failed");
+ host->name = optarg;
+ STAILQ_INSERT_TAIL(&hqueue, host, next);
break;
+ }
case 'c':
no_compress++;
break;
@@ -433,7 +448,7 @@ main(int argc, char *argv[])
if (strlen(name) >= sizeof(sunx.sun_path))
errx(1, "%s path too long, exiting", name);
if ((fx = malloc(sizeof(struct funix))) == NULL)
- errx(1, "malloc failed");
+ err(1, "malloc failed");
fx->s = -1;
fx->name = name;
fx->mode = mode;
@@ -555,8 +570,26 @@ main(int argc, char *argv[])
}
increase_rcvbuf(fx->s);
}
- if (SecureMode <= 1)
- finet = socksetup(family, bindhostname);
+ if (SecureMode <= 1) {
+ if (STAILQ_EMPTY(&hqueue))
+ finet = socksetup(family, NULL);
+ STAILQ_FOREACH(host, &hqueue, next) {
+ int *finet0, total;
+ finet0 = socksetup(family, host->name);
+ if (finet0 && !finet) {
+ finet = finet0;
+ } else if (finet0 && finet) {
+ total = *finet0 + *finet + 1;
+ finet = realloc(finet, total * sizeof(int));
+ if (finet == NULL)
+ err(1, "realloc failed");
+ for (i = 1; i <= *finet0; i++) {
+ finet[(*finet)+i] = finet0[i];
+ }
+ *finet = total - 1;
+ }
+ }
+ }
if (finet) {
if (SecureMode) {
@@ -2730,6 +2763,7 @@ socksetup(int af, char *bindhostname)
}
(*socks)++;
+ dprintf("socksetup: new socket fd is %d\n", *s);
s++;
}
OpenPOWER on IntegriCloud