Skip to content

Commit 841298f

Browse files
committed
tests/readonly: Add SELinux enforcing check
Verify that SELinux is in enforcing mode at the start of the readonly test suite. This catches accidental regressions where test images ship with permissive mode or enforcing=0 on the kernel command line. The check is skipped for composefs upgrade tests where enforcing=0 is intentionally needed due to the base image SELinux policy not yet covering composefs file contexts. Assisted-by: OpenCode (Claude claude-opus-4-6) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 7e3e24e commit 841298f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use std assert
2+
use tap.nu
3+
4+
tap begin "verify SELinux is enforcing"
5+
6+
# Composefs upgrade source images boot with enforcing=0 because the
7+
# base image's SELinux policy doesn't yet cover composefs file contexts.
8+
# Skip this check in that case.
9+
let upgrade_image = $env.BOOTC_test_upgrade_image? | default ""
10+
let is_composefs = (tap is_composefs)
11+
if $upgrade_image != "" and $is_composefs {
12+
print "# skip: composefs upgrade boots with enforcing=0 (base image SELinux policy gap)"
13+
tap ok
14+
exit 0
15+
}
16+
17+
let enforce = (open /sys/fs/selinux/enforce | str trim)
18+
assert equal $enforce "1" "SELinux should be in enforcing mode"
19+
print "SELinux is enforcing"
20+
21+
tap ok

0 commit comments

Comments
 (0)