]> git.ipfire.org Git - thirdparty/systemd.git/blame_incremental - test/units/testsuite-23.runtime-bind-paths.sh
mount-util: use mount beneath to replace previous namespace mount
[thirdparty/systemd.git] / test / units / testsuite-23.runtime-bind-paths.sh
... / ...
CommitLineData
1#!/usr/bin/env bash
2# SPDX-License-Identifier: LGPL-2.1-or-later
3# shellcheck disable=SC2016
4set -eux
5set -o pipefail
6
7# Test adding new BindPaths while unit is already running
8
9at_exit() {
10 set +e
11
12 rm -f /run/testsuite-23-marker-{fixed,runtime}
13 rm -fr /run/inaccessible
14}
15
16trap at_exit EXIT
17
18echo "MARKER_FIXED" >/run/testsuite-23-marker-fixed
19mkdir /run/inaccessible
20
21systemctl 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
26echo "MARKER_WRONG" >/run/testsuite-23-marker-wrong
27echo "MARKER_RUNTIME" >/run/testsuite-23-marker-runtime
28
29# Mount twice to exercise mount-beneath (on kernel 6.5+, on older kernels it will just overmount)
30systemctl bind --mkdir testsuite-23-namespaced.service /run/testsuite-23-marker-wrong /tmp/testfile-marker-runtime
31test "$(systemctl show -P SubState testsuite-23-namespaced.service)" = "running"
32systemctl bind --mkdir testsuite-23-namespaced.service /run/testsuite-23-marker-runtime /tmp/testfile-marker-runtime
33
34timeout 10 bash -xec 'while [[ "$(systemctl show -P SubState testsuite-23-namespaced.service)" == running ]]; do sleep .5; done'
35systemctl is-active testsuite-23-namespaced.service
36
37# Now test that systemctl bind fails when attempted on a non-namespaced unit
38systemctl start testsuite-23-non-namespaced.service
39
40(! systemctl bind --mkdir testsuite-49-non-namespaced.service /run/testsuite-23-marker-runtime /tmp/testfile-marker-runtime)
41
42timeout 10 bash -xec 'while [[ "$(systemctl show -P SubState testsuite-23-non-namespaced.service)" == running ]]; do sleep .5; done'
43(! systemctl is-active testsuite-23-non-namespaced.service)