From: Harald Hoyer Date: Wed, 31 Mar 2021 08:41:00 +0000 (+0200) Subject: fix(multipath): shellcheck regression X-Git-Tag: 054~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85378f44af4a0133dce06f81659157c2f45b7517;p=thirdparty%2Fdracut.git fix(multipath): shellcheck regression `$_allow` should not have been quoted, because it can be multiple options. Instead of unquoting it, convert it to an associative array with easy deduplication and prefix every device with the `--allow` option. Fixes: https://github.com/dracutdevs/dracut/issues/1274 --- diff --git a/modules.d/90multipath/module-setup.sh b/modules.d/90multipath/module-setup.sh index 452be6556..681006d80 100755 --- a/modules.d/90multipath/module-setup.sh +++ b/modules.d/90multipath/module-setup.sh @@ -62,17 +62,16 @@ installkernel() { # called by dracut install() { - local _allow + local -A _allow add_hostonly_mpath_conf() { - is_mpath "$1" && { + if is_mpath "$1"; then local _dev _dev=$(majmin_to_mpath_dev "$1") [ -z "$_dev" ] && return - strstr "$_allow" "$_dev" && return - _allow="$_allow --allow $_dev" - } + _allow["$_dev"]="$_dev" + fi } inst_multiple -o \ @@ -92,7 +91,14 @@ install() { [[ $hostonly ]] && [[ $hostonly_mode == "strict" ]] && { for_each_host_dev_and_slaves_all add_hostonly_mpath_conf - [ -n "$_allow" ] && mpathconf "$_allow" --outfile "${initdir}"/etc/multipath.conf + if ((${#_allow[@]} > 0)); then + local -a _args + local _dev + for _dev in "${_allow[@]}"; do + _args+=("--allow" "$_dev") + done + mpathconf "${_args[@]}" --outfile "${initdir}"/etc/multipath.conf + fi } inst "$(command -v partx)" /sbin/partx