From nobody Mon Nov 23 01:18:40 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 4jXp4129rXz71TMK for ; Mon, 23 Nov 2026 01:18:41 +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 4jXp406tyNz4bvt for ; Mon, 23 Nov 2026 01:18:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795396721; 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=DbnMWgYJiIhA5jQHlkYfOoZs/J5pg4TMcpym6IOfWf4=; b=tVHCuG+8QrRKcSHDG1NhRRffmP+kWYJpgeWGQ3je6CGUSs5tdMlyDQxYeT7etXeFS8ro9b EmQ0hcJabZSmZ2SwfE7NwwSIpTx/+hNzMqVp4tuOq9VZXKiq/0/KN19IMb++XEEKdatxWN Xir/5+iq7+W2wF5GbDyZxYyZZOexsCmaT+q5ma7X8xxTWcAkyrZBjwVunuRGhcrjklWjdm +cfv+wHurwicG2riuO2IgeiPck+LZl1cqy0KgkkoICqxcZJ56P5rDUDuDbV8IHYKTBs39y ts8SCU+D1kEl7gwyuAmzVcgezAeInaGWm+ybyt3cySyVy8dQU/I5Ua5dsu7JyA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795396721; b=gLn5wgsBQctGSz9PjD7dFVO0AakLiryoK+6t3ytFXIrsZxhZ7hzkEMy9f/OrkItaSVtAdd wYniifn/Z+gGvZO7zEjJT1H8NyUE1Cv8ttXee10uqBd5sZIUA5Q/PHAFPvOo/HKhrHe/np MurAQyHN4hibAFHvNEKsxaAooTxWF5+quifO7+JGQA0BLatyKoDSO0wZDTqMo+lyysMTti awv3Snm19Vu5DmVanjYeOJZOHVmUBQwq7dsdpHYaUCFDNAgU5kdhTTmDToHLFf8oe8lGcb xhexcSr5LeTJTUKOZ3shfHrIydNG8DrlA7BdhqyhyDQQ/Vw4KTWTsA4GUW8Mvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795396721; 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=DbnMWgYJiIhA5jQHlkYfOoZs/J5pg4TMcpym6IOfWf4=; b=Se8nX/vptfKmfBxEoHzdG73x97z24ogcoRZnm32wccaKuxi0XkrmM5RmTA+GIgEPvGVKer UytCAgtmCJTR3i6+VB2faGnAEM7gJPvVXNCzzFsNj01a6Nf/eib/uLaMN15mSsLtLfw5d9 gEUnt17ooYlhTZlKtb4kb5D9NUZEOoPN+Q3t4rmv5VKFFuixSFb5ce/VXd57Y/rLGNd5pM pMY3XxSr++vL0iaaGbJdyb8+RcHnImBppknfO/LiQgFfrvh8/ZvSfPCWemj5gePpCMLoI3 56B3IFxB0DSMINO4vWL50a3/RUFYesDL5RqMTZhT6P8zF5lrAevxBFoh45ktzw== 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 4jXp405nY3zSYj for ; Mon, 23 Nov 2026 01:18:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 30f6 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 23 Nov 2026 01:18:40 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Enji Cooper Subject: git: c07ae9b28fca - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: c07ae9b28fca411d25d01c21ba9312f55b32b437 Auto-Submitted: auto-generated Date: Mon, 23 Nov 2026 01:18:40 +0000 Message-Id: <6b039470.30f6.5db99141@gitrepo.freebsd.org> The branch stable/15 has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=c07ae9b28fca411d25d01c21ba9312f55b32b437 commit c07ae9b28fca411d25d01c21ba9312f55b32b437 Author: Enji Cooper AuthorDate: 2026-11-10 01:55:45 +0000 Commit: Enji Cooper CommitDate: 2026-11-23 01:17:40 +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 788fa9f9394c..ddd6eadcfc0e 100644 --- a/tests/sys/capsicum/Makefile +++ b/tests/sys/capsicum/Makefile @@ -9,14 +9,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 \ @@ -36,8 +33,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(); }