]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-fd-util: skip test when lacking privileges to create a new namespace
authorLuca Boccassi <luca.boccassi@gmail.com>
Wed, 11 Dec 2024 12:01:18 +0000 (12:01 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 20 Dec 2024 19:43:57 +0000 (19:43 +0000)
To reproduce, as an unprivileged user start a docker container and build
and run the unit tests inside it:

$ docker run --rm -ti debian:bookworm bash
...
/* test_close_all_fds */
Successfully forked off '(caf-plain)' as PID 10496.
Skipping PR_SET_MM, as we don't have privileges.
(caf-plain) succeeded.
Failed to fork off '(caf-noproc)': Operation not permitted
Assertion 'r >= 0' failed at src/test/test-fd-util.c:392, function test_close_all_fds(). Aborting.

Partially fixes #35552

(cherry picked from commit 630a2e7ee195ca96e102acac8df67a278a879124)
(cherry picked from commit 5573ac7d9c52bed8d38480788b02639ede3881fc)

src/test/test-fd-util.c

index f2b65d492a63a043589b41bcd1880788823c2b8a..409433a529bb4eb1c279b5e16e4896ee79c09d21 100644 (file)
@@ -360,6 +360,8 @@ TEST(close_all_fds) {
                         test_close_all_fds_inner();
                 _exit(EXIT_SUCCESS);
         }
+        if (ERRNO_IS_NEG_PRIVILEGE(r))
+                return (void) log_tests_skipped("Lacking privileges for test in namespace with /proc/ overmounted");
         assert_se(r >= 0);
 
         if (!is_seccomp_available())