diff options
author | Maxim Sobolev <sobomax@FreeBSD.org> | 2017-04-15 18:20:11 +0000 |
---|---|---|
committer | Maxim Sobolev <sobomax@FreeBSD.org> | 2017-04-15 18:20:11 +0000 |
commit | 023653459a4a36a26d7b7de3de8ea30c031d2eb3 (patch) | |
tree | e36d117263e4c93d055f13a41609f109a8693682 /usr.sbin/syslogd | |
parent | e0427caa4724ed22961a05f4e2b3c31fca76b9f0 (diff) | |
download | src-023653459a4a36a26d7b7de3de8ea30c031d2eb3.tar.gz src-023653459a4a36a26d7b7de3de8ea30c031d2eb3.zip |
Fix another logic bug that came out of recent syslogd refactoring and exposed by
the r316874: don't call shutdown(2) on all sockets, but only net ones, which seems
to be the behaviour existed before that refactoring. Also don't call listen(2)
in datagram sockets and fix misplaced debug messages while I am here.
Reported by: peter
Notes
Notes:
svn path=/head/; revision=316973
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 6861c0945090..86f9faaf9f5d 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -3003,10 +3003,14 @@ socksetup(struct peer *pe) continue; } dprintf("new socket fd is %d\n", s); - listen(s, 5); + if (res->ai_socktype != SOCK_DGRAM) { + listen(s, 5); + } sl_recv = socklist_recv_sock; - dprintf("shutdown\n"); - if (SecureMode || res->ai_family == AF_LOCAL) { +#if defined(INET) || defined(INET6) + if (SecureMode && (res->ai_family == AF_INET || + res->ai_family == AF_INET6)) { + dprintf("shutdown\n"); /* Forbid communication in secure mode. */ if (shutdown(s, SHUT_RD) < 0 && errno != ENOTCONN) { @@ -3014,10 +3018,11 @@ socksetup(struct peer *pe) if (!Debug) die(0); } - dprintf("listening on socket\n"); sl_recv = NULL; } else - dprintf("sending on socket\n"); +#endif + dprintf("listening on socket\n"); + dprintf("sending on socket\n"); addsock(res->ai_addr, res->ai_addrlen, &(struct socklist){ .sl_socket = s, |