]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut.sh): do not ignore invalid config file or dir path
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Thu, 14 Oct 2021 15:10:27 +0000 (17:10 +0200)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Sat, 11 Dec 2021 15:58:50 +0000 (15:58 +0000)
Fix issue #1136

dracut.sh

index ce54a851950141779e7c63683101e0d283af5187..20556762c4c360b70d753dadefd8cbf5e27ff3be 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -891,20 +891,26 @@ export DRACUT_LOG_LEVEL=warning
 [[ $dracutbasedir ]] || dracutbasedir="$dracutsysrootdir"/usr/lib/dracut
 
 # if we were not passed a config file, try the default one
-if [[ ! -f $conffile ]]; then
+if [[ -z $conffile ]]; then
     if [[ $allowlocal ]]; then
         conffile="$dracutbasedir/dracut.conf"
     else
         conffile="$dracutsysrootdir/etc/dracut.conf"
     fi
+elif [[ ! -f $conffile ]]; then
+    printf "%s\n" "dracut: Configuration file '$conffile' not found." >&2
+    exit 1
 fi
 
-if [[ ! -d $confdir ]]; then
+if [[ -z $confdir ]]; then
     if [[ $allowlocal ]]; then
         confdir="$dracutbasedir/dracut.conf.d"
     else
         confdir="$dracutsysrootdir/etc/dracut.conf.d"
     fi
+elif [[ ! -d $confdir ]]; then
+    printf "%s\n" "dracut: Configuration directory '$confdir' not found." >&2
+    exit 1
 fi
 
 # source our config file