diff options
author | cognet <cognet@FreeBSD.org> | 2005-09-28 16:05:13 +0000 |
---|---|---|
committer | cognet <cognet@FreeBSD.org> | 2005-09-28 16:05:13 +0000 |
commit | 74216dceb21edf3d8580d114039d8d54c94913d2 (patch) | |
tree | 0d926698d97ab1f76d0fac145c752dea6de7a2fa /usr.sbin/syslogd/syslogd.c | |
parent | 2e1aceea336eca52ab7cd6387b0c3447a5d0e48c (diff) | |
download | FreeBSD-src-74216dceb21edf3d8580d114039d8d54c94913d2.zip FreeBSD-src-74216dceb21edf3d8580d114039d8d54c94913d2.tar.gz |
Use SO_REUSEADDR on the socket, to make the use of syslogd in jails easier.
Submitted by: Jeremie Le Hen <jeremie le-hen org>
Diffstat (limited to 'usr.sbin/syslogd/syslogd.c')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index ead508a..19f03cd 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -2553,13 +2553,13 @@ socksetup(int af, const char *bindhostname) *socks = 0; /* num of sockets counter at start of array */ s = socks + 1; for (r = res; r; r = r->ai_next) { + int on = 1; *s = socket(r->ai_family, r->ai_socktype, r->ai_protocol); if (*s < 0) { logerror("socket"); continue; } if (r->ai_family == AF_INET6) { - int on = 1; if (setsockopt(*s, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&on, sizeof (on)) < 0) { logerror("setsockopt"); @@ -2567,6 +2567,12 @@ socksetup(int af, const char *bindhostname) continue; } } + if (setsockopt(*s, SOL_SOCKET, SO_REUSEADDR, + (char *)&on, sizeof (on)) < 1) { + logerror("setsockopt"); + close(*s); + continue; + } if (bind(*s, r->ai_addr, r->ai_addrlen) < 0) { close(*s); logerror("bind"); |