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