summaryrefslogtreecommitdiffstats
path: root/bin/rancid.in
diff options
context:
space:
mode:
Diffstat (limited to 'bin/rancid.in')
-rw-r--r--bin/rancid.in215
1 files changed, 81 insertions, 134 deletions
diff --git a/bin/rancid.in b/bin/rancid.in
index 0841594..915be60 100644
--- a/bin/rancid.in
+++ b/bin/rancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: rancid.in,v 1.185 2005/03/29 23:38:41 heas Exp $
+## $Id: rancid.in,v 1.190 2005/06/24 16:07:00 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -34,15 +34,16 @@ $found_end = 0;
$found_version = 0;
$found_env = 0;
$found_diag = 0;
-$timeo = 90; # clogin timeout in seconds
+$timeo = 90; # clogin timeout in seconds
-my(%filter_pwds); # password filtering mode
+my(@commandtable, %commands, @commands);# command lists
+my(%filter_pwds); # password filtering mode
# This routine is used to print out the router configuration
sub ProcessHistory {
- my($new_hist_tag,$new_command,$command_string,@string)=(@_);
- if((($new_hist_tag ne $hist_tag) || ($new_command ne $command))
- && defined %history) {
+ my($new_hist_tag,$new_command,$command_string,@string) = (@_);
+ if ((($new_hist_tag ne $hist_tag) || ($new_command ne $command))
+ && defined %history) {
print eval "$command \%history";
undef %history;
}
@@ -64,10 +65,10 @@ sub ProcessHistory {
sub numerically { $a <=> $b; }
-# This is a sort routing that will sort numerically on the
+# This is a sort routine that will sort numerically on the
# keys of a hash as if it were a normal array.
sub keynsort {
- local(%lines)=@_;
+ local(%lines) = @_;
local($i) = 0;
local(@sorted_lines);
foreach $key (sort numerically keys(%lines)) {
@@ -77,10 +78,10 @@ sub keynsort {
@sorted_lines;
}
-# This is a sort routing that will sort on the
+# This is a sort routine that will sort on the
# keys of a hash as if it were a normal array.
sub keysort {
- local(%lines)=@_;
+ local(%lines) = @_;
local($i) = 0;
local(@sorted_lines);
foreach $key (sort keys(%lines)) {
@@ -90,10 +91,10 @@ sub keysort {
@sorted_lines;
}
-# This is a sort routing that will sort on the
+# This is a sort routine that will sort on the
# values of a hash as if it were a normal array.
sub valsort{
- local(%lines)=@_;
+ local(%lines) = @_;
local($i) = 0;
local(@sorted_lines);
foreach $key (sort values %lines) {
@@ -103,9 +104,9 @@ sub valsort{
@sorted_lines;
}
-# This is a numerical sort routing (ascending).
+# This is a numerical sort routine (ascending).
sub numsort {
- local(%lines)=@_;
+ local(%lines) = @_;
local($i) = 0;
local(@sorted_lines);
foreach $num (sort {$a <=> $b} keys %lines) {
@@ -119,7 +120,7 @@ sub numsort {
# ip address when the ip address is anywhere in
# the strings.
sub ipsort {
- local(%lines)=@_;
+ local(%lines) = @_;
local($i) = 0;
local(@sorted_lines);
foreach $addr (sort sortbyipaddr keys %lines) {
@@ -132,7 +133,7 @@ sub ipsort {
# These two routines will sort based upon IP addresses
sub ipaddrval {
my(@a) = ($_[0] =~ m#^(\d+)\.(\d+)\.(\d+)\.(\d+)$#);
- $a[3]+256*($a[2]+256*($a[1]+256*$a[0]));
+ $a[3] + 256 * ($a[2] + 256 * ($a[1] +256 * $a[0]));
}
sub sortbyipaddr {
&ipaddrval($a) <=> &ipaddrval($b);
@@ -1235,8 +1236,8 @@ sub WriteTerm {
$lineauto = 1 if /^ modem auto/;
/^ speed / && $lineauto && next; # kill speed on serial lines
/^ clockrate / && next; # kill clockrate on serial interfaces
- if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) {
- ProcessHistory("ENABLE","","","!$1$2 <removed>\n");
+ if (/^(enable )?(password|passwd)( level \d+)? / && $filter_pwds >= 1) {
+ ProcessHistory("ENABLE","","","!$1$2$3 <removed>\n");
next;
}
if (/^(enable secret) / && $filter_pwds >= 2) {
@@ -1315,7 +1316,7 @@ sub WriteTerm {
ProcessHistory("","","","!$1 <removed> $'"); next;
}
# filter HSRP passwords
- if (/^(\s+standby \d authentication) / && $filter_pwds >= 1) {
+ if (/^(\s+standby \d+ authentication) / && $filter_pwds >= 1) {
ProcessHistory("","","","!$1 <removed>\n"); next;
}
# this appears in "measurement/sla" images
@@ -1499,122 +1500,68 @@ sub WriteTerm {
sub DoNothing {print STDOUT;}
# Main
-%commands=(
- 'admin show version' => "ShowVersion",
- 'show version' => "ShowVersion",
- 'show redundancy secondary' => "ShowRedundancy",
- 'show idprom backplane', => "ShowIDprom",
- 'show install active' => "ShowInstallActive",
- 'admin show env all' => "ShowEnv",
- 'show env all' => "ShowEnv",
- 'show rsp chassis-info',=> "ShowRSP",
- 'show gsr chassis' => "ShowGSR",
- 'show boot' => "ShowBoot",
- 'show bootvar' => "ShowBoot",
- 'show variables boot' => "ShowBoot",
- 'show flash' => "ShowFlash",
- 'dir /all nvram:' => "DirSlotN",
- 'dir /all bootflash:' => "DirSlotN",
- 'dir /all slot0:' => "DirSlotN",
- 'dir /all disk0:' => "DirSlotN",
- 'dir /all slot1:' => "DirSlotN",
- 'dir /all disk1:' => "DirSlotN",
- 'dir /all slot2:' => "DirSlotN",
- 'dir /all disk2:' => "DirSlotN",
- 'dir /all harddisk:' => "DirSlotN",
- 'dir /all harddiska:' => "DirSlotN",
- 'dir /all harddiskb:' => "DirSlotN",
- "dir /all sup-bootflash:"=> "DirSlotN", # cat 6500-ios
- "dir /all sup-microcode:"=> "DirSlotN", # cat 6500-ios
- 'dir /all slavenvram:' => "DirSlotN",
- 'dir /all slavebootflash:' => "DirSlotN",
- 'dir /all slaveslot0:' => "DirSlotN",
- 'dir /all slavedisk0:' => "DirSlotN",
- 'dir /all slaveslot1:' => "DirSlotN",
- 'dir /all slavedisk1:' => "DirSlotN",
- 'dir /all slaveslot2:' => "DirSlotN",
- 'dir /all slavedisk2:' => "DirSlotN",
- "dir /all slavesup-bootflash:"=> "DirSlotN", # cat 7609
- 'dir /all sec-nvram:' => "DirSlotN",
- 'dir /all sec-bootflash:' => "DirSlotN",
- 'dir /all sec-slot0:' => "DirSlotN",
- 'dir /all sec-disk0:' => "DirSlotN",
- 'dir /all sec-slot1:' => "DirSlotN",
- 'dir /all sec-disk1:' => "DirSlotN",
- 'dir /all sec-slot2:' => "DirSlotN",
- 'dir /all sec-disk2:' => "DirSlotN",
- 'show controllers' => "ShowContAll",
- 'show controllers cbus' => "ShowContCbus",
- 'show diagbus' => "ShowDiagbus",
- 'admin show diag' => "ShowDiag",
- 'show diag' => "ShowDiag",
- 'show module' => "ShowModule", # cat 6500-ios
- 'show spe version' => "ShowSpeVersion",
- 'show c7200' => "ShowC7200",
- 'show vtp status' => "ShowVTP",
- 'show vlan' => "ShowVLAN",
- 'show running-config' => "WriteTerm",
- 'write term' => "WriteTerm"
-);
-# keys() doesnt return things in the order entered and the order of the
-# cmds is important (show version first and write term last). pita
-@commands=(
- "admin show version",
- "show version",
- "show redundancy secondary",
- "show idprom backplane",
- "show install active",
- "admin show env all",
- "show env all",
- "show rsp chassis-info",
- "show gsr chassis",
- "show boot",
- "show bootvar",
- "show variables boot",
- "show flash",
- "dir /all nvram:",
- "dir /all bootflash:",
- "dir /all slot0:",
- "dir /all disk0:",
- "dir /all slot1:",
- "dir /all disk1:",
- "dir /all slot2:",
- "dir /all disk2:",
- "dir /all harddisk:",
- "dir /all harddiska:",
- "dir /all harddiskb:",
- "dir /all sup-bootflash:",
- "dir /all sup-microcode:",
- "dir /all slavenvram:",
- "dir /all slavebootflash:",
- "dir /all slaveslot0:",
- "dir /all slavedisk0:",
- "dir /all slaveslot1:",
- "dir /all slavedisk1:",
- "dir /all slaveslot2:",
- "dir /all slavedisk2:",
- "dir /all slavesup-bootflash:",
- "dir /all sec-nvram:",
- "dir /all sec-bootflash:",
- "dir /all sec-slot0:",
- "dir /all sec-disk0:",
- "dir /all sec-slot1:",
- "dir /all sec-disk1:",
- "dir /all sec-slot2:",
- "dir /all sec-disk2:",
- "show controllers",
- "show controllers cbus",
- "show diagbus",
- "admin show diag",
- "show diag",
- "show module",
- "show spe version",
- "show c7200",
- "show vtp status",
- "show vlan",
- "show running-config",
- "write term"
+@commandtable = (
+ {'admin show version' => 'ShowVersion'},
+ {'show version' => 'ShowVersion'},
+ {'show redundancy secondary' => 'ShowRedundancy'},
+ {'show idprom backplane', => 'ShowIDprom'},
+ {'show install active' => 'ShowInstallActive'},
+ {'admin show env all' => 'ShowEnv'},
+ {'show env all' => 'ShowEnv'},
+ {'show rsp chassis-info', => 'ShowRSP'},
+ {'show gsr chassis' => 'ShowGSR'},
+ {'show boot' => 'ShowBoot'},
+ {'show bootvar' => 'ShowBoot'},
+ {'show variables boot' => 'ShowBoot'},
+ {'show flash' => 'ShowFlash'},
+ {'dir /all nvram:' => 'DirSlotN'},
+ {'dir /all bootflash:' => 'DirSlotN'},
+ {'dir /all slot0:' => 'DirSlotN'},
+ {'dir /all disk0:' => 'DirSlotN'},
+ {'dir /all slot1:' => 'DirSlotN'},
+ {'dir /all disk1:' => 'DirSlotN'},
+ {'dir /all slot2:' => 'DirSlotN'},
+ {'dir /all disk2:' => 'DirSlotN'},
+ {'dir /all harddisk:' => 'DirSlotN'},
+ {'dir /all harddiska:' => 'DirSlotN'},
+ {'dir /all harddiskb:' => 'DirSlotN'},
+ {'dir /all sup-bootflash:' => 'DirSlotN'}, # cat 6500-ios
+ {'dir /all sup-microcode:' => 'DirSlotN'}, # cat 6500-ios
+ {'dir /all slavenvram:' => 'DirSlotN'},
+ {'dir /all slavebootflash:' => 'DirSlotN'},
+ {'dir /all slaveslot0:' => 'DirSlotN'},
+ {'dir /all slavedisk0:' => 'DirSlotN'},
+ {'dir /all slaveslot1:' => 'DirSlotN'},
+ {'dir /all slavedisk1:' => 'DirSlotN'},
+ {'dir /all slaveslot2:' => 'DirSlotN'},
+ {'dir /all slavedisk2:' => 'DirSlotN'},
+ {'dir /all slavesup-bootflash:' => 'DirSlotN'}, # cat 7609
+ {'dir /all sec-nvram:' => 'DirSlotN'},
+ {'dir /all sec-bootflash:' => 'DirSlotN'},
+ {'dir /all sec-slot0:' => 'DirSlotN'},
+ {'dir /all sec-disk0:' => 'DirSlotN'},
+ {'dir /all sec-slot1:' => 'DirSlotN'},
+ {'dir /all sec-disk1:' => 'DirSlotN'},
+ {'dir /all sec-slot2:' => 'DirSlotN'},
+ {'dir /all sec-disk2:' => 'DirSlotN'},
+ {'show controllers' => 'ShowContAll'},
+ {'show controllers cbus' => 'ShowContCbus'},
+ {'show diagbus' => 'ShowDiagbus'},
+ {'admin show diag' => 'ShowDiag'},
+ {'show diag' => 'ShowDiag'},
+ {'show module' => 'ShowModule'}, # cat 6500-ios
+ {'show spe version' => 'ShowSpeVersion'},
+ {'show c7200' => 'ShowC7200'},
+ {'show vtp status' => 'ShowVTP'},
+ {'show vlan' => 'ShowVLAN'},
+ {'show running-config' => 'WriteTerm'},
+ {'write term' => 'WriteTerm'},
);
+# Use an array to preserve the order of the commands and a hash for mapping
+# commands to the subroutine and track commands that have been completed.
+@commands = map(keys(%$_), @commandtable);
+%commands = map(%$_, @commandtable);
+
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);