Blame SOURCES/0377-95iscsi-parse-output-from-iscsiadm-correctly.patch

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