Blame 0007-99base-Properly-remove-files-with-rd.hostonly-0.patch

Harald Hoyer 43a122
From 7075a402d741b0bab1f47ffdec130926b38e3004 Mon Sep 17 00:00:00 2001
Harald Hoyer 43a122
From: Jonas Jonsson <jonas@websystem.se>
Harald Hoyer 43a122
Date: Sun, 28 Dec 2014 01:03:29 +0100
Harald Hoyer 43a122
Subject: [PATCH] 99base: Properly remove files with rd.hostonly=0
Harald Hoyer 43a122
Harald Hoyer 43a122
Dracut will generate systemd units for additional devices that should be
Harald Hoyer 43a122
brought up during boot, e.g. swap devices. These unit files are broken
Harald Hoyer 43a122
symlinks with \ in the filename, e.g.
Harald Hoyer 43a122
/etc/systemd/system/initrd.target.wants/dev-disk-by\x2duuid-e6a54f99\x2da4fd\x2d4931\x2da956\x2d1c642bcfee5e.device.
Harald Hoyer 43a122
Harald Hoyer 43a122
Both the backslash and the broken symlink causes problems for shell
Harald Hoyer 43a122
scripts, [ -e "$file" ] isn't enough and read requires the additional -r
Harald Hoyer 43a122
argument to not react on the \.
Harald Hoyer 43a122
---
Harald Hoyer 43a122
 modules.d/99base/dracut-lib.sh | 4 ++--
Harald Hoyer 43a122
 1 file changed, 2 insertions(+), 2 deletions(-)
Harald Hoyer 43a122
Harald Hoyer 43a122
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer 43a122
index 5c1504f..079c9a2 100755
Harald Hoyer 43a122
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer 43a122
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer 43a122
@@ -1286,8 +1286,8 @@ show_memstats()
Harald Hoyer 43a122
 remove_hostonly_files() {
Harald Hoyer 43a122
     rm -fr /etc/cmdline /etc/cmdline.d/*.conf
Harald Hoyer 43a122
     if [ -f /lib/dracut/hostonly-files ]; then
Harald Hoyer 43a122
-        while read line; do
Harald Hoyer 43a122
-            [ -e "$line" ] || continue
Harald Hoyer 43a122
+        while read -r line; do
Harald Hoyer 43a122
+            [ -e "$line" ] || [ -h "$line" ] || continue
Harald Hoyer 43a122
             rm -f "$line"
Harald Hoyer 43a122
         done < /lib/dracut/hostonly-files
Harald Hoyer 43a122
     fi