1573a3
From 0a6125bf834c5a1808e4898f46093bc2ab2fed05 Mon Sep 17 00:00:00 2001
1573a3
From: Harald Hoyer <harald@redhat.com>
1573a3
Date: Wed, 23 Oct 2019 14:16:56 +0200
1573a3
Subject: [PATCH] dracut.sh: add check for invalid configuration files
1573a3
1573a3
Emit a warning about possible misconfigured configuration files, where
1573a3
the spaces around values are missing for +=""
1573a3
1573a3
Better report a possible source of problems. We can fix annoying false
1573a3
positives later.
1573a3
1573a3
(cherry picked from commit dfe2247a43d6a216d9af533825c9a103e3b056cd)
1573a3
1573a3
Resolves: #1946245
1573a3
---
1573a3
 dracut.sh | 14 +++++++++++++-
1573a3
 1 file changed, 13 insertions(+), 1 deletion(-)
1573a3
1573a3
diff --git a/dracut.sh b/dracut.sh
1573a3
index 952c57c8..702b2f78 100755
1573a3
--- a/dracut.sh
1573a3
+++ b/dracut.sh
1573a3
@@ -277,6 +277,14 @@ read_arg() {
1573a3
     fi
1573a3
 }
1573a3
 
1573a3
+check_conf_file()
1573a3
+{
1573a3
+    if grep -H -e '^[^#]*[+]=\("[^ ]\|.*[^ ]"\)' "$@"; then
1573a3
+        printf '\ndracut: WARNING: <key>+=" <values> ": <values> should have surrounding white spaces!\n' >&2
1573a3
+        printf 'dracut: WARNING: This will lead to unwanted side effects! Please fix the configuration file.\n\n' >&2
1573a3
+    fi
1573a3
+}
1573a3
+
1573a3
 dropindirs_sort()
1573a3
 {
1573a3
     local suffix=$1; shift
1573a3
@@ -697,10 +705,14 @@ if [[ ! -d $confdir ]]; then
1573a3
 fi
1573a3
 
1573a3
 # source our config file
1573a3
-[[ -f $conffile ]] && . "$conffile"
1573a3
+if [[ -f $conffile ]]; then
1573a3
+    check_conf_file "$conffile"
1573a3
+    . "$conffile"
1573a3
+fi
1573a3
 
1573a3
 # source our config dir
1573a3
 for f in $(dropindirs_sort ".conf" "$confdir" "$dracutbasedir/dracut.conf.d"); do
1573a3
+    check_conf_file "$f"
1573a3
     [[ -e $f ]] && . "$f"
1573a3
 done
1573a3
 
1573a3