Blame SOURCES/0213-network-net-lib.sh-parse_iscsi_root-do-not-enforce-t.patch

712866
From f86fa29cda6dcea1320de29864173d4de47c5bb7 Mon Sep 17 00:00:00 2001
712866
From: Harald Hoyer <harald@redhat.com>
712866
Date: Tue, 9 Sep 2014 13:33:16 +0200
712866
Subject: [PATCH] network/net-lib.sh:parse_iscsi_root() do not enforce target
712866
 name
712866
712866
https://bugzilla.redhat.com/show_bug.cgi?id=1078867
712866
712866
cherry-picked from 29763cb72d17fe8d22766170ec06b32419829243
712866
---
712866
 modules.d/40network/net-lib.sh | 112 ++++++++++++++++++-----------------------
712866
 1 file changed, 50 insertions(+), 62 deletions(-)
712866
712866
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
5c6c2a
index c8f92048..e2901dad 100755
712866
--- a/modules.d/40network/net-lib.sh
712866
+++ b/modules.d/40network/net-lib.sh
712866
@@ -271,66 +271,46 @@ parse_iscsi_root()
712866
     local v
712866
     v=${1#iscsi:}
712866
 
712866
-# extract authentication info
712866
+    # extract authentication info
712866
     case "$v" in
712866
-	*@*:*:*:*:*)
712866
-	    authinfo=${v%%@*}
712866
-	    v=${v#*@}
712866
-    # allow empty authinfo to allow having an @ in iscsi_target_name like this:
712866
-    # netroot=iscsi:@192.168.1.100::3260::iqn.2009-01.com.example:testdi@sk
712866
-	    if [ -n "$authinfo" ]; then
712866
-		OLDIFS="$IFS"
712866
-		IFS=:
712866
-		set $authinfo
712866
-		IFS="$OLDIFS"
712866
-		if [ $# -gt 4 ]; then
712866
-		    warn "Wrong authentication info in iscsi: parameter!"
712866
-		    return 1
712866
-		fi
712866
-		iscsi_username=$1
712866
-		iscsi_password=$2
712866
-		if [ $# -gt 2 ]; then
712866
-		    iscsi_in_username=$3
712866
-		    iscsi_in_password=$4
712866
-		fi
712866
-	    fi
712866
-	    ;;
712866
-    esac
712866
-
712866
-# extract target ip
712866
-    case "$v" in
712866
-	[[]*[]]:*)
712866
-	    iscsi_target_ip=${v#[[]}
712866
-		iscsi_target_ip=${iscsi_target_ip%%[]]*}
712866
-	    v=${v#[[]$iscsi_target_ip[]]:}
712866
-	    ;;
712866
-	*)
712866
-	    iscsi_target_ip=${v%%[:]*}
712866
-	    v=${v#$iscsi_target_ip:}
712866
-	    ;;
712866
+        *@*:*:*:*:*)
712866
+            authinfo=${v%%@*}
712866
+            v=${v#*@}
712866
+            # allow empty authinfo to allow having an @ in iscsi_target_name like this:
712866
+            # netroot=iscsi:@192.168.1.100::3260::iqn.2009-01.com.example:testdi@sk
712866
+            if [ -n "$authinfo" ]; then
712866
+                OLDIFS="$IFS"
712866
+                IFS=:
712866
+                set $authinfo
712866
+                IFS="$OLDIFS"
712866
+                if [ $# -gt 4 ]; then
712866
+                    warn "Wrong authentication info in iscsi: parameter!"
712866
+                    return 1
712866
+                fi
712866
+                iscsi_username=$1
712866
+                iscsi_password=$2
712866
+                if [ $# -gt 2 ]; then
712866
+                    iscsi_in_username=$3
712866
+                    iscsi_in_password=$4
712866
+                fi
712866
+            fi
712866
+            ;;
712866
     esac
712866
 
712866
-# extract target name
712866
+    # extract target ip
712866
     case "$v" in
712866
-	*:iqn.*)
712866
-	    iscsi_target_name=iqn.${v##*:iqn.}
712866
-	    v=${v%:iqn.*}:
712866
-	    ;;
712866
-	*:eui.*)
712866
-	    iscsi_target_name=iqn.${v##*:eui.}
712866
-	    v=${v%:iqn.*}:
712866
-	    ;;
712866
-	*:naa.*)
712866
-	    iscsi_target_name=iqn.${v##*:naa.}
712866
-	    v=${v%:iqn.*}:
712866
-	    ;;
712866
-	*)
712866
-	    warn "Invalid iscii target name, should begin with 'iqn.' or 'eui.' or 'naa.'"
712866
-	    return 1
712866
-	    ;;
712866
+        [[]*[]]:*)
712866
+            iscsi_target_ip=${v#[[]}
712866
+                iscsi_target_ip=${iscsi_target_ip%%[]]*}
712866
+            v=${v#[[]$iscsi_target_ip[]]:}
712866
+            ;;
712866
+        *)
712866
+            iscsi_target_ip=${v%%[:]*}
712866
+            v=${v#$iscsi_target_ip:}
712866
+            ;;
712866
     esac
712866
 
712866
-# parse the rest
712866
+    # parse the rest
712866
     OLDIFS="$IFS"
712866
     IFS=:
712866
     set $v
712866
@@ -338,17 +318,25 @@ parse_iscsi_root()
712866
 
712866
     iscsi_protocol=$1; shift # ignored
712866
     iscsi_target_port=$1; shift
712866
-    if [ $# -eq 3 ]; then
712866
-	iscsi_iface_name=$1; shift
712866
-    fi
712866
-    if [ $# -eq 2 ]; then
712866
-	iscsi_netdev_name=$1; shift
712866
+
712866
+    if [ $# -gt 3 ] && [ -n "$1$2" ]; then
712866
+        iscsi_iface_name=$1; shift
712866
+        iscsi_netdev_name=$1; shift
712866
     fi
712866
+
712866
     iscsi_lun=$1; shift
712866
-    if [ $# -ne 0 ]; then
712866
-	warn "Invalid parameter in iscsi: parameter!"
712866
-	return 1
712866
+
712866
+    if [ $# -gt 2 ]; then
712866
+        warn "Invalid parameter in iscsi: parameter!"
712866
+        return 1
712866
     fi
712866
+
712866
+    if [ $# -eq 2 ]; then
712866
+        iscsi_target_name="$1:$2"
712866
+    else
712866
+        iscsi_target_name="$1"
712866
+    fi
712866
+
712866
 }
712866
 
712866
 ip_to_var() {