]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
95iscsi: parse output from iscsiadm correctly
authorHannes Reinecke <hare@suse.de>
Thu, 25 Feb 2016 12:58:13 +0000 (20:58 +0800)
committerHarald Hoyer <harald@redhat.com>
Wed, 18 May 2016 12:44:16 +0000 (14:44 +0200)
Due to some obsure reason the IFS parameter is not set correctly
when evaluating get_ibft_mod(). So change the parsing to not rely
on IFS altogether.

References: bnc#886199

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
modules.d/95iscsi/module-setup.sh

index 64c9c1d161acff599b5713de268cdd5fdffe1091..b1f5c6cb05ff4524cf281b42992627229a0a7a07 100755 (executable)
@@ -31,15 +31,16 @@ check() {
 
 get_ibft_mod() {
     local ibft_mac=$1
+    local iface_mac iface_mod
     # Return the iSCSI offload module for a given MAC address
-    iscsiadm -m iface | while read iface_name iface_desc ; do
-        IFS=$','
-        set -- $iface_desc
-        if [ "$ibft_mac" = "$2" ] ; then
-            echo $1
+    for iface_desc in $(iscsiadm -m iface | cut -f 2 -d ' '); do
+        iface_mod=${iface_desc%%,*}
+        iface_mac=${iface_desc#*,}
+        iface_mac=${iface_mac%%,*}
+        if [ "$ibft_mac" = "$iface_mac" ] ; then
+            echo $iface_mod
             return 0
         fi
-        unset IFS
     done
 }