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

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