test: fix syscall existence check
Follow-up for 0643eb47a0.
This also drops errnously introduced hashmap_put() in the commit.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
cf2ab2e7ea
commit
7422405623
+31
-14
@@ -805,10 +805,18 @@ static void test_load_syscall_filter_set_raw(void) {
|
||||
assert_se(s = hashmap_new(NULL));
|
||||
#if defined __NR_access && __NR_access >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_access + 1), INT_TO_PTR(-1)) >= 0);
|
||||
#else
|
||||
log_debug("has access()");
|
||||
#endif
|
||||
#if defined __NR_faccessat && __NR_faccessat >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_faccessat + 1), INT_TO_PTR(-1)) >= 0);
|
||||
log_debug("has faccessat()");
|
||||
#endif
|
||||
#if defined __NR_faccessat2 && __NR_faccessat2 >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_faccessat2 + 1), INT_TO_PTR(-1)) >= 0);
|
||||
log_debug("has faccessat2()");
|
||||
#endif
|
||||
|
||||
assert_se(!hashmap_isempty(s));
|
||||
assert_se(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, s, SCMP_ACT_ERRNO(EUCLEAN), true) >= 0);
|
||||
|
||||
assert_se(access("/", F_OK) < 0);
|
||||
@@ -816,14 +824,16 @@ static void test_load_syscall_filter_set_raw(void) {
|
||||
|
||||
assert_se(poll(NULL, 0, 0) == 0);
|
||||
|
||||
s = hashmap_free(s);
|
||||
|
||||
assert_se(s = hashmap_new(NULL));
|
||||
hashmap_clear(s);
|
||||
#if defined __NR_access && __NR_access >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_access + 1), INT_TO_PTR(EILSEQ)) >= 0);
|
||||
#else
|
||||
#endif
|
||||
#if defined __NR_faccessat && __NR_faccessat >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_faccessat + 1), INT_TO_PTR(EILSEQ)) >= 0);
|
||||
#endif
|
||||
#if defined __NR_faccessat2 && __NR_faccessat2 >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_faccessat2 + 1), INT_TO_PTR(EILSEQ)) >= 0);
|
||||
#endif
|
||||
|
||||
assert_se(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, s, SCMP_ACT_ERRNO(EUCLEAN), true) >= 0);
|
||||
|
||||
@@ -832,15 +842,21 @@ static void test_load_syscall_filter_set_raw(void) {
|
||||
|
||||
assert_se(poll(NULL, 0, 0) == 0);
|
||||
|
||||
s = hashmap_free(s);
|
||||
|
||||
assert_se(s = hashmap_new(NULL));
|
||||
hashmap_clear(s);
|
||||
#if defined __NR_poll && __NR_poll >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_poll + 1), INT_TO_PTR(-1)) >= 0);
|
||||
#elif defined __NR_ppoll
|
||||
log_debug("has poll()");
|
||||
#endif
|
||||
#if defined __NR_ppoll && __NR_ppoll >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll + 1), INT_TO_PTR(-1)) >= 0);
|
||||
log_debug("has ppoll()");
|
||||
#endif
|
||||
#if defined __NR_ppoll_time64 && __NR_ppoll_time64 >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll_time64 + 1), INT_TO_PTR(-1)) >= 0);
|
||||
log_debug("has ppoll_time64()");
|
||||
#endif
|
||||
|
||||
assert_se(!hashmap_isempty(s));
|
||||
assert_se(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, s, SCMP_ACT_ERRNO(EUNATCH), true) >= 0);
|
||||
|
||||
assert_se(access("/", F_OK) < 0);
|
||||
@@ -849,15 +865,16 @@ static void test_load_syscall_filter_set_raw(void) {
|
||||
assert_se(poll(NULL, 0, 0) < 0);
|
||||
assert_se(errno == EUNATCH);
|
||||
|
||||
s = hashmap_free(s);
|
||||
|
||||
assert_se(s = hashmap_new(NULL));
|
||||
hashmap_clear(s);
|
||||
#if defined __NR_poll && __NR_poll >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_poll + 1), INT_TO_PTR(EILSEQ)) >= 0);
|
||||
#elif defined __NR_ppoll
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll + 1), INT_TO_PTR(-1)) >= 0);
|
||||
#endif
|
||||
#if defined __NR_ppoll && __NR_ppoll >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll + 1), INT_TO_PTR(EILSEQ)) >= 0);
|
||||
#endif
|
||||
#if defined __NR_ppoll_time64 && __NR_ppoll_time64 >= 0
|
||||
assert_se(hashmap_put(s, UINT32_TO_PTR(__NR_ppoll_time64 + 1), INT_TO_PTR(EILSEQ)) >= 0);
|
||||
#endif
|
||||
|
||||
assert_se(seccomp_load_syscall_filter_set_raw(SCMP_ACT_ALLOW, s, SCMP_ACT_ERRNO(EUNATCH), true) >= 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user