]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
99base: Properly remove files with rd.hostonly=0
authorJonas Jonsson <jonas@websystem.se>
Sun, 28 Dec 2014 00:03:29 +0000 (01:03 +0100)
committerHarald Hoyer <harald@redhat.com>
Thu, 19 Feb 2015 09:58:18 +0000 (10:58 +0100)
Dracut will generate systemd units for additional devices that should be
brought up during boot, e.g. swap devices. These unit files are broken
symlinks with \ in the filename, e.g.
/etc/systemd/system/initrd.target.wants/dev-disk-by\x2duuid-e6a54f99\x2da4fd\x2d4931\x2da956\x2d1c642bcfee5e.device.

Both the backslash and the broken symlink causes problems for shell
scripts, [ -e "$file" ] isn't enough and read requires the additional -r
argument to not react on the \.

modules.d/99base/dracut-lib.sh

index 5c1504f49b104a5261bdd546aaf6305e16dd282c..079c9a21ecad4d7941119cb0f97df1330f1eb24c 100755 (executable)
@@ -1286,8 +1286,8 @@ show_memstats()
 remove_hostonly_files() {
     rm -fr /etc/cmdline /etc/cmdline.d/*.conf
     if [ -f /lib/dracut/hostonly-files ]; then
-        while read line; do
-            [ -e "$line" ] || continue
+        while read -r line; do
+            [ -e "$line" ] || [ -h "$line" ] || continue
             rm -f "$line"
         done < /lib/dracut/hostonly-files
     fi