]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-06-SELINUX: Add knob to allow checking for AVCs
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 8 Jan 2025 12:31:11 +0000 (13:31 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 15 Jan 2025 09:56:07 +0000 (09:56 +0000)
When running the integration tests downstream, it's useful to be
able to test that a new systemd version doesn't introduce any AVC
denials, so let's add a knob to make that possible.

(cherry picked from commit de19520ec979902fd457515d1a795210fdaedf93)

test/README.testsuite
test/fmf/integration-tests/test.sh
test/units/TEST-06-SELINUX.sh

index da2d17a6dba7cd8cb1fff23da77f0da9276fddf3..6b367aa6738fa4e2d9211ad510550751c5b11051 100644 (file)
@@ -151,6 +151,16 @@ that make use of `run_testcases`.
 
 `TEST_SKIP_TESTCASE=testcase`: takes a space separated list of testcases to skip.
 
+### SELinux AVCs
+
+To have `TEST-06-SELINUX` check for SELinux denials, write the following to
+mkosi.local.conf:
+
+```conf
+[Runtime]
+KernelCommandLineExtra=systemd.setenv=TEST_SELINUX_CHECK_AVCS=1
+```
+
 ## Ubuntu CI
 
 New PRs submitted to the project are run through regression tests, and one set
index 4545090c3c1ab1edad4d3ba85ab7b73f206698f6..fccfa15c728214ac6ef273affa033e9a0a112385 100755 (executable)
@@ -69,6 +69,13 @@ ToolsTreeDistribution=$ID
 ToolsTreeRelease=${VERSION_ID:-rawhide}
 EOF
 
+if [[ -n "${TEST_SELINUX_CHECK_AVCS:-}" ]]; then
+    tee --append mkosi.local.conf <<EOF
+[Runtime]
+KernelCommandLineExtra=systemd.setenv=TEST_SELINUX_CHECK_AVCS=$TEST_SELINUX_CHECK_AVCS
+EOF
+fi
+
 if [[ -n "${TESTING_FARM_REQUEST_ID:-}" ]]; then
     tee --append mkosi.local.conf <<EOF
 [Build]
index 937a04005ad8d82f571ec33627b44dbcbeee6550..4ab9224a9ea302445c3acb36cb195a38258e219b 100755 (executable)
@@ -46,4 +46,8 @@ NSPAWN_ARGS=(systemd-nspawn -q --volatile=yes --directory=/ --bind-ro=/etc --ina
 [[ "$("${NSPAWN_ARGS[@]}" --selinux-apifs-context="$CONTEXT" stat --printf %C /run)" == "$CONTEXT" ]]
 [[ "$("${NSPAWN_ARGS[@]}" --selinux-apifs-context="$CONTEXT" --tmpfs=/tmp stat --printf %C /tmp)" == "$CONTEXT" ]]
 
+if [[ -n "${TEST_SELINUX_CHECK_AVCS:-}" ]] && ((TEST_SELINUX_CHECK_AVCS)); then
+    (! journalctl -t audit -g AVC -o cat)
+fi
+
 touch /testok