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