Blob Blame History Raw
From f86fa29cda6dcea1320de29864173d4de47c5bb7 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Tue, 9 Sep 2014 13:33:16 +0200
Subject: [PATCH] network/net-lib.sh:parse_iscsi_root() do not enforce target
 name

https://bugzilla.redhat.com/show_bug.cgi?id=1078867

cherry-picked from 29763cb72d17fe8d22766170ec06b32419829243
---
 modules.d/40network/net-lib.sh | 112 +++++++++++++++------------------
 1 file changed, 50 insertions(+), 62 deletions(-)

diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
index c8f92048..e2901dad 100755
--- a/modules.d/40network/net-lib.sh
+++ b/modules.d/40network/net-lib.sh
@@ -271,66 +271,46 @@ parse_iscsi_root()
     local v
     v=${1#iscsi:}
 
-# extract authentication info
+    # extract authentication info
     case "$v" in
-	*@*:*:*:*:*)
-	    authinfo=${v%%@*}
-	    v=${v#*@}
-    # allow empty authinfo to allow having an @ in iscsi_target_name like this:
-    # netroot=iscsi:@192.168.1.100::3260::iqn.2009-01.com.example:testdi@sk
-	    if [ -n "$authinfo" ]; then
-		OLDIFS="$IFS"
-		IFS=:
-		set $authinfo
-		IFS="$OLDIFS"
-		if [ $# -gt 4 ]; then
-		    warn "Wrong authentication info in iscsi: parameter!"
-		    return 1
-		fi
-		iscsi_username=$1
-		iscsi_password=$2
-		if [ $# -gt 2 ]; then
-		    iscsi_in_username=$3
-		    iscsi_in_password=$4
-		fi
-	    fi
-	    ;;
-    esac
-
-# extract target ip
-    case "$v" in
-	[[]*[]]:*)
-	    iscsi_target_ip=${v#[[]}
-		iscsi_target_ip=${iscsi_target_ip%%[]]*}
-	    v=${v#[[]$iscsi_target_ip[]]:}
-	    ;;
-	*)
-	    iscsi_target_ip=${v%%[:]*}
-	    v=${v#$iscsi_target_ip:}
-	    ;;
+        *@*:*:*:*:*)
+            authinfo=${v%%@*}
+            v=${v#*@}
+            # allow empty authinfo to allow having an @ in iscsi_target_name like this:
+            # netroot=iscsi:@192.168.1.100::3260::iqn.2009-01.com.example:testdi@sk
+            if [ -n "$authinfo" ]; then
+                OLDIFS="$IFS"
+                IFS=:
+                set $authinfo
+                IFS="$OLDIFS"
+                if [ $# -gt 4 ]; then
+                    warn "Wrong authentication info in iscsi: parameter!"
+                    return 1
+                fi
+                iscsi_username=$1
+                iscsi_password=$2
+                if [ $# -gt 2 ]; then
+                    iscsi_in_username=$3
+                    iscsi_in_password=$4
+                fi
+            fi
+            ;;
     esac
 
-# extract target name
+    # extract target ip
     case "$v" in
-	*:iqn.*)
-	    iscsi_target_name=iqn.${v##*:iqn.}
-	    v=${v%:iqn.*}:
-	    ;;
-	*:eui.*)
-	    iscsi_target_name=iqn.${v##*:eui.}
-	    v=${v%:iqn.*}:
-	    ;;
-	*:naa.*)
-	    iscsi_target_name=iqn.${v##*:naa.}
-	    v=${v%:iqn.*}:
-	    ;;
-	*)
-	    warn "Invalid iscii target name, should begin with 'iqn.' or 'eui.' or 'naa.'"
-	    return 1
-	    ;;
+        [[]*[]]:*)
+            iscsi_target_ip=${v#[[]}
+                iscsi_target_ip=${iscsi_target_ip%%[]]*}
+            v=${v#[[]$iscsi_target_ip[]]:}
+            ;;
+        *)
+            iscsi_target_ip=${v%%[:]*}
+            v=${v#$iscsi_target_ip:}
+            ;;
     esac
 
-# parse the rest
+    # parse the rest
     OLDIFS="$IFS"
     IFS=:
     set $v
@@ -338,17 +318,25 @@ parse_iscsi_root()
 
     iscsi_protocol=$1; shift # ignored
     iscsi_target_port=$1; shift
-    if [ $# -eq 3 ]; then
-	iscsi_iface_name=$1; shift
-    fi
-    if [ $# -eq 2 ]; then
-	iscsi_netdev_name=$1; shift
+
+    if [ $# -gt 3 ] && [ -n "$1$2" ]; then
+        iscsi_iface_name=$1; shift
+        iscsi_netdev_name=$1; shift
     fi
+
     iscsi_lun=$1; shift
-    if [ $# -ne 0 ]; then
-	warn "Invalid parameter in iscsi: parameter!"
-	return 1
+
+    if [ $# -gt 2 ]; then
+        warn "Invalid parameter in iscsi: parameter!"
+        return 1
     fi
+
+    if [ $# -eq 2 ]; then
+        iscsi_target_name="$1:$2"
+    else
+        iscsi_target_name="$1"
+    fi
+
 }
 
 ip_to_var() {