git: 94cae4cb339a - main - syslogd: Do not add shutdown sockets to the kqueue

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 28 Sep 2023 15:52:49 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=94cae4cb339a839b9f9a1b35226de06271017b25

commit 94cae4cb339a839b9f9a1b35226de06271017b25
Author:     Jake Freeland <jfree@FreeBSD.org>
AuthorDate: 2023-09-01 02:51:33 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-09-28 15:51:54 +0000

    syslogd: Do not add shutdown sockets to the kqueue
    
    If syslogd is in secure mode, all INET sockets are shutdown. Do not
    add these to the kqueue because we can't read from them.
    
    Also, remove the listen() call when setting up sockets. Syslogd
    exclusively uses SOCK_DGRAM sockets, so calling listen() is useless.
    
    Reviewed by:    markj
    MFC after:      3 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D41526
---
 usr.sbin/syslogd/syslogd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 8d2f3c3edf14..7db5bab11008 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -825,6 +825,8 @@ main(int argc, char *argv[])
 		exit(1);
 	}
 	STAILQ_FOREACH(sl, &shead, next) {
+		if (sl->sl_recv == NULL)
+			continue;
 		EV_SET(&ev, sl->sl_socket, EVFILT_READ, EV_ADD, 0, 0, sl);
 		if (kevent(kq, &ev, 1, NULL, 0, NULL) == -1) {
 			warn("failed to add kevent to kqueue");
@@ -3741,9 +3743,6 @@ socksetup(struct addrinfo *ai, const char *name, mode_t mode)
 		return (NULL);
 	}
 	dprintf("new socket fd is %d\n", s);
-	if (ai->ai_socktype != SOCK_DGRAM) {
-		listen(s, 5);
-	}
 	sl_recv = socklist_recv_sock;
 #if defined(INET) || defined(INET6)
 	if (SecureMode && (ai->ai_family == AF_INET ||