]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-capability: skip tests that need CAP_NET_RAW if cap is not passed
authorLennart Poettering <lennart@poettering.net>
Wed, 2 Jun 2021 13:50:16 +0000 (15:50 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 3 Jun 2021 09:27:36 +0000 (11:27 +0200)
See: #19746

src/test/test-capability.c

index 5fa8fe242ef4ee11f2cd8a6641dbcad65c7d3451..7a781e57e4978432cb712afd5dedd31a5593ac14 100644 (file)
@@ -159,9 +159,15 @@ static void test_drop_privileges_fail(void) {
 }
 
 static void test_drop_privileges(void) {
+        fork_test(test_drop_privileges_fail);
+
+        if (have_effective_cap(CAP_NET_RAW) == 0) /* The remaining two tests only work if we have CAP_NET_RAW
+                                                   * in the first place. If we are run in some restricted
+                                                   * container environment we might not. */
+                return;
+
         fork_test(test_drop_privileges_keep_net_raw);
         fork_test(test_drop_privileges_dontkeep_net_raw);
-        fork_test(test_drop_privileges_fail);
 }
 
 static void test_have_effective_cap(void) {