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