live-build/functions: Always use mount --make-private before umount

Util-linux 2.33 fixed mount --rbind --make-rslave which did not pass MS_REC
with MS_BIND and livecd-rootfs did only --bind --make-rslave effectively with
prior mount versions.
While mount --rbind --rslave are properly passed the flags to mount()
unmounting did not work cleanly with --make-rslave.

To clearly stop propagation of umount, --make-private is used instead of
--make-rslave and it is always set before umounts. Umount -R is replaced
with a simple umount since submounts are tore down in teardown_mountpoint()
earlier.

LP: #1813730
sil2100/core18-pi3-arm64
Balint Reczey 6 years ago
parent a06d208871
commit 33c5ad0b19

@ -91,7 +91,7 @@ mount_image() {
setup_mountpoint() { setup_mountpoint() {
local mountpoint="$1" local mountpoint="$1"
mount --rbind --make-rslave /dev "$mountpoint/dev" mount --rbind /dev "$mountpoint/dev"
mount proc-live -t proc "$mountpoint/proc" mount proc-live -t proc "$mountpoint/proc"
mount sysfs-live -t sysfs "$mountpoint/sys" mount sysfs-live -t sysfs "$mountpoint/sys"
mount -t tmpfs none "$mountpoint/tmp" mount -t tmpfs none "$mountpoint/tmp"
@ -112,6 +112,7 @@ teardown_mountpoint() {
# sort -r ensures that deeper mountpoints are unmounted first # sort -r ensures that deeper mountpoints are unmounted first
for submount in $(awk </proc/self/mounts "\$2 ~ /$mountpoint_match/ \ for submount in $(awk </proc/self/mounts "\$2 ~ /$mountpoint_match/ \
{ print \$2 }" | LC_ALL=C sort -r); do { print \$2 }" | LC_ALL=C sort -r); do
mount --make-private $submount
umount $submount umount $submount
done done
mv resolv.conf.tmp "$mountpoint/etc/resolv.conf" mv resolv.conf.tmp "$mountpoint/etc/resolv.conf"
@ -179,7 +180,8 @@ EOF
umount_partition() { umount_partition() {
local mountpoint=${1} local mountpoint=${1}
teardown_mountpoint $mountpoint teardown_mountpoint $mountpoint
umount -R $mountpoint mount --make-private $mountpoint
umount $mountpoint
udevadm settle udevadm settle
if [ -n "${rootfs_dev_mapper}" -a -b "${rootfs_dev_mapper}" ]; then if [ -n "${rootfs_dev_mapper}" -a -b "${rootfs_dev_mapper}" ]; then
@ -202,6 +204,7 @@ umount_disk_image() {
# zero fill free space in UEFI partition # zero fill free space in UEFI partition
cat < /dev/zero > "$mountpoint/boot/efi/bloat_file" 2> /dev/null || true cat < /dev/zero > "$mountpoint/boot/efi/bloat_file" 2> /dev/null || true
rm "$mountpoint/boot/efi/bloat_file" rm "$mountpoint/boot/efi/bloat_file"
mount --make-private "$mountpoint/boot/efi"
umount --detach-loop "$mountpoint/boot/efi" umount --detach-loop "$mountpoint/boot/efi"
fi fi

Loading…
Cancel
Save