Skip to content

Commit

Permalink
fix(multipath): shellcheck regression
Browse files Browse the repository at this point in the history
`$_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: #1274
  • Loading branch information
haraldh committed Mar 31, 2021
1 parent af3cd22 commit 85378f4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions modules.d/90multipath/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand Down

0 comments on commit 85378f4

Please sign in to comment.