summaryrefslogtreecommitdiffstats
path: root/bin/nslogin.in
diff options
context:
space:
mode:
Diffstat (limited to 'bin/nslogin.in')
-rw-r--r--bin/nslogin.in68
1 files changed, 34 insertions, 34 deletions
diff --git a/bin/nslogin.in b/bin/nslogin.in
index 0dae833..b5cee90 100644
--- a/bin/nslogin.in
+++ b/bin/nslogin.in
@@ -3,7 +3,7 @@
## $Id$
##
## @PACKAGE@ @VERSION@
-## Copyright (c) 1997-2008 by Terrapin Communications, Inc.
+## Copyright (c) 1997-2009 by Terrapin Communications, Inc.
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
@@ -55,7 +55,7 @@
#
# Usage line
-set usage "Usage: $argv0 \[-dV\] \[-autoenable\] \[-noenable\] \[-c command\] \
+set usage "Usage: $argv0 \[-dSV\] \[-autoenable\] \[-noenable\] \[-c command\] \
\[-Evar=x\] \[-e enable-password\] \[-f cloginrc-file\] \[-p user-password\] \
\[-s script-file\] \[-t timeout\] \[-u username\] \
\[-v vty-password\] \[-w enable-username\] \[-x command-file\] \
@@ -78,6 +78,8 @@ set avautoenable 0
# tracks if we receive them on the command line.
set do_passwd 1
set do_enapasswd 1
+# Save config, if prompted
+set do_saveconfig 0
# Find the user in the ENV, or use the unix userid.
if {[ info exists env(CISCO_USER) ]} {
@@ -112,38 +114,33 @@ for {set i 0} {$i < $argc} {incr i} {
-d* {
exp_internal 1
# Username
- } -u* -
- -U* {
+ } -u* {
if {! [ regexp .\[uU\](.+) $arg ignore user]} {
incr i
set username [ lindex $argv $i ]
}
# VTY Password
- } -p* -
- -P* {
+ } -p* {
if {! [ regexp .\[pP\](.+) $arg ignore userpasswd]} {
incr i
set userpasswd [ lindex $argv $i ]
}
set do_passwd 0
# VTY Password
- } -v* -
- -v* {
+ } -v* {
if {! [ regexp .\[vV\](.+) $arg ignore passwd]} {
incr i
set passwd [ lindex $argv $i ]
}
set do_passwd 0
# Enable Username
- } -w* -
- -W* {
+ } -w* {
if {! [ regexp .\[wW\](.+) $arg ignore enauser]} {
incr i
set enausername [ lindex $argv $i ]
}
# Environment variable to pass to -s scripts
- } -E*
- {
+ } -E* {
if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} {
set E$varname $varvalue
} else {
@@ -151,24 +148,21 @@ for {set i 0} {$i < $argc} {incr i} {
exit 1
}
# Enable Password
- } -e*
- {
+ } -e* {
if {! [ regexp .\[e\](.+) $arg ignore enapasswd]} {
incr i
set enapasswd [ lindex $argv $i ]
}
set do_enapasswd 0
# Command to run.
- } -c* -
- -C* {
+ } -c* {
if {! [ regexp .\[cC\](.+) $arg ignore command]} {
incr i
set command [ lindex $argv $i ]
}
set do_command 1
# Expect script to run.
- } -s* -
- -S* {
+ } -s* {
if {! [ regexp .\[sS\](.+) $arg ignore sfile]} {
incr i
set sfile [ lindex $argv $i ]
@@ -178,30 +172,29 @@ for {set i 0} {$i < $argc} {incr i} {
exit 1
}
set do_script 1
+ # save config on exit
+ } -S* {
+ set do_saveconfig 1
# 'ssh -c' cypher type
- } -y* -
- -Y* {
+ } -y* {
if {! [ regexp .\[eE\](.+) $arg ignore cypher]} {
incr i
set cypher [ lindex $argv $i ]
}
# alternate cloginrc file
- } -f* -
- -F* {
+ } -f* {
if {! [ regexp .\[fF\](.+) $arg ignore password_file]} {
incr i
set password_file [ lindex $argv $i ]
}
# Timeout
- } -t* -
- -T* {
+ } -t* {
if {! [ regexp .\[tT\](.+) $arg ignore timeout]} {
incr i
set timeout [ lindex $argv $i ]
}
# Command file
- } -x* -
- -X {
+ } -x* {
if {! [ regexp .\[xX\](.+) $arg ignore cmd_file]} {
incr i
set cmd_file [ lindex $argv $i ]
@@ -214,6 +207,10 @@ for {set i 0} {$i < $argc} {incr i} {
close $cmd_fd
set command [join [split $cmd_text \n] \;]
set do_command 1
+ # Version string
+ } -V* {
+ send_user "@PACKAGE@ @VERSION@\n"
+ exit 0
# Do we enable?
} -noenable {
set avenable 0
@@ -398,15 +395,18 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
-re "(Host key not found |The authenticity of host .* be established).*\(yes\/no\)\?" {
send "yes\r"
send_user "\nHost $router added to the list of known hosts.\n"
- exp_continue }
- -re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
+ exp_continue
+ }
+ -re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n"
- return 1 }
- -re "Offending key for .* \(yes\/no\)\?" {
+ return 1
+ }
+ -re "Offending key for .* \(yes\/no\)\?" {
send "no\r"
send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n"
- return 1 }
+ return 1
+ }
-re "(denied|Sorry)" {
send_user "\nError: Check your passwd for $router\n"
catch {close}; catch {wait}; return 1
@@ -495,11 +495,11 @@ proc run_commands { prompt command } {
send "n\r"
exp_continue
}
- "\n" { exp_continue }
- timeout { catch {close}; catch {wait};
+ "\n" { exp_continue }
+ timeout { catch {close}; catch {wait};
return 0
}
- eof { return 0 }
+ eof { return 0 }
}
set in_proc 0
}