From 02af947c2c9cf2290183ce28379a40fa6c6d9c56 Mon Sep 17 00:00:00 2001 From: Vladimir Gozora Date: Mon, 18 Feb 2019 21:04:30 +0100 Subject: [PATCH] Do not patch $TARGET_FS_ROOT/etc/mtab if symbolic link. --- usr/share/rear/finalize/GNU/Linux/280_migrate_uuid_tags.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usr/share/rear/finalize/GNU/Linux/280_migrate_uuid_tags.sh b/usr/share/rear/finalize/GNU/Linux/280_migrate_uuid_tags.sh index 32f3e3af31..de3fc107a2 100644 --- a/usr/share/rear/finalize/GNU/Linux/280_migrate_uuid_tags.sh +++ b/usr/share/rear/finalize/GNU/Linux/280_migrate_uuid_tags.sh @@ -34,6 +34,13 @@ for file in [b]oot/{grub.conf,menu.lst,device.map} [e]tc/grub.* \ [e]tc/security/pam_mount.conf.xml [b]oot/efi/*/*/grub.cfg do + # $TARGET_FS_ROOT/etc/mtab is no longer regular file but symbolic link + # pointing to /proc/mounts resp /proc/self/mounts. + # We should not poke around /proc with `sed -i` for this reason we will + # check if $TARGET_FS_ROOT/etc/mtab is symbolic link and skip all further + # replacements. + [[ "$file" = "etc/mtab" && -L "$file" ]] && continue + #[[ -d "$file" ]] && continue # skip directory [[ ! -f "$file" ]] && continue # skip directory and file not found # sed -i bails on symlinks, so we follow the symlink and patch the result