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