From: Daan De Meyer Date: Thu, 6 Nov 2025 19:21:55 +0000 (+0100) Subject: test-rm-rf: Check capabilities X-Git-Tag: v259-rc1~59^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1312353fdd71013a0747ca084bbfaf679a6dd604;p=thirdparty%2Fsystemd.git test-rm-rf: Check capabilities The assertion will succeed if we have the right capability, causing the test to fail. --- diff --git a/src/test/test-rm-rf.c b/src/test/test-rm-rf.c index af369d81f7c..870a8b9a4ef 100644 --- a/src/test/test-rm-rf.c +++ b/src/test/test-rm-rf.c @@ -3,6 +3,7 @@ #include #include +#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));