From 8a3b5596af3d942958aea57287b959a321d51fc7 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Tue, 3 Apr 2012 15:13:54 +0000 Subject: [PATCH] Flesh out the blade clicmds ssh support a bit more and accomodate CMM default password behavior/requirements git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12104 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/perl/xCAT/SSHInteract.pm | 3 +++ xCAT-server/lib/xcat/plugins/blade.pm | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/perl/xCAT/SSHInteract.pm b/xCAT-server/lib/perl/xCAT/SSHInteract.pm index cd605d93f..186573621 100644 --- a/xCAT-server/lib/perl/xCAT/SSHInteract.pm +++ b/xCAT-server/lib/perl/xCAT/SSHInteract.pm @@ -56,6 +56,9 @@ sub new { $self->waitfor("-match" => '/password:/i', -errmode => "return") or die "Unable to reach host ",$self->lastline; $self->print($password); my $nextline = $self->getline(); + if ($nextline eq "\n") { + $nextline = $self->get(); + } if ($nextline =~ /^password:/ or $nextline =~ /Permission denieid, please try again/) { die "Incorrect Password"; } diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 38facc148..5c6abb7c7 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -4029,12 +4029,32 @@ sub clicmds { -password=>$currpass, -host=>$curraddr, -nokeycheck=>$nokeycheck, + -output_record_separator=>"\r", Timeout=>15, Errmode=>'return', Prompt=>'/system> $/' ); my $Rc=1; - unless ($t) { #ssh failed.. fallback to a telnet attempt for older AMMs with telnet disabled by default + if ($t) { #we sshed in, but we may be forced to deal with initial password set + my $output = $t->get(); + if ($output =~ /Enter current password/) { + $t->print($currpass); + $t->waitfor(-match=>"/password:/i"); + $t->print($pass); + $t->waitfor(-match=>"/password:/i"); + $t->print($pass); + my $result=$t->getline(); + chomp($result); + $result =~ s/\s*//; + while ($result eq "") { + $result = $t->getline(); + $result =~ s/\s*//; + } + if ($result =~ /not compliant/) { + return ([1,\@unhandled,"Management module refuses requested password as insufficiently secure, try another password"]); + } + } + } else {#ssh failed.. fallback to a telnet attempt for older AMMs with telnet disabled by default require Net::Telnet; $t = new Net::Telnet( Timeout=>15,