]> git.ipfire.org Git - thirdparty/systemd.git/blame - 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
518c3e27
FS
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
7c83d42e 26echo "MARKER_WRONG" >/run/testsuite-23-marker-wrong
518c3e27
FS
27echo "MARKER_RUNTIME" >/run/testsuite-23-marker-runtime
28
7c83d42e
LB
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"
518c3e27
FS
32systemctl bind --mkdir testsuite-23-namespaced.service /run/testsuite-23-marker-runtime /tmp/testfile-marker-runtime
33
a6dac790 34timeout 10 bash -xec 'while [[ "$(systemctl show -P SubState testsuite-23-namespaced.service)" == running ]]; do sleep .5; done'
518c3e27
FS
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
a6dac790 42timeout 10 bash -xec 'while [[ "$(systemctl show -P SubState testsuite-23-non-namespaced.service)" == running ]]; do sleep .5; done'
518c3e27 43(! systemctl is-active testsuite-23-non-namespaced.service)