From 9470af395f283b087b09cd68611ad6fc13cb7b5e Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Sat, 7 Nov 2020 17:18:44 +0000 Subject: [PATCH] syslogd: Stop trying to send remote messages through special sockets Specifically this was causing the /dev/klog fd and the signal pipe handling fd to get a sendmsg(2) called on them and always returned [ENOTSOCK]. r310350 combined these sockets into the main socket list and properly skipped AF_UNSPEC at the sendmsg(2) call but later in r344739 it was broken such that these special sockets were no longer excluded since the AF_UNSPEC check specifically excluded these special sockets. Only these special sockets have sl_sa = NULL. The sl_family checks should be redundant now but are left in case of future changes so the intent is clearer. MFC after: 2 weeks --- usr.sbin/syslogd/syslogd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 8cd4cdde9db9..bc797f44eb6b 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1871,9 +1871,9 @@ fprintlog_write(struct filed *f, struct iovlist *il, int flags) STAILQ_FOREACH(sl, &shead, next) { if (sl->sl_socket < 0) continue; - if (sl->sl_sa != NULL && - (sl->sl_family == AF_LOCAL || - sl->sl_family == AF_UNSPEC)) + if (sl->sl_sa == NULL || + sl->sl_family == AF_UNSPEC || + sl->sl_family == AF_LOCAL) { continue; lsent = sendmsg(sl->sl_socket, &msghdr, 0); if (lsent == (ssize_t)il->totalsize)