]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tests: prefer MS_SLAVE over MS_PRIVATE for turning off mount propagation
authorLennart Poettering <lennart@poettering.net>
Fri, 20 Jul 2018 13:33:48 +0000 (15:33 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 20 Jul 2018 14:51:20 +0000 (16:51 +0200)
When we open our own little namespace for running our tests in, let's
turn off mount propagation only one way, rather than both ways. This is
better as this means we don't pin host mounts unnecessarily long in our
namespace, even though the host already got rid of them. This is because
MS_SLAVE in contrast to MS_PRIVATE allows umount events to propagate
from the host into our environment.

src/test/test-process-util.c
src/test/test-udev.c

index fd4d17408de612916e321d1189fbcbcce1ade225..7f3f502c56aa25ae9c90c3486862d53bd2398d00 100644 (file)
@@ -206,7 +206,7 @@ static void test_get_process_cmdline_harder(void) {
         assert_se(pid == 0);
         assert_se(unshare(CLONE_NEWNS) >= 0);
 
-        assert_se(mount(NULL, "/", NULL, MS_PRIVATE|MS_REC, NULL) >= 0);
+        assert_se(mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) >= 0);
 
         fd = mkostemp(path, O_CLOEXEC);
         assert_se(fd >= 0);
index bed51c1270873e0c73757c57a90956202b7d46e8..dd630b97181f121ad40c48059fb6f77e552a93db 100644 (file)
@@ -38,7 +38,7 @@ static int fake_filesystems(void) {
         if (unshare(CLONE_NEWNS) < 0)
                 return log_error_errno(errno, "failed to call unshare(): %m");
 
-        if (mount(NULL, "/", NULL, MS_PRIVATE|MS_REC, NULL) < 0)
+        if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) < 0)
                 return log_error_errno(errno, "failed to mount / as private: %m");
 
         for (i = 0; i < ELEMENTSOF(fakefss); i++) {