From nobody Sat Oct 19 12:56:30 2024 X-Original-To: dev-commits-src-branches@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 4XW1mH0VJZz5b4PF; Sat, 19 Oct 2024 12:56:31 +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 4XW1mG51w6z4NhX; Sat, 19 Oct 2024 12:56:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729342590; 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=2lHVXFKqiEjmYLKd+GCyAOv9vWMRDQnfNpwuyct4wCc=; b=k32i+REO/ZVtKrcRjQPrxSXMK53C49fbBd/SCRrFDBjVAICnTCyhMxrX3lgsx8icD8Mcy7 XChWXA77r+XJadkzFvGUMrOtpbjr4MQjheWOO0ycCADd29TbL8AlLEE0lkcZC6MXAbpqHS y64CyOyq+uroArdNGh7yPGWtsuO35cGMGAzysrNvB5pQcGozu446UWMYK1vojHIGs3w9nr HeIPXUpH/iG8qLwqOgebQZQAaaabgxIAvCzQee8b0o41GO8fmVreXCJx+P/dBkIbKSOOxM BCf4iPla9Jt8nCPx6yLwrPBVKeidikdBwbpUgU9mLEhIQ/mELDOZP5QUSCnAwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729342590; 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=2lHVXFKqiEjmYLKd+GCyAOv9vWMRDQnfNpwuyct4wCc=; b=fSroSOPI24aiHMOFNH6VtURsEaLGpS4fCDl96oBmGiOBVZknm4dsmJFYbuB9RVTUJIdvGM 6Rga8xdvPTfyiUqhf+ljAohdvr4134cMSVIYyHBVcADn6LoeVtDdR/YDF/PJTPrE0jO162 cE9w5EWZDUecx+bOndeLZtuIa5ycJRxYKRwt0q28wWqCvkDKQU0CWqRCvY9TCorsrI/veI YyGag4bx5J7vnpBJajXxvzNwmsIMGsyi3sbJsWqb4APksOYCP6UAyPVv3tj3mQupU5HVgg xFEWl7fHrXPdtHXd84E0nux3Puy4ob4oeJfo53FLISH/POwiUw0cZZk3cbvU5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729342590; a=rsa-sha256; cv=none; b=U8vkBFTNHZUtJquAQTutorJPs7tz0Q2fTjbeL0ksVDgOKU58oHnKQgapXjW6+JEj0lZNa9 YBABGARCWY7tvOT0PPuqmaBQx5RG362FAOLz0hFiHcOP3pBaz8jLX5mvtYTaEduqUlw7Rr rLez0kg22PlGHSgIKPFKJcrcX70HsXdhpY5q02QrOYL9DIgN1nAS7VI1DyEM5pVQiiwSb1 7jTRoT8qodoIw69ILqT53Jmh2rtUoFjvRyvWp/E42w7N+abIqvu8qlcNJNjm+hUlv+WG0y ykMfku8rWuw0GSz7fZMkY6JEGuyz9uUrEI3gH3NTJFnAbpab9KpcwXHdsS681A== 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 4XW1mG4L5xzJZG; Sat, 19 Oct 2024 12:56:30 +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 49JCuU8E065120; Sat, 19 Oct 2024 12:56:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49JCuUap065117; Sat, 19 Oct 2024 12:56:30 GMT (envelope-from git) Date: Sat, 19 Oct 2024 12:56:30 GMT Message-Id: <202410191256.49JCuUap065117@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: 9c0455e4c43a - stable/14 - syslogd: Ignore getaddrinfo() errors if -ss is specified List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/14 X-Git-Reftype: branch X-Git-Commit: 9c0455e4c43a8123bd7965125d34273c5b3d9eaf Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9c0455e4c43a8123bd7965125d34273c5b3d9eaf commit 9c0455e4c43a8123bd7965125d34273c5b3d9eaf Author: Mark Johnston AuthorDate: 2024-09-19 10:00:33 +0000 Commit: Mark Johnston CommitDate: 2024-10-19 12:55:03 +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 de3d7c106f8a..7356fb3fa43f 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" }