Skip to content

Commit bb6be0c

Browse files
committed
ver_linux: Log SecureBoot and Lockdown state
These are important, as they influence few tests in syscalls and ima runtests (see TST_SKIP_IN_SECUREBOOT=1, .skip_in_secureboot = 1, .skip_in_lockdown = 1, TST_SKIP_IN_LOCKDOWN=1). While at it, simplify AppArmor detection code. Signed-off-by: Petr Vorel <pvorel@suse.cz>
1 parent da6b614 commit bb6be0c

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

ver_linux

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,38 @@ echo 'tainted (/proc/sys/kernel/tainted):'
176176
cat /proc/sys/kernel/tainted
177177

178178
echo
179+
printf 'Secure Boot: '
180+
if tst_cmd_available mokutil; then
181+
mokutil --sb-state
182+
elif [ -f /sys/firmware/efi/efivars/SecureBoot* ]; then
183+
val=$(od --address-radix=n --format=u1 /sys/firmware/efi/efivars/SecureBoot* | awk 'NR==1 {print $5}')
184+
if [ "$val" = "0" ]; then
185+
echo 'disabled'
186+
elif [ "$val" = "1" ]; then
187+
echo 'enabled'
188+
else
189+
echo 'failed to detect, tying dmesg'
190+
dmesg | grep -i secure.*boot
191+
fi
192+
elif [ ! -f /sys/firmware/efi/efivars/SecureBoot* ]; then
193+
echo 'EFI variables not supported on SUT'
194+
fi
195+
tst_cmd_run 'dmesg | grep -i secure.*boot'
196+
197+
echo
198+
echo 'Lockdown (/sys/kernel/security/lockdown):'
199+
cat /sys/kernel/security/lockdown
200+
201+
echo
202+
printf "AppArmor: "
179203
if is_enabled /sys/module/apparmor/parameters/enabled; then
180-
echo 'AppArmor enabled'
204+
echo 'enabled'
181205
tst_cmd_run aa-status
182206
else
183-
echo 'AppArmor disabled'
207+
echo 'disabled'
184208
fi
185209

186210
echo
187-
188211
if ! tst_cmd_run sestatus; then
189212
printf 'SELinux mode: '
190213
tst_cmd_run getenforce || echo 'unknown'

0 commit comments

Comments
 (0)