From 8d9887bd773936cf3e42798dd26d70edd4213d4d Mon Sep 17 00:00:00 2001 From: Jo Zzsi Date: Sat, 2 Aug 2025 12:53:50 -0400 Subject: [PATCH] fix: make sure final hostonly value is computed before reading it hostonly variable is unset later in a later code block after decisions are made based on the value of the hostonly variable which is unexpected, hard to reason about and inconsistent. Fix it by rearranging the order of execution of the code blocks. --- dracut.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dracut.sh b/dracut.sh index d5c5db084..66608508a 100755 --- a/dracut.sh +++ b/dracut.sh @@ -1314,6 +1314,15 @@ check_kernel_compress_support() { [[ ${hostonly-} == yes ]] && hostonly="-h" [[ ${hostonly-} != "-h" ]] && unset hostonly +if [[ ${hostonly-} ]]; then + for i in /sys /proc /run /dev; do + if ! findmnt --target "$i" &> /dev/null; then + dwarning "Turning off host-only mode: '$i' is not mounted!" + unset hostonly + fi + done +fi + case $hostonly_mode in '') [[ ${hostonly-} ]] && hostonly_mode="sloppy" @@ -1726,15 +1735,6 @@ fi # Need to be able to have non-root users read stuff (rpcbind etc) chmod 755 "$initdir" -if [[ ${hostonly-} ]]; then - for i in /sys /proc /run /dev; do - if ! findmnt --target "$i" &> /dev/null; then - dwarning "Turning off host-only mode: '$i' is not mounted!" - unset hostonly - fi - done -fi - declare -A host_fs_types=() declare -a host_devs=() declare -a root_devs=() -- 2.47.3