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.
master
Harald Hoyer 2019-10-23 14:16:56 +02:00 committed by Harald Hoyer
parent 17d62d1206
commit dfe2247a43
1 changed files with 13 additions and 1 deletions

View File

@ -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