diff options
author | unknown <unknown@unknown> | 2009-09-01 13:24:17 +0000 |
---|---|---|
committer | unknown <unknown@unknown> | 2009-09-01 13:24:17 +0000 |
commit | 1e2a739ede68f904c84ea693362fdd4445c4fc16 (patch) | |
tree | c812acb3606017e6a4334a0b6ce24f769c73c5eb /bin | |
parent | 09f0f026fd4931b90016d0090778983da01c294a (diff) | |
download | rancid-1e2a739ede68f904c84ea693362fdd4445c4fc16.tar.gz rancid-1e2a739ede68f904c84ea693362fdd4445c4fc16.tar.xz rancid-1e2a739ede68f904c84ea693362fdd4445c4fc16.zip |
Imported from rancid-2.3.2a10.tar.gz.rancid-2.3.2a10
Diffstat (limited to 'bin')
-rw-r--r-- | bin/Makefile.am | 6 | ||||
-rw-r--r-- | bin/Makefile.in | 14 | ||||
-rw-r--r-- | bin/alogin.in | 60 | ||||
-rw-r--r-- | bin/avologin.in | 97 | ||||
-rw-r--r-- | bin/avorancid.in | 45 | ||||
-rw-r--r-- | bin/blogin.in | 55 | ||||
-rw-r--r-- | bin/clogin.in | 92 | ||||
-rw-r--r-- | bin/control_rancid.in | 2 | ||||
-rw-r--r-- | bin/elogin.in | 42 | ||||
-rw-r--r-- | bin/flogin.in | 54 | ||||
-rw-r--r-- | bin/hlogin.in | 72 | ||||
-rw-r--r-- | bin/hpuifilter.c | 19 | ||||
-rw-r--r-- | bin/htlogin.in | 42 | ||||
-rw-r--r-- | bin/jerancid.in | 13 | ||||
-rw-r--r-- | bin/jlogin.in | 40 | ||||
-rw-r--r-- | bin/mrvlogin.in | 51 | ||||
-rw-r--r-- | bin/nlogin.in | 172 | ||||
-rw-r--r-- | bin/nslogin.in | 68 | ||||
-rw-r--r-- | bin/rancid-fe.in | 1 | ||||
-rw-r--r-- | bin/rancid.in | 14 | ||||
-rw-r--r-- | bin/rivlogin.in | 441 | ||||
-rwxr-xr-x | bin/srancid.in | 13 | ||||
-rw-r--r-- | bin/tlogin.in | 101 | ||||
-rw-r--r-- | bin/tntlogin.in | 113 | ||||
-rw-r--r-- | bin/trancid.in | 53 |
25 files changed, 872 insertions, 808 deletions
diff --git a/bin/Makefile.am b/bin/Makefile.am index 3ad2a93..a2f0c5c 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -50,8 +50,8 @@ AUTOMAKE_OPTIONS=foreign bin_PROGRAMS = hpuifilter bin_SCRIPTS = agmrancid alogin arancid avologin avorancid blogin brancid \ - cat5rancid clogin control_rancid cssrancid elogin erancid f10rancid \ - flogin fnrancid francid hlogin hrancid htlogin htrancid \ + cat5rancid clogin control_rancid cssrancid elogin erancid f5rancid \ + f10rancid flogin fnrancid francid hlogin hrancid htlogin htrancid \ jerancid jlogin jrancid mrancid mrvlogin mrvrancid nlogin nrancid \ nslogin nsrancid nxrancid par prancid rancid-fe rancid rivlogin \ rivrancid rrancid srancid tlogin tntlogin tntrancid trancid xrancid \ @@ -125,3 +125,5 @@ rancid-run: Makefile $(srcdir)/rancid-run.in $(auto_edit) $(srcdir)/rancid-run.in >rancid-run.tmp; \ chmod +x rancid-run.tmp; \ mv rancid-run.tmp rancid-run + +$(bin_PROGRAMS) $(bin_SCRIPTS): ../include/version.h diff --git a/bin/Makefile.in b/bin/Makefile.in index 51a47bf..69784fb 100644 --- a/bin/Makefile.in +++ b/bin/Makefile.in @@ -219,12 +219,12 @@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign bin_SCRIPTS = agmrancid alogin arancid avologin avorancid blogin \ brancid cat5rancid clogin control_rancid cssrancid elogin \ - erancid f10rancid flogin fnrancid francid hlogin hrancid \ - htlogin htrancid jerancid jlogin jrancid mrancid mrvlogin \ - mrvrancid nlogin nrancid nslogin nsrancid nxrancid par prancid \ - rancid-fe rancid rivlogin rivrancid rrancid srancid tlogin \ - tntlogin tntrancid trancid xrancid zrancid lg.cgi lgform.cgi \ - rancid-cvs rancid-run + erancid f5rancid f10rancid flogin fnrancid francid hlogin \ + hrancid htlogin htrancid jerancid jlogin jrancid mrancid \ + mrvlogin mrvrancid nlogin nrancid nslogin nsrancid nxrancid \ + par prancid rancid-fe rancid rivlogin rivrancid rrancid \ + srancid tlogin tntlogin tntrancid trancid xrancid zrancid \ + lg.cgi lgform.cgi rancid-cvs rancid-run EXTRA_DIST = lg.cgi.in lgform.cgi.in rancid-cvs.in rancid-run.in #dist_bin_SCRIPTS= $(bin_SCRIPTS:%=%.in) CLEANFILES = lg.cgi lgform.cgi rancid-cvs rancid-run @@ -656,6 +656,8 @@ rancid-run: Makefile $(srcdir)/rancid-run.in $(auto_edit) $(srcdir)/rancid-run.in >rancid-run.tmp; \ chmod +x rancid-run.tmp; \ mv rancid-run.tmp rancid-run + +$(bin_PROGRAMS) $(bin_SCRIPTS): ../include/version.h # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/bin/alogin.in b/bin/alogin.in index a17bd2a..0fec1a7 100644 --- a/bin/alogin.in +++ b/bin/alogin.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 @@ -49,11 +49,10 @@ # # Usage line -set usage "Usage: $argv0 \[-dV\] \[-c command\] \ -\[-Evar=x\] \[-f cloginrc-file\] \ -\[-s script-file\] \[-t timeout\] \[-u username\] \ -\[-v vty-password\] \[-x command-file\] \ -\[-y ssh_cypher_type\] router \[router...\]\n" +set usage "Usage: $argv0 \[-dSV\] \[-c command\] \[-Evar=x\] \ +\[-f cloginrc-file\] \[-s script-file\] \[-t timeout\] \[-u username\] \ +\[-v vty-password\] \[-x command-file\] \[-y ssh_cypher_type\] router \ +\[router...\]\n" # env(CLOGIN) may contain: # x == do not set xterm banner or name @@ -71,6 +70,8 @@ set avautoenable 0 # The default is to look in the password file to find the passwords. This # tracks if we receive them on the command line. set do_passwd 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) ]} { @@ -105,8 +106,7 @@ 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 ] @@ -123,12 +123,10 @@ for {set i 0} {$i < $argc} {incr i} { send_user "@PACKAGE@ @VERSION@\n" exit 0 # Enable Username - } -w* - - -W* { + } -w* { # ignore -w # Environment variable to pass to -s scripts - } -E* - { + } -E* { if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { incr i set E$varname $varvalue @@ -137,20 +135,17 @@ for {set i 0} {$i < $argc} {incr i} { exit 1 } # Enable Password - } -e* - { + } -e* { # ignore -e # 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 ] @@ -160,30 +155,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 ] @@ -360,7 +354,8 @@ proc login { router user userpswd passwd prompt cmethod cyphertype } { sleep 0.3 expect eof send_user "\nError: Connection Refused\n"; wait; return 1 - } eof { send_user "\nError: Couldn't login\n"; wait; return 1 + } + eof { send_user "\nError: Couldn't login\n"; wait; return 1 } "Unknown host\r\n" { expect eof send_user "\nError: Unknown host\n"; wait; return 1 @@ -375,15 +370,16 @@ proc login { router user userpswd passwd prompt cmethod cyphertype } { send "yes\r" send_user "\nHost $router added to the list of known hosts.\n" exp_continue } - -re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" { + -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 "$u_prompt" { send -- "$user\r" set uprompt_seen 1 diff --git a/bin/avologin.in b/bin/avologin.in index b51f841..1ffbddd 100644 --- a/bin/avologin.in +++ b/bin/avologin.in @@ -3,22 +3,42 @@ ## $Id$ ## ## @PACKAGE@ @VERSION@ -## Copyright (C) 1997-2008 by Terrapin Communications, Inc. +## Copyright (c) 1997-2009 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 license -## remains intact and unmodified with any RANCID distribution. +## This code is derived from software contributed to and maintained by +## Terrapin Communications, Inc. by Henry Kilmer, John Heasley, Andrew Partan, +## Pete Whiting, Austin Schutz, and Andrew Fort. ## -## There is no warranty or other guarantee of fitness of this software. -## 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. +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## 1. Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## 2. Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## 3. All advertising materials mentioning features or use of this software +## must display the following acknowledgement: +## This product includes software developed by Terrapin Communications, +## Inc. and its contributors for RANCID. +## 4. Neither the name of Terrapin Communications, Inc. nor the names of its +## contributors may be used to endorse or promote products derived from +## this software without specific prior written permission. +## 5. It is requested that non-binding fixes and modifications be contributed +## back to Terrapin Communications, Inc. ## +## THIS SOFTWARE IS PROVIDED BY Terrapin Communications, INC. AND CONTRIBUTORS +## ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COMPANY OR CONTRIBUTORS +## BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +## POSSIBILITY OF SUCH DAMAGE. # # The login expect scripts were based on Erik Sherk's gwtn, by permission. # @@ -33,7 +53,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\] \ @@ -56,6 +76,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)]} { @@ -90,23 +112,20 @@ 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] @@ -117,15 +136,13 @@ for {set i 0} {$i < $argc} {incr i} { send_user "@PACKAGE@ @VERSION@\n" exit 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 { @@ -133,24 +150,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] @@ -160,30 +174,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] @@ -395,14 +408,16 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } { send "yes\r" send_user "\nHost $router added to the list of known hosts.\n" exp_continue } - -re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" { + -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 diff --git a/bin/avorancid.in b/bin/avorancid.in index 33b77d3..fa23ed8 100644 --- a/bin/avorancid.in +++ b/bin/avorancid.in @@ -3,22 +3,43 @@ ## $Id$ ## ## @PACKAGE@ @VERSION@ -## Copyright (C) 1997-2008 by Terrapin Communications, Inc. +## Copyright (c) 1997-2008 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 license -## remains intact and unmodified with any RANCID distribution. +## This code is derived from software contributed to and maintained by +## Terrapin Communications, Inc. by Henry Kilmer, John Heasley, Andrew Partan, +## Pete Whiting, Austin Schutz, and Andrew Fort. ## -## There is no warranty or other guarantee of fitness of this software. -## 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. +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## 1. Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## 2. Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## 3. All advertising materials mentioning features or use of this software +## must display the following acknowledgement: +## This product includes software developed by Terrapin Communications, +## Inc. and its contributors for RANCID. +## 4. Neither the name of Terrapin Communications, Inc. nor the names of its +## contributors may be used to endorse or promote products derived from +## this software without specific prior written permission. +## 5. It is requested that non-binding fixes and modifications be contributed +## back to Terrapin Communications, Inc. ## +## THIS SOFTWARE IS PROVIDED BY Terrapin Communications, INC. AND CONTRIBUTORS +## ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COMPANY OR CONTRIBUTORS +## BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +## POSSIBILITY OF SUCH DAMAGE. + # # RANCID - Really Awesome New Cisco confIg Differ # diff --git a/bin/blogin.in b/bin/blogin.in index 27b89b2..41878a8 100644 --- a/bin/blogin.in +++ b/bin/blogin.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 @@ -52,7 +52,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\] \ @@ -75,6 +75,8 @@ set avautoenable 0 # tracks if we receive them on the command line. set do_passwd 1 set do_enapasswd 0 +# 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) ]} { @@ -109,15 +111,13 @@ 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 ] @@ -135,15 +135,13 @@ for {set i 0} {$i < $argc} {incr i} { send_user "@PACKAGE@ @VERSION@\n" exit 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 +149,21 @@ for {set i 0} {$i < $argc} {incr i} { exit 1 } # Enable Password - } -e* - { + } -e* { if {! [ regexp .\[eE\](.+) $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 +173,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 ] @@ -382,7 +376,8 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } { if !$progs { send_user "\nError: Connection Refused ($prog)\n"; return 1 } - } eof { send_user "\nError: Couldn't login\n"; wait; return 1 + } + eof { send_user "\nError: Couldn't login\n"; wait; return 1 } -nocase "unknown host\r" { catch {close}; catch {wait}; send_user "\nError: Unknown host\n"; wait; return 1 @@ -397,14 +392,16 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } { send "yes\r" send_user "\nHost $router added to the list of known hosts.\n" exp_continue } - -re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" { + -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 "$u_prompt" { send -- "$user\r" expect { eof { send_user "\nError: Couldn't login\n"; wait; return 1 } diff --git a/bin/clogin.in b/bin/clogin.in index b3e4c81..e8c7fb3 100644 --- a/bin/clogin.in +++ b/bin/clogin.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 @@ -53,7 +53,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\] \ @@ -76,6 +76,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 # set send_human {.4 .4 .7 .3 5} @@ -112,15 +114,13 @@ 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 ] @@ -138,15 +138,13 @@ for {set i 0} {$i < $argc} {incr i} { send_user "@PACKAGE@ @VERSION@\n" exit 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 { @@ -154,24 +152,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 ] @@ -181,30 +176,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 ] @@ -342,7 +336,6 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } { regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port if {"$port" == ""} { set retval [ catch {spawn $sshcmd -c $cyphertype -x -l $user $router} reason ] - } else { set retval [ catch {spawn $sshcmd -c $cyphertype -x -l $user -p $port $router} reason ] } @@ -490,14 +483,15 @@ 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" catch {close}; catch {wait}; return 1 } - -re "Offending key for .* \(yes\/no\)\?" { + -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" catch {close}; catch {wait}; @@ -563,8 +557,8 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } { # Enable proc do_enable { enauser enapasswd } { - global prompt in_proc - global u_prompt e_prompt + global do_saveconfig in_proc + global prompt u_prompt e_prompt set in_proc 1 send "enable\r" @@ -572,7 +566,7 @@ proc do_enable { enauser enapasswd } { -re "$u_prompt" { send -- "$enauser\r"; exp_continue} -re "$e_prompt" { send -- "$enapasswd\r"; exp_continue} "#" { set prompt "#" } - "(enable)" { set prompt "> (enable) " } + "(enable)" { set prompt "> \\(enable\\) " } -re "(denied|Sorry|Incorrect)" { # % Access denied - from local auth and poss. others send_user "\nError: Check your Enable passwd\n"; @@ -611,17 +605,15 @@ proc run_commands { prompt command } { } else { send "terminal length 0\r" } - # escape any parens in the prompt, such as "(enable)" - regsub -all {[)(]} $prompt {\\&} reprompt # match cisco config mode prompts too, such as router(config-if)#, # but catalyst does not change in this fashion. - regsub -all {^(.{1,11}).*([#>])$} $reprompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt + regsub -all {^(.{1,11}).*([#>])$} $prompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt expect { -re $reprompt {} -re "\[\n\r]+" { exp_continue } } } else { - regsub -all "\[)(]" $prompt {\\&} reprompt + set reprompt $prompt } # this is the only way i see to get rid of more prompts in o/p..grrrrr @@ -681,20 +673,36 @@ proc run_commands { prompt command } { exp_continue; } "The system has unsaved changes" { # Force10 SFTOS - send "n\r" + if {$do_saveconfig} { + catch {send "y\r"} + } else { + catch {send "n\r"} + } exp_continue } "Would you like to save them now" { # Force10 - send "n\r" + if {$do_saveconfig} { + catch {send "y\r"} + } else { + catch {send "n\r"} + } exp_continue } -re "(Profile|Configuration) changes have occurred.*" { # Cisco CSS - send "n\r" + if {$do_saveconfig} { + catch {send "y\r"} + } else { + catch {send "n\r"} + } exp_continue } "Do you wish to save your configuration changes" { - send "n\r" + if {$do_saveconfig} { + catch {send "y\r"} + } else { + catch {send "n\r"} + } exp_continue } -re "\[\n\r]+" { exp_continue } @@ -851,13 +859,10 @@ foreach router [lrange $argv $i end] { set junk $expect_out(1,string) regsub -all "^\\\* " $expect_out(1,string) {} junk set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)"; + regsub -all "\[\]\[\(\)]" $prompt {\\&} prompt; set platform "extreme" } -re "^.+$prompt" { set junk $expect_out(0,string); - regsub -all "\[\]\[]" $junk {\\&} prompt; - } - -re "^.+> \\\(enable\\\)" { - set junk $expect_out(0,string); regsub -all "\[\]\[\(\)]" $junk {\\&} prompt; } } @@ -872,6 +877,7 @@ foreach router [lrange $argv $i end] { # command is "set length 0"; otherwise its "terminal length 0". if [ regexp -- ".*> .*enable" "$prompt" ] { send "set length 0\r" + expect -re $prompt {} send "set logging session disable\r" } else { send "terminal length 0\r" diff --git a/bin/control_rancid.in b/bin/control_rancid.in index 2e39068..d1fe450 100644 --- a/bin/control_rancid.in +++ b/bin/control_rancid.in @@ -433,7 +433,7 @@ do then rm -f $router.new else - lines=`awk '{if (/^([-*!;#]|\/\*)/) { next; } lines++; \ + lines=`awk '{if ($0 ~ /^([-*!;#]|\/\*)/) { next; } lines++; \ if (lines > 10) { print "1"; exit;}} \ END { if (lines < 10) {print "0";}}' $router.new` diff --git a/bin/elogin.in b/bin/elogin.in index e13f206..7e7f4fc 100644 --- a/bin/elogin.in +++ b/bin/elogin.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 @@ -46,7 +46,7 @@ # # Usage line -set usage "Usage: $argv0 \[-dV\] \[-noenable\] \[-c command\] \ +set usage "Usage: $argv0 \[-dSV\] \[-noenable\] \[-c command\] \ \[-Evar=x\] \[-f cloginrc-file\] \[-p user-password\] \ \[-s script-file\] \[-t timeout\] \[-u username\] \ \[-v vty-password\] \[-w enable-username\] \[-x command-file\] \ @@ -68,6 +68,8 @@ set avautoenable 0 # The default is to look in the password file to find the passwords. This # tracks if we receive them on the command line. set do_passwd 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) ]} { @@ -102,15 +104,13 @@ 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 ] @@ -128,12 +128,10 @@ for {set i 0} {$i < $argc} {incr i} { send_user "@PACKAGE@ @VERSION@\n" exit 0 # Enable Username - } -w* - - -W* { + } -w* { # ignore -w # Environment variable to pass to -s scripts - } -E* - { + } -E* { if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { set E$varname $varvalue } else { @@ -141,20 +139,17 @@ for {set i 0} {$i < $argc} {incr i} { exit 1 } # Enable Password - } -e* - { + } -e* { # ignore -e # 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 ] @@ -164,30 +159,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 ] diff --git a/bin/flogin.in b/bin/flogin.in index 483a06e..98c2573 100644 --- a/bin/flogin.in +++ b/bin/flogin.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 @@ -56,7 +56,7 @@ # # Usage line -set usage "Usage: $argv0 \[-dV\] \[-autoenable\] \[-noenable\] \ +set usage "Usage: $argv0 \[-dSV\] \[-autoenable\] \[-noenable\] \ \[-c command\] \[-Evar=x\] \[-e enable-password\] \[-p user-password\] \ \[-f cloginrc-file\] \[-s script-file\] \[-t timeout\] \[-u user\] \ \[-v vty-password\] \[-w enable-username\]\[-y ssh_cypher_type\] \ @@ -79,6 +79,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) ]} { @@ -113,15 +115,13 @@ 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 ] @@ -139,15 +139,13 @@ for {set i 0} {$i < $argc} {incr i} { send_user "@PACKAGE@ @VERSION@\n" exit 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 { @@ -155,24 +153,21 @@ for {set i 0} {$i < $argc} {incr i} { exit 1 } # Enable Password - } -e* - { + } -e* { if {! [ regexp .\[eE\](.+) $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 ] @@ -182,26 +177,25 @@ for {set i 0} {$i < $argc} {incr i} { exit 1 } set do_script 1 - # cypher type - } -y* - - -Y* { + # save config on exit + } -S* { + set do_saveconfig 1 + # cypher type + } -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 ] } - } -t* - - -T* { + } -t* { incr i set timeout [ lindex $argv $i ] - } -x* - - -X { + } -x* { if {! [ regexp .\[xX\](.+) $arg ignore cmd_file]} { incr i set cmd_file [ lindex $argv $i ] @@ -419,14 +413,16 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } { send "yes\r" send_user "\nHost $router added to the list of known hosts.\n" exp_continue } - -re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" { + -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 diff --git a/bin/hlogin.in b/bin/hlogin.in index e372fe0..f1cbf51 100644 --- a/bin/hlogin.in +++ b/bin/hlogin.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 @@ -53,7 +53,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 do_passwd 1 set do_enapasswd 1 # attempt at platform switching. set platform "" +# Save config, if prompted +set do_saveconfig 0 # set send_human {.2 .1 .4 .2 1} @@ -114,15 +116,13 @@ 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 ] @@ -140,15 +140,13 @@ for {set i 0} {$i < $argc} {incr i} { send_user "@PACKAGE@ @VERSION@\n" exit 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 { @@ -156,24 +154,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 ] @@ -183,30 +178,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 ] @@ -413,14 +407,16 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } { send "yes\r" send_user "\nHost $router added to the list of known hosts.\n" exp_continue } - -re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" { + -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 + } eof { send_user "\nError: Couldn't login\n"; wait; return 1 } -nocase "unknown host\r" { catch {close}; catch {wait}; @@ -500,7 +496,7 @@ proc do_enable { enauser enapasswd } { # Run commands given on the command line. proc run_commands { prompt command } { - global in_proc platform + global do_saveconfig in_proc platform set in_proc 1 # Turn off the pager and escape regex meta characters in the $prompt @@ -522,8 +518,7 @@ proc run_commands { prompt command } { send -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "^\[^\n\r *]*$reprompt" { catch {send_user -- "$expect_out(buffer)"} } - -re "^\[^\n\r]*$reprompt." { catch {send_user -- "$expect_out(buffer)"} - exp_continue } + -re "^\[^\n\r]*$reprompt " { catch {send_user -- "$expect_out(buffer)"} } -re "\[\n\r]+" { catch {send_user -- "$expect_out(buffer)"} exp_continue } -re "\[^\r\n]*Press <SPACE> to cont\[^\r\n]*" { @@ -558,11 +553,19 @@ proc run_commands { prompt command } { send -h "exit\r" expect { "Do you want to save current configuration" { - catch {send "n\r"} + if {$do_saveconfig} { + catch {send "y\r"} + } else { + catch {send "n\r"} + } exp_continue } - "Do you wish to save " { - catch {send "n\r"} + "Do you wish to save " { + if {$do_saveconfig} { + catch {send "y\r"} + } else { + catch {send "n\r"} + } exp_continue } "Do you want to log out" { @@ -701,6 +704,7 @@ foreach router [lrange $argv $i end] { if { "$sshcmd" == "" } { set sshcmd {ssh} } # Adjust our path to find hpuifilter + set hpf_path "" regexp {(.*)/[^/]+} $argv0 junk hpf_path if { "$hpf_path" != "" && "$hpf_path" != "." } { append env(PATH) ":$hpf_path" diff --git a/bin/hpuifilter.c b/bin/hpuifilter.c index ab437f7..69569d8 100644 --- a/bin/hpuifilter.c +++ b/bin/hpuifilter.c @@ -141,7 +141,7 @@ main(int argc, char **argv, char **ev) hbuf[BUFSZ], /* hlogin buffer */ ptyname[FILENAME_MAX + 1], tbuf[BUFSZ], /* telnet/ssh buffer */ - tbufstr[4] = {ESC, '\r', '\n', '\0'}; + tbufstr[5] = {ESC, '\x07', '\r', '\n', '\0'}; int bytes, /* bytes read/written */ devnull, rval = EX_OK, @@ -533,7 +533,8 @@ int filter(char *buf, int len) { static regmatch_t pmatch[1]; -#define N_REG 14 /* number of regexes in reg[][] */ +#define N_REG 15 /* number of regexes in reg[][] */ +#define N_CRs 2 /* number of CR replacements */ static regex_t preg[N_REG]; static char reg[N_REG][50] = { /* vt100/220 escape codes */ "\x1B""7\x1B\\[1;24r\x1B""8", /* ds */ @@ -551,21 +552,23 @@ filter(char *buf, int len) "\x1B\\[\\?25l", /* vi */ "\x1B\\[K", /* ce */ "\x1B\\[7m", /* mr - ansi */ + "\x07", /* bell */ /* replace these with CR */ "\x1B\\[0m", /* me */ "\x1B""E", }; - char ebuf[256]; + char bufstr[3] = {ESC, '\x07', '\0'}, + ebuf[256]; size_t nmatch = 1; int err, x; static int init = 0; - if (index(buf, ESC) == 0 || len == 0) + if (len == 0 || (err = strcspn(buf, bufstr)) >= len) return(len); - for (x = 0; x < N_REG - 2; x++) { + for (x = 0; x < N_REG - N_CRs; x++) { if (! init) { if ((err = regcomp(&preg[x], reg[x], REG_EXTENDED))) { regerror(err, &preg[x], ebuf, 256); @@ -587,9 +590,9 @@ filter(char *buf, int len) } } - /* no the CR NL replacements */ + /* now the CR NL replacements */ if (! init++) { - for (x = N_REG - 2; x < N_REG; x++) + for (x = N_REG - N_CRs; x < N_REG; x++) if ((err = regcomp(&preg[x], reg[x], REG_EXTENDED))) { regerror(err, &preg[x], ebuf, 256); fprintf(stderr, "%s: regex compile failed: %s\n", progname, @@ -597,7 +600,7 @@ filter(char *buf, int len) abort(); } } - for (x = N_REG - 2; x < N_REG; x++) { + for (x = N_REG - N_CRs; x < N_REG; x++) { if ((err = regexec(&preg[x], buf, nmatch, pmatch, 0))) { if (err != REG_NOMATCH) { regerror(err, &preg[x], ebuf, 256); diff --git a/bin/htlogin.in b/bin/htlogin.in index fbe8b1f..88533c9 100644 --- a/bin/htlogin.in +++ b/bin/htlogin.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 @@ -48,7 +48,7 @@ # # Usage line -set usage "Usage: $argv0 \[-dV\] \[-noenable\] \[-c command\] \ +set usage "Usage: $argv0 \[-dSV\] \[-noenable\] \[-c command\] \ \[-Evar=x\] \[-f cloginrc-file\] \[-p user-password\] \ \[-s script-file\] \[-t timeout\] \[-u username\] \ \[-v vty-password\] \[-w enable-username\] \[-x command-file\] \ @@ -70,6 +70,8 @@ set avautoenable 0 # The default is to look in the password file to find the passwords. This # tracks if we receive them on the command line. set do_passwd 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) ]} { @@ -104,15 +106,13 @@ 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 ] @@ -130,12 +130,10 @@ for {set i 0} {$i < $argc} {incr i} { send_user "@PACKAGE@ @VERSION@\n" exit 0 # Enable Username - } -w* - - -W* { + } -w* { # ignore -w # Environment variable to pass to -s scripts - } -E* - { + } -E* { if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { set E$varname $varvalue } else { @@ -143,20 +141,17 @@ for {set i 0} {$i < $argc} {incr i} { exit 1 } # Enable Password - } -e* - { + } -e* { # ignore -e # 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 ] @@ -166,30 +161,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 ] diff --git a/bin/jerancid.in b/bin/jerancid.in index 69d4697..86e08d8 100644 --- a/bin/jerancid.in +++ b/bin/jerancid.in @@ -293,6 +293,19 @@ sub DirSlotN { # fail if the RP is amid the auto-sync process return(-1) if (/active\/standby/i && /not sync/); + if (/(\S+:\s+)(\d+)(\s+)(\d+)(\s+)(\d+)/) { + my($totlen) = length($2) - 1; + my($tot) = $2 / (1024 * 1024); + my($freelen) = length($4) - 1; + my($free) = $4 / (1024 * 1024); + my($usedlen) = length($6) - 1; + my($used) = $6 / (1024 * 1024); + my($fmt) = sprintf("%%-%dsK%s%%-%dsK%s%%-%dsK", $totlen, $3, + $freelen, $5, $usedlen); + + ProcessHistory("FLASH","","","!Flash: $1" . + sprintf($fmt, $tot, $free, $used)); + } ProcessHistory("FLASH","","","!Flash: $_"); } ProcessHistory("","","","!\n"); diff --git a/bin/jlogin.in b/bin/jlogin.in index 03c75a7..de14fdf 100644 --- a/bin/jlogin.in +++ b/bin/jlogin.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 @@ -49,7 +49,7 @@ # # Usage line -set usage "Usage: $argv0 \[-dV\] \[-c command\] \[-Evar=x\] \ +set usage "Usage: $argv0 \[-dSV\] \[-c command\] \[-Evar=x\] \ \[-f cloginrc-file\] \[-p user-password\] \[-r passphrase\] \[-s script-file\] \ \[-u username\] \[-t timeout\] \[-x command-file\] \[-y ssh_cypher_type\] \ router \[router...\]\n" @@ -67,6 +67,8 @@ set avenable 1 # The default is to look in the password file to find the passwords. This # tracks if we receive them on the command line. set do_passwd 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) ]} { @@ -109,8 +111,7 @@ for {set i 0} {$i < $argc} {incr i} { } -d* { exp_internal 1 # Environment variable to pass to -s scripts - } -E* - { + } -E* { if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { set E$varname $varvalue } else { @@ -118,15 +119,13 @@ for {set i 0} {$i < $argc} {incr i} { exit 1 } # alternate cloginrc file - } -f* - - -F* { + } -f* { if {! [ regexp .\[fF\](.+) $arg ignore password_file]} { incr i set password_file [ lindex $argv $i ] } # user Password - } -p* - - -P* { + } -p* { if {! [ regexp .\[pP\](.+) $arg ignore userpasswd]} { incr i set userpasswd [ lindex $argv $i ] @@ -137,15 +136,13 @@ for {set i 0} {$i < $argc} {incr i} { send_user "@PACKAGE@ @VERSION@\n" exit 0 # passphrase - } -r* - - -R* { + } -r* { if {! [ regexp .\[rR\](.+) $arg ignore passphrase]} { incr i set avpassphrase [ lindex $argv $i ] } # Expect script to run. - } -s* - - -S* { + } -s* { if {! [ regexp .\[sS\](.+) $arg ignore sfile]} { incr i set sfile [ lindex $argv $i ] @@ -155,23 +152,23 @@ for {set i 0} {$i < $argc} {incr i} { exit 1 } set do_script 1 + # save config on exit + } -S* { + set do_saveconfig 1 # Timeout - } -t* - - -T* { + } -t* { if {! [ regexp .\[tT\](.+) $arg ignore timeout]} { incr i set timeout [ lindex $argv $i ] } # Username - } -u* - - -U* { + } -u* { if {! [ regexp .\[uU\](.+) $arg ignore user]} { incr i set username [ lindex $argv $i ] } # command file - } -x* - - -X* { + } -x* { if {! [ regexp .\[xX\](.+) $arg ignore cmd_file]} { incr i set cmd_file [ lindex $argv $i ] @@ -185,8 +182,7 @@ for {set i 0} {$i < $argc} {incr i} { set command [join [split $cmd_text \n] \;] set do_command 1 # 'ssh -c' cypher type - } -y* - - -Y* { + } -y* { if {! [ regexp .\[yY\](.+) $arg ignore cypher]} { incr i set cypher [ lindex $argv $i ] @@ -389,11 +385,11 @@ proc login { router user passwd cmethod cyphertype identfile} { send "yes\r" send_user "\nHost $router added to the list of known hosts.\n" exp_continue } - -re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" { + -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\)\?" { + -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 } diff --git a/bin/mrvlogin.in b/bin/mrvlogin.in index 2de0c28..1eb7fa0 100644 --- a/bin/mrvlogin.in +++ b/bin/mrvlogin.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 @@ -53,7 +53,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\] \ @@ -76,6 +76,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 # set send_human {.4 .4 .7 .3 5} @@ -112,15 +114,13 @@ 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 ] @@ -138,15 +138,13 @@ for {set i 0} {$i < $argc} {incr i} { send_user "@PACKAGE@ @VERSION@\n" exit 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 { @@ -154,24 +152,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 ] @@ -181,30 +176,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 ] @@ -418,14 +412,15 @@ 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" catch {close}; catch {wait}; return 1 } - -re "Offending key for .* \(yes\/no\)\?" { + -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" catch {close}; catch {wait}; @@ -435,7 +430,7 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } - "Login failed" { + -re "Login (failed|incorrect)" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } diff --git a/bin/nlogin.in b/bin/nlogin.in index d2e211d..5d302b4 100644 --- a/bin/nlogin.in +++ b/bin/nlogin.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 @@ -53,7 +53,7 @@ # users permissions can not change. # Usage line -set usage "Usage: $argv0 \[-dV\] \[-c command\] \[-Evar=x\] \ +set usage "Usage: $argv0 \[-dSV\] \[-c command\] \[-Evar=x\] \ \[-f cloginrc-file\] \[-p user-password\] \ \[-s script-file\] \[-t timeout\] \[-u username\] \ \[-v vty-password\] \[-x command-file\] \ @@ -71,6 +71,8 @@ set do_script 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) ]} { @@ -105,23 +107,20 @@ 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 # Environment variable to pass to -s scripts - } -E* - { + } -E* { if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { set E$varname $varvalue } else { @@ -129,16 +128,14 @@ for {set i 0} {$i < $argc} {incr i} { exit 1 } # 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 ] @@ -148,26 +145,25 @@ for {set i 0} {$i < $argc} {incr i} { exit 1 } set do_script 1 - # cypher type - } -y* - - -Y* { + # save config on exit + } -S* { + set do_saveconfig 1 + # cypher type + } -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 ] } - } -t* - - -T* { + } -t* { incr i set timeout [ lindex $argv $i ] - } -x* - - -X { + } -x* { if {! [ regexp .\[xX\](.+) $arg ignore cmd_file]} { incr i set cmd_file [ lindex $argv $i ] @@ -180,6 +176,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 # Does tacacs automatically enable us? } -autoenable { # ignore autoenable @@ -240,11 +240,11 @@ proc include {args} { source_password_file $args } -proc find {var firewall} { +proc find {var router} { upvar int_$var list if { [info exists list] } { foreach line $list { - if { [string match [lindex $line 0] $firewall ] } { + if { [string match [lindex $line 0] $router ] } { return [lrange $line 1 end] } } @@ -276,8 +276,7 @@ proc source_password_file { password_file } { # Log into the firewall. # returns: 0 on success, 1 on failure -proc login { firewall user userpswd passwd enapasswd prompt cmethod -cyphertype } { +proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } { global spawn_id in_proc do_command do_script sshcmd set in_proc 1 set uprompt_seen 0 @@ -289,16 +288,24 @@ cyphertype } { if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog command suffix port if {"$port" == ""} { - set retval [ catch {spawn telnet $firewall} reason ] + set retval [ catch {spawn telnet $router} reason ] } else { - set retval [ catch {spawn telnet $firewall $port} reason ] + set retval [ catch {spawn telnet $router $port} reason ] } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } - } elseif ![string compare $prog "ssh"] { - if [ catch {spawn $sshcmd -c $cyphertype -x -l $user $firewall} reason ] { + } elseif [string match "ssh*" $prog] { + regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port + if {"$port" == ""} { + set cmd [join [lindex $sshcmd 0] " "] + set retval [ catch {eval spawn [split "$cmd -c $cyphertype -x -l $user $router" { }]} reason ] + } else { + set cmd [join [lindex $sshcmd 0] " "] + set retval [ catch {eval spawn [split "$cmd -c $cyphertype -x -l $user -p $port $router" { }]} reason ] + } + if { $retval } { send_user "\nError: $sshcmd failed: $reason\n" return 1 } @@ -344,39 +351,60 @@ cyphertype } { # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { - "Connection refused" { - send_user "\nError: Connection Refused\n"; wait; return 1 - } eof { send_user "\nError: Couldn't login\n"; wait; return 1 - } "Unknown host\r\n" { - expect eof - send_user "\nError: Unknown host\n"; wait; return 1 - } "Host is unreachable" { - expect eof - send_user "\nError: Host Unreachable!\n"; wait; return 1 - } "No address associated with name" { - expect eof - send_user "\nError: Unknown host\n"; wait; return 1 + -re "(Connection refused|Secure connection \[^\n\r]+ refused)" { + catch {close}; catch {wait}; + if !$progs { + send_user "\nError: Connection Refused ($prog): $router\n" + return 1 + } + } + -re "(Connection closed by|Connection to \[^\n\r]+ closed)" { + catch {close}; catch {wait}; + if !$progs { + send_user "\nError: Connection closed ($prog): $router\n" + return 1 + } + } + eof { send_user "\nError: Couldn't login: $router\n"; wait; return 1 } + -nocase "unknown host\r" { + send_user "\nError: Unknown host $router\n"; + catch {close}; catch {wait}; + return 1 } - -re "Are you sure you want to continue connecting .*" { + "Host is unreachable" { + send_user "\nError: Host Unreachable: $router\n"; + catch {close}; catch {wait}; + return 1 + } + "No address associated with name" { + send_user "\nError: Unknown host $router\n"; + catch {close}; catch {wait}; + return 1 + } + -re "(Host key not found |The authenticity of host .* be established).*\(yes\/no\)\?" { send "yes\r" - send_user "Host $firewall added to the list of known hosts.\n" - exp_continue } - -re "Host key not found .* \(yes\/no\)\?" { - send "yes\r" - send_user "Host $firewall added to the list of known hosts.\n" - exp_continue } - -re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" { - send "no\r" - send_user "\nError: The host key for $firewall has changed. Update the SSH known_hosts file accordingly.\n" - return 1 } - -re "Offending key for .* \(yes\/no\)\?" { + send_user "\nHost $router added to the list of known hosts.\n" + 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" + catch {close}; catch {wait}; + return 1 + } + -re "Offending key for .* \(yes\/no\)\?" { send "no\r" - send_user "\nError: host key mismatch for $firewall. Update the SSH known_hosts file accordingly.\n" - return 1 } - denied { send_user "\nError: Check your passwd for $firewall\n" - catch {close}; catch {wait}; return 1 - } - " ### Login failed" {send_user "\nError: Check your passwd for $firewall\n"; return 1 } + send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" + catch {close}; catch {wait}; + return 1 + } + -re "(denied|Sorry)" { + send_user "\nError: Check your passwd for $router\n" + catch {close}; catch {wait}; return 1 + } + "Login failed" { + send_user "\nError: Check your passwd for $router\n"; + catch {close}; catch {wait}; return 1 + } -re "(login:)" { sleep 1; send -- "$user\r" @@ -450,17 +478,17 @@ proc run_commands { prompt command } { source_password_file $password_file set in_proc 0 set exitval 0 -foreach firewall [lrange $argv $i end] { - set firewall [string tolower $firewall] - send_user "$firewall\n" +foreach router [lrange $argv $i end] { + set router [string tolower $router] + send_user "$router\n" set prompt {-> } # Figure out passwords if { $do_passwd || $do_enapasswd } { - set pswd [find password $firewall] + set pswd [find password $router] if { [llength $pswd] == 0 } { - send_user "\nError: no password for $firewall in $password_file.\n" + send_user "\nError: no password for $router in $password_file.\n" continue } set passwd [join [lindex $pswd 0] ""] @@ -475,7 +503,7 @@ foreach firewall [lrange $argv $i end] { # command line username set ruser $username } else { - set ruser [join [find user $firewall] ""] + set ruser [join [find user $router] ""] if { "$ruser" == "" } { set ruser $default_user } } @@ -484,7 +512,7 @@ foreach firewall [lrange $argv $i end] { # command line username set userpswd $userpasswd } else { - set userpswd [join [find userpassword $firewall] ""] + set userpswd [join [find userpassword $router] ""] if { "$userpswd" == "" } { set userpswd $passwd } } @@ -494,20 +522,20 @@ foreach firewall [lrange $argv $i end] { # command line cypher type set cyphertype $cypher } else { - set cyphertype [find cyphertype $firewall] + set cyphertype [find cyphertype $router] if { "$cyphertype" == "" } { set cyphertype "3des" } } # Figure out connection method - set cmethod [find method $firewall] + set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name - set sshcmd [find sshcmd $firewall] + set sshcmd [find sshcmd $router] if { "$sshcmd" == "" } { set sshcmd {ssh} } - # Login to the firewall - if {[login $firewall $ruser $userpswd $passwd $enapasswd $prompt $cmethod $cyphertype]} { + # Login to the router + if {[login $router $ruser $userpswd $passwd $enapasswd $prompt $cmethod $cyphertype]} { incr exitval continue } @@ -534,7 +562,7 @@ foreach firewall [lrange $argv $i end] { source $sfile catch {close}; } else { - label $firewall + label $router log_user 1 interact } 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 } diff --git a/bin/rancid-fe.in b/bin/rancid-fe.in index a76bc4d..61bf571 100644 --- a/bin/rancid-fe.in +++ b/bin/rancid-fe.in @@ -55,7 +55,6 @@ $vendor =~ tr/[A-Z]/[a-z]/; 'alteon' => 'arancid', 'avocent' => 'avorancid', 'baynet' => 'brancid', - 'bigip' => 'f5rancid', 'cat5' => 'cat5rancid', 'cisco' => 'rancid', 'cisco-nx' => 'nxrancid', diff --git a/bin/rancid.in b/bin/rancid.in index 6926691..2b1631e 100644 --- a/bin/rancid.in +++ b/bin/rancid.in @@ -1246,6 +1246,14 @@ REDUX: tr/\015//d; while (<INPUT>) { tr/\015//d; + # Sometimes "show diag" just ends while we are + # trying to process this pcb stuff. Check for a + # prompt so we can get out. + if (/^$prompt/) { + $found_diag=1; + goto PerlSucks; + } + if (/0x..: / || /^$/) { # no effing idea why break does not work there goto PerlSucks; @@ -1268,6 +1276,8 @@ PerlSucks: # ProcessHistory("SLOT","keysort","B","!Slot $slot$WIC: hvers $hw rev $rev\n"); ProcessHistory("SLOT","keysort","C","!Slot $slot$WIC: part $pn, serial $sn\n"); + # If we saw the prompt, then we are done. + last if $found_diag; } /revision\s+(\S+).*revision\s+(\S+)/ && ProcessHistory("SLOT","keysort","C","!Slot $slot$WIC: hvers $1 rev $2\n") && @@ -1551,6 +1561,8 @@ sub WriteTerm { # some versions have other crap mixed in with the bits in the # block above /^! (Last configuration|NVRAM config last)/ && next; + # and for the ASA + /^: (Written by \w+ at|Saved)/ && next; # skip consecutive comment lines to avoid oscillating extra comment # line on some access servers. grrr. @@ -1824,7 +1836,7 @@ sub WriteTerm { next; } - /^Cryptochecksum:/ && next; + /^ *Cryptochecksum:/ && next; # catch anything that wasnt matched above. ProcessHistory("","","","$_"); diff --git a/bin/rivlogin.in b/bin/rivlogin.in index b9ca2bc..df8bc21 100644 --- a/bin/rivlogin.in +++ b/bin/rivlogin.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 @@ -75,6 +75,8 @@ set output_file "" set conf_prompt "*\(config\)# " set logging 0 set config_mode 0 +# Save config, if prompted +set do_saveconfig 0 # Password file for routers to access set password_file $env(HOME)/.cloginrc @@ -122,28 +124,27 @@ if {[ info exists env(CLOGINRC) ]} { # Sets Xterm title if interactive...if its an xterm and the user cares # proc label { host } { - global env # if CLOGIN has an 'x' in it, don't set the xterm name/banner if [info exists env(CLOGIN)] { - if {[string first "x" $env(CLOGIN)] != -1} { return } + if {[string first "x" $env(CLOGIN)] != -1} { return } } if [info exists env(TERM)] { - if [regexp \^(xterm|vs) $env(TERM) ignore ] { - send_user "\033]1;[lindex [split $host "."] 0]\a" - send_user "\033]2;$host\a" - } + if [regexp \^(xterm|vs) $env(TERM) ignore ] { + send_user "\033]1;[lindex [split $host "."] 0]\a" + send_user "\033]2;$host\a" + } } } # This is a helper function to make the password file easier to # maintain. # NOTES: Using this the password file has the form: -# add password sl* pete cow -# add password at* steve -# add password * hanky-pie +# add password sl* pete cow +# add password at* steve +# add password * hanky-pie proc add { var args } { global $var @@ -156,23 +157,22 @@ proc add { var args } { # that a "bad guy" could just as easy put such code in the clogin # script, so I will leave .cloginrc as just an extention of that script proc source_password_file { } { - global env password_file read_password_file if { [info exists read_password_file] } { - return 1 + return 1 } if { [info exists password_file] == 0 } { - set password_file $env(HOME)/.cloginrc + set password_file $env(HOME)/.cloginrc } set read_password_file 1 file stat $password_file fileinfo if { [expr ($fileinfo(mode) & 007)] != 0000 } { - puts "ERROR: $password_file must not be group or world readable and writable\n" - return 1 + puts "ERROR: $password_file must not be group or world readable and writable\n" + return 1 } source $password_file @@ -183,23 +183,23 @@ proc source_password_file { } { proc find { var router } { if {[ source_password_file ] == 0 } { - return {} + return {} } upvar $var list if { [info exists list] } { - foreach line $list { - if { [string match [lindex $line 0] $router ] } { - return [lrange $line 1 end] - } - } + foreach line $list { + if { [string match [lindex $line 0] $router ] } { + return [lrange $line 1 end] + } + } } return {} } # pre: login completed ok # post: terminate login session by closing tcp connection -proc auto_exit { } { +proc auto_exit { } { global telnet_id @@ -225,19 +225,19 @@ proc login { router user userpswd passwd enapasswd } { global config verbose my_prompt if { $verbose == 1 } { - puts "DEBUG: login router = $router" - puts "DEBUG: login username = $user" - puts "DEBUG: login userpasswd = $userpswd" + puts "DEBUG: login router = $router" + puts "DEBUG: login username = $user" + puts "DEBUG: login userpasswd = $userpswd" puts "DEBUG: login passwd = $passwd" - puts "DEBUG: login enapasswd = $enapasswd" + puts "DEBUG: login enapasswd = $enapasswd" } spawn -noecho telnet $router set telnet_id $spawn_id if { $telnet_id == 0 } { - puts "ERROR: login: spawn telnet session failed.\n" - return 1 + puts "ERROR: login: spawn telnet session failed.\n" + return 1 } # wait for initial 'Press RETURN to...' response @@ -249,70 +249,56 @@ proc login { router user userpswd passwd enapasswd } { # If password fails 3 times then expect again set pass_attempt 0 - expect { - - -re ".*> " { } - - "Password:" { - incr pass_attempt - send -- "$passwd\r" - exp_continue - } - - "Username: " { - - set pattempt 0 - - send -- "$user\r" - expect { - - "Password: " { - - incr pattempt - if {$pattempt == 1} { - send -- "$userpswd\r"; - } else { - send -- "$enapasswd\r"; - } - exp_continue - } - - -re ".*> " { exp_continue;} - } - } - + expect { + -re ".*> " { } + "Password:" { + incr pass_attempt + send -- "$passwd\r" + exp_continue + } + "Username: " { + set pattempt 0 + + send -- "$user\r" + expect { + "Password: " { + incr pattempt + if {$pattempt == 1} { + send -- "$userpswd\r"; + } else { + send -- "$enapasswd\r"; + } + exp_continue + } + -re ".*> " { exp_continue;} + } + } "%TELNETD-W-BADPASSWD" { puts "ERROR: bad userid or password to telnet." return 1 } "%CONS-W-AUTH_PASSWD" { exp_continue - } - + } "% Authentication failed." { puts "ERROR: bad userid or password to telnet." return 1 } - - "Authentication Failed:" { puts "ERROR: bad userid or password to radius/tacacs+" return 1 } - - "Connection closed *" { - if {$pass_attempt == 3} { - puts "ERROR: Maximum attempts for password reached. Check password. Exiting."; - puts $expect_out(0,string); + "Connection closed *" { + if {$pass_attempt == 3} { + puts "ERROR: Maximum attempts for password reached. Check password. Exiting."; + puts $expect_out(0,string); return 1 - } - } - - timeout { - puts "ERROR: Timeout on login. Exiting."; - return 1 - } - + } + } + timeout { + puts "ERROR: Timeout on login. Exiting."; + return 1 + } eof { puts "ERROR: device closed telnet connection during login" return 1 @@ -324,7 +310,7 @@ proc login { router user userpswd passwd enapasswd } { expect -re ".*> " set abc "$expect_out(buffer)" set my_prompt "[lindex $abc 0]" - regexp {(.*[^>])} $my_prompt my + regexp {(.*[^>])} $my_prompt my return 0; } @@ -338,7 +324,7 @@ proc disable_cli_paging { } { send "cli set terminal rows 0\r" expect { - "$my_prompt" {return 0 } + "$my_prompt" {return 0 } } return 1 } @@ -346,19 +332,17 @@ proc disable_cli_paging { } { # pre: login returned 0, prompt at top level # post: turn off command completion return 0 # on error, return 1 -proc disable_cmd_autocomplete { } { +proc disable_cmd_autocomplete { } { global my_prompt send "cli set command completion off\r" expect { + $my_prompt { } - $my_prompt { } - - timeout { - puts "ERROR:disable_cmd_autocomplete(TIMEOUT)"; - return 0; - } - + timeout { + puts "ERROR:disable_cmd_autocomplete(TIMEOUT)"; + return 0; + } } return 0 @@ -371,18 +355,14 @@ proc logout { prompt } { # in case of not being at root cmd... # verify top level prompt state, move to it if necessary - if { $config_mode == 1 } { - send "exit\r" expect { "Do you want*" { send "no\r" } - "$enable_prompt" { } - timeout { puts "ERROR: logout: timeout from config mode\n" } eof { puts "ERROR: device dropped connection\n" } } @@ -391,8 +371,7 @@ proc logout { prompt } { send "logout\r" expect { - - "Are you sure*" { + "Are you sure*" { send "yes\r" return 0 } @@ -406,22 +385,21 @@ proc do_enable { enauser enapasswd userpswd } { global my_prompt enable_prompt set enable_prompt [ string trimright $my_prompt ">" ] set enable_prompt $enable_prompt\# + set uses_username 0; if { $verbose == 1 } { puts "DEBUG: do_enable: my_prompt = $my_prompt ena_prompt = $enable_prompt" } - set uses_username 0; - send "enable\r" expect { - Username: { + Username: { set uses_username 1; send -- "$enauser\r"; exp_continue } - Password: { + Password: { if {$uses_username == 1} { send -- "$userpswd\r"; } else { @@ -429,18 +407,14 @@ proc do_enable { enauser enapasswd userpswd } { } exp_continue } - - "$my_prompt" { + "$my_prompt" { puts "ERROR: do_enable failed to gain enable mode." return 1 } - "CONS-W-AUTH_PASSWD" { send -- "$enapasswd\r"; } - - "$enable_prompt " { } - "%SYS-W-NOPASSWD*" { } - - "Authentication Failed: Access Denied" { + "$enable_prompt " { } + "%SYS-W-NOPASSWD*" { } + "Authentication Failed: Access Denied" { puts "ERROR: Bad user or password for enable mode." return 1 } @@ -464,10 +438,8 @@ proc do_configure { } { send "configure\r" expect { - "$config_prompt " { } - "$my_prompt" { - } - + "$config_prompt " { } + "$my_prompt" { } eof { return 1} timeout { return 1} } @@ -484,9 +456,7 @@ proc start_logfile { output_file } { global logging if { [ string length $output_file ] != 0 } { - set rc [ catch { - log_file -noappend $output_file - } errMsg ] + set rc [ catch { log_file -noappend $output_file } errMsg ] if { $rc != 0 } { puts "ERROR: open file $output_file for write access failed. $errMsg\n" @@ -505,12 +475,12 @@ proc run_commands { prompt cmdstring } { set num_commands [llength $cmdstring] for {set i 0} {$i < $num_commands} { incr i} { - regsub -- {[ ]*([^\.]*)} [subst -nocommands [lindex $commands $i]] {\1} sendstring + regsub -- {[ ]*([^\.]*)} [subst -nocommands [lindex $commands $i]] {\1} sendstring - if {[ run_single_command $prompt $sendstring ] == 1} { - puts "ERROR: command '$sendstring' not processed by device. Check previous error messages." - return 1 - } + if {[ run_single_command $prompt $sendstring ] == 1} { + puts "ERROR: command '$sendstring' not processed by device. Check previous error messages." + return 1 + } } return 0 } @@ -529,16 +499,16 @@ proc run_single_command { prompt cmdstring } { set delay 0 if {$verbose == 1} { - puts "DEBUG: run_commands: prompt=$prompt \"$cmdstring\" " + puts "DEBUG: run_commands: prompt=$prompt \"$cmdstring\" " } # ays == "are you sure" - must send back yes if { [string compare $cmdstring "save startup" ] == 0 } { set need_ays 1 - set delay 1 - if {$verbose == 1} { - puts "DEBUG: save startup cmd seen, set need_ays = 1" - } + set delay 1 + if {$verbose == 1} { + puts "DEBUG: save startup cmd seen, set need_ays = 1" + } } # TODO: add case for copy command to startup, also prompts for ok @@ -549,48 +519,39 @@ proc run_single_command { prompt cmdstring } { send "$cmdstring\r" if { $delay == 1} { - sleep 1 + sleep 1 } expect { - - "%CLI-E-IVCMD*" { - puts "ERROR: run_commands(command rejected by device)\n" - set rc 1 - } - + "%CLI-E-IVCMD*" { + puts "ERROR: run_commands(command rejected by device)\n" + set rc 1 + } "%CLI-E-FACUNKNWN*" { - puts "ERROR: run_commands(command rejected by device)\n" - set rc 1 + puts "ERROR: run_commands(command rejected by device)\n" + set rc 1 } - "%SYS-I-ADDFAILED*" { - puts "ERROR: run_commands(command rejected by device)\n" - set rc 1 + puts "ERROR: run_commands(command rejected by device)\n" + set rc 1 } "%TFTP-E-REMOTE,*" { - puts "ERROR: run_commands(command rejected by device)\n" - set rc 1 + puts "ERROR: run_commands(command rejected by device)\n" + set rc 1 } - "%SYS-E-PRIMARY_NO_SUCH_IMAGE*" { - puts "ERROR: run_commands(command rejected by device)\n" - set rc 1 + puts "ERROR: run_commands(command rejected by device)\n" + set rc 1 } - "want to overwrite " { send "yes\r" if {$verbose == 1} { - puts "DEBUG: got overwrite question, set need_ays to 0" - } + puts "DEBUG: got overwrite question, set need_ays to 0" + } set need_ays 0 } - - - "%CONFIG-E-DUPLICATE,*" { - } - - "$prompt" { + "%CONFIG-E-DUPLICATE,*" { } + "$prompt" { if { $seen_prompt == 0 } { set seen_prompt 1 } @@ -603,14 +564,11 @@ proc run_single_command { prompt cmdstring } { exp_continue } } - - -re ".* More: m,<space> --- Quit: q --- One line: <return> ---" { - send "q" - exp_continue - } - - - timeout { + -re ".* More: m,<space> --- Quit: q --- One line: <return> ---" { + send "q" + exp_continue + } + timeout { if {$verbose == 1} { puts "DEBUG: timeout occured for the $seen_time time\n" } @@ -621,16 +579,14 @@ proc run_single_command { prompt cmdstring } { exp_continue } - puts "ERROR:run_commands(TIMEOUT)" - set rc 1 - } - - eof { + puts "ERROR:run_commands(TIMEOUT)" + set rc 1 + } + eof { puts "ERROR:run_commands(connection closed by device)\n" set rc 1 - } - - "\n" { exp_continue } + } + "\n" { exp_continue } } # clear input buffer of any remaining data @@ -645,39 +601,34 @@ proc init_userid { } { global default_user if {[ info exists env(RSTONE_USER) ] } { - set default_user $env(RSTONE_USER) + set default_user $env(RSTONE_USER) } 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 - - # unlike whoami or id -nu. - regexp {\(([^)]*)} [exec id] junk default_user + # This uses "id" which I think is portable. At least it has existed + # (without options) on all machines/OSes I've been on recently - + # unlike whoami or id -nu. + regexp {\(([^)]*)} [exec id] junk default_user } } proc source_script_file { filename } { - global my_prompt - - expect -re "$my_prompt" {} + global my_prompt - source $filename + expect -re "$my_prompt" {} + source $filename } - # pre: login completed ok, filename contains set of cli commands one per line # post: each command is extracted from filename and sent to device # return 0 on success, return 1 on error # NOTE: for scripts that begin with "configure", change the mode to configure # before executing the following commands proc process_script_file { filename } { - global my_prompt verbose set rc 0 set ifile "" - set rc [ catch { - set ifile [ open $filename r] - } errMsg ] + set rc [ catch { set ifile [ open $filename r] } errMsg ] if { $rc != 0 } { puts "ERROR: process_script_file: open script file $filename for read access failed. $errMsg\n" @@ -724,27 +675,20 @@ proc process_script_file { filename } { return $rc } - - # pre: filename is valid file # post: remove extended ascii sequences and other cruft # and prepend a header: rscmd: ip-addr : date # TODO: should watch all file commands more closely -proc strip_log { filename router } { - +proc strip_log { filename router } { global tempfile - set rc [ catch { - set ifile [ open $filename r] - } errMsg ] + set rc [ catch { set ifile [ open $filename r] } errMsg ] if { $rc != 0 } { puts "ERROR: strip_log: open script file $filename for read access failed. $errMsg\n" return 1 } - set rc [ catch { - set ofile [ open $tempfile w] - } errMsg ] + set rc [ catch { set ofile [ open $tempfile w] } errMsg ] if { $rc != 0 } { puts "ERROR: strip_log: open temp file $tempfile for write access failed. $errMsg\n" @@ -780,8 +724,6 @@ proc strip_log { filename router } { # # main section # - - if { $verbose == 1 } { puts "\n\nrscmd: Version 1.1 started on [exec date]" puts "[exec uname -a]" @@ -795,84 +737,83 @@ set send_human {.1 .3 1 .05 2} init_userid # Parse Command Line - for {set idx 0} {$idx < $argc} {incr idx} { - set arg [lindex $argv $idx] switch -glob -- $arg { - -c* - - -C* { - if {! [ regexp .\[cC\](.+) $arg ignore command]} { - incr idx - set command [ lindex $argv $idx ] - } - set do_command 1 + -c* - + -C* { + if {! [ regexp .\[cC\](.+) $arg ignore command]} { + incr idx + set command [ lindex $argv $idx ] + } + set do_command 1 # Expect debug mode } -d* { exp_internal 1 - # Environment variable to pass to -s scripts - } -E* - { - if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { - set E$varname $varvalue - } else { - send_user "Error: invalid format for -E in $arg\n" - exit 1 - } + # Environment variable to pass to -s scripts + } -E* + { + if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { + set E$varname $varvalue + } else { + send_user "Error: invalid format for -E in $arg\n" + exit 1 + } # Expect script to run - } -s* - - -S* { - if {! [ regexp .\[sS\](.+) $arg ignore sfile]} { - incr idx - set sfile [ lindex $argv $idx ] - } - - if { ! [ file exists $sfile ] } { - puts "ERROR: invalid argument script file \"$sfile\" does not exist.\n" + } -s* { + if {! [ regexp .\[sS\](.+) $arg ignore sfile]} { + incr idx + set sfile [ lindex $argv $idx ] + } + + if { ! [ file exists $sfile ] } { + puts "ERROR: invalid argument script file \"$sfile\" does not exist.\n" exit 1 } - if { ! [ file readable $sfile ] } { - puts "ERROR: invalid argument script file \"$sfile\" permissions disallow read access.\n" + if { ! [ file readable $sfile ] } { + puts "ERROR: invalid argument script file \"$sfile\" permissions disallow read access.\n" exit 1 - } + } - set do_script 1 + set do_script 1 + # save config on exit + } -S* { + set do_saveconfig 1 # Version string } -V* { send_user "@PACKAGE@ @VERSION@\n" exit 0 - # Command file - } -x* - - -X { - if {! [ regexp .\[xX\](.+) $arg ignore cmd_file]} { - incr idx - set cmd_file [ lindex $argv $idx ] - } - if [ catch {set cmd_fd [open $cmd_file r]} reason ] { - send_user "\nError: $reason\n" - exit 1 - } - set cmd_text [read $cmd_fd] - close $cmd_fd - set command [join [split $cmd_text \n] \;] - set do_command 1 - } -f* - - -F* { - if {! [ regexp .\[fF\](.+) $arg ignore password_file]} { - incr idx - set password_file [ lindex $argv $idx ] - } - - } -o* - - -O* { - if {! [ regexp .\[fF\](.+) $arg ignore password_file]} { - incr idx - set output_file [ lindex $argv $idx ] + # Command file + } -x* - + -X { + if {! [ regexp .\[xX\](.+) $arg ignore cmd_file]} { + incr idx + set cmd_file [ lindex $argv $idx ] + } + if [ catch {set cmd_fd [open $cmd_file r]} reason ] { + send_user "\nError: $reason\n" + exit 1 + } + set cmd_text [read $cmd_fd] + close $cmd_fd + set command [join [split $cmd_text \n] \;] + set do_command 1 + } -f* - + -F* { + if {! [ regexp .\[fF\](.+) $arg ignore password_file]} { + incr idx + set password_file [ lindex $argv $idx ] + } + } -o* - + -O* { + if {! [ regexp .\[fF\](.+) $arg ignore password_file]} { + incr idx + set output_file [ lindex $argv $idx ] if { $verbose == 1 } { puts "DEBUG: output file: $output_file" } - } + } # Timeout } -t* - -T* { @@ -1009,7 +950,7 @@ foreach router [lrange $argv $idx end] { exit 1 } -# if { [process_script_file $sfile] == 1} { +# if { [process_script_file $sfile] == 1}{ # puts "DEBUG: logfile $output_file closed on error\n" # logout $my_prompt # exit 1 diff --git a/bin/srancid.in b/bin/srancid.in index f8549c5..ad88613 100755 --- a/bin/srancid.in +++ b/bin/srancid.in @@ -212,6 +212,19 @@ sub ShowSys { # Remove Uptime / Up time/ && next; + # filter temperature sensor info for Dell 6428 stacks + /Temperature Sensors:/ && next; + if (/Temperature \(Celsius\)/ && + ProcessHistory("COMMENTS","keysort","C1","! Unit\tStatus\n")) { + while (<INPUT>) { + s/^\s+\015//g; + tr/\015//d; + /(\d+)\s+\d+\s+(.*)$/ && + ProcessHistory("COMMENTS","keysort","C1","! $1\t$2\n"); + /^\s*$/ && last; + } + } + /system description: (.*)/i && ProcessHistory("COMMENTS","keysort","A1", "!Chassis type: $1\n") && next; diff --git a/bin/tlogin.in b/bin/tlogin.in index e097da1..59a166a 100644 --- a/bin/tlogin.in +++ b/bin/tlogin.in @@ -2,22 +2,43 @@ ## ## $Id$ ## -## Copyright (C) 1997-2008 by Terrapin Communications, Inc. +## @PACKAGE@ @VERSION@ +## Copyright (c) 1997-2009 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 license -## remains intact and unmodified with any RANCID distribution. +## This code is derived from software contributed to and maintained by +## Terrapin Communications, Inc. by Henry Kilmer, John Heasley, Andrew Partan, +## Pete Whiting, Austin Schutz, and Andrew Fort. ## -## There is no warranty or other guarantee of fitness of this software. -## 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. +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## 1. Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## 2. Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## 3. All advertising materials mentioning features or use of this software +## must display the following acknowledgement: +## This product includes software developed by Terrapin Communications, +## Inc. and its contributors for RANCID. +## 4. Neither the name of Terrapin Communications, Inc. nor the names of its +## contributors may be used to endorse or promote products derived from +## this software without specific prior written permission. +## 5. It is requested that non-binding fixes and modifications be contributed +## back to Terrapin Communications, Inc. ## +## THIS SOFTWARE IS PROVIDED BY Terrapin Communications, INC. AND CONTRIBUTORS +## ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COMPANY OR CONTRIBUTORS +## BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +## POSSIBILITY OF SUCH DAMAGE. # # The login expect scripts were based on Erik Sherk's gwtn, by permission. # @@ -26,11 +47,10 @@ # Modified by Ed Ravin for Netopia. # Usage line -set usage "Usage: $argv0 \[-autoenable\] \[-noenable\] \[-c command\] \ -\[-debug] \ +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\] \ +\[-V\] \[-v vty-password\] \[-w enable-username\] \[-x command-file\] \ \[-y ssh_cypher_type\] router \[router...\]\n" # env(CLOGIN) may contain: @@ -79,39 +99,36 @@ for {set i 0} {$i < $argc} {incr i} { set arg [lindex $argv $i] switch -glob -- $arg { + } -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 { @@ -119,24 +136,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 ] @@ -146,30 +160,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 ] @@ -182,6 +195,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 @@ -189,8 +206,6 @@ for {set i 0} {$i < $argc} {incr i} { } -autoenable { set avautoenable 1 set avenable 0 - } -debug { - exp_internal 1 } -* { send_user "\nError: Unknown argument! $arg\n" send_user $usage @@ -404,11 +419,11 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } { send "yes\r" send_user "\nHost $router added to the list of known hosts.\n" exp_continue } - -re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" { + -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\)\?" { + -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 } diff --git a/bin/tntlogin.in b/bin/tntlogin.in index 8a265b3..02c20a0 100644 --- a/bin/tntlogin.in +++ b/bin/tntlogin.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 @@ -45,11 +45,10 @@ # Modified by P B Matthews. # Usage line -set usage "Usage: $argv0 \[-dV\] \[-c command\] \ -\[-Evar=x\] \[-f cloginrc-file\] \ -\[-s script-file\] \[-t timeout\] \[-u username\] \ -\[-v vty-password\] \[-x command-file\] \ -\[-y ssh_cypher_type\] router \[router...\]\n" +set usage "Usage: $argv0 \[-dSV\] \[-c command\] \[-Evar=x\] \ +\[-f cloginrc-file\] \[-s script-file\] \[-t timeout\] \[-u username\] \ +\[-v vty-password\] \[-x command-file\] \[-y ssh_cypher_type\] router \ +\[router...\]\n" # env(CLOGIN) may contain: # x == do not set xterm banner or name @@ -67,6 +66,8 @@ set avautoenable 1 # The default is to look in the password file to find the passwords. This # tracks if we receive them on the command line. set do_passwd 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) ]} { @@ -101,8 +102,7 @@ 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 ] @@ -119,12 +119,10 @@ for {set i 0} {$i < $argc} {incr i} { send_user "@PACKAGE@ @VERSION@\n" exit 0 # Enable Username - } -w* - - -W* { + } -w* { # ignore -w # Environment variable to pass to -s scripts - } -E* - { + } -E* { if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { incr i set E$varname $varvalue @@ -133,20 +131,17 @@ for {set i 0} {$i < $argc} {incr i} { exit 1 } # Enable Password - } -e* - { + } -e* { # ignore -e # 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 ] @@ -156,30 +151,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 ] + 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 ] @@ -313,10 +307,10 @@ proc login { router user userpswd passwd prompt cmethod cyphertype } { return 1 } } elseif ![string compare $prog "ssh"] { - if [ catch {spawn $sshcmd -c $cyphertype -x -l $user $router} reason ] { - send_user "\nError: $sshcmd failed: $reason\n" - return 1 - } + if [ catch {spawn $sshcmd -c $cyphertype -x -l $user $router} reason ] { + send_user "\nError: $sshcmd failed: $reason\n" + return 1 + } } elseif ![string compare $prog "rsh"] { send_error "\nError: unsupported method: rsh\n" if { $progs == 0 } { @@ -324,8 +318,8 @@ proc login { router user userpswd passwd prompt cmethod cyphertype } { } continue; } else { - send_user "\nError: unknown connection method: $prog\n" - return 1 + send_user "\nError: unknown connection method: $prog\n" + return 1 } sleep 0.3 @@ -356,7 +350,8 @@ proc login { router user userpswd passwd prompt cmethod cyphertype } { sleep 0.3 expect eof send_user "\nError: Connection Refused\n"; wait; return 1 - } eof { send_user "\nError: Couldn't login\n"; wait; return 1 + } + eof { send_user "\nError: Couldn't login\n"; wait; return 1 } "Unknown host\r\n" { expect eof send_user "\nError: Unknown host\n"; wait; return 1 @@ -370,16 +365,18 @@ proc login { router user userpswd passwd prompt 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 "$u_prompt" { send -- "$user\r" set uprompt_seen 1 @@ -466,30 +463,30 @@ foreach router [lrange $argv $i end] { # Figure out passwords if { $do_passwd } { - set pswd [find password $router] - if { [llength $pswd] == 0 } { - send_user "\nError - no password for $router in $password_file.\n" - continue - } - set passwd [join [lindex $pswd 0] ""] + set pswd [find password $router] + if { [llength $pswd] == 0 } { + send_user "\nError - no password for $router in $password_file.\n" + continue + } + set passwd [join [lindex $pswd 0] ""] } # Figure out username if {[info exists username]} { - # command line username - set ruser $username + # command line username + set ruser $username } else { - set ruser [join [find user $router] ""] - if { "$ruser" == "" } { set ruser $default_user } + set ruser [join [find user $router] ""] + if { "$ruser" == "" } { set ruser $default_user } } # Figure out username's password (if different from the vty password) if {[info exists userpasswd]} { - # command line username - set userpswd $userpasswd + # command line username + set userpswd $userpasswd } else { - set userpswd [join [find userpassword $router] ""] - if { "$userpswd" == "" } { set userpswd $passwd } + set userpswd [join [find userpassword $router] ""] + if { "$userpswd" == "" } { set userpswd $passwd } } # Figure out prompts @@ -509,11 +506,11 @@ foreach router [lrange $argv $i end] { # Figure out cypher type if {[info exists cypher]} { - # command line cypher type - set cyphertype $cypher + # command line cypher type + set cyphertype $cypher } else { - set cyphertype [find cyphertype $router] - if { "$cyphertype" == "" } { set cyphertype "3des" } + set cyphertype [find cyphertype $router] + if { "$cyphertype" == "" } { set cyphertype "3des" } } # Figure out connection method diff --git a/bin/trancid.in b/bin/trancid.in index 0e4f7fd..3c6e945 100644 --- a/bin/trancid.in +++ b/bin/trancid.in @@ -2,30 +2,55 @@ ## ## $Id$ ## -## Copyright (C) 1997-2004 by Terrapin Communications, Inc. +## @PACKAGE@ @VERSION@ +## Copyright (c) 1997-2008 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 license -## remains intact and unmodified with any RANCID distribution. +## This code is derived from software contributed to and maintained by +## Terrapin Communications, Inc. by Henry Kilmer, John Heasley, Andrew Partan, +## Pete Whiting, Austin Schutz, and Andrew Fort. ## -## There is no warranty or other guarantee of fitness of this software. -## 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. +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions +## are met: +## 1. Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## 2. Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## 3. All advertising materials mentioning features or use of this software +## must display the following acknowledgement: +## This product includes software developed by Terrapin Communications, +## Inc. and its contributors for RANCID. +## 4. Neither the name of Terrapin Communications, Inc. nor the names of its +## contributors may be used to endorse or promote products derived from +## this software without specific prior written permission. +## 5. It is requested that non-binding fixes and modifications be contributed +## back to Terrapin Communications, Inc. ## +## THIS SOFTWARE IS PROVIDED BY Terrapin Communications, INC. AND CONTRIBUTORS +## ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +## TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COMPANY OR CONTRIBUTORS +## BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +## POSSIBILITY OF SUCH DAMAGE. # # RANCID - Really Awesome New Cisco confIg Differ # -# usage: rancid [-d] [-l] [-f filename | $host] +# usage: rancid [-dV] [-l] [-f filename | $host] # # Modified by Ed Ravin for Netopia. use Getopt::Std; -getopts('dfl'); +getopts('dflV'); +if ($opt_V) { + print "@PACKAGE@ @VERSION@\n"; + exit(0); +} $log = $opt_l; $debug = $opt_d; $file = $opt_f; |