diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-03-04 02:43:02 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-03-04 02:50:15 +0900 |
commit | 600ed5c24251367f5cfeaa5df22792c9c90e5cd6 (patch) | |
tree | e092cc8ca9198f1e508a67897714aaf40a2b9684 /test/test-execute | |
parent | c9a25632253f3000641737b690a562a2c4c7d580 (diff) | |
download | systemd-600ed5c24251367f5cfeaa5df22792c9c90e5cd6.tar.gz |
test-execute: add test for NetworkNamespacePath=
Prompted by https://github.com/systemd/systemd/issues/26422#issuecomment-1435772839.
Diffstat (limited to 'test/test-execute')
-rw-r--r-- | test/test-execute/exec-networknamespacepath-privatemounts-no.service | 16 | ||||
-rw-r--r-- | test/test-execute/exec-networknamespacepath-privatemounts-yes.service | 16 |
2 files changed, 32 insertions, 0 deletions
diff --git a/test/test-execute/exec-networknamespacepath-privatemounts-no.service b/test/test-execute/exec-networknamespacepath-privatemounts-no.service new file mode 100644 index 0000000000..49277e3d51 --- /dev/null +++ b/test/test-execute/exec-networknamespacepath-privatemounts-no.service @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Unit] +Description=Test for NetworkNamespacePath= without mount namespacing + +[Service] +ExecStart=/bin/sh -x -c '! ip link show dummy-test-exec' +ExecStart=/bin/sh -x -c 'test ! -e /proc/sys/net/ipv4/conf/dummy-test-exec' +# Without mount namespacing, we can access the dummy-test-exec interface through sysfs. +ExecStart=/bin/sh -x -c 'test -e /sys/class/net/dummy-test-exec' +ExecStart=/bin/sh -x -c 'ip link show dummy-test-ns' +ExecStart=/bin/sh -x -c 'test -e /proc/sys/net/ipv4/conf/dummy-test-ns' +# Without mount namespacing, we cannot access the dummy-test-ns interface through sysfs. +ExecStart=/bin/sh -x -c 'test ! -e /sys/class/net/dummy-test-ns' +Type=oneshot +NetworkNamespacePath=/run/netns/test-execute-netns +PrivateMounts=no diff --git a/test/test-execute/exec-networknamespacepath-privatemounts-yes.service b/test/test-execute/exec-networknamespacepath-privatemounts-yes.service new file mode 100644 index 0000000000..078fba8fa2 --- /dev/null +++ b/test/test-execute/exec-networknamespacepath-privatemounts-yes.service @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Unit] +Description=Test for NetworkNamespacePath= with mount namespacing + +[Service] +ExecStart=/bin/sh -x -c '! ip link show dummy-test-exec' +ExecStart=/bin/sh -x -c 'test ! -e /proc/sys/net/ipv4/conf/dummy-test-exec' +# With mount namespacing, we cannot access the dummy-test-exec interface through sysfs. +ExecStart=/bin/sh -x -c 'test ! -e /sys/class/net/dummy-test-exec' +ExecStart=/bin/sh -x -c 'ip link show dummy-test-ns' +ExecStart=/bin/sh -x -c 'test -e /proc/sys/net/ipv4/conf/dummy-test-ns' +# With mount namespacing, we can access the dummy-test-ns interface through sysfs. +ExecStart=/bin/sh -x -c 'test -e /sys/class/net/dummy-test-ns' +Type=oneshot +NetworkNamespacePath=/run/netns/test-execute-netns +# NetworkNamespacePath= implies PrivateMounts=yes |