From 097dd367bbd61da1577a182c535c5aacdfd07031 Mon Sep 17 00:00:00 2001 From: Antonio Alvarez Feijoo Date: Mon, 12 Dec 2022 15:41:55 +0100 Subject: [PATCH] fix(dracut): shellcheck regression in DRACUT_INSTALL calls If the DRACUT_INSTALL environment variable contains arguments (e.g.: DRACUT_INSTALL="/usr/lib/dracut/dracut-install --debug"), its call cannot be enclosed in double quotes. E.g.: ``` > export DRACUT_INSTALL="/usr/lib/dracut/dracut-install" > "$DRACUT_INSTALL" > /dev/null dracut-install: No SOURCE argument given > export DRACUT_INSTALL="/usr/lib/dracut/dracut-install --debug" > "$DRACUT_INSTALL" > /dev/null -bash: /usr/lib/dracut/dracut-install --debug: No such file or directory > $DRACUT_INSTALL > /dev/null dracut-install: No SOURCE argument given ``` --- dracut-init.sh | 24 ++++++++++++------------ dracut.sh | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/dracut-init.sh b/dracut-init.sh index 30de6f6cb..c89f7e80e 100755 --- a/dracut-init.sh +++ b/dracut-init.sh @@ -203,7 +203,7 @@ fi if [[ $hostonly == "-h" ]]; then if ! [[ $DRACUT_KERNEL_MODALIASES ]] || ! [[ -f $DRACUT_KERNEL_MODALIASES ]]; then export DRACUT_KERNEL_MODALIASES="${DRACUT_TMPDIR}/modaliases" - "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${srcmods:+--kerneldir "$srcmods"} --modalias > "$DRACUT_KERNEL_MODALIASES" + $DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${srcmods:+--kerneldir "$srcmods"} --modalias > "$DRACUT_KERNEL_MODALIASES" fi fi @@ -211,7 +211,7 @@ fi inst_dir() { local _ret [[ -e ${initdir}/"$1" ]] && return 0 # already there - if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -d "$@"; then + if $DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -d "$@"; then return 0 else _ret=$? @@ -227,7 +227,7 @@ inst() { shift fi [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there - if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then + if $DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then return 0 else _ret=$? @@ -244,7 +244,7 @@ inst_simple() { fi [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there [[ -e $1 ]] || return 1 # no source - if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@"; then + if $DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${_hostonly_install:+-H} "$@"; then return 0 else _ret=$? @@ -261,7 +261,7 @@ inst_symlink() { fi [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there [[ -L $1 ]] || return 1 - if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then + if $DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then return 0 else _ret=$? @@ -276,7 +276,7 @@ inst_multiple() { _hostonly_install="-H" shift fi - if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then + if $DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then return 0 else _ret=$? @@ -298,7 +298,7 @@ dracut_instmods() { [[ $i == "--silent" ]] && _silent=1 done - if "$DRACUT_INSTALL" \ + if $DRACUT_INSTALL \ ${dracutsysrootdir:+-r "$dracutsysrootdir"} \ ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${srcmods:+--kerneldir "$srcmods"} -m "$@"; then return 0 @@ -319,7 +319,7 @@ inst_library() { fi [[ -e ${initdir}/"${2:-$1}" ]] && return 0 # already there [[ -e $1 ]] || return 1 # no source - if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then + if $DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@"; then return 0 else _ret=$? @@ -330,7 +330,7 @@ inst_library() { inst_binary() { local _ret - if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then + if $DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then return 0 else _ret=$? @@ -341,7 +341,7 @@ inst_binary() { inst_script() { local _ret - if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then + if $DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$@"; then return 0 else _ret=$? @@ -352,7 +352,7 @@ inst_script() { inst_fsck_help() { local _ret _helper="/run/dracut/fsck/fsck_help_$1.txt" - if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" "$_helper"; then + if $DRACUT_INSTALL ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l} ${DRACUT_FIPS_MODE:+-f} "$2" "$_helper"; then return 0 else _ret=$? @@ -1112,7 +1112,7 @@ instmods() { return 0 fi - "$DRACUT_INSTALL" \ + $DRACUT_INSTALL \ ${initdir:+-D "$initdir"} \ ${dracutsysrootdir:+-r "$dracutsysrootdir"} \ ${loginstall:+-L "$loginstall"} \ diff --git a/dracut.sh b/dracut.sh index 0381985e0..f6b8a015a 100755 --- a/dracut.sh +++ b/dracut.sh @@ -2168,8 +2168,9 @@ if [[ $kernel_only != yes ]]; then if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then dinfo "*** Resolving executable dependencies ***" + # shellcheck disable=SC2086 find "$initdir" -type f -perm /0111 -not -path '*.ko' -print0 \ - | xargs -r -0 "$DRACUT_INSTALL" ${initdir:+-D "$initdir"} ${dracutsysrootdir:+-r "$dracutsysrootdir"} -R ${DRACUT_FIPS_MODE:+-f} -- + | xargs -r -0 $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${dracutsysrootdir:+-r "$dracutsysrootdir"} -R ${DRACUT_FIPS_MODE:+-f} -- dinfo "*** Resolving executable dependencies done ***" fi -- 2.47.3