]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(functions): prevent find_binary from dropping last PATH element
authorMatéo Pourrier <mateo.pourrier@smile.fr>
Tue, 28 Apr 2026 15:23:23 +0000 (17:23 +0200)
committerBenjamin Drung <bdrung@ubuntu.com>
Thu, 30 Apr 2026 12:01:47 +0000 (14:01 +0200)
When `read` encounters EOF before the delimiter, it returns a non-zero
exit status, causing the while loop to terminate immediately. As a result,
if the PATH string doesn't end with a colon, the very last directory in
PATH is ignored by find_binary().

This caused regressions on split-usr architectures where critical
binaries reside exclusively in /bin, and /bin happens to be
appended at the very end of the PATH by dracut.sh.

Appending a virtual colon to the Here-String ensures the loop processes
all directories correctly.

Fixes dracut-ng issue #1467.

dracut-functions.sh

index d617acd8d85683c5d28fca012ec69176740dc323..d03ba24fbe6a963e8c74d696b0e5e9fde67510b6 100755 (executable)
@@ -94,7 +94,7 @@ find_binary() {
             printf "%s\n" "${_path}"
             return 0
         fi
-    done <<< "$PATH"
+    done <<< "${PATH}:"
 
     [[ -n ${dracutsysrootdir-} ]] && return 1
     type -P "${1##*/}"