]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: skip test-reread-partition-table if missing privileges
authorNick Rosbrook <enr0n@ubuntu.com>
Fri, 21 Nov 2025 17:49:37 +0000 (12:49 -0500)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 21 Nov 2025 19:28:05 +0000 (19:28 +0000)
Right now, this test runs inside unprivileged chroots, despite the
running_in_chroot() check. This is because running_in_chroot() fails
with -EACCES, which is ignored.

Hence, check for privileges before calling running_in_chroot(),
otherwise call is inconclusive. Note, the test will fail later on if
running without privileges anyways.

src/test/test-reread-partition-table.c

index cff31f41a1e9442866cadc02eb375c6dc2fbca13..769d2a8d2f98e0cd26d1e490de443596c7a09274 100644 (file)
@@ -4,6 +4,7 @@
 #include <sys/file.h>
 
 #include "blockdev-util.h"
+#include "capability-util.h"
 #include "fd-util.h"
 #include "loop-util.h"
 #include "memfd-util.h"
@@ -45,6 +46,8 @@ TEST(rereadpt) {
 
         if (detect_container() > 0)
                 return (void) log_tests_skipped("test not available in container");
+        if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0)
+                return (void) log_tests_skipped("test requires privileges");
         if (running_in_chroot() > 0)
                 return (void) log_tests_skipped("test not available in chroot()");