mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 13:58:22 +00:00
regression sysctl: skip if sysctl not available
Some kernels have CONFIG_SYSCALL_SYSCTL disabled, which is something to be encouraged. This patch separates out the two different kind of sysctl tests (syscall based and /proc/sys based) into separate shell functions, and then checks to see that the test environment supports each before invoking each shell function, issuing a warning (but not failing the tests) if not available. Signed-off-by: Steve Beattie <steve@nxnw.org> Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
@@ -25,6 +25,9 @@ bin=$pwd
|
|||||||
##
|
##
|
||||||
## C. SYSCTL
|
## C. SYSCTL
|
||||||
##
|
##
|
||||||
|
|
||||||
|
test_syscall_sysctl()
|
||||||
|
{
|
||||||
settest syscall_sysctl
|
settest syscall_sysctl
|
||||||
|
|
||||||
runchecktest "SYSCTL (no confinement read only)" pass ro
|
runchecktest "SYSCTL (no confinement read only)" pass ro
|
||||||
@@ -66,9 +69,10 @@ runchecktest "SYSCTL (confinement/bad r w/ rw perm)" fail ro
|
|||||||
|
|
||||||
genprofile $sysctlbad:rw
|
genprofile $sysctlbad:rw
|
||||||
runchecktest "SYSCTL (confinement/bad rw w/ rw perm)" fail
|
runchecktest "SYSCTL (confinement/bad rw w/ rw perm)" fail
|
||||||
|
}
|
||||||
|
|
||||||
# now test /proc/sys/ paths
|
test_sysctl_proc()
|
||||||
|
{
|
||||||
settest sysctl_proc
|
settest sysctl_proc
|
||||||
|
|
||||||
#unconfined
|
#unconfined
|
||||||
@@ -138,6 +142,23 @@ runchecktest "SYSCTL /proc (confinement/bad rw w/ w perm)" fail $sysctlgood rw
|
|||||||
|
|
||||||
genprofile $sysctlbad:rw
|
genprofile $sysctlbad:rw
|
||||||
runchecktest "SYSCTL /proc (confinement/bad rw w/ rw perm)" fail $sysctlgood rw
|
runchecktest "SYSCTL /proc (confinement/bad rw w/ rw perm)" fail $sysctlgood rw
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# check if the kernel supports CONFIG_SYSCTL_SYSCALL
|
||||||
|
# generally we want to encourage kernels to disable it, but if it's
|
||||||
|
# enabled we want to test against it
|
||||||
|
settest syscall_sysctl
|
||||||
|
res=$(${test} ro)
|
||||||
|
if [ $? -ne 0 -a $res == "FAIL: sysctl read failed - Function not implemented" ] ; then
|
||||||
|
echo " WARNING: syscall sysctl not implemented, skipping tests ..."
|
||||||
|
else
|
||||||
|
test_syscall_sysctl
|
||||||
|
fi
|
||||||
|
|
||||||
|
# now test /proc/sys/ paths
|
||||||
|
if [ ! -f "${sysctlgood}" ] ; then
|
||||||
|
echo " WARNING: proc sysctl path not found, /proc not mounted? Skipping tests ..."
|
||||||
|
else
|
||||||
|
test_sysctl_proc
|
||||||
|
fi
|
||||||
|
Reference in New Issue
Block a user