From nobody Mon Nov 23 05:57:33 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 4jXwFp1Ggjz720k0 for ; Mon, 23 Nov 2026 05:57:34 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jXwFn6fN3z4WBR for ; Mon, 23 Nov 2026 05:57:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795413453; 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=V1OCeBZr2r7ZZPcphVoGlDQXyvIuyn3oE+9GfkbJQOE=; b=iCdX0ewohU7JdlbNztHSAfwEKcwbhMGNX4erCKK651Ivz6hHhwpVnVzkAFnlLfxfLvu7Qr 06TjyJl5mffhily9iQdaq96apkeBF+Vh2fWRbexahQSCymwuvnch0IqBprXxpvB1YxfEDt Egr4dZhrb5FnUD7jOrTm70OpwtgSoLkrm9RT1twlMRPiIFjf5X9E7hDROXYy9vpdpIFZjK 3dgU5rvS0bnsTvEaBQzTjTi3fjv3NmyBtMkl4B9i3RuEdZ0T9irLixcbjbYuYTekMYwqqm g/sb077t4BvRt5xP7ilA7uFSllmG3E+/8epnYRnqS6qNa3yi6KdEABkpv0v2dQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795413453; b=NZTE/gvAFtzZ9TCsKz3Qn5O2BCDW6Eg7XVHPwH7BYNMODloDwJVW/V2ihSwOcNQQDhsuPR YVYU5iB3ujNJw6nejQR5bIFX8b7yeNHGXqvw4CJtJdLe42lKYsZhZiErvc9RSCjlpTcg7J HGlGlhp3RNGNeBVV1Z8Azz+Y8pqJTI6R0Y+/rk/2EmUwNhVNO0Hw7NRN2q6DbO9ruxNgmj VICrxOt7XkUHqfe1GMkZTi5w03ctobGAVRjrgG06PTg0jL+EkxcsqDe2PvwIQBUEv7EHiI whMBeFaZtMKdgJSReXnNCciQlsKG+4TYzt2y25/Bx7GnU6P+VDUOIT5nqSf6/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795413453; 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=V1OCeBZr2r7ZZPcphVoGlDQXyvIuyn3oE+9GfkbJQOE=; b=tXEEOmCkb8EFFxb720+rxruNejGTi6kVGY8u8YTzr5A9QoXU1O+2wgVQRnLnRtfeidsYKy +Ia62Sq32j3aimxUng0781GWT+byVxvXPkEe7EMILjpis5d5RrXdep0XBTOcXFu4V2LwH4 UxM4Be5A6RRhhHRXxicO6PcbFEg/P6O1zveoZ3LHi/pJjaEJyjZW6h5EMeXncbXZ7IPZDV AFIa7TNSONsOlJG5AIWVMjfsj5/RRbbtwXIfKXLSLrpLkHC+U7fVNALr6p++PzMUhREUsf ftSipQIchYLLYSuXBqnEW+JToy6LMXG+h5b2cvvRJpvn5y36CegDfQDX6kDEkg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jXwFn5cVFzfM2 for ; Mon, 23 Nov 2026 05:57:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 31 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 23 Nov 2026 05:57:33 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Enji Cooper Subject: git: 2ca11a16475a - stable/14 - tests/sys/capsicum: restore test coverage with root user List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ngie X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 2ca11a16475a766256bd5c0354121bba9b95d890 Auto-Submitted: auto-generated Date: Mon, 23 Nov 2026 05:57:33 +0000 Message-Id: <6b03d5cd.31.6a41f254@gitrepo.freebsd.org> The branch stable/14 has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=2ca11a16475a766256bd5c0354121bba9b95d890 commit 2ca11a16475a766256bd5c0354121bba9b95d890 Author: Enji Cooper AuthorDate: 2026-11-10 01:55:45 +0000 Commit: Enji Cooper CommitDate: 2026-11-23 05:50:28 +0000 tests/sys/capsicum: restore test coverage with root user This change builds capsicum_test and installs/runs it as an unprivileged user ("tests" in vanilla FreeBSD) and root. This required adjusting logic in the Makefile in order to build two binaries with the same sources and running them as separate binaries. Moreover, in order to restore coverage and ensure that some tests which require `other_uid` (typically specified via `-u` on the CLI with the test program) don't fail, become the "tests" user when run as root. This technically doesn't honor unprivileged_user property in kyua.conf: the property needs to be passed via a command-line parameter to the test program. MFC after: 1 week Reported by: markj Fixes: 3fb03fb35b20 ("[tests] switch GoogleTest tests ...") Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D61066 (cherry picked from commit 58e5c5cac1e7c8c99a6e7f8846b655afed05b74f) --- tests/sys/capsicum/Makefile | 27 ++++++++++++++++++--------- tests/sys/capsicum/capsicum-test-main.cc | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/tests/sys/capsicum/Makefile b/tests/sys/capsicum/Makefile index 8309d9a190e9..d559a66d9c83 100644 --- a/tests/sys/capsicum/Makefile +++ b/tests/sys/capsicum/Makefile @@ -10,14 +10,11 @@ CFLAGS+= -I${SRCTOP}/tests .if ${MK_GOOGLETEST} != no -GTESTS+= capsicum-test -# This test script runs the same test suite twice, once as root and once as an -# unprivileged user. Serialize them since some tests access global namespaces, -# e.g., mqueuefs, and can trample on each other. -TEST_METADATA.functional+= is_exclusive="true" -TEST_METADATA.functional+= required_kmods="mqueuefs" +GTESTS+= capsicum-test_privileged +GTESTS+= capsicum-test_unprivileged -SRCS.capsicum-test+= \ +# SRCS required for `capsicum-test*`. +SRCS.capsicum-test= \ capsicum-test-main.cc \ capsicum-test.cc \ capability-fd.cc \ @@ -37,8 +34,20 @@ SRCS.capsicum-test+= \ overhead.cc \ rename.cc -LIBADD.capsicum-test+= gtest pthread procstat -TEST_METADATA.capsicum-test= required_user="unprivileged" +.for gtest in ${GTESTS} +SRCS.${gtest}= ${SRCS.capsicum-test} + +LIBADD.${gtest}+= gtest pthread procstat + +# This test script runs the same test suite twice, once as root and once as an +# unprivileged user. Serialize them since some tests access global namespaces, +# e.g., mqueuefs, and can trample on each other. +TEST_METADATA.${gtest}+= is_exclusive="true" +TEST_METADATA.${gtest}+= required_kmods="mqueuefs" +.endfor + +TEST_METADATA.capsicum-test_privileged+= required_user="root" +TEST_METADATA.capsicum-test_unprivileged+= required_user="unprivileged" .for p in mini-me mini-me.noexec mini-me.setuid PROGS+= $p diff --git a/tests/sys/capsicum/capsicum-test-main.cc b/tests/sys/capsicum/capsicum-test-main.cc index 2a2c75000039..308c121a0281 100644 --- a/tests/sys/capsicum/capsicum-test-main.cc +++ b/tests/sys/capsicum/capsicum-test-main.cc @@ -136,6 +136,30 @@ int main(int argc, char* argv[]) { } } + // Last ditch effort to get an unprivileged user on the fly from /etc/passwd + // for testcases that need it. + // + // This must be done this way because the typical way of handling this (via + // the `-u` argument) isn't supported yet with kyua: + // https://github.com/freebsd/kyua/issues/354 . + // + // IMPORTANT: + // - this doesn't honor `unprivileged_user` in `kyua.conf`. + // - this doesn't fail because doing that could break all testing on systems + // where the `tests` user isn't available. + if (other_uid == 0) { + const char *test_user = "tests"; + + struct passwd *test_user_entry = getpwnam(test_user); + + if (test_user_entry) { + other_uid = test_user_entry->pw_uid; + } else { + std::cerr << "Failed to get entry for " << test_user << ", errno=" << errno << "; some tests may fail" << std::endl; + } + + } + testing::AddGlobalTestEnvironment(new SetupEnvironment()); return RUN_ALL_TESTS(); }