From: Hans de Goede Date: Fri, 31 Jul 2009 08:31:16 +0000 (+0200) Subject: Implement extended iscsi: rfc4173 syntax which allows specifying credentials X-Git-Tag: 0.8~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=766968bb6f42472393b4afee668ddbf1fa7b394d;p=thirdparty%2Fdracut.git Implement extended iscsi: rfc4173 syntax which allows specifying credentials As discussed before, it would be nice to be able to specify the iscsi chap credentials inside the netroot=iscsi:..... syntax, this patch implements this in a backwards compatible way, like this: iscsi:username:pass@127.0.0.1::3260::iqn.2009-01.com.example:testdisk iscsi:username:pass:reverse:pass@127.0.0.1::3260::iqn.2009-01.com.example:test The only downside is that the backwards compatibility is broken when there is an @ in the iscsi target name (very unlikely), that can still be used, but only like this: iscsi:@192.168.1.100::3260::iqn.2009-01.com.example:testdi@sk --- diff --git a/dracut.8 b/dracut.8 index 37c73bfb7..807d3fe42 100644 --- a/dracut.8 +++ b/dracut.8 @@ -192,7 +192,7 @@ This is supported by dracut but not recommended. .SH iSCSI .TP -.B root=iscsi:[]:[]:[]:[]: +.B root=iscsi:[username:password[reverse:password]@][]:[]:[]:[]: protocol defaults to "6", LUN defaults to "0". If the "servername" field is provided by BOOTP or DHCP, then that @@ -205,18 +205,16 @@ associated fields. http://tools.ietf.org/html/rfc4173 .TP -.B root=iscsi:[]:[]:[]:[]: +.B root=iscsi:[username:password[reverse:password]@][]:[]:[]:[]: e.g. root=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0 - .TP -.B root=??? netroot=iscsi:[]:[]:[]:[]: ... +.B root=??? netroot=iscsi:[username:password[reverse:password]@][]:[]:[]:[]: ... multiple netroot options allow setting up multiple iscsi disks e.g. root=UUID=12424547 netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0 netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target1 .B not yet implemented .TP .B root=??? iscsi_initiator= iscsi_target_name= iscsi_target_ip= iscsi_target_port= iscsi_target_group= iscsi_username= iscsi_password= iscsi_in_username= iscsi_in_password= - .TP .B root=??? iscsi_firmware will read the iscsi parameter from the BIOS firmware diff --git a/modules.d/95iscsi/iscsiroot b/modules.d/95iscsi/iscsiroot index a9ad14ac3..e28cbaa7a 100755 --- a/modules.d/95iscsi/iscsiroot +++ b/modules.d/95iscsi/iscsiroot @@ -77,6 +77,24 @@ fi # override conf/commandline options by dhcp root_path # FIXME this assumes that all values have been provided OLDIFS="$IFS" +IFS=@ +set $iroot +if [ $# -gt 1 ]; then + authinfo=$1; shift + iroot=$* + # 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 + IFS=: + set $authinfo + iscsi_username=$1 + iscsi_password=$2 + if [ $# -gt 2 ]; then + iscsi_in_username=$3 + iscsi_in_password=$4 + fi + fi +fi IFS=: set $iroot iscsi_target_ip=$1; shift