test: make sure that {readonly|inaccessible|readwrite}paths disconnect mount propagation
authorDjalal Harouni <tixxdz@opendz.org>
Sun, 25 Sep 2016 17:50:25 +0000 (19:50 +0200)
committerDjalal Harouni <tixxdz@opendz.org>
Tue, 27 Sep 2016 07:24:46 +0000 (09:24 +0200)
Better safe.

Makefile.am
src/test/test-execute.c
test/test-execute/exec-inaccessiblepaths-mount-propagation.service [new file with mode: 0644]
test/test-execute/exec-readonlypaths-mount-propagation.service [new file with mode: 0644]
test/test-execute/exec-readwritepaths-mount-propagation.service [new file with mode: 0644]

index 0417a05..9185bae 100644 (file)
@@ -1644,6 +1644,9 @@ EXTRA_DIST += \
        test/test-execute/exec-privatetmp-no.service \
        test/test-execute/exec-privatetmp-yes.service \
        test/test-execute/exec-readonlypaths.service \
+       test/test-execute/exec-readonlypaths-mount-propagation.service \
+       test/test-execute/exec-readwritepaths-mount-propagation.service \
+       test/test-execute/exec-inaccessiblepaths-mount-propagation.service \
        test/test-execute/exec-spec-interpolation.service \
        test/test-execute/exec-systemcallerrornumber.service \
        test/test-execute/exec-systemcallfilter-failing2.service \
index aa8544e..8b4ff22 100644 (file)
@@ -144,6 +144,15 @@ static void test_exec_privatedevices_capabilities(Manager *m) {
 
 static void test_exec_readonlypaths(Manager *m) {
         test(m, "exec-readonlypaths.service", 0, CLD_EXITED);
+        test(m, "exec-readonlypaths-mount-propagation.service", 0, CLD_EXITED);
+}
+
+static void test_exec_readwritepaths(Manager *m) {
+        test(m, "exec-readwritepaths-mount-propagation.service", 0, CLD_EXITED);
+}
+
+static void test_exec_inaccessiblepaths(Manager *m) {
+        test(m, "exec-inaccessiblepaths-mount-propagation.service", 0, CLD_EXITED);
 }
 
 static void test_exec_systemcallfilter(Manager *m) {
@@ -360,6 +369,8 @@ int main(int argc, char *argv[]) {
                 test_exec_privatedevices,
                 test_exec_privatedevices_capabilities,
                 test_exec_readonlypaths,
+                test_exec_readwritepaths,
+                test_exec_inaccessiblepaths,
                 test_exec_privatenetwork,
                 test_exec_systemcallfilter,
                 test_exec_systemcallerrornumber,
diff --git a/test/test-execute/exec-inaccessiblepaths-mount-propagation.service b/test/test-execute/exec-inaccessiblepaths-mount-propagation.service
new file mode 100644 (file)
index 0000000..23c6ff3
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test to make sure that InaccessiblePaths= disconnect mount propagation
+
+[Service]
+InaccessiblePaths=-/i-dont-exist
+ExecStart=/bin/sh -x -c 'mkdir -p /TEST; mount -t tmpfs tmpfs /TEST; grep TEST /proc/self/mountinfo && ! grep TEST /proc/$${PPID}/mountinfo && ! grep TEST /proc/1/mountinfo'
+Type=oneshot
diff --git a/test/test-execute/exec-readonlypaths-mount-propagation.service b/test/test-execute/exec-readonlypaths-mount-propagation.service
new file mode 100644 (file)
index 0000000..237cbb2
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test to make sure that passing ReadOnlyPaths= disconnect mount propagation
+
+[Service]
+ReadOnlyPaths=-/i-dont-exist
+ExecStart=/bin/sh -x -c 'mkdir -p /TEST; mount -t tmpfs tmpfs /TEST; grep TEST /proc/self/mountinfo && ! grep TEST /proc/$${PPID}/mountinfo && ! grep TEST /proc/1/mountinfo'
+Type=oneshot
diff --git a/test/test-execute/exec-readwritepaths-mount-propagation.service b/test/test-execute/exec-readwritepaths-mount-propagation.service
new file mode 100644 (file)
index 0000000..466ce6c
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test to make sure that passing ReadWritePaths= disconnect mount propagation
+
+[Service]
+ReadWritePaths=-/i-dont-exist
+ExecStart=/bin/sh -x -c 'mkdir -p /TEST; mount -t tmpfs tmpfs /TEST; grep TEST /proc/self/mountinfo && ! grep TEST /proc/$${PPID}/mountinfo && ! grep TEST /proc/1/mountinfo'
+Type=oneshot