#include "sd-event.h"
+#include "capability-util.h"
#include "device-internal.h"
#include "device-private.h"
#include "device-util.h"
#include "tests.h"
#include "tmpfile-util.h"
#include "udev-util.h"
+#include "virt.h"
TEST(mdio_bus) {
int r;
/* For issue #37711 */
- if (getuid() != 0)
- return (void) log_tests_skipped("not running as root");
+ if (getuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0)
+ return (void) log_tests_skipped("Not privileged");
+ if (running_in_chroot() > 0)
+ return (void) log_tests_skipped("Running in chroot");
ASSERT_OK(r = safe_fork("(mdio_bus)", FORK_CLOSE_ALL_FDS|FORK_DEATHSIG_SIGTERM|FORK_REOPEN_LOG|FORK_LOG|FORK_WAIT|FORK_NEW_MOUNTNS|FORK_MOUNTNS_SLAVE, NULL));
if (r == 0) {
if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0)
return log_tests_skipped("not privileged");
+ if (running_in_chroot() > 0)
+ return log_tests_skipped("running in chroot");
+
if (enter_cgroup_subroot(NULL) == -ENOMEDIUM)
return log_tests_skipped("cgroupfs not available");
#include "strv.h"
#include "tests.h"
#include "tmpfile-util.h"
+#include "virt.h"
#define FORK_COMMON_FLAGS \
(FORK_CLOSE_ALL_FDS | \
#define CHECK_PRIV \
if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0) \
- return (void) log_tests_skipped("Not privileged");
+ return (void) log_tests_skipped("Not privileged"); \
+ if (running_in_chroot() > 0) \
+ return (void) log_tests_skipped("running in chroot");
TEST(mount_option_mangle) {
char *opts = NULL;
#include "string-util.h"
#include "tests.h"
#include "tmpfile-util.h"
+#include "virt.h"
static void test_mount_propagation_flag_one(const char *name, int ret, unsigned long expected) {
unsigned long flags;
/* let's move into our own mount namespace with all propagation from the host turned off, so
* that /proc/self/mountinfo is static and constant for the whole time our test runs. */
+ if (running_in_chroot() > 0) {
+ /* We cannot remount file system with MS_PRIVATE when running in chroot. */
+ log_notice("Running in chroot, proceeding in originating mount namespace.");
+ return EXIT_SUCCESS;
+ }
+
if (unshare(CLONE_NEWNS) < 0) {
if (!ERRNO_IS_PRIVILEGE(errno))
return log_error_errno(errno, "Failed to detach mount namespace: %m");