summaryrefslogtreecommitdiffstats
path: root/bin/jlogin.in
diff options
context:
space:
mode:
Diffstat (limited to 'bin/jlogin.in')
-rw-r--r--[-rwxr-xr-x]bin/jlogin.in50
1 files changed, 31 insertions, 19 deletions
diff --git a/bin/jlogin.in b/bin/jlogin.in
index 0f005d7..31be4f6 100755..100644
--- a/bin/jlogin.in
+++ b/bin/jlogin.in
@@ -1,25 +1,30 @@
-#!@EXPECT_PATH@ --
+#! @EXPECT_PATH@ --
##
+## $Id: jlogin.in,v 1.41 2004/01/11 05:39:15 heas Exp $
##
-## Copyright (C) 1997-2001 by Henry Kilmer, Erik Sherk and Pete Whiting.
+## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
##
-## This software may be freely copied, modified and redistributed without
-## fee for non-commerical purposes provided that this copyright notice is
-## preserved intact on all copies and modified copies.
+## This software may be freely copied, modified and redistributed
+## without fee for non-commerical purposes provided that this license
+## remains intact and unmodified with any RANCID distribution.
##
## There is no warranty or other guarantee of fitness of this software.
-## It is provided solely "as is". The author(s) disclaim(s) all
+## It is provided solely "as is". The author(s) disclaim(s) all
## responsibility and liability with respect to this software's usage
## or its effect upon hardware, computer systems, other software, or
## anything else.
##
+## Except where noted otherwise, rancid was written by and is maintained by
+## Henry Kilmer, John Heasley, Andrew Partan, Pete Whiting, and Austin Schutz.
##
#
-# jlogin - juniper ssh login
+# The login expect scripts were based on Erik Sherk's gwtn, by permission.
#
-## Most options are intuitive for logging into a Cisco router.
-## The default username password is the same as the vty password.
+# jlogin - juniper login
+#
+# Most options are intuitive for logging into a Cisco router.
+# The default username password is the same as the vty password.
#
# Usage line
@@ -49,6 +54,8 @@ if {[ info exists env(CISCO_USER) ] } {
set default_user $env(CISCO_USER)
} elseif {[ info exists env(USER) ]} {
set default_user $env(USER)
+} elseif {[ info exists env(LOGNAME) ]} {
+ set default_user $env(LOGNAME)
} else {
# This uses "id" which I think is portable. At least it has existed
# (without options) on all machines/OSes I've been on recently -
@@ -82,7 +89,7 @@ for {set i 0} {$i < $argc} {incr i} {
if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} {
set E$varname $varvalue
} else {
- send_user "Error: invalid format for -E in $arg\n"
+ send_user "\nError: invalid format for -E in $arg\n"
exit 1
}
# alternate cloginrc file
@@ -249,6 +256,7 @@ proc source_password_file { password_file } {
# Log into the router.
proc login { router user passwd cmethod cyphertype identfile} {
global spawn_id in_proc do_command do_script passphrase prompt
+ global sshcmd
set in_proc 1
# try each of the connection methods in $cmethod until one is successful
@@ -270,13 +278,13 @@ proc login { router user passwd cmethod cyphertype identfile} {
# We use two calls to spawn since spawn does not seem to parse
# spaces correctly.
if {$identfile != ""} {
- if [ catch {spawn ssh -c $cyphertype -x -l $user -i $identfile $router} reason ] {
- send_user "\nError: failed to ssh: $reason\n"
+ if [ catch {spawn $sshcmd -c $cyphertype -x -l $user -i $identfile $router} reason ] {
+ send_user "\nError: failed to $sshcmd: $reason\n"
exit 1
}
} else {
- if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
- send_user "\nError: failed to ssh: $reason\n"
+ if [ catch {spawn $sshcmd -c $cyphertype -x -l $user $router} reason ] {
+ send_user "\nError: failed to $sshcmd: $reason\n"
exit 1
}
}
@@ -438,7 +446,7 @@ foreach router [lrange $argv $i end] {
# command line username
set loginname $username
} else {
- set loginname [find user $router]
+ set loginname [join [find user $router] ""]
if { "$loginname" == "" } { set loginname $default_user }
}
@@ -447,11 +455,11 @@ foreach router [lrange $argv $i end] {
# command line passwd
set passwd $userpasswd
} else {
- set passwd [lindex [find userpassword $router] 0]
+ set passwd [join [lindex [find userpassword $router] 0] ""]
if { "$passwd" == "" } {
- set passwd [lindex [find password $router] 0]
+ set passwd [join [lindex [find password $router] 0] ""]
if { "$passwd" == "" } {
- send_user "Error: no password for $router in $password_file.\n"
+ send_user "\nError: no password for $router in $password_file.\n"
continue
}
}
@@ -460,7 +468,7 @@ foreach router [lrange $argv $i end] {
# figure out identity file to use
set identfile ""
if {[info exists identity]} {
- set identfile [lindex [find identity $router] 0]
+ set identfile [join [lindex [find identity $router] 0] ""]
}
# Figure out ssh cypher type
@@ -476,6 +484,10 @@ 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} }
+
# Login to the router
if {[login $router $loginname $passwd $cmethod $cyphertype $identfile]} {
continue