sysext: Deal with nested mounts properly
Nested mounts should be carried over from host to overlayfs to overlayfs (and back to host if unmerged). Otherwise you run into hard to debug issues where merging extensions means you can't unmount those nested mounts anymore as they are hidden by the overlayfs mount. To fix this, before unmerging any previous extensions, let's move the nested mounts from the hierarchy to the workspace, then set up the new hierachy, and finally, just before moving the hierarchy into place, move the nested mounts back into place. Because there might be multiple nested mounts that consists of one or more mounts stacked on top of each other, we make sure to move all stacked mounts properly to the overlayfs. The kernel doesn't really provide a nice way to do this, so we create a stack, pop off each mount onto the stack and then pop from the stack again to the destination to re-establish the stacked mounts in the same order in the destination.
This commit is contained in:
committed by
Luca Boccassi
parent
5e81ce42e7
commit
ddbddebe0c
@@ -3,6 +3,9 @@
|
||||
set -eux
|
||||
set -o pipefail
|
||||
|
||||
# shellcheck source=test/units/util.sh
|
||||
. "$(dirname "$0")"/util.sh
|
||||
|
||||
FAKE_ROOTS_DIR="$(mktemp -d --tmpdir="" fake-roots-XXX)"
|
||||
FSTYPE=$(stat --file-system --format "%T" /usr)
|
||||
|
||||
@@ -1008,5 +1011,23 @@ if [[ -w /usr ]]; then
|
||||
fi
|
||||
run_sysext_tests "$FAKE_ROOTS_DIR"
|
||||
|
||||
install_extension_images
|
||||
|
||||
# Test that mountpoints are carried over into and back from the sysext overlayfs.
|
||||
ln -s /tmp/app0.raw /var/lib/extensions/app0.raw
|
||||
mkdir /tmp/foo
|
||||
mount --bind /tmp/foo /usr/share
|
||||
systemd-sysext merge
|
||||
test -f /usr/lib/systemd/system/some_file
|
||||
mountpoint /usr/share
|
||||
touch /tmp/foo/abc
|
||||
test -f /usr/share/abc
|
||||
umount /usr/share
|
||||
test ! -f /usr/share/abc
|
||||
mount --bind /tmp/foo /usr/share
|
||||
systemd-sysext unmerge
|
||||
test ! -f /usr/lib/systemd/system/some_file
|
||||
mountpoint /usr/share
|
||||
umount /usr/share
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user