]>
Commit | Line | Data |
---|---|---|
518c3e27 FS |
1 | #!/usr/bin/env bash |
2 | # SPDX-License-Identifier: LGPL-2.1-or-later | |
3 | # shellcheck disable=SC2016 | |
4 | set -eux | |
5 | set -o pipefail | |
6 | ||
7 | # Test adding new BindPaths while unit is already running | |
8 | ||
9 | at_exit() { | |
10 | set +e | |
11 | ||
12 | rm -f /run/testsuite-23-marker-{fixed,runtime} | |
13 | rm -fr /run/inaccessible | |
14 | } | |
15 | ||
16 | trap at_exit EXIT | |
17 | ||
18 | echo "MARKER_FIXED" >/run/testsuite-23-marker-fixed | |
19 | mkdir /run/inaccessible | |
20 | ||
21 | systemctl start testsuite-23-namespaced.service | |
22 | ||
23 | # Ensure that inaccessible paths aren't bypassed by the runtime setup, | |
24 | (! systemctl bind --mkdir testsuite-23-namespaced.service /run/testsuite-23-marker-fixed /run/inaccessible/testfile-marker-fixed) | |
25 | ||
26 | echo "MARKER_RUNTIME" >/run/testsuite-23-marker-runtime | |
27 | ||
28 | systemctl bind --mkdir testsuite-23-namespaced.service /run/testsuite-23-marker-runtime /tmp/testfile-marker-runtime | |
29 | ||
a6dac790 | 30 | timeout 10 bash -xec 'while [[ "$(systemctl show -P SubState testsuite-23-namespaced.service)" == running ]]; do sleep .5; done' |
518c3e27 FS |
31 | systemctl is-active testsuite-23-namespaced.service |
32 | ||
33 | # Now test that systemctl bind fails when attempted on a non-namespaced unit | |
34 | systemctl start testsuite-23-non-namespaced.service | |
35 | ||
36 | (! systemctl bind --mkdir testsuite-49-non-namespaced.service /run/testsuite-23-marker-runtime /tmp/testfile-marker-runtime) | |
37 | ||
a6dac790 | 38 | timeout 10 bash -xec 'while [[ "$(systemctl show -P SubState testsuite-23-non-namespaced.service)" == running ]]; do sleep .5; done' |
518c3e27 | 39 | (! systemctl is-active testsuite-23-non-namespaced.service) |