summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2016-10-17 11:19:55 +0000
committerbluhm <bluhm@openbsd.org>2016-10-17 11:19:55 +0000
commit396e0a96d8bb8d9ab4a1c73efd6d80c8d80adde5 (patch)
tree7a29d2600a86031feeb4c29a3e8c2b0a1cdeed78
parentUse strtoull() to read the datapath id and expect "datapath" instead of (diff)
downloadwireguard-openbsd-396e0a96d8bb8d9ab4a1c73efd6d80c8d80adde5.tar.xz
wireguard-openbsd-396e0a96d8bb8d9ab4a1c73efd6d80c8d80adde5.zip
Remove the artificial maximum number of unix domain sockets in
syslogd(8). Just malloc(3) them dynamically which also gives a more random address space layout. OK deraadt@
-rw-r--r--usr.sbin/syslogd/syslogd.85
-rw-r--r--usr.sbin/syslogd/syslogd.c20
-rw-r--r--usr.sbin/syslogd/syslogd.h5
3 files changed, 18 insertions, 12 deletions
diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8
index 044a93abc0b..34dc7cb4c59 100644
--- a/usr.sbin/syslogd/syslogd.8
+++ b/usr.sbin/syslogd/syslogd.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: syslogd.8,v 1.51 2016/10/04 22:09:21 bluhm Exp $
+.\" $OpenBSD: syslogd.8,v 1.52 2016/10/17 11:19:55 bluhm Exp $
.\"
.\" Copyright (c) 1983, 1986, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -30,7 +30,7 @@
.\" from: @(#)syslogd.8 8.1 (Berkeley) 6/6/93
.\" $NetBSD: syslogd.8,v 1.3 1996/01/02 17:41:48 perry Exp $
.\"
-.Dd $Mdocdate: October 4 2016 $
+.Dd $Mdocdate: October 17 2016 $
.Dt SYSLOGD 8
.Os
.Sh NAME
@@ -75,7 +75,6 @@ to use only IPv6 addresses for UDP.
Specify a location where
.Nm
should place an additional log socket.
-Up to 20 additional logging sockets can be specified.
The primary use for this is to place additional log sockets in
.Pa /dev/log
of various chroot filespaces, though the need for these is
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 7690f2787dd..e8babd0b10f 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslogd.c,v 1.220 2016/10/16 22:12:50 bluhm Exp $ */
+/* $OpenBSD: syslogd.c,v 1.221 2016/10/17 11:19:55 bluhm Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
@@ -197,8 +197,8 @@ char *TypeNames[] = {
SIMPLEQ_HEAD(filed_list, filed) Files;
struct filed consfile;
-int nunix = 1; /* Number of Unix domain sockets requested */
-char *path_unix[MAXUNIX] = { _PATH_LOG }; /* Paths to Unix domain sockets */
+int nunix; /* Number of Unix domain sockets requested */
+char **path_unix; /* Paths to Unix domain sockets */
int Debug; /* debug flag */
int Foreground; /* run in foreground, instead of daemonizing */
int Startup = 1; /* startup flag */
@@ -359,7 +359,12 @@ main(int argc, char *argv[])
int ch, i;
int lockpipe[2] = { -1, -1}, pair[2], nullfd, fd;
int fd_ctlsock, fd_klog, fd_sendsys, fd_bind, fd_listen;
- int fd_unix[MAXUNIX];
+ int *fd_unix;
+
+ if ((path_unix = malloc(sizeof(*path_unix))) == NULL)
+ err(1, "malloc %s", _PATH_LOG);
+ path_unix[0] = _PATH_LOG;
+ nunix = 1;
while ((ch = getopt(argc, argv, "46a:C:c:dFf:hK:k:m:nP:p:S:s:T:U:uVZ"))
!= -1)
@@ -371,8 +376,9 @@ main(int argc, char *argv[])
Family = PF_INET6;
break;
case 'a':
- if (nunix >= MAXUNIX)
- errx(1, "out of descriptors: %s", optarg);
+ if ((path_unix = reallocarray(path_unix, nunix + 1,
+ sizeof(*path_unix))) == NULL)
+ err(1, "malloc %s", optarg);
path_unix[nunix++] = optarg;
break;
case 'C': /* file containing CA certificates */
@@ -520,6 +526,8 @@ main(int argc, char *argv[])
die(0);
}
+ if ((fd_unix = reallocarray(NULL, nunix, sizeof(*fd_unix))) == NULL)
+ err(1, "malloc unix");
for (i = 0; i < nunix; i++) {
fd_unix[i] = unix_socket(path_unix[i], SOCK_DGRAM, 0666);
if (fd_unix[i] == -1) {
diff --git a/usr.sbin/syslogd/syslogd.h b/usr.sbin/syslogd/syslogd.h
index f95c66a4b7f..2dd444d117b 100644
--- a/usr.sbin/syslogd/syslogd.h
+++ b/usr.sbin/syslogd/syslogd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslogd.h,v 1.25 2016/10/16 22:00:14 bluhm Exp $ */
+/* $OpenBSD: syslogd.h,v 1.26 2016/10/17 11:19:55 bluhm Exp $ */
/*
* Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org>
@@ -42,9 +42,8 @@ void send_fd(int, int);
int receive_fd(int);
/* The list of domain sockets */
-#define MAXUNIX 21
extern int nunix;
-extern char *path_unix[MAXUNIX];
+extern char **path_unix;
extern char *path_ctlsock;
#define MAXLINE 8192 /* maximum line length */