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.
#include <sys/file.h>
#include "blockdev-util.h"
+#include "capability-util.h"
#include "fd-util.h"
#include "loop-util.h"
#include "memfd-util.h"
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()");