diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-09-01 17:53:15 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2015-09-01 17:53:15 +0000 |
commit | b30cb16b80dd0f40005e804685a7d7755d9cfd4e (patch) | |
tree | c3dcb961d6c11a865ca9749e57a9b8294dedae20 /usr.sbin | |
parent | bc8b4535170ccb9a6902fab3919f6a55a6b4a78f (diff) |
Bind the *:514 UDP socket of syslogd with SO_REUSEADDR. This avoids
conflicts with other processes bound to a specific address with the
same port. Syslogd uses this socket basically for outgoing traffic
to remote UDP log servers, so increase the chance that it works.
OK jung@ benno@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 07976b4b664..a59d5fdc11b 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.180 2015/08/31 20:44:47 bluhm Exp $ */ +/* $OpenBSD: syslogd.c,v 1.181 2015/09/01 17:53:14 bluhm Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -334,7 +334,7 @@ void usage(void); void wallmsg(struct filed *, struct iovec *); int loghost_parse(char *, char **, char **, char **); int getmsgbufsize(void); -int socket_bind(const char *, const char *, const char *, int, int, +int socket_bind(const char *, const char *, const char *, int, int *, int *); int unix_socket(char *, int, mode_t); void double_rbuf(int); @@ -450,7 +450,7 @@ main(int argc, char *argv[]) die(0); } - if (socket_bind("udp", NULL, "syslog", 0, SecureMode, + if (socket_bind("udp", NULL, "syslog", SecureMode, &fd_udp, &fd_udp6) == -1) { errno = 0; logerror("socket bind *"); @@ -458,7 +458,7 @@ main(int argc, char *argv[]) die(0); } fd_bind = -1; - if (bind_host && socket_bind("udp", bind_host, bind_port, 1, 0, + if (bind_host && socket_bind("udp", bind_host, bind_port, 0, &fd_bind, &fd_bind) == -1) { errno = 0; logerror("socket bind udp"); @@ -466,7 +466,7 @@ main(int argc, char *argv[]) die(0); } fd_listen = -1; - if (listen_host && socket_bind("tcp", listen_host, listen_port, 1, 0, + if (listen_host && socket_bind("tcp", listen_host, listen_port, 0, &fd_listen, &fd_listen) == -1) { errno = 0; logerror("socket listen tcp"); @@ -695,12 +695,12 @@ main(int argc, char *argv[]) int socket_bind(const char *proto, const char *host, const char *port, - int reuseaddr, int shutread, int *fd, int *fd6) + int shutread, int *fd, int *fd6) { struct addrinfo hints, *res, *res0; char hostname[NI_MAXHOST], servname[NI_MAXSERV]; char ebuf[ERRBUFSIZE]; - int *fdp, error; + int *fdp, error, reuseaddr; *fd = *fd6 = -1; if (proto == NULL) @@ -761,6 +761,7 @@ socket_bind(const char *proto, const char *host, const char *port, *fdp = -1; continue; } + reuseaddr = 1; if (setsockopt(*fdp, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr)) == -1) { snprintf(ebuf, sizeof(ebuf), "setsockopt SO_REUSEADDR " |