diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-06-02 22:10:22 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-06-03 11:30:56 +0200 |
commit | c75370cc18d92a9a2cc3eafeb3b46e1d23ea0ac4 (patch) | |
tree | ccd10c2a46963036fcb9db6d7fd4d4a21ecfdf8b /src/test/test-mount-util.c | |
parent | 6da5d7de78dd6b98d42cbe177975887907ea6dc2 (diff) | |
download | systemd-c75370cc18d92a9a2cc3eafeb3b46e1d23ea0ac4.tar.gz |
test: tweak privilege tests for two more tests
These tests require properly privileged root users, hence skip things
when we don't have CAP_SYS_ADMIN.
Fixes: #19746
Diffstat (limited to 'src/test/test-mount-util.c')
-rw-r--r-- | src/test/test-mount-util.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/test/test-mount-util.c b/src/test/test-mount-util.c index 2e9116d359..ab5184121c 100644 --- a/src/test/test-mount-util.c +++ b/src/test/test-mount-util.c @@ -4,6 +4,7 @@ #include <sys/statvfs.h> #include "alloc-util.h" +#include "capability-util.h" #include "fd-util.h" #include "fileio.h" #include "mount-util.h" @@ -75,8 +76,8 @@ static void test_bind_remount_recursive(void) { _cleanup_free_ char *subdir = NULL; const char *p; - if (geteuid() != 0) { - (void) log_tests_skipped("not running as root"); + if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0) { + (void) log_tests_skipped("not running privileged"); return; } @@ -128,8 +129,8 @@ static void test_bind_remount_recursive(void) { static void test_bind_remount_one(void) { pid_t pid; - if (geteuid() != 0) { - (void) log_tests_skipped("not running as root"); + if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0) { + (void) log_tests_skipped("not running privileged"); return; } |