]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(multipath): shellcheck regression
authorHarald Hoyer <harald@redhat.com>
Wed, 31 Mar 2021 08:41:00 +0000 (10:41 +0200)
committerHarald Hoyer <harald@hoyer.xyz>
Wed, 31 Mar 2021 09:29:31 +0000 (11:29 +0200)
`$_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
modules.d/90multipath/module-setup.sh

index 452be655612271f52c4f0504352cce7289bd60f8..681006d80831b3d38b6fe267628a9b3efa90bb78 100755 (executable)
@@ -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