]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-rm-rf: Check capabilities
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 6 Nov 2025 19:21:55 +0000 (20:21 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 14 Nov 2025 08:19:01 +0000 (09:19 +0100)
The assertion will succeed if we have the right capability, causing the
test to fail.

src/test/test-rm-rf.c

index af369d81f7c99c136e85d766b3ff2ebf516393af..870a8b9a4ef238756aedba9636854498a54720f5 100644 (file)
@@ -3,6 +3,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include "capability-util.h"
 #include "process-util.h"
 #include "rm-rf.h"
 #include "string-util.h"
@@ -29,7 +30,8 @@ static void test_rm_rf_chmod_inner(void) {
         ASSERT_OK_ERRNO(chmod(x, 0500));
         ASSERT_OK_ERRNO(chmod(d, 0500));
 
-        ASSERT_ERROR(rm_rf(d, REMOVE_PHYSICAL), EACCES);
+        if (!have_effective_cap(CAP_DAC_OVERRIDE))
+                ASSERT_ERROR(rm_rf(d, REMOVE_PHYSICAL), EACCES);
 
         ASSERT_OK_ERRNO(access(d, F_OK));
         ASSERT_OK_ERRNO(access(x, F_OK));