summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorTar Committer <tar@ocjtech.us>2004-03-14 17:00:09 +0000
committerTar Committer <tar@ocjtech.us>2004-03-14 17:00:09 +0000
commit381d322caf5928732f3d478d80e70acfccd67f99 (patch)
treed52aa26f9698cd869eca3f09661bfc05a7008a28 /bin
parent989312339ea2e16579803a48700628c5469e327a (diff)
downloadrancid-381d322caf5928732f3d478d80e70acfccd67f99.tar.gz
rancid-381d322caf5928732f3d478d80e70acfccd67f99.tar.xz
rancid-381d322caf5928732f3d478d80e70acfccd67f99.zip
Imported from rancid-2.3.tar.gz.rancid-2.3
Diffstat (limited to 'bin')
-rw-r--r--bin/Makefile.in4
-rw-r--r--bin/alogin.in4
-rw-r--r--bin/blogin.in9
-rw-r--r--bin/clogin.in34
-rw-r--r--bin/control_rancid.in16
-rw-r--r--bin/elogin.in4
-rw-r--r--bin/flogin.in9
-rw-r--r--bin/francid.in21
-rw-r--r--bin/hlogin.in9
-rw-r--r--bin/htlogin.in4
-rw-r--r--bin/jlogin.in31
-rw-r--r--bin/jrancid.in3
-rw-r--r--bin/lg.cgi.in28
-rw-r--r--bin/lgform.cgi.in28
-rw-r--r--bin/nlogin.in4
-rw-r--r--bin/nslogin.in10
-rw-r--r--bin/rancid-run.in85
-rw-r--r--bin/rancid.in32
-rw-r--r--bin/rivlogin.in221
-rw-r--r--bin/tntlogin.in4
-rw-r--r--bin/xrancid.in8
21 files changed, 319 insertions, 249 deletions
diff --git a/bin/Makefile.in b/bin/Makefile.in
index eedc795..dac26ed 100644
--- a/bin/Makefile.in
+++ b/bin/Makefile.in
@@ -109,6 +109,8 @@ CCDEPMODE = @CCDEPMODE@
#CFLAGS += -g
CFLAGS = -g -O0
COMM = @COMM@
+CONF_INSTALL_FALSE = @CONF_INSTALL_FALSE@
+CONF_INSTALL_TRUE = @CONF_INSTALL_TRUE@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CVS = @CVS@
@@ -141,6 +143,8 @@ MAILPLUS = @MAILPLUS@
MAKE = @MAKE@
MAKEINFO = @MAKEINFO@
MKDIR = @MKDIR@
+MK_LCLSTATEDIR_FALSE = @MK_LCLSTATEDIR_FALSE@
+MK_LCLSTATEDIR_TRUE = @MK_LCLSTATEDIR_TRUE@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
diff --git a/bin/alogin.in b/bin/alogin.in
index 91623fb..8937b95 100644
--- a/bin/alogin.in
+++ b/bin/alogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: alogin.in,v 1.22 2004/01/11 05:39:15 heas Exp $
+## $Id: alogin.in,v 1.23 2004/02/02 17:38:36 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -43,7 +43,7 @@ set password_file $env(HOME)/.cloginrc
set do_command 0
set do_script 0
# The default is to automatically enable
-set enable 1
+set avenable 1
# The default is that you login non-enabled (tacacs can have you login already
# enabled)
set avautoenable 0
diff --git a/bin/blogin.in b/bin/blogin.in
index 92d2e8c..90843ed 100644
--- a/bin/blogin.in
+++ b/bin/blogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: blogin.in,v 1.22 2004/01/11 05:39:15 heas Exp $
+## $Id: blogin.in,v 1.23 2004/02/02 17:38:36 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -46,7 +46,7 @@ set password_file $env(HOME)/.cloginrc
set do_command 0
set do_script 0
# The default is to automatically enable
-set enable 0
+set avenable 0
# The default is that you login non-enabled (tacacs can have you login already
# enabled)
set avautoenable 0
@@ -183,11 +183,11 @@ for {set i 0} {$i < $argc} {incr i} {
set do_command 1
# Do we enable?
} -noenable {
- set enable 0
+ set avenable 0
# Does tacacs automatically enable us?
} -autoenable {
set avautoenable 1
- set enable 0
+ set avenable 0
} -* {
send_user "\nError: Unknown argument! $arg\n"
send_user $usage
@@ -498,6 +498,7 @@ foreach router [lrange $argv $i end] {
set prompt "#"
} else {
set autoenable 0
+ set enable $avenable
set prompt ">"
}
}
diff --git a/bin/clogin.in b/bin/clogin.in
index 281d634..dd8b817 100644
--- a/bin/clogin.in
+++ b/bin/clogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: clogin.in,v 1.72 2004/01/11 05:39:15 heas Exp $
+## $Id: clogin.in,v 1.77 2004/03/12 05:44:06 asp Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -47,7 +47,7 @@ set password_file $env(HOME)/.cloginrc
set do_command 0
set do_script 0
# The default is to automatically enable
-set enable 1
+set avenable 1
# The default is that you login non-enabled (tacacs can have you login already
# enabled)
set avautoenable 0
@@ -189,11 +189,11 @@ for {set i 0} {$i < $argc} {incr i} {
set do_command 1
# Do we enable?
} -noenable {
- set enable 0
+ set avenable 0
# Does tacacs automatically enable us?
} -autoenable {
set avautoenable 1
- set enable 0
+ set avenable 0
} -* {
send_user "\nError: Unknown argument! $arg\n"
send_user $usage
@@ -306,8 +306,15 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
send_user "\nError: telnet failed: $reason\n"
exit 1
}
- } elseif ![string compare $prog "ssh"] {
- if [ catch {spawn $sshcmd -c $cyphertype -x -l $user $router} reason ] {
+ } elseif [string match "ssh*" $prog] {
+ regexp {ssh(:([^[:space:]]+))*} $prog command 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 ]
+ }
+ if { $retval } {
send_user "\nError: $sshcmd failed: $reason\n"
exit 1
}
@@ -403,7 +410,12 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
send_user "\nError: Check your passwd for $router\n"
return 1
}
- -re "^Enter Selection: " {
+ "Press any key to continue." {
+ # send_user "Pressing the ANY key\n"
+ send "\r"
+ exp_continue
+ }
+ -re "Enter Selection: " {
# Catalyst 1900s have some lame menu. Enter
# K to reach a command-line.
send "K\r"
@@ -453,8 +465,8 @@ proc do_enable { enauser enapasswd } {
-re "$e_prompt" { send "$enapasswd\r"; exp_continue}
"#" { set prompt "#" }
"(enable)" { set prompt "> (enable) " }
- "denied" {
- # % Access denied - from local auth
+ -re "(denied|Sorry|Incorrect)" {
+ # % Access denied - from local auth and poss. others
send_user "\nError: Check your Enable passwd\n";
return 1
}
@@ -485,6 +497,9 @@ proc run_commands { prompt command } {
if { [ string compare "extreme" "$platform" ] } {
if [ regexp -- ".*> .*enable" "$prompt" ] {
send "set length 0\r"
+ # This is ugly, but reduces code duplication, allowing the
+ # subsequent expects to handle everything as normal.
+ set command "set logging session disable\r;$command"
} else {
send "term length 0\r"
}
@@ -618,6 +633,7 @@ foreach router [lrange $argv $i end] {
set prompt "(#| \\(enable\\))"
} else {
set autoenable 0
+ set enable $avenable
set prompt ">"
}
}
diff --git a/bin/control_rancid.in b/bin/control_rancid.in
index f51a21b..bcfd316 100644
--- a/bin/control_rancid.in
+++ b/bin/control_rancid.in
@@ -1,6 +1,6 @@
#! /bin/sh
##
-## $Id: control_rancid.in,v 1.61 2004/01/11 05:25:13 hank Exp $
+## $Id: control_rancid.in,v 1.64 2004/03/12 23:13:09 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -82,8 +82,9 @@ TMP=${TMPDIR:=/tmp}/rancid.$GROUP.$$
trap 'rm -fr $TMP;' 1 2 15
# the receipient(s) of diffs
-mailrcpt=${mailrcpt:-"@MAILPLUS@$GROUP"}; export mailrcpt
-adminmailrcpt=${mailrcpt:-"@ADMINMAILPLUS@$GROUP"}; export adminmailrcpt
+mailrcpt=${mailrcpt:-"@MAILPLUS@${GROUP}${MAILDOMAIN}"}; export mailrcpt
+adminmailrcpt=${mailrcpt:-"@ADMINMAILPLUS@${GROUP}${MAILDOMAIN}"};
+export adminmailrcpt
# Number of things par should run in parallel.
PAR_COUNT=${PAR_COUNT:-5}
@@ -127,9 +128,6 @@ then
echo "$DIR/router.db does not exist."
) | sendmail -t
exit 1;
-elif [ ! -s $DIR/router.db ]
-then
- exit
fi
# generate the list of all, up, & down routers
@@ -140,15 +138,15 @@ sed -e '/^#/d' -e 's/^ *//' -e 's/ *$//' -e 's/ *: */:/g' router.db |
sort -u > routers.db
cut -d: -f1,2 routers.db > routers.all.new
if [ ! -f routers.all ] ; then touch routers.all; fi
-diff routers.all routers.all.new > /dev/null 2>&1; RALL=$?
+@DIFF_CMD@ routers.all routers.all.new > /dev/null 2>&1; RALL=$?
@PERLV@ -F: -ane '{($F[0] =~ tr@A-Z@a-z@,print $_)
if ($F[2] !~ /^up$/i);}' routers.db > routers.down.new
if [ ! -f routers.down ] ; then touch routers.down; fi
-diff routers.down routers.down.new > /dev/null 2>&1; RDOWN=$?
+@DIFF_CMD@ routers.down routers.down.new > /dev/null 2>&1; RDOWN=$?
@PERLV@ -F: -ane '{($F[0] =~ tr@A-Z@a-z@,print "$F[0]:$F[1]\n")
if ($F[2] =~ /^up$/i);}' routers.db > routers.up.new
if [ ! -f routers.up ] ; then touch routers.up; fi
-diff routers.up routers.up.new > /dev/null 2>&1; RUP=$?
+@DIFF_CMD@ routers.up routers.up.new > /dev/null 2>&1; RUP=$?
if [ $RALL -ne 0 -o $RDOWN -ne 0 -o $RUP -ne 0 ]
then
diff --git a/bin/elogin.in b/bin/elogin.in
index 651d7fb..0a41285 100644
--- a/bin/elogin.in
+++ b/bin/elogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: elogin.in,v 1.27 2004/01/11 05:39:15 heas Exp $
+## $Id: elogin.in,v 1.28 2004/02/02 17:38:36 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -40,7 +40,7 @@ set password_file $env(HOME)/.cloginrc
set do_command 0
set do_script 0
# The default is to automatically enable
-set enable 1
+set avenable 1
# The default is that you login non-enabled (tacacs can have you login already
# enabled)
set avautoenable 0
diff --git a/bin/flogin.in b/bin/flogin.in
index 169e522..35af3cd 100644
--- a/bin/flogin.in
+++ b/bin/flogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: flogin.in,v 1.32 2004/01/11 05:39:15 heas Exp $
+## $Id: flogin.in,v 1.33 2004/02/02 17:38:36 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -50,7 +50,7 @@ set password_file $env(HOME)/.cloginrc
set do_command 0
set do_script 0
# The default is to automatically enable
-set enable 1
+set avenable 1
# The default is that you login non-enabled (tacacs can have you login already
# enabled)
set avautoenable 0
@@ -186,11 +186,11 @@ for {set i 0} {$i < $argc} {incr i} {
set do_command 1
# Do we enable?
} -noenable {
- set enable 0
+ set avenable 0
# Does tacacs automatically enable us?
} -autoenable {
set avautoenable 1
- set enable 0
+ set avenable 0
} -* {
send_user "\nError: Unknown argument! $arg\n"
send_user $usage
@@ -535,6 +535,7 @@ foreach router [lrange $argv $i end] {
set prompt "#"
} else {
set autoenable 0
+ set enable $avenable
set prompt ">"
}
}
diff --git a/bin/francid.in b/bin/francid.in
index e1fd284..cc3acd6 100644
--- a/bin/francid.in
+++ b/bin/francid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: francid.in,v 1.26 2004/01/11 03:49:13 heas Exp $
+## $Id: francid.in,v 1.28 2004/03/03 00:33:48 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -154,7 +154,7 @@ sub ShowVersion {
s/^\s*(HW|SW)/$1/;
s/^\s*(Compiled on)/SW: $1/;
#s/^(HW.*)/$1\n/;
- if (/^SL (\d)/) {
+ if (/^SL (\d+)/) {
$slot = "Slot $1";
s/^SL \d+/$slot/;
}
@@ -301,6 +301,23 @@ sub WriteTerm {
next;
}
+ # reorder listing of ports in a vlan
+ if (/^ (?:un)?tagged ethe/) {
+ chomp;
+ s/^\s+//;
+ s/\s+$//;
+
+ my @list = split /\s+ethe\s+/, $_;
+ my $tagtype = shift @list;
+
+ while (@list) {
+ ProcessHistory("","","",
+ " $tagtype ethe " . (shift @list) . "\n");
+ }
+ next;
+ }
+
+
ProcessHistory("","","","$_");
# end of config
if (/^end$/) {
diff --git a/bin/hlogin.in b/bin/hlogin.in
index 6af11b4..a98e926 100644
--- a/bin/hlogin.in
+++ b/bin/hlogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: hlogin.in,v 1.21 2004/01/11 05:39:15 heas Exp $
+## $Id: hlogin.in,v 1.22 2004/02/02 17:38:36 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -47,7 +47,7 @@ set password_file $env(HOME)/.cloginrc
set do_command 0
set do_script 0
# The default is to automatically enable
-set enable 1
+set avenable 1
# The default is that you login non-enabled (tacacs can have you login already
# enabled)
set avautoenable 0
@@ -189,12 +189,12 @@ for {set i 0} {$i < $argc} {incr i} {
set do_command 1
# Do we enable?
} -noenable {
- set enable 0
+ set avenable 0
# Does tacacs automatically enable us?
} -autoenable {
# hp does not autoenable
#set autoenable 1
- #set enable 0
+ #set avenable 0
} -* {
send_user "\nError: Unknown argument! $arg\n"
send_user $usage
@@ -570,6 +570,7 @@ foreach router [lrange $argv $i end] {
set prompt "#"
} else {
set autoenable 0
+ set enable $avenable
set prompt ">"
}
}
diff --git a/bin/htlogin.in b/bin/htlogin.in
index 8e9c5f5..01de69c 100644
--- a/bin/htlogin.in
+++ b/bin/htlogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: htlogin.in,v 1.7 2004/01/11 05:39:15 heas Exp $
+## $Id: htlogin.in,v 1.8 2004/02/02 17:38:36 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -42,7 +42,7 @@ set password_file $env(HOME)/.cloginrc
set do_command 0
set do_script 0
# The default is to automatically enable
-set enable 1
+set avenable 1
# The default is that you login non-enabled (tacacs can have you login already
# enabled)
set avautoenable 0
diff --git a/bin/jlogin.in b/bin/jlogin.in
index 31be4f6..afa860e 100644
--- a/bin/jlogin.in
+++ b/bin/jlogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: jlogin.in,v 1.41 2004/01/11 05:39:15 heas Exp $
+## $Id: jlogin.in,v 1.46 2004/03/11 19:36:25 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -42,12 +42,10 @@ set password_file $env(HOME)/.cloginrc
set do_command 0
set do_script 0
# The default is to automatically enable
-set enable 1
+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
-# No passphrase by default
-set passphrase ""
# Find the user in the ENV, or use the unix userid.
if {[ info exists env(CISCO_USER) ] } {
@@ -112,7 +110,7 @@ for {set i 0} {$i < $argc} {incr i} {
-R* {
if {! [ regexp .\[rR\](.+) $arg ignore passphrase]} {
incr i
- set passphrase [ lindex $argv $i ]
+ set avpassphrase [ lindex $argv $i ]
}
# Expect script to run.
} -s* -
@@ -345,8 +343,12 @@ proc login { router user passwd cmethod cyphertype identfile} {
catch {close};
send_user "\nError: Unknown host\n"; wait; return 1
}
- -re "Enter passphrase for RSA key '\[^'\]*': " {
- send_user "\nKey has passphrase!\n"
+ "Login incorrect" {
+ send_user "\nError: Check your password for $router\n"
+ catch {close}; wait; return 1
+ }
+ -re "Enter passphrase.*: " {
+ # sleep briefly to allow time for stty -echo
sleep 1
send "$passphrase\r"
exp_continue }
@@ -465,10 +467,17 @@ foreach router [lrange $argv $i end] {
}
}
- # figure out identity file to use
- set identfile ""
- if {[info exists identity]} {
- set identfile [join [lindex [find identity $router] 0] ""]
+ # Figure out identity file to use
+ set identfile [join [lindex [find identity $router] 0] ""]
+
+ # Figure out passphrase to use
+ if {[info exists avpassphrase]} {
+ set passphrase $avpassphrase
+ } else {
+ set passphrase [join [lindex [find passphrase $router] 0] ""]
+ }
+ if { ! [string length "$passphrase"]} {
+ set passphrase $passwd
}
# Figure out ssh cypher type
diff --git a/bin/jrancid.in b/bin/jrancid.in
index 2793446..1217931 100644
--- a/bin/jrancid.in
+++ b/bin/jrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: jrancid.in,v 1.58 2004/01/11 03:49:13 heas Exp $
+## $Id: jrancid.in,v 1.59 2004/03/11 23:58:59 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -337,6 +337,7 @@ sub ShowChassisSCB {
sub ShowChassisAlarms {
print STDERR " In ShowChassisAlarms: $_" if ($debug);
+ s/^[a-z]+@//;
ProcessHistory("","","","# $_");
while (<INPUT>) {
tr/\015//d;
diff --git a/bin/lg.cgi.in b/bin/lg.cgi.in
index ad08c68..8b09847 100644
--- a/bin/lg.cgi.in
+++ b/bin/lg.cgi.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: lg.cgi.in,v 1.47 2004/01/11 03:49:13 heas Exp $
+## $Id: lg.cgi.in,v 1.50 2004/03/10 23:01:28 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -27,8 +27,8 @@
# vars: query, router, args
BEGIN {
-$me = $0;
-$me =~ s/.*\/(\S+)$/$1/;
+ $me = $0;
+ $me =~ s/.*\/(\S+)$/$1/;
}
use CGI qw/:standard escapeHTML/;
@@ -38,6 +38,7 @@ use LockFile::Simple qw(lock trylock unlock);
my($BASEDIR) = "@prefix@";
my($SYSCONFDIR) = "@sysconfdir@";
+my($LOCALSTATEDIR) = "@localstatedir@";
my($pingcmd) = "@LG_PING_CMD@";
my($query, $max_time_diff, $cache_dir, $cloginrc, @results);
@@ -134,23 +135,24 @@ sub readrouters
# if the router.db file does not exist, try to compile the list from
# the rancid group router.db files.
local(*DIR);
- if (! opendir(DIR, $BASEDIR)) {
- dolog(LOG_ERR, "ERROR: couldn\'t read $BASEDIR: $!\n");
+ if (! opendir(DIR, $LOCALSTATEDIR)) {
+ dolog(LOG_ERR, "ERROR: couldn\'t read $LOCALSTATEDIR: $!\n");
} else {
while ($dir = readdir(DIR)) {
- next if ($dir =~ /^(\.|\.\.|CVS|bin|etc|logs|util)$/);
- push(@dirs, $dir) if (-d "$BASEDIR/$dir");
+ next if ($dir =~ /^(\.|\.\.|\.ssh|CVS|bin|etc|logs|util)$/);
+ push(@dirs, $dir) if (-d "$LOCALSTATEDIR/$dir");
}
closedir(DIR);
foreach $dir (@dirs) {
- if (! opendir(DIR, "$BASEDIR/$dir")) {
- dolog(LOG_ERR, "ERROR: couldn\'t read $BASEDIR/$dir: $!\n");
+ if (! opendir(DIR, "$LOCALSTATEDIR/$dir")) {
+ dolog(LOG_ERR,
+ "ERROR: couldn\'t read $LOCALSTATEDIR/$dir: $!\n");
next;
}
closedir(DIR);
- next if (! -f "$BASEDIR/$dir/router.db");
- if (open(RTR, "< $BASEDIR/$dir/router.db")) {
+ next if (! -f "$LOCALSTATEDIR/$dir/router.db");
+ if (open(RTR, "< $LOCALSTATEDIR/$dir/router.db")) {
while (<RTR>) {
next if (/^\s*(#|$)/);
# fqdn:mfg:state
@@ -162,7 +164,7 @@ sub readrouters
close(RTR);
} else {
dolog(LOG_ERR, "ERROR: couldn\'t open the router.db " .
- "file: $BASEDIR/$dir/router.db: $!\n");
+ "file: $LOCALSTATEDIR/$dir/router.db: $!\n");
}
}
}
@@ -430,7 +432,7 @@ $max_lock_hold = 300;
if (defined($LG_CLOGINRC)) {
$cloginrc = $LG_CLOGINRC;
} else {
- $cloginrc = "$ENV(HOME)/.cloginrc";
+ $cloginrc = $ENV{HOME} . "/.cloginrc";
}
$query = new CGI;
diff --git a/bin/lgform.cgi.in b/bin/lgform.cgi.in
index 461ae68..f680a13 100644
--- a/bin/lgform.cgi.in
+++ b/bin/lgform.cgi.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: lgform.cgi.in,v 1.25 2004/01/11 03:49:13 heas Exp $
+## $Id: lgform.cgi.in,v 1.28 2004/03/10 22:41:54 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -26,11 +26,18 @@
# lgform.cgi - Looking glass front-end
# produces html form for calling lg.cgi
+BEGIN {
+ $me = $0;
+ $me =~ s/.*\/(\S+)$/$1/;
+}
+
use CGI qw/:standard/;
+use Sys::Syslog;
my(@rtrlist, %rtrlabels);
my($BASEDIR) = "@prefix@";
my($SYSCONFDIR) = "@sysconfdir@";
+my($LOCALSTATEDIR) = "@localstatedir@";
# note: the following functions are duplicated between lgform.cgi and lg.cgi
# to avoid the need for module inclusion headaches from within a httpd context.
@@ -118,23 +125,24 @@ sub readrouters
# if the router.db file does not exist, try to compile the list from
# the rancid group router.db files.
local(*DIR);
- if (! opendir(DIR, $BASEDIR)) {
- dolog(LOG_ERR, "ERROR: couldn\'t read $BASEDIR: $!\n");
+ if (! opendir(DIR, $LOCALSTATEDIR)) {
+ dolog(LOG_ERR, "ERROR: couldn\'t read $LOCALSTATEDIR: $!\n");
} else {
while ($dir = readdir(DIR)) {
- next if ($dir =~ /^(\.|\.\.|CVS|bin|etc|logs|util)$/);
- push(@dirs, $dir) if (-d "$BASEDIR/$dir");
+ next if ($dir =~ /^(\.|\.\.|\.ssh|CVS|bin|etc|logs|util)$/);
+ push(@dirs, $dir) if (-d "$LOCALSTATEDIR/$dir");
}
closedir(DIR);
foreach $dir (@dirs) {
- if (! opendir(DIR, "$BASEDIR/$dir")) {
- dolog(LOG_ERR, "ERROR: couldn\'t read $BASEDIR/$dir: $!\n");
+ if (! opendir(DIR, "$LOCALSTATEDIR/$dir")) {
+ dolog(LOG_ERR,
+ "ERROR: couldn\'t read $LOCALSTATEDIR/$dir: $!\n");
next;
}
closedir(DIR);
- next if (! -f "$BASEDIR/$dir/router.db");
- if (open(RTR, "< $BASEDIR/$dir/router.db")) {
+ next if (! -f "$LOCALSTATEDIR/$dir/router.db");
+ if (open(RTR, "< $LOCALSTATEDIR/$dir/router.db")) {
while (<RTR>) {
next if (/^\s*(#|$)/);
# fqdn:mfg:state
@@ -146,7 +154,7 @@ sub readrouters
close(RTR);
} else {
dolog(LOG_ERR, "ERROR: couldn\'t open the router.db " .
- "file: $BASEDIR/$dir/router.db: $!\n");
+ "file: $LOCALSTATEDIR/$dir/router.db: $!\n");
}
}
}
diff --git a/bin/nlogin.in b/bin/nlogin.in
index 685c759..9c6f8b8 100644
--- a/bin/nlogin.in
+++ b/bin/nlogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: nlogin.in,v 1.14 2004/01/11 05:39:15 heas Exp $
+## $Id: nlogin.in,v 1.15 2004/02/02 17:38:36 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -40,7 +40,7 @@ set password_file $env(HOME)/.cloginrc
set do_command 0
set do_script 0
# The default is to automatically enable
-set enable 0
+set avenable 0
# The default is that you login non-enabled (tacacs can have you login already
# enabled)
set avautoenable 1
diff --git a/bin/nslogin.in b/bin/nslogin.in
index 385f530..c4b8e8a 100644
--- a/bin/nslogin.in
+++ b/bin/nslogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: nslogin.in,v 1.10 2004/01/11 05:39:15 heas Exp $
+## $Id: nslogin.in,v 1.11 2004/02/02 17:38:36 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -49,7 +49,7 @@ set password_file $env(HOME)/.cloginrc
set do_command 1
set do_script 0
# The default is to automatically enable
-set enable 0
+set avenable 0
# The default is that you login non-enabled (tacacs can have you login already
# enabled)
set avautoenable 0
@@ -191,11 +191,11 @@ for {set i 0} {$i < $argc} {incr i} {
set do_command 1
# Do we enable?
} -noenable {
- set enable 0
+ set avenable 0
# Does tacacs automatically enable us?
} -autoenable {
set avautoenable 1
- set enable 0
+ set avenable 0
} -* {
send_user "\nError: Unknown argument! $arg\n"
send_user $usage
@@ -510,6 +510,8 @@ foreach router [lrange $argv $i end] {
# look for noenable option in .cloginrc
if { [find noenable $router] != "" } {
set enable 0
+ } else {
+ set enable $avenable
}
# Figure out passwords
diff --git a/bin/rancid-run.in b/bin/rancid-run.in
index b59b026..b09d8a0 100644
--- a/bin/rancid-run.in
+++ b/bin/rancid-run.in
@@ -1,6 +1,6 @@
#! /bin/sh
##
-## $Id: rancid-run.in,v 1.28 2004/01/11 06:11:23 hank Exp $
+## $Id: rancid-run.in,v 1.30 2004/03/12 23:17:28 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -88,49 +88,48 @@ fi
for GROUP in $LIST_OF_GROUPS
do
- LOCKFILE=$TMPDIR/.$GROUP.run.lock
-
- (
- echo starting: `date`
- echo
-
- if [ -f $LOCKFILE ]
- then
- echo hourly config diffs failed: $LOCKFILE exists
- ls -l $LOCKFILE
-
- # Send email if the lock file is old.
- if [ "X$LOCKTIME" = "X" ] ; then
- LOCKTIME=4
- fi
- @PERLV@ -e "\$t = (stat(\"$LOCKFILE\"))[9]; print \"OLD\\n\" if (time() - \$t >= $LOCKTIME*60*60);" > $TMPDIR/.$GROUP.old
- if [ -s $TMPDIR/.$GROUP.old ]
- then
- (
- echo "To: @ADMINMAILPLUS@$GROUP"
- echo "Subject: rancid hung - $GROUP"
- echo "Precedence: bulk"
- echo ""
-
- cat <<END
+ LOCKFILE=$TMPDIR/.$GROUP.run.lock
+
+ (
+ echo starting: `date`
+ echo
+
+ if [ -f $LOCKFILE ]
+ then
+ echo hourly config diffs failed: $LOCKFILE exists
+ ls -l $LOCKFILE
+
+ # Send email if the lock file is old.
+ if [ "X$LOCKTIME" = "X" ] ; then
+ LOCKTIME=4
+ fi
+ @PERLV@ -e "\$t = (stat(\"$LOCKFILE\"))[9]; print \"OLD\\n\" if (time() - \$t >= $LOCKTIME*60*60);" > $TMPDIR/.$GROUP.old
+ if [ -s $TMPDIR/.$GROUP.old ]
+ then
+ (
+ echo "To: @ADMINMAILPLUS@${GROUP}${MAILDOMAIN}"
+ echo "Subject: rancid hung - $GROUP"
+ echo "Precedence: bulk"
+ echo ""
+
+ cat <<END
rancid $GROUP hung on `hostname`? Old lockfile still exists:
`ls -l $LOCKFILE`
END
- ) | sendmail -t
- fi
- rm -f $TMPDIR/.$GROUP.old
-
- else
- trap 'rm -fr $LOCKFILE;exit 1' 1 2 3 6 10 15
- touch $LOCKFILE
- if [ $? -eq 0 ] ; then
- control_rancid $CR_ARGV $GROUP
- rm -f $LOCKFILE
- fi
- trap '' 1 2 3 6 10 15
- fi
-
- echo
- echo ending: `date`
- ) >$LOGDIR/$GROUP.`date +%Y%m%d.%H%M%S` 2>&1
+ ) | sendmail -t
+ fi
+ rm -f $TMPDIR/.$GROUP.old
+ else
+ trap 'rm -fr $LOCKFILE;exit 1' 1 2 3 6 10 15
+ touch $LOCKFILE
+ if [ $? -eq 0 ] ; then
+ control_rancid $CR_ARGV $GROUP
+ rm -f $LOCKFILE
+ fi
+ trap '' 1 2 3 6 10 15
+ fi
+
+ echo
+ echo ending: `date`
+ ) >$LOGDIR/$GROUP.`date +%Y%m%d.%H%M%S` 2>&1
done
diff --git a/bin/rancid.in b/bin/rancid.in
index 27a5a48..4bc83ef 100644
--- a/bin/rancid.in
+++ b/bin/rancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: rancid.in,v 1.168 2004/01/12 00:52:47 asp Exp $
+## $Id: rancid.in,v 1.172 2004/03/14 16:57:05 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -225,7 +225,17 @@ sub ShowVersion {
# incantations. for a slave, we dont get this info and its just a
# blank line.
$_ = <INPUT>;
- $_ = <INPUT> if (/processor board id/i);
+ if (/processor board id/i) {
+ my($sn);
+
+ if (/processor board id (\S+)/i) {
+ $sn = $1;
+ $sn =~ s/,$//;
+ ProcessHistory("COMMENTS","keysort","D9",
+ "!Processor ID: $sn\n");
+ }
+ $_ = <INPUT>;
+ }
$_ = "" if (! /(cpu at |processor: |$cpu processor,)/i);
tr/\015//d;
s/implementation/impl/i;
@@ -372,7 +382,6 @@ sub ShowIDprom {
/FRU is .(.*)\'/ && ($tmp = $1);
/Product Number = .(.*)\'/ &&
- ProcessHistory("COMMENTS","keysort","D0","!\n") &&
ProcessHistory("COMMENTS","keysort","D0",
"!Catalyst Chassis type: $1, $tmp\n");
/Serial Number = .([0-9A-Za-z]+)/ &&
@@ -461,7 +470,6 @@ sub ShowRSP {
/^$/ && next;
/^\s+Chassis model: (\S+)/ &&
- ProcessHistory("COMMENTS","keysort","D0","!\n") &&
ProcessHistory("COMMENTS","keysort","D1",
"!RSP Chassis model: $1\n") &&
next;
@@ -490,7 +498,6 @@ sub ShowGSR {
s/^<-+ More -+>\s*//;
/^$/ && next;
/^\s+Chassis: type (\S+) Fab Ver: (\S+)/ &&
- ProcessHistory("COMMENTS","keysort","D0","!\n") &&
ProcessHistory("COMMENTS","keysort","D1",
"!GSR Chassis type: $1 Fab Ver: $2\n") &&
next;
@@ -562,6 +569,7 @@ sub ShowFlash {
return(1) if /(Invalid input detected|Type help or )/;
# the pager can not be disabled per-session on the PIX
s/^<-+ More -+>\s*//;
+ /\s+vlan\.dat$/ && next;
ProcessHistory("FLASH","","","!Flash: $_");
}
ProcessHistory("","","","!\n");
@@ -880,6 +888,8 @@ sub ShowDiag {
$WIC = "/$2";
} elsif ($1 eq "WIC/VIC") {
$WIC = "/$2";
+ } elsif ($1 eq "DSP") {
+ $WIC = "/$2";
} elsif ($1 eq "Encryption AIM") {
$slot = "$2";
undef($WIC);
@@ -915,6 +925,15 @@ sub ShowDiag {
ProcessHistory("SLOT","keysort","B","!Slot $slot$WIC: type $_");
}
next;
+ } elsif (/^\s+(.* (DSP) Module) Slot (\d):/) {
+ # The 1760 (at least) has yet another format...where it has two
+ # dedicated DSP slots, and thus two slot 0s.
+ my($TYPE) = $1;
+ $WIC = "/$3";
+ ProcessHistory("SLOT","","","!\n");
+ ProcessHistory("SLOT","keysort","B",
+ "!Slot $slot$WIC: type $TYPE\n");
+ next;
}
# yet another format. seen on 2600s w/ 12.1, but appears to be all
# 12.1, including 7200s & 3700s. Sometimes the PCB serial appears
@@ -929,7 +948,7 @@ sub ShowDiag {
while (<INPUT>) {
tr/\015//d;
- if (/0x..: /) {
+ if (/0x..: / || /^$/) {
# no effing idea why break does not work there
goto PerlSucks;
}
@@ -1531,6 +1550,7 @@ if ($ENV{"FILTER_PWDS"} =~ /no/i) {
ProcessHistory("","","","!RANCID-CONTENT-TYPE: cisco\n!\n");
ProcessHistory("COMMENTS","keysort","B0","!\n");
+ProcessHistory("COMMENTS","keysort","D0","!\n");
ProcessHistory("COMMENTS","keysort","F0","!\n");
ProcessHistory("COMMENTS","keysort","G0","!\n");
TOP: while(<INPUT>) {
diff --git a/bin/rivlogin.in b/bin/rivlogin.in
index 12554d5..4468fff 100644
--- a/bin/rivlogin.in
+++ b/bin/rivlogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: rivlogin.in,v 1.15 2004/01/11 05:39:15 heas Exp $
+## $Id: rivlogin.in,v 1.17 2004/02/02 17:38:36 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -60,7 +60,7 @@ set do_script 0
set log_user 0
# The default CLI mode to login to is "enable" mode
-set enable 1
+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.
@@ -839,7 +839,7 @@ for {set idx 0} {$idx < $argc} {incr idx} {
set timeout [ lindex $argv $idx ]
} -noenable {
- set enable 0
+ set avenable 0
} -* {
puts "ERROR:unkown argument passed: $arg\n"
puts $usage
@@ -863,142 +863,133 @@ if { $idx == $argc } {
foreach router [lrange $argv $idx end] {
set router [string tolower $router]
-# Figure out passwords
-if {$verbose == 1} {
- puts "DEBUG: do_passwd = $do_passwd\n"
- puts "DEBUG: do_enablepasswd = $do_enapasswd\n"
-}
-
-if { $do_passwd || $do_enapasswd } {
- set pswd [find password $router]
- if { [llength $pswd] == 0 } {
- puts "ERROR: - no password for $router in $password_file.\n"
- exit 1
- }
- if { $do_enapasswd && [llength $pswd] < 2 } {
- puts "ERROR: no enable password found for $router in $password_file."
- exit 1
+ # Figure out passwords
+ if {$verbose == 1} {
+ puts "DEBUG: do_passwd = $do_passwd\n"
+ puts "DEBUG: do_enablepasswd = $do_enapasswd\n"
}
-
- set passwd [join [lindex $pswd 0] ""]
- set enapasswd [join [lindex $pswd 1] ""]
-}
-
-
-# Figure out user to login with if necessary
-
-if {[info exists username]} {
- # command line username
- set user $username
-} else {
- set user [join [find user $router] ""]
- if { "$user" == "" } { set user $default_user }
-}
-
-# Figure out username's password
-
-if {[info exists userpasswd]} {
- # command line username
- set userpswd $userpasswd
-} else {
- set userpswd [join [find userpassword $router] ""]
- if { "$userpswd" == "" } { set userpswd $passwd }
-}
-
-# Figure out enable username
-if {[info exists enausername]} {
- # command line enausername
- set enauser $enausername
-} else {
- set enauser [join [find enauser $router] ""]
- if { "$enauser" == "" } { set enauser $user }
-}
-
-# Login to the router, set my_prompt to router's cmd prompt
+ # look for noenable option in .cloginrc
+ if { [find noenable $router] != "" } {
+ set enable 0
+ } else {
+ set enable $avenable
+ }
-if {[login $router $user $userpswd $passwd $enapasswd ]} {
- if { $verbose == 1 } {
- puts "DEBUG: login to $router failed\n"
+ if { $do_passwd || $do_enapasswd } {
+ set pswd [find password $router]
+ if { [llength $pswd] == 0 } {
+ puts "ERROR: - no password for $router in $password_file.\n"
+ exit 1
+ }
+ if { $do_enapasswd && [llength $pswd] < 2 } {
+ puts "ERROR: no enable password found for $router in $password_file."
+ exit 1
+ }
+
+ set passwd [join [lindex $pswd 0] ""]
+ set enapasswd [join [lindex $pswd 1] ""]
}
- exit 1
-}
-if {$verbose == 1 } {
- puts "DEBUG: login completed ok\n"
-}
+ # Figure out user to login with if necessary
+ if {[info exists username]} {
+ # command line username
+ set user $username
+ } else {
+ set user [join [find user $router] ""]
+ if { "$user" == "" } { set user $default_user }
+ }
-if { $enable == 1 } {
+ # Figure out username's password
+ if {[info exists userpasswd]} {
+ # command line username
+ set userpswd $userpasswd
+ } else {
+ set userpswd [join [find userpassword $router] ""]
+ if { "$userpswd" == "" } { set userpswd $passwd }
+ }
- if { [do_enable $enauser $enapasswd $userpswd] == 1} {
+ # Figure out enable username
+ if {[info exists enausername]} {
+ # command line enausername
+ set enauser $enausername
+ } else {
+ set enauser [join [find enauser $router] ""]
+ if { "$enauser" == "" } { set enauser $user }
+ }
+
+ # Login to the router, set my_prompt to router's cmd prompt
+ if {[login $router $user $userpswd $passwd $enapasswd ]} {
if { $verbose == 1 } {
- puts "DEBUG: switch to enable mode on $router failed\n"
+ puts "DEBUG: login to $router failed\n"
}
exit 1
}
-}
-
-# run in one of three modes
-
-if { $do_command } {
- disable_cmd_autocomplete
- disable_cli_paging
-
- if {[ start_logfile $output_file] != 0 } {
- exit 1
+ if {$verbose == 1 } {
+ puts "DEBUG: login completed ok\n"
}
- if {[ run_commands $my_prompt $command ]} {
-
- log_file
- exit 1
-
- } else {
-
- logout $my_prompt
-
+ if { $enable == 1 } {
+ if { [do_enable $enauser $enapasswd $userpswd] == 1} {
+ if { $verbose == 1 } {
+ puts "DEBUG: switch to enable mode on $router failed\n"
+ }
+ exit 1
+ }
}
+
+ # run in one of three modes
+ if { $do_command } {
+ disable_cmd_autocomplete
+ disable_cli_paging
-} elseif { $do_script } {
-
- disable_cmd_autocomplete
- disable_cli_paging
-
- if {[ start_logfile $output_file] != 0 } {
- exit 1
- }
+ if { [start_logfile $output_file] != 0 } {
+ exit 1
+ }
- #if { [process_script_file $sfile] == 1} {
-# puts "DEBUG: logfile $output_file closed on error\n"
-# logout $my_prompt
-# exit 1
-# }
+ if {[ run_commands $my_prompt $command ]} {
+ log_file
+ exit 1
+ } else {
+ logout $my_prompt
+ }
+ } elseif { $do_script } {
+ disable_cmd_autocomplete
+ disable_cli_paging
+
+ if {[ start_logfile $output_file] != 0 } {
+ exit 1
+ }
- source_script_file $sfile
+# if { [process_script_file $sfile] == 1} {
+# puts "DEBUG: logfile $output_file closed on error\n"
+# logout $my_prompt
+# exit 1
+# }
- logout $my_prompt
+ source_script_file $sfile
-} else {
-
- label $router
- log_user 1
+ logout $my_prompt
+ } else {
+ label $router
+ log_user 1
- if {[ start_logfile $output_file] != 0 } {
- exit 1
+ if {[ start_logfile $output_file] != 0 } {
+ exit 1
+ }
+ interact
+ log_file
}
- interact
- log_file
-}
-if { $verbose == 1 } {
- puts "DEBUG: exiting normally.\n"
-}
+ if { $verbose == 1 } {
+ puts "DEBUG: exiting normally.\n"
+ }
-if { $logging == 1} {
- log_file
- strip_log $output_file $router
-}
+ if { $logging == 1} {
+ log_file
+ strip_log $output_file $router
+ }
}
# puts "\n"
diff --git a/bin/tntlogin.in b/bin/tntlogin.in
index 021f0d2..2eae6e3 100644
--- a/bin/tntlogin.in
+++ b/bin/tntlogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: tntlogin.in,v 1.11 2004/01/11 05:39:15 heas Exp $
+## $Id: tntlogin.in,v 1.12 2004/02/02 17:38:36 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -39,7 +39,7 @@ set password_file $env(HOME)/.cloginrc
set do_command 0
set do_script 0
# The default is to automatically enable
-set enable 0
+set avenable 0
# The default is that you login non-enabled (tacacs can have you login already
# enabled)
set avautoenable 1
diff --git a/bin/xrancid.in b/bin/xrancid.in
index 4aeb1d3..b415c86 100644
--- a/bin/xrancid.in
+++ b/bin/xrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: xrancid.in,v 1.32 2004/01/11 03:49:13 heas Exp $
+## $Id: xrancid.in,v 1.33 2004/01/13 01:56:50 asp Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -180,7 +180,7 @@ sub ShowMemory {
return(0);
}
-# This routine parses "show diagnostics"
+# This routine parses "show diag"
sub ShowDiag {
print STDERR " In ShowDiag: $_" if ($debug);
@@ -376,7 +376,7 @@ sub DoNothing {print STDOUT;}
%commands=(
'show version' => "ShowVersion",
'show memory' => "ShowMemory",
- 'show diagnostics' => "ShowDiag",
+ 'show diag' => "ShowDiag",
'show switch' => "ShowSwitch",
'show slot' => "ShowSlot",
'show configuration detail' => "WriteTerm",
@@ -387,7 +387,7 @@ sub DoNothing {print STDOUT;}
@commands=(
"show version",
"show memory",
- "show diagnostics",
+ "show diag",
"show switch",
"show slot",
"show configuration detail",