diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-03-13 15:22:38 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-03-14 09:39:28 +0100 |
commit | 888519889cefdc65b173ea7e529d21a386d2737a (patch) | |
tree | 87709905ebabde313184c44e344a32c4459ebba9 /src/test/test-process-util.c | |
parent | Merge pull request #26767 from yuwata/udev-rule-rework-logging (diff) | |
download | systemd-888519889cefdc65b173ea7e529d21a386d2737a.tar.xz systemd-888519889cefdc65b173ea7e529d21a386d2737a.zip |
test-process-util: port to detach_mount_namespace()
Diffstat (limited to 'src/test/test-process-util.c')
-rw-r--r-- | src/test/test-process-util.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c index 9a0c15dffe..fc0d25ea2b 100644 --- a/src/test/test-process-util.c +++ b/src/test/test-process-util.c @@ -25,6 +25,7 @@ #include "macro.h" #include "missing_sched.h" #include "missing_syscall.h" +#include "namespace-util.h" #include "parse-util.h" #include "process-util.h" #include "procfs-util.h" @@ -244,6 +245,7 @@ TEST(get_process_cmdline_harder) { _cleanup_close_ int fd = -EBADF; _cleanup_free_ char *line = NULL; pid_t pid; + int r; if (geteuid() != 0) { log_info("Skipping %s: not root", __func__); @@ -278,11 +280,11 @@ TEST(get_process_cmdline_harder) { } assert_se(pid == 0); - assert_se(unshare(CLONE_NEWNS) >= 0); - if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) { - log_warning_errno(errno, "mount(..., \"/\", MS_SLAVE|MS_REC, ...) failed: %m"); - assert_se(IN_SET(errno, EPERM, EACCES)); + r = detach_mount_namespace(); + if (r < 0) { + log_warning_errno(r, "detach mount namespace failed: %m"); + assert_se(ERRNO_IS_PRIVILEGE(r)); return; } |