712866
From 68021e85c982e62dd4082accf024b84da040f450 Mon Sep 17 00:00:00 2001
712866
From: Hannes Reinecke <hare@suse.de>
712866
Date: Thu, 25 Feb 2016 20:58:13 +0800
712866
Subject: [PATCH] 95iscsi: parse output from iscsiadm correctly
712866
712866
Due to some obsure reason the IFS parameter is not set correctly
712866
when evaluating get_ibft_mod(). So change the parsing to not rely
712866
on IFS altogether.
712866
712866
References: bnc#886199
712866
712866
Signed-off-by: Hannes Reinecke <hare@suse.de>
712866
Signed-off-by: Thomas Renninger <trenn@suse.de>
712866
---
712866
 modules.d/95iscsi/module-setup.sh | 13 +++++++------
712866
 1 file changed, 7 insertions(+), 6 deletions(-)
712866
712866
diff --git a/modules.d/95iscsi/module-setup.sh b/modules.d/95iscsi/module-setup.sh
5c6c2a
index 64c9c1d1..b1f5c6cb 100755
712866
--- a/modules.d/95iscsi/module-setup.sh
712866
+++ b/modules.d/95iscsi/module-setup.sh
712866
@@ -31,15 +31,16 @@ check() {
712866
 
712866
 get_ibft_mod() {
712866
     local ibft_mac=$1
712866
+    local iface_mac iface_mod
712866
     # Return the iSCSI offload module for a given MAC address
712866
-    iscsiadm -m iface | while read iface_name iface_desc ; do
712866
-        IFS=$','
712866
-        set -- $iface_desc
712866
-        if [ "$ibft_mac" = "$2" ] ; then
712866
-            echo $1
712866
+    for iface_desc in $(iscsiadm -m iface | cut -f 2 -d ' '); do
712866
+        iface_mod=${iface_desc%%,*}
712866
+        iface_mac=${iface_desc#*,}
712866
+        iface_mac=${iface_mac%%,*}
712866
+        if [ "$ibft_mac" = "$iface_mac" ] ; then
712866
+            echo $iface_mod
712866
             return 0
712866
         fi
712866
-        unset IFS
712866
     done
712866
 }
712866