Skip to content

Commit c1eb501

Browse files
committed
Change test_sysctl_probe_all to succeed for non-root users
- add blacklist for confidential kernel params - set PATH explicitly to make sure sysctl is found fix for #1263
1 parent fa23962 commit c1eb501

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/probes/sysctl/test_sysctl_probe_all.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
set -e -o pipefail
66

7+
# on some systems sysctl might live in sbin, which can cause problems for
8+
# non root users
9+
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
10+
11+
# non root users are not able to access some kernel params, so they get blacklisted
12+
SYSCTL_BLACKLIST='stable_secret\|vm.stat_refresh\|fs.protected_hardlinks\|fs.protected_symlinks\|kernel.cad_pid\|kernel.unprivileged_userns_apparmor_policy\|kernel.usermodehelper.bset\|kernel.usermodehelper.inheritable\|net.core.bpf_jit_harden\|net.core.bpf_jit_kallsyms\|net.ipv4.tcp_fastopen_key\|vm.mmap_rnd_bits\|vm.mmap_rnd_compat_bits'
13+
714
function perform_test {
815
probecheck "sysctl" || return 255
916

@@ -24,9 +31,9 @@ $OSCAP oval eval --results $result $srcdir/test_sysctl_probe_all.oval.xml > /dev
2431
# sysctl has duplicities in output
2532
# hide permission errors like: "sysctl: permission denied on key 'fs.protected_hardlinks'"
2633
# kernel parameters might use "/" and "." separators interchangeably - normalizing
27-
sysctl -aN --deprecated 2> /dev/null | tr "/" "." | sort -u > "$sysctlNames"
34+
sysctl -aN --deprecated 2> /dev/null | grep -v $SYSCTL_BLACKLIST | tr "/" "." | sort -u > "$sysctlNames"
2835

29-
grep unix-sys:name "$result" | sed -E 's;.*>(.*)<.*;\1;g' | sort > "$ourNames"
36+
grep unix-sys:name "$result" | grep -v $SYSCTL_BLACKLIST | sed -E 's;.*>(.*)<.*;\1;g' | sort > "$ourNames"
3037

3138
# If procps_ver > 3.3.12 we need to filter *stable_secret and vm.stat_refresh
3239
# options from the sysctl output, for more details see

0 commit comments

Comments
 (0)