mount-util: use mount beneath to replace previous namespace mount
Instead of mounting over, do an atomic swap using mount beneath, if available. This way assets can be mounted again and again (e.g.: updates) without leaking mounts.
This commit is contained in:
committed by
Luca Boccassi
parent
f5e6f3117c
commit
7c83d42ef8
@@ -23,8 +23,12 @@ systemctl start testsuite-23-namespaced.service
|
||||
# Ensure that inaccessible paths aren't bypassed by the runtime setup,
|
||||
(! systemctl bind --mkdir testsuite-23-namespaced.service /run/testsuite-23-marker-fixed /run/inaccessible/testfile-marker-fixed)
|
||||
|
||||
echo "MARKER_WRONG" >/run/testsuite-23-marker-wrong
|
||||
echo "MARKER_RUNTIME" >/run/testsuite-23-marker-runtime
|
||||
|
||||
# Mount twice to exercise mount-beneath (on kernel 6.5+, on older kernels it will just overmount)
|
||||
systemctl bind --mkdir testsuite-23-namespaced.service /run/testsuite-23-marker-wrong /tmp/testfile-marker-runtime
|
||||
test "$(systemctl show -P SubState testsuite-23-namespaced.service)" = "running"
|
||||
systemctl bind --mkdir testsuite-23-namespaced.service /run/testsuite-23-marker-runtime /tmp/testfile-marker-runtime
|
||||
|
||||
timeout 10 bash -xec 'while [[ "$(systemctl show -P SubState testsuite-23-namespaced.service)" == running ]]; do sleep .5; done'
|
||||
|
||||
@@ -363,6 +363,11 @@ ExecStart=/bin/sh -c ' \\
|
||||
EOF
|
||||
systemctl start testservice-50d.service
|
||||
|
||||
# Mount twice to exercise mount-beneath (on kernel 6.5+, on older kernels it will just overmount)
|
||||
mkdir -p /tmp/wrong/foo
|
||||
mksquashfs /tmp/wrong/foo /tmp/wrong.raw
|
||||
systemctl mount-image --mkdir testservice-50d.service /tmp/wrong.raw /tmp/img
|
||||
test "$(systemctl show -P SubState testservice-50d.service)" = "running"
|
||||
systemctl mount-image --mkdir testservice-50d.service "${image}.raw" /tmp/img root:nosuid
|
||||
|
||||
while systemctl show -P SubState testservice-50d.service | grep -q running
|
||||
|
||||
Reference in New Issue
Block a user