From: Antonio Alvarez Feijoo Date: Mon, 18 Aug 2025 08:05:23 +0000 (+0200) Subject: test-nss-hosts: do not call seccomp functions if HAVE_SECCOMP is not set X-Git-Tag: v258-rc3~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a83ba27b892428e25ecc1f7ca8fcfb6149962179;p=thirdparty%2Fsystemd.git test-nss-hosts: do not call seccomp functions if HAVE_SECCOMP is not set Otherwise, the build fails: ``` Features ... disabled : ACL, SECCOMP, ... ... [1592/2115] Compiling C object test-nss-hosts.p/src_test_test-nss-hosts.c.o FAILED: test-nss-hosts.p/src_test_test-nss-hosts.c.o ... In file included from ../src/test/test-nss-hosts.c:27: ../src/test/test-nss-hosts.c: In function ‘run’: ../src/test/test-nss-hosts.c:497:43: error: implicit declaration of function ‘seccomp_filter_set_add_by_name’ [-Werror=implicit-function-declaration] 497 | ASSERT_OK(seccomp_filter_set_add_by_name(filter, /* add = */ true, s)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/shared/tests.h:181:24: note: in definition of macro ‘ASSERT_OK’ 181 | typeof(expr) _result = (expr); \ | ^~~~ ../src/test/test-nss-hosts.c:497:43: warning: nested extern declaration of ‘seccomp_filter_set_add_by_name’ [-Wnested-externs] 497 | ASSERT_OK(seccomp_filter_set_add_by_name(filter, /* add = */ true, s)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/shared/tests.h:181:24: note: in definition of macro ‘ASSERT_OK’ 181 | typeof(expr) _result = (expr); \ | ^~~~ ../src/test/test-nss-hosts.c:498:35: error: implicit declaration of function ‘seccomp_load_syscall_filter_set_raw’ [-Werror=implicit-function-declaration] 498 | ASSERT_OK(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, filter, SCMP_ACT_ERRNO(ENOSYS), /* log_missing = */ true)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/shared/tests.h:181:24: note: in definition of macro ‘ASSERT_OK’ 181 | typeof(expr) _result = (expr); \ | ^~~~ ../src/test/test-nss-hosts.c:498:35: warning: nested extern declaration of ‘seccomp_load_syscall_filter_set_raw’ [-Wnested-externs] 498 | ASSERT_OK(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, filter, SCMP_ACT_ERRNO(ENOSYS), /* log_missing = */ true)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/shared/tests.h:181:24: note: in definition of macro ‘ASSERT_OK’ 181 | typeof(expr) _result = (expr); \ | ^~~~ ../src/test/test-nss-hosts.c:498:71: error: ‘SCMP_ACT_ALLOW’ undeclared (first use in this function) 498 | ASSERT_OK(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, filter, SCMP_ACT_ERRNO(ENOSYS), /* log_missing = */ true)); | ^~~~~~~~~~~~~~ ../src/shared/tests.h:181:24: note: in definition of macro ‘ASSERT_OK’ 181 | typeof(expr) _result = (expr); \ | ^~~~ ../src/test/test-nss-hosts.c:498:71: note: each undeclared identifier is reported only once for each function it appears in 498 | ASSERT_OK(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, filter, SCMP_ACT_ERRNO(ENOSYS), /* log_missing = */ true)); | ^~~~~~~~~~~~~~ ../src/shared/tests.h:181:24: note: in definition of macro ‘ASSERT_OK’ 181 | typeof(expr) _result = (expr); \ | ^~~~ ../src/test/test-nss-hosts.c:498:95: error: implicit declaration of function ‘SCMP_ACT_ERRNO’ [-Werror=implicit-function-declaration] 498 | ASSERT_OK(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, filter, SCMP_ACT_ERRNO(ENOSYS), /* log_missing = */ true)); | ^~~~~~~~~~~~~~ ../src/shared/tests.h:181:24: note: in definition of macro ‘ASSERT_OK’ 181 | typeof(expr) _result = (expr); \ | ^~~~ ../src/test/test-nss-hosts.c:498:95: warning: nested extern declaration of ‘SCMP_ACT_ERRNO’ [-Wnested-externs] 498 | ASSERT_OK(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, filter, SCMP_ACT_ERRNO(ENOSYS), /* log_missing = */ true)); | ^~~~~~~~~~~~~~ ../src/shared/tests.h:181:24: note: in definition of macro ‘ASSERT_OK’ 181 | typeof(expr) _result = (expr); \ | ^~~~ cc1: some warnings being treated as errors ``` Fixes 788b3e030e717404cbb65b4261bff2ef7ddb1b90 --- diff --git a/src/test/test-nss-hosts.c b/src/test/test-nss-hosts.c index 93de6d7add6..1cc5e72007f 100644 --- a/src/test/test-nss-hosts.c +++ b/src/test/test-nss-hosts.c @@ -483,6 +483,7 @@ static int run(int argc, char **argv) { assert_se(path_extract_directory(argv[0], &dir) >= 0); +#if HAVE_SECCOMP if (geteuid() != 0 || !is_seccomp_available()) log_tests_skipped("Not privileged or seccomp is not available"); else { @@ -508,6 +509,7 @@ static int run(int argc, char **argv) { _exit(EXIT_SUCCESS); } } +#endif STRV_FOREACH(module, modules) { r = test_one_module(dir, *module, names, addresses, n_addresses);