From d46633f7694ed1dd49f671582ba3c21a246339cf Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sun, 21 Oct 2012 17:20:16 -0700 Subject: [PATCH] Add fields to allow per-session login and password --- iscsi-client/add_conn.cgi | 10 +++++++- iscsi-client/add_form.cgi | 12 +++++++++ iscsi-client/images/smallicon.gif | Bin 0 -> 1289 bytes iscsi-client/iscsi-client-lib.pl | 39 ++++++++++++++++++++++++++---- iscsi-client/lang/en | 3 +++ 5 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 iscsi-client/images/smallicon.gif diff --git a/iscsi-client/add_conn.cgi b/iscsi-client/add_conn.cgi index 2e6da5239..92720c8a2 100755 --- a/iscsi-client/add_conn.cgi +++ b/iscsi-client/add_conn.cgi @@ -18,9 +18,17 @@ if ($in{'target'}) { $target || &error(&text('add_etarget', $in{'target'})); } +# Validate username and password +my @auth; +if (!$in{'auth_def'}) { + $in{'authuser'} =~ /\S/ || &error($text{'auth_eusername'}); + $in{'authpass'} =~ /\S/ || &error($text{'auth_epassword'}); + @auth = ( $in{'authmethod'}, $in{'authuser'}, $in{'authpass'} ); + } + # Try to make the connection my $err = &create_iscsi_connection($in{'host'}, $in{'port'}, - $in{'iface'}, $target); + $in{'iface'}, $target, @auth); &error($err) if ($err); &webmin_log("add", "connection", $in{'host'}, diff --git a/iscsi-client/add_form.cgi b/iscsi-client/add_form.cgi index ee0b9e719..38af87f29 100755 --- a/iscsi-client/add_form.cgi +++ b/iscsi-client/add_form.cgi @@ -41,6 +41,7 @@ print &ui_table_row($text{'conns_port'}, print &ui_table_row($text{'conns_iface'}, $in{'iface'} || "$text{'conns_ifacedef'}"); +# Target to mount print &ui_table_row($text{'add_target'}, &ui_select("target", undef, [ [ "", "<".$text{'add_alltargets'}.">" ], @@ -53,6 +54,17 @@ print &ui_table_row($text{'add_target'}, : " (".$text{'add_used'}.")"), ] } @$targets ])); +# Username, password and authentication method +print &ui_table_row($text{'add_auth'}, + &ui_radio("auth_def", 1, + [ [ 1, $text{'add_auth1'}."
" ], + [ 0, &text('add_auth0', + &ui_select("authmethod", "CHAP", + [ [ "None", $text{'auth_method_none'} ], + [ "CHAP" ] ]), + &ui_textbox("authuser", undef, 15), + &ui_textbox("authpass", undef, 15)) ] ])); + print &ui_table_end(); print &ui_form_end([ [ undef, $text{'add_ok'} ] ]); diff --git a/iscsi-client/images/smallicon.gif b/iscsi-client/images/smallicon.gif new file mode 100644 index 0000000000000000000000000000000000000000..18bf9f3da09e371fbdfae4a306abaa0e12f29d8e GIT binary patch literal 1289 zcmV+k1@`(!Nk%v~VHf}y0QUd@kFU$v;_H#D!;8A;s?F@1xX^{A!I`$sa*?Z$vCqHO z=99tcZHuPNbYKWrH z;O~j5$9SjIrn|{ymA-VN(1D`Au*KGYpuKdDrEZ-m_p%VK|) zwbbtL_x+Tgrq1N{&E)lxuEp2n>vWj7pS;zexy-=Z@*Fr(*X#I!vfq-!=@>LkgPyjL zuE%?<*+XW5v%JJ)gPxqo?3A+2vefZ>pSQ|LRX5a#^&+-!`}2pV0J)XdZ5Yd zC`@TXUUQVf>XN|d?)LqRuFH$8%FE;Rs?P79$?m?|@`I$plEmxO==YPc%k=sDiLA?L zh@@9`kVj;FywKcVfScj!^O?o#7bGyy=Jt=k>#x!9R(O(BbdZUu#At<`DotvIrND)> z;eoK-YmTjdvfF>I+oiF)ztrWizshKbptsE3hNr}Jq|uP2x}V7Hh_&67#qHPW`L4p$ zfvwhCd6OF;ChPP3r_Jt$smGqm@43s^|NsA+#_Zzj^M9eh#n%0gnXX`z z!o}O|}~-|=OHpOmMzh^4+!aEOMZytLQzZH}t3)9{YK=vjD^ zslU;9nz%MnYKgkzin!!sgrE}{AR;_daHG+1lCWQZoZIX8uEp87*6>Vhh5!Hn00000 z0000000000EC2ui02lxm000R70D%b{NRX9+I>ZPnTnH=xz8J}F47ni#jx#Kp7!pjQ zjb5x+FN~xxp{hg)Tv&u@d=yK}NL8n*b?IUX8ay}ejHpz&Clv`2bfCS1H^2=u9qK47 zFysZ-LRva7csgVVlGR$Zf^CA(XwZm5+X%Lh;|szpGiGKD;=zj-kGBL=d}0)i;0i4r z@9M)LZ!i! z1`R4yXb_H#6or*w2#d07M;p-hq)Fq#n?tsF$P`|xmxWuiNl_53sJ&yyH5xWHdDV!{14JhPb@`D6UgkgaN zk{s}ZDDmWQf-VbX^UNr}_<%$jq5vR-Bzri3ggx%av!6mVfbm2*EYyR;45b*j2R73X zp-Un2Ec5^>7r>yzI>mrf2{=LMa{>|8EJFwg4B{'name'}).":". quotemeta($target->{'target'}) : ""). " -p ".quotemeta($host).($port ? ":".quotemeta($port) : ""). - ($iface ? " -I ".quotemeta($iface) : ""). - " --login"; + ($iface ? " -I ".quotemeta($iface) : ""); + +# Create the session &clean_language(); my $out = &backquote_logged("$cmd 2>&1"); &reset_environment(); -return $? ? $out : undef; +return $out if ($?); + +# Set session username and password +if ($method) { + &clean_language(); + my $out = &backquote_logged("$cmd --op=update --name=node.session.auth.authmethod --value=$method 2>&1"); + &reset_environment(); + return $out if ($?); + } +if ($user) { + &clean_language(); + my $out = &backquote_logged("$cmd --op=update --name=node.session.auth.username --value=".quotemeta($user)." 2>&1"); + &reset_environment(); + return $out if ($?); + + &clean_language(); + my $out = &backquote_logged("$cmd --op=update --name=node.session.auth.password --value=".quotemeta($pass)." 2>&1"); + &reset_environment(); + return $out if ($?); + } + +# Connect the session with --login +&clean_language(); +my $out = &backquote_logged("$cmd --login 2>&1"); +&reset_environment(); +return $out if ($?); + +return undef; } # delete_iscsi_connection(&connection) diff --git a/iscsi-client/lang/en b/iscsi-client/lang/en index ba1b3c5ff..02e287ceb 100644 --- a/iscsi-client/lang/en +++ b/iscsi-client/lang/en @@ -135,6 +135,9 @@ add_etarget=No target $1 found add_dev=Connected as $1 add_used=Already connected add_on=$1 on $2 +add_auth=Login to server +add_auth1=Use default authentication method +add_auth0=Login as $2 with password $3 using method $1 dconns_err=Failed to disconnect connections dconns_enone=None selected