From nobody Sat Oct 19 13:18:00 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XW2F51wl7z5b5Sm; Sat, 19 Oct 2024 13:18:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XW2F51HYGz4RNb; Sat, 19 Oct 2024 13:18:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729343881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ef8kcIiKcXFA6BCYhsvDBjlA8ozWUoIB1kY9Wfo2d5o=; b=lN1yHho+qfHVhwZ6f55iXM4dsKlTdojai3awQurtju0zGuqGoIoPgI6vuC6dwWj+XB+Vpf v5iSnDu3UwAkvunh27XveQtq2lQr3LrjP3rLVDqTBQG2460Uk9n4KtUBggE0iQT4hL2bc1 ib0VOibh+eMm513CG+7u6/JkXx1TRADg7xZi04zUcXdA0YHjO2FynIKytQFrJN/Q2CkXRn TqmLxQhFed7XlVaGIjiXxZhB4Sdvc6iLGIYJLSJod/NDGp8aLy3xiKwpsyJKTp+w3VLBQ4 2XgcgpXps+4URa2qKaUQJOb5fOaSkTG5Rf0rwg1UbwOHhAvxUIB2bZ/5fL6W7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729343881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ef8kcIiKcXFA6BCYhsvDBjlA8ozWUoIB1kY9Wfo2d5o=; b=nv1tov0zTNS0ez0B/0+Y2naNT86jZLEJP4wE80lFXglPJAe1oh3SVHJLJcKpMvgD+9YFpL /WlyJFFWyiOegYMYdmuP6NG/awR/Innz/Vb6V/GuweEE9DHo70ElGUWBaEk/FNSUqMFxSe o7X1rqfjzncT6GORS1wOL4GlGRnTB41CPZReSKRoH1v0ieYcYpw929UYDy14xlMJqLRgm2 2kvxYZk2DqYbhf8xLrzb/fpVlkxo+0hqWACe/mSwuMnMFsn+cIqstlTl3qHPdtNb28nxIu PtX76tGPfNpMbmGnENdTrdG2LLl2J0fVPu5W61WdB5pCytysi2qiSOM1ulNiSw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729343881; a=rsa-sha256; cv=none; b=yafrAiGfL2s33ip1q0AztASYfqlGj0LANcUaA8Ku7fdVA6FsdiWoVsUnSU+Rb26n3mj0F+ CPgRZjhz171Gw8Sj89UDgd2smnFC/xed64t+xfVQZ3AbogY09Eu2yzWXbHrGlLoLNZnq6F lXsp2RiM5L2+QAudyrxoLuey7XrgF7E1P5Xc7Sulp5J8inLZ7MP4vhG49f1yGye0PKFE/c 5rMGtxLq8FPG3tY8Hx9NL+McC/LLnR9EUV7AK/EqptVd66peJLfii4S2BYLnrsVajnFqev 1z+OtNd6Mc8QJ3vn1TKD40hA7p9vKSCzgzH+9AIOxqWF2u8VvFcz2744Cxzxgg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XW2F50tyqzK7C; Sat, 19 Oct 2024 13:18:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49JDI0Cv003526; Sat, 19 Oct 2024 13:18:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49JDI0pN003523; Sat, 19 Oct 2024 13:18:00 GMT (envelope-from git) Date: Sat, 19 Oct 2024 13:18:00 GMT Message-Id: <202410191318.49JDI0pN003523@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 9ecbda844643 - stable/13 - syslogd: Ignore getaddrinfo() errors if -ss is specified List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9ecbda844643f19aba4c1652b2f9db7c8427d336 Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9ecbda844643f19aba4c1652b2f9db7c8427d336 commit 9ecbda844643f19aba4c1652b2f9db7c8427d336 Author: Mark Johnston AuthorDate: 2024-09-19 10:00:33 +0000 Commit: Mark Johnston CommitDate: 2024-10-19 13:17:51 +0000 syslogd: Ignore getaddrinfo() errors if -ss is specified This can arise if the jail doesn't have networking configured, and if -ss is specified, syslogd won't listen on port 514 anyway. Add a regression test case for this as well. PR: 238006 MFC after: 1 month (cherry picked from commit 5d045d556b1cfeb1487d49017b536afb3df105d3) --- usr.sbin/syslogd/syslogd.c | 8 ++++++++ usr.sbin/syslogd/tests/syslogd_test.sh | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 02f8aa39afe8..e78e2327be3b 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -3825,6 +3825,14 @@ socksetup(struct peer *pe) if (pe->pe_serv == NULL) pe->pe_serv = "syslog"; error = getaddrinfo(pe->pe_name, pe->pe_serv, &hints, &res0); + if (error == EAI_NONAME && pe->pe_name == NULL && SecureMode > 1) { + /* + * If we're in secure mode, we won't open inet sockets anyway. + * This failure can arise legitimately when running in a jail + * without networking. + */ + return (0); + } if (error) { char *msgbuf; diff --git a/usr.sbin/syslogd/tests/syslogd_test.sh b/usr.sbin/syslogd/tests/syslogd_test.sh index e4927868e47f..08e6d76b9ba6 100644 --- a/usr.sbin/syslogd/tests/syslogd_test.sh +++ b/usr.sbin/syslogd/tests/syslogd_test.sh @@ -22,7 +22,13 @@ readonly SYSLOGD_LOCAL_PRIVSOCKET="${PWD}/logpriv.sock" # Start a private syslogd instance. syslogd_start() { - syslogd \ + local jail + + if [ "$1" = "-j" ]; then + jail="jexec $2" + shift 2 + fi + $jail syslogd \ -b ":${SYSLOGD_UDP_PORT}" \ -C \ -d \ @@ -288,6 +294,31 @@ pipe_action_cleanup() syslogd_stop } +atf_test_case "jail_noinet" "cleanup" +jail_noinet_head() +{ + atf_set descr "syslogd -ss can be run in a jail without INET support" + atf_set require.user root +} +jail_noinet_body() +{ + local logfile + + atf_check jail -c name=syslogd_noinet persist + + logfile="${PWD}/jail_noinet.log" + printf "user.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}" + syslogd_start -j syslogd_noinet -ss + + syslogd_log -p user.debug -t "test" -h "${SYSLOGD_LOCAL_SOCKET}" \ + "hello, world" + atf_check -s exit:0 -o match:"test: hello, world" cat "${logfile}" +} +jail_noinet_cleanup() +{ + jail -r syslogd_noinet +} + atf_init_test_cases() { atf_add_test_case "basic" @@ -296,4 +327,5 @@ atf_init_test_cases() atf_add_test_case "host_filter" atf_add_test_case "prop_filter" atf_add_test_case "pipe_action" + atf_add_test_case "jail_noinet" }