From b73f299e731fbddae095c0b5eff04717b6dce1af Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Feb 2008 20:34:57 +0000 Subject: Imported from rancid-2.3.2a8.tar.gz. --- bin/jrancid.in | 85 +++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 19 deletions(-) (limited to 'bin/jrancid.in') diff --git a/bin/jrancid.in b/bin/jrancid.in index 252b1a3..309cef9 100644 --- a/bin/jrancid.in +++ b/bin/jrancid.in @@ -1,25 +1,45 @@ #! @PERLV_PATH@ ## -## $Id: jrancid.in,v 1.80 2006/12/05 17:14:27 heas Exp $ +## $Id$ ## ## @PACKAGE@ @VERSION@ -## Copyright (C) 1997-2006 by Terrapin Communications, Inc. +## Copyright (c) 1997-2007 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. +## 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. ## -## Except where noted otherwise, rancid was written by and is maintained by -## Henry Kilmer, John Heasley, Andrew Partan, Pete Whiting, and Austin Schutz. -## -# +## 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. +# # Amazingly hacked version of Hank's rancid - this one tries to # deal with Junipers. # @@ -43,7 +63,9 @@ $found_end = 0; $timeo = 120; # clogin timeout in seconds my(@commandtable, %commands, @commands);# command lists -my(%filter_pwds); # password filtering mode +my($aclsort) = ("ipsort"); # ACL sorting mode +my($filter_commstr); # SNMP community string filtering +my($filter_pwds); # password filtering mode my($ShowChassisSCB); # Only run ShowChassisSCB() once # This routine is used to print out the router configuration @@ -181,6 +203,11 @@ sub ShowChassisClocks { $x = sprintf(" MHz%".length($2)."s", " "); substr($_, $leadlen, length($2)+4, $x); } + # filter timestamps + next if (/selected for/i); + next if (/selected since/i); + + next if (/deviation/i); ProcessHistory("","","","# $_"); } return(0); @@ -195,6 +222,7 @@ sub ShowChassisEnvironment { while () { tr/\015//d; last if (/^$prompt/); + return 1 if (/^aborted!/i); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup)}/); @@ -228,6 +256,7 @@ sub ShowChassisFirmware { while () { tr/\015//d; last if (/^$prompt/); + return 1 if (/^aborted!/i); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup)}/); @@ -252,6 +281,7 @@ sub ShowChassisFpcDetail { while () { tr/\015//d; last if (/^$prompt/); + return 1 if (/^aborted!/i); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup)}/); @@ -279,6 +309,7 @@ sub ShowChassisHardware { while () { tr/\015//d; last if (/^$prompt/); + return 1 if (/^aborted!/i); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup)}/); @@ -547,7 +578,7 @@ sub ShowConfiguration { /^snmp/ && $snmp++; /^}/ && ($snmp = 0); if ($snmp && /^(\s*)(community|trap-group) [^ ;]+(\s?[;{])$/) { - if (defined($ENV{'NOCOMMSTR'})) { + if ($filter_commstr) { $_ = "$1$2 \"\"$3\n"; } } @@ -563,6 +594,11 @@ sub ShowConfiguration { ProcessHistory("","","","#$1$'"); next; } + # don't filter this one - there is no secret here. + if (/^\s*permissions .* secret /) { + ProcessHistory("","","","$_"); + next; + } if (/^(.*\ssecret )[^ ;]+/ && $filter_pwds >= 1) { ProcessHistory("","","","#$1$'"); next; @@ -660,13 +696,24 @@ if ($file) { } +# determine ACL sorting mode +if ($ENV{"ACLSORT"} =~ /no/i) { + $aclsort = ""; +} +# determine community string filtering mode +if (defined($ENV{"NOCOMMSTR"}) && + ($ENV{"NOCOMMSTR"} =~ /yes/i || $ENV{"NOCOMMSTR"} =~ /^$/)) { + $filter_commstr = 1; +} else { + $filter_commstr = 0; +} # determine password filtering mode if ($ENV{"FILTER_PWDS"} =~ /no/i) { - $filter_pwds = 0; + $filter_pwds = 0; } elsif ($ENV{"FILTER_PWDS"} =~ /all/i) { - $filter_pwds = 2; + $filter_pwds = 2; } else { - $filter_pwds = 1; + $filter_pwds = 1; } ProcessHistory("","","","# RANCID-CONTENT-TYPE: juniper\n#\n"); -- cgit