diff options
author | Tar Committer <tar@ocjtech.us> | 2005-07-07 01:14:43 +0000 |
---|---|---|
committer | Tar Committer <tar@ocjtech.us> | 2005-07-07 01:14:43 +0000 |
commit | 96dc4026054df77affedfe50380a661dcdba732a (patch) | |
tree | 0c8de7e68e7f316bf312cecce0b76e1f76b63020 /bin/jlogin.in | |
parent | 4d684aecaacc9a59e7e9c0661934aeba0b16efec (diff) | |
download | rancid-96dc4026054df77affedfe50380a661dcdba732a.tar.gz rancid-96dc4026054df77affedfe50380a661dcdba732a.tar.xz rancid-96dc4026054df77affedfe50380a661dcdba732a.zip |
Imported from rancid-2.3.2a2.tar.gz.rancid-2.3.2a2
Diffstat (limited to 'bin/jlogin.in')
-rw-r--r-- | bin/jlogin.in | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/bin/jlogin.in b/bin/jlogin.in index afa860e..e6c4a01 100644 --- a/bin/jlogin.in +++ b/bin/jlogin.in @@ -1,6 +1,6 @@ #! @EXPECT_PATH@ -- ## -## $Id: jlogin.in,v 1.46 2004/03/11 19:36:25 heas Exp $ +## $Id: jlogin.in,v 1.51 2005/06/14 20:20:43 heas Exp $ ## ## Copyright (C) 1997-2004 by Terrapin Communications, Inc. ## All rights reserved. @@ -48,7 +48,7 @@ set avenable 1 set do_passwd 1 # Find the user in the ENV, or use the unix userid. -if {[ info exists env(CISCO_USER) ] } { +if {[ info exists env(CISCO_USER) ]} { set default_user $env(CISCO_USER) } elseif {[ info exists env(USER) ]} { set default_user $env(USER) @@ -252,6 +252,7 @@ proc source_password_file { password_file } { } # Log into the router. +# returns: 0 on success, 1 on failure proc login { router user passwd cmethod cyphertype identfile} { global spawn_id in_proc do_command do_script passphrase prompt global sshcmd @@ -260,6 +261,7 @@ proc login { router user passwd cmethod cyphertype identfile} { # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { + incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog command suffix port if {"$port" == ""} { @@ -269,7 +271,7 @@ proc login { router user passwd cmethod cyphertype identfile} { } if { $retval } { send_user "\nError: telnet failed: $reason\n" - exit 1 + return 1 } } elseif ![string compare $prog "ssh"] { # ssh to the router & try to login with or without an identfile. @@ -278,24 +280,24 @@ proc login { router user passwd cmethod cyphertype identfile} { if {$identfile != ""} { if [ catch {spawn $sshcmd -c $cyphertype -x -l $user -i $identfile $router} reason ] { send_user "\nError: failed to $sshcmd: $reason\n" - exit 1 + return 1 } } else { if [ catch {spawn $sshcmd -c $cyphertype -x -l $user $router} reason ] { send_user "\nError: failed to $sshcmd: $reason\n" - exit 1 + return 1 } } } elseif ![string compare $prog "rsh"] { - if [ catch {spawn rsh -l $user $router} reason ] { - send_user "\nError: rsh failed: $reason\n" - exit 1 + send_error "\nError: unsupported method: rsh\n" + if { $progs == 0 } { + return 1 } + continue } else { - puts "\nError: unknown connection method: $prog" + send_user "\nError: unknown connection method: $prog\n" return 1 } - incr progs -1 sleep 0.3 # This helps cleanup each expect clause. @@ -493,9 +495,9 @@ foreach router [lrange $argv $i end] { set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } - # Figure out the SSH executable name - set sshcmd [find sshcmd $router] - if { "$sshcmd" == "" } { set sshcmd {ssh} } + # Figure out the SSH executable name + set sshcmd [find sshcmd $router] + if { "$sshcmd" == "" } { set sshcmd {ssh} } # Login to the router if {[login $router $loginname $passwd $cmethod $cyphertype $identfile]} { |