File 0600-iscsiroot-remove-bashisms.patch of Package dracut.16003

From c14a550d54b408088fd0aa14a4f2088f8b45237e Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Thu, 4 Apr 2019 17:12:07 +0200
Subject: [PATCH 6/6] iscsiroot: remove bashisms

According to the dracut README, module code to be run in
the initrd must be POSIX-compliant. Replace remaining
bashisms (as reported by checkbashisms) with POSIX compliant
code.

The use of "type" is not strictly POSIX compliant, but it's
all over the place in dracut code. dash supports it, anyway.
---
 modules.d/95iscsi/iscsiroot.sh | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh
index 73dd8c20..c00a9f58 100755
--- a/modules.d/95iscsi/iscsiroot.sh
+++ b/modules.d/95iscsi/iscsiroot.sh
@@ -61,11 +61,11 @@ handle_firmware()
     if ! iscsiadm -m fw; then
         warn "iscsiadm: Could not get list of targets from firmware."
     else
-        ifaces=( $(echo /sys/firmware/ibft/ethernet*) )
+        ifaces=$(set -- /sys/firmware/ibft/ethernet*; echo $#)
         retry=$(cat /tmp/session-retry)
 
-        if [ $retry -lt ${#ifaces[*]} ]; then
-            let retry++
+        if [ $retry -lt $ifaces ]; then
+            retry=$((retry+1))
             echo $retry > /tmp/session-retry
             return 1
         else
@@ -95,6 +95,7 @@ handle_netroot()
     local iscsi_iface_name iscsi_netdev_name
     local iscsi_param param
     local p found
+    local login_retry_max_seen=
 
     # override conf settings by command line options
     arg=$(getarg rd.iscsi.initiator -d iscsi_initiator=)
@@ -110,7 +111,9 @@ handle_netroot()
     arg=$(getarg rd.iscsi.in.password -d iscsi_in_password=)
     [ -n "$arg" ] && iscsi_in_password=$arg
     for p in $(getargs rd.iscsi.param -d iscsi_param); do
-	iscsi_param="$iscsi_param $p"
+        [ "${p%=*}" = node.session.initial_login_retry_max ] && \
+            login_retry_max_seen=yes
+            iscsi_param="$iscsi_param $p"
     done
 
     # this sets iscsi_target_name and possibly overwrites most
@@ -123,9 +126,8 @@ handle_netroot()
     fi
 
     #limit iscsistart login retries
-    if [[ ! "$iscsi_param" =~ "node.session.initial_login_retry_max" ]]; then
-        set_login_retries
-        retries=$?
+    if [ "$login_retry_max_seen" != yes ]; then
+        retries=$(getargnum 3 0 10000 rd.iscsi.login_retry_max)
         if [ $retries -gt 0 ]; then
             iscsi_param="${iscsi_param% } node.session.initial_login_retry_max=$retries"
         fi
-- 
2.16.4

openSUSE Build Service is sponsored by