diff --git a/tests/regression/apparmor/Makefile b/tests/regression/apparmor/Makefile index 338a4445d..a70e6ec88 100644 --- a/tests/regression/apparmor/Makefile +++ b/tests/regression/apparmor/Makefile @@ -48,6 +48,9 @@ endif # USE_SYSTEM CFLAGS += -g -O0 -Wall -Wstrict-prototypes +USE_SYSCTL:=$(shell echo "#include " | cpp -dM >/dev/null 2>/dev/null && echo true) + + SRC=access.c \ introspect.c \ changeprofile.c \ @@ -109,7 +112,6 @@ SRC=access.c \ syscall_sethostname.c \ syscall_setdomainname.c \ syscall_setscheduler.c \ - syscall_sysctl.c \ sysctl_proc.c \ tcp.c \ unix_fd_client.c \ @@ -124,6 +126,12 @@ ifneq (,$(findstring $(shell uname -i),i386 i486 i586 i686 x86 x86_64)) SRC+=syscall_ioperm.c syscall_iopl.c endif +#only do sysctl syscall test if defines installed and OR supported by the +# kernel +ifeq ($(USE_SYSCTL),true) +SRC+=syscall_sysctl.c +endif + #only do dbus if proper libs are installl ifneq (,$(shell pkg-config --exists dbus-1 && echo TRUE)) SRC+=dbus_eavesdrop.c dbus_message.c dbus_service.c dbus_unrequested_reply.c diff --git a/tests/regression/apparmor/syscall_sysctl.sh b/tests/regression/apparmor/syscall_sysctl.sh index f93946f33..5f8569847 100644 --- a/tests/regression/apparmor/syscall_sysctl.sh +++ b/tests/regression/apparmor/syscall_sysctl.sh @@ -148,11 +148,18 @@ test_sysctl_proc() # 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 -if ! res="$(${test} ro 2>&1)" && [ "$res" = "FAIL: sysctl read failed - Function not implemented" ] ; then - echo " WARNING: syscall sysctl not implemented, skipping tests ..." +# In addition test that sysctl exists in the kernel headers, if it does't +# then we can't even built the syscall_sysctl test +if echo "#include " | cpp -dM >/dev/null 2>/dev/null ; then + settest syscall_sysctl + + if ! res="$(${test} ro 2>&1)" && [ "$res" = "FAIL: sysctl read failed - Function not implemented" ] ; then + echo " WARNING: syscall sysctl not implemented, skipping tests ..." + else + test_syscall_sysctl + fi else - test_syscall_sysctl + echo " WARNING: syscall sysctl not supported by kernel headers, skipping tests ..." fi # now test /proc/sys/ paths