diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-02-02 18:56:12 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-07-07 11:20:42 +0200 |
commit | e2ec9c4d3abf49e95565574214f8979d819e3f48 (patch) | |
tree | a181ae36c1b239549e324186c0c80a03a39dc77f /src/shared/tests.c | |
parent | cda667722c2218cf1a0185284d2a87f8a25f1b2d (diff) | |
download | systemd-e2ec9c4d3abf49e95565574214f8979d819e3f48.tar.gz |
namespace-util: introduce helper for combining unshare() + MS_SLAVE remount
We have multiple places we do these two non-trivial operations together,
let's introduce a unified helper for doing both at once.
Diffstat (limited to 'src/shared/tests.c')
-rw-r--r-- | src/shared/tests.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/shared/tests.c b/src/shared/tests.c index ecf8e8f623..ff662ecfe0 100644 --- a/src/shared/tests.c +++ b/src/shared/tests.c @@ -21,6 +21,7 @@ #include "env-util.h" #include "fs-util.h" #include "log.h" +#include "namespace-util.h" #include "path-util.h" #include "random-util.h" #include "strv.h" @@ -137,10 +138,7 @@ bool have_namespaces(void) { if (pid == 0) { /* child */ - if (unshare(CLONE_NEWNS) < 0) - _exit(EXIT_FAILURE); - - if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) + if (detach_mount_namespace() < 0) _exit(EXIT_FAILURE); _exit(EXIT_SUCCESS); |