From 0b93291a418bcc2c5eeba45f3b0f78f939403527 Mon Sep 17 00:00:00 2001 From: lissav Date: Fri, 6 Feb 2009 12:52:36 +0000 Subject: [PATCH] change interface to use -l flag and remove -w flag when updating keys git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2707 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/DSHCLI.pm | 45 ++++++++++++++++++++-------------------- xCAT-client/bin/xdsh | 26 +++++++++++++++++------ 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/perl-xCAT/xCAT/DSHCLI.pm b/perl-xCAT/xCAT/DSHCLI.pm index 2457ae466..0f6f422c9 100644 --- a/perl-xCAT/xCAT/DSHCLI.pm +++ b/perl-xCAT/xCAT/DSHCLI.pm @@ -41,6 +41,7 @@ our @dsh_valid_env = ( 'DSH_NODE_RSH', 'DSH_OUTPUT', 'DSH_PATH', 'DSH_SYNTAX', 'DSH_TIMEOUT', 'DSH_REMOTE_PASSWORD', + 'DSH_TO_USERID', 'DSH_FROM_USERID', ); select(STDERR); $| = 1; @@ -3547,7 +3548,7 @@ sub usage_dsh ## usage message my $usagemsg1 = " xdsh -h \n xdsh -q \n xdsh -v \n xdsh [noderange] [group]\n"; - my $usagemsg1a = " xdsh [noderange] -K [-w touserid]\n"; + my $usagemsg1a = " xdsh [noderange] -K [-l logonuserid]\n"; my $usagemsg2 = " [-B bypass ] [-C context] [-c] [-e] [-E environment_file] [--devicetype type_of_device] [-f fanout]\n"; my $usagemsg3 = " [-l user_ID] [-L] "; @@ -3654,7 +3655,6 @@ sub parse_and_run_dsh 's|stream' => \$options{'streaming'}, 't|timeout=i' => \$options{'timeout'}, 'v|verify' => \$options{'verify'}, - 'w|touserid=s' => \$options{'touserid'}, 'z|exit-status' => \$options{'exit-status'}, 'B|bypass' => \$options{'bypass'}, 'C|context=s' => \$options{'context'}, @@ -3785,7 +3785,7 @@ sub parse_and_run_dsh } - if (!($ENV{'DSH_CURRENT_USERID'})) + if (!($ENV{'DSH_FROM_USERID'})) { my $rsp = (); $rsp->{data}->[0] = @@ -3795,33 +3795,34 @@ sub parse_and_run_dsh } - my $current_userid = $ENV{'DSH_CURRENT_USERID'}; - - # if touser id defined - if (defined $options{'touserid'}) + if (!($ENV{'DSH_TO_USERID'})) # id to logon to the node and update the + # keys { + my $rsp = (); + $rsp->{data}->[0] = + "Logon Userid has not been supplied./n Cannot complete the -K command./n"; + xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); + return; - # if current_userid ne touserid then current_userid - # must be root - if ( ($current_userid ne $options{'touserid'}) + } + + + my $current_userid = $ENV{'DSH_FROM_USERID'}; + my $to_userid = $ENV{'DSH_TO_USERID'}; + + + # if current_userid ne touserid then current_userid + # must be root + if ( ($current_userid ne $to_userid) && ($current_userid ne "root")) - { + { my $rsp = (); $rsp->{data}->[0] = - "When touserid:$options{'touserid'} is not the same as the current user:$current_userid. The the command must be run by root id."; + "When touserid:$to_userid is not the same as the current user:$current_userid. The the command must be run by root id."; xCAT::MsgUtils->message("E", $rsp, $::CALLBACK, 1); return; - } + } - # passed security checks so, if set - $ENV{'DSH_FROM_USERID'} = $current_userid; - $ENV{'DSH_TO_USERID'} = $options{'touserid'}; - } - else - { # not defined, so default to current userid - $ENV{'DSH_FROM_USERID'} = $current_userid; - $ENV{'DSH_TO_USERID'} = $current_userid; - } # setting up IB switch ssh, different interface that ssh for # userid on node. Must build special ssh command to be sent diff --git a/xCAT-client/bin/xdsh b/xCAT-client/bin/xdsh index feb902908..3baf6655e 100644 --- a/xCAT-client/bin/xdsh +++ b/xCAT-client/bin/xdsh @@ -155,9 +155,15 @@ if ($ENV{'DSH_REMOTE_PASSWORD'}) { push(@{$cmdref->{env}}, "DSH_REMOTE_PASSWORD=$ENV{'DSH_REMOTE_PASSWORD'}"); } -if ($ENV{'DSH_CURRENT_USERID'}) + +if ($ENV{'DSH_FROM_USERID'}) { - push(@{$cmdref->{env}}, "DSH_CURRENT_USERID=$ENV{'DSH_CURRENT_USERID'}"); + push(@{$cmdref->{env}}, "DSH_FROM_USERID=$ENV{'DSH_FROM_USERID'}"); +} + +if ($ENV{'DSH_TO_USERID'}) +{ + push(@{$cmdref->{env}}, "DSH_TO_USERID=$ENV{'DSH_TO_USERID'}"); } xCAT::Client::submit_request($cmdref, \&xCAT::Client::handle_response); @@ -196,7 +202,6 @@ sub parse_args_xdsh 's|stream' => \$options{'streaming'}, 't|timeout=i' => \$options{'timeout'}, 'v|verify' => \$options{'verify'}, - 'w|touserid=s' => \$options{'touserid'}, 'z|exit-status' => \$options{'exit-status'}, 'B|bypass' => \$options{'bypass'}, 'C|context=s' => \$options{'context'}, @@ -236,10 +241,19 @@ sub parse_args_xdsh # prompt for the password for the current userid on the node my $current_userid = getlogin(); - $ENV{DSH_CURRENT_USERID} = $current_userid; + $ENV{DSH_FROM_USERID} = $current_userid; + # find out who we are going to long on to the node as + # if -l option or current userid + my $to_userid; + if ($options{'user'}) { + $to_userid=$options{'user'}; + } else { + $to_userid=$current_userid; + } + $ENV{DSH_TO_USERID} = $to_userid; my $userpw; my $msg = - "Enter the password for the userid on the node where the ssh keys \nwill be updated:\n"; + "Enter the password for the userid:$to_userid on the node where the ssh keys \nwill be updated:\n"; xCAT::MsgUtils->message("I", $msg); system("stty -echo"); # turn off keyboard chop($userpw = ); @@ -261,7 +275,7 @@ sub parse_args_xdsh { my $version = xCAT::Utils->Version(); $version .= "\n"; - xCAT::MsgUtils->message("I", $version); + xCAT::MsgUtils->message("N", $version); exit 0; } if ($options{'rootimg'})