]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(dracut): source dracut-functions.sh before calling dwarning
authorBenjamin Drung <benjamin.drung@canonical.com>
Mon, 5 Jan 2026 23:32:20 +0000 (00:32 +0100)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Tue, 6 Jan 2026 11:31:50 +0000 (06:31 -0500)
`dracut-functions.sh` sources `dracut-logger.sh` which defines the
`dwarning` function. `dracut.sh` might call `dwarning` before
`dracut-functions.sh` is sourced.

`dracut-functions.sh` calls `find_binary` and `dlog_init` when sourced.
`find_binary` needs `dracutsysrootdir` set and `dlog_init` needs
`stdloglvl`, `sysloglvl`, `kmsgloglvl`, `maxloglvl`, `fileloglvl`,
`logfile`. Move sourcing `dracut-functions.sh` as early as possible, but
after setting those variables.

Follow-up for 8d9887b
Fixes: https://bugs.debian.org/1124479
dracut.sh

index d490c4e9e5ddd4ce96040263365d6819986aeaaf..d8dbcc5c818c06a438a6216e375837dbde1bdc02 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -1204,6 +1204,9 @@ drivers_dir="${drivers_dir%"${drivers_dir##*[!/]}"}"
 [[ $sbat_l ]] && sbat="$sbat_l"
 [[ $machine_id_l ]] && machine_id="$machine_id_l"
 
+# shellcheck source=./dracut-functions.sh
+. "$dracutbasedir"/dracut-functions.sh
+
 if ! [[ $outfile ]]; then
     if [[ $machine_id != "no" ]]; then
         if [[ -d "${dracutsysrootdir-}"/efi/Default ]] \
@@ -1487,9 +1490,6 @@ if ! [[ ${dracutbasedir-} ]]; then
     dracutbasedir="$(readlink -f "$dracutbasedir")"
 fi
 
-# shellcheck source=./dracut-functions.sh
-. "$dracutbasedir"/dracut-functions.sh
-
 if ! [[ ${initdir-} ]]; then
     dfatal "initdir not set"
     exit 1