From nobody Wed Mar 4 14:45:10 2026 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 4fQwSQ466Rz6Tb9F for ; Wed, 04 Mar 2026 14:45:10 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fQwSQ1V52z3bR6 for ; Wed, 04 Mar 2026 14:45:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772635510; 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=2GkVJCzG+aM+P8X6ODQziq1Sl/VLSk4M7nN1AM07GZA=; b=p3A4O65dkdPqjFyqAGcr81tNt/ECIffyhvmSbHBLys1b1cJmcNx4m7rP98nFmAi0EhbICM /UHDaAnlMW48sNsgIK/1vPOA3H2yGEQD6B9rSYiNQTqELWPndHbhjVRLkZEy6msdJ3/bOZ PMmtJEjCwtl1pwcFAZU9Hku7T9IYx2TIyK3t9dt0FONMf4OyxX8rd5Y6gSrQc3vQ/ypDlm EghvMZqtlVODklBpILK/nWTnjcnpFOrY0u65FiqB0Qissy6IMBf0k0J8kFKU9CPVl2ihBC Ok+qdHbErEpawlFGq10SrCVRNi4gYqWGtlQydi8es3G5JKrBdAPPGCPDXULY3g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1772635510; a=rsa-sha256; cv=none; b=nV5BATswj9EsWtH0JzdgJLSlnc4/WeWU9Bz18e7G5npVZ8wqQs3Fu07QZ3CfcPz6R66fSY bYVr3YWi2wGcm+z4+fYmpziQyLs1Wu7jpuBd0bGs7INtGp4yN4EQhYFuj8moGd/pi26pbR UcFrTr8KiHHhap9zpGJCmEuQqVDA+FcY85/E75zr+yciW0hKUQXS7mDvdSnLUX6EBC7aGs PUsWIxxmEYB60zlpTJOWa35AiUYIaXW0QWnMsag/txXB5v9TmkRThOM2ZBnxfnDGrPTz/M KgucztozCF0hzIvl63S3LMjMKeyx/Xo1EXDb0hHJecNfQOmPggkb6epPJOWCug== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772635510; 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=2GkVJCzG+aM+P8X6ODQziq1Sl/VLSk4M7nN1AM07GZA=; b=BMuFuwc6K+i7/1JM29KVPGvfyt5QXevRKHGEMR6ZwND5AU2ny+eUQZr1uxAWg5oncRIpHb XqVxf8/7VshDGNqOXxLs1ittVpzzumdUgY2hJasnW88BGYFXZ8VQ5Cp0VerD3Kr/uUcndG beY1TBv/AJ45/ajePiVYHrQEkMTZLiJ70eAft4GfiZRBWk3CHA1djdm7SQK/srzz5b5RTP 0qqIi1/kWrXw9tnhns3jQsde1dLrgOUtoe8KVeSu5NsfsWV74i3R1V5qyeU76ZWPjOyGMM 6ItTIjd+vwoqSzES68Acxeel8lF4BJ0TPem3pb262sib7ees1HOce+OAJwFoUQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fQwSQ0pv2zvJb for ; Wed, 04 Mar 2026 14:45:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 276fb by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 04 Mar 2026 14:45:10 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 99eed0b41c75 - stable/15 - system(3): Fix null case 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: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 99eed0b41c75aeec17e70999121e10ea82b0df4c Auto-Submitted: auto-generated Date: Wed, 04 Mar 2026 14:45:10 +0000 Message-Id: <69a84576.276fb.584d2665@gitrepo.freebsd.org> The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=99eed0b41c75aeec17e70999121e10ea82b0df4c commit 99eed0b41c75aeec17e70999121e10ea82b0df4c Author: Dag-Erling Smørgrav AuthorDate: 2026-02-25 21:12:42 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-03-04 14:45:00 +0000 system(3): Fix null case Our manual page states that if given a null pointer, system() returns non-zero if the shell is available and zero if it is not. This is consistent with the C standard's description of system(), but it is not what we actually do. What we actually do is always return non-zero, as required by POSIX. As the POSIX rationale explains, implementing the logic required by the C standard does not violate POSIX, since a conforming system always has a shell, therefore the logic will always return non-zero. Since our libc is commonly used in non-conforming situations such as chroots or thin jails, we should implement the full logic required by the C standard. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: obiwac, bnovkov, kevans Differential Revision: https://reviews.freebsd.org/D55484 (cherry picked from commit 8ae3f44991948cc97b09adc248a9a46db71bf9e0) --- lib/libc/stdlib/system.c | 2 +- lib/libc/tests/stdlib/system_test.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c index 17dd63eb52f9..94f7460c9b68 100644 --- a/lib/libc/stdlib/system.c +++ b/lib/libc/stdlib/system.c @@ -64,7 +64,7 @@ __libc_system(const char *command) pid_t pid; if (command == NULL) /* just checking... */ - return (1); + return (eaccess(_PATH_BSHELL, X_OK) == 0); /* * If we are the first concurrent instance, ignore SIGINT and diff --git a/lib/libc/tests/stdlib/system_test.c b/lib/libc/tests/stdlib/system_test.c index 713e4bb0f87a..b6a31583d52d 100644 --- a/lib/libc/tests/stdlib/system_test.c +++ b/lib/libc/tests/stdlib/system_test.c @@ -57,10 +57,20 @@ ATF_TC(system_null); ATF_TC_HEAD(system_null, tc) { atf_tc_set_md_var(tc, "descr", "system(NULL)"); + atf_tc_set_md_var(tc, "require.user", "root"); } ATF_TC_BODY(system_null, tc) { + /* First, test in a normal environment */ ATF_REQUIRE_EQ(1, system(NULL)); + + /* Now enter an empty chroot */ + ATF_REQUIRE_EQ(0, chroot(".")); + ATF_REQUIRE_EQ(0, chdir("/")); + + /* Test again with no shell available */ + ATF_REQUIRE_EQ(0, system(NULL)); + ATF_REQUIRE_EQ(W_EXITCODE(127, 0), system("true")); } /*