rancid-3.13/000755 015615 000000 00000000000 13735706334 012771 5ustar00heaswheel000000 000000 rancid-3.13/UPGRADING000644 015615 000000 00000014470 13533567552 014245 0ustar00heaswheel000000 000000 RANCiD 2.3 to >2.3 Assuming that no other specifics in the sections below apply to your installation or environment, then upgrades should be straight-forward. - review the CHANGES file for anything that may affect you, - backup your current installation, - optionally disable rancid's cron jobs and waiting for running collections to finish. - follow the quick installation instructions in the README, using the same arguments to configure that were used for the previous version (if any), and installing the new directly over the previous. - it may be necessary to merge new .conf files (rancd.conf, lg.conf, rancid.types.conf) with the existing files, which will not have been over-written. - re-enable rancid's cron jobs RANCiD 3.2 3.2 includes support for the git SCM. It is based on the patch from Jeffrey C. Ollie. However, unlike the patch, which places all of the rancid collections into one repository rooted at rancid.conf:$BASEDIR, we've chosen to use separate respositories as remote located in rancid.conf:$BASEDIR. This allows the code to be the same whether the master repository is local or remote and allows each to be in a different location and autonomous. Also see rancid-cvs(1). We do not want to instruct or help convert between SCMs; that is better left to those that provide the tools that do the conversion. But, a few notes for a starting point: CVS to SVN: % su - rancid % cvs2svn -s `pwd`/.svn `pwd`/CVS/ Now update the RCSSYS and CVSROOT variables in rancid.conf. SVN to GIT: cvs to git did not work well; so recommend cvs to svn to git. So, assuming that your CVSROOT is ~/.svn from the conversion of cvs to svn, convert to git as follows. If you began with svn, then your CVSROOT is probably ~/CVS. % su - rancid % cat > authors< rancid = rancid EOF % mkdir .scm tmp % cd tmp % git init --bare `pwd`/.git If you have more than one group, you must separate separate the groups into individual git repositories: ~rancid/.scm/ etc. You must --exclude the other groups as you convert each one. % svn2git file://`echo ~`/.svn --notags --nobranches --authors \ ~/authors % mv .git ~/.scm/ Now update the RCSSYS and CVSROOT variables in rancid.conf. Please do not ask us for help with these tools. Also see https://github.com/svn-all-fast-export/svn2git. RANCiD 3.0 3.0 requires minimum revisions of perl 5.10 and expect 5.43. The router.db field separator has been changed to ';' from ':' to avoid conflict with IPv6 addresses and etc. 3.0 also introduces perl libraries for device O/S specific handling and replaces the individual rancid scripts with rancid which imports the libraries. Also, rancid.pm supplies the functions common among the former rancid scripts. RANCiD 2.3 introduces a new directory layout. It has been changed to more closely follow the standard path hierarchy, which is defined by the FHS standard and autoconf, and/or make these locations more easily configurable within rancid. The obvious advantage of this is making rancid more easily packagable; i.e.: NetBSD pkgsrc, FreeBSD port, Linux RPM, etc. Make sure your rancid repository is quiet before upgrading; disable rancid cron jobs, wait for running jobs to complete, etc. Autoconf defines the following (see configure --help): Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [/usr/local/rancid] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --mandir=DIR man documentation [PREFIX/man] Also defined, though not mentioned above, is: pkgdatadir same as datadir, but datadir/rancid File and directory movement: bin/env the rancid configuration file has moved to sysconfdir/rancid.conf util/lg/lg.conf the looking glass configuration has moved to sysconfdir/lg.conf util/lg/lg.cgi util/lg/lgform.cgi the looking glass CGI scripts have moved to bindir util/lg/* the remainder of looking glass html, README, etc files have moved to pkgdatadir util/* misc examples, scripts, etc have moved to pkgdatadir cloginrc.sample moved to pkgdatadir For those upgrading, there is one basic choice to make; to move your CVS repository and logs or not. Prior to rancid 2.3, these were placed in . They are now in "localstatedir". The user who runs rancid will need write access to this directory. To maintain the same location as was used prior to rancid 2.3, provide the --localstatedir option to configure. e.g.: ./configure --localstatedir=/usr/local/rancid /usr/local/rancid is, and has been, the default . To move them elsewhere, accept the default (e.g.: /usr/local/rancid/var) or specify your own and move the existing directories. e.g.: ./configure --localstatedir=/var/rancid make install edit /rancid.conf # merge with your old bin/env # configuration file mv /usr/local/rancid/logs /var/rancid mv /usr/local/rancid/CVS /var/rancid cd /var/rancid su - rancid_user /bin/sh . /rancid.conf for grp in $LIST_OF_GROUPS; do cvs -d /var/rancid/CVS co $grp done Note that the first rancid-run will send messages about routers being added, marked up or down, etc., because the routers.{all,down,up} will have been lost. Afterward, it will be back to normal. Note also that any non-rancid files that may have been placed in these CVS trees will be lost. You have been warned. *** We strongly suggest that if a DIR used as the install prefix, as in --prefix=DIR, is not dedicated to rancid that "/rancid" should be appended to the --localstatedir, as in the example above. Note that not all operating systems have a mv command that will move directories across file systems. It may be necessary to use 'cp -r' or 'tar cf - | (cd ; tar xpf -)'. rancid-3.13/aclocal.m4000644 015615 000000 00000125273 13735672072 014644 0ustar00heaswheel000000 000000 # generated automatically by aclocal 1.16.2 -*- Autoconf -*- # Copyright (C) 1996-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # Copyright (C) 2002-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.16.2], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.16.2])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. AS_CASE([$CONFIG_FILES], [*\'*], [eval set x "$CONFIG_FILES"], [*], [set x $CONFIG_FILES]) shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`AS_DIRNAME(["$am_mf"])` am_filepart=`AS_BASENAME(["$am_mf"])` AM_RUN_LOG([cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles]) || am_rc=$? done if test $am_rc -ne 0; then AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments for automatic dependency tracking. If GNU make was not used, consider re-running the configure script with MAKE="gmake" (or whatever is necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking).]) fi AS_UNSET([am_dirpart]) AS_UNSET([am_filepart]) AS_UNSET([am_mf]) AS_UNSET([am_rc]) rm -f conftest-deps.mk } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking is enabled. # This creates each '.Po' and '.Plo' makefile fragment that we'll need in # order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering # Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. # Default is to disable them, unless 'enable' is passed literally. # For symmetry, 'disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), [enable], [m4_define([am_maintainer_other], [disable])], [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], am_maintainer_other[ make rules and dependencies not useful (and sometimes confusing) to the casual installer])], [USE_MAINTAINER_MODE=$enableval], [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE AC_SUBST([MAINT])dnl ] ) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check whether make has an 'include' directive that can support all # the idioms we need for our automatic dependency tracking code. AC_DEFUN([AM_MAKE_INCLUDE], [AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) AS_CASE([$?:`cat confinc.out 2>/dev/null`], ['0:this is the am__doit target'], [AS_CASE([$s], [BSD], [am__include='.include' am__quote='"'], [am__include='include' am__quote=''])]) if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* AC_MSG_RESULT([${_am_result}]) AC_SUBST([am__include])]) AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([acinclude.m4]) rancid-3.13/configure.vers000755 015615 000000 00000001021 13465702362 015645 0ustar00heaswheel000000 000000 #!/bin/sh # # Produce package name or version from $srcdir/include/version.h.in # me=$0 info=$1 srcdir=`dirname $0` value= nl=' ' case "${info}" in package_name ) value=`sed -n 's/.*package.*"\(.*\)".*/\1/p' $srcdir/include/version.h.in|tr -d ' '` ;; package_version ) value=`sed -n 's/.*version.*"\(.*\)".*/\1/p' $srcdir/include/version.h.in|tr -d ' '` ;; * ) echo "usage $me (package_name|package_version)" >&2 exit 1 ;; esac # remove trailing newline echo "${value}" | tr -d "$nl" rancid-3.13/install-sh000755 015615 000000 00000036435 13735672075 015014 0ustar00heaswheel000000 000000 #!/bin/sh # install - install a program, script, or datafile scriptversion=2018-03-11.20; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. tab=' ' nl=' ' IFS=" $tab$nl" # Set DOITPROG to "echo" to test this script. doit=${DOITPROG-} doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) is_target_a_directory=always dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done # We allow the use of options -d and -T together, by making -d # take the precedence; this is for compatibility with GNU install. if test -n "$dir_arg"; then if test -n "$dst_arg"; then echo "$0: target directory not allowed when installing a directory." >&2 exit 1 fi fi if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then if test $# -gt 1 || test "$is_target_a_directory" = always; then if test ! -d "$dst_arg"; then echo "$0: $dst_arg: Is not a directory." >&2 exit 1 fi fi fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dstbase=`basename "$src"` case $dst in */) dst=$dst$dstbase;; *) dst=$dst/$dstbase;; esac dstdir_status=0 else dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi case $dstdir in */) dstdirslash=$dstdir;; *) dstdirslash=$dstdir/;; esac obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) # Note that $RANDOM variable is not portable (e.g. dash); Use it # here however when possible just to lower collision chance. tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 # Because "mkdir -p" follows existing symlinks and we likely work # directly in world-writeable /tmp, make sure that the '$tmpdir' # directory is successfully created first before we actually test # 'mkdir -p' feature. if (umask $mkdir_umask && $mkdirprog $mkdir_mode "$tmpdir" && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. test_tmpdir="$tmpdir/a" ls_ld_tmpdir=`ls -ld "$test_tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac oIFS=$IFS IFS=/ set -f set fnord $dstdir shift set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=${dstdirslash}_inst.$$_ rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && { test -z "$stripcmd" || { # Create $dsttmp read-write so that cp doesn't create it read-only, # which would cause strip to fail. if test -z "$doit"; then : >"$dsttmp" # No need to fork-exec 'touch'. else $doit touch "$dsttmp" fi } } && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: rancid-3.13/configure.ac000644 015615 000000 00000037506 13735655205 015272 0ustar00heaswheel000000 000000 dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.69) dnl VERSION needs to be updated such that 'make dist' uses the correct dnl filename for the directory name and tarball. PACKAGE=`$srcdir/configure.vers package_name` VERSION=`$srcdir/configure.vers package_version` AC_SUBST(VERSION) AC_SUBST(PACKAGE) AC_INIT(m4_esyscmd(configure.vers package_name), m4_esyscmd(configure.vers package_version), [rancid@shrubbery.net]) AC_CONFIG_SRCDIR(CHANGES) AM_INIT_AUTOMAKE COPYYEARS="1997-2019" AC_SUBST(COPYYEARS) dnl default install location AC_PREFIX_DEFAULT(/usr/local/rancid) AM_MAINTAINER_MODE([disable]) dnl AC_CONFIG_SUBDIRS(util) # make sure MAKE sets ${MAKE} AC_PATH_PROG(MAKE,gmake,no) if test $MAKE = no; then unset ac_cv_path_MAKE AC_PATH_PROG(MAKE,make,no) if test $MAKE = no; then AC_MSG_ERROR([can't locate a make.]) exit 1 fi fi AC_PROG_MAKE_SET() # compiler specifics AC_PROG_CC AC_PROG_CPP AC_C_CONST AC_C_INLINE AC_C_STRINGIZE # check includes/headers AC_HEADER_STDC AC_CHECK_HEADERS(ctype.h errno.h fcntl.h libutil.h limits.h pty.h malloc.h \ memory.h siginfo.h stdarg.h stdint.h stdlib.h string.h \ strings.h stropts.h sys/resource.h sys/time.h \ sys/types.h sys/wait.h sysexits.h unistd.h util.h wait.h) # check functions AC_CHECK_FUNCS(asprintf memcpy memmove memset strerror strchr \ strrchr strstr strtok strrtok index rindex unsetenv) AC_CHECK_FUNCS(openpty, openpty=1, openpty=0) # openpty() is not in the default libraries. See if it is in some other lib. if test $openpty = 0; then for lib in util; do AC_CHECK_LIB($lib, openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -l$lib"; openpty=1; break]) done fi # If we dont have openpty, then look for /dev/ptmx for use by our own # openpty(). if test $openpty = 0; then # This check (partially) comes from expect's configure AC_MSG_CHECKING([for SVR4 style pty allocation]) AH_TEMPLATE(HAVE_PTMX, "define this if your o/s has /dev/ptmx") if test -r /dev/ptmx ; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PTMX) # Some systems need libpt.a to use /dev/ptmx AC_CHECK_FUNCS(ptsname) if test $ac_cv_func_ptsname+set != set; then # ptsname is not in the default libraries. for lib in pt; do AC_CHECK_LIB($lib, ptsname, [LIBS="$LIBS -l$lib"; break]) done fi else AC_MSG_RESULT(no) fi # In OSF/1 case, SVR4 are somewhat different. # Gregory Depp 17Aug93 AC_MSG_CHECKING([for OSF/1 style pty allocation]) AH_TEMPLATE(HAVE_PTMX_OSF, "define this for OSF/1 ptmx") if test -r /dev/ptmx_bsd ; then AC_DEFINE(HAVE_PTMX_OSF) AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi fi dnl AC_FUNC_VPRINTF # type checks AC_TYPE_SIGNAL AC_TYPE_SIZE_T # Package-specific options/knobs # # Check if user wants us to create LOCALSTATEDIR. If it's a package-system, # they might create it themselves for book-keeping sake; eg: NetBSD AC_MSG_CHECKING([whether to create the local state directory at install time]) AC_ARG_ENABLE(mk-localstatedir, AS_HELP_STRING([--enable-mk-localstatedir], [enable creation of the local state directory at install time (default: yes)]), [if test "$enable_mk_localstatedir" = yes; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi], [AC_MSG_RESULT(yes) enable_mk_localstatedir="yes" ]) AM_CONDITIONAL([MK_LCLSTATEDIR], [test "${enable_mk_localstatedir}" = yes]) # Check if user wants us to install sample configurations into the sysconfdir. AC_MSG_CHECKING([whether to install sample .conf files in sysconfdir]) AC_ARG_ENABLE(conf-install, AS_HELP_STRING([--enable-conf-install], [enable install of sample .conf files in sysconfdir (default: yes)]), [if test "$enable_conf_install" = yes; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi], [AC_MSG_RESULT(yes) enable_conf_install="yes" ]) AM_CONDITIONAL([CONF_INSTALL], [test "${enable_conf_install}" = yes]) # Configure for subversion revision control system instead of CVS. SVN_FSTYPE="--fs-type fsfs" AC_MSG_CHECKING([whether subversion]) AC_ARG_WITH(svn, AS_HELP_STRING([--with-svn=fstype], [use subversion instead of cvs, with optional svn fstype (fsfs|bdb)]), [ case "$withval" in yes) AC_MSG_RESULT(yes) RCSSYS="svn" ;; fsfs) AC_MSG_RESULT([yes fstype fsfs]) RCSSYS="svn" SVN_FSTYPE="--fs-type fsfs" ;; bdb) AC_MSG_RESULT([yes fstype bdb]) RCSSYS="svn" SVN_FSTYPE="--fs-type bdb" ;; no) AC_MSG_RESULT(no) RCSSYS="cvs" ;; *) AC_MSG_ERROR([unknown svn fs-type $withval]) esac ], [AC_MSG_RESULT(no) AC_ARG_WITH(git, AS_HELP_STRING([--with-git], [use git instead of cvs]), [ case "$withval" in yes) AC_MSG_RESULT(yes) RCSSYS="git" ;; no) AC_MSG_RESULT(no) RCSSYS="cvs" esac ], [AC_MSG_RESULT(no) RCSSYS="cvs" ]) ]) AC_SUBST(RCSSYS) AC_SUBST(SVN_FSTYPE) rd_cv_RCSSYS=$RCSSYS # Check for a preference for using mail addresses like rancid+group # instead of the standard rancid-group AC_MSG_CHECKING([whether mail addresses should be in the rancid+ form]) AC_ARG_ENABLE(mail-plus, AS_HELP_STRING([--enable-mail-plus], [enable mail to rancid+ addresses, instead of rancid-]), [if test "$enable_mail_plus" = yes; then AC_MSG_RESULT(yes) MAILPLUS="rancid+" AC_SUBST(MAILPLUS) else AC_MSG_RESULT(no) MAILPLUS="rancid-" AC_SUBST(MAILPLUS) fi], [AC_MSG_RESULT(no) MAILPLUS="rancid-" AC_SUBST(MAILPLUS) ]) rd_cv_MAILPLUS=$MAILPLUS # Check for a preference for using mail addresses like rancid+admin-group # instead of the standard rancid-admin-group AC_MSG_CHECKING([whether admin mail addresses should be in the rancid-admin+ form]) AC_ARG_ENABLE(adminmail-plus, AS_HELP_STRING([--enable-adminmail-plus], [enable mail to rancid-admin+ addresses, instead of rancid-admin-]), [if test "$enable_adminmail_plus" = yes; then AC_MSG_RESULT([rancid-admin+]) ADMINMAILPLUS="rancid-admin+" AC_SUBST(ADMINMAILPLUS) else AC_MSG_RESULT([${MAILPLUS}admin-]) ADMINMAILPLUS="${MAILPLUS}admin-" AC_SUBST(ADMINMAILPLUS) fi], [AC_MSG_RESULT([${MAILPLUS}admin-]) ADMINMAILPLUS="${MAILPLUS}admin-" AC_SUBST(ADMINMAILPLUS) ]) rd_cv_ADMINMAILPLUS=$ADMINMAILPLUS AC_PATH_PROG(DIRNAME,dirname,no) # locate GNU diff (one supporting the -u option) AC_MSG_CHECKING([for a diff(1) that supports -u]) _DIFF_PATH=`echo $PATH:${prefix}/bin:/usr/bin:/usr/pkg/bin:/usr/local/bin:/usr/gnu/bin:/usr/contrib/bin | sed -e 's/:/ /g'` for _diff in ${_DIFF_PATH} ; do if test -e ${_diff}/diff ; then ${_diff}/diff -u -4 /dev/null /dev/null > /dev/null 2>&1 if test $? -ne 0; then # linux/gnu shit has to change options that have been around # since organized religion; see if -U 4 works. ${_diff}/diff -U 4 /dev/null /dev/null > /dev/null 2>&1 if test $? -ne 0; then if test "${ADIFF}" = "" ; then ADIFF="${_diff}/diff" ADIFF_CMD="diff -c -4" fi else DIFF="${_diff}/diff" DIFF_CMD="diff -U 4" break fi else DIFF="${_diff}/diff" DIFF_CMD="diff -u -4" break fi fi done if test "$DIFF" = "" ; then DIFF=$ADIFF DIFF_CMD=$ADIFF_CMD fi if test "$DIFF" = "" ; then AC_MSG_ERROR([can't locate diff.]) fi AC_MSG_RESULT([${DIFF_CMD}]) rd_cv_DIFF=$DIFF AC_SUBST(DIFF) rd_cv_DIFF_CMD=$DIFF_CMD AC_SUBST(DIFF_CMD) AC_PATH_PROG(SENDMAIL, [sendmail], [no], [/usr/sbin:/usr/bin:/usr/lib]) if test "$SENDMAIL" = "no"; then echo "WARNING: sendmail not found" >&2 SENDMAIL='' fi AC_SUBST(SENDMAIL) # Find an appropriate tar for use in "dist" targets. A "best guess" # is good enough -- if we can't find GNU tar, we don't really care. AC_CHECK_PROGS(TAR, gnutar gtar tar) AC_CHECK_PROGS(AUTOMAKE, automake) dnl locate perl 5 and expect. AC_PROG_INSTALL AC_PATH_PROG(PERLV_PATH,perl5,no) if test $PERLV_PATH = no; then unset ac_cv_path_PERLV_PATH AC_PATH_PROG(PERLV_PATH,perl,no) if test $PERLV_PATH = no; then AC_MSG_ERROR([can't locate a suitable perl5.]) exit 1 else $PERLV_PATH -e 'require 5;' if test $? -ne 0 ; then AC_MSG_ERROR([can't locate a suitable perl5.]) exit 1 fi fi fi AC_SUBST(PERLV_PATH) PERLV=`basename $PERLV_PATH` AC_SUBST(PERLV) # check Socket.pm version AC_MSG_CHECKING([Socket.pm version]) $PERLV_PATH -e 'use 2.006 Socket qw(inet_pton);' 2>&1 >/dev/null if test $? -ne 0 ; then AC_MSG_ERROR([Socket.pm is older than 2.006; upgrade from http://metacpan.org/pod/Socket]) exit 1 fi AC_PATH_PROG(EXPECT_PATH,expect,no) if test $EXPECT_PATH = no; then AC_MSG_ERROR([can't locate expect.]) fi AC_SUBST(EXPECT_PATH) dnl dnl locate python 3 dnl AC_PROG_INSTALL dnl AC_PATH_PROG(PYTHON3_PATH,python3,no) dnl if test $PYTHON3_PATH = no; then dnl unset ac_cv_path_PYTHON3_PATH dnl AC_PATH_PROG(PYTHON3_PATH,python,no) dnl if test $PYTHON3_PATH = no; then dnl AC_MSG_ERROR([can't locate a suitable python3.]) dnl exit 1 dnl else dnl $PYTHON3_PATH -c << EOF dnl import sys dnl if not sys.version_info[0] == 3 or not sys.version_info[1] < 5: dnl sys.exit(1) dnl dnl EOF dnl if test $? -ne 0 ; then dnl AC_MSG_ERROR([can't locate a suitable python3; must >=3.5.]) dnl exit 1 dnl fi dnl fi dnl fi AC_SUBST(PYTHON3_PATH) dnl PYTHON3=`basename $PYTHON3_PATH` AC_SUBST(PYTHON3) # look for lockfile utility AC_PATH_PROG(MKTEMP,mktemp,no) if test $MKTEMP = no; then unset ac_cv_path_MKTEMP AC_MSG_ERROR([can't locate a mktemp(1).]) fi AC_SUBST(MKTEMP) # locate ping and it's syntax AC_PATH_PROG(PING_PATH,[ping],[no], [$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin]) if test $PING_PATH = no; then AC_MSG_ERROR([can't locate ping.]) exit 1 fi # ping seems to take one of two formats for count (N) # BSD: ping -c N host # SVR: ping host N $PING_PATH -c 1 -v 127.0.0.1 > /dev/null 2>&1 if test $? -eq 0 ; then LG_PING_CMD="$PING_PATH -c 1" else $PING_PATH 127.0.0.1 56 1 > /dev/null 2>&1 if test $? -eq 0 ; then LG_PING_CMD="$PING_PATH" else # cygwin using windows ping? $PING_PATH -n 1 127.0.0.1 > /dev/null 2>&1 if test $? -eq 0 ; then LG_PING_CMD="$PING_PATH -n 1" else AC_MSG_ERROR([can't figure out how to pass count == 1 to $PING_PATH.]) exit 1 fi fi fi AC_SUBST(LG_PING_CMD) rd_cv_lg_ping_cmd=$LG_PING_CMD # locate tools to build $PATH for rancid.conf. order is significant. want # to be sure that we pick up the the proper diff and ucbmail in # etc/rancid.conf. ENV_PATH="`dirname $PERLV_PATH`:`dirname $EXPECT_PATH`:`dirname \"$SENDMAIL\"`" ENV_PATH="$ENV_PATH:`dirname $DIRNAME`:`dirname $DIFF`:`dirname $MKTEMP`" if test $RCSSYS = "cvs" ; then AC_PATH_PROG(CVS,cvs,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_CVS`" elif test $RCSSYS = "svn" ; then AC_PATH_PROG(SVN,svn,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_SVN`" else AC_PATH_PROG(GIT,git,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_GIT`" fi AC_PATH_PROG(COMM,comm,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_COMM`" AC_PATH_PROG(FIND,find,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_FIND`" AC_PATH_PROG(GREP,grep,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_GREP`" AC_PATH_PROG(ID,id,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_ID`" AC_PATH_PROG(MKDIR,mkdir,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_MKDIR`" AC_PATH_PROG(RSH,rsh,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_RSH`" AC_PATH_PROG(SORT,sort,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_SORT`" AC_PATH_PROG(SSH,ssh,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_SSH`" AC_PATH_PROG(TELNET,telnet,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_TELNET`" # test if telnet accepts -K $ac_cv_path_TELNET -K < /dev/null > /dev/null 2>&1 if test $? -eq 0 ; then TELNET_CMD="telnet -K" else TELNET_CMD="telnet" fi AC_SUBST(TELNET_CMD) AC_PATH_PROG(TOUCH,touch,no) ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_TOUCH`" ENV_PATH="$ENV_PATH:/usr/local/bin:/usr/bin" AC_SUBST(ENV_PATH) ENV_PATH=`echo $ENV_PATH | $PERLV_PATH -e 'foreach $x(split(":",<>)){next unless (length($x));next if ($x =~ /^\.$/);$x =~ s/[\n\r]*//;push(@F, $x),$seen{$x}=1 unless (defined $seen{$x});}print join(":",@F);'` ac_cv_env_path=$ENV_PATH AC_SUBST(ENV_PATH) AC_CONFIG_FILES(Makefile) AC_CONFIG_FILES(bin/Makefile) AC_CONFIG_FILES(etc/Makefile) AC_CONFIG_FILES(include/Makefile) AC_CONFIG_FILES(lib/Makefile) AC_CONFIG_FILES(man/Makefile) AC_CONFIG_FILES(share/Makefile) AC_CONFIG_FILES(include/version.h) # this is not a header in the sense of # AC_CONFIG_HEADERS will cause # autoheader to overwrite it, while all # want is simple variable replacement # autoheader bits AH_TOP([ #ifndef CONFIG_H #define CONFIG_H 1 ]) AH_BOTTOM([ /* damned linux... */ #if defined(LINUX) || defined(linux) # define _GNU_SOURCE #endif #ifndef __P # if STDC_HEADERS # define __P(a) a # else # define __P(a) () # endif #endif #if HAVE_STDLIB_H # include #endif #if HAVE_UNISTD_H # include # include #elif HAVE_SYS_TYPES_H # include #endif #if HAVE_ERRNO_H # include #endif extern int errno; #if HAVE_STRING_H # include #endif #if HAVE_STRINGS_H # include #endif #if ! HAVE_STRERROR # define strerror(n) sys_errlist[n]; #endif #if HAVE_WAIT_H # include #elif HAVE_SYS_WAIT_H # include #endif #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif #if HAVE_SYSEXITS_H # include #else /* missing sysexits.h */ # define EX_OK 0 # define EX_USAGE 64 /* command line usage error */ # define EX_NOINPUT 66 /* cannot open input */ # define EX_TEMPFAIL 75 /* temp failure */ # define EX_OSERR 71 /* system error */ # define EX_CANTCREAT 73 /* can't create (user) output file */ # define EX_IOERR 74 /* input/output error */ # define EX_CONFIG 78 /* configuration error */ #endif #endif /* CONFIG_H */ ]) AC_CONFIG_HEADERS(include/config.h) AC_CONFIG_FILES(bin/login_top) AC_SUBST_FILE([copyright]) AC_SUBST_FILE([login_top]) copyright=$srcdir/COPYING login_top=$srcdir/bin/login_top AC_CONFIG_FILES(bin/a10login, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/agmrancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/alogin bin/arancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/anlogin, [chmod a+x $ac_file]) dnl AC_CONFIG_FILES(bin/atrancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/avologin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/blogin bin/brancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/brlogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/cat5rancid bin/clogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/csblogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/cssrancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/dllogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/elogin bin/erancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/f5rancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/flogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/fnlogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/fxlogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/hlogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/htlogin bin/htrancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/jlogin bin/jerancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/mrancid bin/mrvlogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/mtlogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/nlogin bin/nrancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/noklogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/nslogin bin/nsrancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/panlogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/rblogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/rivlogin bin/rivrancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/rrancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/rtftpcopy, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/tlogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/trancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/xilogin bin/xirancid, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/xlogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/ulogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(bin/wlogin, [chmod a+x $ac_file]) AC_CONFIG_FILES(share/rtrfilter, [chmod a+x $ac_file]) AC_OUTPUT() rancid-3.13/Makefile.in000644 015615 000000 00000067004 13735672075 015051 0ustar00heaswheel000000 000000 # Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : @MK_LCLSTATEDIR_TRUE@am__append_1 = $(DESTDIR)$(localstatedir) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ $(am__configure_deps) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = depcomp = am__maybe_remake_depfiles = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkgdatadir)" DATA = $(pkgdata_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir distdir-am dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in COPYING README compile depcomp \ install-sh missing mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ ADMINMAILPLUS = @ADMINMAILPLUS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ COMM = @COMM@ COPYYEARS = @COPYYEARS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CVS = @CVS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DIFF = @DIFF@ DIFF_CMD = @DIFF_CMD@ DIRNAME = @DIRNAME@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENV_PATH = @ENV_PATH@ EXEEXT = @EXEEXT@ EXPECT_PATH = @EXPECT_PATH@ FIND = @FIND@ GIT = @GIT@ GREP = @GREP@ ID = @ID@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LG_PING_CMD = @LG_PING_CMD@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAILPLUS = @MAILPLUS@ MAINT = @MAINT@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ MKDIR_P = @MKDIR_P@ MKTEMP = @MKTEMP@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERLV = @PERLV@ PERLV_PATH = @PERLV_PATH@ PING_PATH = @PING_PATH@ PYTHON3 = @PYTHON3@ PYTHON3_PATH = @PYTHON3_PATH@ RCSSYS = @RCSSYS@ RSH = @RSH@ SENDMAIL = @SENDMAIL@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SORT = @SORT@ SSH = @SSH@ STRIP = @STRIP@ SVN = @SVN@ SVN_FSTYPE = @SVN_FSTYPE@ TAR = @TAR@ TELNET = @TELNET@ TELNET_CMD = @TELNET_CMD@ TOUCH = @TOUCH@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign no-dependencies pkgdata_DATA = COPYING CHANGES FAQ README README.lg UPGRADING cloginrc.sample EXTRA_DIST = BUGS Todo configure configure.vers install-sh \ mkinstalldirs Makefile.in Todo $(pkgdata_DATA) #DIST_COMMON = # '.' is here (and at the beginnging of the macro) so that distclean-recursive # will run make distclean in . after the other dirs (preserving Makefile) and # mkinstalldirs will create the install destination before descending into # the subdirs. SUBDIRS = . include etc lib bin man share # sysconfdir is here because etc/Makefile uses a script to be careful about # installing rancid.conf, not over-writing an existing one. DIRS2_CREATE = $(DESTDIR)$(prefix) $(DESTDIR)$(sysconfdir) \ $(am__append_1) all: all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): install-pkgdataDATA: $(pkgdata_DATA) @$(NORMAL_INSTALL) @list='$(pkgdata_DATA)'; test -n "$(pkgdatadir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(pkgdatadir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkgdatadir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgdatadir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgdatadir)" || exit $$?; \ done uninstall-pkgdataDATA: @$(NORMAL_UNINSTALL) @list='$(pkgdata_DATA)'; test -n "$(pkgdatadir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgdatadir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-zstd: distdir tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ *.tar.zst*) \ zstd -dc $(distdir).tar.zst | $(am__untar) ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build/sub \ && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(DATA) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(pkgdatadir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-local \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-pkgdataDATA @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-pkgdataDATA .MAKE: $(am__recursive_targets) install-am install-data-am \ install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-cscope clean-generic \ cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ dist-zstd distcheck distclean distclean-generic \ distclean-local distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am \ install-data-hook install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkgdataDATA install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-pkgdataDATA .PRECIOUS: Makefile @SET_MAKE@ install-data-hook: $(mkinstalldirs) $(DIRS2_CREATE); distclean-local: -rm -rf $(top_srcdir)/autom4te.cache # 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: rancid-3.13/share/000755 015615 000000 00000000000 13735706334 014073 5ustar00heaswheel000000 000000 rancid-3.13/acinclude.m4000644 015615 000000 00000000051 13465702362 015153 0ustar00heaswheel000000 000000 AUTOMAKE_OPTIONS=no-dependencies foreign rancid-3.13/Makefile.am000644 015615 000000 00000002246 13534015472 015022 0ustar00heaswheel000000 000000 ## Process this file with automake to produce Makefile.in ## A Makefile.in is supplied, in case you do not have automake. ## Copyright (C) 1997-2019 by Henry Kilmer and John Heasley ## All rights reserved. ## ## Please see the file COPYING for the text of the license. ## AUTOMAKE_OPTIONS=foreign no-dependencies @SET_MAKE@ pkgdata_DATA = COPYING CHANGES FAQ README README.lg UPGRADING cloginrc.sample EXTRA_DIST = BUGS Todo configure configure.vers install-sh \ mkinstalldirs Makefile.in Todo $(pkgdata_DATA) #DIST_COMMON = # '.' is here (and at the beginnging of the macro) so that distclean-recursive # will run make distclean in . after the other dirs (preserving Makefile) and # mkinstalldirs will create the install destination before descending into # the subdirs. SUBDIRS = . include etc lib bin man share # sysconfdir is here because etc/Makefile uses a script to be careful about # installing rancid.conf, not over-writing an existing one. DIRS2_CREATE=$(DESTDIR)$(prefix) $(DESTDIR)$(sysconfdir) if MK_LCLSTATEDIR DIRS2_CREATE+=$(DESTDIR)$(localstatedir) endif install-data-hook: $(mkinstalldirs) $(DIRS2_CREATE); distclean-local: -rm -rf $(top_srcdir)/autom4te.cache rancid-3.13/man/000755 015615 000000 00000000000 13735706334 013544 5ustar00heaswheel000000 000000 rancid-3.13/cloginrc.sample000644 015615 000000 00000007554 13465702362 016004 0ustar00heaswheel000000 000000 # comments are cool, as is whitespace # clogin supports a number of add directives (non-exhaustive): # password # user # userprompt # userpassword # passprompt # method # noenable # enauser # enableprompt # autoenable # cyphertype # identity # # Details on each of these follows. Also see cloginrc(5). # # add password # Special characters must be escaped. See cloginrc(5). # # add user # The default user is $USER (i.e.: the user running clogin). # # add userprompt # What the router prints to prompt for the username. # Default: {"(Username|login|user name):"} # # add userpassword # The password for user if different than the password set # using 'add password'. # # add passprompt # What the router prints to prompt for the password. # Default: {"(\[Pp]assword|passwd):"} # # add method {ssh} [...] # Defines, in order, which connection method(s) to use for a device # from the set {ssh,telnet,rsh}. e.g.: add method * {ssh} {telnet} {rsh} # will attempt ssh connection first. if ssh fails with connection # refused (i.e.: not due to authentication failure), then try telnet, # then rsh. # Default: {telnet} {ssh} # # add noenable <1> # equivalent of -noenable on the cmd line to not enable at login. # # add enableprompt # What the router prints to prompt for the enable password. # Default: {"\[Pp]assword:"} # # add enauser # This is only needed if enable asks for a username and this # username is different from what user is set to. # # add autoenable <1/0> # This is used if you are automatically enabled by the login process. # # add cyphertype # Default is 3des. # # add identity # Default is your default ssh identity. # # include # include a secondary .cloginrc file # # # Note: The first match for a hostname takes precedence. The -[Mm] options # are useful for debugging cloginrc issues. # # Also see cloginrc(5) and clogin(1). #add password sl-bb*-dc cow24 #add password sl-gw*-dc geeks #add password sl* hank dog #add password at* pete cow #add password sdn* mujahid horse #add password icm* peter #add password * anything # #add user sl-gw*-dc twit #add user sdn* sdn_auto #add user sdn-bb* ops_eng #add user * $env(USER) # customer x # these routers ask for a username and password. we automatically get # enable access after successful authentication. add user *.custx.net roger add password *.custx.net {doger} add autoenable *.custx.net 1 # customer y # this is the normal cisco login. a password followed by and enable password. # try ssh first, then rlogin. add password *.custy.net {vector} {victor} add method *.custy.net ssh rlogin # customer z; they use ssh only. add user *.custz.net shirley add password *.custz.net {jive} {surely} add method *.custz.net ssh # the route-server's do not provide enable access. cmdline -noenable # equivalent. add noenable route-server* 1 # all our routers, i.e.: everything else add password * {clearance} {clarence} # set ssh encryption type, dflt: 3des add cyphertype * {3des} # set the username prompt to "router login:" #add userprompt * {"router login:"} # ssh identity for a juniper; used with jlogin add identity my.juniper $env(HOME)/.ssh/juniper # riverstone / enterasys / cabletron (rivlogin) example # these boxes are 'back-to-front' from cisco (i.e., ask # for vty password always, then tac+/radius if configured). # # vty password and last resort (enable) password for rivlogin add password rs3000 {vtypass} {lastresort} # if using tac+ or radius login, include these lines add user rs3000 {monster} add userpassword rs3000 {scary} rancid-3.13/FAQ000644 015615 000000 00000075771 13657102757 013346 0ustar00heaswheel000000 000000 Frequently Asked Questions about rancid - last updated 20180408. This FAQ contains information that may not apply directly to versions of rancid prior to 3.0. It also contains paths containing tags such as , which refer to paths that are site-specific and are determined by how rancid was configured at installation time. These are explained briefly in the configure --help output. Below are the defaults used in rancid. PREFIX configure --prefix= option. default: /usr/local/rancid EPREFIX configure --exec-prefix= option. default: BINDIR configure --bindir= option. default: /bin The location of clogin, etc. SYSCONFDIR configure --sysconfdir option. default: /etc The location of rancid.conf, etc. LOCALSTATEDIR configure --localstatedir option. default: /var The location of the CVS repository, log files, etc. The most recent FAQ can be found at http://www.shrubbery.net/rancid/FAQ ToC 1) Platform/Device specific 2) CVS and filesystem permissions 3) General 4) Extending RANCiD 5) O/S specific 6) E-mail problems 7) I am still stuck 8) License 1) Platform/Device specific Q. I have a Cisco Catalyst 6500 series switch running the IOS (NOT catOS) software, is the router.db device type cisco or cat5? A. A catalyst running IOS is type "cisco". The 'show version' output will have banner including a phrase similar to "Cisco Internetwork Operating System Software". See the router.db(5) manual page. Q. I have Hybrid Cisco switch, like a cat5k with an RSM. How do I collect both the routing engine and switch configurations? A. Recommended way is to use two entries in the router.db, one for each. For example: cat5k_rsm.domain.com;cisco;up cat5k_sw.domain.com;cat5;up Q. I have a Cisco ??? on which collection stopped working, but clogin works as expected. A. Check if 'write term' produces output. Some IOS combined with large configs and low free memory produce zero 'write term' output, esp. combined with a memory leak. The device will have to be rebooted and/or upgraded. Q. I have a Cisco Catalyst switch. clogin connects, but after receiving the prompt, it stalls until it times out. Why? A. This may be due to your prompt. CatOS does not include an implicit '>' in it's prompt, like IOS does. clogin looks for '>' during login, so specify your prompt with a trailing '>'. Also see cat5rancid(1). For example: cat5k> cat5k> enable Password: cat5k> (enable) Q. Why won't a saved HP Procurve configuration load onto the switch to restore the configuration. A. Stefan Metzger and Per-Olof Olsson have found that the Procurve O/S does not like the leading comments, the lines beginning with ';', so remove these comments in whatever manner you wish. Also, they appear to expect a leading comment line that varies between different models, for example: "; Running config file:" OR "; JJBA8" Q. Polling a ZebOS box fails from cron, but is successful from the command- line. A. This is the tty/pty handling of either your O/S or ZebOS. Supposedly, changing the TERM in /rancid.conf to the following seems to fix it. TERM=vt100;export TERM COLUMNS=160; LINES=48; export COLUMNS LINES 2) CVS and filesystem permissions WARNING: Be careful when mucking around with the repository! Q. I am new to CVS, where can I find additional information? A. The manual page for CVS is quite complete, but can be be overwhelming even for someone familiar with RCS. There are some excellent resources on the web. See http://en.wikipedia.org/wiki/Concurrent_Versions_System and http://cvshome.org/. Q. Errors are showing up in the logs like: cvs [diff aborted]: there is no version here; run 'cvs checkout' first A. The directory was not imported into CVS properly or was not properly checked out afterward, so CVS control files or directories do not exist. rancid-cvs should always be used to create the directories and perform the CVS work. If it is just the directories that have been created manually, save a copy of the router.db file, then remove the group's directory, use rancid-cvs, and replace the router.db file. If the CVS import was also performed manually, cd to and use 'cvs co ' to create all the CVS control bits. Q. Errors are showing up in the logs like: cvs commit: Up-to-date check failed for `filename' A. This could mean that the version of the file that rancid has is older than the one in repository or that the file is missing. That could be due to a filesystem error, a system crash, a rancid crash or premature termination, or some third party altering the repository or rancid's local repository. Third parties should NOT alter the repository or rancid's local repository, except for editing the router.db file. All other modificiations should be left to rancid's automation. To recover, run cvs update in the group's directory as the rancid user. If the update fails or creates conflict, the files can be removed and the cvs update re-run. Some files are not saved in cvs, but these will be re-created without harm.. Some have asked why rancid does not run a cvs (or svn or git) update itself. If it did, it could inherit malicious modifications in the repository meant to hide the modifications. Q. I keep receiving the same diff for a (or set of) devices, but I know the data is not changing repeatedly. Why? A. This is probably a CVS or filesystem permissions problem. Check the log file from the last run for that group for clues first; it may provide the exact cause. Note: It is very important the following be done as the user who normally runs the rancid collection from cron. Check the cvs status of the device's file. example: guelah [2704] cvs status rtr.shrubbery.net =================================================================== File: yogi.shrubbery.net Status: Up-to-date Working revision: 1.197 Tue Jul 10 15:41:16 2001 Repository revision: 1.197 /usr/local/rancid/var/CVS/shrubbery/configs/rtr.shrubbery.net,v Sticky Tag: (none) Sticky Date: (none) Sticky Options: (none) The Status: should be Up-to-date. If the status is "Unknown", then somehow the file has been created without being cvs add'ed. This should be corrected by removing that device's entry from the group's router.db file, run rancid-run, replace the entry in router.db, and run rancid-run again. If the Status is anything else, someone has most likely been touching the files manually. Sane state can be achieved by removing the file and running cvs update to get a fresh copy from the repository. Check the ownership and permissions of the file and directory and the directory and file in the cvs repository (/CVS/). They should be owned by the user who runs rancid-run from cron. At the very least, the directory and files should be writable by the rancid user. Group and world permissions will determined by the umask (default 027), which is set in /rancid.conf. Likely the easiest way to fix the ownership on the cvs repository is chown -R /CVS / Q. I am renaming a device but would like to retain the history in CVS. How is this done? A. CVS does not provide a way (AFAIK) to rename files or to rename or delete directories. The best way is to copy the CVS repository file manually like this (disclaimer: BE VERY CAREFUL mucking around with the repository): % su - rancid_user % cd % echo "new_device_name;device_type;up" >> /router.db % cp -p CVS//configs/old_device_name,v \ CVS//configs/new_device_name,v % cd /configs % cvs update where GROUP is the name of the rancid group that the device is a member of. Once the renaming is complete, remove the old name from the router.db file and leave the CVS clean-up of the old filename to rancid. If one wanted to move a device to a different group and maintain the history, the same procedure would work, substituting the new group name appropriately and editing the router.db of both old and new groups, of course. SVN provides a rename function; but we suggest that you use it's copy function instead, and leave the clean-up of the old name to rancid. So, you would use the copy function (proper substitutions, of course) in place of the cp in the CVS example, then commit the new file. Q. I am new to svn. Where can I find more information? A. The svn so-called "red book" is the definitive guide. http://svnbook.red-bean.com/en/1.5/svn-book.html Q. I am removing a group and would like to remove all traces of it from the rancid directory and the CVS repository. How is this done? A. As far as I know, CVS does not provide a way to remove directories. First, remove the group from /rancid.conf. If rancid is running, wait for it to complete. Then just recursively remove the directory. For example, a group named "fubar": % su - rancid_user % cd % rm -rf fubar CVS/fubar Q. I would like to place my git repository on a remote machine. How do I do that? A. We suggest that you configure git to push a clone to the remote. That is, create the rancid group as normally done, including running rancid-cvs(1). Then add a push url to the existing origin. % cd $BASEDIR/ % git remote add % git remote set-url --add --push origin $CVSROOT/ % git remote set-url --add --push origin http://www.shrubbery.net/pipermail/rancid-discuss/2018-August/010348.html Q. I would like to place my CVS repository on a remote machine. How do I do that? A. Assuming that you're starting fresh, its quite simple. Before running rancid-cvs for the first time, adjust CVS_RSH & CVSROOT in rancid.conf similar to the following: CVS_RSH=ssh; export CVS_RSH CVSROOT="myhost:/fqpn/CVS"; export CVSROOT Note that CVS_RSH is not found in the sample rancid.conf that is distributed with rancid. Q. I need a web interface to the rancid CVS repository, for the CVS unsavvy. A. cvsweb works with rancid. Other software may exist for CVS and there are similar tools for Subversion and git. http://www.freebsd.org/projects/cvsweb.html cvsweb.conf: @CVSrepositories = ( 'rancid' => ['RANCID CVS, '/full_path_to_the_RANCID_CVS'], where the path will be /CVS. 3) General Q. I have upgraded to rancid >=3.0 and I am not receiving updates for any devices. A. Have you updated the format of your router.db files? The field separator changed in 3.0. See the UPGRADING file or router.db(5). Q. I have a (set of) device(s) on which collection fails. How can I debug this? A. Our usual diagnostic procedure for this is: - Make sure that the appropriate login script (example: clogin for cisco) works (see rancid.types.base). Use these tests to make sure you don't have routing or firewall issues, DNS or hostname errors, that your .cloginrc is correct, your banner does not have some character that the login script confuses for a prompt, and that the login script doesn't have a bug of some sort. For example: clogin cisco_router This should login to cisco_router and produce a router prompt that you can use normally (interactively), as if clogin were not used (i.e.: telnet cisco_router). Also, see the next FAQ entry. - Verify that commands can be executed on the router via the login script. This will exercise the script functionality needed for rancid. For example: clogin -c 'show version; show diag' cisco_router Should login to cisco_router, run show version and show diag, then disconnect and exit. The output will be displayed on your terminal. Use commands appropriate for the device; for rancid modules converted to perl modules, rancid -t -C produces the full list of commands that rancid would normally run. - Then see if the correct rancid commands work against the router. For example: rancid -t cisco cisco_router Should produce a cisco_router.new file (cooked to a golden rancid-style colour) in the current directory. If it does not, try again with the -d option, so that the cisco_router.new and cisco_router.raw files will not be removed if an error is detected. The cisco_router.raw file is the raw output of the dialogue with the device, and with the -d option, the .raw file will not be deleted at the end, which is helpful to see all the input. The -l option is also useful for logging. Note: in versions prior to 3.10, NOPIPE=YES must be set in your environment to produce the cisco_router.raw file. If all of these work, make sure that the device's entry in the group's router.db file is correct and check the group's last log file for errors. Q. A login script is failing to login to a device with an authentication error. I have the correct information in my .cloginrc. A. It is useful to verify that the information that you this is used, really id. See clogin(1) for the [Mm] options. Q. I am receiving persistent diffs for up/down/added/deleted devices in router.db, but nothing has changed and the cvs repository is up to date. A. Check that the configure process run during the installation of rancid determined the proper options for diff(1); look for diff in the control_rancid script. If you also run rancid from the command-line, be sure that your locale environment variables are consistent between your interactive and non- interactive (ie: cron) environments. On some O/Ses, the locale will affect the operation of sort(1). Q. I have received an e-mail with the subject "rancid hung - ". What does this mean? A. It means that the lockfile for already exists and rancid-run is attempting to run again. The lockfile prevents two instances of rancid from running simulaneously for the same rancid group. This could be due to a system crash or rancid being killed and this not having an opportunity to remove the lock or rancid could indeed be hung. Look at the system process list for an existing instance of rancid for the given group. If none exist, simply remove the lockfile named in the email. If it does exist, note what process in the progress group is hung and where it is hung (see system utilities ps, lsof, truss, ktrace, strace, dtrace and so on). Kill the hung process and rancid may run to completion from there. If the hang occurs again, further debugging will be necessary and will be dependant upon what is hanging. It has been observed that some devies have had bugs that cause interactive sessions to hang at exit and exhibit other exciting behaviors. Q. Are there any characters in the banner that rancid has problems with OR I changed the device's command prompt and now collection is failing? A. The trickiest part about clogin (et al) is recognizing the prompt correctly. clogin looks for '>' and '#' to figure out if it is logged in or in enable mode. So if you have a '>' or '#' in your login banner (or other motd), then clogin gets confused and will not be able to log in correctly, and thus rancid will fail. Don't use '>' or '#', or whatever the termination character of the given device's prompt is, in your prompt or in your banner or other motd. Q. I am experiencing random login failures using telnet and am seeing a kerberos message like: Kerberos: No default realm defined for Kerberos! A. This diagnostic output can confuse rancid if it appears amid a login prompt. The easiest work around is to tell telnet not to attempt kerberos authentication: echo DEFAULT unset autologin >> ~/.telnetrc Q. I use /*login -c to run commands on multiple boxes. Sometimes these are commands that take secondary input, like a filename. How can I enter the data for that secondary prompt? A. Two methods will work. Write an expect script to be used with clogin's -s option, for which a few examples come with rancid like cisco-load.exp. OR provide all the input in one command with the -c option like so: Router#clear counters Clear "show interface" counters on all interfaces [confirm] Router# clogin -c 'clear counters\n' The specific return (\n) will be entered after 'clear counters' followed by the normal return after the command. Some devices apparently eat the linefeed of the typical Unix \r\n sequence and require that a carriage- return be used instead (\r). Q. I would like to collect device configurations every hour, but only receive diffs every Nth collection or every N hours. Is this possible? A. Certainly, but rancid does not provide such a mechanism natively. Two approaches are recommended: 1) Using your preferred mail-list software, add a list with a digest and configure your MTA (example: sendmail) to send diffs to the list. Configure the mail-list software to force the digest at the interval desired. This allows folks to choose which type they prefer, after each collection or every N hours. This method also provides easy methods to archive the diff mail and retrieve previous diffs. 2) Write a script to send diffs, which saves the time it last ran and passes this to the -D option of CVS. Obviously, the first option is the cleanest and most featureful, which is why the script mentioned in the second option is not provided. Q. I'd like to have RANCID automatically begin collection when someone finishes configuring a router. How can I do this? A. Using a syslog watcher script, one can trigger RANCID from the syslog line emitted by, for example, an IOS router after configuration mode is ended. Here's a simple example using the Simple Event Correlator: (http://simple-evcorr.sourceforge.net/) If the syslog line in your logs looks like this (wrapped for readability): Apr 5 09:56:52 acc1.geo269.example.com 72: 000069: *Mar 6 21:40:13.466 \ AEDT: %SYS-5-CONFIG_I: Configured from console by gwbush on vty0 (10.1.1.1) You would use a SEC configuration stanza like this: # example rancid trigger # type=SingleWithSuppress ptype=RegExp pattern=\s\S+:\S+\S+\s(\S+)\.example\.com.*SYS-5-CONFIG_I action=shellcmd /opt/rancid/bin/run-rancid -r $1 window=1800 This will execute the command '/opt/rancid/bin/run-rancid -r acc1.geo269' when it is fed a line like that syslog line. The command will be run at most once every 1800 seconds. If you do not get hostnames in your log lines that match your router.db entries, either fix your reverse DNS or remove the '-r $1' part. And, if it can identify the group the device is part of, include the group on the command line to reduce the time it takes rancid to locate the group and avoid lock contention. Q. I would like to limit the permissions of the rancid user on my devices. Is this possible? A. Strictly speaking, no. Rancid needs permission to read device configuration and other data which is often not available to underprivileged users. However, if you use TACACS+, you can limit the commands that are available to a user. For example, to allow ping and show, but not "show tcp", and nothing else: user = rancid { cmd = "ping" { permit .* } cmd = "show" { deny tcp.* permit .* } # the default is to deny other commands } For RADIUS, Justin Grote suggested privilege levels: http://www.cisco.com/univercd/cc/td/doc/product/software/ios122/122newft/122t/122t13/ftprienh.htm Or, on a Juniper, configure a login class, such as below: set system login class RANCID permissions access set system login class RANCID permissions admin set system login class RANCID permissions firewall set system login class RANCID permissions flow-tap set system login class RANCID permissions interface set system login class RANCID permissions network set system login class RANCID permissions routing set system login class RANCID permissions secret set system login class RANCID permissions security set system login class RANCID permissions snmp set system login class RANCID permissions storage set system login class RANCID permissions system set system login class RANCID permissions trace set system login class RANCID permissions view set system login class RANCID permissions view-configuration set system login user rancid class RANCID Q. For approximately X hosts (configs), what size server should we be considering - speed and data storage? A. On modern machines it is unlikely you will have issues with disk space or memory - A heavily laden access router with a complex config won't consume more than a few megabytes of disk space for its configs over several years time (roughly 3 times the sum of all the config or */configs/* over 2 years is a decent approximation). Rancid is typically CPU bound, if you have adequate network bandwidth, but truthfully it spends most of its time waiting for information from the devices it is polling and network RTT. Experience shows rancid takes around 50 Mhz * minutes / device of processing power. This means that a 1Ghz machine can poll: 1000 Mhz * 60 (min/hour) / 50(Mhz min / device) = 1200 devices/hour That's obviously a ball park estimate which varies with many different factors such as the CPU type, the types of devices on your network, and the speed of your network. Q. How can I run rancid to make the most efficient use of resources (i.e. run in the shortest amount of time)? A. You can adjust PAR_COUNT in rancid.conf to achieve maximum efficiency during polling. You can watch the output of the standard unix command vmstat command during polling to determine whether or not the cpu is being wholly utilized - there should be little idle time and no process blocking (see vmstat(8)). Another simpler method is to look at the time stamps on the rancid log files, and adjust PAR_COUNT until the least amount of time is taken during polling. Make sure all devices are being polled by rancid before using this method - failing devices can extend the amount of time rancid takes to finish by a *LONG* period and throw your times way off. It may help to run rancid niced (man nice) if it will be sharing resources with other processes, as it may eat whatever is available if PAR_COUNT is set high. This is done by changing the crontab to be something like: 5 * * * * nice -19 /usr/local/rancid/bin/rancid-run If you _do_ share resources with other processes but want rancid to run efficiently, probably the vmstat method above will work better - rancid may take a little longer to run but you won't be stepping on other processes. Q. *login is failing to connect to devices via ssh with an error about the lack of a matching key or cipher, etc.. A. openssh has disabled (or removed from the default list offered) a number of legacy cryptography algorithms, but many devices are still running old code without support for newer algorithms. Also, as of RANCiD 3.5, the ssh -c option default of "3des" has been dropped from all of the login scripts due to its affect on offered ssh version 2 (sshv2) ciphers, allowing sshv2 negotiation to proceed as normal. See http://www.openssh.com/legacy.html, use ssh -v to display details about the connection negotiation to see what the remote device supports. Also see Cisco bug https://tools.cisco.com/bugsearch/bug/CSCuo76464 and http://stackoverflow.com/questions/25341773/cisco-ssh-key-exchange-fails-from-ubuntu-14-04-client-dh-key-range-mismatch. Suggested fixes for these failures may include the following options being added to /etc/ssh/ssh_config or ~/.ssh/config: Host * KexAlgorithms +diffie-hellman-group1-sha1 Cipher +3des Ciphers +3des-cbc Options can also be set in .cloginrc, such as: add sshcmd * {ssh\ -o\ KexAlgorithms=+diffie-hellman-group1-sha1} Q. What else can I do with rancid? A. The possibilities are endless...rancid is non-toxic when applied properly. see Joe Abley and Stephen Stuart's NANOG presentation: http://www.nanog.org/mtg-0210/abley.html or our NANOG presentation: http://www.shrubbery.net/rancid/NANOG29/ 4) Extending RANCiD Q. I wrote scripts for an unsupported device in rancid 2.x, but I am upgrading to 3.x and rancid-fe no longer works in the same manner. Can I use the script with 3.x? A. Yes. The device type must be added to etc/rancid.types.conf such as: DeviceTypeName;script;RancidScriptName DeviceTypeName;login;LoginScriptName eg: alteon;script;arancid alteon;login;alogin See rancid.types.conf(5). Q. I Have a device that is not supported by rancid. How can I add support for it? A. You should first search the rancid-discuss mail list and the web for previous art. Someone may have already accomplished or begun the task. If that is fruitless, you should query the rancid-discuss mail list, for someone still may have done the work or you may be able to hire or bribe someone. If you must write one, it is helpful to have a basic understanding of rancid's general process. See rancid_intro(7) and this maillist thread thread: http://www.shrubbery.net/pipermail/rancid-discuss/2015-August/008630.html . You should begin with installation of the latest version of rancid. Adding device support has been made easier in 3.0 and is being made easier as it progresses. Now, following the advice from Alan in the mail thread, choose the login script and rancid library that most closely resembles the new device. If it resembles none of them, clogin and ios.pm are reasonable starting points. If you wish to contribute your scripts to the community, it is easier if they are already in the format that autoconf and automake require. You accomplish this by beginning with the .in version of the scripts/libraries. The new files must also be added to automake &/ autoconf configuration files; configure.ac and various Makefile.am files. In some cases, it is possible to use an existing script without modification or just simple changes. Do so, if possible, BUT we encourage you to contribute those changes back to the community so that they will be in the next version and it will be easier for you to upgrade in the future, AND be careful making changes as it is easy to break the login scripts. Otherwise, copy the files to the new names that you have chosen. We normally use the name of the device's O/S for the library name; eg: iosxr.pm. For the login script, we use a one or two character prefix added to login to differentiate them and try to keep the names unique within the filesystem. If you must create an pre-rancid 3.0 style rancid script, the name typically follows the same format as the login script. Add your definitions to rancid.types.conf(5). Alter the login script so that interactive login works; then make -c, -s, and -x work. There are more tips on testing the login script earlier in this FAQ. After the login script works, work on the rancid library. First the inloop function, followed by the filter functions. See tips regarding rancid -d and .raw files earlier in this FAQ. Q. I wish to extend an existing rancid device type with an additional command or alter the filtering of an existing command. What is the recommended way to do this? A. It is recommended that a new device type is defined, so that future upgrades can proceed more smoothly. To do so, read the previous question in this FAQ and see the device type iosshtech in rancid.types.conf(5) for an example of altering the commands run for an existing device type ("ios"), adding a command and adding a new filtering function. 5) O/S specific 5a) General Q. After an O/S upgrade, ssh logins are failing errors such as: Unable to negotiate with IP port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1 or %SSH-3-DH_RANGE_FAIL: Client DH key range mismatch with maximum configured DH key on server. A. The latest openssh has dropped support for less secure ciphers, but many devices do not support the newer ciphers, kex, etc. Work-arounds: Set a different cipher in your .cloginrc, eg: add cyphertype * {aes256-cbc} Re-enable the old kex method in your ssh_config (weakdh.org): Host * GSSAPIAuthentication yes KexAlgorithms +diffie-hellman-group1-sha1 Increase the key size in Cisco config: ip ssh dh min size 4096 5b) Linux Q. Some device collections have erroneously duplicated characters and which characters are duplicated often change between collections. Such as: - access-list 1 permit x.x.x.101 + access-list 1 permitt x.x.x.101 A. This is likely a problem with Kerberized-telnet. See http://www.shrubbery.net/pipermail/rancid-discuss/2011-September/005929.html http://www.shrubbery.net/pipermail/rancid-discuss/2012-February/006210.html There was also a bug prior to 3.0 affecting hlogin and other login scripts that use hpuifilter. 6) E-mail problems Q. Can you help with e-mail delivery problems? A. No. rancid-discuss@, etc. are not Mail Transport Agent (MTA) support lists. There are lists specific to Postfix, Sendmail, and all other MTAs; google for those lists and ask there. But, to explain basic information about rancid's use of the MTA is simple, rancid simply uses sendmail (the executable, named so for historical purposes and not to be confused with the MTA Sendmail) to send mail to the per-rancid-group aliases described in the rancid source README and rancid.conf(5) and affected by rancid.conf(5) and build-time configure options. All mail delivery is performed by the MTA. For debugging the MTA, review logs that your MTA generates and try sending mail to the per-rancid-group aliases manually using your favorite Mail User Agent (MUA) (Mail, mail, mutt, pine, etc) and see debugging options that your MTA and MUA offer for providing more logs, delivery receipts, etc. Q. I just want to store configrurations, I do not want to receive diffs. How can I accomplish this? A. Use procmail to filter them out of your inbox. OR, redirect the mail aliases in your MTA's aliases file or database to a mailman list with no subscribers. OR, redirect the mail aliases to /dev/null. OR, set DIFFSCRIPT in rancid.conf to something that eats it's input, such as "dd of=/dev/null bs=16k". 7) I am still stuck Q. I'm still stuck on this problem. Where can I get more help? A. A discussion list is available, rancid-discuss@shrubbery.net. You must be a subscriber to post. Subscribe like this: shell% echo "subscribe" | mail rancid-discuss-request@shrubbery.net Please, no questions about Unix or MTAs. This is not a Unix, MTA, or Perl help list. If you ask such questions, you will most likely be ignored. 8) License Q. Please explain the RANCID license. A. Quite simple; read it. It is a slightly modified BSD license; it has an additional clause. rancid-3.13/mkinstalldirs000755 015615 000000 00000006723 13735672075 015613 0ustar00heaswheel000000 000000 #! /bin/sh # mkinstalldirs --- make directory hierarchy scriptversion=2018-03-07.03; # UTC # Original author: Noah Friedman # Created: 1993-05-16 # Public domain. # # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' IFS=" "" $nl" errstatus=0 dirmode= usage="\ Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... Create each directory DIR (with mode MODE, if specified), including all leading file name components. Report bugs to ." # process command line arguments while test $# -gt 0 ; do case $1 in -h | --help | --h*) # -h for help echo "$usage" exit $? ;; -m) # -m PERM arg shift test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } dirmode=$1 shift ;; --version) echo "$0 $scriptversion" exit $? ;; --) # stop option processing shift break ;; -*) # unknown option echo "$usage" 1>&2 exit 1 ;; *) # first non-opt arg break ;; esac done for file do if test -d "$file"; then shift else break fi done case $# in 0) exit 0 ;; esac # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and # mkdir -p a/c at the same time, both will detect that a is missing, # one will create a, then the other will try to create a and die with # a "File exists" error. This is a problem when calling mkinstalldirs # from a parallel make. We use --version in the probe to restrict # ourselves to GNU mkdir, which is thread-safe. case $dirmode in '') if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then echo "mkdir -p -- $*" exec mkdir -p -- "$@" else # On NextStep and OpenStep, the 'mkdir' command does not # recognize any option. It will interpret all options as # directories to create, and then abort because '.' already # exists. test -d ./-p && rmdir ./-p test -d ./--version && rmdir ./--version fi ;; *) if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && test ! -d ./--version; then echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" else # Clean up after NextStep and OpenStep mkdir. for d in ./-m ./-p ./--version "./$dirmode"; do test -d $d && rmdir $d done fi ;; esac for file do case $file in /*) pathcomp=/ ;; *) pathcomp= ;; esac oIFS=$IFS IFS=/ set fnord $file shift IFS=$oIFS for d do test "x$d" = x && continue pathcomp=$pathcomp$d case $pathcomp in -*) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr else if test ! -z "$dirmode"; then echo "chmod $dirmode $pathcomp" lasterr= chmod "$dirmode" "$pathcomp" || lasterr=$? if test ! -z "$lasterr"; then errstatus=$lasterr fi fi fi fi pathcomp=$pathcomp/ done done exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: rancid-3.13/configure000755 015615 000000 00000700267 13735672076 014721 0ustar00heaswheel000000 000000 #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for rancid 3.13. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: rancid@shrubbery.net about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='rancid' PACKAGE_TARNAME='rancid' PACKAGE_VERSION='3.13' PACKAGE_STRING='rancid 3.13' PACKAGE_BUGREPORT='rancid@shrubbery.net' PACKAGE_URL='' ac_unique_file="CHANGES" ac_default_prefix=/usr/local/rancid # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS ENV_PATH TOUCH TELNET_CMD TELNET SSH SORT RSH MKDIR ID FIND COMM GIT SVN CVS LG_PING_CMD PING_PATH MKTEMP PYTHON3 PYTHON3_PATH EXPECT_PATH PERLV PERLV_PATH TAR SENDMAIL DIFF_CMD DIFF DIRNAME ADMINMAILPLUS MAILPLUS SVN_FSTYPE RCSSYS CONF_INSTALL_FALSE CONF_INSTALL_TRUE MK_LCLSTATEDIR_FALSE MK_LCLSTATEDIR_TRUE EGREP GREP CPP am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC MAKE MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE COPYYEARS AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL PACKAGE VERSION am__quote' ac_subst_files='copyright login_top' ac_user_opts=' enable_option_checking enable_silent_rules enable_maintainer_mode enable_dependency_tracking enable_mk_localstatedir enable_conf_install with_svn with_git enable_mail_plus enable_adminmail_plus ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures rancid 3.13 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/rancid] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of rancid 3.13:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-mk-localstatedir enable creation of the local state directory at install time (default: yes) --enable-conf-install enable install of sample .conf files in sysconfdir (default: yes) --enable-mail-plus enable mail to rancid+ addresses, instead of rancid- --enable-adminmail-plus enable mail to rancid-admin+ addresses, instead of rancid-admin- Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-svn=fstype use subversion instead of cvs, with optional svn fstype (fsfs|bdb) --with-git use git instead of cvs Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF rancid configure 3.13 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ----------------------------------- ## ## Report this to rancid@shrubbery.net ## ## ----------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by rancid $as_me 3.13, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version='1.16' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='rancid' VERSION='3.13' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi COPYYEARS="1997-2019" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval else USE_MAINTAINER_MODE=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 $as_echo "$USE_MAINTAINER_MODE" >&6; } if test $USE_MAINTAINER_MODE = yes; then MAINTAINER_MODE_TRUE= MAINTAINER_MODE_FALSE='#' else MAINTAINER_MODE_TRUE='#' MAINTAINER_MODE_FALSE= fi MAINT=$MAINTAINER_MODE_TRUE # make sure MAKE sets ${MAKE} # Extract the first word of "gmake", so it can be a program name with args. set dummy gmake; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MAKE+:} false; then : $as_echo_n "(cached) " >&6 else case $MAKE in [\\/]* | ?:[\\/]*) ac_cv_path_MAKE="$MAKE" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_MAKE="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_MAKE" && ac_cv_path_MAKE="no" ;; esac fi MAKE=$ac_cv_path_MAKE if test -n "$MAKE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKE" >&5 $as_echo "$MAKE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test $MAKE = no; then unset ac_cv_path_MAKE # Extract the first word of "make", so it can be a program name with args. set dummy make; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MAKE+:} false; then : $as_echo_n "(cached) " >&6 else case $MAKE in [\\/]* | ?:[\\/]*) ac_cv_path_MAKE="$MAKE" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_MAKE="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_MAKE" && ac_cv_path_MAKE="no" ;; esac fi MAKE=$ac_cv_path_MAKE if test -n "$MAKE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKE" >&5 $as_echo "$MAKE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test $MAKE = no; then as_fn_error $? "can't locate a make." "$LINENO" 5 exit 1 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi # compiler specifics ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 $as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } cat > confinc.mk << 'END' am__doit: @echo this is the am__doit target >confinc.out .PHONY: am__doit END am__include="#" am__quote= # BSD make does it like this. echo '.include "confinc.mk" # ignored' > confmf.BSD # Other make implementations (GNU, Solaris 10, AIX) do it like this. echo 'include confinc.mk # ignored' > confmf.GNU _am_result=no for s in GNU BSD; do { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } case $?:`cat confinc.out 2>/dev/null` in #( '0:this is the am__doit target') : case $s in #( BSD) : am__include='.include' am__quote='"' ;; #( *) : am__include='include' am__quote='' ;; esac ;; #( *) : ;; esac if test "$am__include" != "#"; then _am_result="yes ($s style)" break fi done rm -f confinc.* confmf.* { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 $as_echo "${_am_result}" >&6; } # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for preprocessor stringizing operator" >&5 $as_echo_n "checking for preprocessor stringizing operator... " >&6; } if ${ac_cv_c_stringize+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define x(y) #y char *s = x(teststring); _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "#teststring" >/dev/null 2>&1; then : ac_cv_c_stringize=no else ac_cv_c_stringize=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stringize" >&5 $as_echo "$ac_cv_c_stringize" >&6; } if test $ac_cv_c_stringize = yes; then $as_echo "#define HAVE_STRINGIZE 1" >>confdefs.h fi # check includes/headers { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in ctype.h errno.h fcntl.h libutil.h limits.h pty.h malloc.h \ memory.h siginfo.h stdarg.h stdint.h stdlib.h string.h \ strings.h stropts.h sys/resource.h sys/time.h \ sys/types.h sys/wait.h sysexits.h unistd.h util.h wait.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # check functions for ac_func in asprintf memcpy memmove memset strerror strchr \ strrchr strstr strtok strrtok index rindex unsetenv do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in openpty do : ac_fn_c_check_func "$LINENO" "openpty" "ac_cv_func_openpty" if test "x$ac_cv_func_openpty" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OPENPTY 1 _ACEOF openpty=1 else openpty=0 fi done # openpty() is not in the default libraries. See if it is in some other lib. if test $openpty = 0; then for lib in util; do as_ac_Lib=`$as_echo "ac_cv_lib_$lib''_openpty" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openpty in -l$lib" >&5 $as_echo_n "checking for openpty in -l$lib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$lib $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char openpty (); int main () { return openpty (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_OPENPTY 1" >>confdefs.h LIBS="$LIBS -l$lib"; openpty=1; break fi done fi # If we dont have openpty, then look for /dev/ptmx for use by our own # openpty(). if test $openpty = 0; then # This check (partially) comes from expect's configure { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SVR4 style pty allocation" >&5 $as_echo_n "checking for SVR4 style pty allocation... " >&6; } if test -r /dev/ptmx ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_PTMX 1" >>confdefs.h # Some systems need libpt.a to use /dev/ptmx for ac_func in ptsname do : ac_fn_c_check_func "$LINENO" "ptsname" "ac_cv_func_ptsname" if test "x$ac_cv_func_ptsname" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_PTSNAME 1 _ACEOF fi done if test $ac_cv_func_ptsname+set != set; then # ptsname is not in the default libraries. for lib in pt; do as_ac_Lib=`$as_echo "ac_cv_lib_$lib''_ptsname" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ptsname in -l$lib" >&5 $as_echo_n "checking for ptsname in -l$lib... " >&6; } if eval \${$as_ac_Lib+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l$lib $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char ptsname (); int main () { return ptsname (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$as_ac_Lib=yes" else eval "$as_ac_Lib=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi eval ac_res=\$$as_ac_Lib { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : LIBS="$LIBS -l$lib"; break fi done fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # In OSF/1 case, SVR4 are somewhat different. # Gregory Depp 17Aug93 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OSF/1 style pty allocation" >&5 $as_echo_n "checking for OSF/1 style pty allocation... " >&6; } if test -r /dev/ptmx_bsd ; then $as_echo "#define HAVE_PTMX_OSF 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi # type checks { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } if ${ac_cv_type_signal+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi # Package-specific options/knobs # # Check if user wants us to create LOCALSTATEDIR. If it's a package-system, # they might create it themselves for book-keeping sake; eg: NetBSD { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to create the local state directory at install time" >&5 $as_echo_n "checking whether to create the local state directory at install time... " >&6; } # Check whether --enable-mk-localstatedir was given. if test "${enable_mk_localstatedir+set}" = set; then : enableval=$enable_mk_localstatedir; if test "$enable_mk_localstatedir" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } enable_mk_localstatedir="yes" fi if test "${enable_mk_localstatedir}" = yes; then MK_LCLSTATEDIR_TRUE= MK_LCLSTATEDIR_FALSE='#' else MK_LCLSTATEDIR_TRUE='#' MK_LCLSTATEDIR_FALSE= fi # Check if user wants us to install sample configurations into the sysconfdir. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install sample .conf files in sysconfdir" >&5 $as_echo_n "checking whether to install sample .conf files in sysconfdir... " >&6; } # Check whether --enable-conf-install was given. if test "${enable_conf_install+set}" = set; then : enableval=$enable_conf_install; if test "$enable_conf_install" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } enable_conf_install="yes" fi if test "${enable_conf_install}" = yes; then CONF_INSTALL_TRUE= CONF_INSTALL_FALSE='#' else CONF_INSTALL_TRUE='#' CONF_INSTALL_FALSE= fi # Configure for subversion revision control system instead of CVS. SVN_FSTYPE="--fs-type fsfs" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether subversion" >&5 $as_echo_n "checking whether subversion... " >&6; } # Check whether --with-svn was given. if test "${with_svn+set}" = set; then : withval=$with_svn; case "$withval" in yes) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } RCSSYS="svn" ;; fsfs) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes fstype fsfs" >&5 $as_echo "yes fstype fsfs" >&6; } RCSSYS="svn" SVN_FSTYPE="--fs-type fsfs" ;; bdb) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes fstype bdb" >&5 $as_echo "yes fstype bdb" >&6; } RCSSYS="svn" SVN_FSTYPE="--fs-type bdb" ;; no) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } RCSSYS="cvs" ;; *) as_fn_error $? "unknown svn fs-type $withval" "$LINENO" 5 esac else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } # Check whether --with-git was given. if test "${with_git+set}" = set; then : withval=$with_git; case "$withval" in yes) { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } RCSSYS="git" ;; no) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } RCSSYS="cvs" esac else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } RCSSYS="cvs" fi fi rd_cv_RCSSYS=$RCSSYS # Check for a preference for using mail addresses like rancid+group # instead of the standard rancid-group { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mail addresses should be in the rancid+ form" >&5 $as_echo_n "checking whether mail addresses should be in the rancid+ form... " >&6; } # Check whether --enable-mail-plus was given. if test "${enable_mail_plus+set}" = set; then : enableval=$enable_mail_plus; if test "$enable_mail_plus" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } MAILPLUS="rancid+" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } MAILPLUS="rancid-" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } MAILPLUS="rancid-" fi rd_cv_MAILPLUS=$MAILPLUS # Check for a preference for using mail addresses like rancid+admin-group # instead of the standard rancid-admin-group { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether admin mail addresses should be in the rancid-admin+ form" >&5 $as_echo_n "checking whether admin mail addresses should be in the rancid-admin+ form... " >&6; } # Check whether --enable-adminmail-plus was given. if test "${enable_adminmail_plus+set}" = set; then : enableval=$enable_adminmail_plus; if test "$enable_adminmail_plus" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: rancid-admin+" >&5 $as_echo "rancid-admin+" >&6; } ADMINMAILPLUS="rancid-admin+" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${MAILPLUS}admin-" >&5 $as_echo "${MAILPLUS}admin-" >&6; } ADMINMAILPLUS="${MAILPLUS}admin-" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${MAILPLUS}admin-" >&5 $as_echo "${MAILPLUS}admin-" >&6; } ADMINMAILPLUS="${MAILPLUS}admin-" fi rd_cv_ADMINMAILPLUS=$ADMINMAILPLUS # Extract the first word of "dirname", so it can be a program name with args. set dummy dirname; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DIRNAME+:} false; then : $as_echo_n "(cached) " >&6 else case $DIRNAME in [\\/]* | ?:[\\/]*) ac_cv_path_DIRNAME="$DIRNAME" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_DIRNAME="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_DIRNAME" && ac_cv_path_DIRNAME="no" ;; esac fi DIRNAME=$ac_cv_path_DIRNAME if test -n "$DIRNAME"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DIRNAME" >&5 $as_echo "$DIRNAME" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # locate GNU diff (one supporting the -u option) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a diff(1) that supports -u" >&5 $as_echo_n "checking for a diff(1) that supports -u... " >&6; } _DIFF_PATH=`echo $PATH:${prefix}/bin:/usr/bin:/usr/pkg/bin:/usr/local/bin:/usr/gnu/bin:/usr/contrib/bin | sed -e 's/:/ /g'` for _diff in ${_DIFF_PATH} ; do if test -e ${_diff}/diff ; then ${_diff}/diff -u -4 /dev/null /dev/null > /dev/null 2>&1 if test $? -ne 0; then # linux/gnu shit has to change options that have been around # since organized religion; see if -U 4 works. ${_diff}/diff -U 4 /dev/null /dev/null > /dev/null 2>&1 if test $? -ne 0; then if test "${ADIFF}" = "" ; then ADIFF="${_diff}/diff" ADIFF_CMD="diff -c -4" fi else DIFF="${_diff}/diff" DIFF_CMD="diff -U 4" break fi else DIFF="${_diff}/diff" DIFF_CMD="diff -u -4" break fi fi done if test "$DIFF" = "" ; then DIFF=$ADIFF DIFF_CMD=$ADIFF_CMD fi if test "$DIFF" = "" ; then as_fn_error $? "can't locate diff." "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${DIFF_CMD}" >&5 $as_echo "${DIFF_CMD}" >&6; } rd_cv_DIFF=$DIFF rd_cv_DIFF_CMD=$DIFF_CMD # Extract the first word of "sendmail", so it can be a program name with args. set dummy sendmail; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_SENDMAIL+:} false; then : $as_echo_n "(cached) " >&6 else case $SENDMAIL in [\\/]* | ?:[\\/]*) ac_cv_path_SENDMAIL="$SENDMAIL" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy="/usr/sbin:/usr/bin:/usr/lib" for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_SENDMAIL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_SENDMAIL" && ac_cv_path_SENDMAIL="no" ;; esac fi SENDMAIL=$ac_cv_path_SENDMAIL if test -n "$SENDMAIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SENDMAIL" >&5 $as_echo "$SENDMAIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "$SENDMAIL" = "no"; then echo "WARNING: sendmail not found" >&2 SENDMAIL='' fi # Find an appropriate tar for use in "dist" targets. A "best guess" # is good enough -- if we can't find GNU tar, we don't really care. for ac_prog in gnutar gtar tar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_TAR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$TAR"; then ac_cv_prog_TAR="$TAR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_TAR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi TAR=$ac_cv_prog_TAR if test -n "$TAR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAR" >&5 $as_echo "$TAR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$TAR" && break done for ac_prog in automake do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AUTOMAKE+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AUTOMAKE"; then ac_cv_prog_AUTOMAKE="$AUTOMAKE" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AUTOMAKE="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AUTOMAKE=$ac_cv_prog_AUTOMAKE if test -n "$AUTOMAKE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AUTOMAKE" >&5 $as_echo "$AUTOMAKE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AUTOMAKE" && break done # Extract the first word of "perl5", so it can be a program name with args. set dummy perl5; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PERLV_PATH+:} false; then : $as_echo_n "(cached) " >&6 else case $PERLV_PATH in [\\/]* | ?:[\\/]*) ac_cv_path_PERLV_PATH="$PERLV_PATH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PERLV_PATH="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PERLV_PATH" && ac_cv_path_PERLV_PATH="no" ;; esac fi PERLV_PATH=$ac_cv_path_PERLV_PATH if test -n "$PERLV_PATH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERLV_PATH" >&5 $as_echo "$PERLV_PATH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test $PERLV_PATH = no; then unset ac_cv_path_PERLV_PATH # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PERLV_PATH+:} false; then : $as_echo_n "(cached) " >&6 else case $PERLV_PATH in [\\/]* | ?:[\\/]*) ac_cv_path_PERLV_PATH="$PERLV_PATH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PERLV_PATH="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PERLV_PATH" && ac_cv_path_PERLV_PATH="no" ;; esac fi PERLV_PATH=$ac_cv_path_PERLV_PATH if test -n "$PERLV_PATH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PERLV_PATH" >&5 $as_echo "$PERLV_PATH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test $PERLV_PATH = no; then as_fn_error $? "can't locate a suitable perl5." "$LINENO" 5 exit 1 else $PERLV_PATH -e 'require 5;' if test $? -ne 0 ; then as_fn_error $? "can't locate a suitable perl5." "$LINENO" 5 exit 1 fi fi fi PERLV=`basename $PERLV_PATH` # check Socket.pm version { $as_echo "$as_me:${as_lineno-$LINENO}: checking Socket.pm version" >&5 $as_echo_n "checking Socket.pm version... " >&6; } $PERLV_PATH -e 'use 2.006 Socket qw(inet_pton);' 2>&1 >/dev/null if test $? -ne 0 ; then as_fn_error $? "Socket.pm is older than 2.006; upgrade from http://metacpan.org/pod/Socket" "$LINENO" 5 exit 1 fi # Extract the first word of "expect", so it can be a program name with args. set dummy expect; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_EXPECT_PATH+:} false; then : $as_echo_n "(cached) " >&6 else case $EXPECT_PATH in [\\/]* | ?:[\\/]*) ac_cv_path_EXPECT_PATH="$EXPECT_PATH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_EXPECT_PATH="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_EXPECT_PATH" && ac_cv_path_EXPECT_PATH="no" ;; esac fi EXPECT_PATH=$ac_cv_path_EXPECT_PATH if test -n "$EXPECT_PATH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $EXPECT_PATH" >&5 $as_echo "$EXPECT_PATH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test $EXPECT_PATH = no; then as_fn_error $? "can't locate expect." "$LINENO" 5 fi # look for lockfile utility # Extract the first word of "mktemp", so it can be a program name with args. set dummy mktemp; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MKTEMP+:} false; then : $as_echo_n "(cached) " >&6 else case $MKTEMP in [\\/]* | ?:[\\/]*) ac_cv_path_MKTEMP="$MKTEMP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_MKTEMP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_MKTEMP" && ac_cv_path_MKTEMP="no" ;; esac fi MKTEMP=$ac_cv_path_MKTEMP if test -n "$MKTEMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKTEMP" >&5 $as_echo "$MKTEMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test $MKTEMP = no; then unset ac_cv_path_MKTEMP as_fn_error $? "can't locate a mktemp(1)." "$LINENO" 5 fi # locate ping and it's syntax # Extract the first word of "ping", so it can be a program name with args. set dummy ping; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PING_PATH+:} false; then : $as_echo_n "(cached) " >&6 else case $PING_PATH in [\\/]* | ?:[\\/]*) ac_cv_path_PING_PATH="$PING_PATH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/sbin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PING_PATH="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_PING_PATH" && ac_cv_path_PING_PATH="no" ;; esac fi PING_PATH=$ac_cv_path_PING_PATH if test -n "$PING_PATH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PING_PATH" >&5 $as_echo "$PING_PATH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test $PING_PATH = no; then as_fn_error $? "can't locate ping." "$LINENO" 5 exit 1 fi # ping seems to take one of two formats for count (N) # BSD: ping -c N host # SVR: ping host N $PING_PATH -c 1 -v 127.0.0.1 > /dev/null 2>&1 if test $? -eq 0 ; then LG_PING_CMD="$PING_PATH -c 1" else $PING_PATH 127.0.0.1 56 1 > /dev/null 2>&1 if test $? -eq 0 ; then LG_PING_CMD="$PING_PATH" else # cygwin using windows ping? $PING_PATH -n 1 127.0.0.1 > /dev/null 2>&1 if test $? -eq 0 ; then LG_PING_CMD="$PING_PATH -n 1" else as_fn_error $? "can't figure out how to pass count == 1 to $PING_PATH." "$LINENO" 5 exit 1 fi fi fi rd_cv_lg_ping_cmd=$LG_PING_CMD # locate tools to build $PATH for rancid.conf. order is significant. want # to be sure that we pick up the the proper diff and ucbmail in # etc/rancid.conf. ENV_PATH="`dirname $PERLV_PATH`:`dirname $EXPECT_PATH`:`dirname \"$SENDMAIL\"`" ENV_PATH="$ENV_PATH:`dirname $DIRNAME`:`dirname $DIFF`:`dirname $MKTEMP`" if test $RCSSYS = "cvs" ; then # Extract the first word of "cvs", so it can be a program name with args. set dummy cvs; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_CVS+:} false; then : $as_echo_n "(cached) " >&6 else case $CVS in [\\/]* | ?:[\\/]*) ac_cv_path_CVS="$CVS" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_CVS="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_CVS" && ac_cv_path_CVS="no" ;; esac fi CVS=$ac_cv_path_CVS if test -n "$CVS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CVS" >&5 $as_echo "$CVS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_CVS`" elif test $RCSSYS = "svn" ; then # Extract the first word of "svn", so it can be a program name with args. set dummy svn; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_SVN+:} false; then : $as_echo_n "(cached) " >&6 else case $SVN in [\\/]* | ?:[\\/]*) ac_cv_path_SVN="$SVN" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_SVN="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_SVN" && ac_cv_path_SVN="no" ;; esac fi SVN=$ac_cv_path_SVN if test -n "$SVN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SVN" >&5 $as_echo "$SVN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_SVN`" else # Extract the first word of "git", so it can be a program name with args. set dummy git; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GIT+:} false; then : $as_echo_n "(cached) " >&6 else case $GIT in [\\/]* | ?:[\\/]*) ac_cv_path_GIT="$GIT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_GIT="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_GIT" && ac_cv_path_GIT="no" ;; esac fi GIT=$ac_cv_path_GIT if test -n "$GIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GIT" >&5 $as_echo "$GIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_GIT`" fi # Extract the first word of "comm", so it can be a program name with args. set dummy comm; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_COMM+:} false; then : $as_echo_n "(cached) " >&6 else case $COMM in [\\/]* | ?:[\\/]*) ac_cv_path_COMM="$COMM" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_COMM="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_COMM" && ac_cv_path_COMM="no" ;; esac fi COMM=$ac_cv_path_COMM if test -n "$COMM"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $COMM" >&5 $as_echo "$COMM" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_COMM`" # Extract the first word of "find", so it can be a program name with args. set dummy find; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_FIND+:} false; then : $as_echo_n "(cached) " >&6 else case $FIND in [\\/]* | ?:[\\/]*) ac_cv_path_FIND="$FIND" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_FIND="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_FIND" && ac_cv_path_FIND="no" ;; esac fi FIND=$ac_cv_path_FIND if test -n "$FIND"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FIND" >&5 $as_echo "$FIND" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_FIND`" # Extract the first word of "grep", so it can be a program name with args. set dummy grep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else case $GREP in [\\/]* | ?:[\\/]*) ac_cv_path_GREP="$GREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_GREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_GREP" && ac_cv_path_GREP="no" ;; esac fi GREP=$ac_cv_path_GREP if test -n "$GREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GREP" >&5 $as_echo "$GREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_GREP`" # Extract the first word of "id", so it can be a program name with args. set dummy id; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ID+:} false; then : $as_echo_n "(cached) " >&6 else case $ID in [\\/]* | ?:[\\/]*) ac_cv_path_ID="$ID" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ID="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_ID" && ac_cv_path_ID="no" ;; esac fi ID=$ac_cv_path_ID if test -n "$ID"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ID" >&5 $as_echo "$ID" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_ID`" # Extract the first word of "mkdir", so it can be a program name with args. set dummy mkdir; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_MKDIR+:} false; then : $as_echo_n "(cached) " >&6 else case $MKDIR in [\\/]* | ?:[\\/]*) ac_cv_path_MKDIR="$MKDIR" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_MKDIR="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_MKDIR" && ac_cv_path_MKDIR="no" ;; esac fi MKDIR=$ac_cv_path_MKDIR if test -n "$MKDIR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR" >&5 $as_echo "$MKDIR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_MKDIR`" # Extract the first word of "rsh", so it can be a program name with args. set dummy rsh; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_RSH+:} false; then : $as_echo_n "(cached) " >&6 else case $RSH in [\\/]* | ?:[\\/]*) ac_cv_path_RSH="$RSH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_RSH="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_RSH" && ac_cv_path_RSH="no" ;; esac fi RSH=$ac_cv_path_RSH if test -n "$RSH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RSH" >&5 $as_echo "$RSH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_RSH`" # Extract the first word of "sort", so it can be a program name with args. set dummy sort; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_SORT+:} false; then : $as_echo_n "(cached) " >&6 else case $SORT in [\\/]* | ?:[\\/]*) ac_cv_path_SORT="$SORT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_SORT="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_SORT" && ac_cv_path_SORT="no" ;; esac fi SORT=$ac_cv_path_SORT if test -n "$SORT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SORT" >&5 $as_echo "$SORT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_SORT`" # Extract the first word of "ssh", so it can be a program name with args. set dummy ssh; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_SSH+:} false; then : $as_echo_n "(cached) " >&6 else case $SSH in [\\/]* | ?:[\\/]*) ac_cv_path_SSH="$SSH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_SSH="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_SSH" && ac_cv_path_SSH="no" ;; esac fi SSH=$ac_cv_path_SSH if test -n "$SSH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SSH" >&5 $as_echo "$SSH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_SSH`" # Extract the first word of "telnet", so it can be a program name with args. set dummy telnet; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_TELNET+:} false; then : $as_echo_n "(cached) " >&6 else case $TELNET in [\\/]* | ?:[\\/]*) ac_cv_path_TELNET="$TELNET" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_TELNET="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_TELNET" && ac_cv_path_TELNET="no" ;; esac fi TELNET=$ac_cv_path_TELNET if test -n "$TELNET"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TELNET" >&5 $as_echo "$TELNET" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_TELNET`" # test if telnet accepts -K $ac_cv_path_TELNET -K < /dev/null > /dev/null 2>&1 if test $? -eq 0 ; then TELNET_CMD="telnet -K" else TELNET_CMD="telnet" fi # Extract the first word of "touch", so it can be a program name with args. set dummy touch; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_TOUCH+:} false; then : $as_echo_n "(cached) " >&6 else case $TOUCH in [\\/]* | ?:[\\/]*) ac_cv_path_TOUCH="$TOUCH" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_TOUCH="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_TOUCH" && ac_cv_path_TOUCH="no" ;; esac fi TOUCH=$ac_cv_path_TOUCH if test -n "$TOUCH"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TOUCH" >&5 $as_echo "$TOUCH" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_TOUCH`" ENV_PATH="$ENV_PATH:/usr/local/bin:/usr/bin" ENV_PATH=`echo $ENV_PATH | $PERLV_PATH -e 'foreach $x(split(":",<>)){next unless (length($x));next if ($x =~ /^\.$/);$x =~ s/\n\r*//;push(@F, $x),$seen{$x}=1 unless (defined $seen{$x});}print join(":",@F);'` ac_cv_env_path=$ENV_PATH ac_config_files="$ac_config_files Makefile" ac_config_files="$ac_config_files bin/Makefile" ac_config_files="$ac_config_files etc/Makefile" ac_config_files="$ac_config_files include/Makefile" ac_config_files="$ac_config_files lib/Makefile" ac_config_files="$ac_config_files man/Makefile" ac_config_files="$ac_config_files share/Makefile" ac_config_files="$ac_config_files include/version.h" # this is not a header in the sense of # AC_CONFIG_HEADERS will cause # autoheader to overwrite it, while all # want is simple variable replacement # autoheader bits ac_config_headers="$ac_config_headers include/config.h" ac_config_files="$ac_config_files bin/login_top" copyright=$srcdir/COPYING login_top=$srcdir/bin/login_top ac_config_files="$ac_config_files bin/a10login" ac_config_files="$ac_config_files bin/agmrancid" ac_config_files="$ac_config_files bin/alogin bin/arancid" ac_config_files="$ac_config_files bin/anlogin" ac_config_files="$ac_config_files bin/avologin" ac_config_files="$ac_config_files bin/blogin bin/brancid" ac_config_files="$ac_config_files bin/brlogin" ac_config_files="$ac_config_files bin/cat5rancid bin/clogin" ac_config_files="$ac_config_files bin/csblogin" ac_config_files="$ac_config_files bin/cssrancid" ac_config_files="$ac_config_files bin/dllogin" ac_config_files="$ac_config_files bin/elogin bin/erancid" ac_config_files="$ac_config_files bin/f5rancid" ac_config_files="$ac_config_files bin/flogin" ac_config_files="$ac_config_files bin/fnlogin" ac_config_files="$ac_config_files bin/fxlogin" ac_config_files="$ac_config_files bin/hlogin" ac_config_files="$ac_config_files bin/htlogin bin/htrancid" ac_config_files="$ac_config_files bin/jlogin bin/jerancid" ac_config_files="$ac_config_files bin/mrancid bin/mrvlogin" ac_config_files="$ac_config_files bin/mtlogin" ac_config_files="$ac_config_files bin/nlogin bin/nrancid" ac_config_files="$ac_config_files bin/noklogin" ac_config_files="$ac_config_files bin/nslogin bin/nsrancid" ac_config_files="$ac_config_files bin/panlogin" ac_config_files="$ac_config_files bin/rblogin" ac_config_files="$ac_config_files bin/rivlogin bin/rivrancid" ac_config_files="$ac_config_files bin/rrancid" ac_config_files="$ac_config_files bin/rtftpcopy" ac_config_files="$ac_config_files bin/tlogin" ac_config_files="$ac_config_files bin/trancid" ac_config_files="$ac_config_files bin/xilogin bin/xirancid" ac_config_files="$ac_config_files bin/xlogin" ac_config_files="$ac_config_files bin/ulogin" ac_config_files="$ac_config_files bin/wlogin" ac_config_files="$ac_config_files share/rtrfilter" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${MK_LCLSTATEDIR_TRUE}" && test -z "${MK_LCLSTATEDIR_FALSE}"; then as_fn_error $? "conditional \"MK_LCLSTATEDIR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${CONF_INSTALL_TRUE}" && test -z "${CONF_INSTALL_FALSE}"; then as_fn_error $? "conditional \"CONF_INSTALL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by rancid $as_me 3.13, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ rancid config.status 3.13 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "bin/Makefile") CONFIG_FILES="$CONFIG_FILES bin/Makefile" ;; "etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;; "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; "share/Makefile") CONFIG_FILES="$CONFIG_FILES share/Makefile" ;; "include/version.h") CONFIG_FILES="$CONFIG_FILES include/version.h" ;; "include/config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;; "bin/login_top") CONFIG_FILES="$CONFIG_FILES bin/login_top" ;; "bin/a10login") CONFIG_FILES="$CONFIG_FILES bin/a10login" ;; "bin/agmrancid") CONFIG_FILES="$CONFIG_FILES bin/agmrancid" ;; "bin/alogin") CONFIG_FILES="$CONFIG_FILES bin/alogin" ;; "bin/arancid") CONFIG_FILES="$CONFIG_FILES bin/arancid" ;; "bin/anlogin") CONFIG_FILES="$CONFIG_FILES bin/anlogin" ;; "bin/avologin") CONFIG_FILES="$CONFIG_FILES bin/avologin" ;; "bin/blogin") CONFIG_FILES="$CONFIG_FILES bin/blogin" ;; "bin/brancid") CONFIG_FILES="$CONFIG_FILES bin/brancid" ;; "bin/brlogin") CONFIG_FILES="$CONFIG_FILES bin/brlogin" ;; "bin/cat5rancid") CONFIG_FILES="$CONFIG_FILES bin/cat5rancid" ;; "bin/clogin") CONFIG_FILES="$CONFIG_FILES bin/clogin" ;; "bin/csblogin") CONFIG_FILES="$CONFIG_FILES bin/csblogin" ;; "bin/cssrancid") CONFIG_FILES="$CONFIG_FILES bin/cssrancid" ;; "bin/dllogin") CONFIG_FILES="$CONFIG_FILES bin/dllogin" ;; "bin/elogin") CONFIG_FILES="$CONFIG_FILES bin/elogin" ;; "bin/erancid") CONFIG_FILES="$CONFIG_FILES bin/erancid" ;; "bin/f5rancid") CONFIG_FILES="$CONFIG_FILES bin/f5rancid" ;; "bin/flogin") CONFIG_FILES="$CONFIG_FILES bin/flogin" ;; "bin/fnlogin") CONFIG_FILES="$CONFIG_FILES bin/fnlogin" ;; "bin/fxlogin") CONFIG_FILES="$CONFIG_FILES bin/fxlogin" ;; "bin/hlogin") CONFIG_FILES="$CONFIG_FILES bin/hlogin" ;; "bin/htlogin") CONFIG_FILES="$CONFIG_FILES bin/htlogin" ;; "bin/htrancid") CONFIG_FILES="$CONFIG_FILES bin/htrancid" ;; "bin/jlogin") CONFIG_FILES="$CONFIG_FILES bin/jlogin" ;; "bin/jerancid") CONFIG_FILES="$CONFIG_FILES bin/jerancid" ;; "bin/mrancid") CONFIG_FILES="$CONFIG_FILES bin/mrancid" ;; "bin/mrvlogin") CONFIG_FILES="$CONFIG_FILES bin/mrvlogin" ;; "bin/mtlogin") CONFIG_FILES="$CONFIG_FILES bin/mtlogin" ;; "bin/nlogin") CONFIG_FILES="$CONFIG_FILES bin/nlogin" ;; "bin/nrancid") CONFIG_FILES="$CONFIG_FILES bin/nrancid" ;; "bin/noklogin") CONFIG_FILES="$CONFIG_FILES bin/noklogin" ;; "bin/nslogin") CONFIG_FILES="$CONFIG_FILES bin/nslogin" ;; "bin/nsrancid") CONFIG_FILES="$CONFIG_FILES bin/nsrancid" ;; "bin/panlogin") CONFIG_FILES="$CONFIG_FILES bin/panlogin" ;; "bin/rblogin") CONFIG_FILES="$CONFIG_FILES bin/rblogin" ;; "bin/rivlogin") CONFIG_FILES="$CONFIG_FILES bin/rivlogin" ;; "bin/rivrancid") CONFIG_FILES="$CONFIG_FILES bin/rivrancid" ;; "bin/rrancid") CONFIG_FILES="$CONFIG_FILES bin/rrancid" ;; "bin/rtftpcopy") CONFIG_FILES="$CONFIG_FILES bin/rtftpcopy" ;; "bin/tlogin") CONFIG_FILES="$CONFIG_FILES bin/tlogin" ;; "bin/trancid") CONFIG_FILES="$CONFIG_FILES bin/trancid" ;; "bin/xilogin") CONFIG_FILES="$CONFIG_FILES bin/xilogin" ;; "bin/xirancid") CONFIG_FILES="$CONFIG_FILES bin/xirancid" ;; "bin/xlogin") CONFIG_FILES="$CONFIG_FILES bin/xlogin" ;; "bin/ulogin") CONFIG_FILES="$CONFIG_FILES bin/ulogin" ;; "bin/wlogin") CONFIG_FILES="$CONFIG_FILES bin/wlogin" ;; "share/rtrfilter") CONFIG_FILES="$CONFIG_FILES share/rtrfilter" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then if $AWK 'BEGIN { getline <"/dev/null" }' /dev/null; then ac_cs_awk_getline=: ac_cs_awk_pipe_init= ac_cs_awk_read_file=' while ((getline aline < (F[key])) > 0) print(aline) close(F[key])' ac_cs_awk_pipe_fini= else ac_cs_awk_getline=false ac_cs_awk_pipe_init="print \"cat <<'|#_!!_#|' &&\"" ac_cs_awk_read_file=' print "|#_!!_#|" print "cat " F[key] " &&" '$ac_cs_awk_pipe_init # The final `:' finishes the AND list. ac_cs_awk_pipe_fini='END { print "|#_!!_#|"; print ":" }' fi ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF # Create commands to substitute file output variables. { echo "cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1" && echo 'cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&' && echo "$ac_subst_files" | sed 's/.*/F["&"]="$&"/' && echo "_ACAWK" && echo "_ACEOF" } >conf$$files.sh && . ./conf$$files.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 rm -f conf$$files.sh { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" \$ac_cs_awk_pipe_init } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } if (nfields == 3 && !substed) { key = field[2] if (F[key] != "" && line ~ /^[ ]*@.*@[ ]*$/) { \$ac_cs_awk_read_file next } } print line } \$ac_cs_awk_pipe_fini _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | if $ac_cs_awk_getline; then $AWK -f "$ac_tmp/subs.awk" else $AWK -f "$ac_tmp/subs.awk" | $SHELL fi \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. # TODO: see whether this extra hack can be removed once we start # requiring Autoconf 2.70 or later. case $CONFIG_FILES in #( *\'*) : eval set x "$CONFIG_FILES" ;; #( *) : set x $CONFIG_FILES ;; #( *) : ;; esac shift # Used to flag and report bootstrapping failures. am_rc=0 for am_mf do # Strip MF so we end up with the name of the file. am_mf=`$as_echo "$am_mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile which includes # dependency-tracking related rules and includes. # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ || continue am_dirpart=`$as_dirname -- "$am_mf" || $as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$am_mf" : 'X\(//\)[^/]' \| \ X"$am_mf" : 'X\(//\)$' \| \ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$am_mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` am_filepart=`$as_basename -- "$am_mf" || $as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ X"$am_mf" : 'X\(//\)$' \| \ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$am_mf" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` { echo "$as_me:$LINENO: cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles" >&5 (cd "$am_dirpart" \ && sed -e '/# am--include-marker/d' "$am_filepart" \ | $MAKE -f - am--depfiles) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } || am_rc=$? done if test $am_rc -ne 0; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Something went wrong bootstrapping makefile fragments for automatic dependency tracking. If GNU make was not used, consider re-running the configure script with MAKE=\"gmake\" (or whatever is necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking). See \`config.log' for more details" "$LINENO" 5; } fi { am_dirpart=; unset am_dirpart;} { am_filepart=; unset am_filepart;} { am_mf=; unset am_mf;} { am_rc=; unset am_rc;} rm -f conftest-deps.mk } ;; "bin/a10login":F) chmod a+x $ac_file ;; "bin/agmrancid":F) chmod a+x $ac_file ;; "bin/alogin":F) chmod a+x $ac_file ;; "bin/arancid":F) chmod a+x $ac_file ;; "bin/anlogin":F) chmod a+x $ac_file ;; "bin/avologin":F) chmod a+x $ac_file ;; "bin/blogin":F) chmod a+x $ac_file ;; "bin/brancid":F) chmod a+x $ac_file ;; "bin/brlogin":F) chmod a+x $ac_file ;; "bin/cat5rancid":F) chmod a+x $ac_file ;; "bin/clogin":F) chmod a+x $ac_file ;; "bin/csblogin":F) chmod a+x $ac_file ;; "bin/cssrancid":F) chmod a+x $ac_file ;; "bin/dllogin":F) chmod a+x $ac_file ;; "bin/elogin":F) chmod a+x $ac_file ;; "bin/erancid":F) chmod a+x $ac_file ;; "bin/f5rancid":F) chmod a+x $ac_file ;; "bin/flogin":F) chmod a+x $ac_file ;; "bin/fnlogin":F) chmod a+x $ac_file ;; "bin/fxlogin":F) chmod a+x $ac_file ;; "bin/hlogin":F) chmod a+x $ac_file ;; "bin/htlogin":F) chmod a+x $ac_file ;; "bin/htrancid":F) chmod a+x $ac_file ;; "bin/jlogin":F) chmod a+x $ac_file ;; "bin/jerancid":F) chmod a+x $ac_file ;; "bin/mrancid":F) chmod a+x $ac_file ;; "bin/mrvlogin":F) chmod a+x $ac_file ;; "bin/mtlogin":F) chmod a+x $ac_file ;; "bin/nlogin":F) chmod a+x $ac_file ;; "bin/nrancid":F) chmod a+x $ac_file ;; "bin/noklogin":F) chmod a+x $ac_file ;; "bin/nslogin":F) chmod a+x $ac_file ;; "bin/nsrancid":F) chmod a+x $ac_file ;; "bin/panlogin":F) chmod a+x $ac_file ;; "bin/rblogin":F) chmod a+x $ac_file ;; "bin/rivlogin":F) chmod a+x $ac_file ;; "bin/rivrancid":F) chmod a+x $ac_file ;; "bin/rrancid":F) chmod a+x $ac_file ;; "bin/rtftpcopy":F) chmod a+x $ac_file ;; "bin/tlogin":F) chmod a+x $ac_file ;; "bin/trancid":F) chmod a+x $ac_file ;; "bin/xilogin":F) chmod a+x $ac_file ;; "bin/xirancid":F) chmod a+x $ac_file ;; "bin/xlogin":F) chmod a+x $ac_file ;; "bin/ulogin":F) chmod a+x $ac_file ;; "bin/wlogin":F) chmod a+x $ac_file ;; "share/rtrfilter":F) chmod a+x $ac_file ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi rancid-3.13/README.lg000644 015615 000000 00000010000 13465702362 014236 0ustar00heaswheel000000 000000 This is a looking glass based on Ed Kern's which used to be available on http://nitrous.digex.net/. This version supports cisco, juniper, and foundry, using rancid's [cfj]login to login (so rcmd is not necessary, it can use telnet, ssh, or rsh), and has some additional commands implemented. There are a few cisco commands where either no juniper or foundry equivalent exists or we have not had time to implement yet. packing list: README This file. index.html often the default document the server will load, contains an html redirect to load lgform.cgi lg.conf looking glass configuration file lg.cgi work horse of the looking glass lgform.cgi front-end form for the looking glass engine lgnotes.html user info for the looking glass The looking glass requires the CGI and LockFile-Simple perl modules. these can be retrieved from CPAN, http://www.cpan.org/. CGI's home is ftp://ftp-genome.wi.mit.edu/pub/software/WWW/. It also requires the POSIX module (for strftime) and Sys::Syslog, which I believe comes with perl5 and/or are converted with h2ph(1). basic installation instructions: The configure and make install process will make variable substitutions and install the looking glass bits. Assuming configure was run without directory options, such as --prefix, the default install prefix is /usr/local/rancid. So, the bits will be installed in /usr/local/rancid/etc/lg.conf, /usr/local/rancid/bin, and /usr/local/rancid/share/rancid (i.e.: /etc/lg.conf, etc.). 1) Make the scripts and html files available to your server (httpd) by creating a directory in your server's document root directory (apache's httpd.conf "DocumentRoot" variable). For example: mkdir /usr/local/htdocs/lg Then either: - copy the files /share/rancid/{index.html,lgnotes.html} and /bin/{lg.cgi,lgform.cgi} to /usr/local/htdocs/lg OR - create symlinks from /usr/local/htdocs/lg to each of these files. Note on links: if you use symlinks, you have to configure apache to allow following symlinks. e.g.: % cat /usr/local/htdocs/lg/.htaccess Options FollowSymLinks ExecCGI Note on index.html: index.html is typically the default file loaded when a url ends with a '/'. index.html can be used to redirect this to lgform.cgi using a netscape meta refresh. Though this is supported by many browsers, it is supposedly netscape specific and non-standard. In apache, the same thing can be acheived by altering the default directory index like this: % cat /usr/local/htdocs/lg/.htaccess Options ExecCGI DirectoryIndex lgform.cgi 2) The looking glass scripts need to be able to find and read lg.conf. By default it is installed as /lg.conf (/etc/lg.conf) and the scripts will first look in their CWD (Current Working Directory) and then /lg.conf, if it does not exist in the CWD. However, the LG_CONF environment variable can be used to move it elsewhere. To get LG_CONF into the CGI enviroment, you can use SetEnvIf in apache's httpd.conf. For example: SetEnvIf Request_URI "\/lg/.*.cgi" LG_CONF=/usr/local/htdocs/lg/lg.conf Note: if you have chosen to locate your router.db (or other possibly sensitive files in the http docs heirarchy, you may wish to restrict download permission for these files. Something like: % cat /usr/local/htdocs/lg/.htaccess Order allow,deny Deny from all Satisfy All 3) Edit /lg.conf (usually /etc/lg.conf). See lg.conf(5) for additional information. 4) Set-up cron jobs to rotate the log file and clean out old cache files. See LG_CACHE_DIR & LG_LOG in lg.conf. Something like (YMMV): # rotate lookingglass log #0 0 * * * cd /usr/local/htdocs/lg/tmp; /usr/local/etc/savelog -m 666 -c14 lg.log 0 0 * * * cd /usr/local/htdocs/lg/tmp; /bin/mv lg.log lg.log.0 # clean out the lookingglass cache 0 0 * * * cd /usr/local/htdocs/lg/tmp; /usr/local/bin/find . -type f -maxdepth 1 \( \! -name lg.log\* \) -mtime +1 -exec rm -f {} \; rancid-3.13/etc/000755 015615 000000 00000000000 13735706334 013544 5ustar00heaswheel000000 000000 rancid-3.13/COPYING000644 015615 000000 00000004473 13534015563 014026 0ustar00heaswheel000000 000000 ## Copyright (c) 1997-2019 by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. rancid-3.13/include/000755 015615 000000 00000000000 13735706334 014414 5ustar00heaswheel000000 000000 rancid-3.13/bin/000755 015615 000000 00000000000 13735706334 013541 5ustar00heaswheel000000 000000 rancid-3.13/BUGS000644 015615 000000 00000000046 13465702362 013451 0ustar00heaswheel000000 000000 See the the file Todo for known bugs. rancid-3.13/compile000755 015615 000000 00000016350 13735672075 014360 0ustar00heaswheel000000 000000 #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2018-03-07.03; # UTC # Copyright (C) 1999-2020 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN* | MSYS*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/* | msys/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: rancid-3.13/README000644 015615 000000 00000040705 13713052202 013637 0ustar00heaswheel000000 000000 RANCiD is a "Really Awesome New Cisco confIg Differ" developed to maintain CVS (or Subversion or git) controlled copies of router configs. *** The Following Information is Very Important **** Rancid 3.0 converts several device scripts (the remaining will follow) to libraries used by the single script, named rancid, to parse device output. It also requires perl 5.10 minimum. Also see the UPGRADING file. Rancid 2.3 introduces a new directory layout. It has been changed to more closely follow the standard path hierarchy, which is defined by the FHS standard and autoconf, and/or make these locations more easily configurable within rancid. The obvious advantage of this is making rancid more easily packagable; i.e.: NetBSD pkgsrc, FreeBSD port, Linux RPM, etc. Please please please please read the UPGRADING file for more information. ********** The following is the packing list for Rancid, excluding files supporting configure (autoconf) and make. .in is stripped from the files below by configure as substitutions are completed: README This file. README.lg Information about the Looking Glass. BUGS Bug list. CHANGES List of changes to Rancid. COPYING RANCID license. FAQ Frequently Asked Questions Todo Partial list of what needs to be done. UPGRADING Notes on upgrading rancid to a new version. cloginrc.sample TCL commands to set passwords, usernames etc. used by clogin and jlogin. See cloginrc(5) etc/ lg.conf.sample Sample Looking Glass configuration rancid.conf.sample Sample RANCID configuration rancid.types.base RANCID default device type configuration rancid.types.conf RANCID user-defined device type configuration bin/ control_rancid.in Builds router list, calls rancid on each router and handles cvs routines. hpuifilter.c HP procurve login filter - see hlogin(1). par.c Parallel processing of commands - any commands. rancid-cvs.in Creates all of the CVS and config directories. rancid-fe.in Used by crontrol_rancid to determine script rancid used rancid-run.in Script designed to be run from cron. rancid.in Generic wrapper for the rancid for the rancid libraries that runs commands on their respective device types as defined in etc/rancid.types.* and processes the output. agmrancid.in Version of rancid.in for Cisco Anomaly Guard Module (AGM) arancid.in Version of rancid.in for Alteon switches. brancid.in Version of rancid.in for baynet/nortel routers. cat5rancid.in Version of rancid.in for Cisco Catalyst switches. cssrancid.in Version of rancid.in for Cisco CSS switches. erancid.in Version of rancid.in for ADC EZ-T3 muxes. f5rancid.in Version of rancid.in for F5 BigIPs. hrancid.in Version of rancid.in for HP Procurve switches. htrancid.in Version of rancid.in for Hitatchi routers. jerancid.in Version of rancid.in for Juniper E-series routers. mrancid.in Version of rancid.in for MRT daemons. nrancid.in Version of rancid.in for Netscreen firewalls. nsrancid.in Version of rancid.in for Netscalers. rivancid.in Version of rancid.in for Cabletron, Riverstone and Enterasys routers. rrancid.in Version of rancid.in for Redback routers. rtftpcopy.in Copy configs from tftpboot within rancid. trancid.in Version of rancid.in for Netopia routers. xirancid.in Version of rancid.in for Xirrus arrays. a10login.in Version of clogin.in for A10 load balancers. alogin.in Version of clogin.in for Alteon switches. anlogin.in Version of clogin.in for Arbor Networks appliances. avologin.in Version of clogin.in for Avocent appliances. blogin.in Version of clogin.in for baynet/Nortel routers. brlogin.in Version of clogin.in for Brocade switches. clogin.in Expect script that logs into routers and either presents an interactive shell, runs a set of commands, or runs another expect script. It handles Cisco, Extreme, Force10, Juniper E-series, Redback, Zebra/MRT. complogin.in Version of clogin.in for Compass Networks routers. csblogin.in Version of clogin.in for Cisco Small Business switches. dllogin.in Version of clogin.in for D-Link devices. elogin.in Version of clogin.in for ADC EZ-T3 muxes. flogin.in Version of clogin.in for Foundry switches. If foundry cleaned-up their bloody UI, clogin should do the job. fxlogin.in Version of clogin.in for Cisco Firepower FX-OS. fnlogin.in Version of clogin.in for Fortinet Firewalls. hlogin.in Version of clogin.in for HP procurve switches. htlogin.in Version of clogin.in for Hitatchi routers. jlogin.in Version of clogin.in for Juniper routers. login_top.in Common login code included in all login scripts. mtlogin.in Version of clogin.in for Microtik routers. nlogin.in Version of clogin.in for Netscreen firewalls. noklogin.in Version of clogin.in for Nokia (Alcatel-Lucent) 7705 SAR, 7210 SAS, 7750 SR and 7950 XRS routers. nslogin.in Version of clogin.in for Netscalers. panlogin.in Version of clogin.in for Palo Alto Networks devices. plogin.in Poly-login version of clogin.in; it uses router.db and router.types.* configuration files to determine the login script to use for a device. rblogin.in Version of clogin.in for Riverbed Steelhead routers. rivlogin.in Version of clogin.in for Riverstone routers. tlogin.in Version of clogin.in for Netopia devices. wlogin.in Version of clogin.in for Cisco Wireless Lan Controllers. xlogin.in Version of clogin.in for Extreme devices. xilogin.in Version of clogin.in for Xirrus arrays. lib/ acos.pm.in rancid library for A10 Networks appliances. aeos.pm.in rancid library for Arista Networks EOS. arbor.pm.in rancid library for Arbor Networks appliances. arcos.pm.in rancid library for Arrcus Networks ArcOS. avocent.pm.in rancid library for Avocent (aka Cyclades). ciscowlc.pm.in rancid library for some Cisco Wireless Lan Controllers. dell.pm.in rancid library for some Dell D-Link models. dnos9.in rancid library for Dell NOS9 (aka Force10) appliances. eos.pm.in rancid library for Compass EOS. exos.in rancid library for Extreme switches. fortigate.pm.in rancid library for Fortinet Firewalls. foundry.pm.in rancid library for Foundry (Brocade) switches. frr.in rancid library for FRR (and Quagga or Zebra) routers. ios.pm.in rancid library for Cisco IOS and IOS-XE. iossb.pm.in rancid library for Cisco Small Business switches. iosxr.pm.in rancid library for Cisco IOS-XR. junos.pm.in rancid library for Juniper JunOS. routeros.pm.in rancid library for Mikrotik RouterOS routers. mrv.pm.in rancid library for MRV MCS. nxos.pm.in rancid library for Cisco NX-OS. panos.pm.in rancid library for Palo Alto Networks devices. rancid.pm.in rancid global functions. rbt.pm.in rancid library for Riverbed Steelhead. smc.in rancid library for SMC switches. appliances. vrp.pm.in rancid library for Hauwei VRP routers. wavesvros.pm.in rancid library for Ciena Waveserver devices. man/ man pages share/ Readmes, samples, utilities, contribs, etc include/ Include files and rancid's version.h Also see rancid_intro(7), rancid(1), and clogin(1). The following (non-exhaustive list) are included as part of the installation and configuration tools: Makefile.am processed by automake to produce Makefile.in Makefile.in processed by configure to produce Makefile acinclude.m4 sets some GNU autoconf options aclocal.m4 Output of GNU autoconf script configure GNU autoconf script configure.in Input file for autoconf to procide configure depcomp part of GNU autoconf install-sh GNU autoconf shell script to simulate BSD style install missing part of GNU autoconf mkinstalldirs GNU autoconf shell script to make installation directories rancid will also need to have the following packages: gnudiff gnudiff provides the uni-diff (-u) option. If you do not have a diff that supports -u, configure will set-up rancid to use 'diff -c' or 'diff -C'. perl5 perl version 5.10 or greater available from www.cpan.org expect http://expect.nist.gov/ We highly suggest that you stick to expect 5.24.1 (or so). This seems to work best. Note that you need to have the accompanying tcl &/ tk. tcl Required by expect. and, rancid will also need to have one of the following packages; your choice: cvs Code revision system available from prep.ai.mit.edu:/pub/gnu git Code revision system, an alternative to cvs. Use the configure option --with-git to configure for git. svn Code revision system, an alternative to cvs. Available from http://subversion.tigris.org/tarballs/. Use the configure option --with-svn to configure for Subversion. To convert from CVS to SVN, find the cvs2svn python script, then: cd ~rancid cvs2svn --trunk= --trunk-only -s `pwd`/.svn --keywords-off \ `pwd`/CVS sh -c '. /path/to/etc/rancid.conf ; for g in $LIST_OF_GROUPS; \ do svn co file://`pwd`/.svn/$g; done' Bill Fenner (now maintained by others) has a cgi script for interacting with CVS repositories via a web interface. This provides a great way to view rancid diffs and full configs, especially for those unfamiliar with cvs. There are similar tools for Subversion and git. The package is not included, but can be found here: http://www.freebsd.org/projects/cvsweb.html Quick Installation Guide (an example): 1) ./configure [--prefix=] By default, rancid will be installed under /usr/local/rancid (the default "prefix"). This can be overridden with the --prefix option. E.g.: ./configure --prefix=/home/rancid Rancid uses autoconf's "localstatedir" as the location of it's logs, CVS, Subversion or git respository, and directories where it's groups are placed. The user who will run rancid (from cron, etc) will need write access to these directories. By default, this is /var, or /home/rancid/var following the example above. We realize that this is not optimal, but it follows the standards. We suggest that this be altered to include the package name, like so: ./configure --prefix=/home/rancid \ --localstatedir=/home/rancid/var/rancid The user who will run rancid must have write permission in "localstatedir". See ./configure --help for other configure options, including which SCM should use. Now is the time to choose the SCM.. 2) make install If rancid is being installed in system locations, then the install will likely need to be done as root. eg: make; sudo make install 3) Modify /rancid.conf (e.g.: /etc/rancid.conf). The variable LIST_OF_GROUPS is a space delimited list of router "groups". E.g.: LIST_OF_GROUPS="backbone aggregation switches" 4) Put .cloginrc in the home directory of the user who will run rancid. .cloginrc must be not be readable/writable/executable by "others", i.e.: .cloginrc must be mode 0600 or 0640. 5) Modify .cloginrc. Test to make sure that you can log into every router. The login scripts support options m and M to help debug the .cloginrc; see clogin(1). Note: the JunOS that user you use *must* log into a cli shell (which is the default on a juniper), not a unix shell. See the file cloginrc.sample, located in (/share/rancid), for examples and a good starting point. Also take a look at the cloginrc manual page, 'man -M /man cloginrc'. See the cloginrc(5) manpage. 6) Modify /etc/aliases Rancid sends the diffs and other administrative emails to rancid- and problems to rancid-admin-, where is the "GROUP" of routers. This way you can separate your backbone routers from your access routers or separate based upon network etc... Different router uses forced different people being interested in router "groups" - thus this setup. Make sure email to rancid- works. /etc/aliases can be maintainable by Majordomo or another maillist software or may just forward to a remote machine, but make sure the user that runs rancid can post to the list. The Precedence header set to bulk or junk and setting the other RFC3834 auto-responder headers *hopefully* avoids replies from auto-responders and other vacation type mail filters. The --enable-mail-plus option to configure will set each of the "rancid-" addresses mentioned above to "rancid+". See sendmail's operation manual for more information on handling of '+'. The --enable-adminmail-plus configure option will set each of the "rancid-admin-" addresses mentioned above to "rancid-admin+". If this option is not used, the value of --enable-mail-plus is assumed. That is, the addresses will be "rancid+", if it is specified. There are several mail-related options in rancid.conf. See the rancid.conf manpage. Also see the manual for your MTA to determine the format of and procedure for adding aliases. 7) Run rancid-cvs. This creates all of the necessary directories and config files for each of the groups in LIST_OF_GROUPS and imports them into CVS (or Subversion or git). This will also be run each time a new group is added. Do not create the directories or CVS repository manually, allow rancid-cvs to do it. Also see 'man -M /man rancid-cvs'. 8) For each "group", modify the router.db file in the group directory. The file is of the form "router;mfg;state" where "router" is the name (we use FQDN) of the router, mfg is the manufacturer from the set of (cat5|cisco|juniper) (see router.db.5 for a complete list and description), and "state" is either up or down. Each router listed as "up" will have the configuration grabbed. Note: manufacturer cat5 is intended only for cisco catalyst switches running catalyst (not IOS) code. e.g.: //router.db: cisco-router.domain.com;cisco;up adc-mux.domain.com;ezt3;up foundry-switch-router.domain.com;foundry;up juniper-router.domain.com;juniper;up redback-dsl-router.domain.com;redback;down extreme-switch.domain.com;extreme;down 9) For first-time users or new installations, run bin/rancid-run (with no arguments) and check the resulting log file(s) (in logs/*) for errors. Repeat until there are no errors. 10) Put rancid-run in cron to be called however often you want it to run for each group (rancid-run []). If you run it less often than once/hour, check the setting of OLDTIME in etc/rancid.conf. E.g.: # run config differ hourly 1 * * * * /bin/rancid-run # clean out config differ logs 50 23 * * * /usr/bin/find /logs -type f -mtime +2 -exec rm {} \; 11) Note: If you are using any of these programs (other than rancid-run) out of cron or from a shell, make sure that you set your $PATH correctly so that they work. E.g.: if you are using clogin, it can call id, telnet, ssh, and/or rsh. configure already makes sure that $PATH is set correctly in etc/rancid.conf for rancid-run, so you could use the $PATH from there. e.g.: 50 23 * * * . /rancid.conf; clogin -c 'sh vers' router 12) Send any bugs, suggestions or updates to rancid@shrubbery.net. See the web page at http://www.shrubbery.net/rancid. We have created the standard mailing lists for those interested; rancid-announce@shrubbery.net and rancid-discuss@shrubbery.net. Subscribe by sending an email whose body contains "subscribe rancid-" to majordomo@shrubbery.net. If you are reporting problems, please include the version of rancid, expect, and your OS in the email. Problem with clogin/telnet hanging within rancid or scripts? If you have experienced rancid (or more precisely, telnet) hanging on a solaris 2.6 box; check to be sure you have the following two o/s patches installed (see showrev -p). There may be more recent versions of these patches and they are likely included with 2.7 and 2.8: Patch-ID# 105529-08 Keywords: security tcp rlogin TCP ACK FIN packet listen Synopsis: SunOS 5.6: /kernel/drv/tcp patch Patch-ID# 105786-11 Keywords: security ip tcp_priv_stream routing ip_enable_group_ifs ndd Synopsis: SunOS 5.6: /kernel/drv/ip patch Another contributor to rancid "hanging", with or without the o/s patches mentioned above, is a bug in expect/tcl. We've noticed that expect (from 5.24.1 forward), and whatever tcl happens to compile with it, exhibits a problem on Linux and Solaris where rancid's scripts hang waiting for input from the device. Patches to expect are available on the rancid web page. Also, for rancid 2.3 and later, changes were made to the login scripts which use some more elaborate regexes that have failed with expect versions prior to 5.40. While 5.40 works, it still seems to need the patch offered on the rancid web page for Linux and Solaris. See www.shrubbery.net/rancid for additional notes on this. Also the UPGRADING file that comes with the distribution. rancid-3.13/lib/000755 015615 000000 00000000000 13735706334 013537 5ustar00heaswheel000000 000000 rancid-3.13/CHANGES000644 015615 000000 00000252703 13735672043 013774 0ustar00heaswheel000000 000000 3.13 iosxr.pm: handle power shelves in eXR-lite dnos10.pm: add command show inventory media - github.com/spike77453 dnos10.pm: filter fan speed for other fans on same tray - github.com/spike77453 junos.pm: recognize error connecting to dead slave RE rancid.types.base: add type ios-xr7 for Cisco XR >=7.0 on *some* devices, such as NCS - Bill Owens rancid.types.base: add axis type for axis.com switch - Troy Beisigl smc.pm: filter module uptime on PowerConnect 5524 nxos.pm: filter fluctuating WWNs arcos.pm: show features command no longer exposed in ~4.x sros.pm: end of config marker disappeared ~20.5, to be fixed in 20.7r1. Use the MD context marker as an alternative marker jlogin: adjust code to set screen with for -s and -c lg.cgi, lgform.cgi: fix missing variable inializations - Troy Boudreau ios.pm: ASAv fails to read licensing debug info sometimes lgform.cgi: ibcgi-pm-perl removed start/endform version 4.04 - Troy Boudreau mtrancid, routeros.pm: convert mikrotik to module control_rancid: omit .old when looking for rogue files a10login: regex lacking regex option - Tim Warnock control_rancid: add --porcelain to git status for expected output - github.com/jude avocent.pm: fix prompt match, so filters will match the exit command, which only occasionally has a leading space, avocent.pm: # seems to be the ACS comment character, not !. Collect total memory from /proc/meminfo. Comment output from some cat commands. rancid.pm: return an error when a rancid.type.conf line has too few fields avorancid, avocent.pm: convert avocent to module avologin: run_commands(): prompt match s.b. [#$], not [#>] avologin: normalize to clogin avologin: make default timeout longer, these are slow ios.pm: show license could return an author failure - Majed Zouhairy zrancid, frr.pm: convert zebra script to FRR perl library wlogin: send_human the logout command rancid.types.base: note AAA role needed for WLC - Charles Allen rancid.pm: check that opt_t is defined before use xilogin: arcos login banner match can fail if a motd-banner is set mtrancid: filter dynamic configuration, such as fluctuating pppoe user-specific config ios.pm: filter flash dir license_evlog, receives debug logs on XE >=17.2 - Reuben Farrelly arbor.pm: add commands system file show, system show, system disk show jerancid: remove more temperatures - Christian Rohmann via debian package man: Move rancid_intro(1) and lg_intro(1) to man section 7 - - Roland Rosenfeld misc: Add some documentation for a10login, brlogin, fxlogin, rblogin - Roland Rosenfeld 3.12 sros.pm: summarize flash free space junos.pm: ShowSystemLicense(): missing variable initialization exos.pm: ShowVersion(): improve parsing of h/w - James Andrewartha ios.pm: do not use perl /n regex modifier; it didnt appear until 5.22 and is causing heartburn 3.11 ios.pm: some IOS, possibly newer releases, report command authorization failures in a different format - Majed arcos.pm: ShowHardware(): drop indexer counts rancid.pm: loadtype(): check if script is defined before processing -C ios.pm: filter lines from 'term exec prompt time' on IOS - Joe Clarke junos.pm: ShowSystemLicense() must recognize some backend daemon communication errors rancid.types.base, iosxr.pm: collect show memory summary iosxr.pm: ShowVersion(): parse eXR flavor rancid.types.base: more eXR command clean-up iosxr.pm: ShowLicense(): import filters from ios.pm for for eXR >=6.4; guessing here that the filters will be the same since the format is the same, but I have nothing to test against. iosxr.pm: ShowRedundancy(): fix for XR >=5.4.3 & eXR >=6.4 iosxr.pm: ShowHWfpd(): remove trailing WS found in eXR rancid.types.base: add ios-exr for IOS-EXR with alias cisco-exr and add ios, ios-sb, ios-nx, ios-xr for the other cisco ios versions. iosxr.pm: ShowInventory(): change commands for exr to make the output the same. Add ShowDiag() for exr equivalent of admin show diag rancid.types.base: rename juniper -> junos. Add alias for juniper iosxr.pm: ShowInventory(): remove trailing WS found in eXR description iosxr.pm: ShowInstallSummary(): add "Image:" prefix for consistency with ShowInstallActive() rancid-fe: recognize rancid.types.conf aliases junos.pm: show chassis clocks is broken in 19.1R2.1-EVO on some platforms. remove the command for now. edgemax.pm: filter fan speed/duty from o/s 1.9 foundry.pm: wrap secure MAC address if FILTER_OSC > YES junos.pm: ShowChassisClocks() must recognize some backend daemon communication errors junos.pm: EVO RE DRAM fluctuates; replace with "installed" value dnos10: add command show inventory iosxr.pm: match old files where the 4-digit year replaces the timestamp add device type junos-evo for JunOS EVO panos.pm: ShowConfig(): missing last line of config - ermuller ios.pm: ShowFlash(): file permissions field in catch-all branch must also match directories ios.pm: ShowFlash(): filter ASA fluctuating files in LOCAL-CA-SERVER/ - Emille Blanc dnos9.pm|force10: ShowVersion(): drop trailing WS - Howard Jones blogin: normalize part of login() to clogin *login: handle openssh fingerprint prompt for new keys - Emille Blanc junos.pm: ShowChassisFirmware(): drop trail WS ios.pm: remove file numbers from flash rancid.pm: fix handling of script name when handling -C ios.pm: processor type may be multiple words eg: AS920 - Emille Blanc ios.pm: dot1x state match must be case-insensitive - Bart Bylemans iosxr.pm: filter .sspdc file sz/ts iosxr.pm: filter volt_hist file sz/ts sros.pm: improve power data filters 3.10 rancid.types.base: cisco eXR does not have admin show install summary; use admin show install active instead, which appears to be the same at least as far back as 5.3.4. rancid, rancid.pm: handle non-modulized rancid scripts in the rancid script by exec()ing the real script dnos10.om: start Dell NOS10 module - Bjørn Skobba smc.pm: filter Dell N1148T-ON and Powerconnect 7048 temperature info smc.pm: inloop() must set clean_run smc.pm: replaces srancid; modularization. ios.pm: collect show dot1x; if dot1x auth is enabled and rancid.conf:FILTER_OSC = ALL, filter show vlan, which otherwise change frequently exos.pm: rancid.types.base: collect show policy detail dnos9.pm: replaces f10rancid; modularization. force10 is now an alias. rancid.types.base: add alias direction - see manpage rancid.pm: ensure device type is lowercase ios.pm: DirFlash(): fix sort field & DirSlotN(): match ASA's unique date format hlogin: add variation of user prompt from Dell PowerConnect M8024-k as type 'smc'. iosxr.pm: match diskN, where N may be >1 in XR 6.x on 9k with a usbdrive arcos.pm: fail on cli to application error rancid-run: wrong variable used in OLDTIME comparison - Adrian Hardy f10rancid: drop version/last config/startup-config comments from config - Florin Vlad Olariu fss2.pm: drop cpu stats and process stats from FSS >=2.5.1 iosxr.pm: DirSlotN(): drop the file number from all files. Missing Arista documentation - github.com/inphobia GC "procket" from manpages & README arcos.pm: drop trailing spaces jlogin: handle change in Fujitsu FSS2 telnet prompt rivlogin: remove some debug output *login: fix password decision when -e or -p are used, and make error msg common - report from Pan Affa ios.pm: add showPlatform() filter for show hw-programmable all flogin: handle config-mode prompts in run_command() ios.pm: drop count status from show license summary hrancid: filter rogue diagnostic output from 3rd-party transceivers in Aruba - Huber Florian Tobias remove manpages, etc of rancid scripts converted to modules - Roland Rosenfel Deprecate rancid.conf:NOPIPE; default is now enabled prancid: deprecated arcos.pm rancid.types.base: change show hardware handling to eliminate fluctuation in formatting and output junos.pm: filter SRX cluster RE/LC names in prompts - Charles R Anderson junos.pm: filter negative chassis temps - Charles R Anderson wavesvros.pm: filter alternate form of user password - Charles R Anderson panos.pm: filter SNMP community strings & protocol encryption keys & correct comment character - Charles R Anderson rancid: escape "s in rancid.types command definitions - Charles R Anderson ios.pm: filter some log files on ASA 9.8 / FTD2100s - Erik Muller various documentation updates/corrections - Nick Nauwelaerts 3.9 ios.pm: add show module switch for 6500 vss data - Per-Olof Olsson arcos.pm: add tacacs key filter arcos.pm: fix prompt handling - WIP noklogin: exit if pager disable command is not permitted xilogin: handle pager disable for arcos junos.pm: add ShowSystemConfDB() sros.pm: ignore Error: Bad command. error msg form older sros devices ciscowlc.pm: filter mgig temperature - Erik Muller anlogin: make the pty allocation the same as in jlogin dell.pm: powerconnect N[234]000 do not reliably echo the after exit - Wayne Eisenberg clogin: new variation of username prompt - Wayne Eisenberg wlogin: fix prompt match in run_commands() which was failing for longer hostnames/prompts - Erik Muller bigip: add "cd /" command for v13 to collect all routes - Wouter de Jong nxos.pm: recognize older SAN nexus devices - Wouter de Jong a10login: handle logout prompt variation for older ACOS - Wouter de Jong junos.pm: handle show chassis firmware bug for 11.x on EX - Wouter de Jong panos.pm: ignore show chassis inventory on invalid syntax sros.pm: remove duplication of chassis type - Greg Hankins sros.pm: restore chassis type line - Greg Hankins panos.pm: add show chassis inventory - Erik Muller nxos.pm: filter bcm_mem_lock_trace.log since ~7.0.3 - Erik Muller hlogin: send \r rather than for "Press any key to continue" to work-around apparant bug - Benoit Dolez panlogin: move scripting mode and pager disabling from command list to panlogin to work-around complete-on-space {mis-}feature added around 8.1.4 - Erik Muller sros.pm: restore chassis type from bootlog.txt clogin: fix problem with catos prompt sros.pm: take chassis s/n from bootlog.txt *login: adjust the command separated used within; tcl <8.6 does not recognize u002 and u0002 as the same value, which caused a regex compilation failure clogin: ArubaOS >~8.3 has a '*' which must be escaped in prompt matching -PJ Goodwin *login: backout send-human change in previous commit, where it wasnt before. W/O an appropriate adjustment of the send-human variables, it was killing performance. *login: address bug in escaping empty commands of -[cx] sros.pm: use file type debug command only for total memory and card type panlogin: copy/customize last/failed login match from clogin fnlogin: accept new banner prompt at login - Ni Ne ciscowlc.pm: the device may not echo the \r\n at logout fss2: filter sys-uptime anlogin, jlogin, noklogin: use spawnopts spawning ssh/telnet nxos.pm: GC unused variables fortigate: rename fortigate device type to fortigate-full and re-create the fortigate type with 'show' (not 'full-configuration') anlogin: use login_top sros.pm: take chassis type and s/n from show chassis instead of boot.log noklogin: remove ^H handling; its consuming too much arbor.pm: increase anlogin timeout for slow cli commands noklogin: allocate a pty if not on a tty & set term width iosxr: DirSlotN(): drop fileno from oscillating files to ignore the rotation by renaming behavior seen with ce_switch.log and sort all files by filename iosxr: also ignore ce_switch.log* *login: add -i option arcos.pm: initial arcos support - WIP anlogin: copy last/failed login match from clogin nxos.pm: also ignore accounting_log.0 - Pavel Korovin srancid: prevent ShowSys() power supply handling from consuming too much fortigate: filter INDUSTRIAL-DB version - Chris Wopat nxos.pm: filter out oscillating data from transceivers - Pavel Korovin fortigate: wrap other DB signatures within FILTER_OSC hlogin: allow prompts with ()s, still not a good idea imo fxlogin: missing escape in regex - Erik Muller wavesvros.pm: add cmds license file list, blade show, & alarm show fortigate.pm: GC unnecessary output spacers & fix comment character - Nick Nauwelaerts fnlogin: fix logout sequence in run_commands() & used -h option of send fnrancid, fortigate.pm: convert fortigate to module waverserver.pm: filter power support wattage, new in waveserveros 1.6 nxos.pm: in ShowEnvTemp() sub-input loop, catch prompt - Scott McInness jlogin: skip login tips that look like prompts, like: JUNOS tip: Use the configuration statement [system login class login-tip] rancid.conf.sample: note ALL option FILTER_OSC fnrancid: filter db version stamps wrapped in FILTER_OSC - Chris Wopat ulogin: parse (ignore) last (failed) login message at login time 3.8 nxos.pm: ShowEnv() missing prompt handling & CR filter - Frank Mogaddedi ios.pm, iosxr.pm: re-organize the DirSlotN() filtering a bit toward reducing fluctuations sros.pm: misc cleanup - Greg Hankins sros.pm: make last config saved/modified info filtering dependent on FILTER_OSC=ALL ios.pm: ShowFlast(): sort by file name noklogin: disable pager in classic cli, from MD cli sros.pm: add non-native commands for MD cli sros.pm: separate WriteTermMD() for MD cli rancid.types.base: add sros-md type (wip) noklogin: disable pager in MD cli sros.pm: ignore "Error: Invalid parameter" error from MD cli ios.pm: DirSlotN(): sort by filename ios.pm: DirSlotN(): roll XE-specific filter into the generic and drop the file number from all files. ios.pm: DirSlotN(): drop XR-specific filter ciscowlc: skip new oscillating o/p for WLC 8.8 - Reuden Farrelly ciscowlc: fix logout match, like ASA, it missed the CR sometimes fxlogin, fxos: initial FX-OS support - thanks Erik Muller sros: filter change since last save line clogin: add clause to recognize F5 >=11 "exit" command error msg rancid.type.base: add bigip13 for >=13.x - Howard Jones control_rancid: @sysconfdir@ not fully expanded rancid.type.base: remove dir command from edgemax, no useful data and produces endless diffs - Reuben Farrelly & Clemens Shrimpe nxos.pm: use diskszsummary() for disk space rancid.pm: add bytes2human(), diskszsummary(), human2bytes() junos.pm: adjust match for backup RE communication failure. ios.pm: filter date/size of underlying-config file fnlogin: handle empty command index in run_commands() fnlogin: fix escaping of '$' in full prompt matching iosxr.pm: filter date/size of cisco_support file ios.pm: match WIC/VIC/HWIC slots - Rybakov Evgeny vrp.pm: drop file number in filesystem filters vrp.pm: add filesystem filters vrp.pm: add Hauwei VRP support - very much alpha quality ATM xilogin: few change to support Hauwei VRP clogin: new info in ASA login sequence matched as login prompt nxos.pm: add show interface transceiver mrv.pm: add show inventory ios.pm: filter new "% free" string from dir slot in new ASA code hrancid: filter timestamp bug in show tech transceivers nxos.pm: filter show redundancy/show env fex when unsupported iosxr.pm: filter .python-history flash file & non-existent paths/devs ulogin: trim match of "last login:" for timing reasons nx.pm: filter debug_logs/ in flash output - Charles T. Brooks rancid.conf: add check for docker environment where the root user check is skipped. this allows rancid.conf to be sourced inside a dcoker build environment. clogin: add tty settings when a real tty doesnt exist; hoping this will help with the long command problem on ASA devices that I have not been able to replicate on ASAs I can access rancid.conf.sample: move UID check after setting PATH aeos.pm: handle new power supply output format fss2.pm, et al: add Fujitsu FSS2/1finity support ulogin: fix regex typo for skipping last login msg in login sequence srancid: filter power rates and tmestamps from 7024 power supply info ciscowlc.pm: handle variant of logout bug fnrancid: update md5-keys filter for Fortigate 5.4.6 sros.pm: move show chassis power-supply o/p - Greg Hankins ciscowlc.pm: filter rogue client Unknowns - Bill Fenner junos.pm: filter scale-subscriber license counters ulogin: increase default timeout to 30s for slower Edgeroute Lite - Andreas Herrmann 3.7 sros.pm: fix prompt match to correctly handle the prompt with a modified config & remove the atom from the output arbor.pm: fail on intermittent h/w retrieval failure iosxr.pm: recognize another possible intermittent failure in show install active fnrancid: filter cluster uptime waveserver.pm: adjust prompt for the case where a ^ appears in the prompt after displaying the config. waveserver.pm: prompt could be # or >, depending on access level - Chris Wopat tested fnlogin.in: Fortiweb 5.8 changed password prompt acos.pm: show aflex is not be supported in the CGN/LSN image wlogin: support -S wlogin: use login_top & GC the code to enable - tested by Reuben Farrelly ciscowlc.pm: filter bogus & oscillating mgmt address disaplay - Reuben Farrelly wlogin: GC some stuff from clogin, disable pager & fix the prompt regex anlogin: disable pager on arbor wlogin: fix use of exitval rancid.pm, rancid.types.base: add timeout directive to set a default login timeout. Move timeouts from the modules to rancid.types. rancid.types.base: argument missing for cisco-wlc8 - Reuben Farrelly iosxr.pm: fail if install director is not up or ready ios.pm: report physical memory for XE devices ios.pm: filter config archive file names running-config-archive-*; no reasonable file name suggestion found in docs. aeos.pm: filter unsaved config changes notification ios.pm: ignore size of throughput_monitor_params on XE - Emille Blanc rancid.types.base, ios.pm: add 'show inventory' w/o raw argument for ASA/PIX arbor.pm: filter cmosh timer error that is intermitent and does appear to affect collection hpuifilter: fix an error in patch import in r3233: hpuifilter: fix escape sequence parsing so that it does not consume sequences after another that are incomplete - Brian Candler rancid.types.base: add cisco-wlc8 with longer default timeout ciscowlc.pm: remove noisy debugging o/p srancid: add username/enable password filtering nxos.pm: adjust regex for nexus with decimal wattages - Howard Jones fnlogin: fix full prompt gleaning code - much appreciated help from Merijn Evertse fnrancid: filter oscillating ospf md5 keys - Merijn Evertse sros.pm: final formatting tweaks - Greg Hankins sros.pm: power info changes for 7750/7950 - Greg Hankins control_rancid: check for duplicated device names in the router.db of the active group. print a warning and drop the dumplicate. http://www.shrubbery.net/pipermail/rancid-discuss/2017-June/009661.html hlogin: recognize username prompt User Name: mtrancid: remove license renewal timestamp junos.pm: filter cycling & useless last commit config line hlogin: prompt matching not needed for interactive - Per-Olof Olsson nxos.pm: drop bootvar_debug.* log files reported on the ML hpuifilter: add 3 CR replacements, fixing hp5412 J8697A or hp5406 and HP/Aruab-2920 switches running WB_16_03_0004 - Kalani Sanders arbor.pm: force a terminal type so as not to confuse the PoS with "network." Seems that it might also support "dumb". clogin: respond to prompt from config:file prompt noisy ios.pm: Filter perpetually changing file "snooping" - Mark Felder nxof.pm: Filter vtp_debug.log and vtp_debug_old.log CDETS bug CSCuy87611 - Mark Felder aeos.pm: skip some junk in the config output ios.pm: fail if show license can not retrieve license info ios.pm: filter ASR901 fan speed - Nick Peelman ios.pm: ShowDiag misinterprets WIC/VIC/HWIC slots - Rybakov Evgeny *login: add cloginrc telnetcmd directive and with the defualt telnet -K (no automatic login) if -K is supported, which otherwise can break logins if the unix username and device username are not the same. dllogin, hlogin, mrvlogin, nslogin, panlogin: include common functions and cmd-line opts from login_top rivlogin: normalize this a bit; its still a mess junos.pm: ShowVersion: fail on no route to secondary RE ios.pm: ShowDiag misinterprets PVDM slots - Rybakov Evgeny junos.pm: add VMX-SCALE & VMX-BANDWIDTH to license filter - Brad Dreisbach rancid.spec: fix omissions & typo - Brad Dreisbach configure: fix --with-git fnlogin: do not send \r to the prompt in run_commands() - Daniel Fussell fnlogin: fix missing/extra brace - Daniel Fussell edgerouter.pm: add match for transient show version command failure ios.pm: summarize bytes free on flash noklogin: SR OS has no concept of enable mode; remove such code so that autoenable/etc are not needed sros.pm: add show card detail - Erik Muller ios.pm: filter flash:smart-log/agentlog, debug file turd that changes size in perpetuity sros.pm: filter passwords & trap communities - Erik Muller ios.pm: ASAv 9.6(2) has a bug with a cycling debug file: smart-log/agentlog *rancid: print which of found_end or clean_run are false with -d option plogin: fix cmd-line option spec - Erik Muller f10rancid: remove s4048 PS fan speed f10rancid: WS after filenames in some versions cause the dir and parent dir filters to fail. fnrancid: filter last-login - Merijn Evertse sros.pm: drop unnecessary command: file type config.dbg - Greg Hankins alogin: respond to modified config saving & peer syncing appropriately - thanks Bob Franzke alogin: missing global variable sros.pm: config.dbg doesnt exist w/o a saved debug config, ignore errors ios.pm: remove fan speed from fan status on ASR901 - Emille Blanc cloginrc.5: make note of special-character escaping precise - Lee timeos -> sros & allogin -> noklogin, at the request of nokia nxos.pm: pull snmp trap host filtering from ios.pm - Brandon Ewing rancid-run, control_rancid: add -c option to specify a SCM commit message - Mischa Diehm rancid.pm, junos.pm: add ALL option to FILTER_OSC and apply this to junos license info summarization and summarize more of the feature license info - Erik Muller et al junos.pm: also summarize dynamic-vpn licenses & use a blank percentage for features with < 100 licenses - Erik Muller iossb.pm: Cisco small business rancid module hlogin: do not use hpuifilter for interactive telnet with non-std port csblogin: start Cisco small business device support complogin, eos.pm: Compass EOS support removed. RiP allogin, timos.pm: TiMOS support 3.6.2 Fix etc/Makefile for rancid.types.conf handling. 3.6.1 ios.pm: filter license registration timestamp fnrancid: filter oscillating md5-keys par.c: fix misplaced pointer deref 3.6 rancid.pm: ipaddrval() if IPv6 prefix length is missing, simply set 128. *login: in_proc must be global in expect_after. had trouble reproducing the original error, but this should be the correct fix. xlogin: escape the * in lastprompt - Mattieu Beretti *login: change handling of ssh key-related prompts to one line at a time to eliminate timing-related problem. alogin: login() eat one line at a time a10login: remove the aflex-specific stuff. This is the wrong way to do this and it doesn't work properly anyway. control_rancid: create /configs if it does not exist hrancid: use rancid.pm (removes code duplication) rancid.pm: check for existence of functions for given device type after loading the modules for the type. return failure if any are missing. par: add -FH options rancid.types.conf, iosshtech.pm: Add device type ciscoshtech for example purposes acos.pm: filter trailing WS & recognize incomplete/invalid command error in basicFilter() acos.pm: filter trailing WS in ShowAflex() acos.pm: 'show vlan' is 'show vlans' in ACOS 4.x. acos.pm: Add cmd 'show partition-config all' for ACOS 4.x, where 'show running-config all-partitions' does not work. acos.pm: recognize invalid cmd error in ShowRunningConfig() and filter the config size comment fnlogin: missing "end" to exit global mode for -[csx] - Richard Goode plogin: add -m & -M rancid.pm: missing variable initialization nxos.pm: fix bug in recognizing the end of an access-list hlogin: set tty init options when there is no controlling tty and set set the term width to 132 when there is no controlling tty and for -[sc] so that the hp device does not wrap lines. ios.pm: also filter IPv6 PDP addresses - Reuben Farrelly ios.pm: evaluation license periods are displayed differently lg: Add show interface optics iosxr.pm: More useless FPD messages junos.pm: handle a transient cmd protocol failure seen in show version control_rancid: use git ls-files instead of git status for .gitignore and /rancid.conf fnrancid: fix formatting around removal of private-keys bigip.pm: filter snmpv3 oscillating auth-password-encrypted iosxr.pm: filter useless FPD upgrade message 3.5.1 hlogin: missed an ssh -c option among the clean-up - Mark Felder 3.5 aeos.pm: handle returning from a function with a prompt in $_ rancid-cvs, rancid-run, rancid.conf: use LOGDIR from rancid.conf, set a default, and makes manpage notes - David Jones complogin: correct ssh/telnet port variable check control_rancid: if the router list is empty, commit everything, not just router.db. .cvsignore, rancid.conf, etc. *login: do not default to ssh -c 3des; as openssh removes more legacy algorithms. note work-arounds in the FAQ S3 & adjust manpages. ciscowlc.pm: filter OUI classification failures - Reuben Farrelly ciscowlc.pm: filter rogue client config that are added/removed automatically - Reuben Farrelly fnlogin: fix pager disabling for newer o/s - Romanens Xavier, Michael Newton confirms working for older 4.x o/s edgerouter.pm: filter passwords, snmp community, keys, GC some unused code, & fix comment character. ciscowlc.pm: some older code fails to echo after logout - Bill Fenner edgerouter.pm: initial module for Ubiquity Edgerouter, WiP hlogin: when refactoring prompt, eat full lines before looking for the prompt hpuifilter: only turn off echo on the tty, not also the slave pty, which fixes the echoing problem with Ubiquity Edgerouters a10login: fix cut-n-paste bug - Romanens Xavier flogin: eat spaces followed by ^H - from Allen login_top: move variable initialization so it doesnt override env()s - Bill Fenner foundry.pm: ignore invalid command errors in inloop found on Ironware 5.5 for MLX - Erik Muller srancid: filter oscillating file aaafile.prv - Wellie W. Chao nxos.pm: reverse VTP test for nexus without vtp ios.pm: filter ios-xe requested time from show inventory feature iosxr.pm: differences in NCS6k show inventory nxos.pm: show env temp does not exist on 1000v lg.cgi: add show interfaces wanphy for cisco-xr & juniper cisco: Change command show flash to show flash:. The first has been dropped from the 15.5M and the latter seems to be supported back as I can check. - Onno Ossendrijver mrvlogin, mrv.pm: fixes for MRV Optiswitch devices - Christian Rohmann iosxr.pm: fix handling of comments in access-lists nxos.pm: sort ip{v6} access-lists & filter sequence numbers foundry.pm: summarize flash free space xrancid, exos.pm, xlogin: convert extreme to a module and hack clogin into xlogin to deal some weird terminal handling in EXOS >11.0 that uses terminal manipulation to reprint the login prompt (telnet) or the first cli prompt (ssh). - thanks to Nick Hilliard nxos.pm: fix PS wattage filtering - Kyle Wilson junos.pm: filter benign subsystem warnings ios.pm: filter license broker BS FAQ: add notes about openssh client changes for logjam hpuifilter: fix handling of buffer when it drains rancid.conf: change NOCOMMSTR to require "YES", not just defined arrancid, aeos.pm: convert Arista to a module ios.pm: add show license summary for older XE images, such as C4500e 3.04/15.1 bigip.pm: module for F5 BIG-IP >=v11 rancid.conf: add variable FILTER_OSC to control filtering oscillating data. See rancid.conf(5). This may not yet be applied in all places. rancid: change logging of missed commands to preserve order to make it easier for us to parse when providing support. also, only log to stderr and not just with -d. fnrancid: filter new private key format and fix filtering of encryptd passwords ios.pm: filter/sort new ipv4/6 access-list format where list names are omitted from rule lines. ios.pm: correct debug log msg - Reuben Farrelly iosxr.pm: ShowInstallSummary() return error if active install operation iosxr.pm: filter perpetually changing file aaa srancid: Add 'terminal dump' cmd for Dell PowerConnect 3524/3548 - Wellie W. Chao iosxr.pm: fail on temp error in admin show install configure: fix mktemp variable inconsistency - Lee edgemax.pm: https://www.ubnt.com/edgemax/ flogin: merge ssh key code from jlogin junos.pm: chassis command error changed/differs in vMX: error: the chassis subsystem is not running to error: the chassis-control subsystem is not responding to ... jlogin: missing catch for wait in login() rancid-cvs: initialize .git/description iosxr.pm: ASR show version chassis line changed - tip top work cisco ios.pm: strip license period from 2900 ios.pm: show license is an incomplete cmd on older XE images ios.pm: trim trailing WS is show activation key, formatting problem on old ASAs plogin: wrong variable used in error msg - randy bush control_rancid: test -e -> -f for old shells hpuifilter: missing include for solaris ios.pm: recognize aironet in ShowVersion & filter counters in ShowVlan - Howard Jones rancid-cvs: do not set git config --global, local only flogin: build with login_top foundry.pm: add 'show media' and 'show media validation', tested on Brocade ICX 6650 and Brocade CER 2024, but not available on pre-8 firmware - Chris Wopat 3.4.1 iosxr.pm: add errmsg_cont to filtered flash files - xr 5.3.1 debugging turd? configure: fix error in filtering '.' from ENV_PATH and filter [\r\n]. 3.4 configure: fix login_top inclusion - Robert Minsk mrv.pm: filter temps from Optiswitch 960G - Christian Rohmann a10 load balancer support - Robert Minsk 3.3 par: fix quote handling in spliting input file lines. Also clean-up some error messages. wavesvros.pm: fix handling of prompt that changes with unsaved config iosxr.pm: filter the vm crap from admin commands on NCS iosxr.pm: add another unknown command filter for NCS - why have one error message that means "unknown command" when you can have two or more iosxr.pm: collect license udi & clean-up license info nxos.pm: filter new format of PS info - Minh Scholes ios.pm: collect show activation-key on ASA - suggested by Bob Brunette control_rancid: track number of invocations per-group in untracked file runcount; after 100, perform extra-cleanup. Currently only applies to git repos. hpuifilter: fix escape sequence parsing so that it does not consume sequences after another that are incomplete - Brian Candler ios.pm: collect ios & iosxe license info suggested by Roman Hochuli wavesvros: initial Ciena Waveserver o/s support hlogin: save config prompt changed - Per-Olaf Olsson control_rancid: always recreate the .{cvs,git}ignore file(s) and append .{cvs,git}ignore.locale if it exists rancid.conf: add option ACLFILTERSEQ for Hakala Reijo rancid-run: use mktemp for mail temporary file in the error path rancid-run: exit status 1 if group is locked control_rancid: scm-ignore routers.single, -r option temp file rancid-run: improve locking by using an exclusive open anlogin: openssh reduced what ssh ciphers are available (https://bbs.archlinux.org/viewtopic.php?id=188613); allow ssh to use its default list if not specified in cloginrc. ios.pm: filter fan rpm on 7201 - Mike Stupalov *login.in: ignore openssh authentication agent forwarding failure nxos.pm: filter unsupported commands on 1000v - Reuben Farrelly panos.pm: update show system info dynamic info filter - Robert Minsk arrancid: filter uptime from older AOS' show version - Robert Minsk nxos.pm: filter ee.log and accounting.log - Reuben Farrelly panos.pm: filter dynamic info from show system info - Reuben Farrelly juniper: add command show version invoke-on other-routing-engine srancid: temp sensor parsing for M6348 and M8024 - Frank Fegert srancid: Insert the command string at the top of some of the output to give some context, along with a preceeding blank line - Frank Fegert srancid: remove uptime on dell powerconnects - Frank Fegert iosxr.pm: misc hacks for NCS rtftpboot: example script to save copies of configs from /tftpboot rblogin, rbt.pm: initial riverbed steelhead support ciscowlc.pm: filter fan status & make temperature match case insensitive ios.pm: filter oscillating DTE lines from show diag alogin: select ibmnos-cli on IBM Flex System Fabric nlogin: handle netscreen agreement - Yannick Charton mtlogin: avoid line truncation with TERM for wide screen - Ehud Gavron f5rancid: change TERM to vt100-w for 132 width - John Kougoulos arbor.pm: sort IP addresses in policy and display one-per-line as comments so that they are readable and it is easier to see what changed in the policy. There does not appear to be a way to split these lines and have the saved config still be loadable into the device. anlogin: arbor produces some *really* long prefix match lines on account of its lousy config syntax. this exceeds the default expect max buffer size, which i have never seen before. Utilize the full_buffer magic patlist to dump the buffer when it is full but hasnt matched an EOL. arbor.pm: sort ip access lists zrancid: change TERM to ansi - Tore Anderson configure: remove . from PATH - Tetsuo Handa rancid-run, control_rancid, rancid.conf.sample: fix sendmail variable usage Rancid 3.0 change - Tetsuo Handa jlogin mtlogin: fix match for method "ssh:port" *login: fix usage line display of -m | -M rancid: fix error checking of module::init() & calling command handlers that are undefined. ios.pm: filter ike2 keys on ASA - Mike Eklund rancid.conf: move the UID check after setting PATH control_rancid: add check for router.db FS mrvlogin: fix prompt re-factoring in run_commands() rancid.types.base: remove cisco-xr dir slave and sec cmds, they do not appear to apply to any XR platforms - Buchan Milne ios.pm: ignore PDP addr and resolvers in cellular o/p - Reuben Farrelly clogin jlogin mtlogin: Add -m & -M options control_rancid: specify path of /rancid.conf iosxr.pm: fix ShowEnv() collection of power info iosxr.pm: dir may return no route error for unknown devicename ios.pm: ShowDiag(): recognize 3800 AIM modules - Terry Kennedy ios.pm: ShowDiag(): if slot # is empty, use Chassis - Terry Kennedy ios.pm: remove "Fan n RPM is #" on 7201's - Terry Kennedy iosxr.pm: collect admin show hw-module fpd location all junos.pm: fix showsystemlicense for errant licenses w/ 0 available rancid.pm: check result from inet_pton() ciscowlc.pm: comment a few config lines that can not be imported 3.2 control_rancid: fix handling of /rancid.conf in git - Mike Eklund control_rancid: fix handling of configs/.cvsignore panos.pm: fix package definition - martyMusto rancid.type.base: comment adtran definition to avoid confusion configure, rancid.pm: check minimum revision of Socket.pm mtlogin: support cloginrc passphrase and identity ios.pm: add ios::ShowCellular() and cmd show cellular 0 profile control_rancid: fix mail rcpt bug in error path rancid-cvs: change git push.default to current - Per Carlson add .old to configs/{.cvsignore,.gitignore}; see control_rancid(1) rancid.pm: rework IP address sorting based on patch from Nick Hilliard ciscowlc.pm: filter some config junk that wont import nxos.pm: not all nexus have show process log vdc-all f5rancid: filter fluctuating monitor state in config FAQ: updates - Thomas Greer ios.pm: drop the fabricated portion of the "Chassis type:" line; its too much to try to track it accurately and doesnt seem to provide any value foundry.pm: filter altitude and pressure in ShowChassis ios.pm: cellular modem speeds not filtered on C819G ios.pm: 3560X w/ XE has different show sdm prefer and show system mtu formats - Reuben Farrelly update lg for router.db delimeter change - Buchan Milne rename slogin to plogin (poly-login), as slogin collides with ssh pkg - Reuben Farrelly jlogin, mtlogin: set tty init options when there is no controlling tty, and update jlogin to match this method to an error from stty on the O/S used by the user, Linux, I believe. http://www.shrubbery.net/pipermail/rancid-discuss/2015-January/007981.html flogin: send term length 0 for MLX & other cases. flogin: remove sleeps, send -h should work, and lower send_human timers *login: set base send_human values and lower (faster) values where it was already set (clogin, complogin, etc), except flogin. rancid.conf: add DIFFSCRIPT knob dllogin, wlogin: handle -t option control_rancid: read rancid.conf sooner & fix handling group/ranicd.conf rancid-run: pass -f to control_rancid Fix the commit command used for -r - Jethro R Binks Updates to default mail headers for RFC3834 & MS - Jethro R Binks rancid.types: fix show config commands for cisco-wlc* ios.pm: filter line password on c2800s & c2900s - Ira Byerly add support for git. See the UPGRADING file. Based on Jeffrey C. Ollie's patch & thanks Dan Lowe, Job Snijders and a number of folks on rancid-discuss. rancid-cvs: add -f option dell.pm: filter up time from show switch control_rancid: svn cleanup after collection commits iosxr.pm: access-list/prefix-list sorting regex fixes ios.pm: access-list/prefix-list sorting regex fixes nxos.pm: filter ASIC/INTAKE cycling temps - Vincent Aniello panos.pm: convert panrancid to a module panlogin, panrancid: import palo alto network script from Doug Hughes jlogin: set tty width to 132 to avoid problems with cli complete-on-space, which fixes problems occuring when hostnames are longer iosxr.pm: access-list regex truncating lines - Peter Jackson rancid.pm: improve IP sorting, esp for IPv6 ios.pm: filter show flash & dir bytes free better ciscowlc: add filters for oscillating config & env o/p - Daniel Schmidt ciscowlc: convert Cisco WLC scripts to library import Cisco WLC scripts from http://www.shrubbery.net/pipermail/rancid-discuss/2010-February/004652.html *login.in; fix handling of empty lines in -x input - reported by lee.e.rian nxos.pm: recognize invalid command in ShowFex - lee.e.rian nxos.pm: does not set $proc - lee.e.rian nxrancid: convert nexus to module nxos.pm ios.pm: save "next reload" template - lee.e.rian tntlogin, tntrancid: remove TNT support par, hpuifilter: type fixes for Raspian compatibility - thanks Dan Anderson slogin: add switching login ios.pm: filter timestamp and size from filename "syslog" configure: complain if sendmail is not found control_rancid: DIR set too early clogin,ios.pm,iosxr.pm: escape plus (+) regex atom in prompt handling foundry.pm: remove rogue newline in regex - from P. R. Wilson Note Allied Telesis AW+ devices support, works as type 'cisco' according to Allied Telesis Employees fix handling of absent sendmail in configure script 3.1 Change rancid script exec(); move cmd-line options to rancid.types.* files. This allows older scripts to function without change, ie: needing to support -t. clogin: missing variable initialization - Per-Olaf Olsson ios.pm: filter fan speed setting on 2900, etc. fnrancid: fix filter match for encrypted pwd ios.pm: filter vlan traffic counters on gsr, 6400 & switches srancid: fix up time filter for dell 3448 ios.pm: some ASAs do not support show vlan ios.pm: bgp password filtering removing neighbor address rancid.types.base: dell definition missing inloop configuration rancid: display useful error if inloop is not configured dell.pm: missing variable declarations nxrancid: filter INTAKE temps and cycling file BufferMonitor-1HourData - reported by Vincent Aniello 3.0 add SENDMAIL variable to rancid.conf - requsted by Mariusz Kruk nsrancid,nslogin: Fix prompt and end-of-config-markers - from Jesse House confirmed by Tom Luong ios.pm: show flash on 867VAE w/ 15.3(3)M2 produces the same output as dir slotN: on "normal" ios, so filtering fials - reported by Reuben Farrelly ios.pm: change $type comparisons to eq - reported by Reuben Farrelly junos.pm: filter MX2020 fan speed ios.pm: update XE match for XE 3.11.00.S - Jan Rheindorf grancid: rename to rancid, now that the IOS script is converted and to reduce confusion. rancid.pm: fix syntax error hrancid: filter uptime from show stack - Alan McKinnon junos.pm: filter primary/secondary on SRX - Frank Eargle par: replace par with C version rancid.types.conf: allow multiple module lines for device type mrvrancid, francid: converted to perl modules hrancid: filter uptime from show version - reported by Rikard Ekman cloginrc: add prompt directive to workaround prompt special characters in login banners. Not supported by all scripts; just clogin, ATM. ios.pm: filter sflog file for cisco 10k alogin: match display private keys prompt - noted by majoosh chacko rancid.types.conf: add jlocal example base on Serge Malev's comment clogin: Extreme XOS >= 12.5 has a new prompt-like banner before the initial prompt, ignore it to avoid confusing location of the prompt rancid.types.base: add command show chassis hardware models nxrancid: filter Fan Zone Speed ios.pm: reverse logic of whether to 'show vlan', skip VTP clients f10rancid: skip . & .. *login: change -c handling of ;'s for escaping like \; rancid.conf: add MAILSPLIT to split large diff mail by kilobytes control_rancid: add group-specific rancid.conf file & supporting -f option nxrancid: filter snmp communities, tacacs keys and neighbor pwds - Alan McKinnon ios.pm: remove lpd neighbor passwords - Alan McKinnon ios.pm: remove interface dynamic addresses - Alan McKinnon nxrancid: add show (fex|module fex) - Alan McKinnon nsrancid: filter last modified lines - Roman Hochuli rancid.conf: add check for EUID - Matthew Walster & Ed Ravin control_rancid: allow MAX_ROUNDS to be zero - Alan McKinnon ios.pm: include 6500 sup-2t CPU info - Per-Olof Olsson fnrancid: filter oscillating certs - based on patch from Gavin McCullagh flogin: handle -S/do_saveconfig xrrancid: filter perpetually changing harddisk:ce_switch.log, a DDTS is open for this ios.pm: filter private-multiple-fs flash file found on APs - robert drake ios.pm: Removing "AC Revision" from UBRs and some others - robert drake ios.pm: GC unused old 7000 series code from ShowEnv - robert drake arrancid: Parse power supplies with no power, Skip free flash space altogether, Optionally include the ribd running-config, Skip the "Time:" comment in "show running", Delete a bunch of cruft left over from IOS rancid copy, Include diffs of unsaved changes, if there is a difference between startup-config and running-config., Handle the common practice of putting the time in the prompt. - Bill Fenner hrancid: ignore disclaimer from show tech transceivers starting with procurve 2610 R11.98 - Mika Tiainen ios: skip the "^" line that preceeds invalid input consistently merge compass branch comprancid: fail on command premature exit/failure in show config comprancid: fail on read failure in show inventory comprancid: add recognitin of EOS 1.1 end of config marker nlogin: add code to filter more prompts in run_commands. no complaints from users; hope this is right as I have no way to test it. hpuifilter: New HP2920-switches use [6n (ansi u7) - Per-Olof Olsson ios.pm: some c3750 stack-specific clean-up - Terry Kennedy ios.pm: add show switch detail, show sdm prefer, show system mtu - Terry Kennedy anrancid: fail collection on TCL traceback grancid: add -h cloginrc(5): remove - from method port example and note that ssh can also take a port argument. hlogin: do not use hpuifilter for interactive - Per Olof Olsson nxrancid: fail collection if show debug times out - Daniel Schmidt rancid, ios.pm: correct strings comparison operator - Vitaly Nikolaev hlogin: match Login Name for radius client w/ old code - David Byers f5rancid: filter auth-password-encrypted lines, which oscillate clogin: match "username" prompt, lowercase u fix install of rancid.types.conf ios.pm: fix INPUT reference implement grancid and rancid.types.{conf,base} collection configuration stuff. rancid, ios.pm: kill rx/txspeed on cellular modem cards cloginrc: add enablecmd directive, for clogin - Jason Greenberg lg.cgi: add cisco ios xr specific commands francid: filter new uptime on netiron switch fabrics - Roman Hochuli hlogin: add Login (capital L) as default login prompt - Johan Ryberg rancid,ios.pm: update ASA/PIX pre-shared-key format - Michael Hertrick *rancid: pass (INPUT,OUTPUT,$cmd) to filter functions rancid::base renamed rancid Add lib/ and bin/grancid to the build process *rancid: add -t option for rancid-fe to pass the device type from router.db. Mainly for grancid, but pass it to all scripts. router.db,rancid.types.*: change field separator to ';' (semi-colon) to allow for IPv6 addresses in router.db and avoid conflict with :s in device commands and perl module names *rancid: few variable name changes to match rancid::base arrancid: summarize flash remaining space jrancid: show version can terminate abnormally when unable to communicate with a daemon nxrancid: improve power supply wattage filtering further nxrancid: improve power supply wattage filtering - Zenon Mousmoulas jlogin: set cli screen-width to prevent cli from mucking with the command line in irritating ways - Jay Borkenhagen xrrancid: adjust for ARS9k RSP440 show version format anrancid: add arbor networks module *rancid: add the -C option rivlogin,jlogin,fnlogin: command-line option clean-up mtlogin: fix cloginrc timeout handling & clean-up command-line options xrancid: capture more info from show switch. xrrancid: filter changing files (*_cont) from nvram:. rancid: ignore "Load for five secs:" and "Time source is NTP" lines. rancid: remove LISP-MapCache files; fix date removal for dhcp & vlan.dat files in flash. nxrancid: delete the line with the "^" from the "Invalid command at" errors. hlogin: add "username" to prompt match for Cisco ACS 5.3 - Skye Hagen rancid: Filter issu_loc_lock and volt_cont files nxrancid: try to get show env power output to line up better. hrancid: ignore unrecognized command for "show system( |-)information" xirancid: xirrus support - Aaron Smith jrancid: filter $9$ at the FILTER_PWDS=YES level rancid: include fans in ShowEnv - Affa Pan fnlogin: correct check for ssh port setting - Robert Blayzor rancid: adjust snmp community filter for ASA version >=8.x - Skye Hagen Add MAILOPTS variable to rancid.conf - Matej Vela share/Makefile: missing MAIL* variables in sed script - Aaron Smith jrancid: distill used subscriber licenses to a percentage, else its forever changing. nxrancid: nx5000 generates spurious 'Permission denied' error for 'show debug' if command authorization is used - Per-Olof Olsson nxrancid: remove cisco ios residuals - Per-Olof Olsson hlogin: add "--" in comment to prevent older expect/tcl from interpretting "-," as an option. !@#&!#$ rancid, xrrancid: add KB to disk/flash bytes free filtering xrrancd: also filter temp_static_data rancid: filter LISP cache file number, size and date on IOS-XE LISP EFT and filter dhcp db and vlan.dat in the same manner, instead of removing clogin.1: note not using [#>] in prompts xrrancid: additional file filters for 4.2 hpuifilter: dont use memcpy for overlapping regions - David Byers 2.3.8 rancid: filter sup-bootflash if sup-bootdisk worked *login: fix match of (yes/no) prompts from ssh rancid: carry-over additional inventory filtering from XR 2.3.7 xrrancid: change some "admin show" sorting to reflect previous code xrrancid: filter useless junk from show inventory mrvrancid: update ShowChassis() for temp filtering in new s/w nrancid: installed memory on Juniper SSG series - Steven Bertsch rancid: missing CR after s/n xrrancid: admin show variables boot clean-up - Per Carlson xrrancid: add admin show install summary, license - Per Carlson xrrancid: fix access-list formatting & sorting rancid: collect show capture & shun for ASA - Josh Ward xrancid: misc patches for XOS - Zenon Mousmoulas rancid-cvs: svn repository handling improvement - Zenon Mousmoulas rancid: filter WPA passwd - Pavel Korovin rancid: add 'show running-config view full' for role cli - Pavel Korovin rancid: filter ppp hostnames (aka usernames) - Pavel Korovin *login: update host key change match for newer ssh clogin: disable pager for XOS-12.3 - Zenon Mousmoulas rancid.conf & control_rancid: support arbitrary subversion URLs as (pre-provisioned) repositories and do not overwrite an existing local repository - Zenon Mousmoulas rancid.conf: add LC_COLLATE - Daniel Schmidt nlogin: add identfile support - Garry Shtern hrancid: match 'logout' in new procurve versions for end of run hrancid: include comment line for procurve parser - Per-Olof Olsson hrancid: collect show config status - mostly from Per-Olof Olsson nxrancid: add show environment fex all fan cmd - Deny IP Any Any *login: dont split $sshcmd nxrancid: Nexus 4000s don't support 'show environment power' - Lee xrrancid: add admin show running - Troy Boudreau arancid: /info/sys -> /info/sys/dump - Tim Frost rancid: correct isakmp key filter - Pan Affa clogin; set terminal width to 132 for both -s and -c clogin: respond to ASA's pager in long login banners - Lee clogin: set terminal width to 132 rancid: match flash memory on likes of Cisco 2811 and 2621XM - Pan Affa import share/rancid-cvspurge - Matthew Grossman rancid: add 'dir /all sup-bootdisk:' for 6500 sup32 - Lee rancid: adjust regex for tacacs key match - Pavel Korovin *login: join sshcmd clogin directive to handle spaces properly mt{login,rancid}: import Microtik module from Chris Boot rancid: ppp password missed on dialer interfaces - noted by Hirofumi Katou arancid: filter "esecret" lines which change with each config display - Ton hlogin: logout from enabled mode instead of exit for -S - Thorsten Hahn hrancid: collect show config files and show tech transceivers - Thorsten Hahn rancid: filter config timestamp on MDS/NX-OS avorancid: collect power management file - from Darius Jan Seroka fnrancid: correct comment character - noted by Gavin McCullagh fnrancid: update system time and conf_file_ver filters - Gavin McCullagh nxrancid: do not require 'show system redundancy status', apparently unsupported on some nexus models. clogin: set terminal width for -c and -s hlogin: stacks prompt for switch number or CR at login, send CR - Per-Olof Olsson 2.3.6 rancid.spec: updated for 2.3.6 - from Florian Koch rancid: fail on error opening nvram: rancid: skip ASA 5520 configuration author line control_rancid: for svn stupidity, run update (yes update) and commit after setting svn:ignore, else . is out of date. rancid: filter auto "rogue ap" configuration - Kevin Nesbitt alogin: adjust match of active alarms msg at login jrancid: patch for master/backup matching on EX series - Sven Engelhardt rancid: update cisco WAE identity string match - from Jim Hock {xr}rancid: summarize DirSlotN() bytes free as GB, else MB. rancid: filter sflog from DirSlotN() for IOS on cisco 10k fnrancid: update recent fortinet software - Diego Ercolani rancid: ignore show flash on IOS XE - Marcus Stoegbauer rancid: copy the dhcp database filter to ShowFlash() - From Lee clogin: Fix pasto in IOS terminal width command. hlogin: -r missing from usage o/p - Per-Olof Olsson clogin: add -r and passphrase/identfile from cloginrc - Per-Olof Olsson francid: remove system uptime line on CER 3000 - Simon Leinen 2.3.5 alogin: respond to active alarms msg at login - Vincent Tamet *rancid: update for grammar deprecated in perl 5.12 *login: handle noenable value consistently, '1' to turn it on configure: look for -n option to ping, for Windows ping (over cygwin) - From Lee rancid: missed case fpr accepting '>' prompt, rather than just '#' xrrancid: filter sequences from ipv4/6 access-lists zrancid: force terminal type vt100 so as not to confuse Linux francid: filter system uptime on new Brocades - Matthias Cramer rancid: filter ASA time-based license noise - Christopher DeRemer rancid: filter command in WriteTerm if echoed - Arjan Oosting configure: specifically look for ping in /sbin & /usr/sbin & fix typo in test operator rancid: handle a few IOS serial number formatting variants - Aaron Rees hpuifilter: change filtering to avoid use of string functions due to a Debian bug. Should be faster too. rancid: adjust show inventory matches for variables WS - Aaron Rees nxrancid: show environment clock and show core vdc-all are not valid commands on all platforms - Ryan West 2.3.4 nrancid: fix serial number matching - Nathan Wallwork nrancid: fix pager prompt filtering - Nathan Wallwork rancid: remove sequences from IPv6 prefix-lists clogin: adjust default ssh password prompt for ExtremeOS 12.3.3.6 - from Sylvain 74 rancid: Accept '>' prompt, rather than just '#' avologin: fix ssh command substitution - Ben O'Hara fnrancid: filter application signature, System Time & conf_file_ver= from GetSystem/GetConf mrvrancid: filter other oscillating info from show version - Ben O'Hara xrrancid: disable timestamps - from Per Carlson hlogin: implement -autoenable for newer hp procurve releases cat5rancid: snmp community may have multiple spaces b/t community name and permissions - from David Adam cat5rancid: filter local user password - from David Adam f5rancid: filter Failover time stamps - from Ben O'Hara hlogin: Add support for ssh identity file & passphrase for newer boxes rancid: split IOS-XR into its own device type: cisco-xr clogin: set term width for catos like for ios. rancid: parse admin show diag for XR better with a separate function hlogin: hpuifilter got omitted from the ssh spawn; replace it. nxrancid: match unknown command errors appropriately & GC some junk carried-over from IOS-rancid. 2.3.3 rancid: check for device busy when opening flash fails, which seems to occur on 6500s when some other command is run. *login: support :port method syntax for ssh and adjust to allow spaces in sshcmd jrancid: fix return values of formatting functions clogin: set terminal width so that o/p is consistent rancid: filter some crud resulting from the change in handling non-empty comment lines rancid: fail if the configuration buffer fills rancid: filter dhcp_[^[:space:].].txt from flash directories, so it does not create constant changes resulting from the ip dhcp database saves. rancid: filter ldap host password on PIX rancid: when compressing consecutive comment lines, only consider empty lines. arancid: handle password filter for HP 1:10Gb Ethernet Blade Switch 5.0.4-Base, running AOS - Tore Anderson *login: add cloginrc timeout directive nrancid: fix control number match - Guillaume RISCHARD rancid: remove ASA coredump* filter - Cisco Bug CSCsz85597, fixed in 8.2(1.2), 8.3(0.0), 100.3(0.3)M f5rancid: adjust fan rpm and config sync time filters for new f5 code - Ben O'Hara rancid: ACE/SANOS report invalid input differently - Michael Stefaniuc rancid: skip leading blank lines in config - Michael Stefaniuc rancid: remove ASA keys such as tacacs and radius - Michael Stefaniuc rancid: match non-space for usernames in "Written by" line - James Davis *rancid: quote meta characters - from Jeremy Singletary rancid: Fail on error msg "% Configuration buffer full" seen on 6500 rancid: Dont filter 'show vlan' on Catalyst 3550/4500s - Jon Lewis import Arista script - from Bill Fenner jerancid: fix for 'show environment all' for filtering with auto-sync on BRASes - from Christophe Fonteyne francid,flogin: edgeiron can not disable the pager and does not offer some commands found on the bigirons rancid: filter coredumpinfo/coredump.cfg found on ASA - rancid-discuss@ f5rancid: fileter HA peer status - from David Stipp WTI scripts from Geert Jan de Groot with a few tweaks jerancid: include standby slots in showversion o/p lg: add code for LG_SINGLE config knob clogin: run_commands() needs do_saveconfig f10rancid: change fan status parsing to handle c300 nxrancid: collect license info; fix 'show env temp' & 'show env power' parsing; drop unused code. change zero-config check to avoid broken awks - from jim buchele 2.3.2 clogin: fix for Extreme prompt handling nxrancid: delete Command: and Time: output f5rancid: install the script and use the device type 'f5' *login: accept -S for "save configuration if prompted" *login: remove uppercase versions of lowercase options tlogin: replace -debug with -d nlogin: cloginrc method handling and login error path fixes clogin: change "(enable)" and/or regex meta-char exscaping so that catalyst logins work properly. hlogin: run_commands exp_continueing when it shouldnt have jerancid: summarize DirSlotN bytes to reduce diffs rancid: catch aborted 'show diag' output on some 7300s. Bug found by Paul Vlaar. rancid: correct/add some filtering for ASA's more system:running-config srancid: filter temperature sensor info for Dell 6428 stacks hpuifilter: Filter \x07 (bell) from output, which the Cisco AGM suddenly started inserting *sometimes*. nxrancid: add "show version build-info". sort snmp-server user. rancid: filter filesize and date of tracelogs dir on IOS-XE rancid: summarize bytes free for IOS-XE like XR nsrancid/nslogin: updates for netscaler version 8 - Marco Schirrmeister f10rancid: updated support for all devices running FTOS: E-Series, C-Series and S-Series - Greg Hankins clogin: force10/SFTOS fixes for username & logout prompts - Doug Hughes f10rancid: SFTOS config end marker has trailing space - Marcus Stoegbauer mrvrancid: support for the MRV fiber switch rancid: collect GSR linecard route memory - Kritian Larsson clogin: new CSS configuration change prompt syntax - Kritian Larsson *login: add -- to other sends that take input from the user *login: terminate send options with -- to avoid interpretation of -'s in arguments - partly from Ric Anderson nxrancid: add support for cisco Nexus boxes; use type cisco-nx rancid: Skip "Cryptochecksum:" line on ASA, PIX, et al hrancid: K.13 s/w changed cmd 'show system information' - Richard Golier rancid: Spot yet another flash disk in show version output. rancid: Some support for Cisco Nexus. rancid: corrupted flash is not a rancid failure - from John Payne rancid.spec: Linux spec file - blame Steve Snodgrass rancid: changes for cisco SAN - from Mark Favas clogin: escape regex grouping atom '()' in the catalyst prompt - From Casey Deccio flogin: handle strange characters like space in prompt w/ the method from clogin for handling regex characters francid: filter SSL secret - From Jethro Binks francid: privlvl 5 does not allow write term, also run show running-config - from Jethro Binks *login: Return/exit non-zero if there are failures for any of the devices on the cmd-line. nslogin: password prompt change in newer code - from Derek Andree hlogin: reformat the prompt matching in run_commands() like cisco, which fixes -x and -c usage in configure mode. avorancid: Avocent (Cyclades) module - from Stephen Griffin f10rancid: updated support for all devices running FTOS: E-Series, C-Series and S-Series - from Greg Hankins jrancid: don't look for passwords in system login class XX permissions [] jrancid: additional filter for M320 rancid: ignore author failure for some data that are collected by different commands and succeeded the first time - from David Luyer *login: add -d to enable expect's debugging configure: make svn fs-type configurable with --with-svn=fstype xrancid: Correct the $prompt regex mangling for XOS - from Tore Anderson f10rancid: E-series support updated - loaner & clues from Greg Hankins rancid: Convert disk/flash free space to MB (from bytes) for IOX/IOS XR accept NO & YES for NOCOMMSTR in rancid.conf Add ACLSORT configuration knob - mostly from Michael Stefaniuc cat5rancid: permit missing CRLF on exit - Michael Stefaniuc cat5rancid: skip show inventory for those without - Michael Stefaniuc agmrancid: show diag can fail shortly after boot rancid: radius/tacacs key filtering on old IOS - from Michael Stefaniuc rancid: Add AS5xxx support from Andre van der Merwe. Changes so the RANCID-CONTENT-TYPE is the same as the documented entry in router.db.5 and the same as the call in rancid-fe. These RANCID-CONTENT-TYPEs changed: brancid from bay to baynet cat5rancid from cisco-cat to cat5 cssrancid from cisco-css to css erancid from adc-ezt3 to ezt3 fnrancid from Fortigate to fortigate hrancid from hp-procurve to hp jerancid from Juniper_ERX to erx srancid from dell to smc f5rancid: F5 BigIPs srancid: SMC/Dell switch support - loaner from Randy Bush *login: Set variables for do_login when both -e and -p/-v are specified - reported by A Dudek *login: recognize the environment variable CLOGINRC, see clogin(1) agmrancid: Cisco AGM/Anomaly Guard Module francid: drop fan speed o/p from show chassis - John Adams clogin: match Cisco CSS's "save config?" prompt - Lance Vermilion jrancid: include show system core-dumps - Michael Lyngbol rancid: filter empty 'show inventory' fields - from Michael Stefaniuc *login: If we timeout while trying to quit in run_commands(), close the connection (ie: file descriptor/tty) gracefully. - from Ed Ravin, adjusted to catch the close. jrancid: Adapt M160 PCG freq rounding to new format - noted by Mark Davis rancid: collect flash size on the FWSM - from Aaron Gee-clough francid: Fix temperature/show chassis filtering for newer Foundry boxes - noted and tested by Gary Roberts rancid: fix Cisco 3825,3845 show version parsing - Michael Stefaniuc clogin/hlogin: use send -h for exit command - Michael Stefaniuc clogin: Answer F10's "unsaved changes" logout prompt - Colin Corbett f10rancid: "Current Conf" begins with ! in recent code - Colin Corbett francid: sort intf "secure" MACs, order fluctuates - noted by Brad Volz francid: filter temperature o/p on the SuperX - Brad Volz convert rancid-fe vendor list to a hash - suggested by Ed Ravin. rancid: new format for PIX 7.0 license string - Aaron Gee-clough rancid: check for 7300 type of routers clogin: older CatOS for 1900s has a CR after the pager prompt clogin & xrancid: Extreme XOS prompt format changed - Tore Anderson User a .cvsignore file to prevent non-cvs'd control files from appearing in cvs update output. rancid: include _ in IOS version strings clogin: reduce the number of leading prompt characters used in run_commands to accomodate change seen in cat6500 12.1(13)E14 - Charles Aresenault hlogin: fix ssh hanging on press any key prompt - Ryan Mooney rancid: more support for HFRs nlogin: fix missing -re option for password matching - Jee Kay lg: fix quoting of juniper command arguments - Richard Doty rancid: also match _ in software image names - Stafford A. Rau nrancid: fix config comment character & more filtering - Stoned Elipot hlogin: look for the 'press any key' prompt after ssh authentication, unlike telnet, where it appears before authentication. hpuifilter: allocate a pty to interact with ssh/telnet, so that we interact with ssh for the password exchange. WARNING: repeated ssh login failures to HP Procurves cause the switch's management interface to lock-up (this includes snmp, ping) and sometimes it will crash. This is with the latest firmware; 5.33 at the time of this writing. *rancid: check hostname, or filename, before opening the output file. rancid: better filtering of {tacacs,radius}-server - Patrick Adlam rancid: better filtering of PIX pager prompt - Aaron Gee-clough rancid: collect show debug - Ed Ravin add subversion support - mostly from Justin Grote clogin: support rsh method - partly from James Stahr collect show inventory raw on rancid and cat5rancid add -ko to cvs diff commands - Michael Shields Add a MAILHEADERS configuration variable for user-defined mail headers rancid: match HSRP group numbers greater than 1 char wide - Ed Ravin nrancid: filter radius secrest - Jee Kay *rancid: collapse the two command list definitions to an array of hashrefs and build the lists from it - Ed Ravin *login: ignore rsh on platforms that do not support it and on those that do (eg: cisco), skip rsh for interactive and script (-s) logins. add MAX_ROUNDS rancid.conf knob - Mardechai Abzug control_rancid: fix adminmailrcpt default - Danny Thomas rancid: correct handling of SNMPv3 host configs - Patrick Adlam rancid: filter nv_hdr file seen on sup720 - Bill Ouchark etc/Makefile.am: support DESTDIR - from Michael Shields rancid: add IOX/CRS support. hrancid: show stack does not apply to all procurves - Eugene Zagrebelny flogin: older foundry o/s has misc spaces preceeding : in username prompt - from mike ethridge A better nlogin & nrancid for NetScreens - help from Stephen Gill jerancid: case fluctuates in "active/standby" - from David Gethings jerancid: filter "please wait" from config - from David Gethings jerancid: filter consecutive periods at top of write term - mark cooper jerancid: fix check for slave RE sync in DirSlotN - from Mark Lovely rancid: collect 6500's sub-module info from show modules jrancid: collect license info & RE Model. Don't collect the license keys as this is only supported on the jseries and running 'show system license keys' on other junipers produces output from *two* commands - 'show system license' AND 'show system licensekeys'. rancid: erroneous space in shared-secret match - from Blaz Zupan nrancid: fix missing brace - from David King lgform: need strftime from POSIX - from Joao Frade rancid: filter multiple-fs file - from Yuval Ben-Ari cssrancid: make this parse the collected output properly rancid: filter & sort IOS AP username passwords - noted by Stafford Rau rancid: parse more variants of 'show diag' output. 2.3.1 jerancid: fail/retry if the RP is syncing to the backup - Dave Mack clogin: cat 19k lacks a space in front of pager prompt - darren @ adam nlogin: correct find(sshcmd) argument - from Samuele Giovanni Tonon lg.cgi: allow :s in arguments for sub-interface from Richard Doty jrancid: filter some more secrets rancid: filter some more secrets francid: bits for Mucho Grande - from Niels Bakker add -- before (telnet|ssh) in call to hpuifilter so that any options for telnet/ssh are not interpretted by hpuifilter look for diff -U if diff -u fails in configure. fix typo in nlogin that made cloginrc password lookups fail. 2.3 The following files have been moved to make rancid more install/pkg/port/rpm friendly. *** bin/env has been moved to etc/rancid.conf *** *** bin/hpfilter has been renamed hpuifilter *** *** util/lg/lg.conf has been moved to etc/lg.conf *** *** util/lg/lg*.cgi have been moved to bin/lg*cgi *** *** bin/create_cvs has been renamed rancid-cvs *** *** bin/do-diffs has been renamed rancid-run *** Note: existing configuration files are *NOT* copied/moved for you bin/rename is no longer shipped with rancid rancid.conf: add MAILDOMAIN knob - from David C. clogin: allow the port to be specified for method ssh jlogin: add cloginrc passphrase directive and order of precedence is cmd-line -r value -> passphrase -> password xrancid: do 'show diag' instead of 'show diagnostics' as the longer version has sometimes timed out. rancid: filter file vlan.dat from show flash on IOS switches rancid: parse cisco 1760's DSP slot show diag output francid: reorder listing of ports in a vlans - from Niels Bakker and Steven Bakker clogin: disable session logging w/ -c on catos - from Jason Ornstein rancid: add Processor ID to save output *login: handle TCL meta-characters in cloginrc directive values francid: correctly parse modules in slots >= 10. from Niels Bakker run cvs delete code even when router.db is empty. Riverstone/Enterasys updates from Andrew Fort rancid.conf: add LOGDIR variable - see rancid.conf(5) rancid: add show spe version and parse FRU show diag output - from Yuval Ben-Ari. add option --enable-adminmail-plus to configure jrancid: collect show chassis alarms rancid: skip show vlan for (3550|4500|7600) - from Andrew Fort rancid: collect 6500 slave sup bootflash - from Andrew Fort rancid: show diag updates for 1700, 3700, etc - help from Michael Haba The Extreme does not have an 'enable' level, so make sure you have 'set autoenable' for it in your .cloginrc so clogin will work. add Cisco CSS support - from Wedge Martin *login: add cloginrc sshcmd directive - idea from steve neighorn rancid: IOS show version changes w/ 12.3 - from Yuval Ben-Ari support for hitachi routers - from Mohacsi Janos strip WS around router.db fields - from Alastair Galloway add goveling of 2600 mainboard port adapter info *login: also check LOGNAME for default username - from Fredrik Thulin jerancid: add matches for "Please wait" to all functions - reported by Dave Mack fnrancid: Fortigate support - from D. Pfleger nlogin: Fix prompt groveling when running a cluster - from D. Pfleger nrancid: filter "set admin user" - from D. Pfleger rancid: do both 'write term' and 'show running-config' and keep the output from the first one that works. As cisco phases out 'write term', this will keep things working. jerancid: filter host ... ftp, encrypted passwords oscillate - reported by Dave Mack. rivlogin: add "User:" as a possible username prompt (u_prompt) for some platforms - from Adam Rothschild cat 3500 s/n and pix failover license - from Rob Evans recognize cisco ContentEngine - from Rob Evans Juniper ERX (jerancid) support, based on 5.0 - thanks to Dan Pfleger, Richard Russman, Zaid, Mike Baker, and Mark Nguyen rancid: drop the "suggested action" portion of GSR LC/RP ROM upgrade warnings. Cisco keeps changing the format; it just is not worth the aggrevation. study causes missed command somehow in redhat9 - from David King filter port security mac entries, from Arnold Nipper add Procket Networks support, "prancid" filter ipsec keys in rancid & jrancid. rancid: collect show idprom backplane (6500 cmd); this could collect more - request from jared mauch rancid: order all 'ip host' commands. rancid: collect show rsp chassis-info rancid: filter HSRP auth and SSA key-string reversable passwords lg: set query/command list in lg.conf, thus allowing individual cmds to {dis,en}abled, and add some multicast and ipv6 queries all of which are disabled by default (for lack of testing) - from Janos Mohacsi cat5rancid: collect 'write term all' for cats that support it - tested by terry kennedy and joe rizzo cat5rancid: regularize escaping of regex operators in switch prompt nsrancid: include "get log setting", as suggested by gael canal. add manpage note about log_user with -s, from mail list discussion xrancid: Handle end of ssh connection a bit better. jrancid: skip master/backup re msgs *rancid: escape regex chars found in prompt xrancid: also collect 'show configuration detail' hlogin: allow the port to be specified for method ssh and add path to hlogin to env(PATH) for locating hpfilter hpfilter: allow >2 arguments so that telnet port number can be passed. rancid: gsr RP slot warning is only 1 line - Russell Heilling add zrancid to handle zebra routing s/w add riverstone support - from Jim Meehan. thanks to Hong Luo for access to a riverstone to test. Kevin Chan reports that this works for Cabletron routers with more recent s/w (~v9.0.3). jrancid: fix handling of reversible keys such that trailing text is not removed rancid: slave/redundancy stuff - from stephen griffin rancid: show version bootstrap format changed in 12.0(23)S rancid: make sure we filter PIX pager prompts xrancid: make xrancid work when the extreme has pending changes. netscaler support - from Anshuman Kanwar. netscreen firewall support - from Stephen Gill rancid: include additional cpu info from show version in !CPU: line. lucent tnt support - from Richard Vander Reyden rancid: skip consecutive comment lines. on some access servers the number of comment lines oscillate. lg.conf: add LG_STYLE variable for style sheet - from Janos Mohacsi also install the FAQ - good idea from Janos Mohacsi's freshport rancid: filter 'cable shared-secret' 2.2.2 *login: fix handling of userprompt et al so that {}'s are used in .cloginrc as they are with every other .cloginrc directive. f10rancid: Fix to pick up new info in show version output. jrancid: Ignore Timecounter "TSC" in show system boot-messages output. rancid: filter tty line speed when configured for auto-configure flogin: bring login() and do_enable() in-line with [cj]login. also match "telnet server disabled" - from brad volz. control_rancid: report devices added to router.db - from Fredrik Thulin also eliminate empty up/down lists. rancid/jrancid: filter isis passwords - partial from Janos Mohacsi lg: make o/p from the lg stream (unbuffered), so one doesnt have to wait for entire o/p from the router in a failing traceroute, for example. suggestion and clues from alexander koch. while here, fix cache handling so 1) it doesnt cache cmds that resulted in an error or otherwise failed and 2) log and run the cmd as normal if there are problems opening a cache file. lg: make logging more consistent. log as defined by LG_LOG if possible and stderr as last resort. it was logging largely to stderr. and make exit-code small (instead of 255); some wait()s only look at the first 3 bits lg: add check in lg.cgi that router name appears in the router.db and is thus accessible. from richard doty. also fix-up a few comments and such. rancid: GSR LC PCA h/w revision now called "design release" on some platforms. CSCdw13295 add util/getipacctg example script - contrib from steve neighorn 2.2.1 rancid: npe400 cpu eeprom info o/p format changed in 12.0.21S1 - spotted by tom campbell fix problem in *login where if there was a login failure we would try to disconnect gracefully (albeit incorrectly). writing to the half-closed socket would not return an error (at least on some platform/expect combinations or even consistently) and expect would hang. add device name to diff mail subject when -r is specified add -m option to do-diffs and control_rancid to allow specific mail recipient. intended for use with -r to trigger diffs off specific events. router.db(5): note that PIX is a 'cisco' - thank kris gulka *login: match openssh prompt for host key to ip key mismatch rancid: add disk/slot2 rancid: 12.2 show c7200 o/p for midplane changed lg: use table inet.0 terse for sh ip route on juniper instead of forwarding-table destination rancid: 12.0S(21) added "FRU" field in show diagbus output. Also look for a couple more things in some show diag output and sort the output a bit better. Also look for 'controler' (cisco can't always spell - thanks to Terry Kennedy for spotting the misspelling). lg: filter ["`'] from args rancid: fix username secret filtering alogin: misplaced brace caused improper return from proc login relax the check ping and traceroute check of hostname arguments such that non-fqdn hosts are allowed. i.e.: just check that arg chars are valid dns chars and leave the resolve errors to the router. Add initial support for Force10. 2.2 rancid: filter vpdn passwords on PIX - from eric greenwood *rancid: handle variable amounts of spaces in front of ' password' correctly. rancid: remove key from "crypto isakmp key". *login: cleanup login() to be more generic and handle openssh password reprompting clogin: fix clogin -x for config mode by adjusting the prompt regex lg.conf: add LG_INFO to append local information to the main form {cat5}rancid: add dir of sup-{bootflash,microcode} for 6500 *rancid: print $host before "missed cmds", "unexpected command", and "End of run" messages. cat5 module type match failed when user module name contained spaces add FILTER_PWDS switch to env(5) add merit MRTd support add -r option to do-diffs and control_rancid brancid: handle []'s in bay prompts and drop lock-address from config - from mark cooper extreme: strip password if config|configure. Strip ^M right after ssh key. Look for BOOTLDR: on ciscos. add par.1 manpage allow a TCP port suffix to telnet in .cloginrc - from Alex Bochannek Fixed RANCID-CONTENT-TYPE to be more consistant. Changes are brancid bay cat5rancid cisco-cat erancid adc-ezt3 jlogin should not look for username@router in .cloginrc filter foundry ssh private key filter '#Time" from catalyst 4 write term display platform specific command in lookingglass results - patch from Janos Mohacsi add support for HP procurve switches, in particular 2524M and 4108gl. thanks to hp for the loaners. filter encrypted passwords on alteon as the change for each display More support for Redbacks. rancid now looks for "[kK] bytes" and "slot|disk". clogin now looks for "login:" as well as "Login:" and escapes "[]" in $prompt. 2.2b8 add PAR_COUNT variable to bin/env for adjusting the number of simultaneous collections. see bin/env (or bin/env.new for those with previous installation) and the env(5) manpage. more work on extreme switch bits + fixes from Alex Bochannek. jlogin: add 1s sleeps to avoid passwords being echo'd before tty noecho is set. richard doty few looking glass fixes brancid: filter uptime and add -all option to config for bayrs version 14. from mordechai abzug jrancid: m160 measured chassis clock MHz fluctuates, trim the decimal places. from Mark A Gebert. par: -x fix for log file monitoring killing xterms. from rdrake. 2.2b7 brancid: patch to filter community strings from Mark Cooper do-diffs: trap'ing SEGV (11) causes error on solaris. 2.2b6 baynetworks/nortel support from Mark Cooper. thanks mark! jlogin was overloading -p's variable causing proc login to fail on 2nd router on cmd-line 2.2b5 fix regex error in clogin affecting catalysts clogin attempts to grope entire prompt after login *login need to catch{} -x cmd file open so expect doesnt puke if there is an error opening the file 2.2b4 add extreme switch bits cisco changed the o/p fmt of h/w info on the 65xx in 12.1.8e PIX520 supplies different more(1) prompt than others. from William R Thomas. fix typo in jlogin. from richard doty. add 2 example expect script for clogin -s handle foundrys and more juniper bits in the lookingglass add LG_STRIP knob to strip login o/p in the lookingglass add LG_BGP_RT knob to {dis}allow heavy o/p sh ip bgp neighbor LG cmds bin/clogin shouldnt insist upon an enable password with -noenable option 2.2b3 bin/rancid changes for cisco 124xx some serial controllers (PAs) have predefined cable-type in show controllers. M8T-V.35 was being missed. modify jlogin to grope the full prompt after login such that -x can be used within configuration mode. note: this turns $prompt into a regexp, WRT -s scripts and -re option for expect's. add -Evar=x option to pass variables to scripts. e.g.: clogin -Evariable=something router... clogin -Evariable=a,b,c [i.e.: an array/list which user splits] 2.2b2 fix jlogin's password/userpassword functionality which broke when cmd-line options were made consistent. add check for config/* files missing from the cvs repository. add 2 juniper config checks to avoid truncation. 1) config should have at least 1 "section" amounting to at least 3 lines and 2) if a mgd version mismatch exists, there may be inaccuracies. convert usage of Mail to sendmail for portability. local .mailrc aliases can no longer be used. bin/alogin and changes (of beta quality) for Alteon WebOS switch from andrew fort. Check for more types of cisco 12000s. Also check for 2600s. jrancid's show chassis hardware needs detail arg in junos 4.4 make *login print \n before errors, so rancid can use an anchored match to find login errors and avoid such matches in router o/p. make *login automatically add host keys with openssh's prompting All routers not listed as 'up' in router.db are considered down. This allows values other than down to mean 'not up'. for use by util/downreport. 2.1 Change default umask to 027 (it was 007) mainly as an attempt to stop people from changing stuff in rancid's CVS store. Only rancid should be updating its CVS store. control_rancid cvs updates router.db before starting a group's collection. configure now has a --enable-mail-plus option to have rancid send mail to rancid+$GROUP instead of to rancd-$GROUP. Patch from davidw@certaintysolutions.com. configure should figure out diff options on it's own. try to get default user from env() and catch exec on id in *login make clean/distclean was missing some files make sure do-diffs cleans up after itself if it exits prematurely ignore case when cvs delete'g removed routers francid/rrancid (foundry/redback) now strip snmp communities like the others, via NOCOMMSTR var in bin/env. add man pages collect 'sh vlan' on cat 6000 - afort@choqolat.org Add 'show vtp status' for the 3500XLs as well. Escape regex meta-chars found in device prompts in *rancid Add "include" directive to include other pwd files via .cloginrc Add "show port ifindex" for the cat5s. Try to detect flash being busy on a cat5. Tag each config file with its 'type'. E.g.: !RANCID-CONTENT-TYPE: cisco fix from afort@staff.webcentral.com.au to lg.cgi to allow prefix-list with numerals. fix lg form's formatting (on some browsers/conditions). Thanks to rrashid@verio.net for the html help. 2.1b add looking glass utility based on Ed Kern's original source. Thanks to Ed for permission to include it with rancid. this is only partially tested. fixed expect foo in *login when .cloginrc is unreadable. Don't sort 'ip name-server' - order matters. 2.0 Better formatting for cisco catalyst [non-ios] switches. Better support the cisco 3500 switches. Get some info out of "show version" for the cat5ks. cat5k "show boot" does variables, not bootflash. Skip more goo from 'write term' on some cat5ks. Collect 'show module' for 6500-ios. Revamp *login's use of .cloginrc's method directive. see cloginrc.sample. Add bits for Cisco PIX. Thanks to joe rizzo@EA for access to a PIX. Sort usernames on ciscos. Get more info out of "show diag" on the GSR. Add "show chassis sfm detail" for the M160. Leave router type in place when telling about changes to router.db. Add autoconf (configure) and makefile bits to automate install and perl/expect replacement 1.6 Add "dir nvram:" to rancid. Add support for ADC EZ T3 mux. adapted from tkenndedy@verio.net's contrib. strip (try to) snmp community strings from cisco and juniper configs if environment variable NOCOMMSTR is set. merge tkennedy@verio.net's support for cisco 2900xl into rancid Ignore "fan spinning at" noise on junipers. 1.5 sync command-line option between clogin / jlogin. jlogin modified: -x passphrase -> -r passphrase -> -x command-file -e encrypt type -> -y ssh_chyper_type add .cloginrc noenable directive to set the cmd-line -noenable option. add .cloginrc userprompt, passprompt, and enableprompt directives to adjust expected cisco router prompts in clogin. see README for info on web interface to rancid CVS repository. Try to detect hung rancid jobs & send email. Add (partial) support for the cat5s. Still need more work on the show output, but it does grab the config. Skip the juniper's kernel version, memory, and fsck output of "show system boot-messages" - fsck output changes every time you boot and the version & memory is better found elsewhere. Delete the cisco ospf authentication and ftp passwords. Get both (juniper) show chassis ssb and scb but only process them once. Get info from show diag for 2600s as well. Catch juniper "command is not valid on the olive" errors. Catch juniper config mismatch between versions of JUNOS. Catch close on EOF in clogin/jlogin/flogin. Don't expand RCS keywords in config files. Catch the case were rancid gets and error and leaves an empty new config file. Make the time to elapse before complaining about unreachable routers be configurable instead of fixed at 24 hrs. The default is now 4 hours. Add -x passphrase to jlogin. You can now set a ssh identity file in .cloginrc for use with jlogin. Handle more errors in jrancid. Also handle changes for JUNOS 4.0 and collect "show system boot-messages" output. rancid now recognizes cisco 12016s and more types of 7200s. It also looks for WARNING messages in show version. And sort ip explicit-paths. 1.4 sort cisco route-maps added (crude) foundry switch bits reworked code to reduce jumps. improvement in speed/cpu util. add bits to cvs delete configs which have been removed from a group's router.db. add support for redback. modified from contrib by scao@verio.net. add support for ssh in clogin modify format of the admin up/down/delete'd msgs. add NOPIPE bin/env var order ARP lists in cisco configs 1.3 update comments re: mail aliases in bin/env add more info/clarification to README for install. 1.2 add more info/clarification to README for install. rename .cloginrc.sample -> cloginrc.sample. clogin patch (courtesy stephen stuart); does two things: - adds a "-x" switch that takes lines from a file and does the same thing as if you'd specified ;-separated commands with -c (newline separates commands). thanks to stephen stuart. - does a subst on commands in run_commands so that expansion of escapes is performed; e.g. you can say "copy rcp://blah slot0:\r" to answer the question that comes after the copy command. rancid-3.13/Todo000644 015615 000000 00000014536 13713052202 013612 0ustar00heaswheel000000 000000 - maybe use https://tox.readthedocs.io/en/latest/ to test python code - add user-specific post-filter option per-device-type to filter output before diff (thus affecting mail and commit). - allow -r to be specified multiple times for rancid-run/control_rancid - add description of the data path/process of a rancid script - add configure option to force the location of perl - would like router cmd-line timestamps based on login. suggest .cloginrc knob for pre-cmd ("post-login"), pre-interactive-cmd ("post-interactive- login"), and the like. it would need to be per-mfg, ie: either know the mfg of the device or assume it from the *login cmd used. eg: add pre-cmd * term monitor add pre-cmd-ios * term monitor -i option - it would be useful to log commands that are permission denied rather than just failing. it was mentioned on cisco-isp list. - login script should catch output to stdout/user, so that if the rancid script exits prematurely, such as due to a cmd authorization failure, the user doesnt get a tcl traceback See http://www.tcl.tk/man/tcl8.4/TclCmd/catch.htm - related; could also add an error msg for required command like write term in the authorization failure case: return(-1) if (/command authorization failed/i); - '% clogin clogin' w/ ssh default produces a tcl traceback - RSP440 show version info is missing, eg: !Chassis type: ASR9K Series - a ASR9K Series router - make *login and login.top.in cmdline options common among all scripts - sup2t show version info is missing - cpu info missing from sup-2t Index: configs/r01.londen01.uk.bb.gin.ntt.net =================================================================== retrieving revision 1.807 diff -U 4 -r1.807 r01.londen01.uk.bb.gin.ntt.net @@ -1,24 +1,23 @@ !RANCID-CONTENT-TYPE: cisco ! !Chassis type: WS-C6509-E - a WS-C6509-E router - !CPU: R7000, SR71000 CPU at 600Mhz, impl 0x504, Rev 1.2, 512KB L2 Cache + !CPU: M8572 ! - !Memory: main 983008K/65536K - !Memory: nvram 1917K - !Memory: bootflash 65536K + !Memory: main 1769472K/262144K + !Memory: nvram 2543K ! !Catalyst Chassis type: WS-C6509-E, Catalyst 6500 9-slot backplane !Catalyst Chassis S/N: SMC1130002A !Catalyst Chassis assembly: 73-9221-06, rev A0, ver 1.4 !Processor ID: SMC1130002A ! ! - !Image: Software: s72033_rp-ADVIPSERVICESK9-M, 12.2(33)SXI7, RELEASE SOFTWARE (fc1) - !Image: Compiled: Mon 18-Jul-11 05:49 by prod_rel_team - !Image: disk0:s72033-advipservicesk9-mz.122-33.SXI7.bin + !Image: Software: s2t54-ADVIPSERVICESK9-M, 12.2(50)SY1, RELEASE SOFTWARE (fc2) + !Image: Compiled: Tue 29-Nov-11 20:49 by prod_rel_team + !Image: bootdisk:s2t54-advipservicesk9-mz.SPA.122-50.SY1.bin ! - !ROM Bootstrap: Version 12.2(17r)S4, RELEASE SOFTWARE (fc1) + !ROM Bootstrap: Version 12.2(50r)SYS2, RELEASE SOFTWARE (fc1) ! - rivlogin is a mess - lg.conf(5) needs the query stuff documented. - could the cloginrc match function do a longest-match search instead of first match? - look at Andreas Dahl's Brocade switch collection scripts - noenable should handle a value properly. i.e.: 1 == noenable, 0 == enable or perhaps don't clear the -noenable cmd-line option. the manpage needs to be fixed as well. see msg from fred jordan. - recent hp procurve s/w does not seem have show flash or show module - would like to have a "pre-login-sequence" cloginrc directive, see rancid-disuss message from mike ethridge 16/may - would like to have a "login_option" cloginrc directive to specify arbitrary command-line options - possibly a "debug" (exp_internal 1 ?) cloginrc directive? *login -d flag for same? warning about filling logs? - on 6500, show boot and show bootvar produce the same output and both appear in the crunched config. should one be filtered? - isis filtering for foundry? - hlogin hangs when the procurve does not ask for passwords - share/ tool to prune cvs versions, excluding those with tags, by (all but latest | keep N versions | keep N days/months/years) - extreme collection fails for tacacs-enabled boxen due to diffs in UI - blech! - FILTER_PWDS knob is not implemented in alteon, bay, ezt3 or redback due to lack of h/w to test against. need help from the community. - should par's -c override an input files' : cmd? - should *login emmit "clogin error:" or "*login error:" to make matches for login failures definitive? - would like hpuifilter to be more friendly to interactive logins - rancid with zebra via vtysh? - rancid for unix? - would be nice if it were possible to add additional commands to be run per-platform as a user desires. how could the user also provide a filtering routine? - a format such as {} as the pwd in .cloginrc to indicate *login should prompt the user for the password - implement the bits marked unimplemented in lg.conf - detect 'same' vty configs - ignoring length/width/passwd is a start, but need more - merge clogin and jlogin (or *login !!) into one. possible? - flogin needs to be fixed for the userpasswd bug seen in jlogin 1.17, but this is clouded by the UI mess. - LG should sort routers - LG {requested} command additions - show controllers T3 (data) - handle redback in the looking glass - show ip as-path-access-list - show access-list - show ip community-list - show ip route-map - should we add CVS ID header to saved configs? configurable option? - idea from andrew fort - cat 2900 extra info uptime is 3 weeks, 3 days, 14 hours, 17 minutes System returned to ROM by power-on System restarted at 15:21:54 UTC Mon Sep 30 2002 System image file is "flash:c2950-i6q4l2-mz.121-9.EA1d.bin" cisco WS-C2950-24 (RC32300) processor (revision B0) with 20821K bytes of memory. Processor board ID FHK0619X2RN Last reset from system-reset Running Standard Image 24 FastEthernet/IEEE 802.3 interface(s) 32K bytes of flash-simulated non-volatile configuration memory. Base ethernet MAC Address: 00:09:B7:50:DE:C0 Motherboard assembly number: 73-5781-10 Power supply part number: 34-0965-01 Motherboard serial number: FOC061903JF Power supply serial number: DAB061735H4 Model revision number: B0 Motherboard revision number: A0 Model number: WS-C2950-24 System serial number: FHK0619X2RN Configuration register is 0xF - Why does nlogin use a gratuitiously different variable name for the device(s) in the main loop? rancid-3.13/missing000755 015615 000000 00000015336 13735672075 014404 0ustar00heaswheel000000 000000 #! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2018-03-07.03; # UTC # Copyright (C) 1996-2020 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=https://www.perl.org/ flex_URL=https://github.com/westes/flex gnu_software_URL=https://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: rancid-3.13/depcomp000755 015615 000000 00000056020 13735672075 014355 0ustar00heaswheel000000 000000 #! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2018-03-07.03; # UTC # Copyright (C) 1999-2020 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: rancid-3.13/lib/rbt.pm.in000644 015615 000000 00000015463 13532047075 015275 0ustar00heaswheel000000 000000 package rbt; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # rbt.pm - Riverbed Steelhead use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; our $proc; our $found_version; our $type; # device model, from ShowVersion @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { $found_version = 0; $type = undef; # device model, from ShowVersion # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: $devtype\n#\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#>]+[#>])/)[0]; $prompt =~ s/([][}{)(+\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/[>#]\s?exit$/) { $clean_run = 1; last; } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; my($slave, $slaveslot); print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; if (/^$prompt/) { $found_version = 1; last}; next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(0) if ($found_version); # Only do this routine once return(-1) if (/command authorization failed/i); next if (/^uptime:/i); next if (/^cpu load averages:/i); if (/^product model:\s+(\S+)/i) { $type = $1; ProcessHistory("COMMENTS","keysort","A1", "#Chassis type: $1\n#\n"); next; } /^system memory:.*\/ (\S+ \S+) total/i && ProcessHistory("COMMENTS","keysort","B1", "# Memory: $1\n") && next; ProcessHistory("COMMENTS","keysort","X1", "# $_"); } # flush the history ProcessHistory("","","", "#\n"); return(0); } # This routine parses "show hardware all" sub ShowHardware { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowHardware: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); ProcessHistory("COMMENTS","keysort","HW","# $_"); } ProcessHistory("COMMENTS","keysort","HW","#\n"); return(0); } # This routine parses "show Info" sub ShowInfo { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInfo: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); next if (/^(appliance|service) up ?time:/i); next if (/^temperature/i); next if (/^services needs a .*restart.* due to a config change/i); /^serial:\s+(\S+)/ && ProcessHistory("COMMENTS","keysort","B1", "#Serial Number: $1\n") && next; } ProcessHistory("COMMENTS","keysort","IO","#\n"); return(0); } # This routine parses "show license" sub ShowLicenses { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowLicenses: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); ProcessHistory("COMMENTS","keysort","LICENSE","#LICENSE: $_"); } ProcessHistory("COMMENTS","keysort","LICENSE","#\n"); return(0); } # This routine parses "show peers" sub ShowPeers { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowPeers: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); ProcessHistory("COMMENTS","keysort","PEERS","#PEERS: $_"); } ProcessHistory("COMMENTS","keysort","PEERS","#\n"); return(0); } # This routine processes a "show configuration" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($comment, $linecnt) = (0,0); while (<$INPUT>) { TOP: tr/\015//d; last if (/^$prompt/); return(1) if (!$linecnt && /^\s+\^\s*$/); next if (/^\s*$cmd\s*$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(1) if (/\%Error: No such file or directory/); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(0) if ($found_end); # Only do this routine once return(-1) if (/command authorization failed/i); return(-1) if (/% ?configuration buffer full/i); next if (/^\s*$/); $linecnt++; if (/^(\s*username \S+ password 7) \$6\$/) { if ($filter_pwds >= 2) { ProcessHistory("USER","","","#$1 \n"); next; } } elsif (/^(\s*username \S+ password 7) / && $filter_pwds >= 1) { ProcessHistory("USER","","","#$1 \n"); next; } if (/^(\s*service shared-secret secret (client|server)) \S+$/ || /^(\s*ip security shared secret) \S+$/) { if ($filter_pwds >= 1) { ProcessHistory("USER","","","#$1 \n"); next; } } if (/^(\s+snmp-server community) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_", "#$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # catch anything that wasnt matched above. ProcessHistory("","","","$_"); } # It lacks a definitive "end of config" marker. If we have seen at least # 5 lines of config output, we can be reasonably sure that we received the # config. if ($linecnt > 5) { $found_end = 1; return(0); } return(0); } 1; rancid-3.13/lib/wavesvros.pm.in000644 015615 000000 00000014221 13532047232 016527 0ustar00heaswheel000000 000000 package wavesvros; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # wavesvros.pm - Ciena Waveserver rancid procedures # use 5.010; use strict 'vars'; use warnings; require(Exporter); our @ISA = qw(Exporter); $Exporter::Verbose=1; use rancid @VERSION@; @ISA = qw(Exporter rancid main); #our @EXPORT = qw($VERSION) # load-time initialization sub import { $timeo = 120; # jlogin timeout in seconds 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while (<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host hlogin error: $_"); print STDERR ("$host hlogin error: $_") if ($debug); $clean_run=0; last; } if (/System shutdown message/) { print STDOUT ("$host shutdown msg: $_"); print STDERR ("$host shutdown msg: $_") if ($debug); $clean_run = 0; last; } if (/error: cli version does not match Managment Daemon/i) { print STDOUT ("$host mgd version mismatch: $_"); print STDERR ("$host mgd version mismatch: $_") if ($debug); $clean_run = 0; last; } while (/[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $_ =~ /^([^>#*^]+)([*^])?([>#])/; $prompt = $1; my($tail) = $3; $prompt =~ s/([][}{)(\\])/\\$1/g; # prompt changes when config is unsaved - "foo*> " and may be # "foo$> " for some unknown reason. $prompt .= "[*^]?" . $tail . " ?"; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/[>#]\s*exit/) { $clean_run=1; last; } } } # This routine parses a few commands generically sub GenericCmd { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In GenericCmd: $_" if ($debug); # include the command s/^[a-z]+@//; s/^([^ ]+)\*([>#])/$1$2/; ProcessHistory("","","","! $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); ProcessHistory("","","","! $_"); } ProcessHistory("","","","!\n"); return(0); } # This routine parses "chassis show" sub ShowChassis { my($INPUT, $OUTPUT, $cmd) = @_; my($PSW) = 0; print STDERR " In ShowChassisClocks: $_" if ($debug); # include the command s/^[a-z]+@//; s/^([^ ]+)\*([>#])/$1$2/; ProcessHistory("","","","! $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); /no matching entry found/ && return(-1); # unknown cmd # skip fan status/chassis power draw if (/(cfu fan status|chassis power summary)/i) { while (<$INPUT>) { tr/\015//d; return(-1) if (/^$prompt/); last if (/^\s*$/); } } # filter PS wattage from power supply status if (/power supply status/i) { ProcessHistory("","","","! $_"); while (<$INPUT>) { tr/\015//d; goto EndShowChassis if (/^$prompt/); $PSW = 1 if (/power \(w\)/i); if ($PSW && /^((?:\|[^|]+){7,})\|\s+(?:[0-9.]+ \|)/) { ProcessHistory("","","","! $1|\n"); } else { ProcessHistory("","","","! $_"); } last if (/^\s*$/); } } ProcessHistory("","","","! $_"); } EndShowChassis: return(0); } # This routine parses "software show" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); # include the command s/^[a-z]+@//; s/^([^ ]+)\*([>#])/$1$2/; ProcessHistory("","","","! $_"); # skip software state info while (<$INPUT>) { tr/\015//d; return(0) if (/^$prompt/); /no matching entry found/ && return(-1); # unknown cmd last if (/^\s*$/); } while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); ProcessHistory("","","","! $_"); } ProcessHistory("","","","!\n"); return(0); } # This routine parses "configuration show" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; my($snmp) = 0; print STDERR " In ShowConfiguration: $_" if ($debug); # include the command s/^[a-z]+@//; s/^([^ ]+)\*([>#])/$1$2/; ProcessHistory("","","","! $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); /no matching entry found/ && return(-1); # unknown cmd next if (/^! created( by)?: /i); next if (/^! on terminal: /i); next if (/^! defaults: /i); # # filter snmp community, when in snmp { stanza } # /^snmp/ && $snmp++; # /^}/ && ($snmp = 0); # if ($snmp && /^(\s*)(community|trap-group) [^ ;]+(\s?[;{])$/) { # if ($filter_commstr) { # $_ = "$1$2 \"\"$3\n"; # } # } # if (/(\s*authentication-key )[^ ;]+/ && $filter_pwds >= 1) { # ProcessHistory("","","","#$1$'"); # next; # } if (/(user (create|set) user \S+ access-level \S+ secret )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1\n"); next; } # if (/(\s*hello-authentication-key )[^ ;]+/ && $filter_pwds >= 1) { # ProcessHistory("","","","#$1$'"); # next; # } # # don't filter this one - there is no secret here. # if (/^\s*permissions .* secret /) { # ProcessHistory("","","","$_"); # next; # } # if (/^(.*\s(secret|simple-password) )[^ ;]+/ && $filter_pwds >= 1) { # ProcessHistory("","","","#$1$'"); # next; # } # if (/(\s+encrypted-password )[^ ;]+/ && $filter_pwds >= 2) { # ProcessHistory("","","","#$1$'"); # next; # } # if (/(\s+ssh-(rsa|dsa) )\"/ && $filter_pwds >= 2) { # ProcessHistory("","","","#$1;\n"); # next; # } # if (/^(\s+(pre-shared-|)key (ascii-text|hexadecimal) )[^ ;]+/ && $filter_pwds >= 1) { # ProcessHistory("","","","#$1$'"); # next; # } if (/^! END OF CONFIG:/) { $found_end = 1; } ProcessHistory("","","","$_"); } return(0); } 1; rancid-3.13/lib/sros.pm.in000644 015615 000000 00000034546 13713052202 015464 0ustar00heaswheel000000 000000 package sros; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # sros.pm - Nokia (Alcatel-Lucent) SR OS rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; our $proc; our $memoryseen; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { $proc = ""; $memoryseen = 0; # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: $devtype\n"); ProcessHistory("COMMENTS","keysort","A0","#\n"); # memory summary ProcessHistory("COMMENTS","keysort","B0","#\n"); # chassis summary ProcessHistory("COMMENTS","keysort","C0","#\n"); # show information ProcessHistory("COMMENTS","keysort","D0","#\n"); # show redundancy ProcessHistory("COMMENTS","keysort","E0","#\n"); # show chassis 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; CMD: if (/[#]\s?logout\s*$/) { $clean_run = 1; last; } if (/^Error:/ && !(/^Error: Invalid parameter\./ || /^Error: Bad command\./)) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/[#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^[*]?([^#>]+[#])/)[0]; $prompt =~ s/([][}{)(+*\\])/\\$1/g; $prompt = "[*]?$prompt"; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } # filter the modified-config indicator ("*") from the line. /^$prompt/ && s/^[*]//; $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } if (defined($prompt)) { if (/$prompt/) { goto CMD; } } } } } # This routine parses "file type bootlog.txt" sub BootLog { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In BootLog: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(-1) if (/error: invalid parameter/i); return(-1) if (/minor: cli command not allowed for this user/i); # if file doesn't exist, return 0 return(0) if (/minor: cli could not access file/i); if (/total memory:\s+(\S+)\s+chassis type:\s+(\S+)\s+card type:\s+(\S+)/i) { next if ($memoryseen++); ProcessHistory("COMMENTS","keysort","A1", "#Total memory: $1\n"); ProcessHistory("COMMENTS","keysort","B1", "#Chassis type: $2\n"); ProcessHistory("COMMENTS","keysort","B2", "#Card type: $3\n"); } /^chassis serial number is \'(.*)\'/i && ProcessHistory("COMMENTS","keysort","B1", "#Chassis serial number: $1\n") && next; } } # This routine parses "show bof" sub ShowBOF { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowBOF: $_" if ($debug); ProcessHistory("BOF","","","#\n# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(-1) if (/error: invalid parameter/i); return(-1) if (/minor: cli command not allowed for this user/i); # context lines /^\[]$/i && next; /^INFO: CLI #\d+: Switching to the .* engine/ && next; /show bof/i && next; /[-=]+$/i && next; ProcessHistory("BOF","","","# $_"); } } # This routine parses "show card detail" sub ShowCardDetail { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowCardDetail: $_" if ($debug); ProcessHistory("COMMENTS","keysort","E6","#\n# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(-1) if (/error: invalid parameter/i); return(-1) if (/minor: cli command not allowed for this user/i); # context lines /^\[]$/i && next; # humanize free space if (/^(\s+free space\s+:\s+)([0-9,]+\s+.*)/i) { my($preamble) = $1; my($space) = bytes2human(human2bytes($2)); ProcessHistory("COMMENTS","keysort","E6","# $preamble$space\n"); next; } # temp varies in "show card detail" next if (/^(\s+Temperature\s+:)\s+\d+C/); next if (/^(Config file|BOF) last (saved|modified)\s+:/ && ($filter_osc >= 2)); # power data if (/hardware resources .power-zone/i) { while (<$INPUT>) { tr/\015//d; last TOP if (/^$prompt/); last if (/(^\s*$|^=+)/); } } /[-=]+$/i && next; ProcessHistory("COMMENTS","keysort","E6","# $_"); } } # This routine parses "show card state" sub ShowCardState { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowCardState: $_" if ($debug); ProcessHistory("COMMENTS","keysort","E5","#\n# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(-1) if (/error: invalid parameter/i); return(-1) if (/minor: cli command not allowed for this user/i); # context lines /^\[]$/i && next; /[-=]+$/i && next; ProcessHistory("COMMENTS","keysort","E5","# $_"); } } # This routine parses "show chassis" sub ShowChassis { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassis: $_" if ($debug); ProcessHistory("COMMENTS","keysort","E1","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*$cmd\s*)$/); next if (/^\s+\^$/); return(-1) if (/error: invalid parameter/i); return(-1) if (/minor: cli command not allowed for this user/i); # context lines /^\[]$/i && next; /^$/i && next; # extra blank lines tr doesn't remove /[-=]+$/i && next; /^\s+type\s+:\s+(.*)/i && ProcessHistory("COMMENTS","keysort","E1","# $_") && next; /^\s+serial number\s+:\s+(.*)/i && ProcessHistory("COMMENTS","keysort","B1", "#Chassis serial number: $1\n") && ProcessHistory("COMMENTS","keysort","E1","# $_") && next; ProcessHistory("COMMENTS","keysort","E1","# $_"); } } # This routine parses "show chassis environment" sub ShowChassisEnv { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassisEnv: $_" if ($debug); ProcessHistory("COMMENTS","keysort","E2","#\n# $_"); TOP: while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(-1) if (/error: invalid parameter/i); return(-1) if (/minor: cli command not allowed for this user/i); # context lines /^\[]$/i && next; # power data if (/hardware resources .power-zone/i) { while (<$INPUT>) { tr/\015//d; last TOP if (/^$prompt/); last if (/(^\s*$|^=+)/); } } /speed/i && next; /[-=]+$/i && next; ProcessHistory("COMMENTS","keysort","E2","# $_"); } } # This routine parses "show chassis power-supply" sub ShowChassisPS { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassisPS: $_" if ($debug); ProcessHistory("COMMENTS","keysort","E3","#\n# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(0) if (/error: invalid parameter/i); # cmd for 7750 SR only /\^+/i && next; return(0) if (/minor: .* unknown element/i); # cmd for 7750 SR only return(-1) if (/minor: cli command not allowed for this user/i); # context lines /^\[]$/i && next; /[-=]+$/i && next; ProcessHistory("COMMENTS","keysort","E3","# $_"); } } # This routine parses "show chassis power-management" sub ShowChassisPM { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassisPM: $_" if ($debug); ProcessHistory("COMMENTS","keysort","E4","#\n# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(0) if (/error: invalid parameter/i); # cmd for 7950 XRS only /\^+/i && next; return(0) if (/minor: .* unknown element/i); # cmd for 7950 XRS only return(-1) if (/minor: cli command not allowed for this user/i); # context lines /^\[]$/i && next; /volts/i && next; /watts/i && next; /amps/i && next; /[-=]+$/i && next; ProcessHistory("COMMENTS","keysort","E4","# $_"); } } # This routine parses "show debug" sub ShowDebug { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowDebug: $_" if ($debug); ProcessHistory("","","","#\n# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(-1) if (/error: invalid parameter/i); return(-1) if (/minor: cli command not allowed for this user/i); # context lines /^\[]$/i && next; /^INFO: CLI #\d+: Switching to the .* engine/ && next; /show debug/i && next; ProcessHistory("","","","$_"); } } # This routine parses "show redundancy synchronization" sub ShowRedundancy { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowRedundancy: $_" if ($debug); ProcessHistory("COMMENTS","keysort","D2","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); # not on 7210 SAS, return 0 return(0) if (/error: invalid parameter/i); return(0) if (/minor: .* synchronization is only supported/i); return(-1) if (/minor: cli command not allowed for this user/i); # context lines /^\[]$/i && next; /[-=]+$/i && next; /standby up time/i && next; /last config file sync time/i && next; /last boot env sync time/i && next; /last rollback sync time/i && next; /last cert sync time/i && next; ProcessHistory("COMMENTS","keysort","D2","# $_"); } } # This routine parses "show system information" sub ShowSystemInfo { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSystemInfo: $_" if ($debug); $_ =~ s/ +/ /; ProcessHistory("COMMENTS","keysort","C1","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(-1) if (/error: invalid parameter/i); return(-1) if (/minor: cli command not allowed for this user/i); # context lines /^\[]$/i && next; /[-=]+$/i && next; /system up time/i && next; # User Last Modified : someuname # Time Last Modified : 2018/05/29 09:15:32 /(user|time) last modified/i && ($filter_osc >= 2) && next; # Changes Since Last Save: Yes /changes since last save/i && ($filter_osc >= 2) && next; /time last saved/i && ($filter_osc >= 2) && next; if (/system type\s+:\s+(.*)/i) { $proc = $1; ProcessHistory("COMMENTS","keysort","B4", "#System type: $proc\n"); } if (/system version\s+:\s+(.*)/i) { $proc = $1; ProcessHistory("COMMENTS","keysort","B5", "#System version: $proc\n"); } ProcessHistory("COMMENTS","keysort","C1","# $_"); } } # This routine parses "admin display-config index" sub WriteTermIndex { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTermIndex: $_" if ($debug); ProcessHistory("","","","#\n# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(-1) if (/error: invalid parameter/i); return(-1) if (/minor: cli command not allowed for this user/i); /# (timos-|all rights reserved|built on)/i && next; /# Generated /i && next; /^#-+$/i && next; s/echo \"(.*)\"/# $1/i; next if (/^# finished \S{3} \S{3} /i); ProcessHistory("","","","$_"); } } # This routine parses "admin display-config" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); ProcessHistory("","","","#\n# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(-1) if (/error: invalid parameter/i); return(-1) if (/minor: cli command not allowed for this user/i); /# (timos-|all rights reserved|built on)/i && next; /# Generated /i && next; /^#-+$/i && next; s/echo \"(.*)\"/# $1/i; # password/community filtering if (/^(\s+community) "[^"]*" /) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_", "#$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } if (/^(\s+trap-target\s+.*)\s+(notify-community)\s+("\S+")/) { if ($filter_commstr) { ProcessHistory("","","","#$1 $2 $'") && next; } else { ProcessHistory("","","","$_") && next; } } if (/^(\s+password)\s+("\$\S+")/) { if ($filter_pwds >= 2) { ProcessHistory("","","","#$1 $'") && next; } else { ProcessHistory("","","","$_") && next; } } # end of config. if (/^# finished \S{3} \S{3} /i) { $found_end = 1; return(0); } ProcessHistory("","","","$_"); } return(0); } # This routine parses "admin show configuration" in the MD-CLI sub WriteTermMD { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTermMD: $_" if ($debug); ProcessHistory("","","","#\n# $_"); my($linecnt) = 0; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(-1) if (/error: invalid parameter/i); return(-1) if (/minor: cli command not allowed for this user/i); /# (timos-|all rights reserved|built on)/i && next; /# Generated /i && next; /^#-+$/i && next; s/echo \"(.*)\"/# $1/i; $linecnt++; # password/community filtering if (/^(\s+community) "[^"]*" /) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","","", "#$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","","","$_") && next; } } if (/^(\s+trap-target\s+.*)\s+(notify-community)\s+("\S+")/) { if ($filter_commstr) { ProcessHistory("","","","#$1 $2 $'") && next; } else { ProcessHistory("","","","$_") && next; } } if (/^(\s+password)\s+("\$\S+")/) { if ($filter_pwds >= 2) { ProcessHistory("","","","#$1 $'") && next; } else { ProcessHistory("","","","$_") && next; } } # end of config. if ((/^(# finished \S{3} \S{3} |\[\]\s*$)/i) && $linecnt > 5) { $found_end = 1; return(0); } ProcessHistory("","","","$_"); } return(0); } 1; rancid-3.13/lib/fxos.pm.in000644 015615 000000 00000103275 13532047225 015461 0ustar00heaswheel000000 000000 package fxos; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # fxos.pm - Cisco FXOS rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; our $proc; our $type; # device model, from ShowVersion our $C0; # output formatting control our $E0; our $H0; our $I0; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { $proc = ""; $C0 = 0; # output formatting control $E0 = 0; $H0 = 0; $I0 = 0; # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","D0","!\n"); ProcessHistory("COMMENTS","keysort","F0","!\n"); ProcessHistory("COMMENTS","keysort","G0","!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/[>#]\s?exit$/) { $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { # the fxos prompt is weird, see comments in fxlogin $prompt = "^(\[^ >]*)(>|#)"; #$prompt = ($_ =~ /^([^#>]+[#>])/)[0]; #$prompt =~ s/([][}{)(+\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } } # This routine parses "show chassis" sub ShowChassis { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassis: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); # Ignore the PDP address and assigned DNS servers next if (/^pdp (ipv6 )?address/i); next if (/^\s*(primary|secondary) DNS (ipv6 )?address/i); ProcessHistory("COMMENTS","keysort","CHASSIS","! $_"); } ProcessHistory("COMMENTS","keysort","CHASSIS","!\n"); return(0); } # This routine parses "dir /all ((disk|slot)N|bootflash|nvram):" sub DirSlotN { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DirSlotN: $_" if ($debug); my($dev) = (/\s([^\s]+):/); ProcessHistory("COMMENTS","keysort","STORAGE","!\n"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(1) if (/(No such device|Error Sending Request)/i); return(1) if (/\%Error: No such file or directory/); return(1) if (/No space information available/); # Corrupt flash /\%Error calling getdents / && ProcessHistory("COMMENTS","keysort","STORAGE", "!Flash: $dev: $_") && next; return(-1) if (/\%Error calling/); return(-1) if (/(: device being squeezed|ATA_Status time out)/i); # busy return(-1) if (/\%Error opening \S+:\S+ \(Device or resource busy\)/i); return(-1) if (/command authorization failed/i); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); # 0 file(s) total size: 0 bytes /\d+ file.* total size: \d+/i && next; # filter frequently changing files (dhcp & vlan database) # change from: # 9 -rw- 660 Jan 15 2011 20:43:54 vlan.dat # 9 -rw- 660 Jan 15 2011 20:43:54 +00:00 vlan.dat # to: # -rw- vlan.dat # -rw- vlan.dat if (/(dhcp_[^. ]*\.txt|vlan\.dat|sflog|snooping|syslog|underlying-config)\s*$/) { if (/(\s*\d+)(\s+\S+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+ .\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s"; $_ = sprintf($fmt, "", $a, "", $c, "", $rem); } elsif (/(\s*\d+)(\s+\S+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s"; $_ = sprintf($fmt, "", $a, "", $c, "", $rem); } elsif (/(\s*\d+)(\s+\S+\s+)(\d+)(\s+)/i) { # 32771 -rw- 24520 underlying-config my($fn, $a, $sz, $dt, $rem) = ($1, $2, $3, $4, $'); my($fnl, $szl) = (length($fn), length($sz)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%s"; $_ = sprintf($fmt, "", $a, "", $dt, $rem); } } # filter frequently changing files of the config archive feature # change from: # 9 -rw- 660 Jan 15 2011 20:43:54 running-config-archive-Jul--1-16-50-27.123-113 # 9 -rw- 660 Jan 15 2011 20:43:54 +00:00 running-config-archive-Jul--1-16-50-27.123-113 # to: # -rw- running-config-archive-Jul--1-16-50-27.123-113 # -rw- running-config-archive-Jul--1-16-50-27.123-113 if (/(running-config-archive-)\S+\s*$/) { my($arc) = $1; if (/(\s*\d+)(\s+\S+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+ .\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s%s\n"; $_ = sprintf($fmt, "", $a, "", $c, "", $arc, ""); } elsif (/(\s*\d+)(\s+\S+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s%s\n"; $_ = sprintf($fmt, "", $a, "", $c, "", $arc, ""); } } if (/.*\((\d+) bytes free(\/\d+% free)?\)/) { my($tmp) = $1; if ($tmp >= (1024 * 1024 * 1024)) { $tmp = int($tmp / (1024 * 1024 * 1024)); s/$1 bytes free/$tmp GB free/; } elsif ($tmp >= (1024 * 1024)) { $tmp = int($tmp / (1024 * 1024)); s/$1 bytes free/$tmp MB free/; } elsif ($tmp >= (1024)) { $tmp = int($tmp / 1024); s/$1 bytes free/$tmp KB free/; } elsif ($tmp > 0) { s/$1 bytes free/< 1KB free/; } else { s/$1 bytes free/0 bytes free/; } s/\/\d+% free//; } # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } ProcessHistory("COMMENTS","keysort","STORAGE","!Flash: $dev: $_"); } ProcessHistory("COMMENTS","keysort","STORAGE","!\n"); return(0); } # This routine parses "show firmware" sub ShowFirmware { my($INPUT, $OUTPUT, $cmd) = @_; my($INT); print STDERR " In ShowFirmware: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","keysort","FIRMWARE","! $_"); } return(0); } # This routine parses "show inventory". sub ShowInventory { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInventory: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return if (/^\s*\^$/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/command authorization failed/i); # split PID/VID/SN line if (/^PID: (\S*)\s*,\s*VID: (\S*)\s*,\s*SN: (\S*)\s*$/) { my($pid,$vid,$sn) = ($1, $2, $3); my($entries) = ""; # filter , "0x" and "N/A" lines if ($pid !~ /^(|0x|N\/A)$/) { $entries .= "!PID: $pid\n"; } if ($vid !~ /^(|0x|N\/A)$/) { $entries .= "!VID: $vid\n"; } if ($sn !~ /^(|0x|N\/A)$/) { $entries .= "!SN: $sn\n"; } ProcessHistory("COMMENTS","keysort","INVENTORY", "$entries"); next; } ProcessHistory("COMMENTS","keysort","INVENTORY","!$_"); } ProcessHistory("COMMENTS","keysort","INVENTORY","!\n"); return(0); } # This routine parses "show managers". sub ShowManagers { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowManagers: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return if (/^\s*\^$/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","keysort","NETWORK","! $_"); } ProcessHistory("COMMENTS","keysort","NETWORK","!\n"); return(0); } # This routine parses "show mode". sub ShowMode { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowMode: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return if (/^\s*\^$/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","keysort","MODE","!MODE: $_"); } ProcessHistory("COMMENTS","keysort","MODE","!\n"); return(0); } # This routine parses "show model". sub ShowModel { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowModel: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return if (/^\s*\^$/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/command authorization failed/i); /(cisco.*)/i && ProcessHistory("COMMENTS","keysort","A1", "!Chassis type: $1\n") && next; ProcessHistory("COMMENTS","keysort","A5","!$_"); } ProcessHistory("COMMENTS","keysort","A9","!\n"); return(0); } # This routine parses "show network". sub ShowNetwork { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowNetwork: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return if (/^\s*\^$/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","keysort","NETWORK","!$_"); } ProcessHistory("COMMENTS","keysort","NETWORK","!\n"); return(0); } # This routine processes a "write term" for the FTD layer sub WriteTermFTD { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTermFTD: $_" if ($debug); my($comment, $linecnt, $ftd_end) = (0, 0, 0); while (<$INPUT>) { TOP: tr/\015//d; last if (/^$prompt/); return(1) if (!$linecnt && /^\s+\^\s*$/); next if (/^\s*$cmd\s*$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(1) if (/\%Error: No such file or directory/); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(0) if ($found_end); # Only do this routine once return(-1) if (/command authorization failed/i); return(-1) if (/% ?configuration buffer full/i); /^! no configuration change since last restart/i && next; # skip emtpy lines at the beginning if (!$linecnt && /^\s*$/) { next; } /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked /% Configuration buffer full, / && return(-1); # buffer is in use $linecnt++; # skip the crap /^:( written by \S+ at| saved| $|$)/i && next; /^ngfw version /i && next; # skip consecutive comment lines to avoid oscillating extra comment # line on some access servers. grrr. if (/^!\s*$/) { next if ($comment); ProcessHistory("COMMENTS","keysort","Z1",$_); $comment++; next; } $comment = 0; # why put h/w info in show chassis something or other when you could # put it in show running-config? # : Serial Number: JAD59721NNU # : Hardware: FPR-2110, 6842 MB RAM, CPU MIPS 1200 MHz, 1 CPU (6 cores) /^: ((serial number|hardware): .*)/i && ProcessHistory("COMMENTS","keysort","A1","!$1\n") && next; # Dog gone Cool matches to process the rest of the config /^tftp-server flash / && next; # kill any tftp remains /^ntp clock-period / && next; # kill ntp clock-period /^ clockrate / && next; # kill clockrate on serial interfaces # kill rx/txspeed (particularly on cellular modem cards) if (/^(line (\d+(\/\d+\/\d+)?|con|aux|vty))/) { my($key) = $1; my($lineauto) = (0); if ($key =~ /con/) { $key = -1; } elsif ($key =~ /aux/) { $key = -2; } elsif ($key =~ /vty/) { $key = -3; } ProcessHistory("COMMENTS","keysort","Z1","$_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); goto TOP if (! /^ /); next if (/\s*(rx|tx)speed \d+/); next if (/^ length /); # kill length on serial lines next if (/^ width /); # kill width on serial lines $lineauto = 0 if (/^[^ ]/); $lineauto = 1 if /^ modem auto/; /^ speed / && $lineauto && next; # kill speed on serial lines if (/^(\s+password) \d+ / && $filter_pwds >= 1) { $_ = "!$1 \n"; } ProcessHistory("COMMENTS","keysort","Z1","$_"); } } if (/^(enable )?(password|passwd)( level \d+)? / && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1$2$3 \n"); next; } if (/^(enable secret) / && $filter_pwds >= 2) { ProcessHistory("COMMENTS","keysort","Z1","!$1 \n"); next; } if (/^username (\S+)(\s.*)? secret /) { if ($filter_pwds >= 2) { ProcessHistory("COMMENTS","keysort","Z1", "!username $1$2 secret \n"); } else { ProcessHistory("COMMENTS","keysort","Z1","$_"); } next; } if (/^username (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds >= 2) { ProcessHistory("COMMENTS","keysort","Z1", "!username $1$2 password \n"); } elsif ($filter_pwds >= 1 && $4 ne "5"){ ProcessHistory("COMMENTS","keysort","Z1", "!username $1$2 password \n"); } else { ProcessHistory("COMMENTS","keysort","Z1", "$_"); } next; } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1password \n"); next; } if (/^(\s*)secret / && $filter_pwds >= 2) { ProcessHistory("COMMENTS","keysort","Z1","!$1secret \n"); next; } if (/^(ip ftp password) / && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 \n"); next; } if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 \n"); next; } if (/^\s+(domain-password|area-password) (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 $3\n"); next; } # this is reversable, despite 'md5' in the cmd if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 \n"); next; } # this is also reversable, despite 'md5 encrypted' in the cmd if (/^( message-digest-key \d+ md5 (7|encrypted)) / && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 \n"); next; } if (/^((crypto )?isakmp key) (\d )?\S+ / && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 $'"); next; } # filter HSRP passwords if (/^(\s+standby \d+ authentication) / && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 \n"); next; } # ASA/PIX keys in more system:running-config if (/^(( ikev2)? (local|remote)-authentication pre-shared-key ).*/ && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 $'"); next; } # ASA/PIX keys in more system:running-config if (/^(( ikev1)? pre-shared-key | key |failover key ).*/ && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 $'"); next; } # ASA/PIX keys in more system:running-config if (/(\s+ldap-login-password )\S+(.*)/ && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 $'"); next; } /fair-queue individual-limit/ && next; # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); if ($token eq '3') { $line .= " " . join(' ', ($token, shift(@tokens))); } } elsif ($token eq 'vrf') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("COMMENTS","keysort","Z1","$line\n"); } else { ProcessHistory("COMMENTS","keysort","Z1","$_"); } next; } # For ASA version 8.x and higher, the format changed a little. It is # 'snmp-server host {interface {hostname | ip_address}} [trap | poll] # [community 0 | 8 community-string] [version {1 | 2c | 3 username}] # [udp-port port] ' if (/^(snmp-server .*community) ([08] )?(\S+)/) { if ($filter_commstr) { ProcessHistory("COMMENTS","keysort","Z1", "!$1 $'") && next; } else { ProcessHistory("COMMENTS","keysort","Z1","$_") && next; } } # prune tacacs/radius server keys if (/^((tacacs|radius)-server\s(\w*[-\s(\s\S+])*\s?key) (\d )?\S+/ && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 $'"); next; } # delete ntp auth password - this md5 is a reversable too if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","Z1","!$1 \n"); next; } /^ *Cryptochecksum:/ && next; # catch anything that wasnt matched above. ProcessHistory("COMMENTS","keysort","Z1","$_"); # end of config. if (/^: +end$/) { $ftd_end = 1; return(0); } } # The ContentEngine lacks a definitive "end of config" marker. If we # know that it is a CE, SAN, or NXOS and we have seen at least 5 lines # of write term output, we can be reasonably sure that we have the config. if (! $ftd_end) { return(-1); } return(0); } # This routine processes a "write term" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($comment, $linecnt) = (0, 0); ProcessHistory("","","","!\n!\n"); while (<$INPUT>) { TOP: tr/\015//d; last if (/^$prompt/); return(1) if (!$linecnt && /^\s+\^\s*$/); next if (/^\s*$cmd\s*$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(1) if (/\%Error: No such file or directory/); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(0) if ($found_end); # Only do this routine once return(-1) if (/command authorization failed/i); return(-1) if (/% ?configuration buffer full/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } /^! no configuration change since last restart/i && next; # skip emtpy lines at the beginning if (!$linecnt && /^\s*$/) { next; } /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked /% Configuration buffer full, / && return(-1); # buffer is in use $linecnt++; # skip the crap if (/^(##+|(building|current) configuration)/i) { while (<$INPUT>) { next if (/^Current configuration\s*:/i); next if (/^:/); next if (/^([%!].*|\s*)$/); next if (/^ip add.*ipv4:/); # band-aid for 3620 12.0S last; } tr/\015//d; } # config timestamp on MDS/NX-OS /Time: / && next; # skip ASA 5520 configuration author line /^: written by /i && next; # 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 \S+ at|Saved)/ && next; # skip consecutive comment lines to avoid oscillating extra comment # line on some access servers. grrr. if (/^!\s*$/) { next if ($comment); ProcessHistory("","","",$_); $comment++; next; } $comment = 0; # Dog gone Cool matches to process the rest of the config /^tftp-server flash / && next; # kill any tftp remains /^ntp clock-period / && next; # kill ntp clock-period /^ clockrate / && next; # kill clockrate on serial interfaces # kill rx/txspeed (particularly on cellular modem cards) if (/^(line (\d+(\/\d+\/\d+)?|con|aux|vty))/) { my($key) = $1; my($lineauto) = (0); if ($key =~ /con/) { $key = -1; } elsif ($key =~ /aux/) { $key = -2; } elsif ($key =~ /vty/) { $key = -3; } ProcessHistory("LINE","keysort","$key","$_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); goto TOP if (! /^ /); next if (/\s*(rx|tx)speed \d+/); next if (/^ length /); # kill length on serial lines next if (/^ width /); # kill width on serial lines $lineauto = 0 if (/^[^ ]/); $lineauto = 1 if /^ modem auto/; /^ speed / && $lineauto && next; # kill speed on serial lines if (/^(\s+password) \d+ / && $filter_pwds >= 1) { $_ = "!$1 \n"; } ProcessHistory("LINE","keysort","$key","$_"); } } if (/^(enable )?(password|passwd)( level \d+)? / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1$2$3 \n"); next; } if (/^(enable secret) / && $filter_pwds >= 2) { ProcessHistory("ENABLE","","","!$1 \n"); next; } if (/^username (\S+)(\s.*)? secret /) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 secret \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^username (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } elsif ($filter_pwds >= 1 && $4 ne "5"){ ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } # cisco AP w/ IOS if (/^(wlccp \S+ username (\S+)(\s.*)? password) (\d \S+|\S+)/) { if ($filter_pwds >= 1) { ProcessHistory("USER","keysort","$2","!$1 \n"); } else { ProcessHistory("USER","keysort","$2","$_"); } next; } # filter auto "rogue ap" configuration lines /^rogue ap classify / && next; if (/^( set session-key (in|out)bound ah \d+ )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1\n"); next; } if (/^( set session-key (in|out)bound esp \d+ (authenticator|cypher) )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1\n"); next; } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","","!$1password \n"); next; } if (/^(\s*)secret / && $filter_pwds >= 2) { ProcessHistory("LINE-PASS","","","!$1secret \n"); next; } if (/^\s*(.*?neighbor.*?) (\S*) password / && $filter_pwds >= 1) { ProcessHistory("","","","! $1 $2 password \n"); next; } if (/^(\s*ppp .* hostname) .*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^(\s*ppp .* password) \d .*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^(ip ftp password) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # isis passwords appear to be completely plain-text if (/^\s+isis password (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!isis password $2\n"); next; } if (/^\s+(domain-password|area-password) (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $3\n"); next; } # this is reversable, despite 'md5' in the cmd if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # this is also reversable, despite 'md5 encrypted' in the cmd if (/^( message-digest-key \d+ md5 (7|encrypted)) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^((crypto )?isakmp key) (\d )?\S+ / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # filter HSRP passwords if (/^(\s+standby \d+ authentication) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # this appears in "measurement/sla" images if (/^(\s+key-string \d?)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^( l2tp tunnel \S+ password)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # l2tp-class secret if (/^( digest secret 7?)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # i am told these are plain-text on the PIX if (/^(vpdn username (\S+) password)/) { if ($filter_pwds >= 1) { ProcessHistory("USER","keysort","$2","!$1 \n"); } else { ProcessHistory("USER","keysort","$2","$_"); } next; } # ASA/PIX keys in more system:running-config if (/^(( ikev2)? (local|remote)-authentication pre-shared-key ).*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # ASA/PIX keys in more system:running-config if (/^(( ikev1)? pre-shared-key | key |failover key ).*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # ASA/PIX keys in more system:running-config if (/(\s+ldap-login-password )\S+(.*)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # filter WPA password such as on cisco 877W ISR if (/^\s+(wpa-psk ascii|hex \d) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # if (/^( cable shared-secret )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } /fair-queue individual-limit/ && next; # sort ip explicit-paths. if (/^ip explicit-path name (\S+)/) { my($key) = $1; my($expath) = $_; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); last if (/^$prompt/ || ! /^(ip explicit-path name |[ !])/); if (/^ip explicit-path name (\S+)/) { ProcessHistory("EXPATH","keysort","$key","$expath"); $key = $1; $expath = $_; } else { $expath .= $_; } } ProcessHistory("EXPATH","keysort","$key","$expath"); } # sort route-maps if (/^route-map (\S+)/) { my($key) = $1; my($routemap) = $_; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || ! /^(route-map |[ !])/); if (/^route-map (\S+)/) { ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); $key = $1; $routemap = $_; } else { $routemap .= $_; } } ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); } # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order access-lists /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order extended access-lists if ($aclfilterseq) { /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+host\s+(\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$4","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+(\d\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$4","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+any/ && ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; } if ($aclfilterseq) { /^ip(v6)? prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\S+)(.*)/ && ProcessHistory("PACL $2 $4","$aclsort","$5", "ip$1 prefix-list $2 $4 $5$6\n") && next; } # sort ipv{4,6} access-lists if ($aclfilterseq && /^ipv(4|6) access-list (\S+)\s*$/) { my($nlri, $key) = ($1, $2); my($seq, $cmd); ProcessHistory("ACL $nlri $key","","","$_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || /^\S/); # ipv4 access-list name # remark NTP # deny ipv4 host 224.0.1.1 any # deny ipv4 239.0.0.0 0.255.255.255 any # permit udp any eq 123 any # permit ipv4 nnn.nnn.nnn.nnn/nn any # permit nnn.nnn.nnn.nnn/nn # ipv6 access-list name # permit ipv6 host 2001:nnnn::nnnn any # permit ipv6 2001:nnn::/nnn any # permit 2001:nnnn::/64 any # permit udp any eq 123 any # # line might begin with " sequence nnn permit ..." s/^\s+(sequence (\d+)) / /; my($seq) = $1; my($cmd, $resid) = ($_ =~ /^\s+(\w+) (.+)/); if ($cmd =~ /(permit|deny)/) { my($ip); my(@w) = ($resid =~ /(\S+) (\S+) (\S+\s)?(.+)/); for (my($i) = 0; $i < $#w; $i++) { if ($w[$i] eq "any") { if ($nlri eq "ipv4") { $ip = "255.255.255.255/32"; } else { $ip = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128"; } last; } elsif ($w[$i] =~ /^[:0-9]/ || $2[$i] =~ /^[a-fA-F]{1,4}:/) { $ip = $w[$i]; $ip =~ s/\s+$//; # trim trailing WS last; } } ProcessHistory("ACL $nlri $key $cmd", "$aclsort", "$ip", " $cmd $resid\n"); } else { ProcessHistory("ACL $nlri $key $cmd", "", "", " $cmd $resid\n"); } } } # order arp lists /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ && ProcessHistory("ARP","$aclsort","$1","$_") && next; # order logging statements /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); if ($token eq '3') { $line .= " " . join(' ', ($token, shift(@tokens))); } } elsif ($token eq 'vrf') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } # For ASA version 8.x and higher, the format changed a little. It is # 'snmp-server host {interface {hostname | ip_address}} [trap | poll] # [community 0 | 8 community-string] [version {1 | 2c | 3 username}] # [udp-port port] ' if (/^(snmp-server .*community) ([08] )?(\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_", "!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # prune tacacs/radius server keys if (/^((tacacs|radius)-server\s(\w*[-\s(\s\S+])*\s?key) (\d )?\S+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # order clns host statements /^clns host \S+ (\S+)/ && ProcessHistory("CLNS","keysort","$1","$_") && next; # order alias statements /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next; # delete ntp auth password - this md5 is a reversable too if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { my($sortkey) = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # order ip host statements /^ip host (\S+) / && ProcessHistory("IPHOST","keysort","$1","$_") && next; # order ip nat source static statements /^ip nat (\S+) source static (\S+)/ && ProcessHistory("IP NAT $1","ipsort","$2","$_") && next; # system controller /^syscon address (\S*) (\S*)/ && ProcessHistory("","","","!syscon address $1 \n") && next; if (/^syscon password (\S*)/ && $filter_pwds >= 1) { ProcessHistory("","","","!syscon password \n"); next; } /^ *Cryptochecksum:/ && next; # catch anything that wasnt matched above. ProcessHistory("","","","$_"); # end of config. the ": " game is for the PIX if (/^(: +)?end$/) { $found_end = 1; return(0); } } # The ContentEngine lacks a definitive "end of config" marker. If we # know that it is a CE, SAN, or NXOS and we have seen at least 5 lines # of write term output, we can be reasonably sure that we have the config. if ($linecnt > 5) { $found_end = 1; return(0); } return(0); } 1; rancid-3.13/lib/vrp.pm.in000644 015615 000000 00000035411 13532047066 015310 0ustar00heaswheel000000 000000 package vrp; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # vrp.pm - Hauwei VRP rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; our $C0; # output formatting control our $E0; our $H0; our $I0; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { $C0 = 0; # output formatting control $E0 = 0; $H0 = 0; $I0 = 0; # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: $devtype\n#\n"); ProcessHistory("COMMENTS","keysort","B0","#\n"); ProcessHistory("COMMENTS","keysort","C0","#\n"); ProcessHistory("COMMENTS","keysort","D0","#\n"); ProcessHistory("COMMENTS","keysort","E0","#\n"); ProcessHistory("COMMENTS","keysort","E2","#\n"); ProcessHistory("COMMENTS","keysort","F0","#\n"); ProcessHistory("COMMENTS","keysort","G0","#\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/>\s?quit$/) { $clean_run = 1; last; } # due to errors from commands in xilogin XXX next if (/^error: (file can.t be found.|unrecognized command)/i); if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^>]+>)/)[0]; $prompt =~ s/([][}{)(+\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } } # This routine parses "display version" sub DispVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DispVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if (/^(\s*|\s*$cmd\s*)$/); last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/((invalid|unrecognized) (input|command) detected|type help or )/i); return(-1) if (/failed to pass the authorization/i); next if (/^\s*VRP(\s\S+)?\s*software\s*,\s*version/i); next if (/^\s*huawei versatile routing platform software/i); next if (/^\s*copyright .*/i); s/\s+uptime\s.*//; /^huawei\s(.*)/i && ProcessHistory("COMMENTS","keysort","A1", "#Chassis type: $1\n") && next; if (/^DDR\s*Memory\s*Size\s*:\s(.*)/i) { $_ = $1; s/ */ /g; ProcessHistory("COMMENTS","keysort","B1", "#Memory: $_\n") && next; } /^software\s*version\s*:\s(.*)/i && ProcessHistory("COMMENTS","keysort","D1", "#Image: $1\n"); ProcessHistory("COMMENTS","keysort","E3", "#$_"); } return(0); } # This routine parses "display startup" sub DispStartup { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DispStartup: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if (/^(\s*|\s*$cmd\s*)$/); last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/((invalid|unrecognized) (input|command) detected|type help or )/i); return(-1) if (/failed to pass the authorization/i); ProcessHistory("COMMENTS","keysort","D2", "#$_") && next; } return(0); } # This routine parses "display device" sub DispDevice { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DispDevice: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if (/^(\s*|\s*$cmd\s*)$/); last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/((invalid|unrecognized) (input|command) detected|type help or )/i); return(-1) if (/failed to pass the authorization/i); /device status:/i && next; ProcessHistory("COMMENTS","keysort","F1", "#$_") && next; } return(0); } # This routine parses "display device manufacture-info" sub DispDeviceMfg { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DispDevice: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if (/^(\s*|\s*$cmd\s*)$/); last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/((invalid|unrecognized) (input|command) detected|type help or )/i); return(-1) if (/failed to pass the authorization/i); ProcessHistory("COMMENTS","keysort","E1", "#$_") && next; } return(0); } # This routine parses "display transceiver verbose" sub DispTransciever { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DispTransciever: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if (/^(\s*|\s*$cmd\s*)$/); last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/((invalid|unrecognized) (input|command) detected|type help or )/i); return(-1) if (/failed to pass the authorization/i); /^$/i && next; /valid only on \S+ interface/i && next; /^(common|manufacture) information/i && next; /^----*/i && next; /^diagnostic information/i && last; ProcessHistory("COMMENTS","keysort","G1", "#$_") && next; } return(0); } # This routine parses "dir /all /all-filesystems" sub DirSlotN { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DirSlotN: $_" if ($debug); ProcessHistory("FLASH","","", "#\n"); while (<$INPUT>) { tr/\015//d; next if (/^(\s*|\s*$cmd\s*)$/); last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/((invalid|unrecognized) (input|command) detected|type help or )/i); return(-1) if (/failed to pass the authorization/i); return(1) if (/(wrong device|no such device|error sending request)/i); return(1) if (/\%Error: No such file or directory/); return(1) if (/No space information available/); return(-1) if (/\%Error calling/); return(-1) if (/\%error opening \S+:\S+ \(device or resource busy\)/i); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); # filter frequently changing files/dirs # change from: # 8 drw- - Mar 24 2018 05:46:04 logfile # to: # drw- logfile if (/(logfile|vrpcfg.zip)\s*$/) { if (/(\s*\d+)(\s+\S+\s+)([\d,]+|-)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+ )/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s"; $_ = sprintf($fmt, "", $a, "", $c, "", $rem); } } else { # drop the file number if (/(\s*\d+)(\s+\S+\s+([\d,]+|-)\s+\w+ \d+\s+\d+ \d+:\d+:\d+ .*)/) { my($fn, $rem) = ($1, $2); my($fnl) = length($fn); my($fmt) = "%-". $fnl ."s%s\n"; $_ = sprintf($fmt, "", $rem); } } # summarize the total/free line if (/^\s*([\d,]+ \S+)\s+total\s+\(([\d,]+ \S+) free\)/i) { my($sz, $mp) = ($1, $2); $_ = diskszsummary($sz, $mp, undef) . "\n"; } ProcessHistory("FLASH","","","#Flash: $_"); } ProcessHistory("","","","#\n"); return(0); } # This routine parses "display debug" sub DispDebug { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DispDebug: $_" if ($debug); my($lines) = 0; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/((invalid|unrecognized) (input|command) detected|type help or )/i); return(-1) if (/failed to pass the authorization/i); ProcessHistory("COMMENTS","keysort","J1","#DEBUG: $_"); $lines++; } if ($lines) { ProcessHistory("COMMENTS","keysort","J0","#\n"); } return(0); } # This routine processes a "display current-configuration" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($linecnt) = 0; while (<$INPUT>) { TOP: tr/\015//d; last if (/^$prompt/); return(1) if (!$linecnt && /^\s+\^\s*$/); next if (/^\s*$cmd\s*$/); next if (/^\s+\^\s*$/); return(1) if (/((invalid|unrecognized) (input|command) detected|type help or )/i); return(-1) if (/failed to pass the authorization/i); return(1) if (/\%Error: No such file or directory/); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(0) if ($found_end); # Only do this routine once # skip emtpy lines at the beginning if (!$linecnt && /^\s*$/) { next; } $linecnt++; # skip the crap /^!\s*software version/i && next; # Dog gone Cool matches to process the rest of the config if (/^ local-user (\S+)(\s.*)? cipher (\S+)/) { if ($filter_pwds >= 1) { ProcessHistory("USER","keysort","$1", "#local-user $1$2 cipher \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^ local-user (\S+)(\s.*)? irreversible-cipher (\S+)/) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "#local-user $1$2 irreversible-cipher \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } /^ local-user (\S+)(\s.*)? / && ProcessHistory("USER","keysort","$1", "$_") && next; # bgp neighbor passwords if (/^(\s+peer \S* password simple)/ && $filter_pwds >= 1) { ProcessHistory("","","","# $1 \n"); next; } if (/^(\s+peer \S* password cipher)/ && $filter_pwds >= 2) { ProcessHistory("","","","# $1 \n"); next; } # XXX how is bgp policy configured on VRP? # # sort route-maps # if (/^route-map (\S+)/) { # my($key) = $1; # my($routemap) = $_; # while (<$INPUT>) { # tr/\015//d; # last if (/^$prompt/ || ! /^(route-map |[ !])/); # if (/^route-map (\S+)/) { # ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); # $key = $1; # $routemap = $_; # } else { # $routemap .= $_; # } # } # ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); # } # XXX how are access-lists configured on VRP? # # order access-lists # /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && # ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # # order extended access-lists # if ($aclfilterseq) { # /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+host\s+(\S+)/ && # ProcessHistory("EACL $1 $2","$aclsort","$4","$_") && next; # /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+(\d\S+)/ && # ProcessHistory("EACL $1 $2","$aclsort","$4","$_") && next; # /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+any/ && # ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; # } # if ($aclfilterseq) { # /^ip(v6)? prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\S+)(.*)/ # && ProcessHistory("PACL $2 $4","$aclsort","$5", # "ip$1 prefix-list $2 $4 $5$6\n") # && next; # } # # sort ipv{4,6} access-lists # if ($aclfilterseq && /^ipv(4|6) access-list (\S+)\s*$/) { # my($nlri, $key) = ($1, $2); # my($seq, $cmd); # ProcessHistory("ACL $nlri $key","","","$_"); # while (<$INPUT>) { # tr/\015//d; # last if (/^$prompt/ || /^\S/); # # ipv4 access-list name # # remark NTP # # deny ipv4 host 224.0.1.1 any # # deny ipv4 239.0.0.0 0.255.255.255 any # # permit udp any eq 123 any # # permit ipv4 nnn.nnn.nnn.nnn/nn any # # permit nnn.nnn.nnn.nnn/nn # # ipv6 access-list name # # permit ipv6 host 2001:nnnn::nnnn any # # permit ipv6 2001:nnn::/nnn any # # permit 2001:nnnn::/64 any # # permit udp any eq 123 any # # # # line might begin with " sequence nnn permit ..." # s/^\s+(sequence (\d+)) / /; # my($seq) = $1; # my($cmd, $resid) = ($_ =~ /^\s+(\w+) (.+)/); # if ($cmd =~ /(permit|deny)/) { # my($ip); # my(@w) = ($resid =~ /(\S+) (\S+) (\S+\s)?(.+)/); # for (my($i) = 0; $i < $#w; $i++) { # if ($w[$i] eq "any") { # if ($nlri eq "ipv4") { # $ip = "255.255.255.255/32"; # } else { # $ip = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128"; # } # last; # } elsif ($w[$i] =~ /^[:0-9]/ || # $2[$i] =~ /^[a-fA-F]{1,4}:/) { # $ip = $w[$i]; # $ip =~ s/\s+$//; # trim trailing WS # last; # } # } # ProcessHistory("ACL $nlri $key $cmd", "$aclsort", "$ip", # " $cmd $resid\n"); # } else { # ProcessHistory("ACL $nlri $key $cmd", "", "", # " $cmd $resid\n"); # } # } # } # XXX how are static ARPs configured on VRP? # # order arp lists # /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ && # ProcessHistory("ARP","$aclsort","$1","$_") && next; # XXX how is logging configured on VRP? # # order logging statements # /^logging (\d+\.\d+\.\d+\.\d+)/ && # ProcessHistory("LOGGING","ipsort","$1","$_") && next; # XXX how is snmp configured on VRP? # # order/prune snmp-server host statements # # we only prune lines of the form # # snmp-server host a.b.c.d # if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { # if ($filter_commstr) { # my($ip) = $1; # my($line) = "snmp-server host $ip"; # my(@tokens) = split(' ', $'); # my($token); # while ($token = shift(@tokens)) { # if ($token eq 'version') { # $line .= " " . join(' ', ($token, shift(@tokens))); # if ($token eq '3') { # $line .= " " . join(' ', ($token, shift(@tokens))); # } # } elsif ($token eq 'vrf') { # $line .= " " . join(' ', ($token, shift(@tokens))); # } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { # $line .= " " . $token; # } else { # $line = "#$line " . join(' ', ("", # join(' ',@tokens))); # last; # } # } # ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); # } else { # ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); # } # next; # } # XXX how are tacacs/radius snmp configured on VRP? # # prune tacacs/radius server keys # if (/^((tacacs|radius)-server\s(\w*[-\s(\s\S+])*\s?key) (\d )?\S+/ # && $filter_pwds >= 1) { # ProcessHistory("","","","#$1 $'"); next; # } # XXX how are static clns hosts configured on VRP? # # order clns host statements # /^clns host \S+ (\S+)/ && # ProcessHistory("CLNS","keysort","$1","$_") && next; # XXX how is ntp configured on VRP? # # delete ntp auth password - this md5 is a reversable too # if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { # ProcessHistory("","","","#$1 \n"); next; # } # # order ntp peers/servers # if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { # my($sortkey) = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); # ProcessHistory("NTP","keysort",$sortkey,"$_"); # next; # } # XXX can static hosts be configured? # # order ip host statements # /^ip host (\S+) / && # ProcessHistory("IPHOST","keysort","$1","$_") && next; # catch anything that wasnt matched above. ProcessHistory("","","","$_"); # end of config. the ": " game is for the PIX if (/^return$/) { $found_end = 1; return(0); } } return(0); } 1; rancid-3.13/lib/iosxr.pm.in000644 015615 000000 00000134557 13735654705 015671 0ustar00heaswheel000000 000000 package iosxr; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # iosxr.pm - Cisco IOS-XR rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; our $proc; our $found_env; our $found_diag; our $found_version; our $config_register; # configuration register value our $type; # device model, from ShowVersion our $C0; # output formatting control our $E0; our $H0; our $I0; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { $proc = ""; $found_env = 0; $found_diag = 0; $found_version = 0; $config_register = undef; # configuration register value # XXX $type = undef; # device model, from ShowVersion $C0 = 0; # output formatting control $E0 = 0; $H0 = 0; $I0 = 0; # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","D0","!\n"); ProcessHistory("COMMENTS","keysort","F0","!\n"); ProcessHistory("COMMENTS","keysort","G0","!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; CMD: if (/[>#]\s?exit$/) { $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(+\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } if (defined($prompt)) { if (/$prompt/) { goto CMD; } } } } } # This routine parses "admin show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; my($slave, $slaveslot); print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; if (/^$prompt/) { $found_version = 1; last}; next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); next if (/^(\e\[.\d+h)?sysadmin-vm:[^#]+# /i); # NCS return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(0) if ($found_version); # Only do this routine once return(-1) if (/command authorization failed/i); if (/^Slave in slot (\d+) is running/) { $slave = " Slave:"; $slaveslot = ", slot $1"; next; } /^(Cisco )?IOS .* Software,? \(([A-Za-z0-9_-]*)\), .*Version\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","F1", "!Image:$slave Software: $2, $3\n") && next; /^([A-Za-z-0-9_]*) Synced to mainline version: (.*)$/ && ProcessHistory("COMMENTS","keysort","F2", "!Image:$slave $1 Synced to mainline version: $2\n") && next; /^Compiled (.*)$/ && ProcessHistory("COMMENTS","keysort","F3", "!Image:$slave Compiled: $1\n") && next; /^ROM: (IOS \S+ )?(System )?Bootstrap.*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G1", "!ROM Bootstrap: $3\n") && next; /^Serial Number:\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","C1", "!$_") && next; /^Activation Key:\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","C2", "!$_") && next; /^ROM: \d+ Bootstrap .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G2", "!ROM Image: Bootstrap $1\n!\n") && next; /^ROM: .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G3","!ROM Image: $1\n") && next; /^BOOTFLASH: .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G4","!BOOTFLASH: $1\n") && next; /^BOOTLDR: .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G4","!BOOTLDR: $1\n") && next; /^System image file is "([^\"]*)", booted via (\S*)/ && # removed the booted source due to # CSCdk28131: cycling info in 'sh ver' # ProcessHistory("COMMENTS","keysort","F4","!Image: booted via $2, $1\n") && ProcessHistory("COMMENTS","keysort","F4","!Image: booted $1\n") && next; /^System image file is "([^\"]*)"$/ && ProcessHistory("COMMENTS","keysort","F5","!Image: $1\n") && next; if (/(\S+(?:\sseries)?)\s+(?:\(([^)]+)\)\s+processor|\(revision[^)]+\)).*\s+with (\S+k) bytes/i) { $proc = $1; my($cpu) = $2; my($mem) = $3; my($device) = "router"; # the next line ought to be the more specific cpu info, grab it. # yet, some boards/IOS vers have a processor ID line between these # two. grrr. make sure we dont grab the "software" junk that # follows these lines by looking for "CPU at " or the 2600s # "processor: " unique string. there are undoubtedly many other # incantations. for a slave, we dont get this info, its just a # blank line. $_ = <$INPUT>; 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; if ($_ !~ /^\s*$/) { chomp; s/^/, /; } if ($proc =~ /1200[48]\/(GRP|PRP)/ || $proc =~ /1201[26]\/(GRP|PRP)/) { $type = "12000"; } elsif ($proc =~ /1201[26]-8R\/(GRP|PRP)/) { $type = "12000"; } elsif ($proc =~ /1240[48]\/(GRP|PRP)/ || $proc =~ /1241[06]\/(GRP|PRP)/) { $type = "12400"; } elsif ($proc =~ /ASR9K/) { $_ = <$INPUT>; $type = $proc; if (/(ASR\S+)\s+(\SC)\s+Chassis/) { $proc = $1; } elsif (/(ASR\S+)\s+Chassis/) { $proc = $1; } elsif (/(ASR)\s+(9\d+)\s+.*\s+Chassis with/) { tr/\015//d; chomp; $proc = $_; } elsif (/(ASR)\s+(9\S+)\s+(\SC)\s+Chassis/) { $proc = "ASR-". $2; } elsif (/(ASR)\s+(9\S+)\s+Chassis/) { $proc = "ASR-". $2; } elsif (/(ASR\s+9922)/) { $proc = "ASR-9922"; } $_ = ""; } else { $type = $proc; } print STDERR "TYPE = $type\n" if ($debug); ProcessHistory("COMMENTS","keysort","A1", "!Chassis type:$slave $proc - a $type $device\n"); ProcessHistory("COMMENTS","keysort","B1", "!Memory:$slave main $mem\n"); if (defined($cpu)) { ProcessHistory("COMMENTS","keysort","A3", "!CPU:$slave $cpu$_$slaveslot\n"); } next; } elsif (/^cisco (\S+(?:\sseries)?)\s+(?:\(([^)]*)\)\s+processor)/i) { $proc = $1; my($cpu) = $2; my($device) = "router"; print STDERR "TYPE = $type\n" if ($debug); ProcessHistory("COMMENTS","keysort","A1", "!Chassis type: $proc - a $proc $device\n"); if (defined($cpu) && length($cpu)) { ProcessHistory("COMMENTS","keysort","A3", "!CPU:$cpu\n"); } } /^(\d+[kK]) bytes of (non-volatile|NVRAM)/ && ProcessHistory("COMMENTS","keysort","B3", "!Memory: nvram $1\n") && next; /^(\d+[kK]) bytes of flash memory/ && ProcessHistory("COMMENTS","keysort","B5","!Memory: flash $1\n") && next; /^(\d+[kK]) bytes of .*flash partition/ && ProcessHistory("COMMENTS","keysort","B6", "!Memory: flash partition $1\n") && next; /^(\d+[kK]) bytes of Flash internal/ && ProcessHistory("COMMENTS","keysort","B4", "!Memory: bootflash $1\n") && next; if (/^(\d+[kK]) bytes of (Flash|ATA)?.*PCMCIA .*(slot|disk) ?(\d)/i) { ProcessHistory("COMMENTS","keysort","B7", "!Memory: pcmcia $2 $3$4 $1\n"); next; } if (/^(\d+[kK]) bytes of (slot|disk)(\d)/i) { ProcessHistory("COMMENTS","keysort","B7", "!Memory: pcmcia $2$3 $1\n"); next; } if (/^WARNING/) { if (!defined($I0)) { $I0 = 1; ProcessHistory("COMMENTS","keysort","I0","!\n"); } ProcessHistory("COMMENTS","keysort","I1","! $_"); } if (/^Configuration register is (.*)$/) { $config_register = $1; next; } if (/^Configuration register on node \S+ is (.*)$/) { $config_register = $1 if (length($config_register) < 1); next; } } return(0); } # This routine parses "admin show diag". sub AdminShowDiag { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In AdminShowDiag: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); next if (/^(\e\[.\d+h)?sysadmin-vm:[^#]+# /i); # NCS return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(-1) if (/command authorization failed/i); # skip blank lines /^$/ && next; # NCS junk next if (/^\S+ connected from 127.0.0.1 using console /); next if (/# terminal length 0$/); s/^NODE //; # wtf are these? next if (/(New Deviation|UDI_VID|Board State)/); # skip insertion time next if (/insertion time/i); # skip board h/w revision junk next if (/^(\s{2}board |\s{3,})/i); ProcessHistory("SLOT","","","!$_"); } ProcessHistory("SLOT","","","!\n"); return(0); } # This routine parses "admin show running". sub AdminShowRunning { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowRunning: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); next if (/^(\e\[.\d+h)?sysadmin-vm:[^#]+# /i); # NCS return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(-1) if (/command authorization failed/i); # skip blank lines /^$/ && next; # NCS junk next if (/^\S+ connected from 127.0.0.1 using console /); next if (/# terminal length 0$/); /^building configuration/i && next; if (/^(\s*secret) / && $filter_pwds >= 2) { ProcessHistory("ASR","","","!$1 \n"); next; } ProcessHistory("ASR","","","!$_"); /^end$/ && last; } ProcessHistory("ASR","","","!\n"); return(0); } # This routine parses "show diag". sub ShowDiag { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowDiag: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); next if (/^(\e\[.\d+h)?sysadmin-vm:[^#]+# /i); # NCS return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(-1) if (/command authorization failed/i); # skip blank lines /^$/ && next; # NCS junk next if (/^\S+ connected from 127.0.0.1 using console /); next if (/# terminal length 0$/); s/^NODE //; # wtf are these? next if (/(New Deviation|UDI_VID|Board State)/); ProcessHistory("SLOT","","","!$_"); } ProcessHistory("SLOT","","","!\n"); return(0); } # This routine parses "admin show hw-module fpd location all" and # "show hw-module fpd" (eXR/eXR-lite). sub ShowHWfpd { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowRunning: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); next if (/^(\e\[.\d+h)?sysadmin-vm:[^#]+# /i); # NCS return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(-1) if (/command authorization failed/i); # skip blank lines /^$/ && next; # NCS junk next if (/^\S+ connected from 127.0.0.1 using console /); next if (/# terminal length 0$/); /^notes:/i && last; # remove trailing WS s/\s+$/\n/; ProcessHistory("FPD","","","!$_"); } ProcessHistory("FPD","","","!\n"); return(0); } # This routine parses "show redundancy" sub ShowRedundancy { my($INPUT, $OUTPUT, $cmd) = @_; my($slave, $slaveslot); print STDERR " In ShowRedundancy: $_" if ($debug); TOP: while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); next if (/^(\e\[.\d+h)?sysadmin-vm:[^#]+# /i); # NCS return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS # filter reload/boot info if (/^reload and boot info/i) { while (<$INPUT>) { tr/\015//d; last TOP if (/^$prompt/); last if (/^\s*$/); } } ProcessHistory("COMMENTS","keysort","F3", "!$_"); } ProcessHistory("COMMENTS","keysort","F3", "!\n"); return(0); } # This routine parses "show install active" sub ShowInstallActive { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInstallActive: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/^\s*\^\s*$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(-1) if (/command authorization failed/i); return(-1) if (/install director is not up or ready/i);# temp error return(-1) if (/failed to output install information /i);# temp error # FPD upgrade in progress on some hardware, reload/configuration change # on those is not recommended as it might cause HW programming failure # and result in RMA of the hardware. # FPD upgrade has ended. next if (/fpd upgrade has ended/i || /fpd upgrade in progress /i || /might cause hw programming failure/i || /result in rma of the hardware/i); # useless FPD messages ProcessHistory("COMMENTS","keysort","F5","!Image: $_") && next; } ProcessHistory("COMMENTS","keysort","F5","!\n"); return(0); } # This routine parses "show memory summary" sub ShowMemorySum { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowMemorySum: $_" if ($debug); # RP/0/RSP0/CPU0:r00.lab#show memory summary # # node: node0_RSP0_CPU0 # ------------------------------------------------------------------ # # Physical Memory: 27426M total (22146M available) # Application Memory : 27426M (21819M available) # Image: 4M (bootram: 0M) # Reserved: 0M, IOMem: 0M, flashfsys: 0M # Total shared window: 140M while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); return(-1) if (/command authorization failed/i); /physical memory:\s+(\d+[GMKB])\s+total/i && ProcessHistory("COMMENTS","keysort","B1", "!Memory: main $1\n") && next; } return(0); } # This routine parses "admin show env all" sub ShowEnv { my($INPUT, $OUTPUT, $cmd) = @_; # Skip if this is not a 7500, 7200, or 7000. print STDERR " In ShowEnv: $_" if ($debug); while (<$INPUT>) { tr/\015//d; if (/^$prompt/) { $found_env = 1; last}; # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); next if (/^(\e\[.\d+h)?sysadmin-vm:[^#]+# /i); # NCS return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(0) if ($found_env); # Only do this routine once return(-1) if (/command authorization failed/i); if (!defined($E0)) { $E0 = 1; ProcessHistory("COMMENTS","keysort","E0","!\n"); } if (/power budget summary for rack/i) { ProcessHistory("COMMENTS","keysort","E1","!Power: $_"); while (<$INPUT>) { tr/\015//d; goto OUT if (/^$prompt/); last if (/^altitude information/i); ProcessHistory("COMMENTS","keysort","E1","!Power: $_"); } next; } if (/power shelf \d+:/i) { my($sep) = 0; ProcessHistory("COMMENTS","keysort","E1","!Power: $_"); while (<$INPUT>) { tr/\015//d; goto OUT if (/^$prompt/); last if (/^altitude information/i); last if (/^=+$/i && ($sep > 1)); $sep++ if (/^=+$/i); if (/^(\s+\S+\s+\S+-(?:AC|DC)\s+)(\S+\s+\S+\s+\S+\s+\S+)(\s+.*)/) { $_ = sprintf("%s%-". length($2) ."s%s\n", $1, "", $3); } ProcessHistory("COMMENTS","keysort","E1","!Power: $_"); } next; } /^Power Supply Information$/ && next; /^\s*Power Module\s+Voltage\s+Current$/ && next; /^\s*(Power [^:\n]+)$/ && ProcessHistory("COMMENTS","keysort","E1","!Power: $1\n") && next; /^\s*(Lower Power .*)/i && ProcessHistory("COMMENTS","keysort","E2","!Power: $1\n") && next; /^\s*(redundant .*)/i && ProcessHistory("COMMENTS","keysort","E2","!Power: $1\n") && next; /^\s*(RPS is .*)/i && ProcessHistory("COMMENTS","keysort","E2","!Power: $1\n") && next; } OUT: ProcessHistory("COMMENTS","keysort","E3","!\n"); return(0); } # This routine parses "dir /all ((disk|slot)N|bootflash|nvram):" sub DirSlotN { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DirSlotN: $_" if ($debug); my($dev) = (/\s([^\s]+):/); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if /^\s*\^\s*$/; return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(1) if (/(No such device|Error Sending Request)/i); return(1) if (/: path doesnot exists/i); # NCS return(1) if (/: Path does not exist/i); # NCS return(1) if (/\%Error: No such file or directory/); return(1) if (/\%Error: No route to host/); return(1) if (/No space information available/); # Corrupt flash /\%Error calling getdents / && ProcessHistory("FLASH","","","!Flash: $dev: $_") && next; return(-1) if (/\%Error calling/); return(-1) if (/(: device being squeezed|ATA_Status time out)/i); # busy return(-1) if (/\%Error opening \S+:\S+ \(Device or resource busy\)/i); return(-1) if (/command authorization failed/i); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); # Filter dhcp database if (/dhcp_[^. ]*\.txt/) { next; } # Filter debugging file dlbg.txt & dlbg.txt-1 only on ASR9k w/ XR if ($proc =~ /ASR9K/ && /dlbg\.txt/) { next; } # filter frequently changing files from IOX bootflash, hardiska, # and nvram if ($dev =~ /(bootflash|disk[0-9]|harddisk|nvram)/) { if (/\s(\.python-history|aaa|\.bash_history|.sppdc)\s*$/ || /\s(ce_switch.log\S*|cisco_support|errmsg_cont)\s*$/ || /\s(genstr_cont|temp_cont|temp_cont|temp_static_data)\s*$/ || /\s(uptime_cont|volt_cont|volt_hist)\s*$/) { # change # 57 -rw- 23100 volt_cont # 614788 drwx 4096 Fri Aug 20 12:06:25 2010 temp_cont # to # -rw- volt_cont # drwx temp_cont if (/\s*\d+\s+(\S+\s+)(\d+)(\s+)()(\s+)/) { my($a, $sz, $c, $dt, $d, $rem) = ($1, $2, $3, $4, $5, $'); my($szl) = length($sz); my($fmt) = "%s%-". $szl ."s%s%s%s%s"; $_ = sprintf($fmt, $c, $dt, $d, $rem); ProcessHistory("FLASH","keysort",$rem,"!Flash: $dev: $_"); next; } elsif (/\s*\d+\s+(\S+\s+\d+\s+)(\d+\s+\w+\s+\d+\s+\d+:\d+)/ || /\s*\d+\s+(\S+\s+\d+\s+)(\d+\s+\w+\s+\d+\s+\d{4})/) { # XR >= 6.3; dir disk0:, but harddisk: is diff format. wtf # drop fileno size, & date. # " 8002 drwxr-xr-x 2 4096 Jan 17 15:27 np" my($perm, $dt, $rem) = ($1, $2, $'); my($dtl) = length($dt); my($fmt) = "%s%-". $dtl ."s%s"; $_ = sprintf($fmt, $perm, "", $rem); ProcessHistory("FLASH","keysort",$rem,"!Flash: $dev: $_"); next; } elsif (/\s*\d+\s+(\S+\s+)(\d+)(\s+)(\w+ \w+\s+\d+ \d+:\d+:\d+ \d+)/) { my($b, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $'); my($szl, $dtl) = (length($sz), length($dt)); my($fmt) = "%s%-". $szl ."s%s%-". $dtl ."s%s"; $_ = sprintf($fmt, $b, "", $c, "", $rem); ProcessHistory("FLASH","keysort",$rem,"!Flash: $dev: $_"); next; } } else { if (/\s*\d+\s+(\S+\s+)(\d+)(\s+)(\s+)/) { my($sz, $c, $dt, $d, $rem) = ($1, $2, $3, $4, $'); ProcessHistory("FLASH","keysort",$rem,"!Flash: $dev: $sz$c$dt$d$rem"); next; } elsif (/\s*\d+\s+(\S+\s+\d+\s+)(\d+\s+\w+\s+\d+\s+\d+:\d+)/ || /\s*\d+\s+(\S+\s+\d+\s+)(\d+\s+\w+\s+\d+\s+\d{4})/) { # XR >= 6.3; dir disk0:, but harddisk: is diff format. wtf my($perm, $dt, $rem) = ($1, $2, $'); ProcessHistory("FLASH","keysort",$rem,"!Flash: $dev: $perm$dt$rem"); next; } elsif (/\s*\d+\s+(\S+\s+)(\d+)(\s+)(\w+ \w+\s+\d+ \d+:\d+:\d+ \d+)/) { # XR < 6.3 & etc. my($b, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $'); ProcessHistory("FLASH","keysort",$rem,"!Flash: $dev: $b$sz$c$dt$rem"); next; } } } # XR: 822083584 bytes total (821081600 bytes free) # eXR: 990484 kbytes total (813208 kbytes free) if (/^\s*(\d+ k?bytes) total\s+\((\d+ k?bytes) free\)/i) { ProcessHistory("FLASH","","","!Flash: $dev: " . diskszsummary($1, $2) . "\n"); next; } ProcessHistory("FLASH","","","!Flash: $dev: $_"); } ProcessHistory("","","","!\n"); return(0); } # This routine parses "admin show variables boot" sub ShowBootVar { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowBootVar: $_" if ($debug); while (<$INPUT>) { # delete non-ascii chars, except new line tr/ -~\n//cd; last if (/^$prompt/); next if (/\s*$cmd\s*$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/^\s*\^\s*$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); next if (/^(\e\[.\d+h)?sysadmin-vm:[^#]+# /i); # NCS return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(1) if (/Ambiguous command/i); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(-1) if (/command authorization failed/i); # skip blank lines next if (/^\s*$/); # NCS junk next if (/^\S+ connected from 127.0.0.1 using console /); next if (/# terminal length 0$/); ProcessHistory("COMMENTS", "keysort", "C30", "! $_"); } ProcessHistory("COMMENTS", "keysort", "C39", "!\n"); return(0); } # This routine parses "show controllers" sub ShowContAll { my($INPUT, $OUTPUT, $cmd) = @_; my($INT); print STDERR " In ShowContAll: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/(Invalid (input|command) detected|Type help or )/i); return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS # return(1) if ($type =~ /^(12[40]|7[05])/); return(-1) if (/command authorization failed/i); if (/^Interface ([^ \n(]*)/) { $INT = "$1, "; next; } /^(BRI unit \d)/ && ProcessHistory("INT","","","!Interface: $1\n") && next; /^LANCE unit \d, NIM/ && ProcessHistory("INT","","","!Interface: $_") && next; /^(LANCE unit \d)/ && ProcessHistory("INT","","","!Interface: $1\n") && next; /(Media Type is \S+),/ && ProcessHistory("INT","","","!\t$1\n"); if (/(M\dT[^ :]*:) show controller:$/) { my($ctlr) = $1; $_ = <$INPUT>; tr/\015//d; s/ subunit \d,//; ProcessHistory("INT","","","!Interface: $ctlr $_"); } if (/^(\S+) : show controller:$/) { my($ctlr) = $1; $_ = <$INPUT>; tr/\015//d; s/ subunit \d,//; ProcessHistory("INT","","","!Interface: $ctlr: $_"); } /^(HD unit \d), idb/ && ProcessHistory("INT","","","!Interface: $1\n") && next; /^HD unit \d, NIM/ && ProcessHistory("INT","","","!Interface: $_") && next; /^buffer size \d+ HD unit \d, (.*)/ && ProcessHistory("INT","","","!\t$1\n") && next; /^AM79970 / && ProcessHistory("INT","","","!Interface: $_") && next; /^buffer size \d+ (Universal Serial: .*)/ && ProcessHistory("INT","","","!\t$1\n") && next; /^Hardware is (.*)/ && ProcessHistory("INT","","","!Interface: $INT$1\n") && next; /^(QUICC Serial unit \d),/ && ProcessHistory("INT","","","!$1\n") && next; /^QUICC Ethernet .*/ && ProcessHistory("INT","","","!$_") && next; /^DTE .*\.$/ && ProcessHistory("INT","","","!\t$_") && next; /^(cable type :.*),/ && ProcessHistory("INT","","","!\t$1\n") && next; /^(.* cable.*), received clockrate \d+$/ && ProcessHistory("INT","","","!\t$1\n") && next; /^.* cable.*$/ && ProcessHistory("INT","","","!\t$_") && next; } return(0); } # This routine parses "show debug" sub ShowDebug { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowDebug: $_" if ($debug); my($lines) = 0; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(-1) if (/command authorization failed/i); /^No matching debug flags set$/ && next; /^No debug flags set$/ && next; ProcessHistory("COMMENTS","keysort","J1","!DEBUG: $_"); $lines++; } if ($lines) { ProcessHistory("COMMENTS","keysort","J0","!\n"); } return(0); } # This routine parses "admin show install active" sub ShowInstallSummary { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInstallSummary: $_" if ($debug); while (<$INPUT>) { # delete non-ascii chars, except new line tr/ -~\n//cd; last if (/^$prompt/); next if (/\s*$cmd\s*$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/^\s*\^\s*$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); next if (/^(\e\[.\d+h)?sysadmin-vm:[^#]+# /i); # NCS return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(1) if (/Ambiguous command/i); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(-1) if (/command authorization failed/i); return(-1) if (/inventory summary cannot be output/i); # temp error return(-1) if (/currently affected by install operation/i);# temp error return(-1) if (/install director is not up or ready/i);# temp error # skip blank lines next if (/^\s*$/); # NCS junk next if (/^\S+ connected from 127.0.0.1 using console /); next if (/# terminal length 0$/); ProcessHistory("COMMENTS", "keysort", "C15", "!Image: $_"); } ProcessHistory("COMMENTS", "keysort", "C10", "!\n"); ProcessHistory("COMMENTS", "keysort", "C19", "!\n"); return(0); } # This routine parses "show inventory". sub ShowInventory { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInventory: $_" if ($debug); while (<$INPUT>) { # delete non-ascii chars, except new line tr/ -~\n//cd; return if (/^\s*\^$/); last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); next if (/^(\e\[.\d+h)?sysadmin-vm:[^#]+# /i); # NCS return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(-1) if (/command authorization failed/i); # NCS junk next if (/^\S+ connected from 127.0.0.1 using console /); next if (/# terminal length 0$/); # remove spaces after quotes s/\"\s+/\"/g; if (/^(name: "[^"]*",) (descr: "[^"]+")/i) { ProcessHistory("INVENTORY","","", sprintf("!%-30s %s\n", $1, $2)); next; } # XR flavor: # NAME: "module 0/RSP0/CPU0", DESCR: "ASR9K Route Switch Processor with 880G/slot Fabric and 32GB" # PID: A9K-RSP880-SE, VID: V01, SN: FOC1911VC2S # # eXR flavor: # NAME: "0/RSP0-Motherboard", DESCR: "Motherboard Module" # PID: N/A , VID: N/A , SN: N/A # split PID/VID/SN line if (/^ ?PID: (\S*)\s*, VID: (\S*)\s*,\s* SN: (\S*)\s*$/) { my($pid,$vid,$sn) = ($1, $2, $3); my($entries) = ""; # filter , "0x" and "N/A" lines if ($pid !~ /^(|0x|N\/A)$/) { $entries .= "!PID: $pid\n"; } if ($vid !~ /^(|0x|N\/A)$/) { $entries .= "!VID: $vid\n"; } if ($sn !~ /^(|0x|N\/A)$/) { $entries .= "!SN: $sn\n"; } ProcessHistory("INVENTORY","","", "$entries"); next; } ProcessHistory("INVENTORY","","","!$_"); } ProcessHistory("INVENTORY","","","!\n"); return(0); } # This routine parses "admin show license" & "admin show license udi" sub ShowLicense { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowLicense: $_" if ($debug); while (<$INPUT>) { tr/\015//d; # delete non-ascii chars, except new line last if (/^$prompt/); next if (/\s*$cmd\s*$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (/^\s*\^\s*$/); next if (/^-+\^$/i); # NCS cmd-line error pointer return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); next if (/^(\e\[.\d+h)?sysadmin-vm:[^#]+# /i); # NCS return(1) if (/^syntax error: element does not exist$/i); # NCS return(1) if (/^syntax error: unknown argument$/i); # NCS return(1) if (/Ambiguous command/i); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(-1) if (/command authorization failed/i); # show lic on o/s w/o licenses s/info\s*: //; # file feature status line (ASR9k, others?) next if (/\s*status: /i); # skip blank lines next if (/^\s*$/); # NCS junk next if (/^\S+ connected from 127.0.0.1 using console /); next if (/# terminal length 0$/); # filter the BS from license broker next if (/(renewal attempt|communication attempt):/i); next if (/next registration attempt:/i); # timestamp next if (/(period used:|requested time:)/i); # show lic feature if (/(^\s*(evaluation )?period (left|remaining):\s*)\d+/i) { ProcessHistory("COMMENTS","keysort","LICENSE","! $1\n"); next; } # drop license counts next if (/license usage:/i); if (/(.*)count status/i) { my($hdr) = $1; my($len) = length($hdr); $hdr =~ s/\s*$//; ProcessHistory("COMMENTS", "keysort", "C20", "! $hdr\n"); while (<$INPUT>) { tr/\015//d; return(0) if (/^$prompt/); s/^(.{1,$len}).*/$1/; ProcessHistory("COMMENTS", "keysort", "C20", "! $_"); } next; } ProcessHistory("COMMENTS", "keysort", "C20", "! $_"); } ProcessHistory("COMMENTS", "keysort", "C20", "!\n"); return(0); } # This routine parses "show rpl maximum" sub ShowRPL { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowRPL: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if /^\s*\^\s*$/; return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(1) if (/Ambiguous command/i); return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","keysort","RPLMAX","! $_"); } ProcessHistory("COMMENTS","keysort","RPLMAX","!\n"); return(0); } # This routine parses "show vlan" sub ShowVLAN { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVLAN: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if /^\s*\^\s*$/; return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(1) if (/Ambiguous command/i); return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","keysort","IO","!VLAN: $_"); } ProcessHistory("COMMENTS","keysort","IO","!\n"); return(0); } # This routine processes a "write term" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($lineauto,$comment,$linecnt) = (0,0,0); while (<$INPUT>) { REPEAT: tr/\015//d; last if (/^$prompt/); # filter the bloody cmd-line timestamp next if (/^\w{3} \w{3,4} {1,3}\d{1,2} {1,2}\d{1,2}:\d+:\d+\.\d+ \S+$/); return(1) if (!$linecnt && /^\s+\^\s*$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(Invalid (input|command) detected|Type help or )/i); return(1) if (/^(-+\^|syntax error: unknown argument)$/i); # NCS return(1) if (/\%Error: No such file or directory/); return(0) if ($found_end); # Only do this routine once return(-1) if (/command authorization failed/i); return(-1) if (/% ?configuration buffer full/i); /^! no configuration change since last restart/i && next; # skip emtpy lines at the beginning if (!$linecnt && /^\s*$/) { next; } if (!$linecnt && defined($config_register)) { ProcessHistory("","","", "!\nconfig-register $config_register\n"); } # NCS junk next if (/^\S+ connected from 127.0.0.1 using console /); next if (/# terminal length 0$/); /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked /% Configuration buffer full, / && return(-1); # buffer is in use $linecnt++; $lineauto = 0 if (/^[^ ]/); # skip the crap if (/^(##+|(building|current) configuration)/i) { while (<$INPUT>) { next if (/^Current configuration\s*:/i); next if (/^:/); next if (/^([%!].*|\s*)$/); next if (/^ip add.*ipv4:/); # band-aid for 3620 12.0S last; } tr/\015//d; } # 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 \S+ at|Saved)/ && next; # skip consecutive comment lines to avoid oscillating extra comment # line on some access servers. grrr. if (/^!\s*$/) { next if ($comment); ProcessHistory("","","",$_); $comment++; next; } $comment = 0; # Dog gone Cool matches to process the rest of the config /^tftp-server flash / && next; # kill any tftp remains /^ntp clock-period / && next; # kill ntp clock-period /^ length / && next; # kill length on serial lines /^ width / && next; # kill width on serial lines $lineauto = 1 if /^ modem auto/; /^ speed / && $lineauto && next; # kill speed on serial lines /^ clockrate / && next; # kill clockrate on serial interfaces if (/^(enable )?(password|passwd)( level \d+)? / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1$2$3 \n"); next; } if (/^(enable secret) / && $filter_pwds >= 2) { ProcessHistory("ENABLE","","","!$1 \n"); next; } if (/^username (\S+)(\s.*)? secret /) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 secret \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^username (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } elsif ($filter_pwds >= 1 && $4 ne "5"){ ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^( set session-key (in|out)bound ah \d+ )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1\n"); next; } if (/^( set session-key (in|out)bound esp \d+ (authenticator|cypher) )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1\n"); next; } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","","!$1password \n"); next; } if (/^(\s*)secret / && $filter_pwds >= 2) { ProcessHistory("LINE-PASS","","","!$1secret \n"); next; } if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) { ProcessHistory("","","","! neighbor $1 password \n"); next; } if (/^(ppp .* password) 7 .*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^(ip ftp password) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # isis passwords appear to be completely plain-text if (/^\s+isis password (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!isis password $2\n"); next; } if (/^\s+(domain-password|area-password) (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $3\n"); next; } # this is reversable, despite 'md5' in the cmd if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # this is also reversable, despite 'md5 encrypted' in the cmd if (/^( message-digest-key \d+ md5 (7|encrypted)) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^((crypto )?isakmp key) \S+ / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # filter HSRP passwords if (/^(\s+standby \d+ authentication) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # this appears in "measurement/sla" images if (/^(\s+key-string \d?)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^( l2tp tunnel \S+ password)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # i am told these are plain-text on the PIX if (/^(vpdn username (\S+) password)/) { if ($filter_pwds >= 1) { ProcessHistory("USER","keysort","$2","!$1 \n"); } else { ProcessHistory("USER","keysort","$2","$_"); } next; } # ASA/PIX keys in more system:running-config if (/^( pre-shared-key | key |failover key ).*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } if (/(\s+ldap-login-password )\S+(.*)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # if (/^( cable shared-secret )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } /fair-queue individual-limit/ && next; # sort ip explicit-paths. if (/^ip explicit-path name (\S+)/) { my($key) = $1; my($expath) = $_; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); last if (! /^(ip explicit-path name |[ !])/); if (/^ip explicit-path name (\S+)/) { ProcessHistory("EXPATH","keysort","$key","$expath"); $key = $1; $expath = $_; } else { $expath .= $_; } } ProcessHistory("EXPATH","keysort","$key","$expath"); } # sort route-maps if (/^route-map (\S+)/) { my($key) = $1; my($routemap) = $_; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || ! /^(route-map |[ !])/); if (/^route-map (\S+)/) { ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); $key = $1; $routemap = $_; } else { $routemap .= $_; } } ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); } # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order access-lists /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order extended access-lists /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ && ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; # sort ipv{4,6} access-lists if ($aclfilterseq && /^ipv(4|6) access-list (\S+)\s*$/) { my($nlri, $key) = ($1, $2); my($seq, $cmd); ProcessHistory("ACL $nlri $key","","","$_"); while (<$INPUT>) { tr/\015//d; goto REPEAT if (/^$prompt/ || !/^(\s|\d|!)/); if (/^\s*!/) { ProcessHistory("ACL $nlri $key !", "", "", "$_"); next; } # ipv4 access-list name # remark NTP # deny ipv4 host 224.0.1.1 any # deny ipv4 239.0.0.0 0.255.255.255 any # permit udp any eq 123 any # permit ipv4 nnn.nnn.nnn.nnn/nn any # permit nnn.nnn.nnn.nnn/nn # ipv6 access-list name # permit ipv6 host 2001:nnnn::nnnn any # permit ipv6 2001:nnn::/nnn any # permit 2001:nnnn::/64 any # permit udp any eq 123 any my($seq, $cmd, $resid) = ($_ =~ /^\s*(\d+) (\w+) (.+)/); if ($cmd =~ /(permit|deny)/) { my($ip); my(@w) = ($resid =~ /(\S+) (\S+) (\S+\s)?(.+)/); for (my($i) = 0; $i < $#w; $i++) { if ($w[$i] eq "any") { if ($nlri eq "ipv4") { $ip = "255.255.255.255/32"; } else { $ip = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128"; } last; } elsif ($w[$i] =~ /^[:0-9]/ || $2[$i] =~ /^[a-fA-F]{1,4}:/) { $ip = $w[$i]; $ip =~ s/\s+$//; # trim trailing WS last; } } ProcessHistory("ACL $nlri $key $cmd", "$aclsort", "$ip", " $cmd $resid\n"); } else { ProcessHistory("ACL $nlri $key $cmd", "", "", " $cmd $resid\n"); } } } # order arp lists /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ && ProcessHistory("ARP","$aclsort","$1","$_") && next; /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(.*)/ && ProcessHistory("PACL $1 $3","$aclsort","$4","ip prefix-list $1 $3 $4$5\n") && next; if ($aclfilterseq) { /^ip(v4|v6) prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\S+)(.*)/ && ProcessHistory("PACL $2 $4","$aclsort","$5","ip$1 prefix-list $2 $4 $5$6\n") && next; } # order logging statements /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); if ($token eq '3') { $line .= " " . join(' ', ($token, shift(@tokens))); } } elsif ($token eq 'vrf') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } if (/^(snmp-server community) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_", "!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # prune tacacs/radius server keys if (/^((tacacs|radius)-server\s(\w*[-\s(\s\S+])*\s?key) (\d )?\w+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # order clns host statements /^clns host \S+ (\S+)/ && ProcessHistory("CLNS","keysort","$1","$_") && next; # order alias statements /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next; # delete ntp auth password - this md5 is a reversable too if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { my($sortkey) = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # order ip host statements /^ip host (\S+) / && ProcessHistory("IPHOST","keysort","$1","$_") && next; # order ip nat source static statements /^ip nat (\S+) source static (\S+)/ && ProcessHistory("IP NAT $1","ipsort","$2","$_") && next; # order atm map-list statements /^\s+ip\s+(\d+\.\d+\.\d+\.\d+)\s+atm-vc/ && ProcessHistory("ATM map-list","ipsort","$1","$_") && next; # order ip rcmd lines /^ip rcmd/ && ProcessHistory("RCMD","keysort","$_","$_") && next; # system controller /^syscon address (\S*) (\S*)/ && ProcessHistory("","","","!syscon address $1 \n") && next; if (/^syscon password (\S*)/ && $filter_pwds >= 1) { ProcessHistory("","","","!syscon password \n"); next; } /^ *Cryptochecksum:/ && next; # catch anything that wasnt matched above. ProcessHistory("","","","$_"); # end of config. if (/^end$/) { $found_end = 1; return(0); } } return(0); } 1; rancid-3.13/lib/nxos.pm.in000644 015615 000000 00000072424 13735654705 015506 0ustar00heaswheel000000 000000 package nxos; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # nxos.pm - Cisco NX-OS rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; our $proc; our $type; # device model, from ShowVersion our $C0; # output formatting control our $E0; our $H0; our $DO_SHOW_VLAN; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { $proc = ""; $type = undef; # device model, from ShowVersion $C0 = 0; # output formatting control $E0 = 0; $H0 = 0; $DO_SHOW_VLAN = 1; # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","D0","!\n"); ProcessHistory("COMMENTS","keysort","F0","!\n"); ProcessHistory("COMMENTS","keysort","G0","!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/[>#]\s?exit$/) { print STDERR ("$host: found exit\n") if ($debug); $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; print STDERR ("$host: $cmd failed: $rval\n") if ($debug); last TOP; } if (/[>#]\s?exit$/) { print STDERR ("$host: found exit\n") if ($debug); $clean_run = 1; last TOP; } } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/\% Invalid command at /); return(-1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); if (/^Cisco (Nexus|Storage Area Networking) Operating System/) { $type = "NXOS";} if (/^Software$/) { while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\s*$cmd\s*$/); if (/^$/) { goto EndSoftware; } /\s*([^:]*:)\s*(.*)$/ && ProcessHistory("COMMENTS","keysort","C1", "!Software: $1 $2\n") && next; } } EndSoftware: if (/^Hardware$/) { while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\s*$cmd\s*$/); if (/^\s*cisco (Nexus[ \d]+) /) { # cisco Nexus7000 C7010 (10 Slot) Chassis ("Supervisor module-1X") # cisco Nexus7000 C7018 (18 Slot) Chassis ("Supervisor module-1X") # cisco Nexus5548 Chassis ("O2 32X10GE/Modular Supervisor") # cisco Nexus 4000 Chassis ("20x10GE/supervisor") $proc = $1; } if (/^$/) { goto EndHardware; } if (/^\s*(.*) CPU\s*with (\d*) kB(.*)$/) { my($tmp) = int($2 / 1024); ProcessHistory("COMMENTS","keysort","A2", "!Hardware: $1 CPU with $tmp MB$3\n"); next; } if (/^\s*(.*)\s*with (\d*) kB(.*)$/) { my($tmp) = int($2 / 1024); ProcessHistory("COMMENTS","keysort","A2", "!Hardware: $1with $tmp MB$3\n"); next; } /^\s*(.*)$/ && ProcessHistory("COMMENTS","keysort","A2", "!Hardware: $1\n") && next; } } EndHardware: if (/^\s+(bootflash|slot0):\s+(\d+) kB(.*)$/) { my($tmp) = int($2 / 1024); ProcessHistory("COMMENTS","keysort","B1", "!Memory: $1: $tmp MB$3\n"); next; } } print STDERR "TYPE = $type\n" if ($debug); # XXX $proc is never set ProcessHistory("COMMENTS","keysort","A1", "!Chassis type: $proc - a $type router\n"); ProcessHistory("COMMENTS","keysort","B0", "!\n"); ProcessHistory("COMMENTS","keysort","C0", "!\n"); ProcessHistory("COMMENTS","","", "!\n"); return(0); } # This routine parses "show version build-info" sub ShowVersionBuild { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersionBuild: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); /^Built By / && ProcessHistory("COMMENTS","","", "!Build: $_"); /^On Date / && ProcessHistory("COMMENTS","","", "!Build: $_"); /^From Tree / && ProcessHistory("COMMENTS","","", "!Build: $_"); /^Base Tag / && ProcessHistory("COMMENTS","","", "!Build: $_"); /^Release for / && ProcessHistory("COMMENTS","","", "!Build: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show license *" sub ShowLicense { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowLicense: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(-1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); /^-+$/ && next; # Skip lines of all dashes. s/ Grace .+$/ Grace/; # Drop anything after Grace. ProcessHistory("COMMENTS","","", "!LIC: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show system redundancy status" sub ShowRedundancy { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowRedundancy: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(1) if (/.* command is not support/i); return(-1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); s/ +$//; # Drop trailing ' ' ProcessHistory("COMMENTS","","","!Red: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show environment" sub ShowEnv { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowEnv: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s*\^\s*$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(1) if (/ .* command is not support/i); return(1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); s/ +$//; # Drop trailing ' ' next if (/Fan Zone Speed:/); if (/(control temperature|monitor temperature)/i) { ProcessHistory("COMMENTS","","","!Env: $_"); while (<$INPUT>) { tr/\015//d; goto EndShowEnv if (/^$prompt/); if (/(.*\s+\d+\s+\d+\s+)(\d+)(.*$)/) { $_ = sprintf("%s%-". length($2)."s%s\n", $1, "", $3); } ProcessHistory("COMMENTS","","","!Env: $_"); last if (/^\s*$/); } next; } ProcessHistory("COMMENTS","","","!Env: $_"); } EndShowEnv: ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show environment temperature" sub ShowEnvTemp { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowEnvTemp: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/No token match at /); # 1000v return(1) if (/\% Invalid command at /);# 1000v has no support return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); s/ +$//; # Drop trailing spaces # Cut out CurTemp - drop the 2nd to last field. #-------------------------------------------------------------------- #Module Sensor MajorThresh MinorThres CurTemp Status # (Celsius) (Celsius) (Celsius) #5 Outlet1 (s1) 125 125 33 Ok #5 QEng1Sn1(s10) 115 105 39 Ok if (/(control temperature|monitor temperature)/i) { ProcessHistory("COMMENTS","","","!Env: $_"); while (<$INPUT>) { tr/\015//d; goto EndShowEnvTemp if (/^$prompt/); if (/(.*\s+\d+\s+\d+\s+)(\d+)(.*$)/) { $_ = sprintf("%s%-". length($2)."s%s\n", $1, "", $3); } ProcessHistory("COMMENTS","","","!Env: $_"); last if (/^\s*$/); } next; } else { next if (/INTAKE/); next if (/ASIC/); s/^(.+\s)(\S+\s+)(\S+\s*)$/$1$3/; s/ +$//; # Drop trailing ' ' ProcessHistory("COMMENTS","","","!Env: $_"); } } EndShowEnvTemp: ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show environment power" sub ShowEnvPower { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowEnvPower: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s*\^\s*$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); # Filter Actual Output/Draw. #Power Actual Total #Supply Model Output Capacity Status # (Watts ) (Watts ) #------- ------------------- ----------- ----------- -------------- #1 ------------ 0 W 0 W Absent #3 749 W 5480 W Ok # Actual Power #Module Model Draw Allocated Status # (Watts ) (Watts ) #------- ------------------- ----------- ----------- -------------- #2 NURBURGRING N/A 573 W Powered-Up #fan1 N/A 720 W Powered-Up # # ELSE # # nexus# sh environment power # Power Supply: # Voltage: 12 Volts # Power Actual Actual Total # Supply Model Output Input Capacity Status # (Watts ) (Watts ) (Watts ) # ------- ------------------- ---------- ---------- ---------- # -------------- # 1 N9K-PAC-650W-B 65 W 76 W 649 W Ok # 2 N9K-PAC-650W-B 70 W 84 W 649 W Ok # # # Power Usage Summary: # -------------------- # Power Supply redundancy mode (configured) PS-Redundant # Power Supply redundancy mode (operational) PS-Redundant # # Total Power Capacity (based on configured mode) 649.92 W # Total Grid-A (first half of PS slots) Power Capacity 649.92 W # Total Grid-B (second half of PS slots) Power Capacity 649.92 W # Total Power of all Inputs (cumulative) 1299.84 W # Total Power Output (actual draw) 136.00 W # Total Power Input (actual draw) 161.00 W # Total Power Allocated (budget) N/A # Total Power Available for additional modules N/A # # nexus# if (/(.* +)(\d+ W +\d+ W)( +\d+ W.+)/) { $_ = sprintf("%s%-". length($2)."s%s\n", $1, "", $3); } elsif (/(.* +)(\d+(\.\d+)? W)( +\d+(\.\d+)? W.+)/) { $_ = sprintf("%s%-". length($2)."s%s\n", $1, "", $4); } /actual draw/ && next; # Drop changing total power output. s/ +$//; # Drop trailing ' ' ProcessHistory("COMMENTS","","","!Env: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show boot" sub ShowBoot { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowBoot: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if /Ambiguous command/i; return(-1) if (/\% Invalid command at /); return(-1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); s/ variable = / = /; ProcessHistory("COMMENTS","","","!Variable: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "dir /all ((disk|slot)N|bootflash|nvram):" sub DirSlotN { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DirSlotN: $_" if ($debug); my($free); my($dev) = (/\s([^\s]+):/); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(1) if /(No such device|Error Sending Request)/i; return(1) if /No such file or directory/; return(1) if /No space information available/; return(1) if / is either not present or not formatted/; return(-1) if /\%Error calling/; return(-1) if /(: device being squeezed|ATA_Status time out)/i; # busy return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); return(1) if /(Open device \S+ failed|Error opening \S+:)/; # Drop ee.log /\s+ee\.log(?:\..*)?$/ && next; # Drop bootvar_debug log files /\s+bootvar_debug\./ && next; # Drop accounting.log* /\s+accounting.log.*/ && next; # Drop vtp_debug.log and vtp_debug_old.log CDETS bug CSCuy87611 /\s+vtp_debug(_old)?\.log$/ && next; # Drop bcm_mem_lock_trace.log /\s+bcm_mem_lock_trace\.log$/ && next; next if (/BufferMonitor-1HourData/); if (/( debug_logs| log)\/$/) { # change # 8192 Jan 08 14:05:05 2015 log/ # to # log/ if (/(\s*\d+\s+)(\S+ \d+\s+\d+:\d+:\d+ \d+)(.*)/) { my($a, $dt, $rem) = ($1, $2, $3); my($dtl) = length($dt); my($fmt) = "%s%-". $dtl ."s%s\n"; $_ = sprintf($fmt, $a, "", $rem); } } if (/^\s*(\d+) bytes free/i) { $free = $1; next; } elsif (/^\s*(\d+) bytes used/i) { next; } elsif (/^\s*(\d+) bytes total/i) { $_ = diskszsummary($1, $free, undef) . "\n"; } ProcessHistory("COMMENTS","","","!Flash: $dev: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show module". sub ShowModule { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowModule: $_" if ($debug); while (<$INPUT>) { tr/\015//d; return if (/^\s*\^$/); last if (/online diag status/i); last if (/^$prompt/); next if (/^\s*$cmd\s*$/); return(1) if (/\% Invalid command at /); return(1) if (/\% Invalid number at /); return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); s/(.*) \*$/$1/; # Drop a trailing '*' /^\* this terminal session/ && next; s/ +$//; # Drop trailing ' ' # filter fluctuating WWNs if (/\s+World-Wide-Name.*/i) { ProcessHistory("COMMENTS","","","!Mod: $_"); while (<$INPUT>) { tr/\015//d; goto EndShowModule if (/^$prompt/); last if (/^\s*$/); if (/^(\d+\s+\S+\s+\S+)\s+.*$/) { $_ = sprintf("%s\n", $1); } ProcessHistory("COMMENTS","","","!Mod: $_"); } } ProcessHistory("COMMENTS","","","!Mod: $_"); } EndShowModule: ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show interface transceiver". sub ShowIntTransceiver { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowtTransceiver: $_" if ($debug); while (<$INPUT>) { tr/\015//d; return if (/^\s*\^$/); last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(-1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); # filter out oscillating data from transceivers next if (/(Temperature|Current|Power|Voltage)\s+:/); ProcessHistory("COMMENTS","","","!$_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show inventory". sub ShowInventory { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInventory: $_" if ($debug); while (<$INPUT>) { tr/\015//d; return if (/^\s*\^$/); last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(-1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); if (/^(NAME: "[^"]*",)\s+(DESCR: "[^"]+")/) { ProcessHistory("COMMENTS","","", sprintf("!%-30s %s\n", $1, $2)); next; } # split PID/VID/SN line if (/^PID: (\S*)\s*,\s+VID: (\S*)\s*,\s+SN: (\S*)\s*$/) { my($entries) = ""; $entries .= "!PID: $1\n" if ($1); $entries .= "!VID: $2\n" if ($2); $entries .= "!SN: $3\n" if ($3); ProcessHistory("COMMENTS","","", "$entries"); next; } # split broken PID/VID/SN lines. if (/^PID: (\S*)\s*,\s+VID: (\S*)\s*$/) { my($entries) = ""; $entries .= "!PID: $1\n" if ($1); $entries .= "!VID: $2\n" if ($2); <$INPUT>; tr/\015//d; /^\s*,\s+SN: (\S*)\s*$/; $entries .= "!SN: $1\n" if ($1); ProcessHistory("COMMENTS","","", "$entries"); next; } ProcessHistory("COMMENTS","","","!$_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show vtp status" sub ShowVTP { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVTP: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); next if (/^Configuration last modified by/); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } # Nexus 5k and 1000v do not support vtp if (!/^VTP Operating Mode\s+:\s+(Transparent|Server)/) { $DO_SHOW_VLAN = 0; } ProcessHistory("COMMENTS","","","!VTP: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show vlan" sub ShowVLAN { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVLAN: $_" if ($debug); ($_ = <$INPUT>, return(1)) if (!$DO_SHOW_VLAN); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/\% Invalid command at /); return(-1) if (/No token match at /); # 1000v return(1) if /Ambiguous command/i; return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } ProcessHistory("COMMENTS","","","!VLAN: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show debug" sub ShowDebug { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowDebug: $_" if ($debug); my($lines) = 0; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/\% Invalid command at /); return(-1) if (/No token match at /); # 1000v return(-1) if (/command authorization failed/i); return(-1) if (/could not retrieve info/i); # XXX return(-1) if (/\% Permission denied/); # NX 5000 bug? "show debug" generates # "Permission denied" when using command authorization. -Per-Olof Olsson next if (/\% Permission denied/); /^No matching debug flags set$/ && next; /^No debug flags set$/ && next; ProcessHistory("COMMENTS","","","!DEBUG: $_"); $lines++; } if ($lines) { ProcessHistory("COMMENTS","","","!\n"); } return(0); } # This routine parses "show cores" sub ShowCores { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowCores: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","","","!CORES: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show fex" and "show module fex" sub ShowFex { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowFex: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/^\s*\^\s*$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(1) if (/% Invalid number at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","","","!FEX: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show processes log" sub ShowProcLog { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowProcLog: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /Line has invalid autocommand /; return(1) if /(Invalid input detected|Type help or )/; return(1) if (/\% Invalid command at /); return(-1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","","","!PROC_LOGS: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine processes a "write term" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($lineauto,$comment,$linecnt) = (0,0,0); while (<$INPUT>) { REPEAT: tr/\015//d; last if (/^$prompt/); return(1) if /Line has invalid autocommand /; return(1) if (/(Invalid input detected|Type help or )/i); return(-1) if (/\% Invalid command at /); return(-1) if (/No token match at /); # 1000v return(-1) if (/\% Permission denied/); return(-1) if (/command authorization failed/i); return(0) if ($found_end); # Only do this routine once $linecnt++; $lineauto = 0 if (/^[^ ]/); # Dog gone Cool matches to process the rest of the config /^!Command: show running-config/ && next; # kill this junk /^!Time: / && next; # kill this junk # Sort username and delete passwords. if (/^username (\S+) password (\d) (\S+)(\s.*)$/) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1 password $4\n"); } elsif ($filter_pwds >= 1 && $2 ne "5") { ProcessHistory("USER","keysort","$1", "!username $1 password $4\n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } # Sort any other username info. /^username (\S+) .*$/ && ProcessHistory("USER","keysort","$1","$_") && next; if (/^\s*(.*?neighbor \S*) password / && $filter_pwds >= 1) { ProcessHistory("","","","! $1 password \n"); next; } # sort ipv{4,6} access-lists if ($aclfilterseq && /^ip(v4|v6)? access-list (\S+)\s*$/) { my($nlri, $key) = ($1, $2); my($seq, $cmd); if (length($nlri) eq 0) { $nlri = "ipv4"; # assume ip will become ipv4 at some point } ProcessHistory("ACL $nlri $key","","","$_"); while (<$INPUT>) { tr/\015//d; goto REPEAT if (/^$prompt/ || !/^\s/); if (/^\s*!/) { ProcessHistory("ACL $nlri $key !", "", "", "$_"); next; } # ip access-list copp-system-acl-bgp # 10 permit tcp any gt 1024 any eq bgp # 20 permit tcp any eq bgp any gt 1024 # ipv6 access-list copp-system-acl-bgp6 # 10 permit tcp any gt 1024 any eq bgp # 20 permit tcp any eq bgp any gt 1024 # XXX this may need more format handling; going off email with # a user. my($seq, $cmd, $resid) = ($_ =~ /^\s*(\d+) (\w+) (.+)/); if ($cmd =~ /(permit|deny)/) { my($ip); my(@w) = ($resid =~ /(\S+) (\S+) (\S+\s)?(.+)/); for (my($i) = 0; $i < $#w; $i++) { if ($w[$i] eq "any") { if ($nlri eq "ipv4") { $ip = "255.255.255.255/32"; } else { $ip = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128"; } last; } elsif ($w[$i] =~ /^[:0-9]/ || $2[$i] =~ /^[a-fA-F]{1,4}:/) { $ip = $w[$i]; $ip =~ s/\s+$//; # trim trailing WS last; } } ProcessHistory("ACL $nlri $key $cmd", "$aclsort", "$ip", " $cmd $resid\n"); } else { ProcessHistory("ACL $nlri $key $cmd", "", "", " $cmd $resid\n"); } } } # Why was this commented out? It shows up in the raw text... if (/^(snmp-server community) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_", "!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); if ($token eq '3') { $line .= " " . join(' ', ($token, shift(@tokens))); } } elsif ($token eq 'vrf') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } # Sort snmp user and delete passwords. if (/^snmp-server user (\S+) (\S+) auth md5 (\S+) priv (\S+) localizedkey$/) { if ($filter_pwds >= 2) { ProcessHistory("SNMP-USER","keysort","$1", "!snmp-server user $1 $2 auth md5 priv localizedkey\n"); } else { ProcessHistory("SNMP-USER","keysort","$1","$_"); } next; } # Sort any other snmp user info. /^snmp-server user (\S+) .*$/ && ProcessHistory("SNMP-USER","keysort","$1","$_") && next; # Delete bgp passwords. if (/^(\s*)password (\d) (\S+)(\s.*)?$/) { if ($filter_pwds >= 2) { ProcessHistory("","","","!$1password $4"); } elsif ($filter_pwds >= 1 && $2 ne "5") { ProcessHistory("","","","!$1password $4"); } else { ProcessHistory("","","","$_"); } next; } # prune tacacs/radius server keys: # tacacs-server host 196.23.0.13 key 7 "xxxxxxx" port 50 timeout 10 if (/^((tacacs|radius)-server.*?\bkey\b.*?) ".*?"(.*)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $3\n"); next; } # order cli alias names /^cli alias name (\S+) .*$/ && ProcessHistory("CLI-ALIAS","keysort","$1","$_") && next; # order snmp-server enable trap statements /^snmp-server enable traps (.*)$/ && ProcessHistory("SNMP-TRAPS","keysort","$1","$_") && next; # catch anything that wasnt matched above. ProcessHistory("","","","$_"); # end of config. the ": " game is for the PIX if (/^(: +)?end$/) { $found_end = 1; return(0); } } # The ContentEngine lacks a definitive "end of config" marker. If we # know that it is NXOS and we have seen at least 5 lines # of write term output, we can be reasonably sure that we got the config. if (($type eq "NXOS") && $linecnt > 5) { $found_end = 1; return(0); } return(0); } 1; rancid-3.13/lib/fss2.pm.in000644 015615 000000 00000012203 13532047223 015343 0ustar00heaswheel000000 000000 package fss2; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # onefinity.pm - Fujitsu FSS2/1finity rancid procedures # use 5.010; use strict 'vars'; use warnings; require(Exporter); our @ISA = qw(Exporter); $Exporter::Verbose=1; use rancid @VERSION@; @ISA = qw(Exporter rancid main); #our @EXPORT = qw($VERSION) # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: $devtype\n#\n"); ProcessHistory("COMMENTS","keysort","A0","#\n"); ProcessHistory("COMMENTS","keysort","B0","#\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while (<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host jlogin error: $_"); print STDERR ("$host jlogin error: $_") if ($debug); $clean_run=0; last; } if (/System shutdown message/) { print STDOUT ("$host shutdown msg: $_"); print STDERR ("$host shutdown msg: $_") if ($debug); $clean_run = 0; last; } if (/error: cli version does not match Managment Daemon/i) { print STDOUT ("$host mgd version mismatch: $_"); print STDERR ("$host mgd version mismatch: $_") if ($debug); $clean_run = 0; last; } while (/>\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^>]+>)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/>\s*quit/) { $clean_run=1; last; } } } # This routine parses "show fw-info" sub ShowFWinfo { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowFWinfo: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("FWINFO","","","#\n# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if /\[ok\]\[/i; ProcessHistory("FWINFO","","","# $_"); } return(0); } # This routine parses "show inventory" sub ShowInventory { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInventory: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("INVENTORY","","","#\n# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if /\[ok\]\[/i; next if (/^inventory\s*$/i); ProcessHistory("INVENTORY","","","# $_"); } return(0); } # This routine parses "show system" sub ShowSystem { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSystem: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("COMMENTS","keysort","C","#\n# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if /\[ok\]\[/i; next if /system (sys-)?uptime/i; /system neType\s+(.*)/ && ProcessHistory("COMMENTS","keysort","A1","#Chassis type: $1\n") && next; /system softwareVersion\s+(.*)/ && ProcessHistory("COMMENTS","keysort","B1","#Image: $1\n") && next; # drop cpu stats and process stats if (/^(index\s*user type\s*|\s*cpu\s*cpu\s*$)/i) { while (<$INPUT>) { tr/\015//d; goto OUT if (/^$prompt/); # should not occur goto OUT if /\[ok\]\[/i; last if (/^\s*$/); } next; } ProcessHistory("","","","# $_"); } OUT: return(0); } # This routine parses "show configuration" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; my($lines) = 0; my($snmp) = 0; print STDERR " In WriteTerm: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("COMMENTS","","","#\n# $_"); while (<$INPUT>) { tr/\015//d; next if (/^\s*$/); # end of config - hopefully. FSS2 does not have a reliable # end-of-config tag. appears to end with "\nPROMPT>", but not sure. if (/^$prompt/ || /^\[ok\]\[/) { $found_end++; last; } next if (/^\s+(last-changed|last-updated|uptime)\s+/i); next if (/^\s+(replay-log-creation-time|replay-log-aged-time)\s+/i); next if (/^\s+sys-vstimer\s+/i); next if (/^\s+softwareversion\s+/i); next if (/^\s+(netype|vendor)\s+/i); $lines++; # filter snmp community, when in snmp { stanza } /^snmp/ && $snmp++; /^}/ && ($snmp = 0); if ($snmp && /^(\s*)(community|trap-group) [^ ;]+(\s?[;{])$/) { if ($filter_commstr) { $_ = "$1$2 \"\"$3\n"; } } # this is either cleartext or *; either way, it should be filtered. if (/(\s+password\s+)[^ ;]+/) { ProcessHistory("","","","#$1$'"); next; } if (/(\s+crypt-password\s+)[^ ;]+/ && $filter_pwds >= 2) { ProcessHistory("","","","#$1$'"); next; } ProcessHistory("","","","$_"); } if ($lines < 3) { printf(STDERR "ERROR: $host configuration appears to be truncated.\n"); $found_end = 0; return(-1); } return(0); } 1; rancid-3.13/lib/smc.pm.in000755 015615 000000 00000023500 13735654705 015273 0ustar00heaswheel000000 000000 package smc; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # smc.pm - SMC rancid procedures; and some Dell products. started by # d_pfleger@juniper.net # # Code tested and working fine on these models: # # DELL PowerConnect M8024 / M8024-k # DELL PowerConnect M6348 # DELL PowerConnect N2048, N4032F and N4064. # DELL PowerConnect 62xx # DELL PowerConnect 7048 # DELL 34xx (partially; configuration is incomplete) # DELL R1-2401 # use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","A0","!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","C0","!\n"); ProcessHistory("COMMENTS","keysort","D0","!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host hlogin error: $_"); print STDERR ("$host hlogin error: $_") if ($debug); last; } while (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (!defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } my($rval) = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/[>#]\s?logout(\s*connection.*closed.*)?$/i) { $clean_run = 1; last; } } } # This routine parses "dir" sub Dir { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In Dir: $_" if ($debug); $_ =~ s/^[^#]*//; ProcessHistory("COMMENTS","keysort","D1","!\n! $_"); while (<$INPUT>) { s/^\s+\015//g; tr/\015//d; next if /^\s*$/; last if(/$prompt/); # pager remnants like: ^H^H^H ^H^H^H content s/[\b]+\s*[\b]*//g; # filter oscillating files next if /^aaafile\.prv/; ProcessHistory("COMMENTS","keysort","D1","! $_"); } ProcessHistory("COMMENTS","keysort","D1","!\n"); return(0); } sub ShowVer { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVer: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if /^\s*$/; last if(/$prompt/); # pager remnants like: ^H^H^H ^H^H^H content s/[\b]+\s*[\b]*//g; # Remove Uptime / up time/i && next; ProcessHistory("COMMENTS","keysort","B1","! $_"); } return(0); } sub ShowSys { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSys: $_" if ($debug); $_ =~ s/^[^#]*//; ProcessHistory("COMMENTS","keysort","C1","!\n! $_"); while (<$INPUT>) { TOP: s/^\s+\015//g; tr/\015//d; next if /^\s*$/; last if(/$prompt/); # pager remnants like: ^H^H^H ^H^H^H content s/[\b]+\s*[\b]*//g; # filter temperature sensor info form Dell N1148T-ON and Powerconnect # 7048 /Temperature Sensors:/; yet another format - a losing battle. if (/^(system thermal conditions|Temperature Sensors):/i) { while (<$INPUT>) { s/^\s+\015//g; tr/\015//d; goto ENDSHOWSYS if (/$prompt/); # next section header goto TOP if (/^(\w\s*)+:/); } } elsif (/Temperature \(Celsius\)/) { # filter temperature sensor info for Dell 6428 stacks ProcessHistory("COMMENTS","keysort","C1","! $_"); ProcessHistory("COMMENTS","keysort","C1","! Unit\tStatus\n"); ProcessHistory("COMMENTS","keysort","C1","! ----\t------\n"); while (<$INPUT>) { s/^\s+\015//g; tr/\015//d; goto ENDSHOWSYS if (/$prompt/); /(\d+)\s+\d+\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","C1","! $1\t$2\n"); /^\s*$/ && last; } } elsif (/Temperature/) { # Filter temperature sensor info for Dell M6348 and M8024 blade # switches. # # M6348 and M8024 sample lines: # Unit Description Temperature Status # (Celsius) # ---- ----------- ----------- ------ # 1 System 39 Good # 2 System 39 Good ProcessHistory("COMMENTS","keysort","C1", "! Unit\tDescription\tStatus\n"); ProcessHistory("COMMENTS","keysort","C1", "! ----\t-----------\t------\n"); while (<$INPUT>) { /\(celsius\)/i && next; s/^\s+\015//g; tr/\015//d; goto ENDSHOWSYS if (/$prompt/); /(\d+)\s+(\w+)\s+\d+\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","C1","! $1\t$2\t\t$3\n"); /^\s*$/ && last; } } elsif (/unit\s+up\s+time/i) { # filter module uptime on PowerConnect 5524 # Unit Up time # ---- --------------- # 1 84,01:53:23 # 2 84,01:53:45 while (<$INPUT>) { s/^\s+\015//g; tr/\015//d; goto ENDSHOWSYS if (/$prompt/); /^\s*$/ && last; } } # Remove Uptime / up time/i && next; # filter power rates and timestamps from 7024 power supply info # Power Supplies: # # Unit Description Status Average Current Since # Power Power Date/Time # (Watts) (Watts) # ---- ----------- ----------- ---------- -------- ------------------- # 1 System OK 1.4 65.2 # 1 Internal OK N/A N/A 10/05/2017 20:18:35 if (/power supplies/i) { ProcessHistory("COMMENTS","keysort","C1", "!\n"); ProcessHistory("COMMENTS","keysort","C1", "! Unit\tDescription\tStatus\n"); ProcessHistory("COMMENTS","keysort","C1", "! ----\t-----------\t------\n"); while (<$INPUT>) { s/^\s+\015//g; tr/\015//d; goto ENDSHOWSYS if(/$prompt/); /^(unit\s|--+\s|\s)/i && next; if (/(\d+)\s+(\w+)\s+(\w+(\s\w+)?)\s/) { if (length($2) >= 8) { ProcessHistory("COMMENTS","keysort","C1","! $1\t$2\t$3\n"); } else { ProcessHistory("COMMENTS","keysort","C1","! $1\t$2\t\t$3\n"); } } /^\s*$/ && last; } } /system description: (.*)/i && ProcessHistory("COMMENTS","keysort","A1", "!Chassis type: $1\n") && next; ProcessHistory("COMMENTS","keysort","C1","! $_"); } ENDSHOWSYS: return(0); } sub ShowVlan { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVlan: $_" if ($debug); $_ =~ s/^[^#]*//; ProcessHistory("COMMENTS","keysort","D1","!\n! $_"); while (<$INPUT>) { s/^\s+\015//g; tr/\015//d; next if /^\s*$/; last if(/$prompt/); # pager remnants like: ^H^H^H ^H^H^H content s/[\b]+\s*[\b]*//g; # Remove Uptime / up time/i && next; ProcessHistory("COMMENTS","keysort","D1","! $_"); } return(0); } # This routine processes a "write term" (aka show running-configuration) sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; my($comment) = (0); print STDERR " In WriteTerm: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if /^\s*$/; last if(/$prompt/); # pager remnants like: ^H^H^H ^H^H^H content s/[\b]+\s*[\b]*//g; # skip consecutive comment lines if (/^!/) { next if ($comment); ProcessHistory("","","",$_); $comment++; next; } $comment = 0; /^building running-config/ && next; /^------+/ && ProcessHistory("","","","!$_") && next; /^router configuration/i && ProcessHistory("","","","!$_") && next; /^oob host config/i && ProcessHistory("","","","!$_") && next; /^empty configuration/i && ProcessHistory("","","","!$_") && next; if (/^username (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } elsif ($filter_pwds >= 1 && $3 ne "5"){ ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^(enable password)( level \d+)? / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1$2 \n"); next; } if (/^password (\S+) encrypted/ && $filter_pwds > 1) { ProcessHistory("","","","!password encrypted\n"); next; } if (/^password (\S+)$/ && $filter_pwds >= 1) { ProcessHistory("","","","!password \n"); next; } if (/^(enable password level \d+) (\S+) encrypted/ && $filter_pwds > 1){ ProcessHistory("","","","!$1 encrypted\n"); next; } if (/^(enable password level \d+) (\S+)$/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'\n"); next; } # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^(snmp-server host) (\d+\.\d+\.\d+\.\d+) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERHOST","ipsort", "$2","!$1 $2 $'"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$2","$_"); } next; } if (/^(snmp-server community) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort", "$_","!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$2","$_") && next; } } # prune tacacs/radius server keys if (/^(tacacs-server|radius-server) key \w+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } ProcessHistory("","","","$_"); } $found_end = 1; return(1); } 1; rancid-3.13/lib/avocent.pm.in000755 015615 000000 00000006556 13713052202 016140 0ustar00heaswheel000000 000000 package avocent; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # avocent.pm - Avocent ACS rancid procedures # (formerly Cyclades) use 5.010; use strict 'vars'; use warnings; require(Exporter); our @ISA = qw(Exporter); $Exporter::Verbose=1; use rancid @VERSION@; our $ShowChassisSCB; # Only run ShowChassisSCB() once our $ShowChassisFirmware; # Only run ShowChassisFirmware() once @ISA = qw(Exporter rancid main); #our @EXPORT = qw($VERSION) # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: $devtype\n#\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host avologin error: $_"); print STDERR ("$host avologin error: $_") if ($debug); $clean_run = 0; last; } while (/[#\$]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#\$]+[#\$])/)[0]; $prompt =~ s/([][}{)(\\\$])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/[#\$]\s*exit$/) { $clean_run = 1; last; } } } # This routine parses "cat" sub CatFile { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In CatFile: $_" if ($debug); my($catfile) = $cmd; $catfile =~ s/cat //; ProcessHistory("COMMENTS","","","# $catfile:\n"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/: Permission denied/); ProcessHistory("COMMENTS","","","$_"); } ProcessHistory("COMMENTS","","","#\n"); if ($catfile eq "/etc/security.opts") { $found_end = 1; $clean_run = 1; } return(0); } # This routine parses "cat" w/ output commented sub CatFileComment { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In CatFile: $_" if ($debug); my($catfile) = $cmd; $catfile =~ s/cat //; ProcessHistory("COMMENTS","","","# $catfile:\n"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/: Permission denied/); ProcessHistory("COMMENTS","","","# $_"); } ProcessHistory("COMMENTS","","","#\n"); if ($catfile eq "/etc/security.opts") { $found_end = 1; $clean_run = 1; } return(0); } # This routine parses "cat /proc/meminfo" sub Meminfo { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In Meminfo: $_" if ($debug); my($catfile) = $cmd; $catfile =~ s/cat //; ProcessHistory("COMMENTS","","","# $catfile:\n"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/: Permission denied/); if (/memtotal:\s+(\d+.*)/i) { # MemTotal: 256944 kB my($size) = bytes2human(human2bytes($1)); ProcessHistory("COMMENTS","","","# Memory: total $size\n"); } } ProcessHistory("COMMENTS","","","#\n"); return(0); } 1; rancid-3.13/lib/bigip.pm.in000644 015615 000000 00000017026 13532047154 015573 0ustar00heaswheel000000 000000 package bigip; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # bigip.pm - F5 BIG-IP >= v11 rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { # force a terminal type so as not to confuse the POS $ENV{'TERM'} = "vt100"; 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","A1","#\n"); ProcessHistory("COMMENTS","keysort","B0","#\n"); ProcessHistory("COMMENTS","keysort","C0","#\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run=0; last; } while (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/\#\s?exit$/) { $clean_run=1; last; } } } # This routine parses a single command that returns no required info. The # output is discarded. sub RunCommandTMSH { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In RunCommandTMSH: $_" if ($debug); while (<$INPUT>) { tr/\015//d; # Needed for when our prompt changes due to our executed command (for # example, after executing 'cd /') $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; last if (/^$prompt/); } return(0); } # This routine parses "tmsh show /sys version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); /^kernel:/i && ($_ = <$INPUT>) && ProcessHistory("COMMENTS","keysort","A3","#Image: Kernel: $_") && next; if (/^package:/i) { my($line); while ($_ = <$INPUT>) { tr/\015//d; last if (/:/); last if (/^$prompt/); chomp; $line .= " $_"; } ProcessHistory("COMMENTS","keysort","A2", "#Image: Package:$line\n"); } if (/:/) { ProcessHistory("COMMENTS","keysort","C1","#$_"); } else { ProcessHistory("COMMENTS","keysort","C1","#\t$_"); } } return(0); } # This routine parses "tmsh show /sys hardware" sub ShowHardware { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowHardware: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); s/\d+rpm//ig; s/^\|//; s/^\ \ ([0-9]+)(\ +).*up.*[0-9]/ $1$2up REMOVED/i; s/^\ \ ([0-9]+)(\ +).*Air\ Inlet/ $1$2REMOVED Air Inlet/i; s/^\ \ ([0-9]+)(\ +).*HSBe/ $1$2REMOVED HSBe/i; s/^\ \ ([0-9]+)(\ +).*TMP421 on die/ $1$2REMOVED TMP421 on die/i; s/^\ \ ([0-9]+)(\ +)[0-9]+\ +[0-9]+/ $1$2REMOVED REMOVED/; /Type: / && ProcessHistory("COMMENTS","keysort","A0", "#Chassis type: $'"); ProcessHistory("COMMENTS","keysort","B1","#$_") && next; } return(0); } # This routine parses "tmsh show /sys license" sub ShowLicense { my($INPUT, $OUTPUT, $cmd) = @_; my($line) = (0); print STDERR " In ShowLicense: $_" if ($debug); while (<$INPUT>) { tr/\015//d; # v9 software license does not have CR at EOF s/^#-+($prompt.*)/$1/; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); if (!$line++) { ProcessHistory("LICENSE","","","#\n#/config/bigip.license:\n"); } ProcessHistory("LICENSE","","","# $_") && next; } return(0); } # This routine parses "tmsh show /net route static" sub ShowRouteStatic { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowRouteStatic: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); ProcessHistory("ROUTE","",""," $_") && next; } return(0); } # This routine parses "cat /config/ZebOS.conf" sub ShowZebOSconf { my($INPUT, $OUTPUT, $cmd) = @_; my($line) = (0); print STDERR " In ShowZebOSconf: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); if (!$line++) { ProcessHistory("ZEBOSCONF","","","#\n#/config/ZebOS.conf:\n"); } ProcessHistory("ZEBOSCONF","","","# $_") && next; } return(0); } # This routine parses "lsof -n -i :179" sub ShowZebOSsockets { my($INPUT, $OUTPUT, $cmd) = @_; my($line) = (0); print STDERR " In ShowZebOSsockets: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); if (!$line++) { ProcessHistory("ZEBOSSOCKETS","","","#\n#lsof -n -i :179:\n"); } ProcessHistory("ZEBOSSOCKETS","","","# $_") && next; } return(0); } # This routine processes a "tmsh -q list" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; my($lines) = 0; print STDERR " In WriteTerm: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if (/^\s*$/); # Ignore monitor down state, save the config as up. s/state down$/state up/i; # end of config - hopefully. f5 does not have a reliable end-of-config # tag. if (/^$prompt/) { $found_end++; last; } return(-1) if (/command authorization failed/i); $lines++; if (/(bind-pw|encrypted-password|user-password-encrypted|passphrase) / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","# $1 \n"); next; } if (/(auth-password-encrypted) / && ($filter_osc || $filter_pwds > 1)) { ProcessHistory("ENABLE","","","# $1 \n"); next; } # catch anything that wasnt matched above. ProcessHistory("","","","$_"); } if ($lines < 3) { printf(STDERR "ERROR: $host configuration appears truncated.\n"); $found_end = 0; return(-1); } return(0); } 1; rancid-3.13/lib/ios.pm.in000644 015615 000000 00000257212 13713052202 015265 0ustar00heaswheel000000 000000 package ios; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # ios.pm - Cisco IOS rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; our $proc; our $ios; our $found_version; our $found_env; our $found_diag; our $found_inventory; our $config_register; # configuration register value our %hwbuf; # defined in ShowContCbus our %hwmemc; # defined in ShowContCbus our %hwmemd; # defined in ShowContCbus our %hwucode; # defined in ShowContCbus our $supbootdisk; # skip sup-bootflash if sup-bootdisk # worked our $type; # device model, from ShowVersion our %ucode; # defined in ShowContCbus our $ssp; # SSP/SSE info, from ShowVersion our $sspmem; # SSP/SSE info, from ShowVersion our $C0; # output formatting control our $E0; our $H0; our $I0; our $DO_SHOW_VLAN; our $vss_show_module; # Use "show module switch" on 6k VSS systems @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { $proc = ""; $ios = "IOS"; $found_version = 0; $found_env = 0; $found_diag = 0; $found_inventory = 0; $config_register = undef; # configuration register value $supbootdisk = 0; # skip sup-bootflash if sup-bootdisk # worked $type = undef; # device model, from ShowVersion $ssp = 0; # SSP/SSE info, from ShowVersion $sspmem = undef; # SSP/SSE info, from ShowVersion $C0 = 0; # output formatting control $E0 = 0; $H0 = 0; $I0 = 0; $DO_SHOW_VLAN = 0; $vss_show_module = 0; # Use "show module switch" on 6k VSS systems # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","D0","!\n"); ProcessHistory("COMMENTS","keysort","F0","!\n"); ProcessHistory("COMMENTS","keysort","G0","!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/[>#]\s?exit$/) { $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#>]+[#>])/)[0]; $prompt =~ s/([][}{)(+\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; my($slave, $slaveslot); print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; if (/^$prompt/) { $found_version = 1; last}; next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(0) if ($found_version); # Only do this routine once return(-1) if (/(?:%|command)? authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } if (/^Slave in slot (\d+) is running/) { $slave = " Slave:"; $slaveslot = ", slot $1"; next; } if (/cisco ios.*(IOS-)?XE/i) { $ios = "XE"; } if (/^Application and Content Networking .*Software/) { $type = "CE"; } # treat the ACE like the Content Engines for matching endofconfig if (/^Cisco Application Control Software/) { $type = "CE"; } if (/^Cisco Storage Area Networking Operating System/) { $type = "SAN";} if (/^Cisco Nexus Operating System/) { $type = "NXOS";} /^Application and Content Networking Software Release /i && ProcessHistory("COMMENTS","keysort","F1", "!Image: $_") && next; /^Cisco Secure PIX /i && ProcessHistory("COMMENTS","keysort","F1", "!Image: $_") && next; # ASA "time-based licenses" - eg: bot-net /^This (PIX|platform) has a time-based license that will expire in\s+(\d{2,})\s+day.*$/ && ProcessHistory("COMMENTS","keysort","D1", "!This $1 has a time-based license\n") && next; # PIX 6 fail-over license, as in "This PIX has an Unrestricted (UR) # license." PIX 7 as "his platform has ..." /^This (PIX|platform) has an?\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","D1", "!$_") && next; /^(Cisco )?IOS .* Software,? \(([A-Za-z0-9_-]*)\), .*Version\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","F1", "!Image:$slave Software: $2, $3\n") && next; /^([A-Za-z-0-9_]*) Synced to mainline version: (.*)$/ && ProcessHistory("COMMENTS","keysort","F2", "!Image:$slave $1 Synced to mainline version: $2\n") && next; /^Compiled (.*)$/ && ProcessHistory("COMMENTS","keysort","F3", "!Image:$slave Compiled: $1\n") && next; /^ROM: (IOS \S+ )?(System )?Bootstrap.*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G1", "!ROM Bootstrap: $3\n") && next; if (/^Hardware:\s+(.*), (.* RAM), CPU (.*)$/) { ProcessHistory("COMMENTS","keysort","A1", "!Chassis type: $1 - a PIX\n"); ProcessHistory("COMMENTS","keysort","A2", "!CPU: $3\n"); ProcessHistory("COMMENTS","keysort","B1", "!Memory: $2\n"); } /^serial number:\s+(.*)$/i && ProcessHistory("COMMENTS","keysort","C1", "!Serial Number: $1\n") && next; # More PIX stuff /^Encryption hardware device\s+:\s+(.*)/ && ProcessHistory("COMMENTS","keysort","A3", "!Encryption: $1\n") && next; /^running activation key\s*:\s+(.*)/i && ProcessHistory("COMMENTS","keysort","D2", "!Key: $1\n") && next; # Flash on the PIX or FWSM (FireWall Switch Module) /^Flash(\s+\S+)+ \@ 0x\S+,\s+(\S+)/ && ProcessHistory("COMMENTS","keysort","B2", "!Memory: Flash $2\n") && next; # 3750 switch stacks next if (/^Model revision number/ && $type eq "3750"); next if (/^Motherboard/ && $type eq "3750"); next if (/^Power supply/ && $type eq "3750"); /^Model number : (.*)$/ && $type eq "3750" && ProcessHistory("COMMENTS","keysort","C2", "!Model number: $1\n") && next; /^System serial number : (.*)$/ && $type eq "3750" && ProcessHistory("COMMENTS","keysort","C2", "!Serial number: $1\n") && next; # CatOS 3500xl stuff /^system serial number\s*:\s+(.*)$/i && ProcessHistory("COMMENTS","keysort","C1", "!Serial Number: $1\n") && next; /^Model / && ProcessHistory("COMMENTS","keysort","C2", "!$_") && next; /^Motherboard / && ProcessHistory("COMMENTS","keysort","C3", "!$_") && next; /^Power supply / && ProcessHistory("COMMENTS","keysort","C4", "!$_") && next; /^Activation Key:\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","C2", "!$_") && next; /^ROM: \d+ Bootstrap .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G2", "!ROM Image: Bootstrap $1\n!\n") && next; /^ROM: .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G3","!ROM Image: $1\n") && next; /^BOOTFLASH: .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G4","!BOOTFLASH: $1\n") && next; /^BOOTLDR: .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G4","!BOOTLDR: $1\n") && next; /^System image file is "([^\"]*)", booted via (\S*)/ && # removed the booted source due to # CSCdk28131: cycling info in 'sh ver' # ProcessHistory("COMMENTS","keysort","F4","!Image: booted via $2, $1\n") && ProcessHistory("COMMENTS","keysort","F4","!Image: booted $1\n") && next; /^System image file is "([^\"]*)"$/ && ProcessHistory("COMMENTS","keysort","F5","!Image: $1\n") && next; # 2800 at least don't have a processor line if ((/(\S+(?:\sseries)?)\s+(?:\(([^)]+)\)\s+processor|\(revision[^)]+\)).*\s+with (\S+k) bytes/i) || (/isco\s+(\S+)\s+\(.+\)\s+with (\S+[kK]) bytes/)) { $proc = $1; my($cpu) = $2; my($mem) = $3; # the next line ought to be the more specific cpu info, grab it. # yet, some boards/IOS vers have a processor ID line between these # two. grrr. make sure we dont grab the "software" junk that # follows these lines by looking for "CPU at " or the 2600s # "processor: " unique string. there are undoubtedly many other # incantations. for a slave, we dont get this info, its just a # blank line. $_ = <$INPUT>; 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>; } # for 6500 sup-2t if ($cpu =~ /M8572/) { if (defined($cpu)) { s/^ CPU://; ProcessHistory("COMMENTS","keysort","A3", "!CPU: $cpu, $_"); } LINE: while (<$INPUT>) { last LINE if /^\s*$/; ProcessHistory("COMMENTS","keysort","A3", "!CPU: $_"); last LINE if /^\s*I-cache/; } undef ($cpu); } $_ = "" if (! /(cpu at |processor: |$cpu processor,)/i); tr/\015//d; s/implementation/impl/i; if ($_ !~ /^\s*$/) { chomp; s/^/, /; } if ($proc eq "CSC") { $type = "AGS"; } elsif ($proc eq "CSC4") { $type = "AGS+"; } elsif ($proc =~ /1900/) { $type = "1900"; } elsif ($proc =~ /2811/) { $type = "2800"; } elsif ($proc =~ /^ME-3400/) { $type = "ME3400"; } elsif ($proc =~ /^ME-C37/) { $type = "ME3700"; } elsif ($proc =~ /^ME-C65/) { $type = "ME6500"; } elsif ($proc =~ /C3750/) { $type = "3750"; } elsif ($proc =~ /^(AS)?25[12][12]/) { $type = "2500"; } elsif ($proc =~ /261[01]/ || $proc =~ /262[01]/) { $type = "2600"; } elsif ($proc =~ /WS-C29/) { $type = "2900XL"; } elsif ($proc =~ /WS-C355/) { $type = "3550"; } elsif ($proc =~ /WS-C35/) { $type = "3500XL"; } elsif ($proc =~ /^36[0246][0-9]/) { $type = "3600"; } elsif ($proc =~ /^37/) { $type = "3700"; } elsif ($proc =~ /WS-C375/) { $type = "3750"; } elsif ($proc =~ /^38/) { $type = "3800"; } elsif ($proc =~ /WS-C45/) { $type = "4500"; } elsif ($proc =~ /^AS5300/) { $type = "AS5300"; } elsif ($proc =~ /^AS5350/) { $type = "AS5350"; } elsif ($proc =~ /^AS5400/) { $type = "AS5400"; } elsif ($proc =~ /^ASR920/) { $type = "ASR920"; } elsif ($proc =~ /6000/) { $type = "6000"; } elsif ($proc eq "WK-C65") { $type = "6500"; } elsif ($proc =~ /WS-C6509/) { $type = "6500"; } elsif ($proc eq "RP") { $type = "7000"; } elsif ($proc eq "RP1") { $type = "7000"; } elsif ($proc =~ /720[246]/) { $type = "7200"; } elsif ($proc =~ /^73/) { $type = "7300"; } elsif ($proc eq "RSP7000") { $type = "7500"; } elsif ($proc =~ /RSP\d/) { $type = "7500"; } elsif ($proc =~ /OSR-76/) { $type = "7600"; } elsif ($proc =~ /CISCO76/) { $type = "7600"; } elsif ($proc =~ /1200[48]\/(GRP|PRP)/ || $proc =~ /1201[26]\/(GRP|PRP)/) { $type = "12000"; } elsif ($proc =~ /1201[26]-8R\/(GRP|PRP)/) { $type = "12000"; } elsif ($proc =~ /1240[48]\/(GRP|PRP)/ || $proc =~ /1241[06]\/(GRP|PRP)/) { $type = "12400"; } elsif ($proc =~ /AIR-L?AP1[12][1234][[1234]/) { $type="Aironet"; } else { $type = $proc; } print STDERR "TYPE = $type\n" if ($debug); ProcessHistory("COMMENTS","keysort","A1", "!Chassis type:$slave $proc\n"); ProcessHistory("COMMENTS","keysort","B1", "!Memory:$slave main $mem\n"); if (defined($cpu)) { ProcessHistory("COMMENTS","keysort","A3", "!CPU:$slave $cpu$_$slaveslot\n"); } next; } if (/(\S+) Silicon\s*Switch Processor/) { if (!$C0) { $C0 = 1; ProcessHistory("COMMENTS","keysort","C0","!\n"); } ProcessHistory("COMMENTS","keysort","C2","!SSP: $1\n"); $ssp = 1; $sspmem = $1; next; } /^(\d+[kK]) bytes of multibus/ && ProcessHistory("COMMENTS","keysort","B2", "!Memory: multibus $1\n") && next; /^(\d+[kK]) bytes of (non-volatile|NVRAM)/ && ProcessHistory("COMMENTS","keysort","B3", "!Memory: nvram $1\n") && next; /^(\d+[kK]) bytes of (flash memory|processor board System flash|ATA CompactFlash)/ && ProcessHistory("COMMENTS","keysort","B5","!Memory: flash $1\n") && next; /^(\d+[kK]) bytes of .*flash partition/ && ProcessHistory("COMMENTS","keysort","B6", "!Memory: flash partition $1\n") && next; /^(\d+[kK]) bytes of Flash internal/ && ProcessHistory("COMMENTS","keysort","B4", "!Memory: bootflash $1\n") && next; if (/^(\d+[kK]) bytes of (Flash|ATA)?.*PCMCIA .*(slot|disk) ?(\d)/i) { ProcessHistory("COMMENTS","keysort","B7", "!Memory: pcmcia $2 $3$4 $1\n"); next; } if (/^(\d+[kK]) bytes of (slot|disk)(\d)/i) { ProcessHistory("COMMENTS","keysort","B7", "!Memory: pcmcia $2$3 $1\n"); next; } if (/^(\d+[kK]) bytes of physical memory/i) { ProcessHistory("COMMENTS","keysort","B1", "!Memory: physical $1\n"); next; } if (/^WARNING/) { if (!$I0) { $I0 = 1; ProcessHistory("COMMENTS","keysort","I0","!\n"); } ProcessHistory("COMMENTS","keysort","I1","! $_"); } if (/^Configuration register is (.*)$/) { $config_register = $1; next; } if (/^Configuration register on node \S+ is (.*)$/) { $config_register = $1 if (length($config_register) < 1); next; } } return(0); } # This routine parses "show activation-key" on ASA sub ShowActivationKey { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowMTU: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } if (/^(failover|licensed) .* for this platform:/i || /^active .* activation key/i) { ProcessHistory("COMMENTS","keysort","LICENSE","! $_"); # parse license features/permanents/etc until an empty line while (<$INPUT>) { tr/\015//d; goto OUT if (/^$prompt/); # should not occur s/\s*$//; # trim trailing WS # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } if (/^\s*$/) { ProcessHistory("COMMENTS","keysort","LICENSE","!\n"); last; } if (/^([^:]+: \S+\s+)(.*)/) { my($L) = $1; my($T) = $2; if ($T !~ /perpetual/i) { $T = ""; } ProcessHistory("COMMENTS","keysort","LICENSE","! $L $T\n"); } else { ProcessHistory("COMMENTS","keysort","LICENSE","! $_\n"); } } next; } ProcessHistory("COMMENTS","keysort","LICENSE","! $_"); } OUT:ProcessHistory("COMMENTS","keysort","LICENSE","!\n"); return(0); } # This routine parses "show cellular 0 profile" sub ShowCellular { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowCellular: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); # Ignore the PDP address and assigned DNS servers next if (/^pdp (ipv6 )?address/i); next if (/^\s*(primary|secondary) DNS (ipv6 )?address/i); ProcessHistory("COMMENTS","keysort","CELL","!CELL: $_"); } ProcessHistory("COMMENTS","keysort","CELL","!\n"); return(0); } # This routine parses "show switch detail" sub ShowDetail { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowDetail: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); ProcessHistory("COMMENTS","keysort","IO","!STACK: $_"); } ProcessHistory("COMMENTS","keysort","IO","!\n"); return(0); } # This routine parses "show license" & "show license udi" sub ShowLicense { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowLicense: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(0) if (/% no licensable udi in the system/i); # show udi on old box return(0) if (/% license not supported on this device/i);# show lic on old box return(0) if (/% incomplete command/i); # show lic on old XE box return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); return(-1) if (/unable to retrieve license info/i); # filter the BS from license broker next if (/(renewal attempt|communication attempt):/i); next if (/next registration attempt:/i); # timestamp next if (/(period used:|requested time:)/i); # show lic feature if (/(^\s*(evaluation )?period (left|remaining):\s*)\d+/i) { ProcessHistory("COMMENTS","keysort","LICENSE","! $1\n"); next; } # drop license counts next if (/license usage:/i); if (/(.*)count status/i) { my($hdr) = $1; my($len) = length($hdr); $hdr =~ s/\s*$//; ProcessHistory("COMMENTS", "keysort", "LICENSE", "! $hdr\n"); while (<$INPUT>) { tr/\015//d; return(0) if (/^$prompt/); s/^(.{1,$len}).*/$1/; ProcessHistory("COMMENTS", "keysort", "LICENSE", "! $_"); } next; } ProcessHistory("COMMENTS","keysort","LICENSE","! $_"); } ProcessHistory("COMMENTS","keysort","LICENSE","!\n"); return(0); } # This routine parses "showMTU" sub ShowMTU { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowMTU: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); if (/System MTU size is (\d+) bytes/) { ProcessHistory("COMMENTS","keysort","IO","!MTU: $1\n"); next; } if (/System Jumbo MTU size is (\d+) bytes/) { ProcessHistory("COMMENTS","keysort","IO","!MTU-Jumbo: $1\n"); next; } if (/Routing MTU size is (\d+) bytes/) { ProcessHistory("COMMENTS","keysort","IO","!MTU-Routing: $1\n"); next; } # XE version if (/Global Ethernet MTU is (\d+) bytes./) { ProcessHistory("COMMENTS","keysort","IO","!MTU-Global: $1\n"); next; } if (/On next reload, (.*)/) { ProcessHistory("COMMENTS","keysort","IO","!MTU-Reload: $1\n"); next; } } ProcessHistory("COMMENTS","keysort","IO","!\n"); return(0); } # This routine parses "show sdm prefer" sub ShowSDM { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSDM: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); if (/current template is "(.+)" template/) { ProcessHistory("COMMENTS","keysort","IO","!SDM Template: $1\n"); next; } if (/current template is the (\S+) template/) { ProcessHistory("COMMENTS","keysort","IO","!SDM Template: $1\n"); next; } # XE version if (/This is the (\S+.*) template/) { ProcessHistory("COMMENTS","keysort","IO","!SDM Template: $1\n"); next; } if (/On next reload, template will be "(.+)" template/) { ProcessHistory("COMMENTS","keysort","IO","!SDM Template-Reload: $1\n"); next; } if (/(current template is|next reload)/) { ProcessHistory("COMMENTS","keysort","IO","!SDM: $_"); } } ProcessHistory("COMMENTS","keysort","IO","!\n"); return(0); } # This routine parses "show redundancy" sub ShowRedundancy { my($INPUT, $OUTPUT, $cmd) = @_; my($slave, $slaveslot); print STDERR " In ShowRedundancy: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } if (/^Version information for secondary in slot (\d+):/) { $slave = " Slave:"; $slaveslot = ", slot $1"; next; } /^IOS .* Software \(([A-Za-z0-9_-]*)\), .*Version\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","F1", "!Image:$slave Software: $1, $2\n") && next; /^Compiled (.*)$/ && ProcessHistory("COMMENTS","keysort","F3", "!Image:$slave Compiled: $1\n") && next; } return(0); } # This routine parses "show IDprom" sub ShowIDprom { my($INPUT, $OUTPUT, $cmd) = @_; my($tmp); print STDERR " In ShowIDprom: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } /FRU is .(.*)\'/ && ($tmp = $1); /Product Number = .(.*)\'/ && ProcessHistory("COMMENTS","keysort","D0", "!Catalyst Chassis type: $1, $tmp\n"); /Serial Number = .([0-9A-Za-z]+)/ && ProcessHistory("COMMENTS","keysort","D1", "!Catalyst Chassis S/N: $1\n"); /Manufacturing Assembly Number = .([-0-9]+)/ && ($tmp = $1); /Manufacturing Assembly Revision = .(.*)\'/ && ($tmp .= ", rev " . $1); /Hardware Revision = ([0-9.]+)/ && ProcessHistory("COMMENTS","keysort","D2", "!Catalyst Chassis assembly: $tmp, ver $1\n"); } return(0); } # This routine parses "show install active" sub ShowInstallActive { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInstallActive: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } ProcessHistory("COMMENTS","keysort","F5","!Image: $_") && next; } return(0); } # This routine parses "show env all" sub ShowEnv { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowEnv: $_" if ($debug); while (<$INPUT>) { tr/\015//d; if (/^$prompt/) { $found_env = 1; last}; next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(0) if ($found_env); # Only do this routine once return(-1) if (/(?:%|command)? authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } # remove "Fan n RPM is #" on 7201, 7301 next if (/ RPM is /); if (!$E0) { $E0 = 1; ProcessHistory("COMMENTS","keysort","E0","!\n"); } if (/^Arbiter type (\d), backplane type (\S+)/) { if (!$C0) { $C0 = 1; ProcessHistory("COMMENTS","keysort","C0","!\n"); } ProcessHistory("COMMENTS","keysort","C1", "!Enviromental Arbiter Type: $1\n"); ProcessHistory("COMMENTS","keysort","A2", "!Chassis type: $2 backplane\n"); next; } # AC revision from UBRs and some others fluctuates s/is AC Revision [A-F]0\./is AC./; /^Power Supply Information$/ && next; /^\s*Power Module\s+Voltage\s+Current$/ && next; /^\s*(Power [^:\n]+)$/ && ProcessHistory("COMMENTS","keysort","E1","!Power: $1\n") && next; /^\s*(Lower Power .*)/i && ProcessHistory("COMMENTS","keysort","E2","!Power: $1\n") && next; /^\s*(redundant .*)/i && ProcessHistory("COMMENTS","keysort","E2","!Power: $1\n") && next; /^\s*((RPS|power-supply) (\d|is) .*)/i && ProcessHistory("COMMENTS","keysort","E2","!Power: $1\n") && next; /^\s*FAN \d RPM is \d+$/ && next; # Fan speed on ASR901 # Fan 1 Operation: Normal, is running at 40 percent speed /^(\s*Fan \d Operation: \S+), .*$/ && ProcessHistory("COMMENTS","keysort","E3","!FAN: $1\n") && next; if (/^\s*((FAN|fan-tray) (\d|is) .*)/i) { my($tmp) = ($1); $tmp =~ s/, \S+ speed setting//; $tmp =~ s/, is running at \d{1,3}\s* percent speed//; ProcessHistory("COMMENTS","keysort","E3","!FAN: $tmp\n"); next; } } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show hw-programmable all" sub ShowHWProgrammable { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowPlatform: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(0) if (/% incomplete command/i); # every platform is different return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); # return(1) if ($type !~ /^12[40]/); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } /^$/ && next; # XXX parsing for show platform, which has CPLD info on some platforms # but is inconsistent across platforms. #if (/^(.*) insert time.*$/i) { # my($len) = length($1); # ProcessHistory("PLATFORM","","", "! $1\n"); # # while (<$INPUT>) { # tr/\015//d; # return(0) if (/^$prompt/); # # s/^(.{1,$len}).*/$1/; # ProcessHistory("PLATFORM","","", "! $_"); # last if (/^$/); # } # next; #} ProcessHistory("HWP","","", "! $_"); } ProcessHistory("HWP","","", "!\n"); return(0); } # This routine parses "show rsp chassis-info" for the rsp # This will create arrays for hw info. sub ShowRSP { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowRSP: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); # return(1) if ($type !~ /^12[40]/); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } /^$/ && next; /^\s+Chassis model: (\S+)/ && ProcessHistory("COMMENTS","keysort","D1", "!RSP Chassis model: $1\n") && next; /^\s+Chassis S\/N: (.*)$/ && ProcessHistory("COMMENTS","keysort","D2", "!RSP Chassis S/N: $1\n") && next; } return(0); } # This routine parses "show gsr chassis-info" for the gsr # This will create arrays for hw info. sub ShowGSR { my($INPUT, $OUTPUT, $cmd) = @_; # Skip if this is not a 1200n. print STDERR " In ShowGSR: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); # return(1) if ($type !~ /^12[40]/); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } /^$/ && next; /^\s+Chassis: type (\S+) Fab Ver: (\S+)/ && ProcessHistory("COMMENTS","keysort","D1", "!GSR Chassis type: $1 Fab Ver: $2\n") && next; /^\s+Chassis S\/N: (.*)$/ && ProcessHistory("COMMENTS","keysort","D2", "!GSR Chassis S/N: $1\n") && next; /^\s+PCA: (\S+)\s*rev: (\S+)\s*dev: \S+\s*HW ver: (\S+)$/ && ProcessHistory("COMMENTS","keysort","D3", "!GSR Backplane PCA: $1, rev $2, ver $3\n") && next; /^\s+Backplane S\/N: (\S+)$/ && ProcessHistory("COMMENTS","keysort","D4", "!GSR Backplane S/N: $1\n") && next; } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show boot" sub ShowBoot { my($INPUT, $OUTPUT, $cmd) = @_; # Pick up boot variables if 7000/7200/7500/12000/2900/3500; # otherwise pick up bootflash. print STDERR " In ShowBoot: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(1) if (/Ambiguous command/i); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(-1) if (/(?:%|command)? authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } next if /CONFGEN variable/; if (!$H0) { $H0 = 1; ProcessHistory("COMMENTS","keysort","H0","!\n"); } if ($type !~ /^(12[04]|7)/) { if ($type !~ /^(29|35)00/) { ProcessHistory("COMMENTS","keysort","H2","!BootFlash: $_"); } else { ProcessHistory("COMMENTS","keysort","H1","!Variable: $_"); } } elsif (/(variable|register)/) { ProcessHistory("COMMENTS","keysort","H1","!Variable: $_"); } } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show flash" sub ShowFlash { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowFlash: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # skip if this is 7000, 7200, 7500, 12000, or IOS-XE; else we have # redundant data from dir /all slot0: return(1) if ($type =~ /^(12[40]|7)/); return(1) if ($ios eq "XE"); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } # Drop these files entirely. /\s+(private-multiple-fs|multiple-fs|LISP-MapCache-IPv\S+|nv_hdr)$/ && next; if (/(dhcp_[^. ]*\.txt|license_evlog|vlan\.dat|sflog|snooping)/ || /(LOCAL-CA-SERVER(?:[^\s]*))\s*$/ || /(smart-log\/agentlog|syslog)\s*$/ || /(log\/(?:ssp_tz\/)?[^. ]+\.log(?:\.[0-9]+\.gz)?)\s*$/) { # filter frequently changing files (dhcp & vlan database, logs) from flash # change from: # 537549598 38354 Feb 19 2019 20:59:32 log/ssp_tz/ssp_tz.log.1.gz # 9 660 Jan 15 2011 20:43:54 vlan.dat # 9 660 Jan 15 2011 20:43:54 +00:00 vlan.dat # to: # log/ssp_tz/ssp_tz.log.1.gz # vlan.dat # vlan.dat if (/(\s*\d+)(\s+[-drwx]+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+ .\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s"; $_ = sprintf($fmt, "", $a, "", $c, "", $rem); } elsif (/(\s*\d+)(\s+[-drwx]+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s"; $_ = sprintf($fmt, "", $a, "", $c, "", $rem); } elsif (/(\s*\d+)(\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+ .\d+:\d+)/) { # System flash directory: # File Length Name/status # 1 12138448 c3640-ik9s-mz.122-40.bin my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s"; $_ = sprintf($fmt, "", $a, "", $c, "", $rem); } elsif (/(\s*\d+)(\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s"; $_ = sprintf($fmt, "", $a, "", $c, "", $rem); } /\s+(\S+)\s*$/ && ProcessHistory("FLASH","keysort","$1","!Flash: $_") && next; } elsif (/(running-config-archive-)\S+\s*$/) { # filter config archives from flash # change from: # 9 660 Jan 15 2011 20:43:54 running-config-archive-Jul--1-16-50-27.123-113 # 9 660 Jan 15 2011 20:43:54 +00:00 running-config-archive-Jul--1-16-50-27.123-113 # to: # running-config-archive- # running-config-archive- my($arc) = $1; if (/(\s*\d+)(\s+[-drwx]+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+ .\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s%s\n"; $_ = sprintf($fmt, "", $a, "", $c, "", $arc , ""); } elsif (/(\s*\d+)(\s+[-drwx]+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s%s\n"; $_ = sprintf($fmt, "", $a, "", $c, "", $arc, ""); } elsif (/(\s*\d+)(\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+ .\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s%s\n"; $_ = sprintf($fmt, "", $a, "", $c, "", $arc, ""); } elsif (/(\s*\d+)(\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%-". $fnl ."s%s%-". $szl ."s%s%-". $dtl ."s%s%s\n"; $_ = sprintf($fmt, "", $a, "", $c, "", $arc, ""); } /\s+(\S+)\s*$/ && ProcessHistory("FLASH","keysort","$1","!Flash: $_") && next; } elsif (/^(\s*\d+)(\s+[-drwx]+\s+\d+\s+\w+ \d+\s+\d+ \d+:\d+:\d+ .\d+:\d+\s+)(\S+)/ || /^(\s*\d+)(\s+[-drwx]+\s+\d+\s+\w+ \d+\s+\d+ \d+:\d+:\d+\s+)(\S+)/ || /^(\s*\d+)(\s+\d+\s+\w+ \d+\s+\d+ \d+:\d+:\d+ .\d+:\d+\s+)(\S+)/ || /^(\s*\d+)(\s+\d+\s+\w+ \d+\s+\d+ \d+:\d+:\d+\s+)(\S+)/) { my($fmt) = "%-". length($1) ."s%s%s\n"; $_ = sprintf($fmt, "", $2, $3); ProcessHistory("FLASH","keysort","$3","!Flash: $_") && next; } if (/(\d+) bytes (available|total) \((\d+) bytes (free|used)(\/\s+% free)?\)/) { my($avail); my($preamble) = ""; if ($2 eq "available") { $avail = $1; } else { $preamble = "$1 bytes total"; if ($4 eq "free") { $avail = $3; } else { $avail = $1 - $3; } } if ($avail >= (1024 * 1024 * 1024)) { $avail = int($avail / (1024 * 1024 * 1024)); $_ = "$avail GB free\n"; } elsif ($avail >= (1024 * 1024)) { $avail = int($avail / (1024 * 1024)); $_ = "$avail MB free\n"; } elsif ($avail >= (1024)) { $avail = int($avail / 1024); $_ = "$avail KB free\n"; } elsif ($avail > 0) { $_ = "< 1KB free\n"; } else { $_ = "0 bytes free\n"; } if (length($preamble)) { chomp($_); $_ = "$preamble ($_)\n"; } } ProcessHistory("FLASH","","","!Flash: $_"); } ProcessHistory("","","","!\n"); return; } # This routine parses "dir /all ((disk|slot)N|bootflash|nvram):" sub DirSlotN { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DirSlotN: $_" if ($debug); my($dev) = (/\s([^\s]+):/); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(1) if (/(No such device|Error Sending Request)/i); return(1) if (/\%Error: No such file or directory/); return(1) if (/No space information available/); # Corrupt flash /\%Error calling getdents / && ProcessHistory("FLASH","","","!Flash: $dev: $_") && next; return(-1) if (/\%Error calling/); return(-1) if (/(: device being squeezed|ATA_Status time out)/i); # busy return(-1) if (/\%Error opening \S+:\S+ \(Device or resource busy\)/i); return(-1) if (/(?:%|command)? authorization failed/i); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } # skip dir sup-bootflash if dir sup-bootdisk was successful, duplicates if ($cmd =~ / sup-bootdisk/) { $supbootdisk++; } elsif ($supbootdisk && $cmd =~ / sup-bootflash/) { return(0); } # Drop LISP cache. /\s+LISP-MapCache-IPv\S+$/ && next; # Filter internal file used by ISSU (In-Service Software Upgrade) # on dual RP ASR systems next if (/\.issu_loc_lock\s*$/); # vASA nonsense # 9 file(s) total size: 252854822 bytes next if (/\d+ file\S+ total size: \d+ bytes/i); # filter frequently changing files (dhcp & vlan database) # change from: # 9 -rw- 660 Jan 15 2011 20:43:54 vlan.dat # 9 -rw- 660 Jan 15 2011 20:43:54 +00:00 vlan.dat # to: # -rw- vlan.dat # -rw- vlan.dat if (/(dhcp_[^. ]*\.txt|vlan\.dat|sflog|snooping|syslog)\s*$/ || /(tracelogs|throughput_monitor_params|underlying-config)\s*$/) { if (/(\s*\d+\s+)(\S+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+ .\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%s%-". $szl ."s%s%-". $dtl ."s%s"; $_ = sprintf($fmt, $a, "", $c, "", $rem); } elsif (/(\s*\d+\s+)(\S+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%s%-". $szl ."s%s%-". $dtl ."s%s"; $_ = sprintf($fmt, $a, "", $c, "", $rem); } elsif (/(\s*\d+\s+)(\S+\s+)(\d+)(\s+)/i) { # 32771 -rw- 24520 underlying-config my($fn, $a, $sz, $dt, $rem) = ($1, $2, $3, $4, $'); my($fnl, $szl) = (length($fn), length($sz)); my($fmt) = "%s%-". $szl ."s%s%s"; $_ = sprintf($fmt, $a, "", $dt, $rem); } /\s+(\S+)\s*$/ && ProcessHistory("FLASH","keysort","$1","!Flash: $dev: $_") && next; } elsif (/(running-config-archive-)\S+\s*$/) { my($arc) = $1; # filter frequently changing files of the config archive feature # change from: # 9 -rw- 660 Jan 15 2011 20:43:54 running-config-archive-Jul--1-16-50-27.123-113 # 9 -rw- 660 Jan 15 2011 20:43:54 +00:00 running-config-archive-Jul--1-16-50-27.123-113 # to: # -rw- running-config-archive-Jul--1-16-50-27.123-113 # -rw- running-config-archive-Jul--1-16-50-27.123-113 if (/(\s*\d+\s+)(\S+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+ .\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%s%-". $szl ."s%s%-". $dtl ."s%s%s\n"; $_ = sprintf($fmt, $a, "", $c, "", $arc, ""); } elsif (/(\s*\d+\s+)(\S+\s+)(\d+)(\s+)(\w+ \d+\s+\d+ \d+:\d+:\d+)/) { my($fn, $a, $sz, $c, $dt, $rem) = ($1, $2, $3, $4, $5, $'); my($fnl, $szl, $dtl) = (length($fn), length($sz), length($dt)); my($fmt) = "%s%-". $szl ."s%s%-". $dtl ."s%s%s\n"; $_ = sprintf($fmt, $a, "", $c, "", $arc, ""); } /\s+(\S+)\s*$/ && ProcessHistory("FLASH","keysort","$1","!Flash: $dev: $_") && next; } else { # drop file number (from the various formats): # 3 -rw- 1011 ifIndex-table # 9 -rw- 660 Jan 15 2011 20:43:54 vlan.dat # 16 -rw- 5437 Jan 16 2016 02:22:32 +00:00 licenses # 114 -rwx 92 13:22:08 Aug 15 2019 .boot_string (ASA) if (/(\s*\d+\s+)(\S+\s+\d+\s+\w+ \d+\s+\d+ \d+:\d+:\d+ .\d+:\d+)/ || /(\s*\d+\s+)(\S+\s+\d+\s+\w+ \d+\s+\d+ \d+:\d+:\d+)/ || /(\s*\d+\s+)(\S+\s+\d+\s+\s+\S+)/ || /(\s*\d+\s+)(\S+\s+\d+\s+\d+:\d+:\d+ \w+ \d+\s+\d+\s+\S+)/) { #my($fn, $a, $rem) = ($1, $2, $'); #my($fnl) = length($fn); #my($fmt) = "%-". $fnl ."s%s%s\n"; #$_ = sprintf($fmt, "", $a, $rem); $_ = $2 . $'; /\s+(\S+)\s*$/ && ProcessHistory("FLASH","keysort","$1","!Flash: $dev: $_") && next; } } # XE: 822083584 bytes total (821081600 bytes free) if (/^\s*(\d+) bytes total\s+\((\d+) bytes free\)/i) { ProcessHistory("FLASH","","","!Flash: $dev: " . diskszsummary($1, $2) . "\n"); next; } # vASA: 8571076608 bytes total (8306561024 bytes free/96% free) if (/^\s*(\d+) bytes total \((\d+) bytes free\/\d+% free\)/) { ProcessHistory("FLASH","","","!Flash: $dev: " . diskszsummary($1, $2) . "\n"); next; } ProcessHistory("FLASH","","","!Flash: $dev: $_"); } ProcessHistory("","","","!\n"); return(0); } # This routine parses "show controllers" sub ShowContAll { my($INPUT, $OUTPUT, $cmd) = @_; my($INT); # Skip if this is a 70[01]0, 7500, or 12000. print STDERR " In ShowContAll: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); # return(1) if ($type =~ /^(12[40]|7[05])/); return(-1) if (/(?:%|command)? authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } if (/^Interface ([^ \n(]*)/) { $INT = "$1, "; next; } /^(BRI unit \d)/ && ProcessHistory("INT","","","!Interface: $1\n") && next; /^LANCE unit \d, NIM/ && ProcessHistory("INT","","","!Interface: $_") && next; /^(LANCE unit \d)/ && ProcessHistory("INT","","","!Interface: $1\n") && next; /(Media Type is \S+),/ && ProcessHistory("INT","","","!\t$1\n"); if (/(M\dT[^ :]*:) show controller:$/) { my($ctlr) = $1; $_ = <$INPUT>; tr/\015//d; s/ subunit \d,//; ProcessHistory("INT","","","!Interface: $ctlr $_"); } if (/^(\S+) : show controller:$/) { my($ctlr) = $1; $_ = <$INPUT>; tr/\015//d; s/ subunit \d,//; ProcessHistory("INT","","","!Interface: $ctlr: $_"); } /^(HD unit \d), idb/ && ProcessHistory("INT","","","!Interface: $1\n") && next; /^HD unit \d, NIM/ && ProcessHistory("INT","","","!Interface: $_") && next; /^buffer size \d+ HD unit \d, (.*)/ && ProcessHistory("INT","","","!\t$1\n") && next; /^AM79970 / && ProcessHistory("INT","","","!Interface: $_") && next; /^buffer size \d+ (Universal Serial: .*)/ && ProcessHistory("INT","","","!\t$1\n") && next; # Remove dynamic addresses like: # !Interface: FastEthernet0/0, GT96K FE ADDR: 62AFB684, FASTSEND: 6 1579E4C, MCI_INDEX: 0 /^ *Hardware is (.*?)($| ADDR: .*| at 0x.*)/ && ProcessHistory("INT","","","!Interface: $INT$1\n") && next; /^Hardware is (.*)/ && ProcessHistory("INT","","","!Interface: $INT$1\n") && next; /^(QUICC Serial unit \d),/ && ProcessHistory("INT","","","!$1\n") && next; /^QUICC Ethernet .*/ && ProcessHistory("INT","","","!$_") && next; /^DTE .*\.$/ && next; /^(cable type :.*),/ && ProcessHistory("INT","","","!\t$1\n") && next; /^(.* cable.*), received clockrate \d+$/ && ProcessHistory("INT","","","!\t$1\n") && next; /^.* cable.*$/ && ProcessHistory("INT","","","!\t$_") && next; } return(0); } # This routine parses "show controllers cbus" # Some of this is printed out in ShowDiagbus. sub ShowContCbus { my($INPUT, $OUTPUT, $cmd) = @_; my($interface, $slot); # Skip if this is not a 7000 or 7500. print STDERR " In ShowContCbus: $_" if ($debug); while (<$INPUT>) { my(%board, %hwver); tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); #return(1) if ($type !~ /^7[05]0/); return(-1) if (/(?:%|command)? authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } if (/^\s*slot(\d+): ([^,]+), hw (\S+), sw (\S+), ccb/) { $slot = $1; $board{$slot} = $2; $hwver{$slot} = $3; $hwucode{$slot} = $4; } elsif (/^\s*(\S+) (\d+), hardware version (\S+), microcode version (\S+)/) { $slot = $2; $board{$slot} = $1; $hwver{$slot} = $3; $hwucode{$slot} = $4; } elsif (/(Microcode .*)/) { $ucode{$slot} = $1; } elsif (/(software loaded .*)/) { $ucode{$slot} = $1; } elsif (/(\d+) Kbytes of main memory, (\d+) Kbytes cache memory/) { $hwmemd{$slot} = $1; $hwmemc{$slot} = $2; } elsif (/byte buffers/) { chop; s/^\s*//; $hwbuf{$slot} = $_; } elsif (/Interface (\d+) - (\S+ \S+),/) { $interface = $1; ProcessHistory("HW","","", "!\n!Int $interface: in slot $slot, named $2\n"); next; } elsif (/(\d+) buffer RX queue threshold, (\d+) buffer TX queue limit, buffer size (\d+)/) { ProcessHistory("HW","","","!Int $interface: rxq $1, txq $2, bufsize $3\n"); next; } } return(0); } # This routine parses "show debug" sub ShowDebug { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowDebug: $_" if ($debug); my($lines) = 0; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); # ASAv produce this error occasionally return(-1) if (/unable to retrieve licensing debug info/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } /Load for / && next; /^Time source is / && next; /^No matching debug flags set$/ && next; /^No debug flags set$/ && next; ProcessHistory("COMMENTS","keysort","J1","!DEBUG: $_"); $lines++; } if ($lines) { ProcessHistory("COMMENTS","keysort","J0","!\n"); } return(0); } # This routine parses "show diagbus" # This will create arrays for hw info. sub ShowDiagbus { my($INPUT, $OUTPUT, $cmd) = @_; my($board, $slot); # Skip if this is not a 7000, 70[01]0, or 7500. print STDERR " In ShowDiagbus: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); #return(1) if ($type !~ /^7[05]/); next if (/^\s+\^$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } if (/^\s*Slot (\d+):/i) { $slot = $1; next; } elsif (/^\s*Slot (\d+) \(virtual\):/i) { $slot = $1; next; } elsif (/^\s*(.*Processor.*|.*controller|.*controler|.*Chassis Interface)(, FRU\s?:.*)?, HW rev (\S+), board revision (\S+)/i) { $board = $1; my($hwver) = $3; my($boardrev) = $4; if ($board =~ /Processor/) { if ($board =~ /7000 Route\/Switch/) { $board = "RSP7000"; } elsif ($board =~ /Route\/Switch Processor (\d)/) { $board = "RSP$1"; } elsif ($board =~ /Route/) { $board = "RP"; } elsif ($board =~ /Silicon Switch/) { $board = "SSP"; } elsif ($board =~ /Switch/) { $board = "SP"; $board = "SSP $sspmem" if $ssp; } elsif ($board =~ /ATM/) { $board = "AIP"; } } elsif ($board =~ /(.*) controller/i) { $board = $1; } # hwucode{$slot} defined in ShowContCbus if (defined($hwucode{$slot})) { ProcessHistory("SLOT","","","!\n!Slot $slot/$board: hvers $hwver rev $boardrev ucode $hwucode{$slot}\n"); } else { ProcessHistory("SLOT","","","!\n!Slot $slot/$board: hvers $hwver rev $boardrev\n"); } # These are also from the ShowContCbus ProcessHistory("SLOT","","","!Slot $slot/$board: $ucode{$slot}\n") if (defined $ucode{$slot}); ProcessHistory("SLOT","","","!Slot $slot/$board: memd $hwmemd{$slot}, cache $hwmemc{$slot}\n") if ((defined $hwmemd{$slot}) && (defined $hwmemc{$slot})); ProcessHistory("SLOT","","","!Slot $slot/$board: $hwbuf{$slot}\n") if (defined $hwbuf{$slot}); next; } /Serial number: (\S+)\s*Part number: (\S+)/ && ProcessHistory("SLOT","","", "!Slot $slot/$board: part $2, serial $1\n") && next; /^\s*Controller Memory Size: (.*)$/ && ProcessHistory("SLOT","","","!Slot $slot/$board: $1\n") && next; if (/PA Bay (\d) Information/) { my($pano) = $1; if ("PA" =~ /$board/) { my($s,$c) = split(/\//,$board); $board = "$s/$c/PA $pano"; } else { $board =~ s/\/PA \d//; $board = "$board/PA $pano"; } next; } /\s+(.*) (IP|PA), (\d) ports?,( \S+,)? (FRU\s?: )?(\S+)/ && ProcessHistory("SLOT","","","!Slot $slot/$board: type $6, $3 ports\n") && next; /\s+(.*) (IP|PA)( \(\S+\))?, (\d) ports?/ && ProcessHistory("SLOT","","","!Slot $slot/$board: type $1$3, $4 ports\n") && next; /^\s*HW rev (\S+), Board revision (\S+)/ && ProcessHistory("SLOT","","","!Slot $slot/$board: hvers $1 rev $2\n") && next; /Serial number: (\S+)\s*Part number: (\S+)/ && ProcessHistory("SLOT","","","!Slot $slot/$board: part $2, serial $1\n") && next; } return(0); } # This routine parses "show diag" for the gsr, 7200, 3700, 3600, 2600. # This will create arrays for hw info. sub ShowDiag { my($INPUT, $OUTPUT, $cmd) = @_; my($fn, $slot, $WIC); print STDERR " In ShowDiag: $_" if ($debug); while (<$INPUT>) { REDUX: tr/\015//d; if (/^$prompt/) { $found_diag = 1; last}; next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(0) if ($found_diag); # Only do this routine once return(-1) if (/(?:%|command)? authorization failed/i); /^$/ && next; # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } s/Port Packet Over SONET/POS/; if (/^\s*SLOT\s+(\d+)\s+\((.*)\): (.*)/) { $slot = $1; ProcessHistory("SLOT","","","!\n"); ProcessHistory("SLOT","keysort","A","!Slot $slot: $3\n"); next; } if (/^\s*NODE\s+(\S+) : (.*)/) { $slot = $1; ProcessHistory("SLOT","","","!\n"); ProcessHistory("SLOT","keysort","A","!Slot $slot: $2\n"); next; } if (/^\s*PLIM\s+(\S+) : (.*)/) { $slot = $1 . " PLIM"; ProcessHistory("SLOT","","","!\n"); ProcessHistory("SLOT","keysort","A","!Slot $slot: $2\n"); next; } if (/^\s*RACK\s+(\S+) : (.*)/) { $slot = "Rack/" . $1; ProcessHistory("SLOT","","","!\n"); ProcessHistory("SLOT","keysort","A","!Slot $slot: $2\n"); next; } if (/^\s+MAIN:\s* type \S+,\s+(.*)/) { my($part) = $1; $_ = <$INPUT>; if (/^\s+(HW version|Design Release) (\S+)\s+S\/N (\S+)/i) { ProcessHistory("SLOT","keysort","AM","!Slot $slot/MAIN: part $part, serial $3\n"); ProcessHistory("SLOT","keysort","AM","!Slot $slot/MAIN: hvers $2\n"); } else { ProcessHistory("SLOT","keysort","AM","!Slot $slot/MAIN: part $part\n"); goto REDUX; } next; } if (/^\s+MAIN:\s* board type \S+$/) { $_ = <$INPUT>; tr/\015//d; if (/^\s+(.+)$/) { my($part) = $1; $_ = <$INPUT>; tr/\015//d; if (/^\s+dev (.*)$/) { my($dev) = $1; $_ = <$INPUT>; if (/^\s+S\/N (\S+)/) { ProcessHistory("SLOT","keysort","AM","!Slot $slot/MAIN: part $part, dev $dev, serial $1\n"); } else { ProcessHistory("SLOT","keysort","AM","!Slot $slot/MAIN: part $part, dev $dev\n"); goto REDUX; } } else { ProcessHistory("SLOT","keysort","AM","!Slot $slot/MAIN: part $part\n"); goto REDUX; } } else { goto REDUX; } next; } if (/^c3700\s+(io-board|mid-plane)/i) { $slot = $1; ProcessHistory("SLOT","","","!\n"); ProcessHistory("SLOT","keysort","A","!Slot $slot: part $1\n"); next; } if (/ Engine:\s+(.*)/) { ProcessHistory("SLOT","keysort","AE","!Slot $slot/Engine: $1\n"); } if (/FRU:\s+Linecard\/Module:\s+(\S+)/) { ProcessHistory("SLOT","keysort","AF","!Slot $slot/FRU: Linecard/Module: $1\n"); next; } if (/\s+Processor Memory:\s+(\S+)/) { ProcessHistory("SLOT","keysort","AF","!Slot $slot/FRU: Processor Memory: $1\n"); next; } if (/\s+Packet Memory:\s+(\S+)/) { ProcessHistory("SLOT","keysort","AF","!Slot $slot/FRU: Packet Memory: $1\n"); next; } if (/\s+Route Memory:\s+(\S+)/) { ProcessHistory("SLOT","keysort","AF","!Slot $slot/FRU: Route Memory: $1\n"); next; } if (/^\s+PCA:\s+(.*)/) { my($part) = $1; $_ = <$INPUT>; if (/^\s+(HW version|design release) (\S+)\s+S\/N (\S+)/i) { ProcessHistory("SLOT","keysort","C1","!Slot $slot/PCA: part $part, serial $3\n"); ProcessHistory("SLOT","keysort","C2","!Slot $slot/PCA: hvers $2\n"); } else { ProcessHistory("SLOT","keysort","C1","!Slot $slot/PCA: part $part\n"); goto REDUX; } next; } if (/^\s+MBUS: .*\)\s+(.*)/) { my($tmp) = "!Slot $slot/MBUS: part $1"; $_ = <$INPUT>; /^\s+HW version (\S+)\s+S\/N (\S+)/ && ProcessHistory("SLOT","keysort","MB1","$tmp, serial $2\n") && ProcessHistory("SLOT","keysort","MB2","!Slot $slot/MBUS: hvers $1\n"); next; } if (/^\s+MBUS Agent Software version (.*)/) { ProcessHistory("SLOT","keysort","MB3","!Slot $slot/MBUS: software $1\n"); next; } if (/^\s+PLD: (.*)/) { ProcessHistory("SLOT","keysort","P","!Slot $slot/PLD: $1\n"); next; } if (/^\s+MONLIB: (.*)/) { ProcessHistory("SLOT","keysort","Q","!Slot $slot/MONLIB: $1\n"); next; } if (/^\s+ROM Monitor version (.*)/) { ProcessHistory("SLOT","keysort","R","!Slot $slot/ROM Monitor: version $1\n"); next; } if (/^\s+ROMMON: Version (.*)/) { ProcessHistory("SLOT","keysort","R","!Slot $slot/ROMMON: version $1\n"); next; } if (/^\s+Fabric Downloader version used (.*)/) { ProcessHistory("SLOT","keysort","Z","!Slot $slot/Fabric Downloader: version $1\n"); next; } if (/^\s+DRAM size: (\d+)/) { my($dram) = $1 / 1048576; $_ = <$INPUT>; if (/^\s+FrFab SDRAM size: (\d+)/) { ProcessHistory("SLOT","keysort","MB4","!Slot $slot/MBUS: $dram Mbytes DRAM, " . $1 / 1024 . " Kbytes SDRAM\n"); } else { ProcessHistory("SLOT","keysort","MB4","!Slot $slot/MBUS: $dram Mbytes DRAM\n"); goto REDUX; } next; } # 7200, 3800, 3600, 2600, and 1700 stuff if (/^(Slot)\s+(\d+(\/\d+)?):/ || /^\s+(PVDM|WIC|VIC|WIC\/VIC|WIC\/VIC\/HWIC) Slot (\d):/ || /^(Encryption AIM) (\d):/ || /^(AIM Module in slot:) (\d)/) { if ($1 eq "PVDM") { $WIC = "/$2"; } elsif ($1 eq "WIC") { $WIC = "/$2"; } elsif ($1 eq "VIC") { $WIC = "/$2"; } elsif ($1 eq "WIC/VIC") { $WIC = "/$2"; } elsif ($1 eq "WIC/VIC/HWIC") { $WIC = "/$2"; } elsif ($1 eq "DSP") { $WIC = "/$2"; } elsif ($1 eq "Encryption AIM") { $slot = "$2"; $WIC = undef; ProcessHistory("SLOT","","","!\n"); ProcessHistory("SLOT","keysort","B","!Slot $slot: type $1\n"); next; } elsif ($1 eq "AIM Module in slot:") { $slot = "AIM $2"; $WIC = undef; ProcessHistory("SLOT","","","!\n"); ProcessHistory("SLOT","keysort","B", "!Slot $slot: type AIM Module\n"); next; } else { $slot = $2; $WIC = undef; } $_ = <$INPUT>; tr/\015//d; # clean up hideous 7200/etc formats to look more like 7500 output s/Fast-ethernet on C7200 I\/O card/FE-IO/; s/ with MII or RJ45/-TX/; s/Fast-ethernet /100Base/; s/[)(]//g; s/intermediate reach/IR/i; ProcessHistory("SLOT","","","!\n"); /\s+(.*) port adapter,?\s+(\d+)\s+/i && ProcessHistory("SLOT","keysort","B", "!Slot $slot: type $1, $2 ports\n") && next; # I/O controller with no interfaces /\s+(.*)\s+port adapter\s*$/i && ProcessHistory("SLOT","keysort","B", "!Slot $slot: type $1, 0 ports\n") && next; /\s+(.*)\s+daughter card(.*)$/ && ProcessHistory("SLOT","keysort","B", "!Slot $slot$WIC: type $1$2\n") && next; /\s+(FT1)$/ && ProcessHistory("SLOT","keysort","B", "!Slot $slot$WIC: type $1\n") && next; # AS5300/5400 handling /^Hardware is\s+(.*)$/i && ProcessHistory("SLOT","keysort","B","!Slot $slot: type $1\n") && next; /^DFC type is\s+(.*)$/i && ProcessHistory("SLOT","keysort","B","!Slot $slot: type $1\n") && next; # # handle WICs lacking "daughter card" in the 2nd line of their # show diag o/p if (length($WIC)) { s/^\s+//; 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 # before the hardware revision. if (/(pcb serial number|hardware revision)\s+:\s+(\S+)$/i) { my($hw, $pn, $rev, $sn); if ($1 =~ /^pcb/i) { $sn = $2; } else { $hw = $2; } 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; } if (/hardware revision\s+:\s+(\S+)/i) { $hw = $1; } if (/part number\s+:\s+(\S+)/i) { $pn = $1; } if (/board revision\s+:\s+(\S+)/i) { $rev = $1; } if (/pcb serial number\s+:\s+(\S+)/i) { $sn = $1; } # fru/pid bits, true Cisco evolving "standard", hopefully # "show inventory" will be "the way" soon. # if (/product \(fru\) number\s+:\s+(\S+)/i) { $fn = $1; } if (/product number\s+:\s+(\S+)/i) { $fn = $1; } if (/product\s+identifier\s+\(PID\)\s+:\s+(\S+)/i) { $fn = $1; } if (/fru\s+part\s+number\s+(\S+)/i) { $fn = $1; } } PerlSucks: # fru/pid bits # If slot is blank, call it "Chassis" if ($slot eq "") { $slot = "Chassis"; } ProcessHistory("SLOT","keysort","AG","!Slot $slot$WIC: fru $fn\n"); # 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") && next; /number\s+(\S+)\s+Part number\s+(\S+)/ && ProcessHistory("SLOT","keysort","D","!Slot $slot$WIC: part $2, serial $1\n") && next; # AS5x00 bits /^\ Board Revision\s+(\S+),\s+Serial Number\s+(\S+),/ && ProcessHistory("SLOT","keysort","D", "!Slot $slot$WIC: rev $1, serial $2\n") && next; /^\ Board Hardware Version\s+(\S+),\s+Item Number\s+(\S+),/ && ProcessHistory("SLOT","keysort","D", "!Slot $slot$WIC: hvers $1, part $2\n") && next; /^Motherboard Info:/ && ProcessHistory("SLOT","keysort","D", "!Slot $slot$WIC: Motherboard\n") && next; # } ProcessHistory("SLOT","","","!\n"); return(0); } # This routine parses "show inventory". sub ShowInventory { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInventory: $_" if ($debug); while (<$INPUT>) { tr/\015//d; return if (/^\s*\^$/); if (/^$prompt/) { $found_inventory = 1; last}; next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); return(0) if ($found_inventory); # Only do this routine once # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } next if (/^Load for /); next if (/^Time source is /); if (/^(NAME: "[^"]*",) (DESCR: "[^"]+")/) { ProcessHistory("INVENTORY","","", sprintf("!%-30s %s\n", $1, $2)); next; } # split PID/VID/SN line if (/^PID: (\S*)\s*,\s*VID: (\S*)\s*,\s*SN: (\S*)\s*$/) { my($pid,$vid,$sn) = ($1, $2, $3); my($entries) = ""; # filter , "0x" and "N/A" lines if ($pid !~ /^(|0x|N\/A)$/) { $entries .= "!PID: $pid\n"; } if ($vid !~ /^(|0x|N\/A)$/) { $entries .= "!VID: $vid\n"; } if ($sn !~ /^(|0x|N\/A)$/) { $entries .= "!SN: $sn\n"; } ProcessHistory("INVENTORY","","", "$entries"); next; } ProcessHistory("INVENTORY","","","!$_"); } ProcessHistory("INVENTORY","","","!\n"); return(0); } # This routine parses "show module". sub ShowModule { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowModule: $_" if ($debug); my(@lines); my($slot, $pa); my($switch, $switch_n); if ($vss_show_module == 1) { while (<$INPUT>) { last if (/^$prompt/); } return(0); } while (<$INPUT>) { tr/\015//d; next if (/^\s*\^$/); next if (/^Load for five/); next if (/^Time source is/); if (/online diag status/i) { $vss_show_module = 1; next; } last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/(?:%|command)? authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } # match Switch Number: 2 Role: Virtual Switch Active/Standby if (/^ *Switch Number: *(\d) .*Virtual Switch\s+(\S+)/) { $switch_n = $1; $switch = "Sw$1 "; ProcessHistory("Module","","","!Virtual Switch $1 is $2\n"); next; } # match slot/card info line if (/^ *(\d+)\s+(\d+)\s+(.*)\s+(\S+)\s+(\S+)\s*$/) { $lines[$switch_n * 10000 + $1 * 1000] .= "!Slot ${switch}$1: type $3, $2 ports\n!Slot ${switch}$1: part $4, serial $5\n"; $lines[$switch_n * 10000 + $1 * 1000] =~ s/\s+,/,/g; next; } # now match the Revs in the second paragraph of o/p and stick it in # the array with the previous bits...grumble. if (/^ *(\d+)\s+\S+\s+to\s+\S+\s+(\S+)\s+(\S*)\s+(\S+)(\s+\S+)?\s*$/) { $lines[$switch_n * 10000 + $1 * 1000] .= "!Slot ${switch}$1: hvers $2, firmware $3, sw $4\n"; $lines[$switch_n * 10000 + $1 * 1000] =~ s/\s+,/,/g; next; } # grab the sub-modules, if any if (/^\s+(\d+)\s(.*)\s+(\S+)\s+(\S+)\s+(\S+)\s+\S+\s*$/) { my($idx); $pa = 0 if ($1 != $slot); $slot = $1; $idx = $switch_n * 10000 + $1 * 1000 + $1 * 10 + $pa; $lines[$idx] .= "!Slot ${switch}$1/$pa: type $2\n"; $lines[$idx] .= "!Slot ${switch}$slot/$pa: part $3, serial $4\n"; $lines[$idx] .= "!Slot ${switch}$slot/$pa: hvers $5\n"; $pa++; } } if ($switch_n != 0) { ProcessHistory("Module","","","!\n"); } foreach $slot (@lines) { next if ($slot =~ /^\s*$/); ProcessHistory("Module","","","$slot!\n"); } return(0); } # This routine parses "show spe version". sub ShowSpeVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSpeVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); ProcessHistory("MODEM","","","!Modem: $_") && next; } ProcessHistory("MODEM","","","!\n"); return(0); } # This routine parses "show c7200" for the 7200 # This will create arrays for hw info. sub ShowC7200 { my($INPUT, $OUTPUT, $cmd) = @_; # Skip if this is not a 7200. print STDERR " In ShowC7200: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^\s*$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); #return(1) if ($type !~ /^72/); return(-1) if (/(?:%|command)? authorization failed/i); /^$/ && next; # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } if (/^(C7200 )?Midplane EEPROM:/) { $_ = <$INPUT>; /revision\s+(\S+).*revision\s+(\S+)/; ProcessHistory("SLOT","","","!Slot Midplane: hvers $1 rev $2\n"); $_ = <$INPUT>; /number\s+(\S+)\s+Part number\s+(\S+)/; ProcessHistory("SLOT","","","!Slot Midplane: part $2, serial $1\n!\n"); next; } if (/C720\d(VXR)? CPU EEPROM:/) { my ($hvers,$rev,$part,$serial); # npe400s report their cpu eeprom info differently w/ 12.0.21S while (<$INPUT>) { /Hardware Revision\s+: (\S+)/ && ($hvers = $1) && next; /Board Revision\s+: (\S+)/ && ($rev = $1) && next; /Part Number\s+: (\S+)/ && ($part = $1) && next; /Serial Number\s+: (\S+)/ && ($serial = $1) && next; /revision\s+(\S+).*revision\s+(\S+)/ && ($hvers = $1, $rev = $2) && next; /number\s+(\S+)\s+Part number\s+(\S+)/ && ($serial = $1, $part = $2) && next; /^\s*$/ && last; } ProcessHistory("SLOT","","","!Slot CPU: hvers $hvers rev $rev\n"); ProcessHistory("SLOT","","","!Slot CPU: part $part, serial $serial\n!\n"); next; } } return(0); } # This routine parses "show capture". Intended for ASA/PIXes. sub ShowCapture { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowCapture: $_" if ($debug); my $capture_found = 0; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return(1) if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } if (/capture (.*) type/) { my $cap_name = $1; s/\d+ bytes/ bytes/; ProcessHistory("CAPTURE","","","!Capture: $cap_name\n"); ProcessHistory("CAPTURE","","","!Capture: $_"); } else { ProcessHistory("CAPTURE","","","!Capture: $_"); } $capture_found = 1 } ProcessHistory("CAPTURE","","","!\n") if ($capture_found == 1); return(0); } # This routine parses "show dot1x" sub ShowDot1x { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVTP: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); next if (/^Configuration last modified by/); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } # if dot1x is enabled, do not collect show vlan output if (/^sysauthcontrol\s+(?:=\s+)?(\S+)/i) { if ($1 !~ /disabled/i && $filter_osc > 1) { $DO_SHOW_VLAN = 1; } } ProcessHistory("COMMENTS","keysort","I0","!DOT1x: $_"); } ProcessHistory("COMMENTS","keysort","I0","!\n"); return(0); } # This routine parses "show vtp status" sub ShowVTP { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVTP: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); #return(1) if ($type !~ /^(2900XL|3500XL|6000)$/); return(-1) if (/(?:%|command)? authorization failed/i); next if (/^Configuration last modified by/); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } if (/^VTP Operating Mode\s+:\s+(Client)/) { $DO_SHOW_VLAN = 1; } ProcessHistory("COMMENTS","keysort","I0","!VTP: $_"); } ProcessHistory("COMMENTS","keysort","I0","!\n"); return(0); } # This routine parses "show vlan" sub ShowVLAN { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVLAN: $_" if ($debug); ($_ = <$INPUT>, return(1)) if ($DO_SHOW_VLAN); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(1) if (/ambiguous command/i); return(1) if (/incomplete command/i); return(-1) if (/(?:%|command)? authorization failed/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } return(0) if (/no virtual lans configured/i); # some ASAs do not support show vlan return(0) if (/use .show switch vlan. to view the vlans that have /i); # GSR-specific, i think, filter if (/received:\s+transmitted:/i) { while (<$INPUT>) { last if (/^\s*$/); goto OUT if (/^$prompt/); } } next if (/total.*packets.*(input|output)/i); # Aironet AP's traffic counters next if (/\d+\s+bytes.*(input|output)/i); next if (/^\s*Other\s+\d+\s+\d+\s*$/i); next if (/^\s*Bridging\s+Bridge.Group.\d+\s+\d+\s+\d+\s*$/i); ProcessHistory("COMMENTS","keysort","IO","!VLAN: $_"); } OUT:ProcessHistory("COMMENTS","keysort","IO","!\n"); return(0); } # This routine processes a "show shun". Intended for ASA/PIXes. sub ShowShun { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowShun: $_" if ($debug); my $shun_found = 0; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return(1) if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/(?:%|command)? authorization failed/i); next if (/^\s+\^\s*$/); next if (/^Load for five/); next if (/^Time source is/); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } ProcessHistory("SHUN","","","!Shun: $_"); $shun_found = 1; } ProcessHistory("SHUN","","","!\n") if ($shun_found == 1); return(0); } # This routine processes a "write term" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($comment, $linecnt) = (0,0); while (<$INPUT>) { TOP: tr/\015//d; last if (/^$prompt/); return(1) if (!$linecnt && /^\s+\^\s*$/); next if (/^\s*$cmd\s*$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); next if (/^Load for five/); next if (/^Time source is/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(1) if (/\%Error: No such file or directory/); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(0) if ($found_end); # Only do this routine once return(-1) if (/(?:%|command)? authorization failed/i); return(-1) if (/% ?configuration buffer full/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } /^! no configuration change since last restart/i && next; # skip emtpy lines at the beginning if (!$linecnt && /^\s*$/) { next; } if (!$linecnt && defined($config_register)) { ProcessHistory("","","", "!\nconfig-register $config_register\n"); } /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked /% Configuration buffer full, / && return(-1); # buffer is in use $linecnt++; # skip the crap if (/^(##+|(building|current) configuration)/i) { while (<$INPUT>) { next if (/^Current configuration\s*:/i); next if (/^:/); next if (/^([%!].*|\s*)$/); next if (/^ip add.*ipv4:/); # band-aid for 3620 12.0S last; } tr/\015//d; } # config timestamp on MDS/NX-OS /Time: / && next; # skip ASA 5520 configuration author line /^: written by /i && next; # 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 \S+ at|Saved)/ && next; # skip consecutive comment lines to avoid oscillating extra comment # line on some access servers. grrr. if (/^!\s*$/) { next if ($comment); ProcessHistory("","","",$_); $comment++; next; } $comment = 0; # Dog gone Cool matches to process the rest of the config /^tftp-server flash / && next; # kill any tftp remains /^ntp clock-period / && next; # kill ntp clock-period /^ clockrate / && next; # kill clockrate on serial interfaces # kill rx/txspeed (particularly on cellular modem cards) if (/^(line (\d+(\/\d+\/\d+)?|con|aux|vty))/) { my($key) = $1; my($lineauto) = (0); if ($key =~ /con/) { $key = -1; } elsif ($key =~ /aux/) { $key = -2; } elsif ($key =~ /vty/) { $key = -3; } ProcessHistory("LINE","keysort","$key","$_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); goto TOP if (! /^ /); next if (/\s*(rx|tx)speed \d+/); next if (/^ length /); # kill length on serial lines next if (/^ width /); # kill width on serial lines $lineauto = 0 if (/^[^ ]/); $lineauto = 1 if /^ modem auto/; /^ speed / && $lineauto && next; # kill speed on serial lines if (/^(\s+password) \d+ / && $filter_pwds >= 1) { $_ = "!$1 \n"; } ProcessHistory("LINE","keysort","$key","$_"); } } if (/^(enable )?(password|passwd)( level \d+)? / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1$2$3 \n"); next; } if (/^(enable secret) / && $filter_pwds >= 2) { ProcessHistory("ENABLE","","","!$1 \n"); next; } if (/^username (\S+)(\s.*)? secret /) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 secret \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^username (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } elsif ($filter_pwds >= 1 && $4 ne "5"){ ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } # cisco AP w/ IOS if (/^(wlccp \S+ username (\S+)(\s.*)? password) (\d \S+|\S+)/) { if ($filter_pwds >= 1) { ProcessHistory("USER","keysort","$2","!$1 \n"); } else { ProcessHistory("USER","keysort","$2","$_"); } next; } # filter auto "rogue ap" configuration lines /^rogue ap classify / && next; if (/^( set session-key (in|out)bound ah \d+ )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1\n"); next; } if (/^( set session-key (in|out)bound esp \d+ (authenticator|cypher) )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1\n"); next; } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","","!$1password \n"); next; } if (/^(\s*)secret / && $filter_pwds >= 2) { ProcessHistory("LINE-PASS","","","!$1secret \n"); next; } if (/^\s*(.*?neighbor.*?) (\S*) password / && $filter_pwds >= 1) { ProcessHistory("","","","! $1 $2 password \n"); next; } if (/^(\s*ppp .* hostname) .*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^(\s*ppp .* password) \d .*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^(ip ftp password) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # isis passwords appear to be completely plain-text if (/^\s+isis password (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!isis password $2\n"); next; } if (/^\s+(domain-password|area-password) (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $3\n"); next; } # this is reversable, despite 'md5' in the cmd if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # this is also reversable, despite 'md5 encrypted' in the cmd if (/^( message-digest-key \d+ md5 (7|encrypted)) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^((crypto )?isakmp key) (\d )?\S+ / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # filter HSRP passwords if (/^(\s+standby \d+ authentication) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # this appears in "measurement/sla" images if (/^(\s+key-string \d?)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^( l2tp tunnel \S+ password)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # l2tp-class secret if (/^( digest secret 7?)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # i am told these are plain-text on the PIX if (/^(vpdn username (\S+) password)/) { if ($filter_pwds >= 1) { ProcessHistory("USER","keysort","$2","!$1 \n"); } else { ProcessHistory("USER","keysort","$2","$_"); } next; } # ASA/PIX keys in more system:running-config if (/^(( ikev2)? (local|remote)-authentication pre-shared-key ).*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # ASA/PIX keys in more system:running-config if (/^(( ikev1)? pre-shared-key | key |failover key ).*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # ASA/PIX keys in more system:running-config if (/(\s+ldap-login-password )\S+(.*)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # filter WPA password such as on cisco 877W ISR if (/^\s+(wpa-psk ascii|hex \d) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # if (/^( cable shared-secret )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } /fair-queue individual-limit/ && next; # sort ip explicit-paths. if (/^ip explicit-path name (\S+)/) { my($key) = $1; my($expath) = $_; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || ! /^(ip explicit-path name |[ !])/); if (/^ip explicit-path name (\S+)/) { ProcessHistory("EXPATH","keysort","$key","$expath"); $key = $1; $expath = $_; } else { $expath .= $_; } } ProcessHistory("EXPATH","keysort","$key","$expath"); } # sort route-maps if (/^route-map (\S+)/) { my($key) = $1; my($routemap) = $_; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || ! /^(route-map |[ !])/); if (/^route-map (\S+)/) { ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); $key = $1; $routemap = $_; } else { $routemap .= $_; } } ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); } # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order access-lists /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order extended access-lists if ($aclfilterseq) { /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+host\s+(\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$4","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+(\d\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$4","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+any/ && ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; } if ($aclfilterseq) { /^ip(v6)? prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\S+)(.*)/ && ProcessHistory("PACL $2 $4","$aclsort","$5", "ip$1 prefix-list $2 $4 $5$6\n") && next; } # sort ipv{4,6} access-lists if ($aclfilterseq && /^ipv(4|6) access-list (\S+)\s*$/) { my($nlri, $key) = ($1, $2); my($seq, $cmd); ProcessHistory("ACL $nlri $key","","","$_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || /^\S/); # ipv4 access-list name # remark NTP # deny ipv4 host 224.0.1.1 any # deny ipv4 239.0.0.0 0.255.255.255 any # permit udp any eq 123 any # permit ipv4 nnn.nnn.nnn.nnn/nn any # permit nnn.nnn.nnn.nnn/nn # ipv6 access-list name # permit ipv6 host 2001:nnnn::nnnn any # permit ipv6 2001:nnn::/nnn any # permit 2001:nnnn::/64 any # permit udp any eq 123 any # # line might begin with " sequence nnn permit ..." s/^\s+(sequence (\d+)) / /; my($seq) = $1; my($cmd, $resid) = ($_ =~ /^\s+(\w+) (.+)/); if ($cmd =~ /(permit|deny)/) { my($ip); my(@w) = ($resid =~ /(\S+) (\S+) (\S+\s)?(.+)/); for (my($i) = 0; $i < $#w; $i++) { if ($w[$i] eq "any") { if ($nlri eq "ipv4") { $ip = "255.255.255.255/32"; } else { $ip = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128"; } last; } elsif ($w[$i] =~ /^[:0-9]/ || $2[$i] =~ /^[a-fA-F]{1,4}:/) { $ip = $w[$i]; $ip =~ s/\s+$//; # trim trailing WS last; } } ProcessHistory("ACL $nlri $key $cmd", "$aclsort", "$ip", " $cmd $resid\n"); } else { ProcessHistory("ACL $nlri $key $cmd", "", "", " $cmd $resid\n"); } } } # order arp lists /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ && ProcessHistory("ARP","$aclsort","$1","$_") && next; # order logging statements /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); if ($token eq '3') { $line .= " " . join(' ', ($token, shift(@tokens))); } } elsif ($token eq 'vrf') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } # For ASA version 8.x and higher, the format changed a little. It is # 'snmp-server host {interface {hostname | ip_address}} [trap | poll] # [community 0 | 8 community-string] [version {1 | 2c | 3 username}] # [udp-port port] ' if (/^(snmp-server .*community) ([08] )?(\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_", "!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # prune tacacs/radius server keys if (/^((tacacs|radius)-server\s(\w*[-\s(\s\S+])*\s?key) (\d )?\S+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # order clns host statements /^clns host \S+ (\S+)/ && ProcessHistory("CLNS","keysort","$1","$_") && next; # order alias statements /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next; # delete ntp auth password - this md5 is a reversable too if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { my($sortkey) = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # order ip host statements /^ip host (\S+) / && ProcessHistory("IPHOST","keysort","$1","$_") && next; # order ip nat source static statements /^ip nat (\S+) source static (\S+)/ && ProcessHistory("IP NAT $1","ipsort","$2","$_") && next; # order atm map-list statements /^\s+ip\s+(\d+\.\d+\.\d+\.\d+)\s+atm-vc/ && ProcessHistory("ATM map-list","ipsort","$1","$_") && next; # order ip rcmd lines /^ip rcmd/ && ProcessHistory("RCMD","keysort","$_","$_") && next; # system controller /^syscon address (\S*) (\S*)/ && ProcessHistory("","","","!syscon address $1 \n") && next; if (/^syscon password (\S*)/ && $filter_pwds >= 1) { ProcessHistory("","","","!syscon password \n"); next; } /^ *Cryptochecksum:/ && next; # catch anything that wasnt matched above. ProcessHistory("","","","$_"); # end of config. the ": " game is for the PIX if (/^(: +)?end$/) { $found_end = 1; return(0); } } # The ContentEngine lacks a definitive "end of config" marker. If we # know that it is a CE, SAN, or NXOS and we have seen at least 5 lines # of write term output, we can be reasonably sure that we have the config. if (($type eq "CE" || $type eq "SAN" || $type eq "NXOS") && $linecnt > 5) { $found_end = 1; return(0); } return(0); } 1; rancid-3.13/lib/dnos9.pm.in000644 015615 000000 00000036252 13657102757 015550 0ustar00heaswheel000000 000000 package dnos9; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # dnos9.pm - Force10 / Dell NOS9 rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","F0","!\n"); ProcessHistory("COMMENTS","keysort","G0","!\n"); 0; } $timeo = 90; # clogin timeout in seconds # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/\#\s?exit$/) { $clean_run=1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run=0; last; } while (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if(/^$prompt/); next if(/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); s/\s*$/\n/; / Type: / && ProcessHistory("COMMENTS","keysort","A1", "!$_"); /^.* Version.*$/ && ProcessHistory("COMMENTS","keysort","F1", "!Image: $_") && next; /^Build .*$/ && ProcessHistory("COMMENTS","keysort","F1", "!Image: $_") && next; /^System image file is "([^\"]*)"$/ && ProcessHistory("COMMENTS","keysort","F5", "!Image: $1\n") && next; if (/^(.*\s+Processor)( \d)?:(.*) with (\d+[kK]?) bytes/) { my($cpu) = "$1$2:$3"; my($mem) = int($4 / (1024 * 1024)); my($device) = "Force10"; ProcessHistory("COMMENTS","keysort","B1", "!Memory: $1$2: $mem" . "M\n"); ProcessHistory("COMMENTS","keysort","A3","!CPU: $cpu\n"); next; } # E-Series and C-Series use NVRAM /^(\d+[kK]) bytes of non-volatile/ && ProcessHistory("COMMENTS","keysort","B3", "!Memory: NVRAM $1\n") && next; # S-Series uses boot flash /^(\d+[mM]) bytes of .oot..lash/ && ProcessHistory("COMMENTS","keysort","B3", "!Memory: Flash $1\n") && next; } return(0); } # This routine parses "show boot" sub ShowBoot { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowBoot: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /(Invalid input|Type help or )/; return(1) if /( *\^$)/; return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","keysort","H0","!Boot Variables: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show chassis" sub ShowChassis { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassis: $_" if ($debug); while (<$INPUT>) { tr/\015//d; REDO: last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /(Invalid input|Type help or )/; return(1) if /( *\^$)/; return(-1) if (/command authorization failed/i); /-----------------------------/ && next; # general stuff that changes /Next Boot/ && next; /Up Time/ && next; /Last Restart/ && next; /Switch Fabric State/ && next; /active / && next; /online / && next; /offline / && next; # E600 AC PSMs /Status : up/ && next; /High line/ && next; # PS fans if (/power\s+supplies/i) { ProcessHistory("COMMENTS","keysort","CHASSIS","!Chassis: $_"); while (<$INPUT>) { tr/\015//d; if (/^$prompt/) { goto OUT; } last if (/^$/); # remove any trailing WS s/\s+$//; next if (/^----+$/); # s4048 style if (/(Unit\s+Bay\s+Status\s+Type\s+FanStatus)\s+FanSpeed/) { ProcessHistory("COMMENTS","keysort","CHASSIS", "!Chassis: $1\n"); while (<$INPUT>) { tr/\015//d; if (/^$prompt/) { goto OUT; } last if (/^$/); # remove any trailing WS s/\s+$//; # consume the following separator line next if (/^----+$/); /^(\s+\d+\s+\d+\s+\S+\s+\S+\s+\S+)\s+\S+/ && ProcessHistory("COMMENTS","keysort","CHASSIS", "!Chassis: $1\n") && next; last; } goto REDO; } } } # fans if (/Fan\s+Status/i) { ProcessHistory("COMMENTS","keysort","CHASSIS","!Chassis: $_"); while (<$INPUT>) { tr/\015//d; if (/^$prompt/) { goto OUT; } last if (/^$/); # remove any trailing WS s/\s+$//; next if (/^----+$/); # c150 / c300 style /FanNumber\s+Speed\s+Status/ && ProcessHistory("COMMENTS", "keysort","CHASSIS","!Chassis: FanNumber\tStatus\n") && next; /^\s+(\d)\s+\d+\s+(\S+)/ && ProcessHistory("COMMENTS", "keysort","CHASSIS","!Chassis: $1\t\t$2\n") && next; # e300 /^Status\s+$/ && next; /^\s+(\S+)\s*$/ && ProcessHistory("COMMENTS","keysort", "CHASSIS","!Chassis: $1\n") && next; # e600 style /Status\s+Temp\s+Fan1\s+Fan2\s+Fan3\s+Serial\s/ && next; /^\s+(\S+)\s+\d+C\s+\d+ RPM\s+/ && ProcessHistory("COMMENTS", "keysort","CHASSIS","!Chassis: $1\n") && next; # e1200 style /Tray\s+Status\s+Temp\s+/ && ProcessHistory("COMMENTS", "keysort","CHASSIS","!Chassis: Tray\tStatus\n") && next; /^\s+(\d+)\s+(\S+)\s+(or down|(< )?\d+C\s+)/ && ProcessHistory("COMMENTS","keysort","CHASSIS", "!Chassis: $1\t$2\n") && next; # s50n / s50v style if (/Unit\s+TrayStatus\s+Fan0\s+Fan1\s+/) { ProcessHistory("COMMENTS","keysort","CHASSIS", "!Chassis: $_\n"); # consume the following blank/separator line $_ = <$INPUT>; # the s50n botches its fan status line with the "---..." # separator line w/o a CR, followed by the fan status. we # would normally skip the sparator line, so hack it. s/^------+(\s+)/$1/; tr/\015//d; # the s50v has a blank line following the table header, # loop for that one and continue for the S50n /^\s+$/ && next; } /^\s+\d+\s+\S+\s+\S+\s+\S+\s+\S+\s+/ && ProcessHistory("COMMENTS","keysort","CHASSIS", "!Chassis: $_") && next; } next; } ProcessHistory("COMMENTS","keysort","CHASSIS","!Chassis: $_"); } OUT: ProcessHistory("COMMENTS","keysort","CHASSIS","!\n"); return(0); } # This routine parses "dir /all (flash|slotN):" sub DirSlotN { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DirSlotN: $_" if ($debug); my($dev) = (/\s([^\s]+):/); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); # return(1) if ($type !~ /^(12[40]|7|36)/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input|Type help or )/; return(1) if /No such device/i; return(1) if /\% ?Error: No such file or directory/; return(1) if /\% ?Error: The file device is not present/; return(1) if /\% ?Error: The specified file or directory does not exist/; return(1) if /No space information available/; return(-1) if (/command authorization failed/i); return(1) if /(Open device \S+ failed|Error opening \S+:)/; /Directory of/ && next; # . & .. / \.{1,2}\s+$/ && next; # clean up totals line if (/.* (\d+) bytes total/) { my($tmp) = int($1 / (1024 * 1024)); s/.* $1 bytes total/${tmp}M total/; } if (/.*\((\d+) bytes free\)/) { my($tmp) = int($1 / (1024 * 1024)); s/$1 bytes free/${tmp}M free/; } s/ +$//g; ProcessHistory("FLASH","","","!Flash: $dev: $_"); } ProcessHistory("","","","!\n"); return(0); } # This routine parses "show inventory" sub ShowInventory { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInventory: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /(Invalid input|Type help or )/; return(-1) if (/command authorization failed/i); /-----------------------------/ && next; ProcessHistory("COMMENTS","keysort","INVENTORY","!Inventory: $_"); } ProcessHistory("COMMENTS","keysort","INVENTORY","!\n"); return(0); } # This routine parses "show vlan" sub ShowVLAN { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVLAN: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /(Invalid input|Type help or )/; return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","keysort","VLAN","!VLAN: $_"); } ProcessHistory("COMMENTS","keysort","VLAN","!\n"); return(0); } # This routine processes a "write term" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if(/^$prompt/); return(-1) if (/command authorization failed/i); # skip crap /^Current Configuration/ && next; /^! (version|last configuration|startup-config last)/i && next; # Dog gone Cool matches to process the rest of the config /^tftp-server flash / && next; # kill any tftp remains /^ntp clock-period / && next; # kill ntp clock-period /^ length / && next; # kill length on serial lines /^ width / && next; # kill width on serial lines /^ clockrate / && next; # kill clockrate on serial interfaces if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1$2 \n"); next; } if (/^(enable secret) / && $filter_pwds >= 2) { ProcessHistory("ENABLE","","","!$1 \n"); next; } if (/^(enable restricted) / && $filter_pwds >= 2) { ProcessHistory("ENABLE","","","!$1 \n"); next; } if (/^username (\S+)(\s.*)? secret /) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1","!username $1$2 secret \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^username (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds == 2) { ProcessHistory("USER","keysort","$1","!username $1$2 password \n"); } elsif ($filter_pwds == 1 && $4 ne "5"){ ProcessHistory("USER","keysort","$1","!username $1$2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","","!$1password \n"); next; } if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) { ProcessHistory("","","","! neighbor $1 password \n"); next; } if (/^(ip ftp password) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^(ftp-server username.*password) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # this is reversable, despite 'md5' in the cmd if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # sort route-maps if (/^route-map (\S+)/) { my($key) = $1; my($routemap) = $_; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || ! /^(route-map |[ !])/); if (/^route-map (\S+)/) { ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); $key = $1; $routemap = $_; } else { $routemap .= $_; } } ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); } # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order access-lists /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order extended access-lists /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ && ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; # order arp lists /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ && ProcessHistory("ARP","$aclsort","$1","$_") && next; /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ && ProcessHistory("PACL $1 $3","$aclsort","$4","ip prefix-list $1 $3 $4$5\n") && next; # order logging statements /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } if (/^(snmp-server community) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_","!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # order/prune tacacs/radius server statements if (/^(tacacs-server|radius-server) key / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 key \n"); next; } # order clns host statements /^clns host \S+ (\S+)/ && ProcessHistory("CLNS","keysort","$1","$_") && next; # delete ntp auth password - this md5 is a reversable too if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { my($sortkey) = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # order ip host line statements /^ip host line(\d+)/ && ProcessHistory("IPHOST","numsort","$1","$_") && next; # order atm map-list statements /^\s+ip\s+(\d+\.\d+\.\d+\.\d+)\s+atm-vc/ && ProcessHistory("ATM map-list","ipsort","$1","$_") && next; # catch anything that wasnt matched above. ProcessHistory("","","","$_"); # end of config. the ": " game is for the PIX if (/^end *$/) { $found_end = 1; return(0); } } return(0); } 1; rancid-3.13/lib/mrv.pm.in000644 015615 000000 00000023446 13532047122 015303 0ustar00heaswheel000000 000000 package mrv; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # mrv.pm - MRV rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; our $found_version; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { # force a terminal type so as not to confuse the POS $ENV{'TERM'} = "vt100"; 0; } # post-open(collection file) initialization sub init { $found_version = 0; # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","C0","!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/[>#]\s?exit$/) { $clean_run = 1; last; } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; if (/^$prompt/) { $found_version = 1; last}; next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /(Invalid input detected|Type help or )/; return(0) if ($found_version); # Only do this routine once return(-1) if (/command authorization failed/i); /copyright/i && next; /^up\s+/ && next; /Cannot get uptime:Timeout expired/ && next; # skip voltage /\s+\d+V\s*\:\s*\d+\.?\d*/ && next; /Internal\ Temperature/i && next; /^Temperature:/i && next; /^PP\s*: \d+C \/ \d+F/ && next; /^Device([^:]*)?: \d+C \/ \d+F/ && next; /^Fans:$/ && next; /^Fan \d: (NOT )?ACTIVE$/ && next; /^users: remote - \d/ && next; /u-boot/i && ProcessHistory("COMMENTS","keysort","C1", "!ROM: $_") && next; ProcessHistory("COMMENTS","keysort","B1", "!Image: $_") && next; } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show chassis" for the gsr # This will create arrays for hw info. sub ShowChassis { my($INPUT, $OUTPUT, $cmd) = @_; # Skip if this is not a 1200n. my($newfmt) = 0; print STDERR " In ShowChassis: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); s/\s+$//; $newfmt = 1 if (/\s+Serial Num$/); if (/Chassis +Model/ || /=======/) { ProcessHistory("COMMENTS","keysort","C1","!$_\n"); next; } # Trim the temp from the end of the slot line if ($newfmt) { s/(-?\d+)(\s+\w+)$//; my($fmt) = "%-" . length($1) . "s"; $_ = $_ . sprintf($fmt, "") . $2; } else { # the old format s/\S+$//; } ProcessHistory("COMMENTS","keysort","C1","!$_\n"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show inventory" for the gsr # This will create arrays for hw info. sub ShowInventory { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInventory: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*$cmd\s*)$/); return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); s/\s+$//; ProcessHistory("COMMENTS","keysort","C1","!$_\n"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show slots". sub ShowSlots { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSlots: $_" if ($debug); while (<$INPUT>) { tr/\015//d; return if (/^\s*\^$/); last if (/online diag status/i); last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); ProcessHistory("SLOTS","","","!$_"); next; } ProcessHistory("SLOTS","","","!\n"); return(0); } # This routine processes a "write term" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($lineauto,$comment,$linecnt) = (0,0,0); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return(1) if /Line has invalid autocommand /; return(1) if (/(Invalid input detected|Type help or )/i); return(0) if ($found_end); # Only do this routine once return(-1) if (/command authorization failed/i); /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked $linecnt++; $lineauto = 0 if (/^[^ ]/); # skip the crap if (/^(##+$|(Building|Current) configuration)/i) { while (<$INPUT>) { next if (/^Current configuration\s*:/i); next if (/^:/); next if (/^([%!].*|\s*)$/); last; } tr/\015//d; } # skip consecutive comment lines to avoid oscillating extra comment # line on some access servers. grrr. if (/^!/) { next if ($comment); ProcessHistory("","","",$_); $comment++; next; } $comment = 0; # Dog gone Cool matches to process the rest of the config /^tftp-server flash / && next; # kill any tftp remains /^ntp clock-period / && next; # kill ntp clock-period /^ length / && next; # kill length on serial lines /^ width / && next; # kill width on serial lines $lineauto = 1 if /^ modem auto/; /^ speed / && $lineauto && next; # kill speed on serial lines if (/^(enable )?(password|passwd)( level \d+)? / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1$2$3 \n"); next; } if (/^(enable secret) / && $filter_pwds >= 2) { ProcessHistory("ENABLE","","","!$1 \n"); next; } if (/^username (\S+)(\s.*)? password (encrypted \S+|\S+)(\sclass .*$)/){ if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 password $4\n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","","!$1password \n"); next; } # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order access-lists /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order extended access-lists /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ && ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; # order arp lists /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ && ProcessHistory("ARP","$aclsort","$1","$_") && next; /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ && ProcessHistory("PACL $1 $3","$aclsort","$4","ip prefix-list $1 $3 $4$5\n") && next; # order logging statements /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); if ($token eq '3') { $line .= " " . join(' ', ($token, shift(@tokens))); } } elsif ($token eq 'vrf') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } if (/^(snmp-server community) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_", "!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # prune tacacs/radius server keys # radius-server host <1-5> IP SECRET [ [TIMEOUT [RETRY]]] if (/^((tacacs|radius)-server)\s(\d+\.\d+\.\d+\.\d+)\s(\w*)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $2 $'"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { my($sortkey) = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # catch anything that wasnt matched above. ProcessHistory("","","","$_"); } # The MRV MCC lacks a definitive "end of config" marker. If we have seen # at least 5 lines of show config output, we can be reasonably sure that # we got the config. if ($linecnt > 5) { $found_end = 1; return(0); } return(0); } 1; rancid-3.13/lib/dnos10.pm.in000644 015615 000000 00000021302 13735654705 015610 0ustar00heaswheel000000 000000 package dnos10; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # dnos10.pm - Dell NOS10 rancid procedures - from Bjørn Skobba use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","A0","!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","C0","!\n"); ProcessHistory("COMMENTS","keysort","D0","!\n"); 0; } $timeo = 90; # clogin timeout in seconds # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/\#\s?exit$/) { $clean_run=1; last; } if (/^Error:/) { print STDOUT ("$host hlogin error: $_"); print STDERR ("$host hlogin error: $_") if ($debug); $clean_run=0; last; } while (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } } # This routine parses "show version" sub ShowVer { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVer: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if (/^\s*$/); last if (/$prompt/); # pager remnants like: ^H^H^H ^H^H^H content s/[\b]+\s*[\b]*//g; # Remove Uptime /^Up Time/ && next; ProcessHistory("COMMENTS","keysort","B1","! $_"); } return(0); } sub ShowSys { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSys: $_" if ($debug); $_ =~ s/^[^#]*//; ProcessHistory("COMMENTS","keysort","C1","!\n! $_"); while (<$INPUT>) { s/^\s+\015//g; tr/\015//d; REDO: last if (/$prompt/); # pager remnants like: ^H^H^H ^H^H^H content s/[\b]+\s*[\b]*//g; # Remove Uptime /^Up Time/i && next; if (/-- power supplies --/i) { ProcessHistory("COMMENTS","keysort","C1","! $_"); # PSU-ID Status Type AirFlow Fan Speed(rpm) Status # ---------------------------------------------------------------- # 1 up AC REVERSE 1 25800 up while (<$INPUT>) { s/^\s+\015//g; tr/\015//d; last if (/$prompt/); last if (/^-- /); # next section /^\s*$/ && next; if (/^(\d+\s+\w+\s+\w+\s+\w+\s+\d+\s+)(\d+)(\s+\w+)\s*$/) { my($sl) = length($2); my($fmt) = "%s%-". $sl ."s%s\n"; $_ = sprintf($fmt, $1, "", $3); } ProcessHistory("COMMENTS","keysort","C1","! $_"); } goto REDO; } if (/-- fan status --/i) { ProcessHistory("COMMENTS","keysort","C1","! $_"); # FanTray Status AirFlow Fan Speed(rpm) Status # ---------------------------------------------------------------- # 1 up REVERSE 1 8520 up # 2 7680 up while (<$INPUT>) { s/^\s+\015//g; tr/\015//d; last if (/$prompt/); last if (/^-- /); # next section if (/^(\d+\s+\w+\s+\w+\s+\d+\s+)(\d+)(\s+\w+)\s*$/) { my($sl) = length($2); my($fmt) = "%s%-". $sl ."s%s\n"; $_ = sprintf($fmt, $1, "", $3); } elsif (/^(\s+\d+\s+)(\d+)(\s+\w+)\s*$/) { my($sl) = length($2); my($fmt) = "%s%-". $sl ."s%s\n"; $_ = sprintf($fmt, $1, "", $3); } /^\s*$/ && next; ProcessHistory("COMMENTS","keysort","C1","! $_"); } goto REDO; } /current type\s*: (.*)/i && ProcessHistory("COMMENTS","keysort","A1", "!Chassis type: $1\n") && next; ProcessHistory("COMMENTS","keysort","C1","! $_"); } return(0); } # This routine parses "show inventory" sub ShowInventory { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInventory: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /(Invalid input|Type help or )/; return(-1) if (/command authorization failed/i); /-----------------------------/ && next; ProcessHistory("COMMENTS","keysort","INVENTORY","!Inventory: $_"); } ProcessHistory("COMMENTS","keysort","INVENTORY","!\n"); return(0); } # This routine parses "show inventory media" sub ShowInventoryMedia { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInventoryMedia: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^(\s*System Inventory Media\s*)$/); return(1) if /(Invalid input|Type help or )/; return(-1) if (/command authorization failed/i); /-----------------------------/ && next; ProcessHistory("COMMENTS","keysort","INVENTORYMEDIA","!Inventory: $_"); } ProcessHistory("COMMENTS","keysort","INVENTORYMEDIA","!\n"); return(0); } sub ShowVlan { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVlan: $_" if ($debug); $_ =~ s/^[^#]*//; ProcessHistory("COMMENTS","keysort","D1","!\n! $_"); while (<$INPUT>) { s/^\s+\015//g; tr/\015//d; next if (/^\s*$/); last if (/$prompt/); # pager remnants like: ^H^H^H ^H^H^H content s/[\b]+\s*[\b]*//g; # Remove Uptime /^Up Time/i && next; ProcessHistory("COMMENTS","keysort","D1","! $_"); } return(0); } # This routine processes a "write term" (aka show running-configuration) sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; my($comment) = (0); print STDERR " In WriteTerm: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if (/^\s*$/); last if (/$prompt/); # pager remnants like: ^H^H^H ^H^H^H content s/[\b]+\s*[\b]*//g; # skip consecutive comment lines if (/^!/) { next if ($comment); ProcessHistory("","","",$_); $comment++; next; } $comment = 0; /^building running-config/ && next; /^------+/ && ProcessHistory("","","","!$_") && next; /^router configuration/i && ProcessHistory("","","","!$_") && next; /^oob host config/i && ProcessHistory("","","","!$_") && next; /^empty configuration/i && ProcessHistory("","","","!$_") && next; if (/^(username|system\-user) (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1 $2 password \n"); } elsif ($filter_pwds >= 1 && $3 ne "5"){ ProcessHistory("USER","keysort","$1", "!username $1 $2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^(enable password)( level \d+)? / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1$2 \n"); next; } if (/^password (\S+) encrypted/ && $filter_pwds > 1) { ProcessHistory("","","","!password encrypted\n"); next; } if (/^password (\S+)$/ && $filter_pwds >= 1) { ProcessHistory("","","","!password \n"); next; } if (/^(enable password level \d+) (\S+) encrypted/ && $filter_pwds > 1){ ProcessHistory("","","","!$1 encrypted\n"); next; } if (/^(enable password level \d+) (\S+)$/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'\n"); next; } # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^(snmp-server host) (\d+\.\d+\.\d+\.\d+) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERHOST","ipsort", "$2","!$1 $2 $'"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$2","$_"); } next; } if (/^(snmp-server community) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort", "$_","!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$2","$_") && next; } } # prune tacacs/radius server keys if (/^(tacacs-server|radius-server) key \w+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } ProcessHistory("","","","$_"); } $found_end = 1; return(1); } 1; rancid-3.13/lib/aeos.pm.in000644 015615 000000 00000034147 13532047157 015436 0ustar00heaswheel000000 000000 package aeos; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # Rancid for Arista Networks' switches; cisco mode works but # Arista mode is better. # Initial version by Bill Fenner # # aeos.pm - Arista EOS rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; our $found_env; our $found_version; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { $found_version = 0; $found_env = 0; 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; CMD: if (/[>#]\s?exit$/) { $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; # "time in prompt" hack: $prompt =~ s/\d+:\d+:\d+/\\d+:\\d+:\\d+/; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } if (defined($prompt)) { if (/$prompt/) { goto CMD; } } } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; if (/^$prompt/) {$found_version = 1; last}; next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^% Invalid input/; return(0) if ($found_version); # Only do this routine once next if (/uptime is/); # Older AOS show uptime my($key, $val) = split(/:\s+/, $_, 2); if (! $val) { # Must be the model name if there's no colon ProcessHistory("COMMENTS", "", "", "!Model: $_" ); next; } if ($key ne 'Uptime' and $key ne 'Free memory') { ProcessHistory("COMMENTS", "", "", "!$key: $val" ); } } return(0); } sub DiffConfig { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In DiffConfig: $_" if ($debug); my($havediffs) = 0; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); ProcessHistory("DIFFS","keysort","BB","!$_"); $havediffs = 1; } if ($havediffs) { ProcessHistory("DIFFS","keysort","AA","!*****************************\n"); ProcessHistory("DIFFS","keysort","AB","!*** unsaved changes exist ***\n"); ProcessHistory("DIFFS","keysort","AC","!*****************************\n"); ProcessHistory("DIFFS","keysort","CC","!\n"); } return; } # This routine parses "show env all" sub ShowEnv { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowEnv: $_" if ($debug); my($fans, $E0) = (0, undef); while (<$INPUT>) { tr/\015//d; if (/^$prompt/) {$found_env = 1; last}; next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^% Invalid input/; return(0) if ($found_env); # Only do this routine once if (!defined($E0)) { $E0 = 1; ProcessHistory("COMMENTS","keysort","E0","!\n"); } /^(System \S+ status is|Action on overheat|Airflow)/ && ProcessHistory("COMMENTS","keysort","E0","!$_") && next; if (/^Fan\s+Status\s+/) { $fans = 1; next; } $fans && /^\s*(\d+)\s+(\S+)/ && ProcessHistory("COMMENTS","keysort","E1","!Fan $1: $2\n") && next; if (/^supply\s+model\s+capacity/i) { while (<$INPUT>) { tr/\015//d; last if (/^\s*/); if (/^$prompt/) {$found_version = 1; last}; /^\s*(\d+)\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+\S+\s+(\S+)/ && ProcessHistory("COMMENTS","keysort","E2","!Power Supply $1: $2 $3 $4\n"); next; /^\s*Total\s+\S+\s+(\S+)\s+/ && ProcessHistory("COMMENTS","keysort","E2","!Power Total: $1\n") && next;; } } } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show boot-config" sub ShowBoot { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowBoot: $_" if ($debug); my($B0) = (undef); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^% Invalid input/; if (!defined($B0)) { $B0 = 1; ProcessHistory("COMMENTS","","","!\n"); } ProcessHistory("COMMENTS","","","!$_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show boot-extensions" sub ShowBootExt { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowBootExt: $_" if ($debug); my($C0) = (undef); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/^% Invalid input/); return(0) if (/^% Error displaying /); if (!defined($C0)) { $C0 = 1; ProcessHistory("COMMENTS","","","!\n"); } ProcessHistory("COMMENTS","","","!BootExtension: $_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "show extensions" sub ShowExt { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowExt: $_" if ($debug); my($D0) = (undef); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^% Invalid input/; return(0) if /^No extensions are available/; if (!defined($D0)) { $D0 = 1; ProcessHistory("COMMENTS","","","!Extensions:\n"); } ProcessHistory("COMMENTS","","","!$_"); } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine parses "dir flash:" sub ShowFlash { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowFlash: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^% Invalid input/; # persist changes constantly if you're running ntp, so # skip its updates. /\spersist$/ && next; # Scheduled commands can cause free space to constantly # change. Even the trick of summarizing the free space # doesn't help, since it can oscillate, e.g., between # 1006MB and 1007MB. Just skip the free space. /.*\((\d+) bytes free\)/ && next; ProcessHistory("FLASH","","","!Flash: $_"); } ProcessHistory("","","","!\n"); return; } # This routine parses "show inventory". sub ShowInventory { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowInventory: $_" if ($debug); while (<$INPUT>) { tr/\015//d; return if (/^\s*\^$/); last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^% Invalid input/; ProcessHistory("INVENTORY","","","!$_"); } ProcessHistory("INVENTORY","","","!\n"); return(0); } # This routine parses "show tech ribd running" for Ribd sub-code commands running. sub WriteRibd { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteRibd: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^% Invalid input/; return(0) if /^% Error displaying /; # Only do this routine once ProcessHistory("RIBD","","","!Ribd: $_"); } ProcessHistory("RIBD","","","!\n"); return(0); } # This routine processes a "write term" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($lineauto, $sortkey) = (0, 0); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return(1) if /^% Invalid input/; return(0) if ($found_end); # Only do this routine once # Dog gone Cool matches to process the rest of the config # Lots of Cisco-specific stuff here, but leaving it alone for now. /^tftp-server flash / && next; # kill any tftp remains /^ntp clock-period / && next; # kill ntp clock-period /^ length / && next; # kill length on serial lines /^ width / && next; # kill width on serial lines $lineauto = 1 if /^ modem auto/; /^ speed / && $lineauto && next; # kill speed on serial lines /^ clockrate / && next; # kill clockrate on serial interfaces /^! Time: / && next; # EOS gives the time that a "show running" command was run next if (/(^\*+$|unsaved changes exist)/i); if (/^(enable )?(password|passwd)( level \d+)? / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1$2$3 \n"); next; } if (/^(enable secret) / && $filter_pwds >= 2) { ProcessHistory("ENABLE","","","!$1 \n"); next; } if (/^username (\S+)(\s.*)? secret /) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 secret \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^username (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } elsif ($filter_pwds >= 1 && $4 ne "5"){ ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("","","","!$1password \n"); next; } if (/^(\s*)secret / && $filter_pwds >= 2) { ProcessHistory("","","","!$1secret \n"); next; } if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) { ProcessHistory("","","","! neighbor $1 password \n"); next; } if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # isis passwords appear to be completely plain-text if (/^\s+isis password (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!isis password $2\n"); next; } if (/^\s+(domain-password|area-password) (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $3\n"); next; } # this is reversable, despite 'md5' in the cmd if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # this is also reversable, despite 'md5 encrypted' in the cmd if (/^( message-digest-key \d+ md5 (7|encrypted)) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # sort route-maps if (/^route-map (\S+)/) { my($key) = $1; my($routemap) = $_; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || ! /^(route-map |[ !])/); if (/^route-map (\S+)/) { ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); $key = $1; $routemap = $_; } else { $routemap .= $_; } } ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); } # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order access-lists /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order extended access-lists /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ && ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; # order arp lists /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ && ProcessHistory("ARP","$aclsort","$1","$_") && next; /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ && ProcessHistory("PACL $1 $3","$aclsort","$4","ip prefix-list $1 $3 $4$5\n") && next; # order logging statements /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); if ($token eq '3') { $line .= " " . join(' ', ($token, shift(@tokens))); } } elsif ($token eq 'vrf') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } if (/^(snmp-server community) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_", "!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # prune tacacs/radius server keys if (/^((tacacs|radius)-server\s(\w*[-\s(\s\S+])*\s?key) (\d )?\w+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # order alias statements /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next; # delete ntp auth password - this md5 is a reversable too if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # catch anything that wasnt matched above. ProcessHistory("","","","$_"); # end of config. if (/^end$/) { $found_end = 1; return(0); } } return(0); } 1; rancid-3.13/lib/frr.pm.in000755 015615 000000 00000014247 13665233101 015273 0ustar00heaswheel000000 000000 package frr; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # frr.pm - FRR (or Quagga or Zebra) rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { # force a terminal type so as not to confuse Linux $ENV{'TERM'} = "ansi"; 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); # show version ProcessHistory("COMMENTS","keysort","C0","!\n"); # show package XXX ProcessHistory("COMMENTS","keysort","D0","!\n"); # show hardware XXX ProcessHistory("COMMENTS","keysort","Z0","!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/\#\s?exit$/) { $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); ProcessHistory("COMMENTS","keysort","B0", "!$_") && next; } return(0); } # This routine processes a "write term" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return(-1) if (/command authorization failed/i); /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked # skip the crap if (/^(##+$|(Building|Current) configuration)/i) { while (<$INPUT>) { next if (/^Current configuration\s*:/i); next if (/^([%!].*|\s*)$/); last; } tr/\015//d; } # some versions have other crap mixed in with the bits in the # block above /^! Last Changed:/ && next; if (/^((enable )?password( \d)?) / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1 \n"); next; } if (/^username (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds == 2) { ProcessHistory("USER","keysort","$1","!username $1$2 password \n"); } elsif ($filter_pwds == 1 && $4 ne "5"){ ProcessHistory("USER","keysort","$1","!username $1$2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } # prune passwords {bgp, ...} if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) { ProcessHistory("","","","! neighbor $1 password \n"); next; } # sort route-maps if (/^route-map (\S+)/) { my($key) = $1; my($routemap) = $_; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || ! /^(route-map |[ !])/); if (/^route-map (\S+)/) { ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); $key = $1; $routemap = $_; } else { $routemap .= $_; } } ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); } # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order access-lists /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order logging statements /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } if (/^(snmp-server community) (\S+)/) { if (defined($ENV{'NOCOMMSTR'})) { ProcessHistory("SNMPSERVERCOMM","keysort","$_","!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # prune tacacs/radius server keys if (/^(tacacs-server|radius-server) key / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 key \n"); next; } if (/^(tacacs-server host \S+( .*)? key) (\d )?\S+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # order clns host statements # /^clns host \S+ (\S+)/ && # ProcessHistory("CLNS","keysort","$1","$_") && next; # prune isis password if (/^( isis authentication-key) \d \S+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # prune msdp password if (/^(ip msdp password \S+) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # # order ip host line statements # /^ip host line(\d+)/ && # ProcessHistory("IPHOST","numsort","$1","$_") && next; # catch anything that wasnt matched above. ProcessHistory("","","","$_"); # end of config. if (/^end$/) { $found_end = 1; return(1); } } return(0); } 1; rancid-3.13/lib/foundry.pm.in000644 015615 000000 00000022770 13657102757 016202 0ustar00heaswheel000000 000000 package foundry; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # foundry.pm - Foundry rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/\#exit$/) { $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host flogin error: $_"); print STDERR ("$host flogin error: $_") if ($debug); $clean_run = 0; last; } while (/[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; # Some devices can give an error that looks a lot like a prompt # for deprecated commands like "write term". Ignore that. if (/^invalid input -> /i) { print STDERR ("Ignoring invalid command: $cmd\n") if ($debug); last; } if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT) = @_; my($slot); print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if /^\s*$/; last if (/^$prompt/); next if (/^(The system |Crash time)/); next if (/^(System|(Active|Standby) Management|LP Slot \d+|Switch Fabric Module \d+) (uptime|Up Time) is/); # remove uptime on newer switches s/(STACKID \d+)\s+system uptime is.*$/$1/; s/^\s*(HW|SW)/$1/; s/^\s*(Compiled on)/SW: $1/; s/^\s*(\(\d+ bytes\) from )/SW: $1/; #s/^(HW.*)/$1\n/; if (/^SL (\d+)/) { $slot = "Slot $1"; s/^SL \d+/$slot/; } if (/MHz .* processor/) { $slot = "MGMT"; } s/^(\s*\d+ )/$slot:$1/; s/^===*//; ProcessHistory("VERSION","","","!$_"); } ProcessHistory("VERSION","","","!\n"); return(0); } # This routine parses "show chassis" sub ShowChassis { my($INPUT, $OUTPUT) = @_; my($skip) = 0; print STDERR " In ShowChassis: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/ from /); next if (/current temperature/i); return(1) if (/^\s+\^$/); # edgeiron invalid command if (/^---/ || /^$/) { # next section reached $skip = 0; } if (/(POWERS|TEMPERATURE READINGS)/) { $skip = 1; } if (/fan controlled temperature:/i || /fan speed switching temperature thresholds/i) { $skip = 1; } if (/THERMAL PLANE/) { $skip = 1; } if (/(pressure|altitude|temperature):/i) { $skip = 1; } s/(Fan \d+ \S+), speed .*/$1/; if (/speed/i) { $skip = 1; } next if $skip; ProcessHistory("CHASSIS","","","! $_"); } ProcessHistory("CHASSIS","","","!\n"); return(0); } # This routine parses "show flash" sub ShowFlash { my($INPUT, $OUTPUT) = @_; print STDERR " In ShowFlash: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\s*$/); return(1) if (/^\s+\^$/); # edgeiron invalid command if (/code flash free space = (\d+)/i) { my($tmp) = $1; if ($tmp >= (1024 * 1024 * 1024)) { $tmp = int($tmp / (1024 * 1024 * 1024)); $_ = "code flash free space = $tmp GB\n"; } elsif ($tmp >= (1024 * 1024)) { $tmp = int($tmp / (1024 * 1024)); $_ = "code flash free space = $tmp MB\n"; } elsif ($tmp >= (1024)) { $tmp = int($tmp / 1024); $_ = "code flash free space = $tmp KB\n"; } elsif ($tmp > 0) { $_ = "code flash free space = < 1KB\n"; } else { $_ = "code flash free space = 0 bytes\n"; } } ProcessHistory("FLASH","","","!Flash: $_"); } ProcessHistory("","","","!\n"); return; } # This routine parses "show media *" sub ShowMedia { my($INPUT, $OUTPUT) = @_; print STDERR " In ShowMedia: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return(1) if (/Invalid input (->|detected)/); return(1) if (/^\s+\^$/); # edgeiron invalid command next if (/^\s*$/); next if (/:\s*$/); ProcessHistory("MEDIA","","","!Media: $_"); } ProcessHistory("","","","!\n"); return(0); } # This routine parses "show module" sub ShowModule { my($INPUT, $OUTPUT) = @_; print STDERR " In ShowModule: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return(1) if (/Invalid input (->|detected)/); return(1) if (/^\s+\^$/); # edgeiron invalid command next if (/^\s*$/); next if (/:\s*$/); ProcessHistory("MODULE","","","!Module: $_"); } ProcessHistory("","","","!\n"); return(0); } # This routine processes a "write term" sub WriteTerm { my($INPUT, $OUTPUT) = @_; print STDERR " In WriteTerm: $_" if ($debug); while (<$INPUT>) { tr/\015//d; return(1) if (/Invalid input (->|detected)/); return(1) if (/^\s+\^$/); # edgeiron invalid command return(0) if ($found_end); # Only do this routine once last if (/^$prompt/); /current configuration\s*:/i && next; /building configuration\.+\s*/i && next; /building running-config, please wait/i && next; # edgeiron /^$/ && next; # blank lines /^ver \d+\.\d+/ && next; /^module \d+ / && next; /^ntp clock-period / && next; # kill ntp clock-period /^ length / && next; # kill length on serial lines /^ width / && next; # kill width on serial lines # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # sort secure-mac-addresses. Note: There is no way to determine which # have been added dynamically vs statically. Filter if FILTER_OSC > YES if (/secure-mac-address (\S+)/) { if ($filter_osc < 2) { ProcessHistory("SECMAC","keysort","$1","$_"); } next; } # order access-lists /^access-list\s+(\d+)\s+(perm|deny)\s+(\d\S+)(\/\d+)\s*$/ && ProcessHistory("PACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order extended access-lists /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ && ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; # order arp lists /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ && ProcessHistory("ARP","$aclsort","$1","$_") && next; # order logging statements /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune snmp-server host/community statements if (/^(snmp-server host )(\d+\.\d+\.\d+\.\d+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERHOST","ipsort","$2","!$1 $2 \n") && next; } else { ProcessHistory("SNMPSERVERHOST","ipsort","$2","$_") && next; } } if (/^(snmp-server community )(\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_","!$1$'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # order tacacs server statements if (/^(tacacs-server key )/ && $filter_pwds >= 1) { ProcessHistory("","","","! $1\n"); next; } # delete ntp auth password if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 2) { ProcessHistory("","","","!$1 \n"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { my($sortkey) = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # order ip host line statements /^ip host line(\d+)/ && ProcessHistory("IPHOST","numsort","$1","$_") && next; # order ip nat source static statements /^ip nat (\S+) source static (\S+)/ && ProcessHistory("IP NAT $1","ipsort","$2","$_") && next; # filter ssh public key if (/^(crypto key generate (rsa|dsa) public_key)/ && $filter_pwds >= 2) { ProcessHistory("","","","!$1 \n"); next; } # filter ssh private key if (/^(crypto key generate (rsa|dsa) private_key)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # filter ssl secret if (/^(crypto-ssl certificate generate secret_data)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); 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$/) { $found_end = 1; return(1); } } return(0); } 1; rancid-3.13/lib/routeros.pm.in000644 015615 000000 00000010241 13713052202 016342 0ustar00heaswheel000000 000000 package routeros; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # routeros.pm - Mikrotik RouterOS rancid procedures # # Original mtrancid was modified by Chris Boot for MikroTik. use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { $timeo = 90; # mtlogin timeout in seconds 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","D0","!\n"); ProcessHistory("COMMENTS","keysort","F0","!\n"); ProcessHistory("COMMENTS","keysort","G0","!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while (<$INPUT>) { tr/\015//d; if (/[>#]\s*quit$/) { $clean_run=1; last; } if (/^Error:/) { print STDOUT ("$host mtlogin error: $_"); print STDERR ("$host mtlogin error: $_") if ($debug); $clean_run = 0; last; } while (/\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = "\] > "; # crude but effective print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } } # This routine parses "show version" sub SystemPackagePrintDetail { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In SystemPackagePrintDetail: $_" if ($debug); my($buffer) = ""; my($name); my(%packages) = (); while (<$INPUT>) { tr/\015//d; last if (/$prompt/); next if (/^Flags:/); return(1) if (/(bad command name )/); s/^\s+//g; s/^\d+\s+//g; s/\s+$//g; if (/^$/) { if ($buffer =~ /name="(.+)"/) { $packages{$1} = $buffer; } $buffer = ""; } else { $buffer .= "$_ "; } } if ($buffer =~ /name="(.+)"/) { $packages{$1} = $buffer; } for $name (sort keys %packages) { ProcessHistory("COMMENTS","keysort","A1","# " . $packages{$name} . "\n"); } return(0); } sub SystemRouterboardPrint { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In SystemRouterboardPrint: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/(bad command name )/); s/^\s+//g; # license renewal timestamp next if (/^next-renewal-at:/i); ProcessHistory("COMMENTS","keysort","C1","# $_"); } return(0); } sub SystemLicensePrint { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In SystemLicensePrint: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/(bad command name )/); s/^\s+//g; ProcessHistory("COMMENTS","keysort","E1","# $_"); } return(0); } sub Export { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In Export: $_" if ($debug); my($buffer) = ""; while (<$INPUT>) { tr/\015//d; if (/$prompt/) { $found_end=1; $clean_run=1; return 0}; next if(/^(\s*|\s*$cmd\s*)$/); next if(/^#/); return(1) if /(bad command name )/; s/^\s+//g; # RouterOS splits long lines with backslashes - this re-joins them if (/\\\n$/) { s/\s*\\\n$//; $buffer .= $_; if (!/=$/ && !/="[^"]+$/ ) { $buffer .= " "; } } else { $buffer .= $_; # Fix quoted strings $buffer =~ s/(\S+)="(\S+)"/$1=$2/g; # skip dynamic configuration, like # set disabled=yes display-time=5s # set disabled=yes display-time=5s ($buffer = "", next) if (/set "?<\S+\s?>"? /); ProcessHistory("","","","$buffer"); $buffer = ""; } } } 1; rancid-3.13/lib/Makefile.am000644 015615 000000 00000005457 13735655205 015606 0ustar00heaswheel000000 000000 ## Process this file with automake to produce Makefile.in ## A Makefile.in is supplied, in case you do not have automake. AUTOMAKE_OPTIONS=foreign no-dependencies my_pkglibdir = $(pkglibdir) my_pkglib_DATA = rancid.pm acos.pm aeos.pm arbor.pm arcos.pm avocent.pm \ bigip.pm ciscowlc.pm \ dell.pm dnos9.pm dnos10.pm edgemax.pm edgerouter.pm exos.pm \ fortigate.pm foundry.pm frr.pm fss2.pm fxos.pm \ ios.pm iossb.pm iosshtech.pm iosxr.pm junos.pm mrv.pm nxos.pm \ panos.pm rbt.pm routeros.pm smc.pm sros.pm vrp.pm wavesvros.pm pkglib_in = $(my_pkglib_DATA:%=%.in) RANLIB= : EXTRA_DIST= $(pkglib_in) ##dist_bin_SCRIPTS= $(bin_SCRIPTS:%=%.in) CLEANFILES= rancid CLEANFILES+= $(my_pkglib_DATA) #clean: # rm -f Makefile env $(BIN_DATAS) $(BIN_PROGS) # auto_edit does the autoconf variable substitution. This allows the # substitution to have the full expansion of the variables, e.g.: $sysconfdir # will be /prefix/etc instead of ${prefix}/etc. # # This is a bit of a PITA, but is the method recommended by the autoconf # documentation. auto_edit = sed \ -e 's,@bindir\@,$(bindir),g' \ -e 's,@prefix\@,$(prefix),g' \ -e 's,@localstatedir\@,$(localstatedir),g' \ -e 's,@sysconfdir\@,$(sysconfdir),g' \ -e 's,@EXPECT_PATH\@,$(EXPECT_PATH),g' \ -e 's,@ENV_PATH\@,$(ENV_PATH),g' \ -e 's,@PERLV\@,$(PERLV),g' \ -e 's,@PERLV_PATH\@,$(PERLV_PATH),g' \ -e 's,@PYTHON3\@,$(PYTHON3),g' \ -e 's,@PYTHON3_PATH\@,$(PYTHON3_PATH),g' \ -e 's,@LG_PING_CMD\@,$(LG_PING_CMD),g' \ -e 's,@ADMINMAILPLUS\@,$(ADMINMAILPLUS),g' \ -e 's,@MAILPLUS\@,$(MAILPLUS),g' \ -e 's,@PACKAGE\@,$(PACKAGE),g' \ -e 's,@RCSSYS\@,$(RCSSYS),g' \ -e 's,@SENDMAIL\@,$(SENDMAIL),g' \ -e 's,@SVN_FSTYPE\@,$(SVN_FSTYPE),g' \ -e 's,@VERSION\@,$(VERSION),g' \ -e 's,@COPYYEARS\@,$(COPYYEARS),g' \ -e '/@copyright@/r ../COPYING' \ -e '/@copyright@/d' $(pkglib_in:%.in=%): Makefile $(top_builddir)/config.status rm -f $@ $@.tmp; \ $(auto_edit) $(srcdir)/$@.in >$@.tmp; \ chmod +r $@.tmp; \ mv $@.tmp $@ # XXX there must be a better way to produce these dependencies, perhaps in # configure. acos.pm: acos.pm.in aeos.pm: aeos.pm.in arbor.pm: arbor.pm.in arcos.pm: arcos.pm.in avocent.pm: avocent.pm.in bigip.pm: bigip.pm.in ciscowlc.pm: ciscowlc.pm.in dell.pm: dell.pm.in dnos9.pm: dnos9.pm.in dnos10.pm: dnos10.pm.in edgemax.pm: edgemax.pm.in edgerouter.pm: edgerouter.pm.in exos.pm: exos.pm.in fortigate.pm: fortigate.pm.in foundry.pm: foundry.pm.in frr.pm: frr.pm.in fss2.pm: fss2.pm.in fxos.pm: fxos.pm.in ios.pm: ios.pm.in iossb.pm: iossb.pm.in iosshtech.pm: iosshtech.pm.in iosxr.pm: iosxr.pm.in junos.pm: junos.pm.in rancid.pm: rancid.pm.in rancid.py: rancid.py.in mrv.pm: mrv.pm.in nxos.pm: nxos.pm.in panos.pm: panos.pm.in rbt.pm: rbt.pm.in routeros.pm: routeros.pm.in smc.pm: smc.pm.in sros.pm: sros.pm.in vrp.pm: vrp.pm.in wavesvros.pm: wavesvros.pm.in rancid-3.13/lib/acos.pm.in000644 015615 000000 00000012350 13532047100 015410 0ustar00heaswheel000000 000000 package acos; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # a10.pm - A10 rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; CMD: if (/[>#]\s?exit$/) { $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host a10login error: $_"); print STDERR ("$host a10login error: $_") if ($debug); $clean_run = 0; last; } while (/[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#>]+[#>])/)[0]; $prompt =~ s/([][}{)(+\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } if (defined($prompt)) { if (/$prompt/) { goto CMD; } } } } } sub basicFilter { my($INPUT, $OUTPUT, $cmd, $prefix) = @_; while (<$INPUT>) { tr/\015//d; next if (/^\s*$/); next if (/^\s*\^$/); # cli cmd error marker return(1) if (/% unrecognized command/i); # cli cmd error return(1) if (/% incomplete command/i); # cli cmd error last if (/$prompt/); s/\s*$/\n/; # trim trailing WS ProcessHistory($prefix,"","","!$prefix: $_"); } ProcessHistory($prefix,"","","!\n"); return(0); } # parses show version sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if /^\s*$/; last if (/$prompt/); next if (/Current time is/); next if (/The system has been up/); next if (/Last configuration saved/); next if (/Free Memory/); ProcessHistory("VERSION","","","!VERSION: $_"); } ProcessHistory("VERSION","","","!\n"); return(0); } # parses show admin sub ShowAdmin { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowAdmin: $_" if ($debug); return basicFilter($INPUT, $OUTPUT, $cmd, "Users"); } sub ShowAflex { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowAflex: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if /^\s*$/; last if (/^$prompt/); return(1) if (/% unrecognized command\./i); # not in CGN/LSN image s/\s*$/\n/; # trim trailing WS ProcessHistory("AFLEX", "", "", "!AFLEX: $_"); } while (/show aflex (\S+) partition/) { my($name) = $1; my($found_content) = 0; ProcessHistory("AFLEX-$name", "", "", "aflex create $name\n"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); if ($found_content) { ProcessHistory("AFLEX-$name", "", "", "$_"); } elsif (/^Content:/) { $found_content = 1 } } if ($found_content) { ProcessHistory("AFLEX-$name", "", "", ".\n"); } } ProcessHistory("ADMIN","","","!\n"); return(0); } # parses show bootimage sub ShowBootimage { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowBootimage: $_" if ($debug); return basicFilter($INPUT, $OUTPUT, $cmd, "BootImage"); } # parses show license sub ShowLicense { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowLicense: $_" if ($debug); return basicFilter($INPUT, $OUTPUT, $cmd, "LICENSE"); } # parses show running-config sub ShowRunningConfig { my($INPUT, $OUTPUT, $cmd) = @_; my $comment = 0; print STDERR " In ShowRunningConfig: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if (/^\s*$/); next if (/^\s*\^$/); # cli cmd error marker return(1) if (/% unrecognized command/i); # cli cmd error last if (/^$prompt/); return(1) if (/invalid (input|command) detected/i); # skip consecutive comment lines if (/^!\s*$/) { next if ($comment); ProcessHistory("CONFIG","","",$_); $comment = 1; next; } $comment = 0; next if (/^!(current configuration:|configuration last)/i); next if (/^vcs config-info/); if ((/^(.* password encrypted )\S+(.*)/ || /^(.* secret secret-encrypted )\w+( .*)/) && $filter_pwds >= 1) { ProcessHistory("CONFIG", "", "", "$1$2\n"); next; } if (/^(snmp-server community \S+ )\S+(.*)/ && $filter_commstr >= 1) { ProcessHistory("CONFIG", "", "", "!$1$2\n"); next; } ProcessHistory("CONFIG","","","$_"); if (/^end/) { $found_end = 1; } } ProcessHistory("CONFIG","","","\n"); return(0); } # parses show vlan sub ShowVlan { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVlan: $_" if ($debug); return basicFilter($INPUT, $OUTPUT, $cmd, "VLAN"); } 1; rancid-3.13/lib/arcos.pm.in000644 015615 000000 00000014374 13735654705 015626 0ustar00heaswheel000000 000000 package arcos; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # arcos.pm - Arrcus Arcos rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","C0","!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/[#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#>]+[#>])/)[0]; $prompt =~ s/([][}{)(+\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/[#]\s?quit$/) { $clean_run = 1; last; } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if (/^(\s*|\s*$cmd\s*)$/); last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/command authorization failed/i); # drop trailing spaces s/ *$//; /version product-name "([^\"]*)"/ && ProcessHistory("COMMENTS","keysort","A1", "!Chassis type: $1\n"); /version serial-num (\S+)/ && ProcessHistory("COMMENTS","keysort","D9", "!Serial Number: $1\n"); /version total-memory "([^\"]*)"/ && ProcessHistory("COMMENTS","keysort","B1", "!Memory: $1\n"); ProcessHistory("COMMENTS","keysort","VERSION","! $_"); } ProcessHistory("COMMENTS","keysort","VERSION","!\n"); return(0); } # This routine parses "show hardware" sub ShowHardware { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if (/^(\s*|\s*$cmd\s*)$/); last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(-1) if (/command authorization failed/i); return(-1) if (/error: application communication failure/i); # skip allocated, free, watermarks & their timestamps next if (/(estimated-free|objects-allocated|high-watermark|raw-(free|used))/); # skip feature tables if (/\s*feature$/) { while (<$INPUT>) { tr/\015//d; next if (/^(\s*|\s*$cmd\s*)$/); last if (/^$prompt/); last if (/^\s*$/); } } # drop indexer counts next if (/^\s+used\s+\d+/); next if (/^\s+hold-count\s+\d+/); # XXX for now, drop the per-unit information. Appears to be mostly # useless. last if (/^UNIT/); ProcessHistory("","","","! $_"); } ProcessHistory("","","","!\n"); return(0); } # This routine processes a "show running-config" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($comment, $linecnt); while (<$INPUT>) { TOP: tr/\015//d; last if (/^$prompt/); return(1) if (!$linecnt && /^\s+\^\s*$/); next if (/^\s*$cmd\s*$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(1) if (/\%Error: No such file or directory/); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(0) if ($found_end); # Only do this routine once return(-1) if (/command authorization failed/i); return(-1) if (/error: application communication failure/i); return(-1) if (/% ?configuration buffer full/i); /^! no configuration change since last restart/i && next; # skip emtpy lines at the beginning if (!$linecnt && /^\s*$/) { next; } /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked /% Configuration buffer full, / && return(-1); # buffer is in use $linecnt++; # skip the crap if (/^(##+|(building|current) configuration)/i) { while (<$INPUT>) { next if (/^Current configuration\s*:/i); next if (/^:/); next if (/^([%!].*|\s*)$/); next if (/^ip add.*ipv4:/); # band-aid for 3620 12.0S last; } tr/\015//d; } # config timestamp on MDS/NX-OS /Time: / && next; # skip consecutive comment lines to avoid oscillating extra comment # line on some access servers. grrr. if (/^!\s*$/) { next if ($comment); ProcessHistory("","","",$_); $comment++; next; } $comment = 0; # prune bgp passwords, possibly others if (/^(\s+auth-password\s+)(\S+)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1$'"); next; } # XXX prune snmp communities #if (/^(snmp-server .*community) ([08] )?(\S+)/) { # if ($filter_commstr) { # ProcessHistory("SNMPSERVERCOMM","keysort","$_", "!$1 $'") && next; # } else { # ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; # } #} # prune tacacs/radius server keys if (/^(\s+(tacacs|radius) secret-key\s)(\S+)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1$'"); next; } # catch anything that wasnt matched above. ProcessHistory("","","","$_"); } # arcos lacks a definitive "end of config" marker. if we have seen at # least 5 lines of input, we can be reasonably sure that we have the config. if ($linecnt > 5) { $found_end = 1; } return(0); } 1; rancid-3.13/lib/fortigate.pm.in000644 015615 000000 00000010563 13532047132 016460 0ustar00heaswheel000000 000000 package fortigate; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # A library built on Stephen Gill's Netscreen stuff to accomodate # the Fortinet/Fortigate product line. [d_pfleger@juniper.net] # # fortigate.pm - Fortigate rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: $devtype\n#\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host fnlogin error: $_"); print STDERR ("$host fnlogin error: $_") if ($debug); $clean_run = 0; last; } while (/^.+[#\$]\s*($cmds_regexp)\s*$/) { $cmd = $1; # FortiGate prompts end with either '#' or '$'. Further, they may # be prepended with a '~' if the hostname is too long. Therefore, # we need to figure out what our prompt really is. if (!defined($prompt)) { $prompt = ($_ =~ /^([^#\$]+~?[#\$])/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; # add the possible ~ $prompt =~ s/~?([#\$])/~?\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (!defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/[#\$]\s?exit$/) { $clean_run = 1; last; } } } # This routine parses "get system" sub GetSystem { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In GetSystem: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if /^\s*$/; last if (/$prompt/); if ($filter_osc >= 2) { next if (/^\s*APP-DB: .*/); next if (/^\s*Botnet DB: .*/); next if (/^\s*Extended DB: .*/); next if (/^\s*industrial-db: .*/i); next if (/^\s*IPS-DB: .*/); next if (/^\s*IPS-ETDB: .*/); next if (/^\s*IPS Malicious URL Database: .*/); next if (/^\s*Virus-DB: .*/); } next if (/^system time:/i); next if (/^FortiClient application signature package:/); # Cluster uptime next if (/^\s*Cluster uptime:/); ProcessHistory("","","","#$_"); } ProcessHistory("SYSTEM","","","\n"); return(0); } sub GetFile { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In GetFile: $_" if ($debug); while (<$INPUT>) { last if (/$prompt/); } ProcessHistory("FILE","","","\n"); return(0); } sub GetConf { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In GetConf: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if /^\s*$/; last if (/$prompt/); # System time is fortigate extraction time next if (/^\s*!System time:/); # remove occurrances of conf_file_ver next if (/^#?conf_file_ver=/); # filter last-login if (/^(\s*set)\slast-login\s(.*)/ && $filter_osc) { ProcessHistory("","","","#$1 last-login \n"); next; } # filter cycling RSA private keys if ($filter_osc && /^\s*set private-key "-----BEGIN (RSA|ENCRYPTED) PRIVATE KEY-----/) { ProcessHistory("","","","#$_"); ProcessHistory("","","","# \n"); while (<$INPUT>) { tr/\015//d; goto ENDGETCONF if (/$prompt/); if (/^\s*-----END (RSA|ENCRYPTED) PRIVATE KEY-----"/) { ProcessHistory("","","","#$_"); last; } } next; } # filter ospf md5-keys if (/^(\s*set)\smd5-key\s(\d+)\s(.*)/ && $filter_osc) { ProcessHistory("","","","#$1 md5-key $2 \n"); next; } # filter cycling password encryption if (/^(\s*set \S*( \d+)?)\s("?enc\s\S+"?)(.*)/i && ($filter_osc || $filter_pwds > 0)) { ProcessHistory("ENC","","","#$1 ENC $4\n"); next; } ProcessHistory("","","","$_"); } ENDGETCONF: $found_end = 1; return(1); } 1; rancid-3.13/lib/rancid.pm.in000644 015615 000000 00000034707 13665233101 015742 0ustar00heaswheel000000 000000 package rancid; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # rancid.pm - base/basic rancid procedures # use 5.010; use strict 'vars'; use warnings; use 2.006 Socket qw(AF_INET AF_INET6 inet_pton); use File::Spec; require(Exporter); our @ISA = qw(Exporter); our $VERSION; our @commandtable; # command lists our %commands; our @commands; our $commandcnt; # number of members in @commandtable our $commandstr; # command string for lscript -c our $cmds_regexp; # command regex for matching input our $devtype; # device type argument our $filter_commstr; # SNMP community string filtering our $filter_osc; # oscillating data filtering mode our $filter_pwds; # password filtering mode our $aclsort; # ACL sorting mode our $aclfilterseq; # ACL sequence filtering mode our $log; # log cmdline option our $debug; # debug cmdline option our $file; # file cmdline option our $host; # hostname from cmdline our $clean_run; # successful run our $found_end; # found end of the config our $timeo; # login script timeout in seconds our $timeodef; # login script timeout in seconds dflt our $prompt; # device prompt regex use vars qw{$script $lscript @modules}; # script, login script, module name(s) use vars qw{$inloop} ; # inloop func use vars qw{$command $hist_tag}; # ProcessHistory state use vars qw{%history @history}; # ProcessHistory state our @EXPORT = qw($VERSION $devtype $script $lscript @modules $inloop @commandtable %commands @commands $commandcnt $commandstr $cmds_regexp $filter_commstr $filter_osc $filter_pwds $aclsort $aclfilterseq $log $debug $file $host $clean_run $found_end $timeo $timeodef $prompt bytes2human diskszsummary human2bytes ipsort ipaddrval loadtype keynsort keysort numerically numsort ProcessHistory rancidinit RunCommand sortbyipaddr valsort which); BEGIN { $VERSION = '@VERSION@'; } # initialize common rancid parameters and handle command-line arguments. sub rancidinit { my($i); if ($main::opt_V) { print "@PACKAGE@ @VERSION@\n"; exit(0); } $command = $hist_tag = ""; # ProcessHistory state for (keys(%history)) { delete $history{$_}; } @history = (); $log = $main::opt_l; $debug = $main::opt_d; $file = $main::opt_f; $host = defined($ARGV[0]) ? $ARGV[0] : ""; $clean_run = 0; $found_end = 0; $timeodef = 90; # login script timeout in seconds $timeo = $timeodef; # login script timeout in seconds $aclsort = "ipsort"; # ACL sorting mode # determine ACL sorting mode if (defined($ENV{"ACLSORT"}) && $ENV{"ACLSORT"} =~ /no/i) { $aclsort = ""; } if (defined($ENV{"ACLFILTERSEQ"}) && $ENV{"ACLFILTERSEQ"} =~ /no/i) { $aclfilterseq = "0"; } else { $aclfilterseq = "1"; } # determine community string filtering mode if (defined($ENV{"NOCOMMSTR"}) && $ENV{"NOCOMMSTR"} =~ /yes/i) { $filter_commstr = 1; } else { $filter_commstr = 0; } # determine oscillating data filtering mode if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) { $filter_osc = 0; } elsif (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /all/i) { $filter_osc = 2; } else { $filter_osc = 1; } # determine password filtering mode if (defined($ENV{"FILTER_PWDS"}) && $ENV{"FILTER_PWDS"} =~ /no/i) { $filter_pwds = 0; } elsif (defined($ENV{"FILTER_PWDS"}) && $ENV{"FILTER_PWDS"} =~ /all/i) { $filter_pwds = 2; } else { $filter_pwds = 1; } if (!$main::opt_C && length($host) == 0) { if ($main::file) { print(STDERR "Too few arguments: file name required\n"); exit(1); } else { print(STDERR "Too few arguments: host name required\n"); exit(1); } } if (!defined($main::opt_t) || length($main::opt_t) == 0) { print(STDERR "Too few arguments: -t option is required\n"); exit(1); } $devtype = lc($main::opt_t); # make OUTPUT unbuffered if debugging if ($debug) { $| = 1; } 1; } # load rancid device-type spec/info from etc/rancid.types.* config files, then # load modules & handle -C option, if present. # usage: loadtype(device_type) sub loadtype { my($devtype) = @_; my($file, $line, $matched); @commandtable = (); $commandcnt = 0; if (!defined($devtype) || length($devtype) == 0) { print STDERR "loadtype(): device_type is empty\n"; return 1; } print STDERR "loadtype: device type $devtype\n" if ($debug); # which device type configuration file has the definition of $devtype? foreach $file ("@sysconfdir@/rancid.types.base", "@sysconfdir@/rancid.types.conf") { $line = 0; open(INPUT, "< $file") || die "Could not open $file: $!"; while () { $line++; chomp; next if (/^\s*$/ || /^\s*#/); my(@line) = split('\;'); # check number of fields if (($#line + 1) < 3) { printf(STDERR "loadtype: insufficient number of fields $#line at %s:%d\n", $file, $line); return(-1); } my($type, $directive, $value) = @line; $type =~ tr/[A-Z]/[a-z]/; $directive =~ tr/[A-Z]/[a-z]/; next if ($type ne $devtype); if (!$matched) { $matched++; printf(STDERR "loadtype: found device type %s at %s:%d\n", $devtype, $file, $line) if ($debug); } if ($directive eq "alias") { # an alias maps a name to another, like a DNS CNAME; it does # NOT augment printf(STDERR "loadtype: found device type %s aliased to %s\n", $devtype, $value) if ($debug); if (length($value) < 1) { printf(STDERR "loadtype: type %s alias has no value at %s:%d\n", $devtype, $file, $line); close(INPUT); return(-1); } $value =~ tr/[A-Z]/[a-z]/; if ($devtype eq $value) { printf(STDERR "loadtype: type %s aliased to itself at %s:%d\n", $devtype, $file, $line); close(INPUT); return(-1); } close(INPUT); undef($script); undef($lscript); undef(@modules); undef($inloop); undef(@commandtable); $timeo = $timeodef; return(loadtype($value)); } elsif ($directive eq "script") { $script = $value; } elsif ($directive eq "login") { $lscript = $value; } elsif ($directive eq "module") { push(@modules, $value); } elsif ($directive eq "inloop") { $inloop = $value; } elsif ($directive eq "command") { if (($#line + 1) < 4) { printf(STDERR "loadtype: insufficient number of fields at %s:%d\n", $file, $line); return(-1); } push(@commandtable, {$line[3], $value}); } elsif ($directive eq "timeout") { $timeo = $value; } else { printf(STDERR "loadtype: unknown directive %s at %s:%s\n", $directive, $file, $line); close(INPUT); return(-1); } } close(INPUT); # do not parse rancid.types.conf if we found any device type matches # in rancid.types.base. last if ($matched); } # load device-type specific modules if (length($#modules)) { my($module); foreach $module (@modules) { eval { (my $file = $module) =~ s/::/\//g; require $file . '.pm'; # call module->import(); we expect 0 as success, as god intended it # XXX how the fuck is this done w/o the eval and w/o a temp var? eval($module ."::import();") ? 0 : 1; } or do { # Module load failed my($error) = $@; print STDERR "loadtype: loading $module failed: ". "$error\n"; return(-1); }; } } # 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); $commandcnt = scalar(keys(%commands)); $commandstr = join(";", @commands); $cmds_regexp = join("|", map quotemeta($_), @commands); # check that the functions exist if ($commandcnt) { my($func); foreach $func (values(%commands)) { if (! defined(&{$func})) { printf(STDERR "loadtype: undefined function in %s: %s\n", $devtype, $func); close(INPUT); return(-1); } } } if ($main::opt_C) { my($cmd, @script); if (!defined($script) || length($script) < 1) { printf(STDERR "$devtype: login script not defined\n"); exit(1); } # if the first word of $script is not us (this script), exec the given # script. @script = split(/\s+/, $script); if (which($script[0]) ne which($0)) { # -[hV] are not handled; they will have already been handled sooner. push(@script, "-d") if $debug; push(@script, "-l") if $log; push(@script, "-C") if $main::opt_C; push(@script, "-f") if $rancid::file; push(@script, $host); exec(join(" ", @script)) || printf(STDERR "exec($script[0]) failed: $!\n"); exit(-1); } if (!defined($lscript)) { printf(STDERR "$devtype: login script not defined\n"); exit(1); } $cmd = $lscript; if (defined($timeo)) { $cmd .= " -t $timeo"; } print "$cmd -c \'$commandstr\' $host\n"; exit(0); } 0; } # This routine is used to print out the router configuration. Each line is # fed to ProcessHistory([tag], [output/sort func], [func argument], line/string) # which outputs the line/strings if there is no tag or sort function, else it # accumulates the lines/strings until either the optional tag changes or the # optional output function changes. sub ProcessHistory { my($new_hist_tag, $new_command, $command_string, @string) = (@_); if ((($new_hist_tag ne $hist_tag) || ($new_command ne $command)) && scalar(%history)) { print eval "$command \%history"; undef %history; } if (($new_hist_tag) && ($new_command) && ($command_string)) { if ($history{$command_string}) { $history{$command_string} = "$history{$command_string}@string"; } else { $history{$command_string} = "@string"; } } elsif (($new_hist_tag) && ($new_command)) { $history{++$#history} = "@string"; } else { print "@string"; } $hist_tag = $new_hist_tag; $command = $new_command; 1; } # convert bytes to human-readable format (ie GB/MB/KB/etc) sub bytes2human { my($cnt) = @_; if ($cnt >= (1024 * 1024 * 1024)) { $cnt = int($cnt / (1024 * 1024 * 1024)); return("$cnt GB"); } elsif ($cnt >= (1024 * 1024)) { $cnt = int($cnt / (1024 * 1024)); return("$cnt MB"); } elsif ($cnt >= (1024)) { $cnt = int($cnt / 1024); return("$cnt KB"); } elsif ($cnt > 0) { return("<1KB"); } else { return("0 KB"); } } # summarize total flash/disk space as human-readable form and remaining space # as a percentage. unknown variables should be 'undef'. returns a string, # without a trailing . sub diskszsummary { my($total, $free, $used) = @_; my($pcnt); # remove commas $total = human2bytes($total) if (defined($total)); $free = human2bytes($free) if (defined($free)); $used = human2bytes($used) if (defined($used)); if (defined($free)) { $pcnt = int($free / $total * 100); } elsif (defined($used)) { $pcnt = int(($total - $used) / $total * 100); } else { $total = $free + $used; $pcnt = int($free / $total * 100); } $total = bytes2human($total); return("$total total ($pcnt% free)"); } # convert human-readable format (like "300,024 GB/MB/KB/etc") to bytes sub human2bytes { my($cnt) = @_; my($mp); $cnt =~ s/,//g; if ($cnt =~ /gb/i) { $mp = 1024 * 1024 * 1024; } elsif ($cnt =~ /mb/i) { $mp = 1024 * 1024; } elsif ($cnt =~ /kb/i) { $mp = 1024; } else { $mp = 1; } $cnt =~ /(\d+)/; return($1 * $mp); } sub numerically { $a <=> $b; } # keynsort(%hash) is a sort routine that will sort numerically on the # keys of the hash as if it were a normal array. sub keynsort { my(%lines) = @_; my($i) = 0; my($key, @sorted_lines); foreach $key (sort numerically keys(%lines)) { $sorted_lines[$i++] = $lines{$key}; } @sorted_lines; } # keysort(%hash) is a sort routine that will sort alpha-numerically on the # keys of the hash as if it were a normal array. sub keysort { my(%lines) = @_; my($i) = 0; my($key, @sorted_lines); foreach $key (sort keys(%lines)) { $sorted_lines[$i++] = $lines{$key}; } @sorted_lines; } # valsort(%hash) is a sort routine that will sort on the values of the hash # as if it were a normal array. sub valsort { my(%lines) = @_; my($i) = 0; my($key, @sorted_lines); foreach $key (sort values(%lines)) { $sorted_lines[$i++] = $key; } @sorted_lines; } # numsort(%hash) is a numerical sort routine (ascending). sub numsort { my(%lines) = @_; my($i) = 0; my($num, @sorted_lines); foreach $num (sort {$a <=> $b} keys(%lines)) { $sorted_lines[$i++] = $lines{$num}; } @sorted_lines; } # ipsort(%hash) is a sort routine that will sort on the IPv4/v6 address keys # of the hash as if it were a normal array. sub ipsort { my(%lines) = @_; my($i) = 0; my($addr, @sorted_lines); foreach $addr (sort sortbyipaddr keys(%lines)) { $sorted_lines[$i++] = $lines{$addr}; } @sorted_lines; } # ipaddrval(IPaddr) converts and IPv4/v6 address to a string for comparison. # Some may ask why not use Net::IP; performance. We tried and it was horribly # slow. sub ipaddrval { my($a) = @_; my($norder); if ($a =~ /:/) { my($l); ($a, $l) = split(/\//, $a); if (!defined($l)) { $l = 128; } $norder = inet_pton(AF_INET6, $a); if (defined($norder)) { return unpack("H*", $norder) . unpack("H*", pack("C", $l)); } } else { my($l); ($a, $l) = split(/\//, $a); if (!defined($l)) { $l = 32; } $norder = inet_pton(AF_INET, $a); if (defined($norder)) { return(unpack("H*", $norder) . unpack("H*", pack("C", $l))); } } # otherwise return the original key value, so as not to sort on null return($_[0]); } # sortbyipaddr(IPaddr, IPaddr) compares two IPv4/v6 addresses like strcmp(). sub sortbyipaddr { &ipaddrval($a) cmp &ipaddrval($b); } # if $prog is non-FQPN, look for it in PATH and return the ABS-FQPN, else # just return the ABS-FQPN. sub which { my($prog) = @_; my($path); # ABS or relative PATH (begins with /, ./, or ../) if ($prog =~ /^(\/|\.\/|\.\.\/)/) { return(File::Spec->rel2abs($prog)); } for $path (split(/:/, $ENV{"PATH"})) { $path = join('/', ($path, $prog)); if (-f $path) { return(File::Spec->rel2abs($path)); } } return($prog); } # This routine parses a single command that returns no required info; the # input is discarded. sub RunCommand { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In RunCommand: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); } return(0); } 1; rancid-3.13/lib/junos.pm.in000644 015615 000000 00000044304 13735654705 015651 0ustar00heaswheel000000 000000 package junos; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # junos.pm - Juniper JunOS rancid procedures # use 5.010; use strict 'vars'; use warnings; require(Exporter); our @ISA = qw(Exporter); $Exporter::Verbose=1; use rancid @VERSION@; our $ShowChassisSCB; # Only run ShowChassisSCB() once our $ShowChassisFirmware; # Only run ShowChassisFirmware() once @ISA = qw(Exporter rancid main); #our @EXPORT = qw($VERSION) # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: $devtype\n#\n"); $junos::ShowChassisFirmware = 0; 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while (<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host jlogin error: $_"); print STDERR ("$host jlogin error: $_") if ($debug); $clean_run = 0; last; } if (/System shutdown message/) { print STDOUT ("$host shutdown msg: $_"); print STDERR ("$host shutdown msg: $_") if ($debug); $clean_run = 0; last; } if (/error: cli version does not match Managment Daemon/i) { print STDOUT ("$host mgd version mismatch: $_"); print STDERR ("$host mgd version mismatch: $_") if ($debug); $clean_run = 0; last; } while (/>\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^>]+>)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/>\s*quit/) { $clean_run = 1; last; } } } # This routine parses "show chassis clocks" sub ShowChassisClocks { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassisClocks: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /error: the chassis(-control)? subsystem is not r/ && return(-1); /error: abnormal communication termination with / && return(-1); /error: invalid xml tag / && return(-1); /Couldn\'t initiate connection/ && return(-1); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); # filter decimal places of m160 measured clock MHz if (/Measured frequency/) { s/\..*MHz/ MHz/; } elsif (/^.+\.[0-9]+ MHz$/) { # filter for the m160 (newer format) s/\.[0-9]+ MHz/ MHz/; } elsif (/^(.+)(\.[0-9]+) MHz/) { # filter for T series my($leadlen) = length($1); my($x); $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); } # This routine parses "show chassis environment" sub ShowChassisEnvironment { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassisEnvironment: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return 1 if (/^aborted!/i); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /error: the chassis(-control)? subsystem is not r/ && return(-1); /Couldn\'t initiate connection/ && return(-1); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); / backplane temperature/ && next; /(\s*Power supply.*), temperature/ && ProcessHistory("","","","# $1\n") && next; /(\s*.+) +-?\d+ degrees C.*$/ && ProcessHistory("","","","# $1\n") && next; /(^.*\S)\s+ Spinning at .*$/ && ProcessHistory("","","","# $1\n") && next; /(^.*\S)\s+ \d+ RPM$/ && ProcessHistory("","","","# $1\n") && next; /(^.*\S)\s+Measurement/ && ProcessHistory("","","","# $1\n") && next; ProcessHistory("","","","# $_"); } return(0); } # This routine parses "show chassis firmware" sub ShowChassisFirmware { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassisFirmware: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return(1) if (/^aborted!/i); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); return(0) if ($junos::ShowChassisFirmware); /error: the chassis(-control)? subsystem is not r/ && return(-1); /Couldn\'t initiate connection/ && return(-1); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); s/\s*$//; ProcessHistory("","","","# $_\n"); } $ShowChassisFirmware = 1; return(0); } # This routine parses "show chassis fpc detail" sub ShowChassisFpcDetail { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassisFpcDetail: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return 1 if (/^aborted!/i); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /error: the chassis(-control)? subsystem is not r/ && return(-1); /Couldn\'t initiate connection/ && return(-1); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); / Temperature/ && next; / Start time/ && next; / Uptime/ && next; ProcessHistory("","","","# $_"); } return(0); } # This routine parses "show chassis hardware" sub ShowChassisHardware { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassisHardware: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return 1 if (/^aborted!/i); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /error: the chassis(-control)? subsystem is not r/ && return(-1); /Couldn\'t initiate connection/ && return(-1); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); ProcessHistory("","","","# $_"); } return(0); } # This routine parses "show chassis routing-engine" # Most output is ignored. sub ShowChassisRoutingEngine { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassisRoutingEngine: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /error: the chassis(-control)? subsystem is not r/ && return(-1); /Couldn\'t initiate connection/ && return(-1); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); /^Routing Engine status:/ && ProcessHistory("","","","# $_") && next; / Slot / && ProcessHistory("","","","# $_") && next; / Current state/ && ProcessHistory("","","","# $_") && next; / Election priority/ && ProcessHistory("","","","# $_") && next; s/ (DRAM\s+)\d+ \w+ \((\d+ \w+) installed\)\s*/ $1$2\n/ && ProcessHistory("","","","# $_") && next; / DRAM/ && ProcessHistory("","","","# $_") && next; / Model/ && ProcessHistory("","","","# $_") && next; / Serial ID/ && ProcessHistory("","","","# $_") && next; /^\s*$/ && ProcessHistory("","","","# $_") && next; } return(0); } # This routine parses "show chassis cfeb", "show chassis feb", "show # chassis scb", "show chassis sfm detail", and "show chassis ssb". # Only do this routine once. sub ShowChassisSCB { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassisSCB: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); return(0) if ($junos::ShowChassisSCB); /error: the chassis(-control)? subsystem is not r/ && return(-1); /Couldn\'t initiate connection/ && return(-1); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); / Temperature/ && next; / temperature/ && next; / utilization/ && next; / Start time/ && next; / Uptime/ && next; / (IP|MLPS) routes:/ && next; / used:/ && next; ProcessHistory("","","","# $_"); } $ShowChassisSCB = 1; return(0); } # This routine parses "show chassis alarms" sub ShowChassisAlarms { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowChassisAlarms: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); ProcessHistory("","","","# $_"); } return(0); } # This routine parses "show system autoinstallation status" sub ShowSystemAutoinstall { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSystemAutoinstall: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); ProcessHistory("","","","# $_"); } return(0); } # This routine parses "show system configuration database usage" # XXX this does not work with older JunOS because the unrecognized command # is mangled by the cli parser and then does not match what was sent! # so, this is a stand-alone function for now. sub ShowSystemConfDB { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSystemConfDB: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; ($found_end = 1, last) if (/^$prompt/); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /Unrecognized command/ && return(0); /command is not valid/ && return(0); /^\s+\^/ && return(0); /syntax error/ && return(0); # trim fractional part of the sizes to reduce churn s/\.\d+ ([GKM]B)/ $1/; ProcessHistory("","","","# $_"); } return(0); } sub ShowSystemCoreDumps { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSystemCoreDumps: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); /^JUNOS / && <$INPUT> && next; /No such file or directory$/ && next; ProcessHistory("","","","# $_"); } return(0); } # This routine parses "show system license" sub ShowSystemLicense { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSystemLicense: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); return -1 if (/error: select: protocol failure /i); return -1 if (/error: abnormal communication /i); # licenses used changes constantly. distill it to a percentage. # example input: # License usage: # Licenses Licenses Licenses Expiry # Feature name used installed needed # dynamic-vpn 1 2 0 permanent if (/^(\s+(?:VMX|dynamic|mobile|scale|service|scale-subscriber|subscriber)-\S+)(\s+)(\d+)(\s+\d+)(.*$)/) { my($a, $sp, $used, $avail, $rem) = ($1, $2, $3, $4, $5); my($spl, $usedl) = (length($sp), length($used)); my($pcnt, $usage, $usagel); if ($avail < 1) { $pcnt = ">100"; $usage = ">0"; } else { if ($filter_osc >= 2) { $usage = "--"; } elsif ($avail < 100) { # if license count is small, percentage doesn't do much to # stabilize the output - just skip it. $usage = "--"; } else { $pcnt = int(($used + 0.0) / ($avail + 0.0) * 100); $usage = sprintf("%s%%", $pcnt); } } $usagel = length($usage) ; $spl = $spl + $usedl - $usagel; my($fmt) = "%s%-" . $spl . "s%s%s%s\n"; $_ = sprintf($fmt, $a, "", $usage, $avail, $rem); } /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); ProcessHistory("","","","# $_"); } return(0); } # This routine parses "show system license keys" sub ShowSystemLicenseKeys { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSystemLicenseKeys: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); ProcessHistory("","","","# $_"); } return(0); } # This routine parses "show system boot-messages" sub ShowSystemBootMessages { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSystemBootMessages: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /Unrecognized command/ && return(1); /command is not valid/ && return(1); /^\s+\^/ && return(1); /syntax error/ && return(1); /^JUNOS / && <$INPUT> && next; /^Timecounter "TSC" / && next; /^real memory / && next; /^avail memory / && next; /^\/dev\// && next; ProcessHistory("","","","# $_"); } return(0); } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return -1 if (/select: protocol failure /i); # fail sending cmd next if (/^\s*$/); next if (/^system (shutdown message from|going down )/i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); /error: abnormal communication termination with / && return(-1); /error: could not connect to \S+ ?: no route to host/i && return(1); /warning: .* subsystem not running - not needed by configuration/ && next; /^Juniper Networks is:/ && ProcessHistory("","","","# \n# $_") && next; ProcessHistory("","","","# $_"); } ProcessHistory("","","","#\n"); return(0); } # This routine parses "show configuration" sub ShowConfiguration { my($INPUT, $OUTPUT, $cmd) = @_; my($lines) = 0; my($snmp) = 0; print STDERR " In ShowConfiguration: $_" if ($debug); s/^[a-z]+@//; ProcessHistory("","","","# $_"); while (<$INPUT>) { tr/\015//d; next if (/^\s*$/); # end of config - hopefully. juniper does not have a reliable # end-of-config tag. appears to end with "\nPROMPT>", but not sure. if (/^$prompt/) { $found_end++; last; } next if (/^system (shutdown message from|going down )/i); next if (/^## last commit: /i); next if (/^\{(master|backup|linecard|primary|secondary)(:(node)?\d+)?\}/); $lines++; /^database header mismatch: / && return(-1); /^version .*;\d+$/ && return(-1); s/ # SECRET-DATA$//; s/ ## SECRET-DATA$//; # filter snmp community, when in snmp { stanza } /^snmp/ && $snmp++; /^}/ && ($snmp = 0); if ($snmp && /^(\s*)(community|trap-group) [^ ;]+(\s?[;{])$/) { if ($filter_commstr) { $_ = "$1$2 \"\"$3\n"; } } if (/(\s*authentication-key )[^ ;]+/ && $filter_pwds >= 1) { ProcessHistory("","","","#$1$'"); next; } if (/(\s*md5 \d+ key )[^ ;]+/ && $filter_pwds >= 1) { ProcessHistory("","","","#$1$'"); next; } if (/(\s*hello-authentication-key )[^ ;]+/ && $filter_pwds >= 1) { ProcessHistory("","","","#$1$'"); next; } # don't filter this one - there is no secret here. if (/^\s*permissions .* secret /) { ProcessHistory("","","","$_"); next; } if (/^(.*\s(secret|simple-password) )[^ ;]+/ && $filter_pwds >= 1) { ProcessHistory("","","","#$1$'"); next; } if (/(\s+encrypted-password )[^ ;]+/ && $filter_pwds >= 2) { ProcessHistory("","","","#$1$'"); next; } if (/(\s+ssh-(rsa|dsa) )\"/ && $filter_pwds >= 2) { ProcessHistory("","","","#$1;\n"); next; } if (/^(\s+(pre-shared-|)key (ascii-text|hexadecimal) )[^ ;]+/ && $filter_pwds >= 1) { ProcessHistory("","","","#$1$'"); next; } ProcessHistory("","","","$_"); } if ($lines < 3) { printf(STDERR "ERROR: $host configuration appears truncated.\n"); $found_end = 0; return(-1); } return(0); } 1; rancid-3.13/lib/edgerouter.pm.in000644 015615 000000 00000014216 13532047137 016645 0ustar00heaswheel000000 000000 package edgerouter; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # edgerouter.pm - Ubiquity ("UBNT") EdgeRouter switch rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: $devtype\n#\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host flogin error: $_"); print STDERR ("$host flogin error: $_") if ($debug); $clean_run = 0; last; } while (/[\$#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^\$#]+[\$#])/)[0]; $prompt =~ s/([][}{)(\\\$])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/[\#\$]\s?(exit|logout)$/) { $clean_run = 1; last; } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT) = @_; my($slot); print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/invalid (input|command) detected/i); return(-1) if (/^plat exception:/i); # failure to connect? next if /^\s*$/; next if (/^(uptime|copyright):/i); ProcessHistory("VERSION","","","#$_"); } ProcessHistory("VERSION","","","#\n"); return(0); } # This routine parses "show hardware" sub ShowHardware { my($INPUT, $OUTPUT) = @_; print STDERR " In ShowHardware: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/invalid (input|command) detected/i); ProcessHistory("HARDWARE","","","#$_"); } ProcessHistory("HARDWARE","","","#\n"); return(0); } # This routine parses "show ubnt Offload" sub ShowOffload { my($INPUT, $OUTPUT) = @_; print STDERR " In ShowEnvironment: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/invalid (input|command) detected/i); next if (/^\s*$/); ProcessHistory("OFFLOAD","","","#$_"); } ProcessHistory("","","","#\n"); return; } # This routine processes a "write running-config" sub WriteTerm { my($INPUT, $OUTPUT) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($comment, $linecnt) = (0, 0); # reset our end marker, if WriteTerm is called multiple times, eg: bird vers $found_end = 0; ProcessHistory("CMD","","","# $_"); while (<$INPUT>) { tr/\015//d; next if (/^\s+\^$/); return(1) if (/invalid (input|command) detected/i); return(0) if ($found_end); # Only do this routine once last if (/^$prompt/); $linecnt++; /^\s*$/ && next; # blank lines # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # XXX TBD ## order access-lists #/^access-list\s+(\d\d?)\s+(\S+)\s+([a-zA-Z]\S+)/ && # ProcessHistory("ACL $1 $2","$aclsort","-1","$_") && next; #/^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && # ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; ## order extended access-lists #/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ && # ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; #/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ && # ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; #/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ && # ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; ## oreder ip routes #/^ip route\s+(\S+)\s+/ && # ProcessHistory("ROUTE","ipsort","$1","$_") && next; ## order/prune snmp-server host/community statements ## snmp-server host ip.add.r "public" ## snmp-server host ip.add.r informs "public" ## snmp-server host ip.add.r informs retries 1 "public" #if (/^(snmp-server host )(\d+\.\d+\.\d+\.\d+ ([^"]*)?)/) { # if ($filter_commstr) { # ProcessHistory("SNMPSERVERHOST","ipsort","$2","#$1$2\n") && next; # } else { # ProcessHistory("SNMPSERVERHOST","ipsort","$2","$_") && next; # } #} if (/^(\s*community)\s+(\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_","#$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } ## filter tacacs key statements #if (/^(tacacs-server key )/ && $filter_pwds >= 1) { # ProcessHistory("","","","# $1\n"); # next; #} # filter ssh public keys if (/^(\s*key) \S+\s*$/ && $filter_pwds >= 2) { ProcessHistory("","","","#$1 \n"); next; } # filter user plaintext password if (/^(\s*plaintext-password)\s+\S+$/ && $filter_pwds >= 1) { ProcessHistory("","","","#$1 \n"); next; } # filter user encrypted password if (/^(\s*encrypted-password)\s+\S+$/ && $filter_pwds >= 2) { ProcessHistory("","","","#$1 \n"); next; } # filter protocol (bgp, etc) password if (/^(\s*password)\s+\S+$/ && $filter_pwds >= 1) { ProcessHistory("","","","#$1 \n"); next; } ProcessHistory("","","","$_"); } # The Edgemax lacks a definitive "end of config" marker. If we have at # least 5 lines of output, we can be reasonably sure that we have the # config. if ($linecnt > 5) { $found_end = 1; return(0); } return(0); } 1; rancid-3.13/lib/edgemax.pm.in000644 015615 000000 00000020362 13657102757 016121 0ustar00heaswheel000000 000000 package edgemax; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # edgemax.pm - Ubiquity ("UBNT") EdgeMAX switch rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/\#exit$/) { $clean_run = 1; last; } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT) = @_; my($slot); print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/invalid (input|command) detected/i); next if /^\s*$/; ProcessHistory("VERSION","","","!$_"); } ProcessHistory("VERSION","","","!\n"); return(0); } # This routine parses "show bootvar" sub ShowBootvar { my($INPUT, $OUTPUT) = @_; my($skip) = 0; print STDERR " In ShowBootvar: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/invalid (input|command) detected/i); ProcessHistory("BOOTVAR","","","!$_"); } ProcessHistory("BOOTVAR","","","!\n"); return(0); } # This routine parses "show hardware" sub ShowHardware { my($INPUT, $OUTPUT) = @_; print STDERR " In ShowHardware: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/invalid (input|command) detected/i); ProcessHistory("HARDWARE","","","!$_"); } ProcessHistory("HARDWARE","","","!\n"); return(0); } # This routine parses "show environment" sub ShowEnvironment { my($INPUT, $OUTPUT) = @_; print STDERR " In ShowEnvironment: $_" if ($debug); TOP:while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/invalid (input|command) detected/i); next if (/^\s*$/); if (/^temperature sensors:/i) { while (<$INPUT>) { tr/\015//d; last if (/^\s*$/); last if (/^$prompt/); } next; } /^(temperature status:.*)/i && ProcessHistory("ENV","","","!$_!\n") && next; next if (/^fan speed level:/i); # trim speed/duty from fan info: # Fans: # Unit Fan Description Type Speed Duty level State # ---- --- -------------- --------- ------------- ------------- -------------- # 1 1 Fan-1 Fixed 0 50% Operational # 1 2 Fan-2 Fixed 0 50% Operational # OR # Fans: # Unit Fan Description Type Speed Duty # ---- --- -------------- --------- ------------- ------------- # 1 1 FAN-1 Fixed 7448 /fan duty level:/i && next; if (/^unit\s+fan\s+description\s+type\s+speed\s+duty\s+/i) { ProcessHistory("ENV","","","!$_"); while (<$INPUT>) { tr/\015//d; last if (/^\s*$/); last TOP if (/^$prompt/); s/\s*$/\n/; if (/^(\d+\s+\d+\s+\S+\s+\S+\s+)(\d+\s+\d+%)/) { my($sdl) = length($2); my($rem) = $'; $_ = sprintf("%s%".length($2)."s%s", $1, " ", $rem); } ProcessHistory("ENV","","","!$_"); } next; } # trim stats from PS info: # Unit Power supply Description Type State Consumed(W) Voltage(V) Current(mA) # ---- ------------ ---------------- ---------- -------------- ------------ ------------ ------------ # 1 1 PS-1 Fixed Powering N/A N/A N/A s/^(\S+\s+(\S+ )?\S+\s+\S+\s+\S+\s+\S+).*/$1/; ProcessHistory("ENV","","","!$_"); } ProcessHistory("","","","!\n"); return; } # This routine parses "show debug" sub ShowDebug { my($INPUT, $OUTPUT) = @_; print STDERR " In ShowDebug: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^\s+\^$/); return(1) if (/invalid (input|command) detected/i); next if (/^\s*$/); ProcessHistory("DEBUG","","","!Debug: $_"); } ProcessHistory("","","","!\n"); return(0); } # This routine processes a "write running-config" sub WriteTerm { my($INPUT, $OUTPUT) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($comment, $linecnt) = (0,0); while (<$INPUT>) { tr/\015//d; next if (/^\s+\^$/); return(1) if (/invalid (input|command) detected/i); return(0) if ($found_end); # Only do this routine once last if (/^$prompt/); next if (/^\s*$/); $linecnt++; /^!current configuration\s*:/i && next; /^!system (description|software|up\s?time)/i && next; /^!current sntp synch/i && next; /^$/ && next; # blank lines /^ length / && next; # kill length on serial lines /^ width / && next; # kill width on serial lines # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order access-lists /^access-list\s+(\d\d?)\s+(\S+)\s+([a-zA-Z]\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","-1","$_") && next; /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order extended access-lists /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ && ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; # oreder ip routes /^ip route\s+(\S+)\s+/ && ProcessHistory("ROUTE","ipsort","$1","$_") && next; # order/prune snmp-server host/community statements # snmp-server host ip.add.r "public" # snmp-server host ip.add.r informs "public" # snmp-server host ip.add.r informs retries 1 "public" if (/^(snmp-server host )(\d+\.\d+\.\d+\.\d+ ([^"]*)?)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERHOST","ipsort","$2","!$1$2\n") && next; } else { ProcessHistory("SNMPSERVERHOST","ipsort","$2","$_") && next; } } if (/^(snmp-server community )(\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_","!$1$'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # filter tacacs key statements if (/^(tacacs-server key )/ && $filter_pwds >= 1) { ProcessHistory("","","","! $1\n"); next; } # filter other keys server statements if (/^(key )/ && $filter_pwds >= 1) { ProcessHistory("","","","! $1\n"); next; } # filter user password if (/^(username \S+ password) \S+ (level .*)$/ && $filter_pwds >= 2) { ProcessHistory("","","","!$1 $2\n"); next; } ProcessHistory("","","","$_"); # end of config if (/^end$/) { $found_end = 1; return(1); } } # The Edgemax lacks a definitive "end of config" marker. If we have at # least 5 lines of output, we can be reasonably sure that we have the # config. if ($linecnt > 5) { $found_end = 1; return(0); } return(0); } 1; rancid-3.13/lib/iossb.pm.in000644 015615 000000 00000014637 13532047130 015617 0ustar00heaswheel000000 000000 package iossb; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # iossb.pm - Cisco IOS small business rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; our $proc; our $ios; our $found_version; our $found_env; our $found_diag; our $config_register; # configuration register value our $C0; # output formatting control our $E0; our $H0; our $I0; our $DO_SHOW_VLAN; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { $proc = ""; $ios = "IOS"; $found_version = 0; $found_env = 0; $found_diag = 0; $config_register = undef; # configuration register value $C0 = 0; # output formatting control $E0 = 0; $H0 = 0; $I0 = 0; $DO_SHOW_VLAN = 0; # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","D0","!\n"); ProcessHistory("COMMENTS","keysort","F0","!\n"); ProcessHistory("COMMENTS","keysort","G0","!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; # note: this match sucks rocks, but currently the cisco-sb bits are # unreliable about echoing the '\n' after exit. this match might # really be a bad idea, but instead rely upon WriteTerm's found_end? CMD: if (/[>#]\s?exit(Connection( to \S+)? closed)?/ && $found_end) { $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#>]+[#>])/)[0]; $prompt =~ s/([][}{)(+\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } if (defined($prompt)) { if (/$prompt/) { goto CMD; } } } } } # This routine parses "show system" sub ShowSystem { my($INPUT, $OUTPUT, $cmd) = @_; my($slave, $slaveslot); print STDERR " In ShowSystem: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); /system description:\s+(.*)$/i && ProcessHistory("COMMENTS","keysort","B0","! Chassis type: $1\n") && next; # # filter individual unit temperature XXX sg500 unit temps # if (/unit\stemperature/i) { # while (<$INPUT>) { # tr/\015//d; # return(0) if (/^$prompt/); # next if (/^(\s*|\s*$cmd\s*)$/); # next if (/^\s+\^$/); # # last if (/^\s*$/); # } # } } return(0); } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; my($slave, $slaveslot); print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); ProcessHistory("COMMENTS","keysort","E0","! Image: $_"); } return(0); } # This routine parses "show running-config" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; my($comment, $linecnt) = (0,0); print STDERR " In WriteTerm: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^\s+\^$/); # skip emtpy lines at the beginning if (!$linecnt && /^\s*$/) { next; } $linecnt++; # these appear to be reversables # enable password level 15 encrypted z9111212555bd4b0d3bec0b98f7ddd6346 if (/^(enable )?(password|passwd)( level \d+)? / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1$2$3 \n"); next; } # username cisco password encrypted z9111212555bd4b0d3bec0b98f7ddd6346 privilege 15 if (/^username (\S+)(\s.*)? password encrypted (\S+)/) { if ($filter_pwds >= 1){ ProcessHistory("USER","keysort","$1", "!username $1$2 password encrypted $'"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host traps version 2c if (/^(snmp-server host (\d+\.\d+\.\d+\.\d+) traps.* )(\S+)$/) { if ($filter_commstr) { ProcessHistory("SNMPTRAPHOST","ipsort","$2","! $1\n"); } else { ProcessHistory("SNMPTRAPHOST","ipsort","$2","$_"); } next; } # snmp-server community ro view Default if (/^(snmp-server community )\S+ (\w+) (\d+\.\d+\.\d+\.\d+)(.*)$/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERHOST","ipsort","$3","! $1 $2 $3$4\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$3","$_"); } next; } # encrypted tacacs-server host key priority 1 # encrypted tacacs-server key if (/^(encrypted (tacacs|radius)-server\s.*\s?key) (\S+)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # catch anything that wasnt matched above. ProcessHistory("","","","$_"); # end of config. # XXX no definitive end of config marker. #if (/^exit$/) { # $found_end = 1; # return(0); #} } # The ContentEngine lacks a definitive "end of config" marker. If we # know that it is a CE, SAN, or NXOS and we have seen at least 5 lines # of write term output, we can be reasonably sure that we have the config. if ($linecnt > 5) { $found_end = 1; return(0); } return(0); } 1; rancid-3.13/lib/ciscowlc.pm.in000644 015615 000000 00000011002 13532047151 016270 0ustar00heaswheel000000 000000 package ciscowlc; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # ciscowlc.pm - Cisco WLC V4.X # # based on modified version of ciscoips by Josh Yost on 4/16/2008 use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","!RANCID-CONTENT-TYPE: $devtype\n!\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if (/^Error:/) { print STDOUT ("$host wlogin error: $_"); print STDERR ("$host wlogin error: $_") if ($debug); $clean_run = 0; last; } while (/($cmds_regexp)/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+>)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/^.*logout(\s*connection.*closed.*)?$/i) { $clean_run = 1; last; } } } # This routine parses "show running-config" sub ShowConfig { my($INPUT, $OUTPUT, $cmd) = @_; my($linecnt) = 0; print STDERR " In ShowConfig: $_" if ($debug); ProcessHistory("","","","\n!--WLC Begin Config Data--!\n"); while (<$INPUT>) { tr/\015//d; tr/\020//d; last if (/^$prompt/); next if (/^\s*rogue ap classify/); next if (/^\s*rogue (adhoc|client) (alert|unknown)/i); next if (/^\s*interface nat-address management set -?[0-9]{4,}\./); $linecnt++; # These can not be imported, so comment them if (/^\s*cisco public safety is not allowed to set in this domain/i || /^\s*outdoor mesh ext.unii b domain channels:/i || /^\s*service port.*/i || /^\s*wlan express setup.*/i || /^\s*wmm-ac (disabled|enabled)/i) { ProcessHistory("","","","!$_"); next; } # remove snmp community string data if (/^(\s*snmp community create)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^(\s*snmp community accessmode (ro|rw))/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^(\s*snmp community ipaddr\s\S+\s\S+) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } next if (/^(\s*|\s*$cmd\s*)$/); $linecnt++; if (! /^$prompt/) { ProcessHistory("","","","$_"); } } ProcessHistory("","","","\n!--WLC End Config Data--!\n"); # WLC lacks a definitive "end of config" marker. if ($linecnt > 5) { $found_end = 1; return(1); } return(0); } # This routine parses "show sysinfo" sub ShowSysinfo { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSysinfo: $_" if ($debug); ProcessHistory("","","","\n!WLC Show Sysinfo Start\n!\n"); while (<$INPUT>) { tr/\015//d; my($skipprocess) = 0; if (/^System Up Time/) { $skipprocess = 1; } if (/^fan status/i) { $skipprocess = 1; } if (/^Number of Active Clients/) { $skipprocess = 1; } if (/^OUI Classification Failure Count/) { $skipprocess = 1; } if (/^(memory|cpu) (current|average)/i) { $skipprocess = 1; } if (/^(mgig|internal|external) temperature/i) { $skipprocess=1; } if (/rpm$/) { $skipprocess = 1; } last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); if (! /^$prompt/) { if (! $skipprocess) { ProcessHistory("","","","! $_"); } } } ProcessHistory("","","","!\n!WLC Show Sysinfo End\n"); return(0); } # This routine parses "show udi" sub ShowUdi { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowUdi: $_" if ($debug); ProcessHistory("","","","\n!WLC Show Udi Start\n!\n"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); ProcessHistory("","","","! $_"); } ProcessHistory("","","","!\n!WLC Show Udi End\n"); return(0); } 1; rancid-3.13/lib/dell.pm.in000644 015615 000000 00000007402 13532047146 015417 0ustar00heaswheel000000 000000 package dell; ## ## fnrancid patched to dlrancid to accomplish D-Link support ## adapted by: Gavin McCullagh ## Griffith College Dublin ## ## @PACKAGE@ @VERSION@ @copyright@ # # A library built on Stephen Gill's Netscreen stuff to accomodate # the Fortinet product line. [d_pfleger@juniper.net] # # RANCID - Really Awesome New Cisco confIg Differ # # Code tested and working fine on these D-Link models: # # DES-3010F # DES-3052P # DES-3526 # DES-3550 # # dell.pm - Dell D-Link rancid procedures # use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; our $proc; our $found_version; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { $proc = ""; $found_version = 0; # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: D-Link\n\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; # XXX this match is not correct for DELL if (/[>#]\s?exit(?:$|Connection)/) { $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host dllogin error: $_"); print STDERR ("$host dllogin error: $_") if ($debug); $clean_run = 0; last; } while (/^.+(#|\$)\s*($cmds_regexp)\s*$/) { $cmd = $2; # - D-Link prompts end with '#'. if ($_ =~ m/^.+#/) { $prompt = '.+#.*'; } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } } # This routine parses "get system" sub GetSystem { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In GetSystem: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if /^\s*$/; last if (/$prompt/); next if (/^system up time:/i); #next if (/^\s*Virus-DB: .*/); #next if (/^\s*Extended DB: .*/); #next if (/^\s*IPS-DB: .*/); #next if (/^FortiClient application signature package:/); ProcessHistory("","","","#$_"); } ProcessHistory("SYSTEM","","","\n"); return(0); } sub GetFile { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In GetFile: $_" if ($debug); while (<$INPUT>) { last if (/$prompt/); } ProcessHistory("FILE","","","\n"); return(0); } sub GetConf { my($INPUT, $OUTPUT, $cmd) = @_; my($password_counter) = (0); print STDERR " In GetConf: $_" if ($debug); while (<$INPUT>) { tr/\015//d; next if /^\s*$/; last if (/$prompt/); # filter variabilities between configurations. password encryption # upon each display of the configuration. #if (/^\s*(set [^\s]*)\s(Enc\s[^\s]+)(.*)/i && $filter_pwds > 0 ) { # ProcessHistory("ENC","","","#$1 ENC $3\n"); # next; #} # if filtering passwords, note that we're on an opening account line # next two lines will be passwords if (/^create account / && $filter_pwds > 0 ) { $password_counter = 2; ProcessHistory("","","","#$_"); next; } elsif ($password_counter > 0) { $password_counter--; ProcessHistory("","","","#\n"); next; } ProcessHistory("","","","$_"); } $found_end = 1; return(1); } 1; rancid-3.13/lib/Makefile.in000644 015615 000000 00000040763 13735672075 015622 0ustar00heaswheel000000 000000 # Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = lib ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = depcomp = am__maybe_remake_depfiles = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(my_pkglibdir)" DATA = $(my_pkglib_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ADMINMAILPLUS = @ADMINMAILPLUS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ COMM = @COMM@ COPYYEARS = @COPYYEARS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CVS = @CVS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DIFF = @DIFF@ DIFF_CMD = @DIFF_CMD@ DIRNAME = @DIRNAME@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENV_PATH = @ENV_PATH@ EXEEXT = @EXEEXT@ EXPECT_PATH = @EXPECT_PATH@ FIND = @FIND@ GIT = @GIT@ GREP = @GREP@ ID = @ID@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LG_PING_CMD = @LG_PING_CMD@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAILPLUS = @MAILPLUS@ MAINT = @MAINT@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ MKDIR_P = @MKDIR_P@ MKTEMP = @MKTEMP@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERLV = @PERLV@ PERLV_PATH = @PERLV_PATH@ PING_PATH = @PING_PATH@ PYTHON3 = @PYTHON3@ PYTHON3_PATH = @PYTHON3_PATH@ RCSSYS = @RCSSYS@ RSH = @RSH@ SENDMAIL = @SENDMAIL@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SORT = @SORT@ SSH = @SSH@ STRIP = @STRIP@ SVN = @SVN@ SVN_FSTYPE = @SVN_FSTYPE@ TAR = @TAR@ TELNET = @TELNET@ TELNET_CMD = @TELNET_CMD@ TOUCH = @TOUCH@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign no-dependencies my_pkglibdir = $(pkglibdir) my_pkglib_DATA = rancid.pm acos.pm aeos.pm arbor.pm arcos.pm avocent.pm \ bigip.pm ciscowlc.pm \ dell.pm dnos9.pm dnos10.pm edgemax.pm edgerouter.pm exos.pm \ fortigate.pm foundry.pm frr.pm fss2.pm fxos.pm \ ios.pm iossb.pm iosshtech.pm iosxr.pm junos.pm mrv.pm nxos.pm \ panos.pm rbt.pm routeros.pm smc.pm sros.pm vrp.pm wavesvros.pm pkglib_in = $(my_pkglib_DATA:%=%.in) RANLIB = : EXTRA_DIST = $(pkglib_in) CLEANFILES = rancid $(my_pkglib_DATA) #clean: # rm -f Makefile env $(BIN_DATAS) $(BIN_PROGS) # auto_edit does the autoconf variable substitution. This allows the # substitution to have the full expansion of the variables, e.g.: $sysconfdir # will be /prefix/etc instead of ${prefix}/etc. # # This is a bit of a PITA, but is the method recommended by the autoconf # documentation. auto_edit = sed \ -e 's,@bindir\@,$(bindir),g' \ -e 's,@prefix\@,$(prefix),g' \ -e 's,@localstatedir\@,$(localstatedir),g' \ -e 's,@sysconfdir\@,$(sysconfdir),g' \ -e 's,@EXPECT_PATH\@,$(EXPECT_PATH),g' \ -e 's,@ENV_PATH\@,$(ENV_PATH),g' \ -e 's,@PERLV\@,$(PERLV),g' \ -e 's,@PERLV_PATH\@,$(PERLV_PATH),g' \ -e 's,@PYTHON3\@,$(PYTHON3),g' \ -e 's,@PYTHON3_PATH\@,$(PYTHON3_PATH),g' \ -e 's,@LG_PING_CMD\@,$(LG_PING_CMD),g' \ -e 's,@ADMINMAILPLUS\@,$(ADMINMAILPLUS),g' \ -e 's,@MAILPLUS\@,$(MAILPLUS),g' \ -e 's,@PACKAGE\@,$(PACKAGE),g' \ -e 's,@RCSSYS\@,$(RCSSYS),g' \ -e 's,@SENDMAIL\@,$(SENDMAIL),g' \ -e 's,@SVN_FSTYPE\@,$(SVN_FSTYPE),g' \ -e 's,@VERSION\@,$(VERSION),g' \ -e 's,@COPYYEARS\@,$(COPYYEARS),g' \ -e '/@copyright@/r ../COPYING' \ -e '/@copyright@/d' all: all-am .SUFFIXES: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign lib/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-my_pkglibDATA: $(my_pkglib_DATA) @$(NORMAL_INSTALL) @list='$(my_pkglib_DATA)'; test -n "$(my_pkglibdir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(my_pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(my_pkglibdir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(my_pkglibdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(my_pkglibdir)" || exit $$?; \ done uninstall-my_pkglibDATA: @$(NORMAL_UNINSTALL) @list='$(my_pkglib_DATA)'; test -n "$(my_pkglibdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(my_pkglibdir)'; $(am__uninstall_files_from_dir) tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(DATA) installdirs: for dir in "$(DESTDIR)$(my_pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-my_pkglibDATA install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-my_pkglibDATA .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic cscopelist-am \ ctags-am distclean distclean-generic distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-my_pkglibDATA install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am tags-am uninstall uninstall-am \ uninstall-my_pkglibDATA .PRECIOUS: Makefile $(pkglib_in:%.in=%): Makefile $(top_builddir)/config.status rm -f $@ $@.tmp; \ $(auto_edit) $(srcdir)/$@.in >$@.tmp; \ chmod +r $@.tmp; \ mv $@.tmp $@ # XXX there must be a better way to produce these dependencies, perhaps in # configure. acos.pm: acos.pm.in aeos.pm: aeos.pm.in arbor.pm: arbor.pm.in arcos.pm: arcos.pm.in avocent.pm: avocent.pm.in bigip.pm: bigip.pm.in ciscowlc.pm: ciscowlc.pm.in dell.pm: dell.pm.in dnos9.pm: dnos9.pm.in dnos10.pm: dnos10.pm.in edgemax.pm: edgemax.pm.in edgerouter.pm: edgerouter.pm.in exos.pm: exos.pm.in fortigate.pm: fortigate.pm.in foundry.pm: foundry.pm.in frr.pm: frr.pm.in fss2.pm: fss2.pm.in fxos.pm: fxos.pm.in ios.pm: ios.pm.in iossb.pm: iossb.pm.in iosshtech.pm: iosshtech.pm.in iosxr.pm: iosxr.pm.in junos.pm: junos.pm.in rancid.pm: rancid.pm.in rancid.py: rancid.py.in mrv.pm: mrv.pm.in nxos.pm: nxos.pm.in panos.pm: panos.pm.in rbt.pm: rbt.pm.in routeros.pm: routeros.pm.in smc.pm: smc.pm.in sros.pm: sros.pm.in vrp.pm: vrp.pm.in wavesvros.pm: wavesvros.pm.in # 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: rancid-3.13/lib/arbor.pm.in000644 015615 000000 00000014442 13657102757 015616 0ustar00heaswheel000000 000000 package arbor; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # arbor.pm - Arbor Networks appliances rancid procedures use 5.010; use strict 'vars'; use warnings; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { # force a terminal type so as not to confuse the POS with "network". # Seems that it might also support "dumb". $ENV{'TERM'} = "vt100"; $timeo = 240; # anlogin timeout in seconds 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: $devtype\n#\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; if ( (/\>\s?logout$/) || $found_end ) { $clean_run=1; last; } if (/^Error:/) { print STDOUT ("$host anlogin error: $_"); print STDERR ("$host anlogin error: $_") if ($debug); $clean_run = 0; last; } while (/[#>]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#>]+[#>])/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } } # This routine parses "config show" sub ShowConfig { my($INPUT, $OUTPUT, $cmd) = @_; my($linecnt) = 0; print STDERR " In ShowConfig: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/invalid command/i); # some stupid timer error from this half-assed device next if (/comsh: timer error, idle timeout will be unavailable/i); # sort mgmt ACLs if (/ip access add (\S+) all (\S+)/) { ProcessHistory("IPACCESS_$1","$aclsort","$2","$_"); next; } # sort IP addresses in policy and display one-per-line as comments so # that they are readable and it is easier to see what changed in the # policy. There does not appear to be a way to split these lines and # have the saved config still be loadable into the device. if (/(services sp managed_objects edit \"[^"]*\" match set cidr_blocks) (.*)/ || /(services sp managed_objects edit \"[^"]*\" match set cidr_v6_blocks) (.*)/ || /(services sp managed_objects edit \"[^"]*\" tags add \"[^"]*\") (.*)/ || /(services sp managed_objects edit \"[^"]*\" portal mitigation tms scope set) (.*)/) { ProcessHistory("MG_OBJ","","","$_"); my(@ips) = split(/,/, $2); next if ($#ips < 2); ProcessHistory("MG_OBJ","","","# $1 \\\n"); my($ip, $n) = (0,0); foreach $ip (@ips) { $n++; if ($n <= $#ips) { ProcessHistory("MG_OBJ","$aclsort","$ip","#\t\t\t\t$ip,\\\n"); } else { ProcessHistory("MG_OBJ","$aclsort","$ip","#\t\t\t\t$ip\n"); } } next; } if (/(services sp device edit .+ snmp community set )\S+/) { if ($filter_commstr) { ProcessHistory("","","","# $1 $'"); next; } } if (/^(services sp router edit \S+ bgp md5_secret set )\S+/ && $filter_pwds >= 1) { ProcessHistory("","","","# $1$'"); next; } if (/^(services sp portal .+ edit .+ key set )\S+/ && $filter_pwds >= 1) { ProcessHistory("","","","# $1$'"); next; } if (/^(services aaa tacacs server .* encrypted )\S+/ && $filter_pwds >= 1) { ProcessHistory("","","","# $1$'"); next; } if (/^(services aaa local add .* encrypted )\S+/ && $filter_pwds >= 2) { ProcessHistory("","","","# $1$'"); next; } ProcessHistory("","","","$_"); $linecnt++; } # Arbor lacks a definitive "end of config" marker. if ($linecnt > 5) { $found_end = 1; return(1); } return(0); } # This routine parses "system disk show" sub ShowFlash { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowFlash: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/invalid command/i); # Filesystem status: # Filesystem Size/Used Inodes/Used # boot 476M/164M (37%) 126K/70 (1%) s/\/used\s+inodes\/used.*//i; s/(\s+\w+\s+)([\d.]+.)\/\S+\s+(\S+).*/$1$2/; # filter RAID resync messages # RAID status: # boot OK # data OK # system OK / RESYNC queued # swap OK s/(\s+\w+\s+\w+)\s+\/\s+resync queued/$1/i; ProcessHistory("Version","","","# $_"); } ProcessHistory("Version","","","#\n"); return(0); } # This routine parses "system hardware" & "system show" sub ShowHardware { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowHardware: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/invalid command/i); # observed intermittently on T4008 running 8.2.0. return(-1) if (/error getting board version/i); # some stupid timer error from this half-assed device next if (/comsh: timer error, idle timeout will be unavailable/i); next if (/^\s*boot time: /i); next if (/^\s*load averages: /i); ProcessHistory("Inventory","","","# $_"); } ProcessHistory("Inventory","","","#\n"); return(0); } # This routine parses "system version", "system build-parameters", # "system file show" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if (/invalid command/i); # some stupid timer error from this half-assed device next if (/comsh: timer error, idle timeout will be unavailable/i); ProcessHistory("Version","","","# $_"); } ProcessHistory("Version","","","#\n"); return(0); } 1; rancid-3.13/lib/iosshtech.pm.in000644 015615 000000 00000037572 13532047125 016500 0ustar00heaswheel000000 000000 package iosshtech; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # iosshtech.pm - Cisco IOS "show tech" rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { 0; } # This routine processes the config portion of 'show tech-support" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In WriteTerm: $_" if ($debug); my($comment, $linecnt) = (0,0); # eat the junk leading up to the running config while (<$INPUT>) { tr/\015//d; return(1) if (/^$prompt/); # premature end of the output return(1) if (/Line has invalid autocommand /); return(1) if (/(invalid (input|command) detected|type help or )/i); return(1) if (/\%Error: No such file or directory/); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(-1) if (/command authorization failed/i); return(-1) if (/% ?configuration buffer full/i); last if (/[- ]+ show running-config [- ]+/); } while (<$INPUT>) { TOP: tr/\015//d; last if (/^$prompt/); return(1) if (!$linecnt && /^\s+\^\s*$/); next if (/^\s*$cmd\s*$/); return(1) if (/Line has invalid autocommand /); next if (/^\s+\^\s*$/); return(1) if (/(invalid (input|command) detected|type help or )/i); return(1) if (/\%Error: No such file or directory/); return(1) if (/(Open device \S+ failed|Error opening \S+:)/); return(0) if ($found_end); # Only do this routine once return(-1) if (/command authorization failed/i); return(-1) if (/% ?configuration buffer full/i); # the pager can not be disabled per-session on the PIX if (/^(<-+ More -+>)/) { my($len) = length($1); s/^$1\s{$len}//; } /^! no configuration change since last restart/i && next; # skip emtpy lines at the beginning if (!$linecnt && /^\s*$/) { next; } if (!$linecnt && defined($ios::config_register)) { ProcessHistory("","","", "!\nconfig-register $ios::config_register\n"); } /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked /% Configuration buffer full, / && return(-1); # buffer is in use $linecnt++; # skip the crap if (/^(##+|(building|current) configuration)/i) { while (<$INPUT>) { next if (/^Current configuration\s*:/i); next if (/^:/); next if (/^([%!].*|\s*)$/); next if (/^ip add.*ipv4:/); # band-aid for 3620 12.0S last; } tr/\015//d; } # config timestamp on MDS/NX-OS /Time: / && next; # skip ASA 5520 configuration author line /^: written by /i && next; # 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 \S+ at|Saved)/ && next; # skip consecutive comment lines to avoid oscillating extra comment # line on some access servers. grrr. if (/^!\s*$/) { next if ($comment); ProcessHistory("","","",$_); $comment++; next; } $comment = 0; # Dog gone Cool matches to process the rest of the config /^tftp-server flash / && next; # kill any tftp remains /^ntp clock-period / && next; # kill ntp clock-period /^ clockrate / && next; # kill clockrate on serial interfaces # kill rx/txspeed (particularly on cellular modem cards) if (/^(line (\d+(\/\d+\/\d+)?|con|aux|vty))/) { my($key) = $1; my($lineauto) = (0); if ($key =~ /con/) { $key = -1; } elsif ($key =~ /aux/) { $key = -2; } elsif ($key =~ /vty/) { $key = -3; } ProcessHistory("LINE","keysort","$key","$_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); goto TOP if (! /^ /); next if (/\s*(rx|tx)speed \d+/); next if (/^ length /); # kill length on serial lines next if (/^ width /); # kill width on serial lines $lineauto = 0 if (/^[^ ]/); $lineauto = 1 if /^ modem auto/; /^ speed / && $lineauto && next; # kill speed on serial lines if (/^(\s+password) \d+ / && $filter_pwds >= 1) { $_ = "!$1 \n"; } ProcessHistory("LINE","keysort","$key","$_"); } } if (/^(enable )?(password|passwd)( level \d+)? / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1$2$3 \n"); next; } if (/^(enable secret) / && $filter_pwds >= 2) { ProcessHistory("ENABLE","","","!$1 \n"); next; } if (/^username (\S+)(\s.*)? secret /) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 secret \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^username (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } elsif ($filter_pwds >= 1 && $4 ne "5"){ ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } # cisco AP w/ IOS if (/^(wlccp \S+ username (\S+)(\s.*)? password) (\d \S+|\S+)/) { if ($filter_pwds >= 1) { ProcessHistory("USER","keysort","$2","!$1 \n"); } else { ProcessHistory("USER","keysort","$2","$_"); } next; } # filter auto "rogue ap" configuration lines /^rogue ap classify / && next; if (/^( set session-key (in|out)bound ah \d+ )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1\n"); next; } if (/^( set session-key (in|out)bound esp \d+ (authenticator|cypher) )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1\n"); next; } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","","!$1password \n"); next; } if (/^(\s*)secret / && $filter_pwds >= 2) { ProcessHistory("LINE-PASS","","","!$1secret \n"); next; } if (/^\s*(.*?neighbor.*?) (\S*) password / && $filter_pwds >= 1) { ProcessHistory("","","","! $1 $2 password \n"); next; } if (/^(\s*ppp .* hostname) .*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^(\s*ppp .* password) \d .*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^(ip ftp password) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # isis passwords appear to be completely plain-text if (/^\s+isis password (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!isis password $2\n"); next; } if (/^\s+(domain-password|area-password) (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $3\n"); next; } # this is reversable, despite 'md5' in the cmd if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # this is also reversable, despite 'md5 encrypted' in the cmd if (/^( message-digest-key \d+ md5 (7|encrypted)) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^((crypto )?isakmp key) (\d )?\S+ / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # filter HSRP passwords if (/^(\s+standby \d+ authentication) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # this appears in "measurement/sla" images if (/^(\s+key-string \d?)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^( l2tp tunnel \S+ password)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # l2tp-class secret if (/^( digest secret 7?)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # i am told these are plain-text on the PIX if (/^(vpdn username (\S+) password)/) { if ($filter_pwds >= 1) { ProcessHistory("USER","keysort","$2","!$1 \n"); } else { ProcessHistory("USER","keysort","$2","$_"); } next; } # ASA/PIX keys in more system:running-config if (/^(( ikev2)? (local|remote)-authentication pre-shared-key ).*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # ASA/PIX keys in more system:running-config if (/^(( ikev1)? pre-shared-key | key |failover key ).*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # ASA/PIX keys in more system:running-config if (/(\s+ldap-login-password )\S+(.*)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # filter WPA password such as on cisco 877W ISR if (/^\s+(wpa-psk ascii|hex \d) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # if (/^( cable shared-secret )/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } /fair-queue individual-limit/ && next; # sort ip explicit-paths. if (/^ip explicit-path name (\S+)/) { my($key) = $1; my($expath) = $_; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); last if (/^$prompt/ || ! /^(ip explicit-path name |[ !])/); if (/^ip explicit-path name (\S+)/) { ProcessHistory("EXPATH","keysort","$key","$expath"); $key = $1; $expath = $_; } else { $expath .= $_; } } ProcessHistory("EXPATH","keysort","$key","$expath"); } # sort route-maps if (/^route-map (\S+)/) { my($key) = $1; my($routemap) = $_; while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || ! /^(route-map |[ !])/); if (/^route-map (\S+)/) { ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); $key = $1; $routemap = $_; } else { $routemap .= $_; } } ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); } # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order access-lists /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order extended access-lists if ($aclfilterseq) { /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+host\s+(\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$4","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+(\d\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$4","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+(\S+)\s+any/ && ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; } if ($aclfilterseq) { /^ip(v6)? prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\S+)(.*)/ && ProcessHistory("PACL $2 $4","$aclsort","$5", "ip$1 prefix-list $2 $4 $5$6\n") && next; } # sort ipv{4,6} access-lists if ($aclfilterseq && /^ipv(4|6) access-list (\S+)\s*$/) { my($nlri, $key) = ($1, $2); my($seq, $cmd); ProcessHistory("ACL $nlri $key","","","$_"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || /^\S/); # ipv4 access-list name # remark NTP # deny ipv4 host 224.0.1.1 any # deny ipv4 239.0.0.0 0.255.255.255 any # permit udp any eq 123 any # permit ipv4 nnn.nnn.nnn.nnn/nn any # permit nnn.nnn.nnn.nnn/nn # ipv6 access-list name # permit ipv6 host 2001:nnnn::nnnn any # permit ipv6 2001:nnn::/nnn any # permit 2001:nnnn::/64 any # permit udp any eq 123 any # # line might begin with " sequence nnn permit ..." s/^\s+(sequence (\d+)) / /; my($seq) = $1; my($cmd, $resid) = ($_ =~ /^\s+(\w+) (.+)/); if ($cmd =~ /(permit|deny)/) { my($ip); my(@w) = ($resid =~ /(\S+) (\S+) (\S+\s)?(.+)/); for (my($i) = 0; $i < $#w; $i++) { if ($w[$i] eq "any") { if ($nlri eq "ipv4") { $ip = "255.255.255.255/32"; } else { $ip = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128"; } last; } elsif ($w[$i] =~ /^[:0-9]/ || $2[$i] =~ /^[a-fA-F]{1,4}:/) { $ip = $w[$i]; $ip =~ s/\s+$//; # trim trailing WS last; } } ProcessHistory("ACL $nlri $key $cmd", "$aclsort", "$ip", " $cmd $resid\n"); } else { ProcessHistory("ACL $nlri $key $cmd", "", "", " $cmd $resid\n"); } } } # order arp lists /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ && ProcessHistory("ARP","$aclsort","$1","$_") && next; # order logging statements /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); if ($token eq '3') { $line .= " " . join(' ', ($token, shift(@tokens))); } } elsif ($token eq 'vrf') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } # For ASA version 8.x and higher, the format changed a little. It is # 'snmp-server host {interface {hostname | ip_address}} [trap | poll] # [community 0 | 8 community-string] [version {1 | 2c | 3 username}] # [udp-port port] ' if (/^(snmp-server .*community) ([08] )?(\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_", "!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # prune tacacs/radius server keys if (/^((tacacs|radius)-server\s(\w*[-\s(\s\S+])*\s?key) (\d )?\S+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # order clns host statements /^clns host \S+ (\S+)/ && ProcessHistory("CLNS","keysort","$1","$_") && next; # order alias statements /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next; # delete ntp auth password - this md5 is a reversable too if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { my($sortkey) = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # order ip host statements /^ip host (\S+) / && ProcessHistory("IPHOST","keysort","$1","$_") && next; # order ip nat source static statements /^ip nat (\S+) source static (\S+)/ && ProcessHistory("IP NAT $1","ipsort","$2","$_") && next; # order atm map-list statements /^\s+ip\s+(\d+\.\d+\.\d+\.\d+)\s+atm-vc/ && ProcessHistory("ATM map-list","ipsort","$1","$_") && next; # order ip rcmd lines /^ip rcmd/ && ProcessHistory("RCMD","keysort","$_","$_") && next; # system controller /^syscon address (\S*) (\S*)/ && ProcessHistory("","","","!syscon address $1 \n") && next; if (/^syscon password (\S*)/ && $filter_pwds >= 1) { ProcessHistory("","","","!syscon password \n"); next; } /^ *Cryptochecksum:/ && next; # catch anything that wasnt matched above. ProcessHistory("","","","$_"); # end of config. the ": " game is for the PIX if (/^(: +)?end$/) { $found_end = 1; return(0); } } # The ContentEngine lacks a definitive "end of config" marker. If we # know that it is a CE, SAN, or NXOS and we have seen at least 5 lines # of write term output, we can be reasonably sure that we have the config. if (($ios::type eq "CE" || $ios::type eq "SAN" || $ios::type eq "NXOS" ) && $linecnt > 5) { $found_end = 1; return(0); } return(0); } 1; rancid-3.13/lib/exos.pm.in000644 015615 000000 00000025342 13657102757 015470 0ustar00heaswheel000000 000000 package exos; ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # exos.pm - Extreme ExtremeXOS rancid procedures use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: $devtype\n#\n"); ProcessHistory("COMMENTS","keysort","B0","#\n"); # chassis info ProcessHistory("COMMENTS","keysort","C0","#\n"); # power supply info ProcessHistory("COMMENTS","keysort","D0","#\n"); # image name ProcessHistory("COMMENTS","keysort","E0","#\n"); # h/w info ProcessHistory("COMMENTS","keysort","F0","#\n"); # slot info ProcessHistory("COMMENTS","keysort","H0","#\n"); # config ProcessHistory("COMMENTS","keysort","X0","#\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); TOP: while(<$INPUT>) { tr/\015//d; # note: this match sucks rocks, but currently the extreme bits are # unreliable about echoing the 'exit\n' command. this match might # really be a bad idea, but instead rely upon WriteTerm's found_end? if (/($prompt\s?(quit|exit)|Connection( to \S+)? closed)/ && $found_end) { $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } while (/$prompt\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; $prompt =~ s/[:.](\d+ ?)#/[:.]\\d+ ?#/; $prompt =~ s/\*/\\\*/; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { printf STDERR "rval = -1\n" if ($debug); $clean_run = 0; last TOP; } } } } # This routine parses "show version" sub ShowVersion { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowVersion: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if(/^$prompt/); next if(/^(\s*|\s*$cmd\s*)$/); /^\S+ Serial Number:/i && ProcessHistory("COMMENTS","keysort","B0","#$_") && next; /^(\S+) Power Supply ([^:]+):\s+(.*)/i && ProcessHistory("COMMENTS","keysort","C0","#Power: $1 $2 $3\n") && next; /^image\s*:\s*(.*)\s+by\s+/i && ProcessHistory("COMMENTS","keysort","D0","#Image: $1\n") && next; /^bootrom\s+:\s+(.*)/i && ProcessHistory("COMMENTS","keysort","D1","#\n#Bootrom: $1\n") && next; # collect slot info rev #s, etc. # SLOT 1 : 702005-06 0025S-00877 CPLD Rev # SLOT 2 : 702005-06 0021S-00131 CPLD Rev 02 # SLOT 3 : 702009-06 0024S-00170 CPLD Rev # SLOT 4 : 702009-06 0024S-00319 CPLD Rev /^(?:Slot-\d|Switch)\s+:\s+[^\s]+/i && ProcessHistory("COMMENTS","keysort","D2","#$_") && next; } return(0); } # This routine parses "show memory" sub ShowMemory { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowMemory: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if(/^$prompt/); next if(/^(\s*|\s*$cmd\s*)$/); /^Total DRAM (Size|\(KB\)): (.*)/ && ProcessHistory("COMMENTS","keysort","B1","#\n#Memory: $2\n") } return(0); } # This routine parses "show diag" sub ShowDiag { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowDiag: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); last if (/^Syntax error at token/); next if (/^(\s*|\s*$cmd\s*)$/); /platform\s+:\s+(.*)$/i && ProcessHistory("COMMENTS","keysort","A0","#Chassis type: $1\n") && next; /(\S+) part no\s+:\s+(.*)$/i && ProcessHistory("COMMENTS","keysort","E0","#$1 PN: $2\n") && next; /(\S+ \S+) no\s+:\s+(.*)$/i && ProcessHistory("COMMENTS","keysort","E0","#$1 PN: $2\n") && next; /(mac address)\s+:\s+(.*)$/i && ProcessHistory("COMMENTS","keysort","B0","#$1: $2\n") && next; } return(0); } # This routine parses "show policy detail" sub ShowPolicy { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowPolicy: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); ProcessHistory("POLICY","","","# $_"); } return(0); } # This routine parses "show slot" sub ShowSlot { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSlot: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); if (/^Slot\s+(\d+)\s+/i) { my($slot) = $1; my($hwtype, $conftype, $sn, $state); ProcessHistory("COMMENTS","keysort","F$slot","#\n"); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/ || /^\s*$/); if (/State:\s+(.*)$/i) { $state = $1; } if (/serial number:\s+(.*)$/i) { $sn = $1; } if (/hw module type:\s+(.*)$/i) { $hwtype = $1; } if (/configured type:\s+(.*)$/i) { $conftype = $1; } } ProcessHistory("COMMENTS","keysort","F$slot","#Slot $slot: type " . "$hwtype," . " $conftype\n#Slot $slot: serial $sn\n#Slot $slot: state " . " $state\n"); return if (/^$prompt/); next; } } return(0); } # This routine parses "show switch" sub ShowSwitch { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowSwitch: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if(/^$prompt/); next if(/^(\s*|\s*$cmd\s*)$/); /^\s*$/i && next; /^(primary|secondary) configuration:/i && next; /^(boot |next reboot)/i && next; /^(auto |qos mode|sys\S*:|temperature|time)/i && next; /^power supply: (.*)/i && ProcessHistory("COMMENTS","keysort","C0","#$1") && next; /^license/i && ProcessHistory("COMMENTS","keysort","D0","#Image: $_") && next; s/^software image (\S+):/Image: $1:/i && ProcessHistory("COMMENTS","keysort","D0","#$_") && next; /^\S+ software version:/i && ProcessHistory("COMMENTS","keysort","D0","#Image: $_") && next; /^(\S+ )?software/i && ProcessHistory("COMMENTS","keysort","D0","# $_") && next; /System MAC:\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","B0","#MAC: $1\n") && next; /System Type:\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","A0","#Chassis type: $1\n") && next; /^(Image Selected):\s+(\S+)/ && ProcessHistory("COMMENTS","keysort","A0","#$1: $2\n") && next; /^(Image Booted):\s+(\S+)/ && ProcessHistory("COMMENTS","keysort","A0","#$1: $2\n") && next; /^(Primary (\S+ )?ver):\s+(\S+)/i && ProcessHistory("COMMENTS","keysort","A0","#$1: $3\n") && next; /^(Secondary (\S+ )?ver):\s+(\S+)/i && ProcessHistory("COMMENTS","keysort","A0","#$1: $3\n") && next; /^(Config Selected):\s+(\S+)/ && ProcessHistory("COMMENTS","keysort","A0","#$1: $2\n") && next; /^(Config Booted):\s+(\S+)/ && ProcessHistory("COMMENTS","keysort","A0","#$1: $2\n") && next; } return(0); } # This routine processes a "show configuration {detail}" sub WriteTerm { my($INPUT, $OUTPUT, $cmd) = @_; my($lines) = 0; print STDERR " In WriteTerm: $_" if ($debug); my($comment) = 1; # strip extra comments, esp to preserve chassis type while (<$INPUT>) { tr/\015//d; last if(/^$prompt/); next if(/^\s*$/); return(0) if (/^syntax error at token /i); return(0) if (/^%% Invalid input detected at /i); return(0) if (/^%% Ambiguous command:/i); # the pager can not be disabled per-session on the PIX s/^<-+ More -+>\s*//; return(0) if ($found_end); s/^\s*$/#/; next if (/full detail configuration/i); # filter extra comments and lead comments in config so we can preserve # the chassis type at the top of muched o/p before the process history # key changes. if (/^#\s*$/) { if ($comment) { next; } else { $comment++; } } else { $comment = 0; } $lines++; # Dog gone Cool matches to process the rest of the config # some chassis report their chassis type in show diag...oh, but # others do not. grab it here, if available. so, nothing else # can change the keysort key until this is grabbed. sigh. /# (\S+) configuration generated/i && ProcessHistory("COMMENTS","keysort","A0","#Chassis type: $1\n") && ($comment = 0) && next; /configuration generated/i && next; /# system name/i && next; /# software version/i && next; if (/((create|configure) account \S+ \S+) / && $filter_pwds >= 2) { ProcessHistory("COMMENTS","keysort","H0","# $1 \n"); next; } if (/configure ssh2 key/ && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","H0","# $_# \n"); while (<$INPUT>) { if (/^(#|enable|conf|disable|unconf)/) { tr/\015//d; last; } } } # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; if (/^((config|configure) bgp (neighbor|peer-group) \S+ password encrypted)/i && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","H0","# $1 \n"); next; } # order logging statements /^configure syslog add logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune snmp-server host statements # we only prune lines of the form # configure snmp add trapreceiver a.b.c.d if (/^(configure snmp add trapreceiver )(\d+\.\d+\.\d+\.\d+) (community) \S+/) { if ($filter_commstr) { ProcessHistory("SNMPSVRHOST","ipsort","$2","# $1$2 $3 $'\n"); } else { ProcessHistory("SNMPSVRHOST","ipsort","$2","$_\n"); } next; } if (/^(configure snmp community (readonly|readwrite)( encrypted)?) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSVRCOMM","keysort","$_","#$1 $'"); next; } else { ProcessHistory("SNMPSVRCOMM","keysort","$_","$_") && next; } } # order/prune tacacs/radius server statements if (/^(configure radius (primary|secondary) (tacacs-server|radius-server) shared-secret encrypted)/ && $filter_pwds >= 1) { ProcessHistory("COMMENTS","keysort","H0","# $1 \n"); next; } # catch anything that wasnt match above. ProcessHistory("COMMENTS","keysort","H0","$_"); # end of config if (/^# End of configuration file/i) { printf STDERR " End WriteTerm: $_" if ($debug); $found_end = 1; return(0); } } printf STDERR " End WriteTerm: $_" if ($debug); if ($lines < 3) { printf(STDERR "ERROR: $host configuration appears to be truncated.\n"); $found_end = 0; return(-1); } $found_end = 1; return(0); } 1; rancid-3.13/lib/panos.pm.in000644 015615 000000 00000007456 13657102757 015640 0ustar00heaswheel000000 000000 package panos; ## ## @PACKAGE@ @VERSION@ @copyright@ # # Amazingly hacked version of Hank's rancid - this one tries to # deal with Palo Altos # # RANCID - Really Awesome New Cisco confIg Differ # # panos.pm - Palo Alto Networks rancid procedures # # 2013-01-05 - fix to put cli pager after scripting-mode is off - doug # hughesd@deshawresearch.com # use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; require(Exporter); our @ISA = qw(Exporter); use rancid @VERSION@; @ISA = qw(Exporter rancid main); #XXX @Exporter::EXPORT = qw($VERSION @commandtable %commands @commands); # load-time initialization sub import { 0; } # post-open(collection file) initialization sub init { # add content lines and separators ProcessHistory("","","","#RANCID-CONTENT-TYPE: $devtype\n#\n"); 0; } # main loop of input of device output sub inloop { my($INPUT, $OUTPUT) = @_; my($cmd, $rval); # Paloalto buffers commands and prints them twice, once while buffering, # and once while executing. It's a bit weird and causes default rancid # code a bit of a conniption, so we need to only execute the callbacks # on second discovery. TOP: while(<$INPUT>) { tr/\015//d; if (/[>#]\s?exit$/) { $clean_run = 1; print STDERR "exiting\n" if ($debug); # because exit occurs implicitly, too delete($commands{exit}); last; } print STDERR ("line: $_") if ($debug); if (/^Error:/) { print STDOUT ("$host panlogin error: $_"); print STDERR ("$host panlogin error: $_") if ($debug); $clean_run = 0; last; } while (/\w+@\S+[>#]\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^>]+>)/)[0]; $prompt =~ s/>/\[#>\]/; $prompt =~ s/\(/\\(/; $prompt =~ s/\)/\\)/; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_\n") if ($debug); print STDERR ("COMMAND is: $cmd|$commands{$cmd}\n") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } if (! defined(&{$commands{$cmd}})) { printf(STDERR "$host: undefined function - \"%s\"\n", $commands{$cmd}); $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}($INPUT, $OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } } # This routine parses "show system info" sub ShowInfo { my($INPUT, $OUTPUT, $cmd) = @_; my($slot); print STDERR " In ShowInfo:: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); next if (/^(time:|uptime:)/); next if (/^(app|av|global-protect-datafile|threat|wf-private|wildfire|url-filtering)-(version|release-date):/); ProcessHistory("INFO","","","#$_"); } ProcessHistory("INFO","","","#\n"); return(0); } # This routine parses "show chassis inventory" sub ShowInventory { my($INPUT, $OUTPUT, $cmd) = @_; my($slot); print STDERR " In ShowInventory:: $_" if ($debug); while (<$INPUT>) { tr/\015//d; last if (/^$prompt/); return(1) if (/^Invalid syntax/); ProcessHistory("INV","","","#$_"); } ProcessHistory("INV","","","#\n"); return(0); } # This routine parses "show config running" sub ShowConfig { my($INPUT, $OUTPUT, $cmd) = @_; print STDERR " In ShowConfig: $_" if ($debug); while (<$INPUT>) { tr/\015//d; if (/^}\s*$|\[edit\]/) { $found_end = 1; ProcessHistory("","","","$_"); return(1); } if (/^(\s*snmp-community-string )[^ ;]+(\s?[;{])$/ && $filter_commstr) { $_ = "#$1$2\n"; } # filter protocol encryption keys if (/^(\s*key )[^ ;]+(\s?[;{])$/ && $filter_pwds >= 1) { $_ = "#$1$2\n"; } ProcessHistory("","","","$_"); # end of config } return 0; } 1; rancid-3.13/bin/csblogin.in000644 015615 000000 00000046137 13657102757 015706 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # clogin - Cisco login # # Most options are intuitive for logging into a Cisco router. # The default is to enable (thus -noenable). Some folks have # setup tacacs to have a user login at priv-lvl = 15 (enabled) # so the -autoenable flag was added for this case (don't go through # the process of enabling and the prompt will be the "#" prompt. # The default username password is the same as the vty password. # # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 45 # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} @login_top@ # Log into the router. # returns: 0 on success, 1 on failure, -1 if rsh was used successfully proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } { global command spawn_id in_proc do_command do_script passphrase global prompt prompt_match u_prompt p_prompt e_prompt sshcmd telnetcmd set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port if {"$port" == ""} { if { $do_command || $do_script } { set retval [catch {eval spawn [split "hpuifilter -- $telnetcmd $router"]} reason] } else { set retval [catch {eval spawn [split "$telnetcmd $router"]} reason] } } else { if { $do_command || $do_script } { set retval [catch {eval spawn [split "hpuifilter -- $telnetcmd $router $port"]} reason] } else { set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason] } } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif [string match "ssh*" $prog] { # ssh to the router & try to login with or without an identfile. regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } if {"$identfile" != ""} { set cmd "$cmd -i $identfile" } if { $do_command || $do_script } { set retval [catch {eval spawn hpuifilter -- [split "$cmd -x -l $user $router" { }]} reason] } else { set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason] } if { $retval } { send_user "\nError: $cmd failed: $reason\n" return 1 } } elseif ![string compare $prog "rsh"] { if { ! $do_command } { if { [llength $cmethod] == 1 } { send_user "\nError: rsh is an invalid method for -x and " send_user "interactive logins\n" } if { $progs == 0 } { return 1 } continue; } # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] set rshfail 0 for {set i 0} {$i < $num_commands && !$rshfail} { incr i} { log_user 0 set retval [catch {spawn rsh $user@$router [lindex $commands $i] } reason] if { $retval } { send_user "\nError: rsh failed: $reason\n" log_user 1; return 1 } send_user "$router# [lindex $commands $i]\n" # rcmd does not get a pager and no prompts, so we just have to # look for failures & lines. expect { "Connection refused" { catch {close}; catch {wait}; send_user "\nError: Connection\ Refused ($prog): $router\n" set rshfail 1 } -re "(Connection closed by|Connection to \[^\n\r]+ closed)" { catch {close}; catch {wait}; send_user "\nError: Connection\ closed ($prog): $router\n" set rshfail 1 } "Host is unreachable" { catch {close}; catch {wait}; send_user "\nError: Host Unreachable:\ $router\n" set rshfail 1 } "No address associated with" { catch {close}; catch {wait}; send_user "\nError: Unknown host\ $router\n" set rshfail 1 } -re "\b+" { exp_continue } -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } timeout { catch {close}; catch {wait}; send_user "\nError: TIMEOUT reached\n" set rshfail 1 } eof { catch {close}; catch {wait}; } } log_user 1 } if { $rshfail } { if { !$progs } { return 1 } else { continue } } # fake the end of the session for rancid. send_user "$router# exit\n" # return rsh "success" return -1 } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } # Here we get a little tricky. There are several possibilities: # the router can ask for a username and passwd and then # talk to the TACACS server to authenticate you, or if the # TACACS server is not working, then it will use the enable # passwd. Or, the router might not have TACACS turned on, # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { -re "^<-+ More -+>\[^\n\r]*" { # ASA will use the pager for long banners send " "; exp_continue } -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 } "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)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -nocase -re "^warning: remote host denied authentication agent forwarding." { exp_continue; } -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 "% (Bad passwords|Authentication failed)" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } "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" exp_continue } -re "Last login:" { exp_continue } -re "Press the key \[^\r\n]+\[\r\n]+" { exp_continue } -re "@\[^\r\n]+ $p_prompt" { # ssh pwd prompt sleep 1 send -- "$userpswd\r" exp_continue } -re "Enter passphrase.*: " { # sleep briefly to allow time for stty -echo sleep .3 send -- "$passphrase\r" exp_continue } -re "$u_prompt" { send -- "$user\r" set uprompt_seen 1 exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send -- "$userpswd\r" } else { send -- "$passwd\r" } exp_continue } -re "$prompt" { set prompt_match $expect_out(0,string); break; } "Login invalid" { send_user "\nError: Invalid login: $router\n"; catch {close}; catch {wait}; return 1 } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } } set in_proc 0 return 0 } # Enable proc do_enable { enauser enapasswd } { global in_proc global prompt u_prompt e_prompt enacmd set in_proc 1 send "$enacmd\r" expect { -re "$u_prompt" { send -- "$enauser\r"; exp_continue} -re "$e_prompt" { send -- "$enapasswd\r"; exp_continue} "#" { set prompt "#" } "(enable)" { set prompt "> \\(enable\\) " } "% Invalid input" { send_user "\nError: Unrecognized command, check your enable command\n"; return 1 } -re "(denied|Sorry|Incorrect)" { # % Access denied - from local auth and poss. others send_user "\nError: Check your Enable passwd\n"; return 1 } "% Error in authentication" { send_user "\nError: Check your Enable passwd\n" return 1 } "% Bad passwords" { send_user "\nError: Check your Enable passwd\n" return 1 } } # We set the prompt variable (above) so script files don't need # to know what it is. set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact do_saveconfig in_proc set in_proc 1 # match cisco config mode prompts too, such as router(config-if)#, # but catalyst does not change in this fashion. regsub -lineanchor -- {^(.{1,11}).*([#>])$} $prompt {\1} reprompt regsub -all -- {[\\]$} $reprompt {} reprompt append reprompt {([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} # this is the only way i see to get rid of more prompts in o/p..grrrrr log_user 0 # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] # the pager can not be turned off on the PIX, so we have to look # for the "More" prompt. the extreme is equally obnoxious in pre-12.3 XOS, # with a global switch in the config. for {set i 0} {$i < $num_commands} { incr i} { send -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "\b+" { exp_continue } -re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)" } -re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)" exp_continue } -re "^--More--\[\r\n]+" { # specific match c1900 pager send " " exp_continue } -re "\[^\r\n]*\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } -re "\[^\r\n]*Press to cont\[^\r\n]*" { send " " # bloody ^[[2K after " " expect { -re "^\[^\r\n]*\r" {} } exp_continue } -re "^ *--More--\[^\n\r]*" { send " " exp_continue } -re "^<-+ More -+>\[^\n\r]*" { send_user -- "$expect_out(buffer)" send " " exp_continue } } } log_user 1 if { $do_interact == 1 } { interact return 0 } send -h "exit\r" expect { -re "^\[^\n\r *]*$reprompt" { # the Cisco CE and Jnx ERX # return to non-enabled mode # on exit in enabled mode. send -h "exit\r" exp_continue; } "The system has unsaved changes" { # Force10 SFTOS if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "Would you like to save them now" { # Force10 if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "(Profile|Configuration) changes have occurred.*" { # Cisco CSS if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "Do you wish to save your configuration changes" { if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "\[\n\r]+" { exp_continue } timeout { catch {close}; catch {wait}; return 1 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 set prompt_match "" # if we have dont have a tty, we need some additional terminal settings if [catch {open /dev/tty w} ttyid] { # no tty, ie: cron set spawnopts "-nottycopy" set stty_init "cols 132" } else { catch {close ttyid} reason } foreach router [lrange $argv $i end] { set router [string tolower $router] send_user -- "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Default prompt. set prompt [join [find prompt $router] ""] if { [llength $prompt] == 0 } { set prompt "(>|#| \\(enable\\))" } # look for autoenable option in .cloginrc & cmd-line set ae [find autoenable $router] if { "$ae" == "1" || $avautoenable } { set autoenable 1 } else { set autoenable 0 } # look for enable options in .cloginrc & cmd-line if { $avenable == 0 } { set enable 0 } else { set ne [find noenable $router] if { "$ne" == "1" || "$autoenable" == "1" } { set enable 0 } else { set enable 1 } } # Figure out passwords if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 } { send_user -- "\nError: no password for $router in $password_file.\n" continue } if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } { send_user -- "\nError: no enable password for $router in $password_file.\n" continue } if { $do_passwd } { set passwd [join [lindex $pswd 0] ""] } else { set passwd $userpasswd } if { $do_enapasswd } { set enapasswd [join [lindex $pswd 1] ""] } else { set enapasswd $enapasswd } } else { set passwd $userpasswd set enapasswd $enapasswd } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } 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 $ruser } } # Figure out enable command set enacmd [join [find enablecmd $router] ""] if { "$enacmd" == "" } { set enacmd "enable" } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(\[Uu]sername|Login|login|\[Uu]ser \[Nn]ame|User):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+):" } else { set p_prompt [join [lindex $p_prompt 0] ""] } set e_prompt [find enableprompt $router] if { "$e_prompt" == "" } { set e_prompt "\[Pp]assword:" } else { set e_prompt [join [lindex $e_prompt 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 cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} { incr exitval # if login failed or rsh was unsuccessful, move on to the next device continue } # Figure out the prompt. if { [regexp -- "(#| \\(enable\\))" $prompt_match junk] == 1 } { set enable 0 } if { $enable } { if {[do_enable $enauser $enapasswd]} { if { $do_command || $do_script } { incr exitval catch {close}; catch {wait}; continue } } } # we are logged in, now figure out the full prompt send "\r" regsub -all {^(\^*)(.*)} $prompt {\2} reprompt expect { -re "\[\r\n]+" { exp_continue; } -re "^.+$reprompt" { set junk $expect_out(0,string); regsub -all "\[\]\[\(\)+]" $junk {\\&} prompt; } } if { $do_command || $do_script } { send "terminal datadump\r" expect -re $prompt {} send "terminal width 132\r" expect -re $prompt {} } if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { source $sfile catch {close}; } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/brlogin.in000644 015615 000000 00000044041 13657102757 015532 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 45 # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} @login_top@ # Log into the router. # returns: 0 on success, 1 on failure, -1 if rsh was used successfully proc login { router user userpswd passwd enapasswd cmethod cyphertype } { global command spawn_id in_proc do_command do_script platform global prompt u_prompt p_prompt e_prompt sshcmd telnetcmd set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port if {"$port" == ""} { set retval [catch {eval spawn [split "$telnetcmd $router"]} reason] } else { set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason] } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif [string match "ssh*" $prog] { # ssh to the router & try to login regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason] if { $retval } { send_user "\nError: $cmd failed: $reason\n" return 1 } } elseif ![string compare $prog "rsh"] { if { ! $do_command } { if { [llength $cmethod] == 1 } { send_user "\nError: rsh is an invalid method for -x and " send_user "interactive logins\n" } if { $progs == 0 } { return 1 } continue; } # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] set rshfail 0 for {set i 0} {$i < $num_commands && !$rshfail} { incr i} { log_user 0 set retval [catch {spawn rsh $user@$router [lindex $commands $i] } reason] if { $retval } { send_user "\nError: rsh failed: $reason\n" log_user 1; return 1 } send_user "$router# [lindex $commands $i]\n" # rcmd does not get a pager and no prompts, so we just have to # look for failures & lines. expect { "Connection refused" { catch {close}; catch {wait}; send_user "\nError: Connection\ Refused ($prog): $router\n" set rshfail 1 } -re "(Connection closed by|Connection to \[^\n\r]+ closed)" { catch {close}; catch {wait}; send_user "\nError: Connection\ closed ($prog): $router\n" set rshfail 1 } "Host is unreachable" { catch {close}; catch {wait}; send_user "\nError: Host Unreachable:\ $router\n" set rshfail 1 } "No address associated with" { catch {close}; catch {wait}; send_user "\nError: Unknown host\ $router\n" set rshfail 1 } -re "\b+" { exp_continue } -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } timeout { catch {close}; catch {wait}; send_user "\nError: TIMEOUT reached\n" set rshfail 1 } eof { catch {close}; catch {wait}; } } log_user 1 } if { $rshfail } { if { !$progs } { return 1 } else { continue } } # fake the end of the session for rancid. send_user "$router:admin> exit\n" # return rsh "success" return -1 } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } # Here we get a little tricky. There are several possibilities: # the router can ask for a username and passwd and then # talk to the TACACS server to authenticate you, or if the # TACACS server is not working, then it will use the enable # passwd. Or, the router might not have TACACS turned on, # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { -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 } "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)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } 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 "% (Bad passwords|Authentication failed)" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } "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" exp_continue } -re "Last login:" { exp_continue } -re "@\[^\r\n]+ $p_prompt" { # ssh pwd prompt sleep 1 send -- "$userpswd\r" exp_continue } -re "$u_prompt" { send -- "$user\r" set uprompt_seen 1 exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send -- "$userpswd\r" } else { send -- "$passwd\r" } exp_continue } -re "$prompt" { break; } "Login invalid" { send_user "\nError: Invalid login: $router\n"; catch {close}; catch {wait}; return 1 } } } set in_proc 0 return 0 } # Enable proc do_enable { enauser enapasswd } { global do_saveconfig in_proc global prompt u_prompt e_prompt enacmd set in_proc 1 send "$enacmd\r" expect { -re "$u_prompt" { send -- "$enauser\r"; exp_continue} -re "$e_prompt" { send -- "$enapasswd\r"; exp_continue} "#" { set prompt "#" } "(enable)" { set prompt "> \\(enable\\) " } -re "(denied|Sorry|Incorrect)" { # % Access denied - from local auth and poss. others send_user "\nError: Check your Enable passwd\n"; return 1 } "% Error in authentication" { send_user "\nError: Check your Enable passwd\n" return 1 } "% Bad passwords" { send_user "\nError: Check your Enable passwd\n" return 1 } } # We set the prompt variable (above) so script files don't need # to know what it is. set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact do_saveconfig in_proc platform set in_proc 1 # If the prompt is (enable), then we are on a switch and the # command is "set length 0"; otherwise its "terminal length 0". # skip if its an extreme (since the pager can not be disabled on a # per-vty basis). 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;$command" } else { send "\r" } # match cisco config mode prompts too, such as router(config-if)#, # but catalyst does not change in this fashion. regsub -all {^(.{1,11}).*([#>])$} $prompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt expect { -re $reprompt {} -re "\[\n\r]+" { exp_continue } } } else { set reprompt $prompt } # this is the only way i see to get rid of more prompts in o/p..grrrrr log_user 0 # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command set sep "\u0002;" set commands [split $command $sep] set num_commands [llength $commands] # the pager can not be turned off on the PIX, so we have to look # for the "More" prompt. the extreme is equally obnoxious, with a # global switch in the config. for {set i 0} {$i < $num_commands} { incr i} { send -h -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "\b+" { exp_continue } -re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)" } -re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)" exp_continue } -re "^--More--\[\r\n]+" { # specific match c1900 pager send " " exp_continue } -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } -re "\[^\r\n]*Press to cont\[^\r\n]*" { send " " # bloody ^[[2K after " " expect { -re "^\[^\r\n]*\r" {} } exp_continue } -re "^ *--More--\[^\n\r]*" { send " " exp_continue } -re "^<-+ More -+>\[^\n\r]*" { send_user -- "$expect_out(buffer)" send " " exp_continue } } } log_user 1 if { $do_interact == 1 } { interact return 0 } if { [ string compare "extreme" "$platform" ] } { send -h "exit\r" } else { send -h "quit\r" } expect { -re "^\[^\n\r *]*$reprompt" { # the Cisco CE and Jnx ERX # return to non-enabled mode # on exit in enabled mode. send -h "exit\r" exp_continue; } "The system has unsaved changes" { # Force10 SFTOS if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "Would you like to save them now" { # Force10 if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "(Profile|Configuration) changes have occurred.*" { # Cisco CSS if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "Do you wish to save your configuration changes" { if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "\[\n\r]+" { exp_continue } timeout { catch {close}; catch {wait}; return 1 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 foreach router [lrange $argv $i end] { set router [string tolower $router] # attempt at platform switching. set platform "" send_user -- "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Figure out the prompt. # autoenable is off by default. If we have it defined, it was done # on the command line. If it is not specifically set on the command # line, check the password file. if $avautoenable { set autoenable 1 set enable 0 set prompt "(>| \\(enable\\))" } else { set ae [find autoenable $router] if { "$ae" == "1" } { set autoenable 1 set enable 0 set prompt "(>| \\(enable\\))" } else { set autoenable 0 set enable $avenable set prompt ">" } } # look for noenable option in .cloginrc if { [find noenable $router] != "" } { set enable 0 } # Figure out passwords if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 } { send_user -- "\nError: no password for $router in $password_file.\n" continue } if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } { send_user -- "\nError: no enable password for $router in $password_file.\n" continue } if { $do_passwd } { set passwd [join [lindex $pswd 0] ""] } else { set passwd $userpasswd } if { $do_enapasswd } { set enapasswd [join [lindex $pswd 1] ""] } else { set enapasswd $enapasswd } } else { set passwd $userpasswd set enapasswd $enapasswd } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } 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 $ruser } } # Figure out enable command set enacmd [join [find enablecmd $router] ""] if { "$enacmd" == "" } { set enacmd "enable" } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(Username|Login|login|user name|User):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "(\[Pp]assword|passwd):" } else { set p_prompt [join [lindex $p_prompt 0] ""] } set e_prompt [find enableprompt $router] if { "$e_prompt" == "" } { set e_prompt "\[Pp]assword:" } else { set e_prompt [join [lindex $e_prompt 0] ""] } # Figure out cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype]} { incr exitval # if login failed or rsh was unsuccessful, move on to the next device continue } if { $enable } { if {[do_enable $enauser $enapasswd]} { if { $do_command || $do_script } { incr exitval catch {close}; catch {wait}; continue } } } # we are logged in, now figure out the full prompt send "\r" expect { -re "\[\r\n]+" { exp_continue; } -re "^(.+\[:.])1 ($prompt)" { # stoopid extreme cmd-line numbers and # prompt based on state of config changes, # which may have an * at the beginning. set junk $expect_out(1,string) regsub -all "^\\\* " $expect_out(1,string) {} junk regsub -all "\[\]\[\(\)]" $junk {\\&} junk; set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)"; set platform "extreme" } -re "^.+$prompt" { set junk $expect_out(0,string); regsub -all "\[\]\[\(\)]" $junk {\\&} prompt; } } if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { # If the prompt is (enable), then we are on a switch and the # command is "set length 0"; otherwise its "terminal length 0". if [ regexp -- ".*> .*enable" "$prompt" ] { send -h "set length 0\r" expect -re $prompt {} send -h "set logging session disable\r" } else { send -h "terminal length 0\r" expect -re $prompt {} send -h "set width 80\r" } expect -re $prompt {} source $sfile catch {close}; } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/Makefile.in000644 015615 000000 00000077743 13735672075 015634 0ustar00heaswheel000000 000000 # Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : bin_PROGRAMS = hpuifilter$(EXEEXT) par$(EXEEXT) subdir = bin ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = login_top a10login agmrancid alogin arancid \ anlogin avologin blogin brancid brlogin cat5rancid clogin \ csblogin cssrancid dllogin elogin erancid f5rancid flogin \ fnlogin fxlogin hlogin htlogin htrancid jlogin jerancid \ mrancid mrvlogin mtlogin nlogin nrancid noklogin nslogin \ nsrancid panlogin rblogin rivlogin rivrancid rrancid rtftpcopy \ tlogin trancid xilogin xirancid xlogin ulogin wlogin CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_hpuifilter_OBJECTS = hpuifilter.$(OBJEXT) hpuifilter_OBJECTS = $(am_hpuifilter_OBJECTS) hpuifilter_LDADD = $(LDADD) am_par_OBJECTS = par.$(OBJEXT) par_OBJECTS = $(am_par_OBJECTS) par_LDADD = $(LDADD) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } SCRIPTS = $(bin_SCRIPTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/hpuifilter.Po ./$(DEPDIR)/par.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(hpuifilter_SOURCES) $(par_SOURCES) DIST_SOURCES = $(hpuifilter_SOURCES) $(par_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/a10login.in \ $(srcdir)/agmrancid.in $(srcdir)/alogin.in \ $(srcdir)/anlogin.in $(srcdir)/arancid.in \ $(srcdir)/avologin.in $(srcdir)/blogin.in $(srcdir)/brancid.in \ $(srcdir)/brlogin.in $(srcdir)/cat5rancid.in \ $(srcdir)/clogin.in $(srcdir)/csblogin.in \ $(srcdir)/cssrancid.in $(srcdir)/dllogin.in \ $(srcdir)/elogin.in $(srcdir)/erancid.in $(srcdir)/f5rancid.in \ $(srcdir)/flogin.in $(srcdir)/fnlogin.in $(srcdir)/fxlogin.in \ $(srcdir)/hlogin.in $(srcdir)/htlogin.in $(srcdir)/htrancid.in \ $(srcdir)/jerancid.in $(srcdir)/jlogin.in \ $(srcdir)/login_top.in $(srcdir)/mrancid.in \ $(srcdir)/mrvlogin.in $(srcdir)/mtlogin.in $(srcdir)/nlogin.in \ $(srcdir)/noklogin.in $(srcdir)/nrancid.in \ $(srcdir)/nslogin.in $(srcdir)/nsrancid.in \ $(srcdir)/panlogin.in $(srcdir)/rblogin.in \ $(srcdir)/rivlogin.in $(srcdir)/rivrancid.in \ $(srcdir)/rrancid.in $(srcdir)/rtftpcopy.in \ $(srcdir)/tlogin.in $(srcdir)/trancid.in $(srcdir)/ulogin.in \ $(srcdir)/wlogin.in $(srcdir)/xilogin.in $(srcdir)/xirancid.in \ $(srcdir)/xlogin.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ADMINMAILPLUS = @ADMINMAILPLUS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ #CPPFLAGS += @PG_CPPFLAGS@ #INCLUDES += -I$(top_srcdir)/include @PG_CPPFLAGS@ #INCLUDES += -I$(top_srcdir)/include #CFLAGS += -g CFLAGS = -g -O0 COMM = @COMM@ COPYYEARS = @COPYYEARS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CVS = @CVS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DIFF = @DIFF@ DIFF_CMD = @DIFF_CMD@ DIRNAME = @DIRNAME@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ ENV_PATH = @ENV_PATH@ EXEEXT = @EXEEXT@ EXPECT_PATH = @EXPECT_PATH@ FIND = @FIND@ GIT = @GIT@ GREP = @GREP@ ID = @ID@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LG_PING_CMD = @LG_PING_CMD@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAILPLUS = @MAILPLUS@ MAINT = @MAINT@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR = @MKDIR@ MKDIR_P = @MKDIR_P@ MKTEMP = @MKTEMP@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERLV = @PERLV@ PERLV_PATH = @PERLV_PATH@ PING_PATH = @PING_PATH@ PYTHON3 = @PYTHON3@ PYTHON3_PATH = @PYTHON3_PATH@ RCSSYS = @RCSSYS@ RSH = @RSH@ SENDMAIL = @SENDMAIL@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SORT = @SORT@ SSH = @SSH@ STRIP = @STRIP@ SVN = @SVN@ SVN_FSTYPE = @SVN_FSTYPE@ TAR = @TAR@ TELNET = @TELNET@ TELNET_CMD = @TELNET_CMD@ TOUCH = @TOUCH@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ #AUTOMAKE_OPTIONS=foreign no-dependencies AUTOMAKE_OPTIONS = foreign bin_SCRIPTS = a10login alogin agmrancid anlogin arancid avologin \ blogin brancid brlogin cat5rancid clogin control_rancid \ csblogin cssrancid dllogin elogin erancid f5rancid flogin \ fnlogin fxlogin hlogin hrancid htlogin htrancid jerancid \ jlogin mrancid mrvlogin mtlogin nlogin noklogin nrancid \ nslogin nsrancid panlogin plogin rancid rblogin rivlogin \ rivrancid rrancid rtftpcopy tlogin trancid ulogin wlogin \ xilogin xirancid xlogin lg.cgi lgform.cgi rancid-cvs rancid-fe \ rancid-run # XXX hack for the rancid to get pkglibdir, see corresponding XXX below bin_in = control_rancid.in hrancid.in plogin.in rancid.in EXTRA_DIST = lg.cgi.in lgform.cgi.in rancid-cvs.in rancid-fe.in rancid-run.in \ $(bin_in) login_top.in #dist_bin_SCRIPTS= $(bin_SCRIPTS:%=%.in) CLEANFILES = lg.cgi lgform.cgi plogin rancid rancid-cvs rancid-fe rancid-run #CLEANFILES= $(bin_SCRIPTS) hpuifilter_SOURCES = hpuifilter.c par_SOURCES = par.c YFLAGS = -d #LFLAGS = -i # no idea why automake doesnt clean these targets #CLEANFILES= y.tab.c y.tab.h lex.yy.c conf.h conf.c conflex.c #clean: # rm -f Makefile env $(BIN_DATAS) $(BIN_PROGS) # auto_edit does the autoconf variable substitution. This allows the # substitution to have the full expansion of the variables, e.g.: $sysconfdir # will be /prefix/etc instead of ${prefix}/etc. # # This is a bit of a PITA, but is the method recommended by the autoconf # documentation. auto_edit = sed \ -e 's,@prefix\@,$(prefix),g' \ -e 's,@localstatedir\@,$(localstatedir),g' \ -e 's,@pkglibdir\@,$(pkglibdir),g' \ -e 's,@sysconfdir\@,$(sysconfdir),g' \ -e 's,@DIFF_CMD\@,$(DIFF_CMD),g' \ -e 's,@EXPECT_PATH\@,$(EXPECT_PATH),g' \ -e 's,@PERLV\@,$(PERLV),g' \ -e 's,@PERLV_PATH\@,$(PERLV_PATH),g' \ -e 's,@PYTHON3\@,$(PYTHON3),g' \ -e 's,@PYTHON3_PATH\@,$(PYTHON3_PATH),g' \ -e 's,@LG_PING_CMD\@,$(LG_PING_CMD),g' \ -e 's,@ADMINMAILPLUS\@,$(ADMINMAILPLUS),g' \ -e 's,@LOCKPROG\@,$(LOCKPROG),g' \ -e 's,@MAILPLUS\@,$(MAILPLUS),g' \ -e 's,@PACKAGE\@,$(PACKAGE),g' \ -e 's,@SVN_FSTYPE\@,$(SVN_FSTYPE),g' \ -e 's,@SENDMAIL\@,$(SENDMAIL),g' \ -e 's,@VERSION\@,$(VERSION),g' \ -e 's,@COPYYEARS\@,$(COPYYEARS),g' \ -e '/@copyright@/r ../COPYING' -e '/@copyright@/d' all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign bin/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign bin/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): login_top: $(top_builddir)/config.status $(srcdir)/login_top.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ a10login: $(top_builddir)/config.status $(srcdir)/a10login.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ agmrancid: $(top_builddir)/config.status $(srcdir)/agmrancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ alogin: $(top_builddir)/config.status $(srcdir)/alogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ arancid: $(top_builddir)/config.status $(srcdir)/arancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ anlogin: $(top_builddir)/config.status $(srcdir)/anlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ avologin: $(top_builddir)/config.status $(srcdir)/avologin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ blogin: $(top_builddir)/config.status $(srcdir)/blogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ brancid: $(top_builddir)/config.status $(srcdir)/brancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ brlogin: $(top_builddir)/config.status $(srcdir)/brlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ cat5rancid: $(top_builddir)/config.status $(srcdir)/cat5rancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ clogin: $(top_builddir)/config.status $(srcdir)/clogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ csblogin: $(top_builddir)/config.status $(srcdir)/csblogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ cssrancid: $(top_builddir)/config.status $(srcdir)/cssrancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ dllogin: $(top_builddir)/config.status $(srcdir)/dllogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ elogin: $(top_builddir)/config.status $(srcdir)/elogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ erancid: $(top_builddir)/config.status $(srcdir)/erancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ f5rancid: $(top_builddir)/config.status $(srcdir)/f5rancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ flogin: $(top_builddir)/config.status $(srcdir)/flogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ fnlogin: $(top_builddir)/config.status $(srcdir)/fnlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ fxlogin: $(top_builddir)/config.status $(srcdir)/fxlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ hlogin: $(top_builddir)/config.status $(srcdir)/hlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ htlogin: $(top_builddir)/config.status $(srcdir)/htlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ htrancid: $(top_builddir)/config.status $(srcdir)/htrancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ jlogin: $(top_builddir)/config.status $(srcdir)/jlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ jerancid: $(top_builddir)/config.status $(srcdir)/jerancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mrancid: $(top_builddir)/config.status $(srcdir)/mrancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mrvlogin: $(top_builddir)/config.status $(srcdir)/mrvlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mtlogin: $(top_builddir)/config.status $(srcdir)/mtlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ nlogin: $(top_builddir)/config.status $(srcdir)/nlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ nrancid: $(top_builddir)/config.status $(srcdir)/nrancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ noklogin: $(top_builddir)/config.status $(srcdir)/noklogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ nslogin: $(top_builddir)/config.status $(srcdir)/nslogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ nsrancid: $(top_builddir)/config.status $(srcdir)/nsrancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ panlogin: $(top_builddir)/config.status $(srcdir)/panlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ rblogin: $(top_builddir)/config.status $(srcdir)/rblogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ rivlogin: $(top_builddir)/config.status $(srcdir)/rivlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ rivrancid: $(top_builddir)/config.status $(srcdir)/rivrancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ rrancid: $(top_builddir)/config.status $(srcdir)/rrancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ rtftpcopy: $(top_builddir)/config.status $(srcdir)/rtftpcopy.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ tlogin: $(top_builddir)/config.status $(srcdir)/tlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ trancid: $(top_builddir)/config.status $(srcdir)/trancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ xilogin: $(top_builddir)/config.status $(srcdir)/xilogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ xirancid: $(top_builddir)/config.status $(srcdir)/xirancid.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ xlogin: $(top_builddir)/config.status $(srcdir)/xlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ ulogin: $(top_builddir)/config.status $(srcdir)/ulogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ wlogin: $(top_builddir)/config.status $(srcdir)/wlogin.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) hpuifilter$(EXEEXT): $(hpuifilter_OBJECTS) $(hpuifilter_DEPENDENCIES) $(EXTRA_hpuifilter_DEPENDENCIES) @rm -f hpuifilter$(EXEEXT) $(AM_V_CCLD)$(LINK) $(hpuifilter_OBJECTS) $(hpuifilter_LDADD) $(LIBS) par$(EXEEXT): $(par_OBJECTS) $(par_DEPENDENCIES) $(EXTRA_par_DEPENDENCIES) @rm -f par$(EXEEXT) $(AM_V_CCLD)$(LINK) $(par_OBJECTS) $(par_LDADD) $(LIBS) install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n' \ -e 'h;s|.*|.|' \ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) { files[d] = files[d] " " $$1; \ if (++n[d] == $(am__install_max)) { \ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ else { print "f", d "/" $$4, $$1 } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binSCRIPTS: @$(NORMAL_UNINSTALL) @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 's,.*/,,;$(transform)'`; \ dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hpuifilter.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/par.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @echo '# dummy' >$@-t && $(am__mv) $@-t $@ am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) $(SCRIPTS) installdirs: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/hpuifilter.Po -rm -f ./$(DEPDIR)/par.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-binSCRIPTS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/hpuifilter.Po -rm -f ./$(DEPDIR)/par.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ clean-binPROGRAMS clean-generic cscopelist-am ctags ctags-am \ distclean distclean-compile distclean-generic distclean-tags \ distdir dvi dvi-am html html-am info info-am install \ install-am install-binPROGRAMS install-binSCRIPTS install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-binPROGRAMS uninstall-binSCRIPTS .PRECIOUS: Makefile # XXX this is the generic version for the rest of bin_scripts that comes from # configure.in now. perhaps change to use this. $(bin_in:%.in=%): Makefile $(top_builddir)/config.status ../COPYING rm -f $@ $@.tmp; \ $(auto_edit) $(srcdir)/$@.in >$@.tmp; \ chmod +x $@.tmp; \ mv $@.tmp $@ # XXX there must be a better way to produce these dependencies, perhaps in # configure, but more likely need a depend target. alogin: $(srcdir)/alogin.in control_rancid: $(srcdir)/control_rancid.in hlogin: $(srcdir)/hlogin.in hrancid: $(srcdir)/hrancid.in plogin: $(srcdir)/plogin.in rancid: $(srcdir)/rancid.in lg.cgi: Makefile $(srcdir)/lg.cgi.in rm -f lg.cgi lg.cgi.tmp; \ $(auto_edit) $(srcdir)/lg.cgi.in >lg.cgi.tmp; \ chmod +x lg.cgi.tmp; \ mv lg.cgi.tmp lg.cgi lgform.cgi: Makefile $(srcdir)/lgform.cgi.in rm -f lgform.cgi lgform.cgi.tmp; \ $(auto_edit) $(srcdir)/lgform.cgi.in >lgform.cgi.tmp; \ chmod +x lgform.cgi.tmp; \ mv lgform.cgi.tmp lgform.cgi rancid-cvs: Makefile $(srcdir)/rancid-cvs.in rm -f rancid-cvs rancid-cvs.tmp; \ $(auto_edit) $(srcdir)/rancid-cvs.in >rancid-cvs.tmp; \ chmod +x rancid-cvs.tmp; \ mv rancid-cvs.tmp rancid-cvs rancid-fe: Makefile $(srcdir)/rancid-fe.in rm -f rancid-fe rancid-fe.tmp; \ $(auto_edit) $(srcdir)/rancid-fe.in >rancid-fe.tmp; \ chmod +x rancid-fe.tmp; \ mv rancid-fe.tmp rancid-fe rancid-run: Makefile $(srcdir)/rancid-run.in rm -f rancid-run rancid-run.tmp; \ $(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 $(bin_SCRIPTS): ../COPYING login_top # 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: rancid-3.13/bin/rivrancid.in000644 015615 000000 00000026140 13534015000 016031 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # Amazingly hacked version of Hank's rancid - this one tries to # deal with Cabletron, Riverstone and Enterasys routers/switches # # 10/23/2002 -- Initial changes for Riverstone/Cabletron support # Jim Meehan -- jmeehan@vpizza.org # # RANCID - Really Awesome New Cisco confIg Differ # # usage: rivrancid [-dltCV] [-f filename | hostname] # use Getopt::Std; getopts('dflt:CV'); if ($opt_V) { print "@PACKAGE@ @VERSION@\n"; exit(0); } $log = $opt_l; $debug = $opt_d; $file = $opt_f; $host = $ARGV[0]; $clean_run = 0; $found_end = 0; $timeo = 90; # rivlogin timeout in seconds my(@commandtable, %commands, @commands);# command lists my($aclsort) = ("ipsort"); # ACL sorting mode my($filter_commstr); # SNMP community string filtering my($filter_osc); # oscillating data filtering mode 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)) && scalar(%history)) { print eval "$command \%history"; undef %history; } if (($new_hist_tag) && ($new_command) && ($command_string)) { if ($history{$command_string}) { $history{$command_string} = "$history{$command_string}@string"; } else { $history{$command_string} = "@string"; } } elsif (($new_hist_tag) && ($new_command)) { $history{++$#history} = "@string"; } else { print "@string"; } $hist_tag = $new_hist_tag; $command = $new_command; 1; } sub numerically { $a <=> $b; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort numerically keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort values %lines) { $sorted_lines[$i] = $key; $i++; } @sorted_lines; } # This is a numerical sort routine (ascending). sub numsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $num (sort {$a <=> $b} keys %lines) { $sorted_lines[$i] = $lines{$num}; $i++; } @sorted_lines; } # This is a sort routine that will sort on the # ip address when the ip address is anywhere in # the strings. sub ipsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $addr (sort sortbyipaddr keys %lines) { $sorted_lines[$i] = $lines{$addr}; $i++; } @sorted_lines; } # 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])); } sub sortbyipaddr { &ipaddrval($a) <=> &ipaddrval($b); } # This routine parses "system show version" sub ShowVersion { my($slot); print STDERR " In ShowVersion: $_" if ($debug); while () { tr/\015//d; next if /^\s*$/; last if(/^$prompt/); ProcessHistory("VERSION","","","!SW: $_"); } ProcessHistory("VERSION","","","!\n"); return(0); } # This routine parses "system show hardware" sub ShowHardware { print STDERR " In ShowHardware: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); ProcessHistory("HARDWARE","","","!HW: $_"); } ProcessHistory("","","","!\n"); return(0); } # This routine parses "system show uptime" sub ShowUptime { print STDERR " In ShowUptime: $_" if ($debug); while () { tr/\015//d; last if(/^$prompt/); next if /^\s*$/; next if /System up/; ProcessHistory("UPTIME","","","!UPTIME: $_"); } ProcessHistory("","","","!\n"); return; } # This routine processes a "system show active" sub ShowActive { print STDERR " In ShowActive: $_" if ($debug); while () { tr/\015//d; # Remove leading whitespace and/or line numbers s/^\s*(\d+\D: )*//; # Riverstone/Cabletron doesn't have an "end" line, so # we need to set $clean_run here if (/^$prompt/) { $clean_run = 1; last; } next if (/Running system configuration/); # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; if (/^(.*hashed-password \S+)/ && $filter_pwds == 2) { ProcessHistory("","","","! $1 \n"); next; } if (/^(snmp set community )\S+/ && $filter_commstr) { ProcessHistory("","","","! $1$'"); next; } ProcessHistory("","","","$_"); } return; } # Main @commandtable = ( {'system show uptime' => 'ShowUptime'}, {'system show version' => 'ShowVersion'}, {'system show hardware' => 'ShowHardware'}, {'system show active-config' => 'ShowActive'} ); # 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); $commandcnt = scalar(keys %commands); $commandstr=join(";",@commands); $cmds_regexp = join("|", map quotemeta($_), @commands); if (length($host) == 0) { if ($file) { print(STDERR "Too few arguments: file name required\n"); exit(1); } else { print(STDERR "Too few arguments: host name required\n"); exit(1); } } if ($opt_C) { print "rivlogin -t $timeo -c\'$commandstr\' $host\n"; exit(0); } open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n"; select(OUTPUT); # make OUTPUT unbuffered if debugging if ($debug) { $| = 1; } if ($file) { print(STDERR "opening file $host\n") if ($debug || $log); open(INPUT,"<$host") || die "open failed for $host: $!\n"; } else { print(STDERR "executing rivlogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log); system "rivlogin -t $timeo -c \"$commandstr\" $host $host.raw 2>&1" || die "rivlogin failed for $host: $!\n"; open(INPUT, "< $host.raw") || die "rivlogin failed for $host: $!\n"; } # 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 oscillating data filtering mode if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) { $filter_osc = 0; } else { $filter_osc = 1; } # determine password filtering mode if ($ENV{"FILTER_PWDS"} =~ /no/i) { $filter_pwds = 0; } elsif ($ENV{"FILTER_PWDS"} =~ /all/i) { $filter_pwds = 2; } else { $filter_pwds = 1; } ProcessHistory("","","","!RANCID-CONTENT-TYPE: riverstone\n!\n"); TOP: while() { tr/\015//d; last if ($clean_run); if (/^Error:/) { print STDOUT ("$host rivlogin error: $_"); print STDERR ("$host rivlogin error: $_") if ($debug); $clean_run=0; last; } $kradcount++; while (/\033(\[\?25l)/) { s/\033\[\?25l//g; #print STDERR "krad $1\n"; #print STDERR $_; #print STDERR $kradcount; next; } while (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([}{)(\\])/\\$1/g; } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } print STDOUT "Done $logincmd: $_\n" if ($log); # Flush History ProcessHistory("","","",""); # Cleanup close(INPUT); close(OUTPUT); unlink("$host.raw") if (! $debug); # check for completeness if (scalar(%commands) || !$clean_run) { if (scalar(keys %commands) eq $commandcnt) { printf(STDERR "$host: missed cmd(s): all commands\n"); } elsif (scalar(%commands)) { my($count, $i) = 0; for ($i = 0; $i < $#commands; $i++) { if ($commands{$commands[$i]}) { if (!$count) { printf(STDERR "$host: missed cmd(s): %s", $commands[$i]); } else { printf(STDERR ", %s", $commands[$i]); } $count++; } } if ($count) { printf(STDERR "\n"); } } if (!$clean_run) { print(STDERR "$host: End of run not found\n"); if ($debug) { print(STDERR "$host: clean_run is false\n") if (!$clean_run); } system("/usr/bin/tail -1 $host.new"); } unlink "$host.new" if (! $debug); } rancid-3.13/bin/mrvlogin.in000644 015615 000000 00000033612 13657102757 015735 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # mrvlogin - MRV login # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 45 # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} @login_top@ # Log into the router. # returns: 0 on success, 1 on failure proc login { router user userpswd passwd enapasswd cmethod cyphertype } { global command spawn_id in_proc do_command do_script global prompt u_prompt p_prompt e_prompt sshcmd telnetcmd set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port if {"$port" == ""} { set retval [ catch {eval spawn [split "$telnetcmd $router"]} reason ] } else { set retval [ catch {eval spawn [split "$telnetcmd $router $port"]} reason ] } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif [string match "ssh*" $prog] { regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } set retval [ catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason ] if { $retval } { send_user "\nError: $sshcmd failed: $reason\n" return 1 } } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } # Here we get a little tricky. There are several possibilities: # the router can ask for a username and passwd and then # talk to the TACACS server to authenticate you, or if the # TACACS server is not working, then it will use the enable # passwd. Or, the router might not have TACACS turned on, # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { -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 } "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)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -nocase -re "^warning: remote host denied authentication agent forwarding." { exp_continue; } -re "(denied|Sorry)" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } -re "Login (failed|incorrect)" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } -re "% (Bad passwords|Authentication failed)" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } "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" exp_continue } -re "Last login:" { exp_continue } -re "@\[^\r\n]+ $p_prompt" { # ssh pwd prompt sleep 1 send -h -- "$userpswd\r" exp_continue } -re "$u_prompt" { send -h -- "$user\r" set uprompt_seen 1 exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send -h -- "$userpswd\r" } else { send -h -- "$passwd\r" } exp_continue } -re "$prompt" { break; } "Login invalid" { send_user "\nError: Invalid login: $router\n"; catch {close}; catch {wait}; return 1 } -re "\[^\r\n]\[\r\n]+" { exp_continue } } } set in_proc 0 return 0 } # Enable proc do_enable { enauser enapasswd } { global prompt in_proc global u_prompt e_prompt set in_proc 1 send -h "enable\r" expect { -re "$u_prompt" { send -h -- "$enauser\r"; exp_continue} -re "$e_prompt" { send -h -- "$enapasswd\r"; exp_continue} "#" { set prompt "#" } -re "(denied|Sorry|Incorrect)" { # % Access denied - from local auth and poss. others send_user "\nError: Check your Enable passwd\n"; return 1 } "% Error in authentication" { send_user "\nError: Check your Enable passwd\n" return 1 } "% Bad passwords" { send_user "\nError: Check your Enable passwd\n" return 1 } } # We set the prompt variable (above) so script files don't need # to know what it is. set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact in_proc set in_proc 1 # match cisco config mode prompts too, such as router(config-if)# regsub -lineanchor -- {^(.{1,11}).*([#>] *)$} $prompt {\1} reprompt # escape any parens or escapes in the prompt regsub -all -- {[)(\\]$} $reprompt {} reprompt append reprompt {([^#>\r\n]+)?[#>]} # this is the only way i see to get rid of more prompts in o/p..grrrrr log_user 0 # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] # the pager can not be turned off on the PIX, so we have to look # for the "More" prompt. the extreme is equally obnoxious, with a # global switch in the config. # XXX I think the pager can be turned off and this is just an artifact of # clogin for {set i 0} {$i < $num_commands} { incr i} { send -h -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "\b+" { exp_continue } -re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)" } -re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)" exp_continue } -re "^--More--\[\r\n]+" { # specific match c1900 pager send " " exp_continue } -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } -re "\[^\r\n]*Press to cont\[^\r\n]*" { send " " # bloody ^[[2K after " " expect { -re "^\[^\r\n]*\r" {} } exp_continue } -re "^ *--More--\[^\n\r]*" { send " " exp_continue } -re "^<-+ More -+>\[^\n\r]*" { send_user -- "$expect_out(buffer)" send " " exp_continue } } } log_user 1 if { $do_interact == 1 } { interact return 0 } send -h "exit\r" expect { -re "^\[^\n\r *]*$reprompt" { # the Cisco CE and Jnx ERX # return to non-enabled mode # on exit in enabled mode. send -h "exit\r" exp_continue; } "Would you like to save them now" { # Force10 send "n\r" exp_continue } "Configuration changes have occurred.*" { # Cisco CSS send "n\r" exp_continue } "Do you wish to save your configuration changes" { send "n\r" exp_continue } -re "\[\n\r]+" { exp_continue } timeout { catch {close}; catch {wait}; return 0 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 foreach router [lrange $argv $i end] { set router [string tolower $router] send_user -- "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Figure out the prompt. # autoenable is off by default. If we have it defined, it was done # on the command line. If it is not specifically set on the command # line, check the password file. if $avautoenable { set autoenable 1 set enable 0 set prompt "#\[^\[:digit:]]" } else { set ae [find autoenable $router] if { "$ae" == "1" } { set autoenable 1 set enable 0 set prompt "#\[^\[:digit:]]" } else { set autoenable 0 set enable $avenable set prompt ">" } } # look for noenable option in .cloginrc if { [find noenable $router] == "1" } { set enable 0 } # Figure out passwords if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 } { send_user -- "\nError: no password for $router in $password_file.\n" continue } if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } { send_user -- "\nError: no enable password for $router in $password_file.\n" continue } if { $do_passwd } { set passwd [join [lindex $pswd 0] ""] } else { set passwd $userpasswd } if { $do_enapasswd } { set enapasswd [join [lindex $pswd 1] ""] } else { set enapasswd $enapasswd } } else { set passwd $userpasswd set enapasswd $enapasswd } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } 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 $ruser } } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(Username|Login|login|user name):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "(\[Pp]assword|passwd):" } else { set p_prompt [join [lindex $p_prompt 0] ""] } set e_prompt [find enableprompt $router] if { "$e_prompt" == "" } { set e_prompt "\[Pp]assword:" } else { set e_prompt [join [lindex $e_prompt 0] ""] } # Figure out cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype]} { incr exitval # if login failed, move on to the next device continue } if { $enable } { if {[do_enable $enauser $enapasswd]} { if { $do_command || $do_script } { incr exitval catch {close}; catch {wait}; continue } } } # we are logged in, now figure out the full prompt send "\r" expect { -re "\[\r\n]+" { exp_continue; } -re "^.+$prompt" { set junk $expect_out(0,string); regsub -all "\[\]\[]" $junk {\\&} prompt; } } if { $do_command || $do_script } { send -h "terminal length 0\r" expect -re $prompt {} send -h "no cli-paging\r" expect -re $prompt {} } if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { source $sfile catch {close}; } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/elogin.in000644 015615 000000 00000034152 13477566443 015363 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # elogin - ADC EZT3 login # # Most options are intuitive for logging into an ADC EZT3 mux. # # XXX need to import login_top. # Usage line set usage "Usage: $argv0 \[-diSV\] \[-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\] \ \[-y ssh_cypher_type\] router \[router...\]\n" # env(CLOGIN) may contain: # x == do not set xterm banner or name # Password file set password_file $env(HOME)/.cloginrc # Default is to login to the router set do_command 0 set do_interact 0 set do_script 0 # The default is to automatically enable set avenable 1 # The default is that you login non-enabled (tacacs can have you login already # enabled) 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 # cloginrc debugging knob set do_cloginrcdbg 0 # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 45 # intialize cloginrc parsing stacks set int_file {} set int_lineno {} # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} # Find the user in the ENV, or use the unix userid. if {[ info exists env(CISCO_USER) ]} { set default_user $env(CISCO_USER) } elseif {[ info exists env(USER) ]} { set default_user $env(USER) } elseif {[ info exists env(LOGNAME) ]} { set default_user $env(LOGNAME) } 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. if [ catch {exec id} reason ] { send_error "\nError: could not exec id: $reason\n" exit 1 } regexp {\(([^)]*)} "$reason" junk default_user } if {[ info exists env(CLOGINRC) ]} { set password_file $env(CLOGINRC) } # Process the command line for {set i 0} {$i < $argc} {incr i} { set arg [lindex $argv $i] switch -glob -- $arg { # Expect debug mode -d* { exp_internal 1 # Username } -u* { if {! [ regexp .\[uU\](.+) $arg ignore user]} { incr i set username [ lindex $argv $i ] } # cloginrc debugging knobs } -m* { set do_cloginrcdbg 1 } -M* { set do_cloginrcdbg 2 # interactive } -i* { set do_interact 1 # VTY Password } -p* { if {! [ regexp .\[pP\](.+) $arg ignore userpasswd]} { incr i set userpasswd [ lindex $argv $i ] } set do_passwd 0 # ssh passphrase } -r* { # ignore -r # VTY Password } -v* { if {! [ regexp .\[vV\](.+) $arg ignore passwd]} { incr i set passwd [ lindex $argv $i ] } set do_passwd 0 # Version string } -V* { send_user "@PACKAGE@ @VERSION@\n" exit 0 # Enable Username } -w* { # ignore -w # Environment variable to pass to -s scripts } -E* { if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { set E$varname $varvalue } else { send_user "\nError: invalid format for -E in $arg\n" exit 1 } # Enable Password } -e* { # ignore -e # Command to run. } -c* { if {! [ regexp .\[cC\](.+) $arg ignore command]} { incr i set command [ lindex $argv $i ] } set do_command 1 # Expect script to run. } -s* { if {! [ regexp .\[sS\](.+) $arg ignore sfile]} { incr i set sfile [ lindex $argv $i ] } if { ! [ file readable $sfile ] } { send_user "\nError: Can't read $sfile\n" exit 1 } set do_script 1 # save config on exit } -S* { set do_saveconfig 1 # 'ssh -c' cypher type } -y* { if {! [ regexp .\[eE\](.+) $arg ignore cypher]} { incr i set cypher [ lindex $argv $i ] } # alternate cloginrc file } -f* { if {! [ regexp .\[fF\](.+) $arg ignore password_file]} { incr i set password_file [ lindex $argv $i ] } # Timeout } -t* { if {! [ regexp .\[tT\](.+) $arg ignore timeout]} { incr i set timeoutdflt [ lindex $argv $i ] } # Command file } -x* { if {! [ regexp .\[xX\](.+) $arg ignore cmd_file]} { incr i set cmd_file [ lindex $argv $i ] } 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 # Do we enable? } -noenable { # ignore -noenable # Does tacacs automatically enable us? } -autoenable { # ignore -autoenable } -* { send_user "\nError: Unknown argument! $arg\n" send_user $usage exit 1 } default { break } } } # Process routers...no routers listed is an error. if { $i == $argc } { send_user "\nError: $usage" } # Only be quiet if we are running a script (it can log its output # on its own) if { $do_script } { log_user 0 } else { log_user 1 } # # Done configuration/variable setting. Now run with it... # # 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 } } # take host from ENV(TERM) 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" } } } # This is a helper function to make the password file easier to # maintain. Using this the password file has the form: # add password sl* pete cow # add password at* steve # add password * hanky-pie proc add {var args} { global int_file int_lineno int_$var set file [lindex $int_file 0] set lineno [lindex $int_lineno 0] lappend int_$var "$var:$file:$lineno: $args" } proc include {args} { global env regsub -all "(^{|}$)" $args {} args if {[regexp "^/" $args ignore] == 0} { set args $env(HOME)/$args } source_password_file $args } proc find {var router} { global do_cloginrcdbg upvar int_$var list if {[info exists list]} { foreach line $list { if {[string match -nocase [lindex $line 1] $router]} { if {$do_cloginrcdbg > 0} { send_error -- [join [list [lindex $line 0] [lrange $line 1 end] "\r\n"]] } if {$do_cloginrcdbg == 2} { # save return value if {! [info exists result]} { set result [lrange $line 2 end] } } else { return [lrange $line 2 end] } } } } if {$do_cloginrcdbg == 2} { if {[info exists result]} { return $result } } return {} } # Loads the password file. Note that as this file is tcl, and that # it is sourced, the user better know what to put in there, as it # could install more than just password info... I will assume however, # 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 {file} { global env int_file int_lineno if {! [file exists $file]} { send_user "\nError: password file ($file) does not exist\n" exit 1 } file stat $file fileinfo if {[expr ($fileinfo(mode) & 007)] != 0000} { send_user "\nError: $file must not be world readable/writable\n" exit 1 } if [catch {set fd [open $file "r"]} reason] { send_user "\nError: $reason\n" exit 1 } set int_file [linsert $int_file 0 $file] set int_lineno [linsert $int_lineno 0 0] while {[gets $fd line] >= 0} { set tmp [lindex $int_lineno 0]; incr tmp lset int_lineno 0 $tmp eval $line } set int_file [lrange $int_file 1 end] set int_lineno [lrange $int_lineno 1 end] close $fd } # Log into the router. # returns: 0 on success, 1 on failure proc login { router user userpswd passwd prompt cmethod cyphertype } { global spawn_id in_proc do_command do_script global u_prompt p_prompt telnetcmd set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog command suffix port if {"$port" == ""} { set retval [ catch {eval spawn [split "$telnetcmd $router"]} reason ] } else { set retval [ catch {eval spawn [split "$telnetcmd $router $port"]} reason ] } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif ![string compare $prog "ssh"] { send_error "\nError: unsupported method: ssh\n" if { $progs == 0 } { return 1 } continue } elseif ![string compare $prog "rsh"] { send_error "\nError: unsupported method: rsh\n" if { $progs == 0 } { return 1 } continue } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } expect { "Connection refused" { catch {close}; catch {wait}; 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 } "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 "$u_prompt" { send -- "$user\r" set uprompt_seen 1 exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send -- "$userpswd\r" } else { send -- "$passwd\r" } exp_continue } "Password incorrect" { send_user "\nError: Check your password for $router\n"; catch {close}; catch {wait}; return 1 } "$prompt" { break; } denied { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } "\r\n" { exp_continue; } } } set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact in_proc set in_proc 1 send "screen 0\r" expect $prompt {} # escape any parens in the prompt, such as "(enable)" regsub -all "\[)(]" $prompt {\\&} reprompt # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] for {set i 0} {$i < $num_commands} { incr i} { send -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "^\[^\n\r]*$reprompt." { exp_continue } -re "^\[^\n\r *]*$reprompt" {} -re "\[\n\r]" { exp_continue } } } if { $do_interact == 1 } { interact return 0 } send "exit\r" expect { "\n" { exp_continue } timeout { catch {close}; catch {wait}; return 0 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 foreach router [lrange $argv $i end] { set router [string tolower $router] send_user "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Figure out prompt. set prompt "Active) > " set autoenable 1 set enable 0 # 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] ""] } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } else { set userpswd [join [find userpassword $router] ""] if { "$userpswd" == "" } { set userpswd $passwd } } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(Username|login| Login):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "\[Pp]assword:" } else { set p_prompt [join [lindex $p_prompt 0] ""] } # Figure out cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet}} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $prompt $cmethod $cyphertype]} { incr exitval continue } if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { send "screen 0\r" expect $prompt {} source $sfile catch {close} } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/alogin.in000644 015615 000000 00000022537 13657102757 015355 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # alogin - Alteon WebOS switch login # # afort@choqolat.org is responsible for this particular mess # (andrew fort) # # default timeout set timeoutdflt 45 # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} @login_top@ # Log into the router. # returns: 0 on success, 1 on failure proc login { router user userpswd passwd prompt cmethod cyphertype } { global spawn_id in_proc do_command do_script global u_prompt p_prompt sshcmd telnetcmd set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog command suffix port if {"$port" == ""} { set retval [ catch {eval spawn [split "$telnetcmd $router"]} reason ] } else { set retval [ catch {eval spawn [split "$telnetcmd $router $port"]} reason ] } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif ![string compare $prog "ssh"] { regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } set retval [ catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason ] if { $retval } { send_user "\nError: $cmd failed: $reason\n" return 1 } } elseif ![string compare $prog "rsh"] { send_error "\nError: unsupported method: rsh\n" if { $progs == 0 } { return 1 } continue; } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } expect { "Connection refused" { catch {close}; catch {wait}; sleep 0.3 catch {expect eof} send_user "\nError: Connection Refused\n"; catch {wait}; return 1 } eof { send_user "\nError: Couldn't login\n"; catch {wait}; return 1 } "Unknown host\r\n" { catch {expect eof} send_user "\nError: Unknown host\n"; catch {wait}; return 1 } "Host is unreachable" { expect eof send_user "\nError: Host Unreachable!\n"; catch {wait}; return 1 } "No address associated with name" { expect eof send_user "\nError: Unknown host\n"; catch {wait}; return 1 } -re "(Host key not found |The authenticity of host .* be established)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -nocase -re "^warning: remote host denied authentication agent forwarding." { exp_continue; } -re "NOTICE:\[^\n\r]* - display now \[^\n\r]*:" { send "no\r" exp_continue } -re "$u_prompt" { send -- "$user\r" set uprompt_seen 1 exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send -- "$userpswd\r" } else { send -- "$passwd\r" } exp_continue } -re "^Confirm seeing above note" { send "y\r" exp_continue } -re "^Select Command Line Interface mode\[^:]*:" { send "ibmnos-cli\r" exp_continue } "Password incorrect" { send_user "\nError: Check your password for $router\n"; catch {close}; catch {wait}; return 1 } -re "$prompt" { break; } -re "Warning: Remote host denied" { exp_continue } denied { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } } set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact do_saveconfig in_proc cmethod set in_proc 1 send "lines 0\r" expect -re $prompt {} regsub -all "\[)(]" $prompt {\\&} reprompt # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] for {set i 0} {$i < $num_commands} { incr i} { send -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "^\[^\n\r]*$reprompt" {} -re "^\[^\n\r ]*>>.*$reprompt" { exp_continue } -re "\[\n\r]+" { exp_continue } -re "Display private keys" { if { "$cmethod" == "ssh" } { send "y\r" } else { send "n\r" } exp_continue } } } if { $do_interact == 1 } { interact return 0 } send "exit\r" expect { -re "^WARNING: There are unsaved configuration changes." { if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "^Confirm Sync to Peer \[^:]*: " { if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "\n" { exp_continue } "\[^\n\r *]*Session terminated" { return 0 } timeout { catch {close}; catch {wait}; return 0 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 foreach router [lrange $argv $i end] { set router [string tolower $router] send_user "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Figure out prompt. set prompt ">> \[^\r\n]*\[#|>] " # alteon only "enables" based on the password used at login time set autoenable 1 set enable 0 # 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] ""] } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } else { set userpswd [join [find userpassword $router] ""] if { "$userpswd" == "" } { set userpswd $passwd } } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(Username|login| Login):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "\[Pp]assword:" } else { set p_prompt [join [lindex $p_prompt 0] ""] } # Figure out cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $prompt $cmethod $cyphertype]} { incr exitval continue } if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { send "lines 0\r" expect -re $prompt {} source $sfile catch {close}; } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/fxlogin.in000644 015615 000000 00000051243 13657102757 015546 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # clogin - Cisco login # # Most options are intuitive for logging into a Cisco router. # The default is to enable (thus -noenable). Some folks have # setup tacacs to have a user login at priv-lvl = 15 (enabled) # so the -autoenable flag was added for this case (don't go through # the process of enabling and the prompt will be the "#" prompt. # The default username password is the same as the vty password. # # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 45 # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} @login_top@ # Log into the router. # returns: 0 on success, 1 on failure, -1 if rsh was used successfully proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } { global command spawn_id in_proc do_command do_script platform passphrase global prompt prompt_match u_prompt p_prompt e_prompt sshcmd telnetcmd set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port if {"$port" == ""} { set retval [catch {eval spawn [split "$telnetcmd $router"]} reason] } else { set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason] } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif [string match "ssh*" $prog] { # ssh to the router & try to login with or without an identfile. regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } if {"$identfile" != ""} { set cmd "$cmd -i $identfile" } set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason] if { $retval } { send_user "\nError: $cmd failed: $reason\n" return 1 } } elseif ![string compare $prog "rsh"] { if { ! $do_command } { if { [llength $cmethod] == 1 } { send_user "\nError: rsh is an invalid method for -x and " send_user "interactive logins\n" } if { $progs == 0 } { return 1 } continue; } # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] set rshfail 0 for {set i 0} {$i < $num_commands && !$rshfail} { incr i} { log_user 0 set retval [catch {spawn rsh $user@$router [lindex $commands $i] } reason] if { $retval } { send_user "\nError: rsh failed: $reason\n" log_user 1; return 1 } send_user "$router# [lindex $commands $i]\n" # rcmd does not get a pager and no prompts, so we just have to # look for failures & lines. expect { "Connection refused" { catch {close}; catch {wait}; send_user "\nError: Connection\ Refused ($prog): $router\n" set rshfail 1 } -re "(Connection closed by|Connection to \[^\n\r]+ closed)" { catch {close}; catch {wait}; send_user "\nError: Connection\ closed ($prog): $router\n" set rshfail 1 } "Host is unreachable" { catch {close}; catch {wait}; send_user "\nError: Host Unreachable:\ $router\n" set rshfail 1 } "No address associated with" { catch {close}; catch {wait}; send_user "\nError: Unknown host\ $router\n" set rshfail 1 } -re "\b+" { exp_continue } -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } timeout { catch {close}; catch {wait}; send_user "\nError: TIMEOUT reached\n" set rshfail 1 } eof { catch {close}; catch {wait}; } } log_user 1 } if { $rshfail } { if { !$progs } { return 1 } else { continue } } # fake the end of the session for rancid. send_user "$router# exit\n" # return rsh "success" return -1 } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } # Here we get a little tricky. There are several possibilities: # the router can ask for a username and passwd and then # talk to the TACACS server to authenticate you, or if the # TACACS server is not working, then it will use the enable # passwd. Or, the router might not have TACACS turned on, # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { -re "^<-+ More -+>\[^\n\r]*" { # ASA will use the pager for long banners send " "; exp_continue } -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 } "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)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -nocase -re "^warning: remote host denied authentication agent forwarding." { exp_continue; } -re "(denied|Sorry)" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } -nocase -re "last login:" { exp_continue } -nocase -re "failed login:" { exp_continue } "Login failed" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } -re "% (Bad passwords|Authentication failed)" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } "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" exp_continue } -re "Press the key \[^\r\n]+\[\r\n]+" { exp_continue } -re "@\[^\r\n]+ $p_prompt" { # ssh pwd prompt sleep 1 send -- "$userpswd\r" exp_continue } -re "Enter passphrase.*: " { # sleep briefly to allow time for stty -echo sleep .3 send -- "$passphrase\r" exp_continue } -re "$u_prompt" { send -- "$user\r" set uprompt_seen 1 exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send -- "$userpswd\r" } else { send -- "$passwd\r" } exp_continue } -re "$prompt" { set prompt_match $expect_out(0,string); break; } "Login invalid" { send_user "\nError: Invalid login: $router\n"; catch {close}; catch {wait}; return 1 } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } } set in_proc 0 return 0 } # Enable proc do_enable { enauser enapasswd } { global in_proc global prompt u_prompt e_prompt enacmd set in_proc 1 send "$enacmd\r" expect { -re "$u_prompt" { send -- "$enauser\r"; exp_continue} -re "$e_prompt" { send -- "$enapasswd\r"; exp_continue} "#" { set prompt "#" } "(enable)" { set prompt "> \\(enable\\) " } "% Invalid input" { send_user "\nError: Unrecognized command, check your enable command\n"; return 1 } -re "(denied|Sorry|Incorrect)" { # % Access denied - from local auth and poss. others send_user "\nError: Check your Enable passwd\n"; return 1 } "% Error in authentication" { send_user "\nError: Check your Enable passwd\n" return 1 } "% Bad passwords" { send_user "\nError: Check your Enable passwd\n" return 1 } } # We set the prompt variable (above) so script files don't need # to know what it is. set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact do_saveconfig in_proc platform set in_proc 1 # leave the prompt alone for fxos #if { [string compare "extreme" "$platform"] } { # # match cisco config mode prompts too, such as router(config-if)#, # # but catalyst does not change in this fashion. # regsub -lineanchor -- {^(.{1,11}).*([#>])$} $prompt {\1} reprompt # regsub -all -- {[\\]$} $reprompt {} reprompt # append reprompt {([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} #} else { set reprompt $prompt #} # this is the only way i see to get rid of more prompts in o/p..grrrrr log_user 0 # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] # the pager can not be turned off on the PIX, so we have to look # for the "More" prompt. the extreme is equally obnoxious in pre-12.3 XOS, # with a global switch in the config. for {set i 0} {$i < $num_commands} { incr i} { send -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "\b+" { exp_continue } -re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)" } -re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)" exp_continue } -re "^\[^-]*--More--\[^\r\n]*\[\r\n]+" { # fxos FTP pager send " " exp_continue } -re "\[^\r\n]*\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } # respond to prompt from "file prompt noisy" config -nocase -re "^display filename \\\[\[^]]*]\\?" { send "\r" exp_continue } -re "\[^\r\n]*Press to cont\[^\r\n]*" { send " " # bloody ^[[2K after " " expect { -re "^\[^\r\n]*\r" {} } exp_continue } -re "^ *--More--\[^\n\r]*" { send " " exp_continue } -re "^<-+ More -+>\[^\n\r]*" { send_user -- "$expect_out(buffer)" send " " exp_continue } } } log_user 1 if { $do_interact == 1 } { interact return 0 } if { [string compare "extreme" "$platform"] } { send -h "exit\r" } else { send -h "quit\r" } expect { -re "^\[^\n\r *]*$reprompt" { # the Cisco CE and Jnx ERX # return to non-enabled mode # on exit in enabled mode. send -h "exit\r" exp_continue; } -re "^\[^\n\r *]*Use .quit. to end" { # the F5 >=11 uses quit send -h "quit\r" exp_continue; } "The system has unsaved changes" { # Force10 SFTOS if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "Would you like to save them now" { # Force10 if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "(Profile|Configuration) changes have occurred.*" { # Cisco CSS if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "Do you wish to save your configuration changes" { if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "\[\n\r]+" { exp_continue } timeout { catch {close}; catch {wait}; return 1 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 set prompt_match "" # if we have dont have a tty, we need some additional terminal settings if [catch {open /dev/tty w} ttyid] { # no tty, ie: cron set spawnopts "-nottycopy" set stty_init "cols 132" set stty_init "rows 4096" } else { catch {close ttyid} reason } foreach router [lrange $argv $i end] { set router [string tolower $router] # attempt at platform switching. set platform "" send_user -- "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Default prompt. set prompt [join [find prompt $router] ""] if { [llength $prompt] == 0 } { set prompt "^(\[^ >]*)(>|#)" } # look for autoenable option in .cloginrc & cmd-line set ae [find autoenable $router] if { "$ae" == "1" || $avautoenable } { set autoenable 1 } else { set autoenable 0 } # look for enable options in .cloginrc & cmd-line if { $avenable == 0 } { set enable 0 } else { set ne [find noenable $router] if { "$ne" == "1" || "$autoenable" == "1" } { set enable 0 } else { set enable 1 } } # Figure out passwords if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 } { send_user -- "\nError: no password for $router in $password_file.\n" continue } if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } { send_user -- "\nError: no enable password for $router in $password_file.\n" continue } if { $do_passwd } { set passwd [join [lindex $pswd 0] ""] } else { set passwd $userpasswd } if { $do_enapasswd } { set enapasswd [join [lindex $pswd 1] ""] } else { set enapasswd $enapasswd } } else { set passwd $userpasswd set enapasswd $enapasswd } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } 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 $ruser } } # Figure out enable command set enacmd [join [find enablecmd $router] ""] if { "$enacmd" == "" } { set enacmd "enable" } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(\[Uu]sername|Login|login|user name|User):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+):" } else { set p_prompt [join [lindex $p_prompt 0] ""] } set e_prompt [find enableprompt $router] if { "$e_prompt" == "" } { set e_prompt "\[Pp]assword:" } else { set e_prompt [join [lindex $e_prompt 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 cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} { incr exitval # if login failed or rsh was unsuccessful, move on to the next device continue } # Figure out the prompt. if { [regexp -- "(#| \\(enable\\))" $prompt_match junk] == 1 } { set enable 0 } if { $enable } { if {[do_enable $enauser $enapasswd]} { if { $do_command || $do_script } { incr exitval catch {close}; catch {wait}; continue } } } # we would normally try to find the full prompt for more precise matching # as we run commands, but the fx has weird properties. first, it has just # ">" as its prompt. two, when we connects to the fxos side, the prompt # changes completely. so, until it matures, just use a wisely chose match. # send "\r" #regsub -all {^(\^*)(.*)} $prompt {\2} reprompt #expect { # -re "\[\r\n]+" { exp_continue; } # -re "^(.+\[:.])1 ($reprompt)" { # stoopid extreme cmd-line numbers and # # prompt based on state of config changes, # # which may have an * at the beginning. # set junk $expect_out(1,string) # regsub -all "^\\\* " $expect_out(1,string) {} junk # regsub -all "\[\]\[\(\)]" $junk {\\&} junk; # set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)"; # set platform "extreme" # } # -re "^.+$reprompt" { set junk $expect_out(0,string); # regsub -all "\[\]\[\(\)+]" $junk {\\&} prompt; # } #} # no pager on fxos layer and entering the unsupported commands is ugly #if { $do_command || $do_script } { # if { [string compare "extreme" "$platform"] } { # # If the prompt is (enable), then we are on a switch and the # # command is "set length 0"; otherwise its "terminal length 0". # if [regexp -- ".*> .*enable" "$prompt"] { # send "set length 0\r" # expect -re $prompt {} # send "set width 132\r" # expect -re $prompt {} # send "set logging session disable\r" # } else { # send "terminal length 0\r" # expect -re $prompt {} # send "terminal width 132\r" # } # expect -re $prompt {} # } else { # send "disable clipaging\r" # expect -re $prompt {} # } #} if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { source $sfile catch {close}; } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/arancid.in000644 015615 000000 00000025265 13534014705 015473 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # RANCID - Really Awesome New Cisco confIg Differ # # arancid - Alteon WebOS plugin for rancid # # usage: arancid [-dltCV] [-f filename | hostname] # use Getopt::Std; getopts('dflt:CV'); if ($opt_V) { print "@PACKAGE@ @VERSION@\n"; exit(0); } $log = $opt_l; $debug = $opt_d; $file = $opt_f; $host = $ARGV[0]; $clean_run = 0; $found_end = 0; $prompt = "#"; $timeo = 90; # alogin timeout in seconds my(@commandtable, %commands, @commands);# command lists my($aclsort) = ("ipsort"); # ACL sorting mode my($filter_commstr); # SNMP community string filtering my($filter_osc); # oscillating data filtering mode 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)) && scalar(%history)) { print eval "$command \%history"; undef %history; } if (($new_hist_tag) && ($new_command) && ($command_string)) { if ($history{$command_string}) { $history{$command_string} = "$history{$command_string}@string"; } else { $history{$command_string} = "@string"; } } elsif (($new_hist_tag) && ($new_command)) { $history{++$#history} = "@string"; } else { print "@string"; } $hist_tag = $new_hist_tag; $command = $new_command; 1; } sub numerically { $a <=> $b; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort numerically keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort values %lines) { $sorted_lines[$i] = $key; $i++; } @sorted_lines; } # This is a numerical sort routine (ascending). sub numsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $num (sort {$a <=> $b} keys %lines) { $sorted_lines[$i] = $lines{$num}; $i++; } @sorted_lines; } # This is a sort routine that will sort on the # ip address when the ip address is anywhere in # the strings. sub ipsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $addr (sort sortbyipaddr keys %lines) { $sorted_lines[$i] = $lines{$addr}; $i++; } @sorted_lines; } # 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])); } sub sortbyipaddr { &ipaddrval($a) <=> &ipaddrval($b); } # This routine parses "/info/sys" (cf. show version) sub ShowVersion { print STDERR " In ShowVersion: $_" if ($debug); while () { tr/\015//d; last if (/^>>.*$prompt/); next if(/^(\s*|\s*$cmd\s*)$/); /^(ACEdirector.*|ACEswitch.*|Alteon.*)/i && ProcessHistory("COMMENTS","keysort","A1", "\/\*Model: $1\n") && next; /^Software Version\s+(.*?)\s\((.*)\)/i && ProcessHistory("COMMENTS","keysort","B1", "\/\*Image: Software: $1 ($2)\n") && next; /^Hardware Part No:\s+(.*?)\s+/i && ProcessHistory("COMMENTS","keysort","A2", "\/\*Hardware part no: $1\n") && next; /^MAC address:\s+([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})/i && ProcessHistory("COMMENTS","keysort","C1", "\/\*Base MAC address: $1\n") && next; } return(0); } # This routine processes a "/cfg/dump" sub WriteTerm { print STDERR " In WriteTerm: $_" if ($debug); # eat the header line #$junk = ; # now just copy it verbatim to the history file while () { tr/\015//d; last if(/^>>.*$prompt/); chop; if (/(rcomm|wcomm|t1com|t2com)(\s+)(.*)/ && $filter_commstr) { ProcessHistory("","","","\/\*\t$1$2\"\"\n") && next; } /^(\s+(.{1,3}pw|pswd) )\S+/ && ProcessHistory("","","","\/\*$1\n") && next; next if (/^\/\* Configuration dump taken/i); next if (/^\/\* Version.*Base MAC.*/i); next if (/^ *esecret /); if (/^\/?script end/) { $found_end = 1; ProcessHistory("","","","$_\n"); return(1); } ProcessHistory("","","","$_\n"); } return(0); } # Main @commandtable = ( {'/info/sys/dump' => 'ShowVersion'}, {'/cfg/dump' => '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); $commandcnt = scalar(keys %commands); $commandstr = join(";",@commands); $cmds_regexp = join("|", map quotemeta($_), @commands); if (length($host) == 0) { if ($file) { print(STDERR "Too few arguments: file name required\n"); exit(1); } else { print(STDERR "Too few arguments: host name required\n"); exit(1); } } if ($opt_C) { print "alogin -t $timeo -c\'$commandstr\' $host\n"; exit(0); } open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n"; select(OUTPUT); # make OUTPUT unbuffered if debugging if ($debug) { $| = 1; } if ($file) { print(STDERR "opening file $host\n") if ($debug || $log); open(INPUT,"<$host") || die "open failed for $host: $!\n"; } else { print(STDERR "executing alogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log); system "alogin -t $timeo -c \"$commandstr\" $host $host.raw 2>&1" || die "alogin failed for $host: $!\n"; open(INPUT, "< $host.raw") || die "alogin failed for $host: $!\n"; } # 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 oscillating data filtering mode if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) { $filter_osc = 0; } else { $filter_osc = 1; } # determine password filtering mode if ($ENV{"FILTER_PWDS"} =~ /no/i) { $filter_pwds = 0; } elsif ($ENV{"FILTER_PWDS"} =~ /all/i) { $filter_pwds = 2; } else { $filter_pwds = 1; } ProcessHistory("","","","\/\*RANCID-CONTENT-TYPE: alteon\n\/\*\n"); ProcessHistory("COMMENTS","keysort","B0","\/\*\n"); ProcessHistory("COMMENTS","keysort","F0","\/\*\n"); TOP: while() { tr/\015//d; if (/^>>.*$prompt exit/) { $clean_run = 1; last; } while (/>>.*$prompt\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (!defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } print STDOUT "Done $logincmd: $_\n" if ($log); # Flush History ProcessHistory("","","",""); # Cleanup close(INPUT); close(OUTPUT); unlink("$host.raw") if (! $debug); # check for completeness if (scalar(%commands) || !$clean_run || !$found_end) { if (scalar(keys %commands) eq $commandcnt) { printf(STDERR "$host: missed cmd(s): all commands\n"); } elsif (scalar(%commands)) { my($count, $i) = 0; for ($i = 0; $i < $#commands; $i++) { if ($commands{$commands[$i]}) { if (!$count) { printf(STDERR "$host: missed cmd(s): %s", $commands[$i]); } else { printf(STDERR ", %s", $commands[$i]); } $count++; } } if ($count) { printf(STDERR "\n"); } } if (!$clean_run || !$found_end) { print(STDERR "$host: End of run not found\n"); if ($debug) { print(STDERR "$host: clean_run is false\n") if (!$clean_run); print(STDERR "$host: found_end is false\n") if (!$found_end); } system("/usr/bin/tail -1 $host.new"); } unlink "$host.new" if (! $debug); } rancid-3.13/bin/ulogin.in000644 015615 000000 00000035722 13657102757 015401 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # ulogin - unix login; EdgeRouter, ... # # Most options are intuitive for logging into a Cisco router. # The default is to enable (thus -noenable). Some folks have # setup tacacs to have a user login at priv-lvl = 15 (enabled) # so the -autoenable flag was added for this case (don't go through # the process of enabling and the prompt will be the "#" prompt. # The default username password is the same as the vty password. # # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 30 # Some CLIs having problems if we write too fast set send_human {.2 .1 .4 .2 1} @login_top@ # Log into the router. # returns: 0 on success, 1 on failure proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } { global spawn_id in_proc do_command do_script passphrase global prompt u_prompt p_prompt e_prompt sshcmd telnetcmd set in_proc 1 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 regexp {(telnet|ssh)(:([^[:space:]]+))*} $prog command suffix junk port if [string match "telnet*" $prog] { if {"$port" == ""} { if { $do_command || $do_script } { set retval [ catch {eval spawn [split "hpuifilter -- $telnetcmd $router"]} reason ] } else { set retval [ catch {eval spawn [split "$telnetcmd $router"]} reason ] } } else { if { $do_command || $do_script } { set retval [ catch {eval spawn [split "hpuifilter -- $telnetcmd $router $port"]} reason ] } else { set retval [ catch {eval spawn [split "$telnetcmd $router $port"]} reason ] } } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif [string match "ssh*" $prog] { # ssh to the router & try to login with or without an identfile. regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } if {"$identfile" != ""} { set cmd "$cmd -i $identfile" } if { $do_command || $do_script } { set retval [ catch {eval spawn hpuifilter -- [split "$cmd -x -l $user $router" { }]} reason ] } else { set retval [ catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason ] } if { $retval } { send_user "\nError: $cmd failed: $reason\n" return 1 } } elseif ![string compare $prog "rsh"] { send_error "\nError: unsupported method: rsh\n" if { $progs == 0 } { return 1 } continue; } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } # Here we get a little tricky. There are several possibilities: # the router can ask for a username and passwd and then # talk to the TACACS server to authenticate you, or if the # TACACS server is not working, then it will use the enable # passwd. Or, the router might not have TACACS turned on, # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { "Press any key to continue" { send " " exp_continue } "Enter switch number to connect to or :" { send "\r" exp_continue } -re "(Connection refused|Secure connection \[^\n\r]+ refused|Connection closed by)" { catch {close}; catch {wait}; if !$progs { send_user "\nError: Connection Refused ($prog)\n"; return 1 } } "Host is unreachable" { catch {close}; catch {wait}; send_user "\nError: Host Unreachable!\n"; wait; return 1 } "No address associated with name" { catch {close}; catch {wait}; send_user "\nError: Unknown host\n"; wait; return 1 } -re "(Host key not found |The authenticity of host .* be established)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -nocase -re "^warning: remote host denied authentication agent forwarding." { exp_continue; } -nocase -re "last login:" { exp_continue } -nocase -re "failed login:" { exp_continue } 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 } -re "Enter passphrase.*: " { # sleep briefly to allow time for stty -echo sleep 1 send -- "$passphrase\r" exp_continue } -nocase -re "last login:" { exp_continue; } -re "$u_prompt" { send -- "$user\r" expect { eof { send_user "\nError: Couldn't login\n"; wait; return 1 } "Login invalid" { send_user "\nError: Invalid login\n"; catch {close}; catch {wait}; return 1 } -re "$p_prompt" { send -- "$userpswd\r" } -re "$prompt" { set in_proc 0; return 0 } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "$p_prompt" { if ![string compare $prog "ssh"] { send -- "$userpswd\r" } else { send -- "$passwd\r" } expect { eof { send_user "\nError: Couldn't login\n"; wait; return 1 } -re "$e_prompt" { send -- "$enapasswd\r" } -re "$prompt" { set in_proc 0; return 0 } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } -re "$prompt" { break; } denied { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 } } } set in_proc 0 return 0 } # Enable proc do_enable { enauser enapasswd } { global prompt in_proc global u_prompt e_prompt set in_proc 1 send "enable\r" expect { -re "$u_prompt" { send -- "$enauser\r"; exp_continue} -re "$e_prompt" { send -- "$enapasswd\r"; exp_continue} "#" { set prompt "#" } "(enable)" { set prompt "> (enable) " } denied { send_user "\nError: Check your Enable passwd\n"; return 1} "% Bad passwords" { send_user "\nError: Check your Enable passwd\n" return 1 } } # We set the prompt variable (above) so script files don't need # to know what it is. set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact do_saveconfig in_proc set in_proc 1 # Turn off the pager and escape regex meta characters in the $prompt send "\r" # match cisco config mode prompts too, such as router(config-if)# regsub -all {^(.{1,11}).*([#$] ?)$} $prompt {\1} reprompt # escape any parens in the prompt, such as "(enable)" regsub -all {[)(]} $reprompt {\\&} reprompt append reprompt {([^#$\r\n]+)?[#$](\\([^)\\r\\n]+\\))?} expect { -re $reprompt {} -re "\[\n\r]+" { exp_continue } } # this is the only way i see to get rid of more prompts in o/p..grrrrr log_user 0 # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] # if the pager can not be turned off, we have to look for the "More" # prompt. for {set i 0} {$i < $num_commands} { incr i} { 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)"} } -re "\[\n\r]+" { catch {send_user -- "$expect_out(buffer)"} exp_continue } -re "^<-+ More -+>\[^\n\r]*" { catch {send " "} exp_continue } -re "^-+ MORE -+\[^\n\r]*" { catch {send " "} exp_continue } # 3 flavours of the more prompt, -- first -More-, then --More-- (for # cisco/riverhead AGM), then with more dashes. -re "^-More-\[^\n\r-]*" { catch {send " "} exp_continue } -re "^--More--\[^\n\r-]*" { catch {send " "} exp_continue } -re "^---+More---+\[^\n\r]*" { catch {send " "} exp_continue } -re "\b+" { exp_continue } } } log_user 1 if { $do_interact == 1 } { interact return 0 } send -h "logout\r" expect { "Do you want to log out" { catch {send "y\r"} exp_continue } -re "\[\r\n]+" { exp_continue } -re "^.+>" { catch {send -h "exit\r"} exp_continue } timeout { catch {close}; catch {wait}; return 0 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 # if we have dont have a tty, we need some additional terminal settings if [catch {open /dev/tty w} ttyid] { # no tty, ie: cron set spawnopts "-nottycopy" set stty_init "cols 132" } else { catch {close ttyid} reason } foreach router [lrange $argv $i end] { set router [string tolower $router] send_user "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Default prompt. set prompt [join [find prompt $router] ""] if { [llength $prompt] == 0 } { set prompt "\[^ ]\[$#] ?" } # look for autoenable option in .cloginrc & cmd-line set ae [find autoenable $router] if { "$ae" == "1" || $avautoenable } { set autoenable 1 } else { set autoenable 0 } # look for enable options in .cloginrc & cmd-line if { $avenable == 0 } { set enable 0 } else { set ne [find noenable $router] if { "$ne" == "1" || "$autoenable" == "1" } { set enable 0 } else { set enable 1 } } # Figure out passwords if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 } { send_user -- "\nError: no password for $router in $password_file.\n" continue } if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } { send_user -- "\nError: no enable password for $router in $password_file.\n" continue } if { $do_passwd } { set passwd [join [lindex $pswd 0] ""] } else { set passwd $userpasswd } if { $do_enapasswd } { set enapasswd [join [lindex $pswd 1] ""] } else { set enapasswd $enapasswd } } else { set passwd $userpasswd set enapasswd $enapasswd } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } 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 $ruser } } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(\[Uu]sername|\[Ll]ogin|user name|Login Name):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "(\[Pp]assword|passwd):" } else { set p_prompt [join [lindex $p_prompt 0] ""] } set e_prompt [find enableprompt $router] if { "$e_prompt" == "" } { set e_prompt "\[Pp]assword:" } else { set e_prompt [join [lindex $e_prompt 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 cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Adjust our path to find hpuifilter set hpf_path "" regexp {(.*)/[^/]+} $argv0 junk hpf_path if { "$hpf_path" != "" && "$hpf_path" != "." } { append env(PATH) ":$hpf_path" } # Login to the router if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} { incr exitval continue } if { $enable } { if {[do_enable $enauser $enapasswd]} { if { $do_command || $do_script } { incr exitval catch {close}; catch {wait}; continue } } } # we are logged in, now figure out the full prompt send "\r" expect { -re "\[\r\n]+" { exp_continue; } -re "^.+$prompt" { set prompt $expect_out(0,string); } } if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { source $sfile catch {close}; } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/nrancid.in000644 015615 000000 00000027421 13534014763 015510 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # Amazingly hacked version of Hank's rancid - this one tries to # deal with Netscreen firewalls # # Original Netscreen hacks implemented by Stephen Gill [gillsr@yahoo.com] # # RANCID - Really Awesome New Cisco confIg Differ # # usage: nrancid [-dltCV] [-f filename | hostname] # use Getopt::Std; getopts('dflt:CV'); if ($opt_V) { print "@PACKAGE@ @VERSION@\n"; exit(0); } $log = $opt_l; $debug = $opt_d; $file = $opt_f; $host = $ARGV[0]; $found_end = 0; $timeo = 90; # nlogin timeout in seconds my(@commandtable, %commands, @commands);# command lists my($aclsort) = ("ipsort"); # ACL sorting mode my($filter_commstr); # SNMP community string filtering my($filter_osc); # oscillating data filtering mode 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)) && scalar(%history)) { print eval "$command \%history"; undef %history; } if (($new_hist_tag) && ($new_command) && ($command_string)) { if ($history{$command_string}) { $history{$command_string} = "$history{$command_string}@string"; } else { $history{$command_string} = "@string"; } } elsif (($new_hist_tag) && ($new_command)) { $history{++$#history} = "@string"; } else { print "@string"; } $hist_tag = $new_hist_tag; $command = $new_command; 1; } sub numerically { $a <=> $b; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort numerically keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort values %lines) { $sorted_lines[$i] = $key; $i++; } @sorted_lines; } # This is a numerical sort routine (ascending). sub numsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $num (sort {$a <=> $b} keys %lines) { $sorted_lines[$i] = $lines{$num}; $i++; } @sorted_lines; } # This is a sort routine that will sort on the # ip address when the ip address is anywhere in # the strings. sub ipsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $addr (sort sortbyipaddr keys %lines) { $sorted_lines[$i] = $lines{$addr}; $i++; } @sorted_lines; } # 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])); } sub sortbyipaddr { &ipaddrval($a) <=> &ipaddrval($b); } # This routine parses "get system" sub GetSystem { print STDERR " In GetSystem: $_" if ($debug); while () { tr/\015//d; next if /^\s*$/; last if(/$prompt/); # throw away the pager prompts s/^--- more ---[ \b]*//g; /^Serial Number: (\S+), Control Number: [0-9a-f]+$/ && ProcessHistory("SYSTEM","","", "#SN: $1\n") && next; /^Product Name: (\S+)$/ && ProcessHistory("SYSTEM","","", "#Product: $1\n") && next; /^Hardware Version: (\S+), / && ProcessHistory("SYSTEM","","", "#HW: $1\n") && next; /^Software Version: (\S+), Type: (\S+)$/ && ProcessHistory("SYSTEM","","", "#Netscreen Type: $2\n#Software Version: $1\n") && next; /^Image: (\S+), / && ProcessHistory("SYSTEM","","", "#Image: $1\n") && next; /^Feature: (\S+)$/ && ProcessHistory("SYSTEM","","", "#Feature: $1\n") && next; /^File Name: (\S+), Checksum: (\S+)$/ && ProcessHistory("SYSTEM","","", "#File Name: $1, Checksum: $2\n") && next; /^, Total Memory: (\S+)$/ && ProcessHistory("SYSTEM","","", "#Memory: $1\n") && next; } ProcessHistory("SYSTEM","","","#\n"); return(0); } sub GetFile { print STDERR " In GetFile: $_" if ($debug); while () { last if(/$prompt/); } ProcessHistory("FILE","","","#\n"); return(0); } sub GetConf { print STDERR " In GetConf: $_" if ($debug); while () { tr/\015//d; next if /^\s*$/; next if /^Total Config.+$/i; last if(/$prompt/); # throw away the pager prompts s/^--- more ---[ \b]*//g; if (/^set admin name "(\S+)"$/ && $filter_pwds >= 1) { ProcessHistory("ADMIN","","","#set admin name \n"); next; } if (/^set admin password (\S+)$/ && $filter_pwds >= 1) { ProcessHistory("ADMIN","","","#set admin password \n"); next; } if (/^set admin user (\S+) password (\S+) privilege (\S+)$/ && $filter_pwds >= 1) { ProcessHistory("ADMIN","","", "#set admin user $1 password privilege $3\n"); next; } if (/^set auth-server (\S+) radius secret / && $filter_pwds >= 1 ) { ProcessHistory("ADMIN","","", "#set auth-server $1 radius secret \n"); next; } if (/^set ike gateway (.*) username (\S+)(.*) password (\S+)(.*)$/ && $filter_pwds >= 1) { ProcessHistory("ADMIN","","", "#set ike gateway $1 username $3 password $5\n"); next; } if (/^set ike gateway (.*) preshare "(\S+)"(.*)$/ && $filter_pwds >= 1) { ProcessHistory("ADMIN","","", "#set ike gateway $1 preshare $3\n"); next; } if (/^set auth-server (.*) secret "(\S+)"(.*)$/ && $filter_pwds >= 1) { ProcessHistory("ADMIN","","", "#set auth-server $1 secret $3\n"); next; } ProcessHistory("","","","$_"); } $found_end=1; return(1); } # Main @commandtable = ( {'get system' => 'GetSystem'}, {'get conf' => 'GetConf'} ); # 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); $commandcnt = scalar(keys %commands); $commandstr=join(";",@commands); $cmds_regexp = join("|", map quotemeta($_), @commands); if (length($host) == 0) { if ($file) { print(STDERR "Too few arguments: file name required\n"); exit(1); } else { print(STDERR "Too few arguments: host name required\n"); exit(1); } } if ($opt_C) { print "nlogin -t $timeo -c\'$commandstr\' $host\n"; exit(0); } open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n"; select(OUTPUT); # make OUTPUT unbuffered if debugging if ($debug) { $| = 1; } if ($file) { print(STDERR "opening file $host\n") if ($debug || $log); open(INPUT,"<$host") || die "open failed for $host: $!\n"; } else { print(STDERR "executing nlogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log); system "nlogin -t $timeo -c \"$commandstr\" $host $host.raw 2>&1" || die "nlogin failed for $host: $!\n"; open(INPUT, "< $host.raw") || die "nlogin failed for $host: $!\n"; } # 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 oscillating data filtering mode if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) { $filter_osc = 0; } else { $filter_osc = 1; } # determine password filtering mode if ($ENV{"FILTER_PWDS"} =~ /no/i) { $filter_pwds = 0; } elsif ($ENV{"FILTER_PWDS"} =~ /all/i) { $filter_pwds = 2; } else { $filter_pwds = 1; } ProcessHistory("","","","#RANCID-CONTENT-TYPE: netscreen\n#\n"); TOP: while() { tr/\015//d; if (/^Error:/) { print STDOUT ("$host nlogin error: $_"); print STDERR ("$host nlogin error: $_") if ($debug); last; } while (/>\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^>]+->)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (!defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; last TOP; } $rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { last TOP; } } } print STDOUT "Done $logincmd: $_\n" if ($log); # Flush History ProcessHistory("","","",""); # Cleanup close(INPUT); close(OUTPUT); unlink("$host.raw") if (! $debug); # check for completeness if (scalar(%commands) || !$found_end) { if (scalar(keys %commands) eq $commandcnt) { printf(STDERR "$host: missed cmd(s): all commands\n"); } elsif (scalar(%commands)) { my($count, $i) = 0; for ($i = 0; $i < $#commands; $i++) { if ($commands{$commands[$i]}) { if (!$count) { printf(STDERR "$host: missed cmd(s): %s", $commands[$i]); } else { printf(STDERR ", %s", $commands[$i]); } $count++; } } if ($count) { printf(STDERR "\n"); } } if (!$found_end) { print(STDERR "$host: End of run not found\n"); if ($debug) { print(STDERR "$host: found_end is false\n") if (!$found_end); } system("/usr/bin/tail -1 $host.new"); } unlink "$host.new" if (! $debug); } rancid-3.13/bin/control_rancid.in000644 015615 000000 00000050554 13713052202 017062 0ustar00heaswheel000000 000000 #! /bin/sh ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # control_rancid $GROUP # # print a usage message to stderr pr_usage() { echo "usage: $0 [-V] [-c commit_msg] [-f group_config_file] [-r device_name] [-m mail rcpt] group" >&2; } # command-line options # -V print version string # -c # -f # -m # -r alt_mailrcpt=0 alt_commitmsg=0 if [ $# -ge 1 ] ; then while [ 1 ] ; do case $1 in -V) echo "@PACKAGE@ @VERSION@" exit 0 ;; -c) shift # next arg is the commit message alt_commitmsg=1 if [ -z "$commitmsg" ] ; then commitmsg="$1" else commitmsg="$commitmsg,$1" fi shift ;; -f) shift # next arg is the alternate config file name ENVFILE="$1" if [ -z $ENVFILE ]; then pr_usage exit 1 fi shift ;; -m) shift # next arg is the mail recipient alt_mailrcpt=1 if [ -z "$mailrcpt" ] ; then mailrcpt="$1" else mailrcpt="$mailrcpt,$1" fi shift ;; -r) shift # next arg is the device name device="$1" shift ;; --) shift; break; ;; -h) pr_usage exit 0 ;; -*) echo "unknown option: $1" >&2 pr_usage exit 1 ;; *) break; ;; esac done fi # Must specify a group on which to run rancid if [ $# -lt 1 ] ; then echo 'must specify group'; exit 1 else GROUP=$1 fi TMP=${TMPDIR:=/tmp}/rancid.$GROUP.$$ if [ -z "$ENVFILE" ] ; then ENVFILE="@sysconfdir@/rancid.conf" fi if [ -f "$ENVFILE" ] ; then . $ENVFILE fi trap 'rm -fr $TMP;' 1 2 15 DIR=$BASEDIR/$GROUP # disable noclobber unset noclobber > /dev/null 2>&1 # SENDMAIL location SENDMAIL=${SENDMAIL:=sendmail}; # default MAILHEADERS set | grep MAILHEADERS= > /dev/null 2>&1 if [ $? -ne 0 ] ; then MAILHEADERS="Precedence: bulk\nAuto-submitted: auto-generated\nX-Auto-Response-Suppress: All"; export MAILHEADERS fi # Bail if we do not have the necessary info to run if [ ! -d $DIR ] ; then adminmailrcpt=${adminmailrcpt:-"@ADMINMAILPLUS@${GROUP}${MAILDOMAIN}"}; echo "$DIR does not exist." echo "Run bin/rancid-cvs $GROUP to make all of the needed directories." ( echo "To: $adminmailrcpt" echo "Subject: no $GROUP directory" echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/) { I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN = substr(LN,I+2,length(LN)-I-1);}print L LN;}' echo "" echo "$DIR does not exist." echo "Run bin/rancid-cvs $GROUP to make all of the needed directories." ) | $SENDMAIL -t $MAILOPTS exit 1 fi cd $DIR if [ -f "rancid.conf" ] ; then . ./rancid.conf fi # RCS system RCSSYS=${RCSSYS:=cvs}; if [ $RCSSYS != "cvs" -a $RCSSYS != "svn" -a $RCSSYS != "git" ] ; then echo "$RCSSYS is not a valid value for RCSSYS. See rancid.conf(5)." >&2 exit 1 fi # the recipient(s) of diffs & mail options mailrcpt=${mailrcpt:-"@MAILPLUS@${GROUP}${MAILDOMAIN}"}; export mailrcpt adminmailrcpt=${adminmailrcpt:-"@ADMINMAILPLUS@${GROUP}${MAILDOMAIN}"}; export adminmailrcpt if [ -z "$commitmsg" ] ; then commitmsg="updates" if [ $alt_mailrcpt -eq 1 ] ; then commitmsg="$commitmsg - courtesy of $mailrcpt" fi export commitmsg fi # Number of things par should run in parallel. PAR_COUNT=${PAR_COUNT:-5} # Number of times failed collections should be retried. Minimum 0. MAX_ROUNDS=${MAX_ROUNDS:-4} if [ $MAX_ROUNDS -lt 0 ] ; then echo "Error: MAX_ROUNDS must be at least 0 or greater." >&2 MAX_ROUNDS=1 fi # Check for missing configs dir. if [ ! -d $DIR/configs ] ; then mkdir $DIR/configs if [ $? -ne 0 ] ; then echo "Error: could not create missing configs directory" >&2 exit fi case $RCSSYS in cvs | svn) $RCSSYS add configs ;; esac fi # create a .cvsignore/.gitignore case $RCSSYS in git ) if [ ! -f .gitignore ] ; then touch .gitignore git add .gitignore else git ls-files .gitignore --error-unmatch > /dev/null 2>&1 if [ $? -ne 0 ] ; then git add .gitignore fi fi rm -rf .gitignore cat > .gitignore <> .gitignore fi ;; cvs | svn ) if [ ! -f .cvsignore ] ; then touch .cvsignore $RCSSYS add .cvsignore fi rm -rf .cvsignore cat >.cvsignore <> .cvsignore fi if [ ! -f configs/.cvsignore ] ; then touch configs/.cvsignore $RCSSYS add configs/.cvsignore fi rm -rf configs/.cvsignore cat > configs/.cvsignore <> configs/.cvsignore fi if [ $RCSSYS = svn ] ; then svn propset svn:ignore -F .cvsignore . svn propset svn:ignore -F configs/.cvsignore configs svn update . svn commit -m 'set svn:ignores' . fi ;; esac # if there is a rancid.conf, check if it needs to be added to the RCS if [ -f rancid.conf ] ; then case $RCSSYS in cvs ) cvs log -rHEAD rancid.conf > /dev/null 2>&1 if [ $? -eq 0 ] ; then LN=1; else LN=0; fi ;; svn ) LN=`(svn ls rancid.conf | wc -l) 2>/dev/null` ;; git ) git ls-files rancid.conf --error-unmatch > /dev/null 2>&1 if [ $? -eq 0 ] ; then LN=1; else LN=0; fi ;; esac if [ $LN -eq 0 ] ; then $RCSSYS add rancid.conf fi fi # do RCS update of router.db in case anyone has fiddled. case $RCSSYS in git ) # git doesnt make this easy. XXX #git fetch > $TMP 2>&1 #git checkout FETCH_HEAD -- router.db #grep "^C" $TMP > /dev/null # XXX right for git? touch $TMP ;; cvs | svn ) $RCSSYS update router.db > $TMP 2>&1 grep "^C" $TMP > /dev/null if [ $? -eq 0 ] ; then echo "There were $RCSSYS conflicts during update." echo "" cat $TMP rm -f $TMP exit 1 fi ;; esac rm -f $TMP if [ ! -f $DIR/router.db ] ; then echo "$DIR/router.db does not exist." ( echo "To: $adminmailrcpt" echo "Subject: no $GROUP/router.db file" echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/) { I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN = substr(LN,I+2,length(LN)-I-1);}print L LN;}' echo "" echo "$DIR/router.db does not exist." ) | $SENDMAIL -t $MAILOPTS exit 1; fi # IQ test @PERLV@ -F\; -ane '{if ($F[0] !~ /^\s*#/ && $F[0] !~ /^\s*$/ && $#F < 2 && $F[0] =~ /:/) {print "WARNING: Have you forgotten to update the FS in router.db?\n"; exit;}}' router.db # generate the list of all, up, & down routers cd $DIR trap 'rm -fr routers.db routers.all.new routers.down.new routers.up.new \ routers.mail routers.added routers.deleted $TMP;' 1 2 15 @PERLV@ -ne '{s/^\s*//; s/\s*$//; s/\s*;\s*/;/g; next if (/^(#|;|$)/); @F = split /\;/; $F[2] =~ s/\s*\$//; $F[0] =~ tr@A-Z@a-z@; if (defined($A{$F[0]})) { printf STDERR "WARNING: %s appears in routers.db multiple times\n", $F[0]; next; } $A{$F[0]} = "$F[1];$F[2]";} END { foreach $k (sort((keys(%A)))) {print "$k;$A{$k}\n";} }' \ router.db > routers.db cut -d\; -f1,2 routers.db > routers.all.new if [ ! -f routers.all ] ; then touch routers.all; fi @DIFF_CMD@ routers.all routers.all.new > /dev/null 2>&1; RALL=$? @PERLV@ -F\; -ane '{$F[2] =~ s/\s*\$//; ($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_CMD@ routers.down routers.down.new > /dev/null 2>&1; RDOWN=$? @PERLV@ -F\; -ane '{$F[2] =~ s/\s*\$//; ($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_CMD@ routers.up routers.up.new > /dev/null 2>&1; RUP=$? if [ $RALL -ne 0 -o $RDOWN -ne 0 -o $RUP -ne 0 ] ; then ( if [ $RUP -ne 0 ] ; then if [ ! -s routers.up ] ; then echo Routers changed to up: sed -e 's/^/ /' routers.up.new echo else WCUP=`comm -13 routers.up routers.up.new | wc -l | \ sed -e 's/^ *\([^ ]*\)/\1/'` if [ $WCUP -gt 0 ] ; then echo Routers changed to up: comm -13 routers.up routers.up.new | sed -e 's/^/ /' echo fi fi fi if [ $RDOWN -ne 0 ] ; then if [ ! -s routers.down ] ; then echo Routers changed to down: sed -e 's/^/ /' routers.down.new echo else WCDOWN=`comm -13 routers.down routers.down.new | wc -l | \ sed -e 's/^ *\([^ ]*\)/\1/'` if [ $WCDOWN -eq 1 ] ; then echo Routers changed to down: comm -13 routers.down routers.down.new | \ sed -e 's/^/ /' echo fi fi fi if [ $RALL -eq 1 ] ; then comm -13 routers.all routers.all.new | sed -e 's/^/ /' \ > routers.added comm -23 routers.all routers.all.new | sed -e 's/^/ /' \ > routers.deleted WCADDED=`wc -l routers.added | sed -e 's/^ *\([^ ]*\) .*$/\1/'` WCDELETED=`wc -l routers.deleted | sed -e 's/^ *\([^ ]*\) .*$/\1/'` if [ $WCADDED -gt 0 ] ; then echo Added routers: cat routers.added echo fi if [ $WCDELETED -gt 0 ] ; then echo Deleted routers: cat routers.deleted echo fi rm -f routers.added routers.deleted fi ) > routers.mail if [ -s routers.mail ] ; then ( echo "To: $adminmailrcpt" echo "Subject: changes in $GROUP routers" echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/) { I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN = substr(LN,I+2,length(LN)-I-1);}print L LN;}' echo "" cat routers.mail ) | $SENDMAIL -t $MAILOPTS fi rm -f routers.mail cd $DIR/configs # Add new routers to the CVS structure. for router in `comm -13 $DIR/routers.up $DIR/routers.up.new` do OFS=$IFS IFS=';' set $router IFS=$OFS router=$1 touch $router case $RCSSYS in cvs ) cvs add -ko $router ;; svn | git ) $RCSSYS add $router ;; esac $RCSSYS commit -m 'new router' $router echo "Added $router" done echo cd $DIR fi mv -f routers.all.new routers.all if [ $? -ne 0 ] ; then echo "Error: could not rename routers.all.new" >&2 fi mv -f routers.down.new routers.down if [ $? -ne 0 ] ; then echo "Error: could not rename routers.down.new" >&2 fi mv -f routers.up.new routers.up if [ $? -ne 0 ] ; then echo "Error: could not rename routers.up.new" >&2 fi rm -f routers.db trap 'rm -fr $TMP;' 1 2 15 cd $DIR/configs # check for 'up' routers missing in RCS. no idea how this happens to some folks for router in `cut -d\; -f1 ../routers.up` ; do case $RCSSYS in cvs ) cvs status $router | grep -i 'status: unknown' > /dev/null 2>&1 if [ $? -eq 0 ] ; then touch $router cvs add -ko $router cvs commit -m 'new router' $router echo "$RCSSYS added missing router $router" fi ;; svn ) if [ ! -f $router ] ; then touch $router fi svn status $router | grep '^?' > /dev/null 2>&1 if [ $? -eq 0 ] ; then svn add $router svn commit -m 'new router' $router echo "$RCSSYS added missing router $router" fi ;; git ) if [ ! -f $router ] ; then touch $router fi git status --porcelain $router | grep '^?' > /dev/null 2>&1 if [ $? -eq 0 ] ; then git add $router git commit -m 'new router' $router echo "$RCSSYS added missing router $router" fi ;; esac done echo # delete configs from RCS for routers not listed in routers.up. for router in `find . \( -name \*.new -prune -o -name CVS -prune -o -name .svn -prune -o -name .cvsignore -prune -o -name .gitignore -prune -o -name .old -prune \) -o -type f -print | sed -e 's/^.\///'` ; do grep -i "^$router\;" ../router.db > /dev/null 2>&1 if [ $? -eq 1 ] ; then rm -f $router case $RCSSYS in cvs | svn ) $RCSSYS delete $router $RCSSYS commit -m "deleted router $router" $router ;; git ) git rm $router git commit -m "deleted router $router" $router ;; esac echo "Deleted $router" fi done cd $DIR # no routers, empty list or all 'down' if [ ! -s routers.up ] ; then # commit router.db, etc message="updates of group $GROUP" case $RCSSYS in cvs | svn ) $RCSSYS commit -m "$message" ;; git ) git add router.db git commit -am "$message" git push ;; esac exit; fi # if a device (-r) was specified, see if that device is in this group if [ "X$device" != "X" ] ; then trap 'rm -fr $TMP $DIR/routers.single;' 1 2 15 devlistfile="$DIR/routers.single" grep -i "^$device\;" routers.up > $devlistfile if [ $? -eq 1 ] ; then exit; fi else devlistfile="$DIR/routers.up" fi # Now we can actually try to get the configs cd $DIR/configs # The number of processes running at any given time can be # tailored to the specific installation. echo "" echo "Trying to get all of the configs." par -q -n $PAR_COUNT -c 'rancid-fe "{}"' $devlistfile # This section will generate a list of missed routers # and try to grab them again. It will run through # $pass times. pass=$MAX_ROUNDS round=1 if [ -f $DIR/routers.up.missed ] ; then rm -f $DIR/routers.up.missed fi while [ $round -le $pass ] do for router in `cat $devlistfile` do OFS=$IFS IFS=';' set $router IFS=$OFS router=$1; mfg=$2 if [ ! -s $router.new ] then echo "$router;$mfg" >> $DIR/routers.up.missed rm -f $router.new fi done if [ -f $DIR/routers.up.missed ] ; then echo "=====================================" echo "Getting missed routers: round $round." par -q -n $PAR_COUNT -c 'rancid-fe "{}"' $DIR/routers.up.missed rm -f $DIR/routers.up.missed round=`expr $round + 1` else echo "All routers successfully completed." round=`expr $pass + 1` fi done echo # Make sure that no empty/truncated configs are accepted. The remainder are # renamed from device_name.new -> device_name. for router in `cat $devlistfile | cut -d\; -f1` do if [ ! -s $router.new ] ; then rm -f $router.new else notcomment=`egrep -v "^[-*\!\;#]|\/\*" $router.new | wc -l` if [ $notcomment -gt 10 ]; then lines=1; else lines=0; fi if [ ! $lines ] ; then rm -f $router.new else mv -f $router.new $router if [ $? -ne 0 ] ; then echo "Error: could not rename $router.new to $router" >&2 rm -f $router.new fi fi fi done # This has been different for different machines... # Diff the directory and then checkin. trap 'rm -fr $TMP $TMP.diff $DIR/routers.single;' 1 2 15 cd $DIR if [ "X$DIFFSCRIPT" = "X" ]; then case $RCSSYS in cvs ) cvs -f @DIFF_CMD@ -ko | sed -e '/^RCS file: /d' -e '/^--- /d' \ -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff ;; svn | git ) $RCSSYS diff | sed -e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff ;; esac else case $RCSSYS in cvs ) cvs -f @DIFF_CMD@ -ko | (eval $DIFFSCRIPT) 2>&1 >$TMP.diff ;; svn | git ) $RCSSYS diff | (eval $DIFFSCRIPT) 2>&1 >$TMP.diff ;; esac fi if [ $alt_mailrcpt -eq 1 ] ; then subject="router config diffs - courtesy of $mailrcpt" else subject="router config diffs" fi if [ $RCSSYS = git ] ; then $RCSSYS commit -am "$commitmsg" else $RCSSYS commit -m "$commitmsg" fi if [ "X$device" != "X" ] ; then subject="$GROUP/$device $subject" else subject="$GROUP $subject" fi # working-directory maintenance & cleanup every 100 runs if [ -f "runcount" ] ; then read RUNCOUNT < ./runcount RUNCOUNT=`expr $RUNCOUNT + 1` else RUNCOUNT=1 fi case $RCSSYS in svn ) svn cleanup ;; git ) git push if [ $RUNCOUNT -gt 100 ] ; then git gc --quiet RUNCOUNT=0 fi ;; esac rm -f ./runcount echo $RUNCOUNT > ./runcount # Mail out the diffs (if there are any). if [ -s $TMP.diff ] ; then MAXSZ=${MAILSPLIT:=0} if [ $MAXSZ -ne 0 ] ; then BLOCKSIZE=1024; export BLOCKSIZE tmpk=`perl -e "my(@S) = stat(\"$TMP.diff\"); print int(\\$S[7] / 1024);"` unset BLOCKSIZE if [ $tmpk -lt $MAXSZ ] ; then MAXSZ=0 fi fi if [ $MAXSZ -eq 0 ] ; then ( echo "To: $mailrcpt" echo "Subject: $subject" echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/) { I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN = substr(LN,I+2,length(LN)-I-1);}print L LN;}' echo "" if [ $alt_commitmsg -eq 1 ] ; then echo "Commit message: $commitmsg" echo "" fi cat $TMP.diff ) | $SENDMAIL -t $MAILOPTS else CDIR=`pwd` SDIR=${TMPDIR:=/tmp}/rancid.$GROUP.$$.mail error=`mkdir $SDIR` if [ $? -ne 0 ] ; then echo "Could not create $SDIR directory" >&2 echo $error >&2 else cd $SDIR split -b${MAXSZ}k $TMP.diff nfiles=`ls | wc -l | sed -e 's/^ *//' |cut -d' ' -f1` n=0 dt=`perl -e 'print time();'` for file in `ls`; do n=`expr $n + 1` MSGID="<$dt.RANCID$GROUP$$${nfiles}${n}@`hostname`>" ( echo "To: $mailrcpt" echo "Subject: $n of ${nfiles}: $subject" echo "Message-Id: $MSGID" if [ $n -gt 1 ] ; then echo "References: $LASTIDS" fi echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/) { I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN = substr(LN,I+2,length(LN)-I-1);}print L LN;}' echo "" if [ $alt_commitmsg -eq 1 ] ; then echo "Commit message: $commitmsg" echo "" fi cat $file ) | $SENDMAIL -t $MAILOPTS LASTIDS="$LASTIDS $MSGID" if [ $n -lt $nfiles ]; then # this just tries to make the msgs order right in MUAs sleep 1 fi done cd $CDIR rm -rf $SDIR fi fi fi # If any machines have not been reached within the last $OLDTIME # hours, mail out a list of them. cd $DIR/configs rm -f $DIR/routers.failed if [ "X$OLDTIME" = "X" ] ; then OLDTIME=24 fi @PERLV@ -F\; -ane "{\$t = (stat(\$F[0]))[9]; print \`ls -ld \$F[0]\` if (time() - \$t >= $OLDTIME*60*60);}" $devlistfile | sort -u > $DIR/routers.failed if [ -s $DIR/routers.failed ] ; then ( echo "To: $adminmailrcpt" echo "Subject: config fetcher problems - $GROUP" echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/) { I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN = substr(LN,I+2,length(LN)-I-1);}print L LN;}' echo "" echo "The following routers have not been successfully contacted for" echo "more than $OLDTIME hours." cat $DIR/routers.failed ) | $SENDMAIL -t $MAILOPTS fi # Cleanup rm -f $TMP.diff $DIR/routers.single $DIR/routers.failed trap '' 1 2 15 rancid-3.13/bin/rancid-fe.in000644 015615 000000 00000007005 13657102757 015725 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # rancid-FE - front-end to rancid/jrancid/etc. for use with par. # # usage: rancid-fe ; # require 5; my($script); my($router, $devtype) = split('\;', $ARGV[0]); $devtype =~ tr/[A-Z]/[a-z]/; if (! length($devtype)) { printf(STDERR "unknown router manufacturer for $router: $devtype\n"); exit(-1); } # XXX use rancid::loadtype() to parse these files. REPEAT: foreach $file ("@sysconfdir@/rancid.types.base", "@sysconfdir@/rancid.types.conf") { open(INPUT, "< $file") || die "Could not open $file: $!"; while () { chomp; my($type, $directive, $value) = split('\;'); $type =~ tr/[A-Z]/[a-z]/; $directive =~ tr/[A-Z]/[a-z]/; if ($type eq $devtype && $directive eq "script") { $script = $value; close(INPUT); goto FOUND; } if ($type eq $devtype && $directive eq "alias") { $devtype = $value; close(INPUT); goto REPEAT; } } close(INPUT); } FOUND: if (! defined($script)) { printf(STDERR "unknown router manufacturer for $router: $devtype\n"); exit(-1); } else { exec($script . " $router"); } printf(STDERR "exec($script) failed router manufacturer $devtype: $!\n"); exit(-1); rancid-3.13/bin/hrancid.in000644 015615 000000 00000037601 13534014741 015477 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ @copyright@ # # Amazingly hacked version of Hank's rancid - this one tries to # deal with HP procurves. # # RANCID - Really Awesome New Cisco confIg Differ # # usage: hrancid [-dltCV] [-f filename | hostname] # use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; use Exporter; use Getopt::Std; our($opt_d, $opt_f, $opt_h, $opt_l, $opt_t, $opt_C, $opt_V); $opt_t = "hp"; getopts('dflt:CV'); BEGIN { push(@INC, "@pkglibdir@"); } use rancid; our @ISA = qw(Exporter rancid); if ($opt_V) { print "@PACKAGE@ @VERSION@\n"; exit(0); } $log = $opt_l; $debug = $opt_d; $file = $opt_f; $host = $ARGV[0]; $clean_run = 0; $found_end = 0; # unused - hp lacks an end-of-config tag $timeo = 90; # hlogin timeout in seconds my(@commandtable, %commands, @commands);# command lists my($aclsort) = ("ipsort"); # ACL sorting mode my($filter_commstr); # SNMP community string filtering my($filter_osc); # oscillating data filtering mode my($filter_pwds); # password filtering mode my($systeminfo) = 0; # show system-information our $cmd; our @EXPORT = qw($cmd); # This routine parses "show config files" sub ShowConfigFiles { print STDERR " In ShowConfigFiles: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); return(1) if /^(Invalid|Ambiguous) input:/i; ProcessHistory("COMMENTS","keysort","H0",";$_"); } return(0); } # This routine parses "show version" sub ShowVersion { print STDERR " In ShowVersion: $_" if ($debug); while () { tr/\015//d; last if(/^$prompt/); next if(/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); return(-1) if /^(Invalid|Ambiguous) input:/i; next if /^uptime/i; s/^image//i; s/^\s*//g; ProcessHistory("COMMENTS","keysort","C1", ";Image: $_") && next; } return(0); } # This routine parses "show flash" sub ShowFlash { print STDERR " In ShowFlash: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); return(1) if /^(Invalid|Ambiguous) input:/i; return(1) if /^\s*\^\s*$/; ProcessHistory("COMMENTS","keysort","D0",";Flash: $_"); } return; } # This routine parses "show system-information" or "show system information" sub ShowSystem { print STDERR " In ShowSystem: $_" if ($debug); if ($systeminfo) { $_ = ; return(0); } while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); return(0) if /^(Invalid|Ambiguous) input:/i; return(0) if /^% Unknown command/i; if (/memory\s+-\s+total\s+:\s+(\S+)/i) { my($mem) = $1; $mem =~ s/,//g; $mem /= (1024 * 1024); ProcessHistory("COMMENTS","keysort","B0",";Memory: " . int($mem) . "M\n"); next; } /serial\s+number\s+:\s+(\S+)/i && ProcessHistory("COMMENTS","keysort","A1",";Serial Number: $1\n"); /firmware\s+revision\s+:\s+(\S+)/i && ProcessHistory("COMMENTS","keysort","C0",";Image: Firmware $1\n"); /rom\s+version\s+:\s+(\S+)/i && ProcessHistory("COMMENTS","keysort","C1",";Image: ROM $1\n"); } $systeminfo = 1; return(0); } # This routine parses "show module". sub ShowModule { print STDERR " In ShowModule: $_" if ($debug); my(@lines); my($slot); while () { tr/\015//d; return if (/^\s*\^$/); last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); return(1) if /^(Invalid|Ambiguous) input:/i; ProcessHistory("COMMENTS","keysort","E0","; $_") && next; } return(0); } # This routine parses "show stack" sub ShowStack { print STDERR " In ShowStack: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); return(1) if /^(Invalid|Ambiguous) input:/i; s/stacking - (Stacking Status).*/$1/i; s/\s*members unreachable .*$//i; next if /^uptime/i; ProcessHistory("COMMENTS","keysort","F0",";$_"); /auto grab/i && last; } return(0); } # This routine parses "show tech transceivers" sub ShowTechTransceivers { print STDERR " In ShowTransceivers: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); return(1) if /^(Invalid|Ambiguous) input:/i; s/ Technical Information//i; if (/^ATTENTION: You are entering a diagnostic mode/) { while () { tr/\015//d; return(1) if (/^$prompt/); last if (/^(\s*)$/); } next; } # KB.16.05.0003 5406R firmware bug next if (/^\s*show time\s*$/i); # Aruba with third-party transceivers last if (/^(\* third-party transceiver)?show time/); next if (/^\s*\S{3} \S{3}\s+\d+\s+\d+:\d+:\d+\s+\d+\s*$/); ProcessHistory("COMMENTS","keysort","G0",";$_"); } return(0); } # This routine parses "show config status" sub ShowConfigStatus { print STDERR " In ShowConfigStatus: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); return(1) if /^(Invalid|Ambiguous) input:/i; next if (/^Running configuration is same as /); next if (/^$/); ProcessHistory("COMMENTS","keysort","H0","; $_"); } return(0); } # This routine processes a "write term" sub WriteTerm { print STDERR " In WriteTerm: $_" if ($debug); while () { tr/\015//d; if (/$prompt\s*(exit|logout)\s*$/i) { $clean_run=1; last; } last if(/^$prompt/); return(-1) if (/command authorization failed/i); # the pager can not be disabled per-session s/^<-+ More -+>\s*//; s/^$/;/; # skip the crap /^running configuration:/i && next; # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; /^; (\S+) configuration editor;/i && ProcessHistory("COMMENTS","keysort","A0",";Chassis type: $1\n") && ProcessHistory("","","",";\n;Running config file:\n$_") && next; # order logging statements - doesnt appear to do syslog as of right now /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # no so sure this match is correct. show running doesnt seem to # actually o/p anything after "password (manager|operator)" if (/^(\s*)password (manager|operator)?/ && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","",";$1password $2 \n"); next; } if (/^(snmp-server community) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_", ";$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # order/prune snmp-server host statements - it actually appears to do # the sortting for us, but just in case it changes ... # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = ";$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } # order/prune tacacs/radius server statements if (/^(tacacs-server|radius-server) key / && $filter_pwds >= 1) { ProcessHistory("","","",";$1 key \n"); next; } if (/^(tacacs-server host \d+\.\S+) key / && $filter_pwds >= 1) { ProcessHistory("","","",";$1 key \n"); next; } # prune passwords from stack member statements if (/^(stack member .* password )\S+/ && $filter_pwds >= 1) { ProcessHistory("","","",";$1$'"); next; } # order arp lists /^ip arp\s+(\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("ARP","$aclsort","$1","$_") && next; /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ && ProcessHistory("PACL $1 $3","$aclsort","$4","ip prefix-list $1 $3 $4$5\n") && next; # blech!!!! /^auto-tftp / && ProcessHistory("","","",";$_") && next; # the rest are from rancid (i.e.: cisco), but suspect they will someday # be applicable or close to it. /^tftp-server flash / && next; # kill any tftp remains /^ntp clock-period / && next; # kill ntp clock-period /^ length / && next; # kill length on serial lines /^ width / && next; # kill width on serial lines if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","",";$1$2 \n"); next; } if (/^username (\S+)(\s.*)? password /) { if ($filter_pwds >= 1) { ProcessHistory("USER","keysort","$1",";username $1$2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^(ip ftp password) / && $filter_pwds >= 1) { ProcessHistory("","","",";$1 \n"); next; } if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { ProcessHistory("","","",";$1 \n"); next; } if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","",";$1 \n"); next; } # sort route-maps if (/^route-map (\S+)/) { my($key) = $1; my($routemap) = $_; while () { tr/\015//d; last if (/^$prompt/ || ! /^(route-map |[ !])/); if (/^route-map (\S+)/) { ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); $key = $1; $routemap = $_; } else { $routemap .= $_; } } ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); } # order access-lists /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order extended access-lists /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ && ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; # order alias statements /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next; # delete ntp auth password if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","",";$1 \n"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { my($sortkey) = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # order ip host line statements /^ip host line(\d+)/ && ProcessHistory("IPHOST","numsort","$1","$_") && next; # order ip nat source static statements /^ip nat (\S+) source static (\S+)/ && ProcessHistory("IP NAT $1","ipsort","$2","$_") && next; # order ip rcmd lines /^ip rcmd/ && ProcessHistory("RCMD","keysort","$_","$_") && next; # catch anything that wasnt match above. ProcessHistory("","","","$_"); } return(0); } # Main rancidinit(); @commandtable = ( {'show version' => 'ShowVersion'}, {'show flash' => 'ShowFlash'}, {'show system-information' => 'ShowSystem'}, {'show system information' => 'ShowSystem'}, {'show module' => 'ShowModule'}, {'show stack' => 'ShowStack'}, {'show tech transceivers' => 'ShowTechTransceivers'}, {'show config files' => 'ShowConfigFiles'}, {'show config status' => 'ShowConfigStatus'}, {'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); $commandcnt = scalar(keys %commands); $commandstr=join(";",@commands); $cmds_regexp = join("|", map quotemeta($_), @commands); if (length($host) == 0) { if ($file) { print(STDERR "Too few arguments: file name required\n"); exit(1); } else { print(STDERR "Too few arguments: host name required\n"); exit(1); } } if ($opt_C) { print "hlogin -t $timeo -c\'$commandstr\' $host\n"; exit(0); } open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n"; select(OUTPUT); # make OUTPUT unbuffered if debugging if ($debug) { $| = 1; } if ($file) { print(STDERR "opening file $host\n") if ($debug || $log); open(INPUT,"<$host") || die "open failed for $host: $!\n"; } else { print(STDERR "executing hlogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log); system "hlogin -t $timeo -c \"$commandstr\" $host $host.raw 2>&1" || die "hlogin failed for $host: $!\n"; open(INPUT, "< $host.raw") || die "hlogin failed for $host: $!\n"; } # 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 oscillating data filtering mode if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) { $filter_osc = 0; } else { $filter_osc = 1; } # determine password filtering mode if ($ENV{"FILTER_PWDS"} =~ /no/i) { $filter_pwds = 0; } elsif ($ENV{"FILTER_PWDS"} =~ /all/i) { $filter_pwds = 2; } else { $filter_pwds = 1; } ProcessHistory("","","",";RANCID-CONTENT-TYPE: hp\n;\n"); ProcessHistory("COMMENTS","keysort","B0",";\n"); # memory info ProcessHistory("COMMENTS","keysort","C0",";\n"); # showversion ProcessHistory("COMMENTS","keysort","D0",";\n"); # showflash ProcessHistory("COMMENTS","keysort","E0",";\n"); # showmodule ProcessHistory("COMMENTS","keysort","F0",";\n"); # showstack ProcessHistory("COMMENTS","keysort","G0",";\n"); # showtechtransceivers ProcessHistory("COMMENTS","keysort","H0",";\n"); # showconfigfiles ProcessHistory("COMMENTS","keysort","I0",";\n"); TOP: while() { tr/\015//d; if (/$prompt\s*(exit|logout)\s*$/i) { $clean_run=1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run=0; last; } while (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; $prompt .= "[#>]"; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } my($rval) = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } print STDOUT "Done $lscript: $_\n" if ($log); # Flush History ProcessHistory("","","",""); # Cleanup close(INPUT); close(OUTPUT); unlink("$host.raw") if (! $debug); # check for completeness if (scalar(%commands) || !$clean_run) { if (scalar(keys %commands) eq $commandcnt) { printf(STDERR "$host: missed cmd(s): all commands\n"); } elsif (scalar(%commands)) { my($count, $i) = 0; for ($i = 0; $i < $#commands; $i++) { if ($commands{$commands[$i]}) { if (!$count) { printf(STDERR "$host: missed cmd(s): %s", $commands[$i]); } else { printf(STDERR ", %s", $commands[$i]); } $count++; } } if ($count) { printf(STDERR "\n"); } } if (!$clean_run) { print(STDERR "$host: End of run not found\n"); if ($debug) { print(STDERR "$host: clean_run is false\n") if (!$clean_run); print(STDERR "$host: found_end is false\n") if (!$found_end); } system("/usr/bin/tail -1 $host.new"); } unlink "$host.new" if (! $debug); } rancid-3.13/bin/rtftpcopy.in000755 015615 000000 00000010504 13534015005 016107 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # copy configs from tftpboot within rancid; assumes CWD=/configs and # that /bin/domainname is the same domainname as the routers, which is # replaced with "-confg" to form the filename expected in /tftpboot. # # usage: rtftpcopy [-dltCV] [-f filename | hostname] # use Getopt::Std; getopts('dflt:CV'); if ($opt_V) { print "@PACKAGE@ @VERSION@\n"; exit(0); } $log = $opt_l; $debug = $opt_d; $file = $opt_f; $host = $ARGV[0]; $domain = system("/bin/domainname"); $domain =~ s/[.]/\\./g; if ($file) { $srcfile = $host; $host =~ s/^.*\///; } else { $srcfile = $host; $srcfile =~ s/$domain$/-confg/; } if (length($host) == 0) { if ($file) { print(STDERR "Too few arguments: file name required\n"); exit(1); } else { print(STDERR "Too few arguments: host name required\n"); exit(1); } } if ($opt_C) { if ($file) { print "cp $srcfile $host.new\n"; } else { print "cp /tftpboot/$srcfile $host.new\n"; } exit(0); } if ($file) { print STDERR "copying file $host\n" if ($debug); print STDOUT "copying file $host\n" if ($log); system("/bin/cp $srcfile $host.new"); } else { print STDERR "copying file $host\n" if ($debug); print STDOUT "copying file $host\n" if ($log); system("/bin/cp /tftpboot/$srcfile $host.new") == 0; } if (!$?) { print STDERR "copy failed: $!\n"; } print STDOUT "Done cp: $_\n" if ($log); # check for completeness if (scalar(%commands) || !$clean_run || !$found_end) { if (scalar(keys %commands) eq $commandcnt) { printf(STDERR "$host: missed cmd(s): all commands\n"); } elsif (scalar(%commands)) { printf(STDOUT "$host: missed cmd(s): %s\n", join(',', keys(%commands))); printf(STDERR "$host: missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug); } if (!$clean_run || !$found_end) { print STDOUT "$host: End of run not found\n"; print STDERR "$host: End of run not found\n" if ($debug); system("/usr/bin/tail -1 $host.new"); } unlink "$host.new" if (! $debug); } rancid-3.13/bin/rivlogin.in000644 015615 000000 00000053352 13477726274 015742 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # rivlogin - Riverstone (and Enterasys SSR) login # # Based upon rscmd (see nmops.org) # rscmd - Riverstone Networks Automated login # by Mike MacFaden, Kiran Addepalli # Riverstone Networks, 2000 # # Returned to the RANCID crowd by andrew fort # Usage line set usage "Error: Usage: $argv0 \[-diV\] \[-noenable\] \ \[-f cloginrc-file\] \[-c command\] \[-Evar=x\] \[-s script-file\] \ \[-x command-file\] \[-t timeout\] \[-o output-file\] \ router \[router...\]\n" # program diagnostics set verbose 0 set success 1 set config 0 # in seconds to wait for data back from device set timeoutdflt 10 # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} set tempfile "/tmp/rivlogin.[exec date]" # cli command prompt set my_prompt ">" set enable_prompt "\#" set default_user "" set output_file "" set conf_prompt "*\(config\)# " set logging 0 set config_mode 0 # Save config, if prompted set do_saveconfig 0 # cloginrc debugging knob set do_cloginrcdbg 0 # Password file for routers to access set password_file $env(HOME)/.cloginrc # If no -c or -s specified, just automate router login ala rsh set do_command 0 set do_interact 0 set do_script 0 set log_user 0 # The default CLI mode to login to is "enable" mode 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 set do_enapasswd 1 # set send_human {.4 .4 .7 .3 5} # intialize cloginrc parsing stacks set int_file {} set int_lineno {} # env(CLOGIN) may contain: # x == do not set xterm banner or name # Find the user in the ENV, or use the unix userid. if {![info exists default_user] && [info exists env(CISCO_USER)]} { if {[string length $env(CISCO_USER)]} { set default_user $env(CISCO_USER) } } if {![info exists default_user] && [info exists env(USER)]} { if {[string length $env(USER)]} { set default_user $env(USER) } } if {![info exists default_user] && [info exists env(LOGNAME)]} { if {[string length $env(LOGNAME)]} { set default_user $env(LOGNAME) } } if (![info exists 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. if [catch {exec id} reason] { send_error "\nError: could not exec id: $reason\n" exit 1 } regexp {\(([^)]*)} "$reason" junk default_user } if {[info exists env(CLOGINRC)]} { set password_file $env(CLOGINRC) } # # Done configuration/variable setting. Now run with it... # # 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 } } # take host from ENV(TERM) 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" } } } # This is a helper function to make the password file easier to # maintain. Using this the password file has the form: # add password sl* pete cow # add password at* steve # add password * hanky-pie proc add {var args} { global int_file int_lineno int_$var set file [lindex $int_file 0] set lineno [lindex $int_lineno 0] lappend int_$var "$var:$file:$lineno: $args" } proc include {args} { global env regsub -all "(^{|}$)" $args {} args if { [regexp "^/" $args ignore] == 0 } { set args $env(HOME)/$args } source_password_file $args } proc find {var router} { global do_cloginrcdbg upvar int_$var list if { [info exists list] } { foreach line $list { if { [string match -nocase [lindex $line 1] $router] } { if { $do_cloginrcdbg > 0 } { send_error -- [join [list [lindex $line 0] [lrange $line 1 end] "\r\n"]] } if { $do_cloginrcdbg == 2 } { # save return value if {! [info exists result]} { set result [lrange $line 2 end] } } else { return [lrange $line 2 end] } } } } if { $do_cloginrcdbg == 2 } { if {[info exists result]} { return $result } } return {} } # Loads the password file. Note that as this file is tcl, and that # it is sourced, the user better know what to put in there, as it # could install more than just password info... I will assume however, # 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 { file } { global env int_file int_lineno if { ! [file exists $file] } { send_user "\nError: password file ($file) does not exist\n" exit 1 } file stat $file fileinfo if { [expr ($fileinfo(mode) & 007)] != 0000 } { send_user "\nError: $file must not be world readable/writable\n" exit 1 } if [catch {set fd [open $file "r"]} reason] { send_user "\nError: $reason\n" exit 1 } set int_file [linsert $int_file 0 $file] set int_lineno [linsert $int_lineno 0 0] while { [gets $fd line] >= 0 } { set tmp [lindex $int_lineno 0]; incr tmp lset int_lineno 0 $tmp eval $line } set int_file [lrange $int_file 1 end] set int_lineno [lrange $int_lineno 1 end] close $fd } # pre: login completed ok # post: terminate login session by closing tcp connection proc auto_exit { } { global telnet_id if { $verbose == 1 } { puts "DEBUG: auto_exit closing connection to pid $telnet_id\n" } close -i telnet_id } # perform login basic to a router # pre: args are valid, router is reachable via network # post: return 0 on successful login, else 1 # # NOTE: a number of globals are setup: my_prompt, telnet_id are key # and paging of cli output is disabled proc login { router user userpswd passwd enapasswd } { global login_array global telnet_id global expect_out global spawn_id global verbose global config verbose my_prompt eval spawn -noecho [split "$telnetcmd $router"] set telnet_id $spawn_id if { $telnet_id == 0 } { puts "ERROR: login: spawn telnet session failed.\n" return 1 } # wait for initial 'Press RETURN to...' response sleep 0.3 expect "*" send "\r" # 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;} } } "%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); return 1 } } timeout { puts "ERROR: Timeout on login. Exiting."; return 1 } eof { puts "ERROR: device closed telnet connection during login" return 1 } } # save my_prompt for later use send "\r" expect -re ".*> " set abc "$expect_out(buffer)" set my_prompt "[lindex $abc 0]" regexp {(.*[^>])} $my_prompt my return 0; } # pre: login completed ok # post: turn off paging of commands proc disable_cli_paging { } { global my_prompt send "cli set terminal rows 0\r" expect { "$my_prompt" {return 0 } } return 1 } # pre: login returned 0, prompt at top level # post: turn off command completion return 0 # on error, return 1 proc disable_cmd_autocomplete { } { global my_prompt send "cli set command completion off\r" expect { $my_prompt { } timeout { puts "ERROR:disable_cmd_autocomplete(TIMEOUT)"; return 0; } } return 0 } # pre: login returned 0, do_enable returned 0, cli is in enable or config mode # post: issues logout cli to device, returns 0 proc logout { prompt } { global config_mode enable_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" } } set config_mode 0 } send "logout\r" expect { "Are you sure*" { send "yes\r" return 0 } } } # pre: current mode allows transition to enable mode # post: enable mode entered, my_prompt updated, return 0 else 1 proc do_enable { enauser enapasswd userpswd } { global expect_out verbose global my_prompt enable_prompt set enable_prompt [ string trimright $my_prompt ">" ] set enable_prompt $enable_prompt\# set uses_username 0; send "enable\r" expect { Username: { set uses_username 1; send -- "$enauser\r"; exp_continue } Password: { if {$uses_username == 1} { send -- "$userpswd\r"; } else { send -- "$enapasswd\r"; } exp_continue } "$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" { puts "ERROR: Bad user or password for enable mode." return 1 } } set my_prompt $enable_prompt return 0 } # pre: current mode allows transition to enable mode # post: enable mode entered, my_prompt updated, return 0 else 1 proc do_configure { } { global expect_out verbose config_mode global my_prompt set config_prompt [ string trimright $my_prompt "\#" ] set config_prompt $config_prompt\(config\)\# send "configure\r" expect { "$config_prompt " { } "$my_prompt" { } eof { return 1} timeout { return 1} } set config_mode 1 set my_prompt $config_prompt return 0 } # track sent/received from device to output_file # pre: outut_file is valid filename w/write access # post: logfile open, global var logging == 1, return 0 , else 1 proc start_logfile { output_file } { global logging if { [ string length $output_file ] != 0 } { set rc [ catch { log_file -noappend $output_file } errMsg ] if { $rc != 0 } { puts "ERROR: open file $output_file for write access failed. $errMsg\n" return 1 } set logging 1 } return 0 } proc run_commands { prompt cmdstring } { global do_interact sendstring # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $cmdstring] for {set i 0} {$i < $num_commands} { incr i} { 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 { $do_interact == 1 } { interact return 0 } return 0 } # Run commands given on the command line # pre: prompt is current system cli prompt, cmdstring is command to execute # post: return 0 on success else 1 # NOTE: output from router ends up in output_file if specified # expect internal input buffer is reset to "" after each command proc run_single_command { prompt cmdstring } { global verbose set rc 0 set seen_prompt 0 set seen_timeout 0 set need_ays 0 set delay 0 # ays == "are you sure" - must send back yes if { [string compare $cmdstring "save startup" ] == 0 } { set need_ays 1 set delay 1 } # TODO: add case for copy command to startup, also prompts for ok # TODO: if we see config command: system set name note it # if we see a save active, then update system prompts as well send "$cmdstring\r" if { $delay == 1} { sleep 1 } expect { "%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 } "%SYS-I-ADDFAILED*" { 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 } "%SYS-E-PRIMARY_NO_SUCH_IMAGE*" { puts "ERROR: run_commands(command rejected by device)\n" set rc 1 } "want to overwrite " { send "yes\r" set need_ays 0 } "%CONFIG-E-DUPLICATE,*" { } "$prompt" { if { $seen_prompt == 0 } { set seen_prompt 1 } if { $need_ays == 1 } { exp_continue } } -re ".* More: m, --- Quit: q --- One line: ---" { send "q" exp_continue } timeout { if {$verbose == 1} { puts "DEBUG: timeout occured for the $seen_time time\n" } if { $seen_timeout == 0 } { set seen_timeout 1 send "\r\r" exp_continue } puts "ERROR:run_commands(TIMEOUT)" set rc 1 } eof { puts "ERROR:run_commands(connection closed by device)\n" set rc 1 } "\n" { exp_continue } } # clear input buffer of any remaining data expect "*" return $rc } # pre: RSTONE_USER env var is set # post: update global "default_user" to this string proc init_userid { } { global default_user if {[ info exists 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 } } proc source_script_file { filename } { global my_prompt 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 ] if { $rc != 0 } { puts "ERROR: process_script_file: open script file $filename for read access failed. $errMsg\n" return 1 } set line_cnt 0 while { [eof $ifile] != 1 } { set bytes [ gets $ifile cmd ] incr line_cnt if { $bytes < 0 } { break } elseif { $bytes == 0 } { continue } # skip comments in script files if { [regexp "^\#" $cmd] != 1 } { # puts "$cmd rc = [string compare $cmd "configure" ]\n" if { [string compare $cmd "configure" ] == 0 } { do_configure } else { if {[ run_commands $my_prompt $cmd ] == 1} { puts "ERROR: line $line_cnt in $filename not processed by device. Check previous error msgs." set rc 1 break } } } } close $ifile 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 } { global tempfile 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 ] if { $rc != 0 } { puts "ERROR: strip_log: open temp file $tempfile for write access failed. $errMsg\n" return 1 } set nl 0 puts $ofile "rscmd: $router : [exec date]" while { [eof $ifile] != 1 } { set bytes [ gets $ifile cmd ] if { $bytes <= 0 } { break } incr nl if { $nl <= 2 } { continue } regsub -all -- "\r" $cmd "" newcmd puts $ofile $newcmd } close $ifile close $ofile set rc 0 file copy -force $tempfile $filename file delete $tempfile return $rc } # # main section # # send input like in a fast and consistent human style set send_human {.1 .3 1 .05 2} # initialize default_user variable init_userid # Parse Command Line for {set idx 0} {$idx < $argc} {incr idx} { set arg [lindex $argv $idx] switch -glob -- $arg { -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 } # Expect script to run } -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" exit 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* { 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* { if {! [ regexp .\[fF\](.+) $arg ignore password_file]} { incr idx set password_file [ lindex $argv $idx ] } } -o* { if {! [ regexp .\[fF\](.+) $arg ignore password_file]} { incr idx set output_file [ lindex $argv $idx ] } # Timeout } -t* { incr idx set timeoutdflt [ lindex $argv $idx ] # Do we enable? } -noenable { set avenable 0 } -* { send_user "Error: Unkown argument! $arg\n" send_user $usage exit 1 } default { break } } } # Verify at least one router is specified # if { $idx == $argc } { puts "\n$usage" exit 1 } # main loop set exitval 0 foreach router [lrange $argv $idx end] { set router [string tolower $router] send_user -- "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # look for noenable option in .cloginrc if { [find noenable $router] == "1" } { set enable 0 } else { set enable $avenable } # Figure out passwords if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 } { send_user -- "\nError: no password for $router in $password_file.\n" exit 1 } if { $do_enapasswd && [llength $pswd] < 2 } { send_user -- "\nError: no enable password for $router in $password_file." exit 1 } if { $do_passwd } { set passwd [join [lindex $pswd 0] ""] } else { set passwd $userpasswd } if { $do_enapasswd } { set enapasswd [join [lindex $pswd 1] ""] } else { set enapasswd $enapasswd } } else { set passwd $userpasswd set enapasswd $enapasswd } # 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 if {[login $router $user $userpswd $passwd $enapasswd ]} { incr exitval if { $verbose == 1 } { puts "DEBUG: login to $router failed\n" } exit 1 } if { $enable == 1 } { if { [do_enable $enauser $enapasswd $userpswd] == 1} { incr exitval if { $verbose == 1 } { puts "DEBUG: switch to enable mode on $router failed\n" } exit 1 } } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # run in one of three modes if { $do_command } { disable_cmd_autocomplete disable_cli_paging if { [start_logfile $output_file] != 0 } { exit 1 } if {[ run_commands $my_prompt $command ]} { incr exitval 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 logout $my_prompt } else { label $router log_user 1 if {[ start_logfile $output_file] != 0 } { exit 1 } interact log_file } if { $logging == 1} { log_file strip_log $output_file $router } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/hlogin.in000644 015615 000000 00000037333 13657102757 015364 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # hlogin - hp login # # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 45 # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} @login_top@ # Log into the router. # returns: 0 on success, 1 on failure proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } { global spawn_id in_proc do_command do_script passphrase global prompt u_prompt p_prompt e_prompt sshcmd telnetcmd set in_proc 1 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 regexp {(telnet|ssh)(:([^[:space:]]+))*} $prog command suffix junk port if [string match "telnet*" $prog] { if {"$port" == ""} { if { $do_command || $do_script } { set retval [ catch {eval spawn [split "hpuifilter -- $telnetcmd $router"]} reason ] } else { set retval [ catch {eval spawn [split "$telnetcmd $router"]} reason ] } } else { if { $do_command || $do_script } { set retval [ catch {eval spawn [split "hpuifilter -- $telnetcmd $router $port"]} reason ] } else { set retval [ catch {eval spawn [split "$telnetcmd $router $port"]} reason ] } } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif [string match "ssh*" $prog] { # ssh to the router & try to login with or without an identfile. regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } if {"$identfile" != ""} { set cmd "$cmd -i $identfile" } if { $do_command || $do_script } { set retval [ catch {eval spawn hpuifilter -- [split "$cmd -x -l $user $router" { }]} reason ] } else { set retval [ catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason ] } if { $retval } { send_user "\nError: $cmd failed: $reason\n" return 1 } } elseif ![string compare $prog "rsh"] { send_error "\nError: unsupported method: rsh\n" if { $progs == 0 } { return 1 } continue; } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } # Here we get a little tricky. There are several possibilities: # the router can ask for a username and passwd and then # talk to the TACACS server to authenticate you, or if the # TACACS server is not working, then it will use the enable # passwd. Or, the router might not have TACACS turned on, # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { "Press any key to continue" { send "\r" exp_continue } "Enter switch number to connect to or :" { send "\r" exp_continue } -re "(Connection refused|Secure connection \[^\n\r]+ refused|Connection closed by)" { catch {close}; catch {wait}; if !$progs { send_user "\nError: Connection Refused ($prog)\n"; return 1 } } "Host is unreachable" { catch {close}; catch {wait}; send_user "\nError: Host Unreachable!\n"; wait; return 1 } "No address associated with name" { catch {close}; catch {wait}; send_user "\nError: Unknown host\n"; wait; return 1 } -re "(Host key not found |The authenticity of host .* be established)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -nocase -re "^warning: remote host denied authentication agent forwarding." { exp_continue; } 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 } -re "Enter passphrase.*: " { # sleep briefly to allow time for stty -echo sleep 1 send -- "$passphrase\r" exp_continue } -re "$u_prompt" { send -- "$user\r" expect { eof { send_user "\nError: Couldn't login\n"; wait; return 1 } "Login invalid" { send_user "\nError: Invalid login\n"; catch {close}; catch {wait}; return 1 } -re "$p_prompt" { send -- "$userpswd\r" } -re "$prompt" { set in_proc 0; return 0 } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } "Press any key to continue" { send " " exp_continue } } exp_continue } -re "$p_prompt" { if ![string compare $prog "ssh"] { send -- "$userpswd\r" } else { send -- "$passwd\r" } expect { eof { send_user "\nError: Couldn't login\n"; wait; return 1 } "Press any key to continue" { send " "; exp_continue } -re "$e_prompt" { send -- "$enapasswd\r" } -re "$prompt" { set in_proc 0; return 0 } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } -re "$prompt" { break; } denied { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 } } } set in_proc 0 return 0 } # Enable proc do_enable { enauser enapasswd } { global prompt in_proc global u_prompt e_prompt set in_proc 1 send "enable\r" expect { -re "$u_prompt" { send -- "$enauser\r"; exp_continue} -re "$e_prompt" { send -- "$enapasswd\r"; exp_continue} "#" { set prompt "#" } "(enable)" { set prompt "> (enable) " } denied { send_user "\nError: Check your Enable passwd\n"; return 1} "% Bad passwords" { send_user "\nError: Check your Enable passwd\n" return 1 } } # We set the prompt variable (above) so script files don't need # to know what it is. set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact do_saveconfig in_proc set in_proc 1 # Escape regex meta characters in the $prompt # match cisco config mode prompts too, such as router(config-if)# regsub -lineanchor -- {^(.{1,11}).*([#>] ?)$} $prompt {\1} reprompt regsub -all -- {[\\]$} $reprompt {} reprompt append reprompt {([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} # this is the only way i see to get rid of more prompts in o/p..grrrrr log_user 0 # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] # if the pager can not be turned off, we have to look for the "More" # prompt. for {set i 0} {$i < $num_commands} { incr i} { 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)"} } -re "\[\n\r]+" { catch {send_user -- "$expect_out(buffer)"} exp_continue } -re "\[^\r\n]*Press to cont\[^\r\n]*" { catch {send " "}; expect { # gag, 2 more prompts -re "\[\r\n]*\r" {} -re "\[^\r\n]*Press to cont\[^\r\n]*" { catch {send " "}; exp_continue } } exp_continue } -re "^More: \[^\n\r]* line:" { catch {send " "} exp_continue } -re "^<-+ More -+>\[^\n\r]*" { catch {send " "} exp_continue } -re "^-+ MORE -+\[^\n\r]*" { catch {send " "} exp_continue } # 3 flavours of the more prompt, -- first -More-, then --More-- (for # cisco/riverhead AGM), then with more dashes. -re "^-More-\[^\n\r-]*" { catch {send " "} exp_continue } -re "^--More--\[^\n\r-]*" { catch {send " "} exp_continue } -re "^---+More---+\[^\n\r]*" { catch {send " "} exp_continue } -re "\b+" { exp_continue } } } log_user 1 if { $do_interact == 1 } { interact return 0 } send -h "logout\r" expect { -re "Do you want to save (the )?current configuration" { if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "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" { catch {send "y\r"} exp_continue } -re "\[\r\n]+" { exp_continue } -re "^.+\[#>]" { # some require logout from # enabled, then the login, and # some do not have logout cmd catch {send -h "exit\r"} exp_continue } timeout { catch {close}; catch {wait}; return 0 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 # if we have dont have a tty, we need some additional terminal settings if [catch {open /dev/tty w} ttyid] { # no tty, ie: cron set spawnopts "-nottycopy" set stty_init "cols 132" } else { catch {close ttyid} reason } foreach router [lrange $argv $i end] { set router [string tolower $router] send_user "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Default prompt. set prompt [join [find prompt $router] ""] if { [llength $prompt] == 0 } { set prompt "(>|#) ?" } # look for autoenable option in .cloginrc & cmd-line set ae [find autoenable $router] if { "$ae" == "1" || $avautoenable } { set autoenable 1 } else { set autoenable 0 } # look for enable options in .cloginrc & cmd-line if { $avenable == 0 } { set enable 0 } else { set ne [find noenable $router] if { "$ne" == "1" || "$autoenable" == "1" } { set enable 0 } else { set enable 1 } } # Figure out passwords if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 } { send_user -- "\nError: no password for $router in $password_file.\n" continue } if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } { send_user -- "\nError: no enable password for $router in $password_file.\n" continue } if { $do_passwd } { set passwd [join [lindex $pswd 0] ""] } else { set passwd $userpasswd } if { $do_enapasswd } { set enapasswd [join [lindex $pswd 1] ""] } else { set enapasswd $enapasswd } } else { set passwd $userpasswd set enapasswd $enapasswd } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } 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 $ruser } } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(\[Uu]sername|\[Ll]ogin|\[Uu]ser \[Nn]ame|^\[Uu]ser|Login Name):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "(\[Pp]assword|passwd):" } else { set p_prompt [join [lindex $p_prompt 0] ""] } set e_prompt [find enableprompt $router] if { "$e_prompt" == "" } { set e_prompt "\[Pp]assword:" } else { set e_prompt [join [lindex $e_prompt 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 cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Adjust our path to find hpuifilter set hpf_path "" regexp {(.*)/[^/]+} $argv0 junk hpf_path if { "$hpf_path" != "" && "$hpf_path" != "." } { append env(PATH) ":$hpf_path" } # Login to the router if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} { incr exitval continue } if { $enable } { if {[do_enable $enauser $enapasswd]} { if { $do_command || $do_script } { incr exitval catch {close}; catch {wait}; continue } } } if { $do_command || $do_script } { # we are logged in, now figure out the full prompt send "\r" expect { -re "\[\r\n]+" { exp_continue; } -re "^.+$prompt" { set junk $expect_out(0,string); regsub -all "\[\]\[\(\)+]" $junk {\\&} prompt; } } # set a wide tty width. set stty_init "cols 132" # disable the pager send "no page\r" expect -re $prompt {} # Ciena Waveserver o/s # system shell session set window-height # system shell session set window-width # system shell session set more (off|on) send "system shell session set more off\r" expect -re $prompt {} } if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { source $sfile catch {close}; } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/xlogin.in000644 015615 000000 00000050511 13657102757 015375 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # xlogin - Extreme login # # Most options are intuitive for logging into a Cisco router. # The default is to enable (thus -noenable). Some folks have # setup tacacs to have a user login at priv-lvl = 15 (enabled) # so the -autoenable flag was added for this case (don't go through # the process of enabling and the prompt will be the "#" prompt. # The default username password is the same as the vty password. # # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 45 # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} @login_top@ # Log into the router. # returns: 0 on success, 1 on failure, -1 if rsh was used successfully proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } { global command spawn_id in_proc do_command do_script platform passphrase global prompt prompt_match u_prompt p_prompt e_prompt sshcmd telnetcmd set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port if {"$port" == ""} { set port 23 } if { $do_command || $do_script } { set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason] } else { set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason] } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif [string match "ssh*" $prog] { # ssh to the router & try to login with or without an identfile. regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } if {"$identfile" != ""} { set cmd "$cmd -i $identfile" } if { $do_command || $do_script } { set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason] } else { set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason] } if { $retval } { send_user "\nError: $cmd failed: $reason\n" return 1 } } elseif ![string compare $prog "rsh"] { if { ! $do_command } { if { [llength $cmethod] == 1 } { send_user "\nError: rsh is an invalid method for -x and " send_user "interactive logins\n" } if { $progs == 0 } { return 1 } continue; } # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] set rshfail 0 for {set i 0} {$i < $num_commands && !$rshfail} { incr i} { log_user 0 set retval [catch {spawn rsh $user@$router [lindex $commands $i] } reason] if { $retval } { send_user "\nError: rsh failed: $reason\n" log_user 1; return 1 } send_user "$router# [lindex $commands $i]\n" # rcmd does not get a pager and no prompts, so we just have to # look for failures & lines. expect { "Connection refused" { catch {close}; catch {wait}; send_user "\nError: Connection\ Refused ($prog): $router\n" set rshfail 1 } -re "(Connection closed by|Connection to \[^\n\r]+ closed)" { catch {close}; catch {wait}; send_user "\nError: Connection\ closed ($prog): $router\n" set rshfail 1 } "Host is unreachable" { catch {close}; catch {wait}; send_user "\nError: Host Unreachable:\ $router\n" set rshfail 1 } "No address associated with" { catch {close}; catch {wait}; send_user "\nError: Unknown host\ $router\n" set rshfail 1 } -re "\b+" { exp_continue } -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } timeout { catch {close}; catch {wait}; send_user "\nError: TIMEOUT reached\n" set rshfail 1 } eof { catch {close}; catch {wait}; } } log_user 1 } if { $rshfail } { if { !$progs } { return 1 } else { continue } } # fake the end of the session for rancid. send_user "$router# exit\n" # return rsh "success" return -1 } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } # Here we get a little tricky. There are several possibilities: # the router can ask for a username and passwd and then # talk to the TACACS server to authenticate you, or if the # TACACS server is not working, then it will use the enable # passwd. Or, the router might not have TACACS turned on, # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { -re "^<-+ More -+>\[^\n\r]*" { # ASA will use the pager for long banners send " "; exp_continue } -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 } "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)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -nocase -re "^warning: remote host denied authentication agent forwarding." { exp_continue; } -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 "% (Bad passwords|Authentication failed)" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } "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" exp_continue } -re "Last login:" { exp_continue } -re "Press the key \[^\r\n]+\[\r\n]+" { exp_continue } -re "@\[^\r\n]+ $p_prompt" { # ssh pwd prompt sleep 1 send -- "$userpswd\r" exp_continue } -re "Enter passphrase.*: " { # sleep briefly to allow time for stty -echo sleep .3 send -- "$passphrase\r" exp_continue } -re "$u_prompt" { send -- "$user\r" set uprompt_seen 1 exp_continue } -re "\\e\\\[Klogin:" { # eat weird EXOS >11.0 re-printing of the # telnet login prompt so we do not become # out of sync with the user/passwd prompts. exp_continue; } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send -- "$userpswd\r" } else { send -- "$passwd\r" } exp_continue } -re "$prompt" { set prompt_match $expect_out(0,string); break; } "Login invalid" { send_user "\nError: Invalid login: $router\n"; catch {close}; catch {wait}; return 1 } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } } set in_proc 0 return 0 } # Enable proc do_enable { enauser enapasswd } { global do_saveconfig in_proc global prompt u_prompt e_prompt enacmd set in_proc 1 send "$enacmd\r" expect { -re "$u_prompt" { send -- "$enauser\r"; exp_continue} -re "$e_prompt" { send -- "$enapasswd\r"; exp_continue} "#" { set prompt "#" } "(enable)" { set prompt "> \\(enable\\) " } "% Invalid input" { send_user "\nError: Unrecognized command, check your enable command\n"; return 1 } -re "(denied|Sorry|Incorrect)" { # % Access denied - from local auth and poss. others send_user "\nError: Check your Enable passwd\n"; return 1 } "% Error in authentication" { send_user "\nError: Check your Enable passwd\n" return 1 } "% Bad passwords" { send_user "\nError: Check your Enable passwd\n" return 1 } } # We set the prompt variable (above) so script files don't need # to know what it is. set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact do_saveconfig in_proc platform set in_proc 1 if { [string compare "extreme" "$platform"] } { # match cisco config mode prompts too, such as router(config-if)#, # but catalyst does not change in this fashion. regsub -lineanchor -- {^(.{1,11}).*([#>])$} $prompt {\1} reprompt regsub -all -- {[\\]$} $reprompt {} reprompt append reprompt {([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} } else { set reprompt $prompt } # this is the only way i see to get rid of more prompts in o/p..grrrrr log_user 0 # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] # the pager can not be turned off on the PIX, so we have to look # for the "More" prompt. the extreme is equally obnoxious in pre-12.3 XOS, # with a global switch in the config. for {set i 0} {$i < $num_commands} { incr i} { send -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "\b+" { exp_continue } -re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)" } -re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)" exp_continue } -re "^--More--\[\r\n]+" { # specific match c1900 pager send " " exp_continue } -re "\[^\r\n]*\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } -re "\[^\r\n]*Press to cont\[^\r\n]*" { send " " # bloody ^[[2K after " " expect { -re "^\[^\r\n]*\r" {} } exp_continue } -re "^ *--More--\[^\n\r]*" { send " " exp_continue } -re "^<-+ More -+>\[^\n\r]*" { send_user -- "$expect_out(buffer)" send " " exp_continue } } } log_user 1 if { $do_interact == 1 } { interact return 0 } if { [string compare "extreme" "$platform"] } { send -h "exit\r" } else { send -h "quit\r" } expect { -re "^\[^\n\r *]*$reprompt" { # the Cisco CE and Jnx ERX # return to non-enabled mode # on exit in enabled mode. send -h "exit\r" exp_continue; } "The system has unsaved changes" { # Force10 SFTOS if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "Would you like to save them now" { # Force10 if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "(Profile|Configuration) changes have occurred.*" { # Cisco CSS if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "Do you wish to save your configuration changes" { if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "\[\n\r]+" { exp_continue } timeout { catch {close}; catch {wait}; return 1 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 set prompt_match "" foreach router [lrange $argv $i end] { set router [string tolower $router] # attempt at platform switching. set platform "" send_user -- "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Default prompt. set prompt [join [find prompt $router] ""] if { [llength $prompt] == 0 } { set prompt "(>|#| \\(enable\\))" } # look for autoenable option in .cloginrc & cmd-line set ae [find autoenable $router] if { "$ae" == "1" || $avautoenable } { set autoenable 1 } else { set autoenable 0 } # look for enable options in .cloginrc & cmd-line if { $avenable == 0 } { set enable 0 } else { set ne [find noenable $router] if { "$ne" == "1" || "$autoenable" == "1" } { set enable 0 } else { set enable 1 } } # Figure out passwords if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 } { send_user -- "\nError: no password for $router in $password_file.\n" continue } if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } { send_user -- "\nError: no enable password for $router in $password_file.\n" continue } if { $do_passwd } { set passwd [join [lindex $pswd 0] ""] } else { set passwd $userpasswd } if { $do_enapasswd } { set enapasswd [join [lindex $pswd 1] ""] } else { set enapasswd $enapasswd } } else { set passwd $userpasswd set enapasswd $enapasswd } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } 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 $ruser } } # Figure out enable command set enacmd [join [find enablecmd $router] ""] if { "$enacmd" == "" } { set enacmd "enable" } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "^(\[Uu]sername|Login|login|user name|User):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+):" } else { set p_prompt [join [lindex $p_prompt 0] ""] } set e_prompt [find enableprompt $router] if { "$e_prompt" == "" } { set e_prompt "\[Pp]assword:" } else { set e_prompt [join [lindex $e_prompt 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 cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} { incr exitval # if login failed or rsh was unsuccessful, move on to the next device continue } # Figure out the prompt. if { [regexp -- "(#| \\(enable\\))" $prompt_match junk] == 1 } { set enable 0 } if { $enable } { if {[do_enable $enauser $enapasswd]} { if { $do_command || $do_script } { incr exitval catch {close}; catch {wait}; continue } } } # we are logged in, now figure out the full prompt send "\r" regsub -all {^(\^*)(.*)} $prompt {\2} reprompt expect { -re "\[\r\n]+" { exp_continue; } -re "^(.+\[:.])1 ($reprompt)" { # stoopid extreme cmd-line numbers and # prompt based on state of config changes, # which may have an * at the beginning. # save the whole prompt to match once below. set lastprompt $expect_out(0,string) regsub -all {[*]} $lastprompt {\\&} lastprompt set junk $expect_out(1,string) regsub -all "^\\\* " $expect_out(1,string) {} junk regsub -all "\[\]\[\(\)]" $junk {\\&} junk; set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)"; set platform "extreme" } -re "^.+$reprompt" { set junk $expect_out(0,string); regsub -all "\[\]\[\(\)+]" $junk {\\&} prompt; } } if { $do_command || $do_script } { if { [string compare "extreme" "$platform"] } { # If the prompt is (enable), then we are on a switch and the # command is "set length 0"; otherwise its "terminal length 0". if [regexp -- ".*> .*enable" "$prompt"] { send "set length 0\r" expect -re $prompt {} send "set width 132\r" expect -re $prompt {} send "set logging session disable\r" } else { send "terminal length 0\r" expect -re $prompt {} send "terminal width 132\r" } expect -re $prompt {} } else { send "disable clipaging\r" expect { -re "^$lastprompt" { # eat weird EXOS >11.0 re-printing of # the first prompt after ssh login so # we do not become out of sync with # the prompts. exp_continue; } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } -re "^$prompt" {} } } } if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { source $sfile catch {close}; } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/tlogin.in000644 015615 000000 00000060306 13657102757 015374 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # The login expect scripts were based on Erik Sherk's gwtn, by permission. # # tlogin - Netopia login # # Modified by Ed Ravin for Netopia. # XXX need to import login_top. # Usage line set usage "Usage: $argv0 \[-diSV\] \[-autoenable\] \[-noenable\] \ \[-c command\] \[-Evar=x\] \[-e enable-password\] \[-f cloginrc-file\] \ \[-p user-password\] \[-s script-file\] \[-t timeout\] \[-u username\] \ \[-V\] \[-v vty-password\] \[-w enable-username\] \[-x command-file\] \ \[-y ssh_cypher_type\] router \[router...\]\n" # env(CLOGIN) may contain: # x == do not set xterm banner or name # Password file set password_file $env(HOME)/.cloginrc # Default is to login to the router set do_command 0 set do_interact 0 set do_script 0 # The default is to automatically enable set avenable 1 # The default is that you login non-enabled (tacacs can have you login already # enabled) 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 set do_enapasswd 1 # Save config, if prompted set do_saveconfig 0 # cloginrc debugging knob set do_cloginrcdbg 0 # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 45 # intialize cloginrc parsing stacks set int_file {} set int_lineno {} # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} # attempt at platform switching. set platform "" # Find the user in the ENV, or use the unix userid. if {[info exists env(CISCO_USER)] } { set default_user $env(CISCO_USER) } elseif {[info exists env(USER)]} { set default_user $env(USER) } elseif {[info exists env(LOGNAME)]} { set default_user $env(LOGNAME) } 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. if [catch {exec id} reason] { send_error "\nError: could not exec id: $reason\n" exit 1 } regexp {\(([^)]*)} "$reason" junk default_user } # Process the command line for {set i 0} {$i < $argc} {incr i} { set arg [lindex $argv $i] switch -glob -- $arg { -d { exp_internal 1 # Username } -u* { if {! [regexp .\[uU\](.+) $arg ignore user]} { incr i set username [lindex $argv $i] } # cloginrc debugging knobs } -m* { set do_cloginrcdbg 1 } -M* { set do_cloginrcdbg 2 # interactive } -i* { set do_interact 1 # VTY Password } -p* { if {! [regexp .\[pP\](.+) $arg ignore userpasswd]} { incr i set userpasswd [lindex $argv $i] } set do_passwd 0 # ssh passphrase } -r* { # ignore -r # VTY Password } -v* { if {! [regexp .\[vV\](.+) $arg ignore passwd]} { incr i set passwd [lindex $argv $i] } set do_passwd 0 # Enable Username } -w* { if {! [regexp .\[wW\](.+) $arg ignore enauser]} { incr i set enausername [lindex $argv $i] } # Environment variable to pass to -s scripts } -E* { if {[regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { set E$varname $varvalue } else { send_user "\nError: invalid format for -E in $arg\n" exit 1 } # Enable Password } -e* { if {! [regexp .\[e\](.+) $arg ignore enapasswd]} { incr i set enapasswd [lindex $argv $i] } set do_enapasswd 0 # Command to run. } -c* { if {! [regexp .\[cC\](.+) $arg ignore command]} { incr i set command [lindex $argv $i] } set do_command 1 # Expect script to run. } -s* { if {! [regexp .\[sS\](.+) $arg ignore sfile]} { incr i set sfile [lindex $argv $i] } if { ! [file readable $sfile] } { send_user "\nError: Can't read $sfile\n" exit 1 } set do_script 1 # save config on exit } -S* { set do_saveconfig 1 # 'ssh -c' cypher type } -y* { if {! [regexp .\[eE\](.+) $arg ignore cypher]} { incr i set cypher [lindex $argv $i] } # alternate cloginrc file } -f* { if {! [regexp .\[fF\](.+) $arg ignore password_file]} { incr i set password_file [lindex $argv $i] } # Timeout } -t* { if {! [regexp .\[tT\](.+) $arg ignore timeout]} { incr i set timeoutdflt [lindex $argv $i] } # Command file } -x* { if {! [regexp .\[xX\](.+) $arg ignore cmd_file]} { incr i set cmd_file [lindex $argv $i] } 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 # Version string } -V* { send_user "@PACKAGE@ @VERSION@\n" exit 0 # Do we enable? } -noenable { set avenable 0 # Does tacacs automatically enable us? } -autoenable { set avautoenable 1 set avenable 0 } -* { send_user "\nError: Unknown argument! $arg\n" send_user $usage exit 1 } default { break } } } # Process routers...no routers listed is an error. if { $i == $argc } { send_user "\nError: $usage" } # Only be quiet if we are running a script (it can log its output # on its own) if { $do_script } { log_user 0 } else { log_user 1 } # # Done configuration/variable setting. Now run with it... # # 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 } } # take host from ENV(TERM) 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" } } } # This is a helper function to make the password file easier to # maintain. Using this the password file has the form: # add password sl* pete cow # add password at* steve # add password * hanky-pie proc add {var args} { global int_file int_lineno int_$var set file [lindex $int_file 0] set lineno [lindex $int_lineno 0] lappend int_$var "$var:$file:$lineno: $args" } proc include {args} { global env regsub -all "(^{|}$)" $args {} args if {[regexp "^/" $args ignore] == 0} { set args $env(HOME)/$args } source_password_file $args } proc find {var router} { global do_cloginrcdbg upvar int_$var list if {[info exists list]} { foreach line $list { if {[string match -nocase [lindex $line 1] $router]} { if {$do_cloginrcdbg > 0} { send_error -- [join [list [lindex $line 0] [lrange $line 1 end] "\r\n"]] } if {$do_cloginrcdbg == 2} { # save return value if {! [info exists result]} { set result [lrange $line 2 end] } } else { return [lrange $line 2 end] } } } } if {$do_cloginrcdbg == 2} { if {[info exists result]} { return $result } } return {} } # Loads the password file. Note that as this file is tcl, and that # it is sourced, the user better know what to put in there, as it # could install more than just password info... I will assume however, # 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 {file} { global env int_file int_lineno if {! [file exists $file]} { send_user "\nError: password file ($file) does not exist\n" exit 1 } file stat $file fileinfo if {[expr ($fileinfo(mode) & 007)] != 0000} { send_user "\nError: $file must not be world readable/writable\n" exit 1 } if [catch {set fd [open $file "r"]} reason] { send_user "\nError: $reason\n" exit 1 } set int_file [linsert $int_file 0 $file] set int_lineno [linsert $int_lineno 0 0] while {[gets $fd line] >= 0} { set tmp [lindex $int_lineno 0]; incr tmp lset int_lineno 0 $tmp eval $line } set int_file [lrange $int_file 1 end] set int_lineno [lrange $int_lineno 1 end] close $fd } # Log into the router. proc login { router user userpswd passwd enapasswd cmethod cyphertype } { global spawn_id in_proc do_command do_script platform global prompt u_prompt p_prompt e_prompt sshcmd telnetcmd usercmd global usercmd_chat otpinuse set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog command suffix port if {"$port" == ""} { set retval [catch {eval spawn [split "$telnetcmd $router"]} reason] } else { set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason] } if { $retval } { send_user "\nError: telnet failed: $reason\n" exit 1 } } elseif [string match "ssh*" $prog] { regexp {ssh(:([^[:space:]]+))*} $prog command suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason] if { $retval } { send_user "\nError: $cmd failed: $reason\n" exit 1 } } elseif [string match "usercmd" $prog] { # user supplies connect cmd set retval [catch {eval spawn $usercmd} reason] if { $retval } { send_user "\nError: '$usercmd' failed: $reason\n" exit 1 } if { [llength $usercmd_chat] > 0 } { #send_user "\nExecuting usercmd_chat: $usercmd_chat\n" sleep 0.3 foreach {i j} $usercmd_chat { expect { -re $i { eval send -- "\"$j\""} timeout { send "\r"; send_user "\nTimeout in usercmd_chat waiting for -re $i: punting with CR\n"; break } } } } } elseif ![string compare $prog "rsh"] { if [catch {spawn rsh -l $user $router} reason] { send_user "\nError: rsh failed: $reason\n" exit 1 } } else { puts "\nError: unknown connection method: $prog" return 1 } incr progs -1 sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; wait if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; wait if {$in_proc} { return 1 } else { continue } } } # Here we get a little tricky. There are several possibilities: # the router can ask for a username and passwd and then # talk to the TACACS server to authenticate you, or if the # TACACS server is not working, then it will use the enable # passwd. Or, the router might not have TACACS turned on, # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { -re "(Connection refused|Secure connection \[^\n\r]+ refused)" { catch {close}; wait if !$progs { send_user "\nError: Connection Refused ($prog): $router\n" return 1 } } -re "(Connection closed by|Connection to \[^\n\r]+ closed)" { catch {close}; 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" { catch {close}; send_user "\nError: Unknown host $router\n"; wait; return 1 } "Host is unreachable" { catch {close}; send_user "\nError: Host Unreachable: $router\n"; wait; return 1 } "No address associated with name" { catch {close}; send_user "\nError: Unknown host $router\n"; wait; return 1 } -re "(Host key not found |The authenticity of host .* be established)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -nocase -re "^warning: remote host denied authentication agent forwarding." { exp_continue; } -re "(denied|Sorry)" { send_user "\nError: Check your passwd for $router\n" catch {close}; wait; return 1 } "Login failed" { send_user "\nError: Check your passwd for $router\n" return 1 } -re "% (Bad passwords|Authentication failed)" { send_user "\nError: Check your passwd for $router\n" return 1 } "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" exp_continue; } -re "Netopia.*always start from this main screen" { # send control-N to escape from the Playskool menu send -- "\x0e" set platform "netopia" set prompt "#" set autoenable 1 return 0 } -re "@\[^\r\n]+ $p_prompt" { # ssh pwd prompt sleep 1 send -- "$userpswd\r" exp_continue } -re "$u_prompt" { send -- "$user\r" set uprompt_seen 1 exp_continue } -re "(s/key|otp-\[0-9a-zA-Z]+) +\[0-9]+ +\[-0-9a-zA-Z]+\[ \r\n]" { if { !$otpinuse} { exp_continue } set challenge $expect_out(0,string) regsub {[ \r\n]$} $challenge {} challenge if [catch {exec otphelper $router "$challenge"} userpswd] { send_error "\nError: login: 'otphelper $router $challenge' failed.\nRun otphelper standalone to diagnose further.\n" exit 1 } exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send -- "$userpswd\r" } else { send -- "$passwd\r" } exp_continue } -re "$prompt" { break; } "Login invalid" { send_user "\nError: Invalid login: $router\n"; catch {close}; wait; return 1 } } } set in_proc 0 return 0 } # Enable proc do_enable { enauser enapasswd } { global prompt in_proc global u_prompt e_prompt global router otpinuse set in_proc 1 send "enable\r" expect { -re "(s/key|otp-\[0-9a-zA-Z]+) +\[0-9]+ +\[-0-9a-zA-Z]+\[ \r\n]" { if { !$otpinuse} { exp_continue } set challenge $expect_out(0,string) regsub {[ \r\n]$} $challenge {} challenge if [catch {exec otphelper $router "$challenge"} enapasswd] { send_error "\nError: enable: 'otphelper $router $challenge' failed.\nRun otphelper standalone to diagnose further.\n" exit 1 } exp_continue } -re "$u_prompt" { send -- "$enauser\r"; exp_continue} -re "$e_prompt" { send -- "$enapasswd\r"; exp_continue} "#" { set prompt "#" } "(enable)" { set prompt "> (enable) " } -re "(denied|Sorry|Incorrect)" { # % Access denied - from local auth and poss. others send_user "\nError: Check your Enable passwd\n"; return 1 } "% Error in authentication" { send_user "\nError: Check your Enable passwd\n" return 1 } "% Bad passwords" { send_user "\nError: Check your Enable passwd\n" return 1 } } # We set the prompt variable (above) so script files don't need # to know what it is. set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact in_proc platform set in_proc 1 # If the prompt is (enable), then we are on a switch and the # command is "set length 0"; otherwise its "term length 0". # skip if its an extreme (since the pager can not be disabled on a # per-vty basis). 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;$command" } elseif { ![string compare "netopia" "$platform"] } { # kludge - should instead skip re-sensing prompt if platform netopia set prompt "#" } else { send "term length 0\r" } # match cisco config mode prompts too, such as router(config-if)# regsub -all {^(.{1,14}).*([#>])$} $prompt {\1} reprompt # escape any parens in the prompt, such as "(enable)" regsub -all {[)(]} $reprompt {\\&} reprompt append reprompt {([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} expect { -re $reprompt {} -re "\[\n\r]+" { exp_continue } } } else { regsub -all "\[)(]" $prompt {\\&} reprompt } # this is the only way i see to get rid of more prompts in o/p..grrrrr log_user 0 # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] # the pager can not be turned off on the PIX, so we have to look # for the "More" prompt. the extreme is equally obnoxious, with a # global switch in the config. for {set i 0} {$i < $num_commands} { incr i} { send -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "\b+" { exp_continue } -re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)" } -re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)" exp_continue } -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } -re "\[^\r\n]*Press to cont\[^\r\n]*" { send " " # bloody ^[[2K after " " expect { -re "^\[^\r\n]*\r" {} } exp_continue } -re "^ *--More--\[^\n\r]*" { send " " exp_continue } -re "^<-+ More -+>\[^\n\r]*" { send_user -- "$expect_out(buffer)" send " " exp_continue } } } log_user 1 if { $do_interact == 1 } { interact return 0 } if { [string compare "extreme" "$platform"] } { send "exit\r" } else { send "quit\r" } expect { -re "^\[^\n\r *]*$reprompt" { # the Cisco CE and Jnx ERX # return to non-enabled mode # on exit in enabled mode. send "exit\r" exp_continue; } "Do you wish to save your configuration changes" { send "n\r" exp_continue } -re "\[\n\r]+" { exp_continue } timeout { close; return 0 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 foreach router [lrange $argv $i end] { set router [string tolower $router] send_user "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Figure out prompt. # Since autoenable is off by default, if we have it defined, it # was done on the command line. If it is not specifically set on the # command line, check the password file. if $avautoenable { set autoenable 1 set enable 0 set prompt "(#| \\(enable\\))" } else { set ae [find autoenable $router] if { "$ae" == "1" } { set autoenable 1 set enable 0 set prompt "(#| \\(enable\\))" } else { set autoenable 0 set enable $avenable set prompt ">" } } # look for noenable option in .cloginrc if { [find noenable $router] == "1" } { set enable 0 } # is OTP in use? If so, bypass password checks set otpinuse 0 if { [find otp_secret $router] != "" } { set otpinuse 1 } # Figure out passwords if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 && !$otpinuse} { send_user -- "\nError: no password for $router in $password_file.\n" continue } if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 && !$otpinuse } { send_user -- "\nError: no enable password for $router in $password_file.\n" continue } if { $do_passwd } { set passwd [join [lindex $pswd 0] ""] } else { set passwd $userpasswd } if { $do_enapasswd } { set enapasswd [join [lindex $pswd 1] ""] } else { set enapasswd $enapasswd } } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } 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 $ruser } } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(Username|Login|login|user name|name):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "(\[Pp]assword|passwd):" } else { set p_prompt [join [lindex $p_prompt 0] ""] } set e_prompt [find enableprompt $router] if { "$e_prompt" == "" } { set e_prompt "\[Pp]assword:" } else { set e_prompt [join [lindex $e_prompt 0] ""] } # Figure out cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # If user provides a router-specific connection method, use it set usercmd [find usercmd $router] set usercmd_chat [find usercmd_chat $router] # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype]} { continue } if { $enable } { if {[do_enable $enauser $enapasswd]} { if { $do_command || $do_script } { close; wait continue } } } # we are logged in, now figure out the full prompt send "\r" expect { -re "\[\r\n]+" { exp_continue; } -re "^(.+:)1 $prompt" { # stoopid extreme cmd-line numbers and # prompt based on state of config changes, # which may have an * at the beginning. set junk $expect_out(1,string) regsub -all "^\\\* " $expect_out(1,string) {} junk set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)"; 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; } } if { $do_command } { if {[run_commands $prompt $command]} { continue } } elseif { $do_script } { # If the prompt is (enable), then we are on a switch and the # command is "set length 0"; otherwise its "term length 0". if [regexp -- ".*> .*enable" "$prompt"] { send "set length 0\r" send "set logging session disable\r" } elseif { ![string compare "netopia" "$platform"] } { # do nothing } else { send "term length 0\r" } expect -re $prompt {} source $sfile close } else { label $router log_user 1 interact } # End of for each router wait sleep 0.3 } exit 0 rancid-3.13/bin/xilogin.in000644 015615 000000 00000057010 13657102757 015547 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # xilogin - Xirrus & Hauwei RVP login # # Most options are intuitive for logging into a Xirrus array. # The default is to not enable. # # XXX need to import login_top. # Usage line set usage "Usage: $argv0 \[-diSV\] \[-autoenable\] \[-noenable\] \ \[-c command\] \[-Evar=x\] \[-e enable-password\] \[-f cloginrc-file\] \ \[-p user-password\] \[-r passphrase\] \[-s script-file\] \[-t timeout\] \ \[-u username\] \[-v vty-password\] \[-w enable-username\] \[-x command-file\] \ \[-y ssh_cypher_type\] router \[router...\]\n" # env(CLOGIN) may contain: # x == do not set xterm banner or name # Password file set password_file $env(HOME)/.cloginrc # Default is to login to the router set do_command 0 set do_interact 0 set do_script 0 # The default is to automatically enable set avenable 1 # The default is that you login non-enabled (tacacs can have you login already # enabled) 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 set do_enapasswd 1 # Save config, if prompted set do_saveconfig 0 # cloginrc debugging knob set do_cloginrcdbg 0 # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 45 # intialize cloginrc parsing stacks set int_file {} set int_lineno {} # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} # Find the user in the ENV, or use the unix userid. if {[info exists env(CISCO_USER)]} { set default_user $env(CISCO_USER) } elseif {[info exists env(USER)]} { set default_user $env(USER) } elseif {[info exists env(LOGNAME)]} { set default_user $env(LOGNAME) } 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. if [catch {exec id} reason] { send_error "\nError: could not exec id: $reason\n" exit 1 } regexp {\(([^)]*)} "$reason" junk default_user } if {[info exists env(CLOGINRC)]} { set password_file $env(CLOGINRC) } # Process the command line for {set i 0} {$i < $argc} {incr i} { set arg [lindex $argv $i] switch -glob -- $arg { # Expect debug mode -d* { exp_internal 1 # Username } -u* { if {! [regexp .\[uU\](.+) $arg ignore user]} { incr i set username [lindex $argv $i] } # cloginrc debugging knobs } -m* { set do_cloginrcdbg 1 } -M* { set do_cloginrcdbg 2 # interactive } -i* { set do_interact 1 # VTY Password } -p* { if {! [regexp .\[pP\](.+) $arg ignore userpasswd]} { incr i set userpasswd [lindex $argv $i] } set do_passwd 0 # cloginrc debugging knobs } -m* { set do_cloginrcdbg 1 } -M* { set do_cloginrcdbg 2 # ssh passphrase } -r* { if {! [regexp .\[rR\](.+) $arg ignore passphrase]} { incr i set vapassphrase [lindex $argv $i] } # VTY Password } -v* { if {! [regexp .\[vV\](.+) $arg ignore passwd]} { incr i set passwd [lindex $argv $i] } set do_passwd 0 # Version string } -V* { send_user "@PACKAGE@ @VERSION@\n"; exit 0 # Enable Username } -w* { if {! [regexp .\[wW\](.+) $arg ignore enauser]} { incr i set enausername [lindex $argv $i] } # Environment variable to pass to -s scripts } -E* { if {[regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { set E$varname $varvalue } else { send_user "\nError: invalid format for -E in $arg\n" exit 1 } # Enable Password } -e* { if {! [regexp .\[e\](.+) $arg ignore enapasswd]} { incr i set enapasswd [lindex $argv $i] } set do_enapasswd 0 # Command to run. } -c* { if {! [regexp .\[cC\](.+) $arg ignore command]} { incr i set command [lindex $argv $i] } set do_command 1 # Expect script to run. } -s* { if {! [regexp .\[sS\](.+) $arg ignore sfile]} { incr i set sfile [lindex $argv $i] } if { ! [file readable $sfile] } { send_user "\nError: Can't read $sfile\n" exit 1 } set do_script 1 # save config on exit } -S* { set do_saveconfig 1 # 'ssh -c' cypher type } -y* { if {! [regexp .\[eE\](.+) $arg ignore cypher]} { incr i set cypher [lindex $argv $i] } # alternate cloginrc file } -f* { if {! [regexp .\[fF\](.+) $arg ignore password_file]} { incr i set password_file [lindex $argv $i] } # Timeout } -t* { if {! [regexp .\[tT\](.+) $arg ignore timeout]} { incr i set timeoutdflt [lindex $argv $i] } # Command file } -x* { if {! [regexp .\[xX\](.+) $arg ignore cmd_file]} { incr i set cmd_file [lindex $argv $i] } 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 # Do we enable? } -noenable { set avenable 0 # Does tacacs automatically enable us? } -autoenable { set avautoenable 1 set avenable 0 } -* { send_user "\nError: Unknown argument! $arg\n" send_user $usage exit 1 } default { break } } } # Process routers...no routers listed is an error. if { $i == $argc } { send_user "\nError: $usage" } # Only be quiet if we are running a script (it can log its output # on its own) if { $do_script } { log_user 0 } else { log_user 1 } # # Done configuration/variable setting. Now run with it... # # 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 } } # take host from ENV(TERM) 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" } } } # This is a helper function to make the password file easier to # maintain. Using this the password file has the form: # add password sl* pete cow # add password at* steve # add password * hanky-pie proc add {var args} { global int_file int_lineno int_$var set file [lindex $int_file 0] set lineno [lindex $int_lineno 0] lappend int_$var "$var:$file:$lineno: $args" } proc include {args} { global env regsub -all "(^{|}$)" $args {} args if {[regexp "^/" $args ignore] == 0} { set args $env(HOME)/$args } source_password_file $args } proc find {var router} { global do_cloginrcdbg upvar int_$var list if {[info exists list]} { foreach line $list { if {[string match -nocase [lindex $line 1] $router]} { if {$do_cloginrcdbg > 0} { send_error -- [join [list [lindex $line 0] [lrange $line 1 end] "\r\n"]] } if {$do_cloginrcdbg == 2} { # save return value if {! [info exists result]} { set result [lrange $line 2 end] } } else { return [lrange $line 2 end] } } } } if {$do_cloginrcdbg == 2} { if {[info exists result]} { return $result } } return {} } # Loads the password file. Note that as this file is tcl, and that # it is sourced, the user better know what to put in there, as it # could install more than just password info... I will assume however, # 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 {file} { global env int_file int_lineno if {! [file exists $file]} { send_user "\nError: password file ($file) does not exist\n" exit 1 } file stat $file fileinfo if {[expr ($fileinfo(mode) & 007)] != 0000} { send_user "\nError: $file must not be world readable/writable\n" exit 1 } if [catch {set fd [open $file "r"]} reason] { send_user "\nError: $reason\n" exit 1 } set int_file [linsert $int_file 0 $file] set int_lineno [linsert $int_lineno 0 0] while {[gets $fd line] >= 0} { set tmp [lindex $int_lineno 0]; incr tmp lset int_lineno 0 $tmp eval $line } set int_file [lrange $int_file 1 end] set int_lineno [lrange $int_lineno 1 end] close $fd } # Log into the router. # returns: 0 on success, 1 on failure, -1 if rsh was used successfully proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } { global command spawn_id in_proc do_command do_script passphrase global platform prompt u_prompt p_prompt sshcmd telnetcmd set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port if {"$port" == ""} { set retval [catch {eval spawn [split "$telnetcmd $router"]} reason] } else { set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason] } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif [string match "ssh*" $prog] { # ssh to the router & try to login with or without an identfile. regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } if {"$identfile" != ""} { set cmd "$cmd -i $identfile" } set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason] if { $retval } { send_user "\nError: $cmd failed: $reason\n" return 1 } } elseif ![string compare $prog "rsh"] { if { ! $do_command } { if { [llength $cmethod] == 1 } { send_user "\nError: rsh is an invalid method for -x and " send_user "interactive logins\n" } if { $progs == 0 } { return 1 } continue; } # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] set rshfail 0 for {set i 0} {$i < $num_commands && !$rshfail} { incr i} { log_user 0 set retval [catch {spawn rsh $user@$router [lindex $commands $i] } reason] if { $retval } { send_user "\nError: rsh failed: $reason\n" log_user 1; return 1 } send_user "$router# [lindex $commands $i]\n" # rcmd does not get a pager and no prompts, so we just have to # look for failures & lines. expect { "Connection refused" { catch {close}; catch {wait}; send_user "\nError: Connection\ Refused ($prog): $router\n" set rshfail 1 } -re "(Connection closed by|Connection to \[^\n\r]+ closed)" { catch {close}; catch {wait}; send_user "\nError: Connection\ closed ($prog): $router\n" set rshfail 1 } "Host is unreachable" { catch {close}; catch {wait}; send_user "\nError: Host Unreachable:\ $router\n" set rshfail 1 } "No address associated with" { catch {close}; catch {wait}; send_user "\nError: Unknown host\ $router\n" set rshfail 1 } -re "\b+" { exp_continue } -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } timeout { catch {close}; catch {wait}; send_user "\nError: TIMEOUT reached\n" set rshfail 1 } eof { catch {close}; catch {wait}; } } log_user 1 } if { $rshfail } { if { !$progs } { return 1 } else { continue } } # fake the end of the session for rancid. send_user "$router# exit\n" # return rsh "success" return -1 } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } # Here we get a little tricky. There are several possibilities: # the router can ask for a username and passwd and then # talk to the TACACS server to authenticate you, or if the # TACACS server is not working, then it will use the enable # passwd. Or, the router might not have TACACS turned on, # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { -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 } "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)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -nocase -re "^warning: remote host denied authentication agent forwarding." { exp_continue; } -nocase -re "^warning:" { exp_continue } -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 "% (Bad passwords|Authentication failed)" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } "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" exp_continue } -nocase -re "(Welcome to ARCOS CLI|Linux arcos \[^\r\n]*)\[\r\n]+" { set platform "arcos" exp_continue } -re "Last login:\[^\r\n]*\[\r\n]+" { exp_continue } -re "@\[^\r\n]+ $p_prompt" { # ssh pwd prompt sleep 1 send -- "$userpswd\r" exp_continue } -re "Enter passphrase.*: " { # sleep briefly to allow time for stty -echo sleep .3 send -- "$passphrase\r" exp_continue } -re "$u_prompt" { send -- "$user\r" set uprompt_seen 1 exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send -- "$userpswd\r" } else { send -- "$passwd\r" } exp_continue } -re "$prompt" { break; } "Login invalid" { send_user "\nError: Invalid login: $router\n"; catch {close}; catch {wait}; return 1 } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } } set in_proc 0 return 0 } # New subroutine to provide "login" command capabilities, using the enable user and enable password # Login proc do_login { enauser enapasswd } { global prompt in_proc global u_prompt set in_proc 1 send "login\r" expect { -re "$u_prompt" { send "$enauser\r"; exp_continue} "#" { set prompt "#" } "(login)" { set prompt "> (login) " } -re "(denied|Sorry|Incorrect)" { # % Access denied - from local auth and poss. others send_user "\nError: Check your Login passwd\n"; return 1 } "% Error in authentication" { send_user "\nError: Check your Login passwd\n" return 1 } "% Bad passwords" { send_user "\nError: Check your Login passwd\n" return 1 } } # We set the prompt variable (above) so script files don't need # to know what it is. set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact do_saveconfig in_proc set in_proc 1 # Disable paging send "\r" # escape any parens in the prompt, such as "(enable)" regsub -all {[)(]} $prompt {\\&} reprompt expect { -re $reprompt {} -re "\[\n\r]+" { exp_continue } } # this is the only way i see to get rid of more prompts in o/p..grrrrr log_user 0 # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] # the pager can not be turned off on the PIX, so we have to look # for the "More" prompt. the extreme is equally obnoxious, with a # global switch in the config. for {set i 0} {$i < $num_commands} { incr i} { send -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "\b+" { exp_continue } -re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)" } -re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)" exp_continue } -re "^--MORE--\[\r\n]+" { # match Xirrus pager send " " exp_continue } -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } } } log_user 1 if { $do_interact == 1 } { interact return 0 } send -h "quit\r" expect { "Do you want to save changes to flash" { # Xirrus if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "\[\n\r]+" { exp_continue } timeout { catch {close}; catch {wait}; return 0 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 set platform "unknown" foreach router [lrange $argv $i end] { set router [string tolower $router] send_user -- "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Default prompt. set prompt "(>|#)" # Figure out passwords if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 } { send_user -- "\nError: no password for $router in $password_file.\n" continue } if { $do_passwd } { set passwd [join [lindex $pswd 0] ""] } else { set passwd $userpasswd } if { $do_enapasswd } { set enapasswd [join [lindex $pswd 1] ""] } else { set enapasswd $enapasswd } } else { set passwd $userpasswd set enapasswd $enapasswd } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } else { set userpswd [join [find userpassword $router] ""] if { "$userpswd" == "" } { set userpswd $passwd } } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(Username|Login|login|user name|User):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+):" } else { set p_prompt [join [lindex $p_prompt 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 cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} { incr exitval # if login failed or rsh was unsuccessful, move on to the next device continue } # we are logged in, now figure out the full prompt send "\r" expect { -re "\[\r\n]+" { exp_continue; } -re "^.+$prompt" { set junk $expect_out(0,string); regsub -all "\[\]\[\(\)]" $junk {\\&} prompt; } } if { $do_command || $do_script } { if { "$platform" == "arcos" } { # Arrcus paging send "screen-length 0\r" expect -re $prompt {} send "screen-width 132\r" expect -re $prompt {} } else { # Hauwei paging send "screen-length 0 temporary\r" expect -re $prompt {} # Disable paging send "more off\r" expect -re $prompt {} # Disable command auto-completion on Xirus send "auto-complete off \r" expect { -re $prompt {} -re "\[\n\r]+" { exp_continue } } } } if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { source $sfile catch {close}; } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/plogin.in000644 015615 000000 00000010670 13477565230 015366 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # plogin - poly-login; use router.db files and rancid.{base,types}.conf # configurations to determine which login script to execute. # use 5.0010; use strict 'vars'; use warnings; no warnings 'uninitialized'; use Exporter; use Getopt::Long; # use Getopt::Long qw(:config no_ignore_case bundling); Getopt::Long::Configure ("bundling", "no_ignore_case"); our($opt_d, $opt_S, $opt_V, $opt_autoenable, $opt_noenable, $opt_c, @opt_E, $opt_e, $opt_f, $opt_h, $opt_i, $opt_m, $opt_M, $opt_p, $opt_r, $opt_s, $opt_t, $opt_u, $opt_v, $opt_w, $opt_x, $opt_y, $opt_z); GetOptions('d' => \$opt_d, 'S' => \$opt_S, 'V' => \$opt_V, 'autoenable' => \$opt_autoenable, 'noenable' => \$opt_noenable, 'c=s' => \$opt_c, "E=s@" => \@opt_E, 'e=s' => \$opt_e, 'f=s' => \$opt_f, 'h' => \$opt_h, 'i' => \$opt_i, 'm' => \$opt_m, 'M' => \$opt_M, 'p=s' => \$opt_p, 'r=s' => \$opt_r, 's=s' => \$opt_s, 't=s' => \$opt_t, 'u=s' => \$opt_u, 'v=s' => \$opt_v, 'w=s' => \$opt_w, 'x=s' => \$opt_x, 'y=s' => \$opt_y, 'z=s' => \$opt_z); my($BASEDIR, $LIST_OF_GROUPS, $cmd, $i, $j, @routers); BEGIN { push(@INC, "@pkglibdir@"); } use rancid; our @ISA = qw(Exporter rancid); sub usage() { print STDERR "plogin [-dSV] [-autoenable] [-noenable] [-c command] [-Evar=x] [-e enable-password] [-f cloginrc-file] [-p user-password] [-r passphrase] [-s script-file] [-t timeout] [-u username] [-v vty-password] [-w enable-username] [-x command-file] [-y ssh_cypher_type] [-z device_type] router [router...]\n"; exit 64; } # make OUTPUT unbuffered if debugging if ($opt_d) { $| = 1; } if ($opt_h) { usage(); } # option handling initialization if ($opt_V) { print "plogin: @PACKAGE@ @VERSION@\n"; # do not exit; exec the script with -V and it will exit } $cmd .= " -d" if ($opt_d); $cmd .= " -i" if ($opt_i); $cmd .= " -m" if ($opt_m); $cmd .= " -M" if ($opt_M); $cmd .= " -S" if ($opt_S); $cmd .= " -V" if ($opt_V); $cmd .= " -autoenable" if ($opt_autoenable); $cmd .= " -noenable" if ($opt_noenable); $cmd .= " -c '$opt_c'" if (length($opt_c)); foreach $i (@opt_E) { $cmd .= " -E$i"; } $cmd .= " -e '$opt_e'" if (length($opt_e)); $cmd .= " -f '$opt_f'" if (length($opt_f)); $cmd .= " -p '$opt_p'" if (length($opt_p)); $cmd .= " -r '$opt_r'" if (length($opt_r)); $cmd .= " -s '$opt_s'" if (length($opt_s)); $cmd .= " -t $opt_s" if (length($opt_t)); $cmd .= " -u '$opt_u'" if (length($opt_u)); $cmd .= " -v '$opt_v'" if (length($opt_v)); $cmd .= " -w '$opt_w'" if (length($opt_w)); $cmd .= " -x '$opt_x'" if (length($opt_x)); $cmd .= " -y '$opt_y'" if (length($opt_y)); $devtype = $opt_z; foreach $i (@ARGV) { $cmd .= " $i"; push(@routers, $i); } # what is the device type, supplied or looked-up if ($opt_z) { $devtype = $opt_z; } else { # Look in router.dbs for device type. # read rancid.conf for BASEDIR and LIST_OF_GROUPS? my($ENVFILE) = "@sysconfdir@/rancid.conf"; open(INPUT, "< $ENVFILE") || die "Could not open $ENVFILE: $!"; close(INPUT); open(INPUT, "sh -c \'. $ENVFILE; echo \"BASEDIR=\$BASEDIR\"; echo \"LIST_OF_GROUPS=\$LIST_OF_GROUPS\"\' |") || die "Could not open $ENVFILE: $!"; while () { chomp; s/#.$//; s/^\s+//; my($varname, $value) = split('='); if ($varname eq "BASEDIR") { $BASEDIR = $value; } if ($varname eq "LIST_OF_GROUPS") { $LIST_OF_GROUPS = $value; $LIST_OF_GROUPS =~ s/^\s+//; $LIST_OF_GROUPS =~ s/\s+$//; } } close(INPUT); # read each router.db for the routername and thus the devtype foreach $i (split(/\s+/, $LIST_OF_GROUPS)) { if (!open(INPUT, "< $BASEDIR/$i/router.db")) { warn "Could not open $BASEDIR/$i/router.db: $!"; next; } while () { chomp; s/#.$//; s/^\s+//; my($router, $type, $state) = split('\;'); foreach $j (@routers) { if ($router eq $j) { $devtype = $type; close(INPUT); goto FOUND; } } } close(INPUT); } } FOUND: if (length($devtype) < 1) { die "Couldn't find device type by hostname in router.dbs\n"; } # load device type spec, build @commandtable and load modules if (loadtype($devtype)) { die "Couldn't load device type spec for $rancid::devtype\n"; } if (! defined($lscript)) { die "login script not defined for device type $rancid::devtype\n"; } exec($lscript . " $cmd") || printf(STDERR "exec($lscript) failed router manufacturer $devtype: $!\n"); exit(-1); rancid-3.13/bin/htlogin.in000644 015615 000000 00000033662 13477565572 015561 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # htlogin - Hitachi router login # # Most options are intuitive for logging into an Hitachi router login. # # XXX need to import login_top. # Usage line set usage "Usage: $argv0 \[-diSV\] \[-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\] \ \[-y ssh_cypher_type\] router \[router...\]\n" # env(CLOGIN) may contain: # x == do not set xterm banner or name # Password file set password_file $env(HOME)/.cloginrc # Default is to login to the router set do_command 0 set do_interact 0 set do_script 0 # The default is to automatically enable set avenable 1 # The default is that you login non-enabled (tacacs can have you login already # enabled) 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 # cloginrc debugging knob set do_cloginrcdbg 0 # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 45 # intialize cloginrc parsing stacks set int_file {} set int_lineno {} # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} # Find the user in the ENV, or use the unix userid. if {[ info exists env(CISCO_USER) ]} { set default_user $env(CISCO_USER) } elseif {[ info exists env(USER) ]} { set default_user $env(USER) } elseif {[ info exists env(LOGNAME) ]} { set default_user $env(LOGNAME) } 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. if [ catch {exec id} reason ] { send_error "\nError: could not exec id: $reason\n" exit 1 } regexp {\(([^)]*)} "$reason" junk default_user } if {[ info exists env(CLOGINRC) ]} { set password_file $env(CLOGINRC) } # Process the command line for {set i 0} {$i < $argc} {incr i} { set arg [lindex $argv $i] switch -glob -- $arg { # Expect debug mode -d* { exp_internal 1 # Username } -u* { if {! [ regexp .\[uU\](.+) $arg ignore user]} { incr i set username [ lindex $argv $i ] } # cloginrc debugging knobs } -m* { set do_cloginrcdbg 1 } -M* { set do_cloginrcdbg 2 # interactive } -i* { set do_interact 1 # VTY Password } -p* { if {! [ regexp .\[pP\](.+) $arg ignore userpasswd]} { incr i set userpasswd [ lindex $argv $i ] } set do_passwd 0 # ssh passphrase } -r* { # ignore -r # VTY Password } -v* { if {! [ regexp .\[vV\](.+) $arg ignore passwd]} { incr i set passwd [ lindex $argv $i ] } set do_passwd 0 # Version string } -V* { send_user "@PACKAGE@ @VERSION@\n" exit 0 # Enable Username } -w* { # ignore -w # 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 } # Enable Password } -e* { # ignore -e # Command to run. } -c* { if {! [ regexp .\[cC\](.+) $arg ignore command]} { incr i set command [ lindex $argv $i ] } set do_command 1 # Expect script to run. } -s* { if {! [ regexp .\[sS\](.+) $arg ignore sfile]} { incr i set sfile [ lindex $argv $i ] } if { ! [ file readable $sfile ] } { send_user "\nError: Can't read $sfile\n" exit 1 } set do_script 1 # save config on exit } -S* { set do_saveconfig 1 # 'ssh -c' cypher type } -y* { if {! [ regexp .\[eE\](.+) $arg ignore cypher]} { incr i set cypher [ lindex $argv $i ] } # alternate cloginrc file } -f* { if {! [ regexp .\[fF\](.+) $arg ignore password_file]} { incr i set password_file [ lindex $argv $i ] } # Timeout } -t* { if {! [ regexp .\[tT\](.+) $arg ignore timeout]} { incr i set timeoutdflt [ lindex $argv $i ] } # Command file } -x* { if {! [ regexp .\[xX\](.+) $arg ignore cmd_file]} { incr i set cmd_file [ lindex $argv $i ] } 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 # Do we enable? } -noenable { # ignore -noenable # Does tacacs automatically enable us? } -autoenable { # ignore -autoenable } -* { send_user "\nError: Unknown argument! $arg\n" send_user $usage exit 1 } default { break } } } # Process routers...no routers listed is an error. if { $i == $argc } { send_user "\nError: $usage" } # Only be quiet if we are running a script (it can log its output # on its own) if { $do_script } { log_user 0 } else { log_user 1 } # # Done configuration/variable setting. Now run with it... # # 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 } } # take host from ENV(TERM) 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" } } } # This is a helper function to make the password file easier to # maintain. Using this the password file has the form: # add password sl* pete cow # add password at* steve # add password * hanky-pie proc add {var args} { global int_file int_lineno int_$var set file [lindex $int_file 0] set lineno [lindex $int_lineno 0] lappend int_$var "$var:$file:$lineno: $args" } proc include {args} { global env regsub -all "(^{|}$)" $args {} args if {[regexp "^/" $args ignore] == 0} { set args $env(HOME)/$args } source_password_file $args } proc find {var router} { global do_cloginrcdbg upvar int_$var list if {[info exists list]} { foreach line $list { if {[string match -nocase [lindex $line 1] $router]} { if {$do_cloginrcdbg > 0} { send_error -- [join [list [lindex $line 0] [lrange $line 1 end] "\r\n"]] } if {$do_cloginrcdbg == 2} { # save return value if {! [info exists result]} { set result [lrange $line 2 end] } } else { return [lrange $line 2 end] } } } } if {$do_cloginrcdbg == 2} { if {[info exists result]} { return $result } } return {} } # Loads the password file. Note that as this file is tcl, and that # it is sourced, the user better know what to put in there, as it # could install more than just password info... I will assume however, # 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 {file} { global env int_file int_lineno if {! [file exists $file]} { send_user "\nError: password file ($file) does not exist\n" exit 1 } file stat $file fileinfo if {[expr ($fileinfo(mode) & 007)] != 0000} { send_user "\nError: $file must not be world readable/writable\n" exit 1 } if [catch {set fd [open $file "r"]} reason] { send_user "\nError: $reason\n" exit 1 } set int_file [linsert $int_file 0 $file] set int_lineno [linsert $int_lineno 0 0] while {[gets $fd line] >= 0} { set tmp [lindex $int_lineno 0]; incr tmp lset int_lineno 0 $tmp eval $line } set int_file [lrange $int_file 1 end] set int_lineno [lrange $int_lineno 1 end] close $fd } # Log into the router. # returns: 0 on success, 1 on failure proc login { router user userpswd passwd prompt cmethod cyphertype } { global spawn_id in_proc do_command do_script global u_prompt p_prompt telnetcmd set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog command suffix port if {"$port" == ""} { set retval [ catch {eval spawn [split "$telnetcmd $router"]} reason ] } else { set retval [ catch {eval spawn [split "$telnetcmd $router $port"]} reason ] } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif ![string compare $prog "ssh"] { send_error "\nError: unsupported method: ssh\n" if { $progs == 0 } { return 1 } continue } elseif ![string compare $prog "rsh"] { send_error "\nError: unsupported method: rsh\n" if { $progs == 0 } { return 1 } continue } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } expect { "Connection refused" { catch {close}; catch {wait}; 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 } "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 "$u_prompt" { send -- "$user\r" set uprompt_seen 1 exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send -- "$userpswd\r" } else { send -- "$passwd\r" } exp_continue } "Password incorrect" { send_user "\nError: Check your password for $router\n"; catch {close}; catch {wait}; return 1 } "$prompt" { break; } denied { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } "\r\n" { exp_continue; } } } set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact in_proc set in_proc 1 # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] for {set i 0} {$i < $num_commands} { incr i} { send -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "^\[^\n\r]*$prompt" {} -re "^\[^\n\r *]*$prompt" {} -re "\[\n\r]" { exp_continue } } } if { $do_interact == 1 } { interact return 0 } send "exit\r" expect { "\n" { exp_continue } timeout { catch {close}; catch {wait}; return 0 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 foreach router [lrange $argv $i end] { set router [string tolower $router] send_user "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Figure out prompt. set prompt "command: " set autoenable 1 set enable 0 # 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] ""] } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } else { set userpswd [join [find userpassword $router] ""] if { "$userpswd" == "" } { set userpswd $passwd } } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(Username|login| Login):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "\[Pp]assword:" } else { set p_prompt [join [lindex $p_prompt 0] ""] } # Figure out cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet}} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $prompt $cmethod $cyphertype]} { incr exitval continue } if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { source $sfile catch {close}; } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/lgform.cgi.in000644 015615 000000 00000020445 13713052202 016105 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # The original original lookingglass s/w was written by Ed Kern. It was # a single script that used to be available at http://nitrous.digex.net/. # Provided by permission and modified beyond recognition. # # 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 POSIX qw(strftime); use Sys::Syslog; my(@rtrlist, %rtrlabels); my($BASEDIR) = "@prefix@"; my($SYSCONFDIR) = "@sysconfdir@"; my($LOCALSTATEDIR) = "@localstatedir@"; my($cache_dir); my($LG_CACHE_DIR, $LG_CLOGINRC, $LG_IMAGE, $LG_INFO, $LG_LOG, $LG_ROUTERDB); my($LG_AS_REG, $LG_BGP_RT, $LG_CACHE_TIME, $LG_SINGLE, $LG_STRIP); # 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. # it is just easier to be self-contained. # SO, ANY CHANGES HERE SHOULD BE REFLECTED IN THE OTHER .cgi. # logging sub dolog { my($level, $msg) = @_; if (defined($LG_LOG) && $LG_LOG !~ /\//) { openlog($me, "pid", $LG_LOG); syslog($level, "%s", $msg); closelog; } else { local(*LOG); my($file); if (defined($LG_LOG)) { $file = $LG_LOG; } else { $file = "$cache_dir/lg.log"; } # log date, hostname, query, addr if (open(LOG, ">>$file") == 0) { # stderr, if all else fails printf(STDERR "[" . strftime("%a %b %e %H:%M:%S %Y", gmtime) . "] could not open log file $file: $!\n"); printf(STDERR $msg); } else { printf(LOG $msg); close(LOG); } } return; } # read LG configuration file sub readconf { my($conffile, $cmds); local(*CONF); if (defined($ENV{LG_CONF})) { $conffile = $ENV{LG_CONF}; } elsif (-e "lg.conf") { $conffile = "lg.conf"; } else { $conffile = "$SYSCONFDIR/lg.conf"; } if (! -f $conffile) { return; } if (open(CONF, "< $conffile")) { while () { next if (/^\s*(#|$)/); $cmds .= $_; } close(CONF); eval $cmds; } else { printf(STDERR "ERROR: couldn\'t open the configuration file: " . "$conffile: $!\n"); exit(1); } return; } # read router.db file sub readrouters { my($rtrdb); local(*RTR); if (defined($LG_ROUTERDB)) { $rtrdb = $LG_ROUTERDB; } else { $rtrdb = "$SYSCONFDIR/router.db"; } if (! -f $rtrdb) { my(@dirs, $dir); # 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, $LOCALSTATEDIR)) { dolog(LOG_ERR, "ERROR: couldn\'t read $LOCALSTATEDIR: $!\n"); } else { while ($dir = readdir(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, "$LOCALSTATEDIR/$dir")) { dolog(LOG_ERR, "ERROR: couldn\'t read $LOCALSTATEDIR/$dir: $!\n"); next; } closedir(DIR); next if (! -f "$LOCALSTATEDIR/$dir/router.db"); if (open(RTR, "< $LOCALSTATEDIR/$dir/router.db")) { while () { next if (/^\s*(#|$)/); # fqdn;mfg;state @record = split('\;', $_); next if ($record[2] !~ /up/i || $record[1] !~ /(cisco|foundry|juniper)/); push(@rtrlist, join(':', ($record[0], $record[1]))); $rtrlabels{join(':', ($record[0], $record[1]))} = $record[0]; } close(RTR); } else { dolog(LOG_ERR, "ERROR: couldn\'t open the router.db " . "file: $LOCALSTATEDIR/$dir/router.db: $!\n"); } } } } else { if (open(RTR, "< $rtrdb")) { while () { next if (/^\s*(#|$)/); # fqdn;mfg;state @record = split('\;', $_); next if ($record[2] !~ /up/i || $record[1] !~ /(cisco|foundry|juniper)/); push(@rtrlist, join(':', ($record[0], $record[1]))); $rtrlabels{join(':', ($record[0], $record[1]))} = $record[0]; } close(RTR); } else { dolog(LOG_ERR, "ERROR: couldn\'t open the router.db file: " . "$rtrdb: $!\n"); exit(1); } } return; } # Main() # read the configuration file if it exists. readconf(); # The script will now cache the results as simple files in the $cache_dir, # named after the type of query (queries must, of course, be one word with # no spaces). Modify $LG_CACHE_TIME to set the lifetime for cache entries. # for most web servers, cache_dir must be writable by uid nobody if (defined($LG_CACHE_DIR)) { $cache_dir = $LG_CACHE_DIR; } else { $cache_dir = "./tmp"; } $query = new CGI; print $query->header; if ($LG_STYLE) { print $query->start_html(-title =>"LookingGlass form", -style => {'src' => $LG_STYLE}); } else { print $query->start_html(-title =>"LookingGlass form"); } # add the company image, LG_IMAGE print $LG_IMAGE; print < Looking Glass

HEAD # start table, etc here print $query->start_form( -action => 'lg.cgi', -method => 'POST'); print < DOTABLE # available query types here print <
Query: Router:
TABLEHEAD foreach $sub_type (sort keys(%$queries)) { next if (! scalar(%{$queries->{$sub_type}})); print $query->radio_group(-name => 'query', -values => $queries->{$sub_type}, -default => '-', -linebreak => 'true'); print "\n" . $query->hr . "\n"; } print <Argument(s):

QTYPES # read routers table and create the scrolling list readrouters(); print $query->scrolling_list(-name => 'router', -values => \@rtrlist, -size => 20, -labels => \%rtrlabels); # end print <

TABLEEND print $query->submit(-name => 'submit', -value =>'Submit'); print $query->reset; print $query->end_form; print <
Looking Glass notes

$LG_INFO TAIL print $query->end_html; exit(0); rancid-3.13/bin/cssrancid.in000644 015615 000000 00000056121 13534014727 016042 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # RANCID - Really Awesome New Cisco confIg Differ # # usage: cssrancid [-dltCV] [-f filename | hostname] # use Getopt::Std; getopts('dflt:CV'); if ($opt_V) { print "@PACKAGE@ @VERSION@\n"; exit(0); } $log = $opt_l; $debug = $opt_d; $file = $opt_f; $host = $ARGV[0]; $clean_run = 0; $found_end = 0; $timeo = 90; # clogin timeout in seconds my(@commandtable, %commands, @commands);# command lists my($aclsort) = ("ipsort"); # ACL sorting mode my($filter_commstr); # SNMP community string filtering my($filter_osc); # oscillating data filtering mode 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)) && scalar(%history)) { print eval "$command \%history"; undef %history; } if (($new_hist_tag) && ($new_command) && ($command_string)) { if ($history{$command_string}) { $history{$command_string} = "$history{$command_string}@string"; } else { $history{$command_string} = "@string"; } } elsif (($new_hist_tag) && ($new_command)) { $history{++$#history} = "@string"; } else { print "@string"; } $hist_tag = $new_hist_tag; $command = $new_command; 1; } sub numerically { $a <=> $b; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort numerically keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort values %lines) { $sorted_lines[$i] = $key; $i++; } @sorted_lines; } # This is a numerical sort routine (ascending). sub numsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $num (sort {$a <=> $b} keys %lines) { $sorted_lines[$i] = $lines{$num}; $i++; } @sorted_lines; } # This is a sort routine that will sort on the # ip address when the ip address is anywhere in # the strings. sub ipsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $addr (sort sortbyipaddr keys %lines) { $sorted_lines[$i] = $lines{$addr}; $i++; } @sorted_lines; } # 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])); } sub sortbyipaddr { &ipaddrval($a) <=> &ipaddrval($b); } # This routine parses "show version" sub ShowVersion { print STDERR " In ShowVersion: $_" if ($debug); while () { tr/\015//d; last if(/^$prompt/); next if(/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); if (/^Slave in slot (\d+) is running/) { $slave = " Slave:"; next; } /^Cisco Secure PIX /i && ProcessHistory("COMMENTS","keysort","F1", "!Image: $_") && next; /^IOS .* Software \(([A-Za-z-0-9]*)\), .*Version\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","F1", "!Image:$slave Software: $1, $2\n") && next; /^([A-Za-z-0-9_]*) Synced to mainline version: (.*)$/ && ProcessHistory("COMMENTS","keysort","F2", "!Image:$slave $1 Synced to mainline version: $2\n") && next; /^Compiled (.*)$/ && ProcessHistory("COMMENTS","keysort","F3", "!Image:$slave Compiled: $1\n") && next; /^ROM: (System )?Bootstrap.*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G1", "!ROM Bootstrap: $2\n") && next; if (/^Hardware:\s+(.*), (.* RAM), CPU (.*)$/) { ProcessHistory("COMMENTS","keysort","A1", "!Chassis type: $1 - a PIX\n"); ProcessHistory("COMMENTS","keysort","A2", "!CPU: $3\n"); ProcessHistory("COMMENTS","keysort","B1", "!Memory: $2\n"); } /^Serial Number:\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","C1", "!$_") && next; /^Activation Key:\s+(.*)$/ && ProcessHistory("COMMENTS","keysort","C2", "!$_") && next; /^ROM: \d+ Bootstrap .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G2", "!ROM Image: Bootstrap $1\n!\n") && next; /^ROM: .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G3","!ROM Image: $1\n") && next; /^BOOTFLASH: .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G4","!BOOTFLASH: $1\n") && next; /^BOOTLDR: .*(Version.*)$/ && ProcessHistory("COMMENTS","keysort","G4","!BOOTLDR: $1\n") && next; /^System image file is "([^\"]*)", booted via (\S*)/ && ProcessHistory("COMMENTS","keysort","F4","!Image: booted $1\n") && next; /^System image file is "([^\"]*)"$/ && ProcessHistory("COMMENTS","keysort","F5","!Image: $1\n") && next; if (/(\S+)\s+\((\S+)\)\s+processor.*with (\S+[kK]) bytes/) { my($proc) = $1; my($cpu) = $2; my($mem) = $3; my($device) = "router"; $type = "CSS"; print STDERR "TYPE = $type\n" if ($debug); ProcessHistory("COMMENTS","keysort","A1", "!Chassis type:$slave $proc - a $type $device\n"); ProcessHistory("COMMENTS","keysort","B1", "!Memory:$slave main $mem\n"); ProcessHistory("COMMENTS","keysort","A3","!CPU:$slave $cpu\n"); next; } if (/(\S+) Silicon\s*Switch Processor/) { if (!defined($C0)) { $C0 = 1; ProcessHistory("COMMENTS","keysort","C0","!\n"); } ProcessHistory("COMMENTS","keysort","C2","!SSP: $1\n"); $ssp = 1; $sspmem = $1; next; } /^(\d+[kK]) bytes of multibus/ && ProcessHistory("COMMENTS","keysort","B2", "!Memory: multibus $1\n") && next; /^(\d+[kK]) bytes of non-volatile/ && ProcessHistory("COMMENTS","keysort","B3", "!Memory: nvram $1\n") && next; /^(\d+[kK]) bytes of flash memory/ && ProcessHistory("COMMENTS","keysort","B5","!Memory: flash $1\n") && next; /^(\d+[kK]) bytes of .*flash partition/ && ProcessHistory("COMMENTS","keysort","B6", "!Memory: flash partition $1\n") && next; /^(\d+[kK]) bytes of Flash internal/ && ProcessHistory("COMMENTS","keysort","B4", "!Memory: bootflash $1\n") && next; if(/^(\d+[kK]) bytes of (Flash|ATA)?.*PCMCIA .*(slot|disk) ?(\d)/i) { ProcessHistory("COMMENTS","keysort","B7", "!Memory: pcmcia $2 $3$4 $1\n"); next; } if(/^WARNING/) { if (!defined($I0)) { $I0 = 1; ProcessHistory("COMMENTS","keysort","I0","!\n"); } ProcessHistory("COMMENTS","keysort","I1","! $_"); # The line after the WARNING is what to do about it. $_ = ; tr/\015//d; ProcessHistory("COMMENTS","keysort","I1","! $_"); } if (/^Configuration register is (.*)$/) { $config_register = $1; next; } } return(0); } # Dummy routine to set term length.... sub TermLength { # Dummy subroutine.. need to set term length differently for CSS # boxes as term length 0 doesnt work correctly. POS. print STDERR " In TermLength: $_" if ($debug); $_ = ; return(0); } # Dummy routine to copy profile... sub CopyProfile { ## Because the term length gets changed twice, the stupid ## box will ask you to save or discard changes. This prompt ## of couse breaks the interaction... strangely enough tho ## in a failover environment, only the secondary behaves this ## way.. the primary lets you log out and does not complain. print STDERR " In CopyProfile: $_" if ($debug); $_ = ; return(0); } # This routine parses "show boot" sub ShowBoot { # Pick up boot variables if 7000/7200/7500/12000/2900/3500; # otherwise pick up bootflash. print STDERR " In ShowBoot: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(-1) if (/command authorization failed/i); return(1) if /Ambiguous command/i; # return(1) if /(Invalid input detected|Type help or )/; return(1) if /(Open device \S+ failed|Error opening \S+:)/; next if (/\*\* BOOT CONFIG /); next if /CONFGEN variable/; if (!defined($H0)) { $H0 = 1; ProcessHistory("COMMENTS","keysort","H0","!\n"); } if ($type !~ /^(12[04]|7)/) { if ($type !~ /^(29|35)00/) { ProcessHistory("COMMENTS","keysort","H2","!BootFlash: $_"); } else { ProcessHistory("COMMENTS","keysort","H1","!Variable: $_"); } } elsif (/variable/) { ProcessHistory("COMMENTS","keysort","H1","!Variable: $_"); } } ProcessHistory("COMMENTS","","","!\n"); return(0); } # This routine processes a "show run" sub ShowRun { print STDERR " In ShowRun: $_" if ($debug); my($lines) = 0; while () { tr/\015//d; if(/^$prompt/) { $found_end = 1 if ($lines > 4); return(1); } return(-1) if (/command authorization failed/i); # the pager can not be disabled per-session on the PIX s/^<-+ More -+>\s*//; /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked # skip the crap if (/^(##+$|(Building|Current) configuration)/i) { while () { next if (/^Current configuration\s*:/i); next if (/^:/); next if (/^([%!].*|\s*)$/); next if (/^ip add.*ipv4:/); # band-aid for 3620 12.0S last; } if (defined($config_register)) { ProcessHistory("","","","!\nconfig-register $config_register\n"); } tr/\015//d; } # some versions have other crap mixed in with the bits in the # block above /^! (Last configuration|NVRAM config last)/ && next; ## CSS specific.... /Generated on/ && next; $lines++; # Dog gone Cool matches to process the rest of the config /^tftp-server flash / && next; # kill any tftp remains /^ntp clock-period / && next; # kill ntp clock-period /^ length / && next; # kill length on serial lines /^ width / && next; # kill width on serial lines /^ speed / && next; # kill speed on serial lines /^ clockrate / && next; # kill clockrate on serial interfaces if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","!$1$2 \n"); next; } if (/^(enable secret) / && $filter_pwds >= 2) { ProcessHistory("ENABLE","","","!$1 \n"); next; } if (/^username (\S+)(\s.*)? secret /) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1","!username $1$2 secret \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/\s*username (\S+)(\s.*)? (des-password|password) (\S+|\S+)/) { if ($filter_pwds >= 1) { ProcessHistory("USER","keysort","$1","! username $1$2 $3 $'\n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","","!$1password \n"); next; } if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) { ProcessHistory("","","","! neighbor $1 password \n"); next; } if (/^(ppp .* password) 7 .*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^(ip ftp password) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # isis passwords appear to be completely plain-text if (/^\s+isis password (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!isis password $2\n"); next; } if (/^\s+(domain-password|area-password) (\S+)( .*)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $2\n"); next; } # this is reversable, despite 'md5' in the cmd if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^((crypto )?isakmp key) \S+ / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # i am told these are plain-text on the PIX if (/^(vpdn username \S+ password)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } /fair-queue individual-limit/ && next; # sort ip explicit-paths. if (/^ip explicit-path name (\S+)/) { my($key) = $1; my($expath) = $_; while () { tr/\015//d; last if (/^$prompt/); last if (/^$prompt/ || ! /^(ip explicit-path name |[ !])/); if (/^ip explicit-path name (\S+)/) { ProcessHistory("EXPATH","keysort","$key","$expath"); $key = $1; $expath = $_; } else { $expath .= $_; } } ProcessHistory("EXPATH","keysort","$key","$expath"); } # sort route-maps if (/^route-map (\S+)/) { my($key) = $1; my($routemap) = $_; while () { tr/\015//d; last if (/^$prompt/ || ! /^(route-map |[ !])/); if (/^route-map (\S+)/) { ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); $key = $1; $routemap = $_; } else { $routemap .= $_; } } ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); } # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order access-lists /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next; # order extended access-lists /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ && ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next; /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ && ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next; # order arp lists /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ && ProcessHistory("ARP","$aclsort","$1","$_") && next; /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ && ProcessHistory("PACL $1 $3","$aclsort","$4","ip prefix-list $1 $3 $4$5\n") && next; # order logging statements /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version') { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } if (/^(snmp-server community) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_","!$1 $'") && next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # order/prune tacacs/radius server statements if (/^(tacacs-server|radius-server) key / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 key \n"); next; } # order clns host statements /^clns host \S+ (\S+)/ && ProcessHistory("CLNS","keysort","$1","$_") && next; # order alias statements /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next; # delete ntp auth password - this md5 is a reversable too if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # order ip host line statements /^ip host line(\d+)/ && ProcessHistory("IPHOST","numsort","$1","$_") && next; # order ip nat source static statements /^ip nat (\S+) source static (\S+)/ && ProcessHistory("IP NAT $1","ipsort","$2","$_") && next; # order atm map-list statements /^\s+ip\s+(\d+\.\d+\.\d+\.\d+)\s+atm-vc/ && ProcessHistory("ATM map-list","ipsort","$1","$_") && next; # order ip rcmd lines /^ip rcmd/ && ProcessHistory("RCMD","keysort","$_","$_") && next; # system controller /^syscon address (\S*) (\S*)/ && ProcessHistory("","","","!syscon address $1 \n") && next; if (/^syscon password (\S*)/ && $filter_pwds >= 1) { ProcessHistory("","","","!syscon password \n"); next; } # catch anything that wasnt matched above. ProcessHistory("","","","$_"); } return(0); } # Main @commandtable = ( {'term length 65535' => 'TermLength'}, {'copy profile user-profile' => 'CopyProfile'}, {'show version' => 'ShowVersion'}, {'show boot' => 'ShowBoot'}, {'show run' => 'ShowRun'} ); # 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); $commandcnt = scalar(keys %commands); $commandstr = join(";",@commands); $cmds_regexp = join("|", map quotemeta($_), @commands); if (length($host) == 0) { if ($file) { print(STDERR "Too few arguments: file name required\n"); exit(1); } else { print(STDERR "Too few arguments: host name required\n"); exit(1); } } if ($opt_C) { print "clogin -t $timeo -c\'$commandstr\' $host\n"; exit(0); } open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n"; select(OUTPUT); # make OUTPUT unbuffered if debugging if ($debug) { $| = 1; } if ($file) { print(STDERR "opening file $host\n") if ($debug || $log); open(INPUT,"<$host") || die "open failed for $host: $!\n"; } else { print(STDERR "executing clogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log); system "clogin -t $timeo -c \"$commandstr\" $host $host.raw 2>&1" || die "clogin failed for $host: $!\n"; open(INPUT, "< $host.raw") || die "clogin failed for $host: $!\n"; } # 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 oscillating data filtering mode if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) { $filter_osc = 0; } else { $filter_osc = 1; } # determine password filtering mode if ($ENV{"FILTER_PWDS"} =~ /no/i) { $filter_pwds = 0; } elsif ($ENV{"FILTER_PWDS"} =~ /all/i) { $filter_pwds = 2; } else { $filter_pwds = 1; } ProcessHistory("","","","!RANCID-CONTENT-TYPE: css\n!\n"); #ProcessHistory("COMMENTS","keysort","B0","!\n"); #ProcessHistory("COMMENTS","keysort","F0","!\n"); #ProcessHistory("COMMENTS","keysort","G0","!\n"); TOP: while() { NEXT: tr/\015//d; if (/\#\s?exit/) { $clean_run = 1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run = 0; last; } if (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } # the function may have read the next prompt/cmd line goto NEXT; } } print STDOUT "Done $logincmd: $_\n" if ($log); # Flush History ProcessHistory("","","",""); # Cleanup close(INPUT); close(OUTPUT); unlink("$host.raw") if (! $debug); # check for completeness if (scalar(%commands) || !$clean_run || !$found_end) { if (scalar(keys %commands) eq $commandcnt) { printf(STDERR "$host: missed cmd(s): all commands\n"); } elsif (scalar(%commands)) { my($count, $i) = 0; for ($i = 0; $i < $#commands; $i++) { if ($commands{$commands[$i]}) { if (!$count) { printf(STDERR "$host: missed cmd(s): %s", $commands[$i]); } else { printf(STDERR ", %s", $commands[$i]); } $count++; } } if ($count) { printf(STDERR "\n"); } } if (!$clean_run || !$found_end) { print(STDERR "$host: End of run not found\n"); if ($debug) { print(STDERR "$host: clean_run is false\n") if (!$clean_run); print(STDERR "$host: found_end is false\n") if (!$found_end); } system("/usr/bin/tail -1 $host.new"); } unlink "$host.new" if (! $debug); } rancid-3.13/bin/f5rancid.in000644 015615 000000 00000046266 13534014736 015575 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # This version of rancid tries to deal with F5 BigIPs. # # RANCID - Really Awesome New Cisco confIg Differ # # usage: f5rancid [-dltCV] [-f filename | hostname] # use Getopt::Std; getopts('dflt:CV'); if ($opt_V) { print "@PACKAGE@ @VERSION@\n"; exit(0); } $log = $opt_l; $debug = $opt_d; $file = $opt_f; $host = $ARGV[0]; $clean_run = 0; $found_end = 0; $timeo = 90; # clogin timeout in seconds # force a terminal type so as not to confuse the POS $ENV{'TERM'} = "vt100-w"; my(@commandtable, %commands, @commands);# command lists my($aclsort) = ("ipsort"); # ACL sorting mode my($filter_commstr); # SNMP community string filtering my($filter_osc); # oscillating data filtering mode 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)) && scalar(%history)) { print eval "$command \%history"; undef %history; } if (($new_hist_tag) && ($new_command) && ($command_string)) { if ($history{$command_string}) { $history{$command_string} = "$history{$command_string}@string"; } else { $history{$command_string} = "@string"; } } elsif (($new_hist_tag) && ($new_command)) { $history{++$#history} = "@string"; } else { print "@string"; } $hist_tag = $new_hist_tag; $command = $new_command; 1; } sub numerically { $a <=> $b; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort numerically keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort values %lines) { $sorted_lines[$i] = $key; $i++; } @sorted_lines; } # This is a numerical sort routine (ascending). sub numsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $num (sort {$a <=> $b} keys %lines) { $sorted_lines[$i] = $lines{$num}; $i++; } @sorted_lines; } # This is a sort routine that will sort on the # ip address when the ip address is anywhere in # the strings. sub ipsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $addr (sort sortbyipaddr keys %lines) { $sorted_lines[$i] = $lines{$addr}; $i++; } @sorted_lines; } # 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])); } sub sortbyipaddr { &ipaddrval($a) <=> &ipaddrval($b); } # This routine parses "bigpipe base list" sub ShowBaseRun { my($line) = (0); print STDERR " In ShowBaseRun: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); if (!$line++) { ProcessHistory("SHOWBASE","","","#\n#base:\n"); } # filter oscillating "password crypt", "auth password crypt", # "privacy password crypt" if (/(password crypt) / && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","","# $`$1 \n"); next; } if (/(auth-password-encrypted )\S+/) { ProcessHistory("SHOWBASE","","","# $1 "); next; } ProcessHistory("SHOWBASE","","","# $_") && next; } return(0); } # This routine parses "bigpipe db show" sub ShowDb { my($line) = (0); print STDERR " In ShowDb: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); if (!$line++) { ProcessHistory("SHOWDB","","","#\n#database:\n"); } /UCS.LoadTime/ && next; /Configsync\..*Time/ && next; /Configsync.peerupdatedstatus/ && next; /Failover\..*Time/ && next; /LTM.ConfigTime/ && next; if (/^(snmp\..*\.community\..* =) (.+)/i) { if ($filter_commstr) { ProcessHistory("SHOWDB","","","# $1 \n") && next; } else { ProcessHistory("SHOWDB","","","# $1 $2\n") && next; } } ProcessHistory("SHOWDB","","","# $_") && next; } return(0); } # This routine parses "cat /config/bigip.license" sub ShowLicense { my($line) = (0); print STDERR " In ShowLicense: $_" if ($debug); while () { tr/\015//d; # v9 software license does not have CR at EOF s/^#-+($prompt.*)/$1/; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); if (!$line++) { ProcessHistory("LICENSE","","","#\n#/config/bigip.license:\n"); } ProcessHistory("LICENSE","","","# $_") && next; } return(0); } # This routine parses "bigpipe monitor list all" sub ShowMonitor { my($line) = (0); print STDERR " In ShowMonitor: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); if (!$line++) { ProcessHistory("MONITOR","","","#\n"); } if (/^(snmp\.[^ ]+\.community) = (.+)/i) { if ($filter_commstr) { ProcessHistory("SHOWDB","","","# $1 \n") && next; } else { ProcessHistory("SHOWDB","","","# $1 $2\n") && next; } } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","","# $1password \n"); next; } ProcessHistory("MONITOR","","","# $_") && next; } return(0); } # This routine parses "bigpipe platform" sub ShowPlatform { print STDERR " In ShowPlatform: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); /fan speed/i && next; /chassis temperature/i && next; /degC/ && next; s/\d+rpm//ig; s/^\|//; /Type: / && ProcessHistory("COMMENTS","keysort","A0", "#Chassis type: $'"); ProcessHistory("COMMENTS","keysort","B1","#$_") && next; } return(0); } # This routine parses "bigpipe profile list" sub ShowProfile { print STDERR " In ShowProfile: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); ProcessHistory("PROFILE","",""," $_") && next; } return(0); } # This routine parses "ls --full-time --color=never /config/ssl/ssl.key" sub ShowSslKey { print STDERR " In ShowSslKey: $_" if ($debug); while () { tr/\015//d; # v9 software license does not have CR at EOF s/^#-+($prompt.*)/$1/; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); ProcessHistory("SSLKEY","","","# $_") && next; } return(0); } # This routine parses "ls --full-time --color=never /config/ssl/ssl.crt" sub ShowSslCrt { print STDERR " In ShowSslCrt: $_" if ($debug); while () { tr/\015//d; # v9 software license does not have CR at EOF s/^#-+($prompt.*)/$1/; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); ProcessHistory("SSLCRT","","","# $_") && next; } return(0); } # This routine parses "bigpipe route static show" sub ShowRouteStatic { print STDERR " In ShowRouteStatic: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(1) if /^\s*\^\s*$/; return(1) if /(Invalid input detected|Type help or )/; return(-1) if (/command authorization failed/i); ProcessHistory("ROUTE","",""," $_") && next; } return(0); } # This routine parses "bigpipe version" sub ShowVersion { print STDERR " In ShowVersion: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); return(-1) if (/command authorization failed/i); /^kernel:/i && ($_ = ) && ProcessHistory("COMMENTS","keysort","A3","#Image: Kernel: $_") && next; if (/^package:/i) { my($line); while ($_ = ) { tr/\015//d; last if (/:/); last if (/^$prompt/); chomp; $line .= " $_"; } ProcessHistory("COMMENTS","keysort","A2", "#Image: Package:$line\n"); } if (/:/) { ProcessHistory("COMMENTS","keysort","C1","#$_"); } else { ProcessHistory("COMMENTS","keysort","C1","#\t$_"); } } return(0); } # This routine processes a "bigpipe list" sub WriteTerm { my($lines) = 0; print STDERR " In WriteTerm: $_" if ($debug); while () { tr/\015//d; next if (/^\s*$/); # end of config - hopefully. f5 does not have a reliable end-of-config # tag. if (/^$prompt/) { $found_end++; last; } return(-1) if (/command authorization failed/i); # the pager can not be disabled per-session on the PIX s/^<-+ More -+>\s*//; /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; $lines++; if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) { ProcessHistory("ENABLE","","","! $1$2 \n"); next; } if (/^(enable secret) / && $filter_pwds >= 2) { ProcessHistory("ENABLE","","","# $1 \n"); next; } if (/^username (\S+)(\s.*)? secret /) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1","# username $1$2 secret \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^username (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds == 2) { ProcessHistory("USER","keysort","$1","# username $1$2 password \n"); } elsif ($filter_pwds == 1 && $4 ne "5"){ ProcessHistory("USER","keysort","$1","# username $1$2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","","# $1password \n"); next; } if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) { ProcessHistory("","","","# neighbor $1 password \n"); next; } # order logging statements /^logging (\d+\.\d+\.\d+\.\d+)/ && ProcessHistory("LOGGING","ipsort","$1","$_") && next; # order/prune tacacs/radius server statements if (/^(tacacs-server|radius-server) key / && $filter_pwds >= 1) { ProcessHistory("","","","# $1 key \n"); next; } # order clns host statements /^clns host \S+ (\S+)/ && ProcessHistory("CLNS","keysort","$1","$_") && next; # order alias statements /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next; # delete ntp auth password - this md5 is a reversable too if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","# $1 \n"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # order ip host line statements /^ip host line(\d+)/ && ProcessHistory("IPHOST","numsort","$1","$_") && next; # order ip nat source static statements /^ip nat (\S+) source static (\S+)/ && ProcessHistory("IP NAT $1","ipsort","$2","$_") && next; # monitor state /^\s+monitor state (\S+)/ && next; # catch anything that wasnt matched above. ProcessHistory("","","","$_"); } if ($lines < 3) { printf(STDERR "ERROR: $host configuration appears truncated.\n"); $found_end = 0; return(-1); } return(0); } # Main @commandtable = ( {'bigpipe version' => 'ShowVersion'}, {'bigpipe platform' => 'ShowPlatform'}, {'cat /config/bigip.license' => 'ShowLicense'}, {'bigpipe monitor list all' => 'ShowMonitor'}, {'bigpipe profile list' => 'ShowProfile'}, {'bigpipe base list' => 'ShowBaseRun'}, {'bigpipe db show' => 'ShowDb'}, {'bigpipe route static show' => 'ShowRouteStatic'}, {'ls --full-time --color=never /config/ssl/ssl.crt' => 'ShowSslCrt'}, {'ls --full-time --color=never /config/ssl/ssl.key' => 'ShowSslKey'}, {'bigpipe list' => '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); $commandcnt = scalar(keys %commands); $commandstr=join(";",@commands); $cmds_regexp = join("|", map quotemeta($_), @commands); if (length($host) == 0) { if ($file) { print(STDERR "Too few arguments: file name required\n"); exit(1); } else { print(STDERR "Too few arguments: host name required\n"); exit(1); } } if ($opt_C) { print "clogin -t $timeo -c\'$commandstr\' $host\n"; exit(0); } open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n"; select(OUTPUT); # make OUTPUT unbuffered if debugging if ($debug) { $| = 1; } if ($file) { print(STDERR "opening file $host\n") if ($debug || $log); open(INPUT,"<$host") || die "open failed for $host: $!\n"; } else { print(STDERR "executing clogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log); system "clogin -t $timeo -c \"$commandstr\" $host $host.raw 2>&1" || die "clogin failed for $host: $!\n"; open(INPUT, "< $host.raw") || die "clogin failed for $host: $!\n"; } # 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 oscillating data filtering mode if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) { $filter_osc = 0; } else { $filter_osc = 1; } # determine password filtering mode if ($ENV{"FILTER_PWDS"} =~ /no/i) { $filter_pwds = 0; } elsif ($ENV{"FILTER_PWDS"} =~ /all/i) { $filter_pwds = 2; } else { $filter_pwds = 1; } ProcessHistory("","","","#RANCID-CONTENT-TYPE: bigip\n#\n"); ProcessHistory("COMMENTS","keysort","A1","#\n"); ProcessHistory("COMMENTS","keysort","B0","#\n"); ProcessHistory("COMMENTS","keysort","C0","#\n"); TOP: while() { tr/\015//d; if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run=0; last; } while (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } if (/\#\s?exit$/) { $clean_run=1; last; } } print STDOUT "Done $logincmd: $_\n" if ($log); # Flush History ProcessHistory("","","",""); # Cleanup close(INPUT); close(OUTPUT); unlink("$host.raw") if (! $debug); # check for completeness if (scalar(%commands) || !$clean_run || !$found_end) { if (scalar(keys %commands) eq $commandcnt) { printf(STDERR "$host: missed cmd(s): all commands\n"); } elsif (scalar(%commands)) { my($count, $i) = 0; for ($i = 0; $i < $#commands; $i++) { if ($commands{$commands[$i]}) { if (!$count) { printf(STDERR "$host: missed cmd(s): %s", $commands[$i]); } else { printf(STDERR ", %s", $commands[$i]); } $count++; } } if ($count) { printf(STDERR "\n"); } } if (!$clean_run || !$found_end) { print(STDERR "$host: End of run not found\n"); if ($debug) { print(STDERR "$host: clean_run is false\n") if (!$clean_run); print(STDERR "$host: found_end is false\n") if (!$found_end); } system("/usr/bin/tail -1 $host.new"); } unlink "$host.new" if (! $debug); } rancid-3.13/bin/rblogin.in000644 015615 000000 00000050240 13657102757 015530 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # rblogin - Riverbed Steelhead login; this is starting from clogin r3115, with # a few changes for UI bugs. # # Most options are intuitive for logging into a Cisco router. # The default is to enable (thus -noenable). Some folks have # setup tacacs to have a user login at priv-lvl = 15 (enabled) # so the -autoenable flag was added for this case (don't go through # the process of enabling and the prompt will be the "#" prompt. # The default username password is the same as the vty password. # # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 45 # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} @login_top@ # Log into the router. # returns: 0 on success, 1 on failure, -1 if rsh was used successfully proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } { global command spawn_id in_proc do_command do_script platform passphrase global prompt prompt_match u_prompt p_prompt e_prompt sshcmd telnetcmd set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port if {"$port" == ""} { set retval [catch {eval spawn [split "$telnetcmd $router"]} reason] } else { set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason] } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif [string match "ssh*" $prog] { # ssh to the router & try to login with or without an identfile. regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } if {"$identfile" != ""} { set cmd "$cmd -i $identfile" } set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason] if { $retval } { send_user "\nError: $cmd failed: $reason\n" return 1 } } elseif ![string compare $prog "rsh"] { if { ! $do_command } { if { [llength $cmethod] == 1 } { send_user "\nError: rsh is an invalid method for -x and " send_user "interactive logins\n" } if { $progs == 0 } { return 1 } continue; } # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] set rshfail 0 for {set i 0} {$i < $num_commands && !$rshfail} { incr i} { log_user 0 set retval [catch {spawn rsh $user@$router [lindex $commands $i] } reason] if { $retval } { send_user "\nError: rsh failed: $reason\n" log_user 1; return 1 } send_user "$router# [lindex $commands $i]\n" # rcmd does not get a pager and no prompts, so we just have to # look for failures & lines. expect { "Connection refused" { catch {close}; catch {wait}; send_user "\nError: Connection\ Refused ($prog): $router\n" set rshfail 1 } -re "(Connection closed by|Connection to \[^\n\r]+ closed)" { catch {close}; catch {wait}; send_user "\nError: Connection\ closed ($prog): $router\n" set rshfail 1 } "Host is unreachable" { catch {close}; catch {wait}; send_user "\nError: Host Unreachable:\ $router\n" set rshfail 1 } "No address associated with" { catch {close}; catch {wait}; send_user "\nError: Unknown host\ $router\n" set rshfail 1 } -re "\b+" { exp_continue } -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } timeout { catch {close}; catch {wait}; send_user "\nError: TIMEOUT reached\n" set rshfail 1 } eof { catch {close}; catch {wait}; } } log_user 1 } if { $rshfail } { if { !$progs } { return 1 } else { continue } } # fake the end of the session for rancid. send_user "$router# exit\n" # return rsh "success" return -1 } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; catch {wait}; if {$in_proc} { return 1 } else { continue } } } # Here we get a little tricky. There are several possibilities: # the router can ask for a username and passwd and then # talk to the TACACS server to authenticate you, or if the # TACACS server is not working, then it will use the enable # passwd. Or, the router might not have TACACS turned on, # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { -re "^<-+ More -+>\[^\n\r]*" { # ASA will use the pager for long banners send " "; exp_continue } -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 } "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)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -nocase -re "^warning: remote host denied authentication agent forwarding." { exp_continue; } -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 "% (Bad passwords|Authentication failed)" { send_user "\nError: Check your passwd for $router\n" catch {close}; catch {wait}; return 1 } "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" exp_continue } -re "Last login:" { exp_continue } -re "Press the key \[^\r\n]+\[\r\n]+" { exp_continue } -re "@\[^\r\n]+ $p_prompt" { # ssh pwd prompt sleep 1 send -- "$userpswd\r" exp_continue } -re "Enter passphrase.*: " { # sleep briefly to allow time for stty -echo sleep .3 send -- "$passphrase\r" exp_continue } -re "$u_prompt" { send -- "$user\r" set uprompt_seen 1 exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send -- "$userpswd\r" } else { send -- "$passwd\r" } exp_continue } -re "$prompt" { set prompt_match $expect_out(0,string); break; } "Login invalid" { send_user "\nError: Invalid login: $router\n"; catch {close}; catch {wait}; return 1 } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } } set in_proc 0 return 0 } # Enable proc do_enable { enauser enapasswd } { global do_saveconfig in_proc global prompt u_prompt e_prompt enacmd set in_proc 1 send "$enacmd\r" expect { -re "$u_prompt" { send -- "$enauser\r"; exp_continue} -re "$e_prompt" { send -- "$enapasswd\r"; exp_continue} "#" { set prompt "#" } "(enable)" { set prompt "> \\(enable\\) " } "% Invalid input" { send_user "\nError: Unrecognized command, check your enable command\n"; return 1 } -re "(denied|Sorry|Incorrect)" { # % Access denied - from local auth and poss. others send_user "\nError: Check your Enable passwd\n"; return 1 } "% Error in authentication" { send_user "\nError: Check your Enable passwd\n" return 1 } "% Bad passwords" { send_user "\nError: Check your Enable passwd\n" return 1 } } # We set the prompt variable (above) so script files don't need # to know what it is. set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact do_saveconfig in_proc platform set in_proc 1 if { [string compare "extreme" "$platform"] } { # match cisco config mode prompts too, such as router(config-if)#, # but catalyst does not change in this fashion. regsub -lineanchor -- {^(.{1,11}).*([#>])$} $prompt {\1} reprompt regsub -all -- {[\\]$} $reprompt {} reprompt append reprompt {([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} } else { set reprompt $prompt } # this is the only way i see to get rid of more prompts in o/p..grrrrr log_user 0 # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] # the pager can not be turned off on the PIX, so we have to look # for the "More" prompt. the extreme is equally obnoxious in pre-12.3 XOS, # with a global switch in the config. for {set i 0} {$i < $num_commands} { incr i} { send -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "\b+" { exp_continue } -re "^<]+>>" { # for whatever reason, the riverbed prints # this warning in show peers o/p, but doesnt # follow it with a CR, so the following # prompt is not at the BOL, confusing the # parsing script. so, filter it. XXX exp_continue; } -re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)" } -re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)" exp_continue } -re "^--More--\[\r\n]+" { # specific match c1900 pager send " " exp_continue } -re "\[^\r\n]*\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } -re "\[^\r\n]*Press to cont\[^\r\n]*" { send " " # bloody ^[[2K after " " expect { -re "^\[^\r\n]*\r" {} } exp_continue } -re "^ *--More--\[^\n\r]*" { send " " exp_continue } -re "^<-+ More -+>\[^\n\r]*" { send_user -- "$expect_out(buffer)" send " " exp_continue } } } log_user 1 if { $do_interact == 1 } { interact return 0 } if { [string compare "extreme" "$platform"] } { send -h "exit\r" } else { send -h "quit\r" } expect { -re "^\[^\n\r *]*$reprompt" { # the Cisco CE and Jnx ERX # return to non-enabled mode # on exit in enabled mode. send -h "exit\r" exp_continue; } "The system has unsaved changes" { # Force10 SFTOS if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "Would you like to save them now" { # Force10 if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "(Profile|Configuration) changes have occurred.*" { # Cisco CSS if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } "Do you wish to save your configuration changes" { if {$do_saveconfig} { catch {send "y\r"} } else { catch {send "n\r"} } exp_continue } -re "\[\n\r]+" { exp_continue } timeout { catch {close}; catch {wait}; return 1 } eof { return 0 } } set in_proc 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 set exitval 0 set prompt_match "" foreach router [lrange $argv $i end] { set router [string tolower $router] # attempt at platform switching. set platform "" send_user -- "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # Default prompt. set prompt [join [find prompt $router] ""] if { [llength $prompt] == 0 } { set prompt "(>|#| \\(enable\\))" } # look for autoenable option in .cloginrc & cmd-line set ae [find autoenable $router] if { "$ae" == "1" || $avautoenable } { set autoenable 1 } else { set autoenable 0 } # look for enable options in .cloginrc & cmd-line if { $avenable == 0 } { set enable 0 } else { set ne [find noenable $router] if { "$ne" == "1" || "$autoenable" == "1" } { set enable 0 } else { set enable 1 } } # Figure out passwords if { $do_passwd || $do_enapasswd } { set pswd [find password $router] if { [llength $pswd] == 0 } { send_user -- "\nError: no password for $router in $password_file.\n" continue } if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } { send_user -- "\nError: no enable password for $router in $password_file.\n" continue } if { $do_passwd } { set passwd [join [lindex $pswd 0] ""] } else { set passwd $userpasswd } if { $do_enapasswd } { set enapasswd [join [lindex $pswd 1] ""] } else { set enapasswd $enapasswd } } else { set passwd $userpasswd set enapasswd $enapasswd } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } 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 $ruser } } # Figure out enable command set enacmd [join [find enablecmd $router] ""] if { "$enacmd" == "" } { set enacmd "enable" } # Figure out prompts set u_prompt [find userprompt $router] if { "$u_prompt" == "" } { set u_prompt "(\[Uu]sername|Login|login|user name|User):" } else { set u_prompt [join [lindex $u_prompt 0] ""] } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+):" } else { set p_prompt [join [lindex $p_prompt 0] ""] } set e_prompt [find enableprompt $router] if { "$e_prompt" == "" } { set e_prompt "\[Pp]assword:" } else { set e_prompt [join [lindex $e_prompt 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 cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} { incr exitval # if login failed or rsh was unsuccessful, move on to the next device continue } # Figure out the prompt. if { [regexp -- "(#| \\(enable\\))" $prompt_match junk] == 1 } { set enable 0 } if { $enable } { if {[do_enable $enauser $enapasswd]} { if { $do_command || $do_script } { incr exitval catch {close}; catch {wait}; continue } } } # we are logged in, now figure out the full prompt send "\r" regsub -all {^(\^*)(.*)} $prompt {\2} reprompt expect { -re "\[\r\n]+" { exp_continue; } -re "^(.+\[:.])1 ($reprompt)" { # stoopid extreme cmd-line numbers and # prompt based on state of config changes, # which may have an * at the beginning. set junk $expect_out(1,string) regsub -all "^\\\* " $expect_out(1,string) {} junk regsub -all "\[\]\[\(\)]" $junk {\\&} junk; set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)"; set platform "extreme" } -re "^.+$reprompt" { set junk $expect_out(0,string); regsub -all "\[\]\[\(\)+]" $junk {\\&} prompt; } } if { $do_command || $do_script } { if { [string compare "extreme" "$platform"] } { # If the prompt is (enable), then we are on a switch and the # command is "set length 0"; otherwise its "terminal length 0". if [regexp -- ".*> .*enable" "$prompt"] { send "set length 0\r" expect -re $prompt {} # XXX This causes the riverbed to reprint the prompt after the # existing prompt, which confuses the expect script. # send "set width 132\r" # expect -re $prompt {} send "set logging session disable\r" } else { send "terminal length 0\r" # XXX This causes the riverbed to reprint the prompt after the # existing prompt, which confuses the expect script. # expect -re $prompt {} # send "terminal width 132\r" } expect -re $prompt {} } else { send "disable clipaging\r" expect -re $prompt {} } } if { $do_command } { if {[run_commands $prompt $command]} { incr exitval continue } } elseif { $do_script } { source $sfile catch {close}; } else { label $router log_user 1 interact } # End of for each router catch {wait}; sleep 0.3 } exit $exitval rancid-3.13/bin/panlogin.in000644 015615 000000 00000031737 13657102757 015715 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ -- ## ## @PACKAGE@ @VERSION@ @copyright@ # # panlogin - Palo Alto Networks login (based on alogin) # # 2013-01-05 - instead of set set cli pager off, send return to get prompt # cli pager moved to panrancid after scripting-mode - doug # # hughesd@deshawresearch.com is responsible for the current mess (copiously # cribbed) # # The default is that you login non-enabled (tacacs can have you login already # enabled). PAN has no enable-mode concept. # Sometimes routers take awhile to answer (the default is 10 sec) set timeoutdflt 120 # Some CLIs having problems if we write too fast (Extreme, PIX, Cat) set send_human {.2 .1 .4 .2 1} @login_top@ # Log into the router. # returns: 0 on success, 1 on failure, -1 if rsh was used successfully proc login { router user userpswd passwd cmethod cyphertype identfile } { global spawn_id in_proc do_command do_script platform global prompt u_prompt p_prompt e_prompt sshcmd telnetcmd set in_proc 1 set uprompt_seen 0 # try each of the connection methods in $cmethod until one is successful set progs [llength $cmethod] foreach prog [lrange $cmethod 0 end] { incr progs -1 if [string match "telnet*" $prog] { regexp {telnet(:([^[:space:]]+))*} $prog command suffix port if {"$port" == ""} { set retval [ catch {eval spawn [split "$telnetcmd $router"]} reason ] } else { set retval [ catch {eval spawn [split "$telnetcmd $router $port"]} reason ] } if { $retval } { send_user "\nError: telnet failed: $reason\n" return 1 } } elseif [string match "ssh*" $prog] { # ssh to the router & try to login with or without an identfile. # We use two calls to spawn since spawn does not seem to parse # spaces correctly. regexp {ssh(:([^[:space:]]+))*} $prog command suffix port set cmd $sshcmd if {"$port" != ""} { set cmd "$cmd -p $port" } if {"$cyphertype" != ""} { set cmd "$cmd -c $cyphertype" } if {"$identfile" != ""} { set cmd "$cmd -i $identfile" } set retval [ catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason ] if { $retval } { send_user "\nError: $sshcmd failed: $reason\n" return 1 } } elseif ![string compare $prog "rsh"] { global command if { ! $do_command } { if { [llength $cmethod] == 1 } { send_user "\nError: rsh is an invalid method for -x and " send_user "interactive logins\n" } if { $progs == 0 } { return 1 } continue; } # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] set rshfail 0 for {set i 0} {$i < $num_commands && !$rshfail} { incr i} { log_user 0 set retval [ catch {spawn rsh $user@$router [lindex $commands $i] } reason ] if { $retval } { send_user "\nError: rsh failed: $reason\n" log_user 1; return 1 } send_user "$router# [lindex $commands $i]\n" # rcmd does not get a pager and no prompts, so we just have to # look for failures & lines. expect { "Connection refused" { catch {close}; wait; send_user "\nError: Connection\ Refused ($prog): $router\n" set rshfail 1 } -re "(Connection closed by|Connection to \[^\n\r]+ closed)" { catch {close}; wait; send_user "\nError: Connection\ closed ($prog): $router\n" set rshfail 1 } "Host is unreachable" { catch {close}; wait; send_user "\nError: Host Unreachable:\ $router\n" set rshfail 1 } "No address associated with" { catch {close}; wait; send_user "\nError: Unknown host\ $router\n" set rshfail 1 } -re "\b+" { exp_continue } -re "\[\n\r]+" { send_user -- "$expect_out(buffer)" exp_continue } timeout { catch {close}; wait send_user "\nError: TIMEOUT reached\n" set rshfail 1 } eof { catch {close}; wait } } log_user 1 } if { $rshfail } { if { !$progs } { return 1 } else { continue } } # fake the end of the session for rancid. send_user "$router# exit\n" # return rsh "success" return -1 } else { send_user "\nError: unknown connection method: $prog\n" return 1 } sleep 0.3 # This helps cleanup each expect clause. expect_after { timeout { global in_proc send_user "\nError: TIMEOUT reached\n" catch {close}; wait if {$in_proc} { return 1 } else { continue } } eof { global in_proc send_user "\nError: EOF received\n" catch {close}; wait if {$in_proc} { return 1 } else { continue } } } # Here we get a little tricky. There are several possibilities: # the router can ask for a username and passwd and then # talk to the TACACS server to authenticate you, or if the # TACACS server is not working, then it will use the enable # passwd. Or, the router might not have TACACS turned on, # then it will just send the passwd. # if telnet fails with connection refused, try ssh expect { -re "(Connection refused|Secure connection \[^\n\r]+ refused)" { catch {close}; wait if !$progs { send_user "\nError: Connection Refused ($prog): $router\n" return 1 } } -re "(Connection closed by|Connection to \[^\n\r]+ closed)" { catch {close}; 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" { catch {close}; send_user "\nError: Unknown host $router\n"; wait; return 1 } "Host is unreachable" { catch {close}; send_user "\nError: Host Unreachable: $router\n"; wait; return 1 } "No address associated with name" { catch {close}; send_user "\nError: Unknown host $router\n"; wait; return 1 } -re "(Host key not found |The authenticity of host .* be established)" { expect { -re "\\(yes\/no\[^\\)]*\\)\\?" { send "yes\r"; send_user "\nHost $router added to the list of known hosts.\n" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } exp_continue } -re "HOST IDENTIFICATION HAS CHANGED" { send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re " strict checking\.\[\r\n]+" { } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -re "Offending key for " { send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n" expect { -re "\\(yes\/no\\)\\?" { send "no\r" } -re "\[^\r\n]*\[\r\n]+" { exp_continue; } } catch {close}; catch {wait}; return 1 } -nocase -re "^warning: remote host denied authentication agent forwarding." { exp_continue; } -re "(denied|Sorry)" { send_user "\nError: Check your passwd for $router\n" catch {close}; wait; return 1 } -nocase -re "successful login:" { exp_continue } -nocase -re "failed login:" { exp_continue } "Login failed" { send_user "\nError: Check your passwd for $router\n" return 1 } -re "% (Bad passwords|Authentication failed)" { send_user "\nError: Check your passwd for $router\n" return 1 } "Press any key to continue." { # send_user "Pressing the ANY key\n" send "\r" exp_continue } "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" exp_continue } -re "Last login:" { exp_continue } -re "@\[^\r\n]+ $p_prompt" { # ssh pwd prompt sleep 1 send "$userpswd\r" exp_continue } -re "$p_prompt" { sleep 1 if {$uprompt_seen == 1} { send "$userpswd\r" } else { send "$passwd\r" } exp_continue } -re "$prompt" { break; } "Login invalid" { send_user "\nError: Invalid login: $router\n"; catch {close}; wait; return 1 } } } set in_proc 0 return 0 } # Run commands given on the command line. proc run_commands { prompt command } { global do_interact in_proc set in_proc 1 #exp_internal 1 # send "set cli pager off\r" send "\r" expect -re $prompt {} regsub ">$" $prompt {[>#]} reprompt expect * ; # throw away everything in the expect buffer # handle escaped ;s in commands, and ;; and ^; regsub -all {([^\\]);} $command "\\1\u0002;" esccommand regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command regsub {^;} $command "\u0002;" esccommand regsub -all {[\\];} $esccommand ";" command regsub -all {\u0002;} $command "\u0002" esccommand set sep "\u0002" set commands [split $esccommand $sep] set num_commands [llength $commands] for {set i 0} {$i < $num_commands} { incr i} { send -- "[subst -nocommands [lindex $commands $i]]\r" expect { -re "^\[^\n\r]*$reprompt" {} -re "^\[^\n\r ]*>>.*$reprompt" { exp_continue } -re "\[\n\r]+" { exp_continue } } } if { $do_interact == 1 } { interact return 0 } send "exit\r" expect { "\n" { exp_continue } "\[^\n\r *]*Session terminated" { return 0 } timeout { catch {close}; wait return 0 } eof { return 0 } } set in_proc 0 exp_internal 0 } # # For each router... (this is main loop) # source_password_file $password_file set in_proc 0 foreach router [lrange $argv $i end] { set router [string tolower $router] send_user "$router\n" # device timeout set timeout [find timeout $router] if { [llength $timeout] == 0 } { set timeout $timeoutdflt } # palo alto doesn't have an enable mode. XXX is this necessary? set autoenable 1 set enable 1 set prompt ">" ;# initialize a default prompt # 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] ""] } # Figure out username if {[info exists username]} { # command line username set ruser $username } else { 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 } else { set userpswd [join [find userpassword $router] ""] if { "$userpswd" == "" } { set userpswd $passwd } } set p_prompt [find passprompt $router] if { "$p_prompt" == "" } { set p_prompt "\[Pp]assword:" } else { set p_prompt [join [lindex $p_prompt 0] ""] } # Figure out identity file to use set identfile [join [lindex [find identity $router] 0] ""] # Figure out cypher type if {[info exists cypher]} { # command line cypher type set cyphertype $cypher } else { set cyphertype [find cyphertype $router] } # Figure out connection method set cmethod [find method $router] if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} } # Figure out the SSH executable name set sshcmd [join [lindex [find sshcmd $router] 0] ""] if { "$sshcmd" == "" } { set sshcmd {ssh} } # Figure out the telnet executable name set telnetcmd [join [lindex [find telnetcmd $router] 0] ""] if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" } # if [-mM], skip do not login if { $do_cloginrcdbg > 0 } { continue; } # Login to the router if {[login $router $ruser $userpswd $passwd $cmethod $cyphertype $identfile ]} { continue } # we are logged in, now figure out the full prompt send "\r" expect { -re "\[\r\n]+" { exp_continue; } -re "^(.+$prompt)" { set junk $expect_out(0,string); # if it has HA (high avail), the prompt will # be "something-(.)->" regsub -all "\[\]\)\(\[]" $junk {\\&} prompt; } } # PAN-OS in interactive mode will send a newline and then redraw the # whole prompt-and-command if you send a space. if { $do_command || $do_script } { set cmd "set cli scripting-mode on\r" send $cmd # ensure we eat the partial commands redrawn while entering the command expect -re "$cmd.*$prompt" {} send "set cli pager off\r" expect -re $prompt {} } if { $do_command } { if {[run_commands $prompt $command]} { continue } } elseif { $do_script } { source $sfile close } else { label $router log_user 1 interact } # End of for each router wait sleep 0.3 } exit 0 rancid-3.13/bin/rancid.in000644 015615 000000 00000010213 13657102757 015330 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ @copyright@ # # RANCID - Really Awesome New Cisco confIg Differ # # rancid - generalized rancid module; command schedule is derived from the # rancid.types.{base,conf} configurations. # # usage: rancid [-dhltCV] -t device_type [-f filename | hostname] # use 5.010; use strict 'vars'; use warnings; no warnings 'uninitialized'; use Exporter; use Getopt::Std; our($opt_d, $opt_f, $opt_h, $opt_l, $opt_t, $opt_C, $opt_V); getopts('dfhlt:CV'); BEGIN { push(@INC, "@pkglibdir@"); } use rancid; our @ISA = qw(Exporter rancid); sub usage() { print STDERR "rancid [-dhlCV] -t device_type [-f filename | hostname]\n"; exit 64; } if ($opt_h) { usage(); } # basic initialization rancidinit(); # load device type spec, build @commandtable and load modules if (loadtype($devtype)) { die "Couldn't load device type spec for $rancid::devtype\n"; } if (! defined($lscript)) { die "login script not defined for device type $rancid::devtype\n"; } # if the first word of $script is not us (this script), exec the given # script. my(@script) = split(/\s+/, $script); if (which($script[0]) ne which($0)) { # -[hCV] are not handled; they will have already been handled earlier. push(@script, "-d") if $opt_d; push(@script, "-l") if $opt_l; push(@script, "-f") if $opt_f; push(@script, $host); if ($debug) { print(STDERR "device script ($script[0]) does not appear to be me ($0)". ": exec(". join(" ", @script) .")\n"); } # there is no way to prevent an error msg from exec such that the die error # is the only one displayed, without also leaving the child without a # working STDERR. exec(join(" ", @script)) || die "exec($script[0]) failed: $!\n"; } # check that inloop, the input/main loop, is defined if (!defined($inloop) || length($inloop) < 1) { die "inloop is not configured for device type $devtype"; } # open the temporary file for the digested output open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n"; select(OUTPUT); if (length($#modules)) { my($module); foreach $module (@modules) { (my $file = $module) =~ s/::/\//g; my($err) = 0; # call module->init(); we expect 0 as success, as god intended it eval "\$err = ". $module ."::init();"; if ($@) { printf(STDERR "loadtype: initializing $module failed: %s\n", $@); exit 1; } elsif ($err) { printf(STDERR "loadtype: %s::init() returned failure\n", $module); exit 1; } } } # open the input; a pre-collected file or start a login for a login stream or # temporary file if ($file) { print(STDERR "opening file $host\n") if ($debug || $log); open(INPUT,"<$host") || die "open failed for $host: $!\n"; } else { my $cstr = $commandstr; $cstr =~ s/\"/\\\"/g; print(STDERR "executing $lscript -t $timeo -c\"$cstr\" $host\n") if ($debug || $log); system "$lscript -t $timeo -c \"$cstr\" $host $host.raw 2>&1" || die "clogin failed for $host: $!\n"; open(INPUT, "< $host.raw") || die "clogin failed for $host: $!\n"; } # loop over the input using the provided input/main loop eval($inloop ."(*INPUT, *OUTPUT);") && die "${inloop} failed: $@\n"; print STDOUT "Done $lscript: $_\n" if ($log); # Flush History ProcessHistory("","","",""); # Cleanup close(INPUT); close(OUTPUT); unlink("$host.raw") if (! $debug); # check for completeness if (scalar(%commands) || !$clean_run || !$found_end) { if (scalar(keys %commands) eq $commandcnt) { printf(STDERR "$host: missed cmd(s): all commands\n"); } elsif (scalar(%commands)) { my($count, $i) = 0; for ($i = 0; $i < $#commands; $i++) { if ($commands{$commands[$i]}) { if (!$count) { printf(STDERR "$host: missed cmd(s): %s", $commands[$i]); } else { printf(STDERR ", %s", $commands[$i]); } $count++; } } if ($count) { printf(STDERR "\n"); } } if (!$clean_run || !$found_end) { print(STDERR "$host: End of run not found\n"); if ($debug) { print(STDERR "$host: clean_run is false\n") if (!$clean_run); print(STDERR "$host: found_end is false\n") if (!$found_end); } system("/usr/bin/tail -1 $host.new"); } unlink "$host.new" if (! $debug); } rancid-3.13/bin/Makefile.am000644 015615 000000 00000010451 13713052202 015556 0ustar00heaswheel000000 000000 ## Process this file with automake to produce Makefile.in ## A Makefile.in is supplied, in case you do not have automake. ## Copyright (c) 1997-2019 by Henry Kilmer and John Heasley ## All rights reserved. ## ## Please see the file COPYING for the text of the license. #AUTOMAKE_OPTIONS=foreign no-dependencies AUTOMAKE_OPTIONS=foreign bin_PROGRAMS = hpuifilter par bin_SCRIPTS = a10login alogin agmrancid anlogin arancid \ avologin blogin brancid brlogin cat5rancid clogin \ control_rancid csblogin cssrancid \ dllogin elogin erancid f5rancid \ flogin fnlogin fxlogin hlogin hrancid htlogin \ htrancid jerancid jlogin mrancid mrvlogin mtlogin \ nlogin noklogin nrancid nslogin nsrancid panlogin plogin \ rancid rblogin rivlogin \ rivrancid rrancid rtftpcopy tlogin trancid ulogin wlogin \ xilogin xirancid xlogin # XXX hack for the rancid to get pkglibdir, see corresponding XXX below bin_in = control_rancid.in hrancid.in plogin.in rancid.in bin_SCRIPTS += lg.cgi lgform.cgi rancid-cvs rancid-fe rancid-run EXTRA_DIST= lg.cgi.in lgform.cgi.in rancid-cvs.in rancid-fe.in rancid-run.in \ $(bin_in) login_top.in #dist_bin_SCRIPTS= $(bin_SCRIPTS:%=%.in) CLEANFILES= lg.cgi lgform.cgi plogin rancid rancid-cvs rancid-fe rancid-run #CLEANFILES= $(bin_SCRIPTS) hpuifilter_SOURCES = hpuifilter.c par_SOURCES = par.c #CPPFLAGS += @PG_CPPFLAGS@ #INCLUDES += -I$(top_srcdir)/include @PG_CPPFLAGS@ #INCLUDES += -I$(top_srcdir)/include #CFLAGS += -g CFLAGS = -g -O0 YFLAGS = -d #LFLAGS = -i # no idea why automake doesnt clean these targets #CLEANFILES= y.tab.c y.tab.h lex.yy.c conf.h conf.c conflex.c #clean: # rm -f Makefile env $(BIN_DATAS) $(BIN_PROGS) # auto_edit does the autoconf variable substitution. This allows the # substitution to have the full expansion of the variables, e.g.: $sysconfdir # will be /prefix/etc instead of ${prefix}/etc. # # This is a bit of a PITA, but is the method recommended by the autoconf # documentation. auto_edit = sed \ -e 's,@prefix\@,$(prefix),g' \ -e 's,@localstatedir\@,$(localstatedir),g' \ -e 's,@pkglibdir\@,$(pkglibdir),g' \ -e 's,@sysconfdir\@,$(sysconfdir),g' \ -e 's,@DIFF_CMD\@,$(DIFF_CMD),g' \ -e 's,@EXPECT_PATH\@,$(EXPECT_PATH),g' \ -e 's,@PERLV\@,$(PERLV),g' \ -e 's,@PERLV_PATH\@,$(PERLV_PATH),g' \ -e 's,@PYTHON3\@,$(PYTHON3),g' \ -e 's,@PYTHON3_PATH\@,$(PYTHON3_PATH),g' \ -e 's,@LG_PING_CMD\@,$(LG_PING_CMD),g' \ -e 's,@ADMINMAILPLUS\@,$(ADMINMAILPLUS),g' \ -e 's,@LOCKPROG\@,$(LOCKPROG),g' \ -e 's,@MAILPLUS\@,$(MAILPLUS),g' \ -e 's,@PACKAGE\@,$(PACKAGE),g' \ -e 's,@SVN_FSTYPE\@,$(SVN_FSTYPE),g' \ -e 's,@SENDMAIL\@,$(SENDMAIL),g' \ -e 's,@VERSION\@,$(VERSION),g' \ -e 's,@COPYYEARS\@,$(COPYYEARS),g' \ -e '/@copyright@/r ../COPYING' -e '/@copyright@/d' # XXX this is the generic version for the rest of bin_scripts that comes from # configure.in now. perhaps change to use this. $(bin_in:%.in=%): Makefile $(top_builddir)/config.status ../COPYING rm -f $@ $@.tmp; \ $(auto_edit) $(srcdir)/$@.in >$@.tmp; \ chmod +x $@.tmp; \ mv $@.tmp $@ # XXX there must be a better way to produce these dependencies, perhaps in # configure, but more likely need a depend target. alogin: $(srcdir)/alogin.in control_rancid: $(srcdir)/control_rancid.in hlogin: $(srcdir)/hlogin.in hrancid: $(srcdir)/hrancid.in plogin: $(srcdir)/plogin.in rancid: $(srcdir)/rancid.in lg.cgi: Makefile $(srcdir)/lg.cgi.in rm -f lg.cgi lg.cgi.tmp; \ $(auto_edit) $(srcdir)/lg.cgi.in >lg.cgi.tmp; \ chmod +x lg.cgi.tmp; \ mv lg.cgi.tmp lg.cgi lgform.cgi: Makefile $(srcdir)/lgform.cgi.in rm -f lgform.cgi lgform.cgi.tmp; \ $(auto_edit) $(srcdir)/lgform.cgi.in >lgform.cgi.tmp; \ chmod +x lgform.cgi.tmp; \ mv lgform.cgi.tmp lgform.cgi rancid-cvs: Makefile $(srcdir)/rancid-cvs.in rm -f rancid-cvs rancid-cvs.tmp; \ $(auto_edit) $(srcdir)/rancid-cvs.in >rancid-cvs.tmp; \ chmod +x rancid-cvs.tmp; \ mv rancid-cvs.tmp rancid-cvs rancid-fe: Makefile $(srcdir)/rancid-fe.in rm -f rancid-fe rancid-fe.tmp; \ $(auto_edit) $(srcdir)/rancid-fe.in >rancid-fe.tmp; \ chmod +x rancid-fe.tmp; \ mv rancid-fe.tmp rancid-fe rancid-run: Makefile $(srcdir)/rancid-run.in rm -f rancid-run rancid-run.tmp; \ $(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 $(bin_SCRIPTS): ../COPYING login_top rancid-3.13/bin/jerancid.in000644 015615 000000 00000053035 13657102757 015660 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # jerancid - tries to deal with Juniper ERXs. # # RANCID - Really Awesome New Cisco confIg Differ # # usage: jerancid [-dltCV] [-f filename | hostname] # use Getopt::Std; getopts('dflt:CV'); if ($opt_V) { print "@PACKAGE@ @VERSION@\n"; exit(0); } $log = $opt_l; $debug = $opt_d; $file = $opt_f; $host = $ARGV[0]; $clean_run = 0; $found_end = 0; $timeo = 90; # clogin timeout in seconds my(@commandtable, %commands, @commands);# command lists my($aclsort) = ("ipsort"); # ACL sorting mode my($filter_commstr); # SNMP community string filtering my($filter_osc); # oscillating data filtering mode 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)) && scalar(%history)) { print eval "$command \%history"; undef %history; } if (($new_hist_tag) && ($new_command) && ($command_string)) { if ($history{$command_string}) { $history{$command_string} = "$history{$command_string}@string"; } else { $history{$command_string} = "@string"; } } elsif (($new_hist_tag) && ($new_command)) { $history{++$#history} = "@string"; } else { print "@string"; } $hist_tag = $new_hist_tag; $command = $new_command; 1; } sub numerically { $a <=> $b; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort numerically keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort values %lines) { $sorted_lines[$i] = $key; $i++; } @sorted_lines; } # This is a numerical sort routine (ascending). sub numsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $num (sort {$a <=> $b} keys %lines) { $sorted_lines[$i] = $lines{$num}; $i++; } @sorted_lines; } # This is a sort routine that will sort on the # ip address when the ip address is anywhere in # the strings. sub ipsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $addr (sort sortbyipaddr keys %lines) { $sorted_lines[$i] = $lines{$addr}; $i++; } @sorted_lines; } # 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])); } sub sortbyipaddr { &ipaddrval($a) <=> &ipaddrval($b); } # This routine parses "show version" sub ShowVersion { print STDERR " In ShowVersion: $_" if ($debug); my($slots); while () { tr/\015//d; last if(/^$prompt/); next if(/^(\s*|\s*$cmd\s*)$/); next if (/^Please wait/i); return(-1) if (/command authorization failed/i); /^Juniper Edge .* (\S+)$/ && ProcessHistory("COMMENTS","keysort","A1", "!Chassis type: $1 - a $_") && next; /^System Release: / && ProcessHistory("COMMENTS","keysort","B1", "!$_") && next; /^\s+(Version: .*)$/ && ProcessHistory("COMMENTS","keysort","B1", "!System $1\n") && next; if (/^(slot .*)\s+slot uptime/i) { ($slots++); ProcessHistory("COMMENTS","keysort","B2", "!\n! $1\n"); next; } /^(--.*) --+$/ && $slots && ProcessHistory("COMMENTS","keysort","B2", "! $1\n") && next; if (/^(\d+\s+(\S+)\s+\S+\s+.*) \S+/ && $slots) { my($line) = $1; if (! ($2 =~ /--+/)) { ProcessHistory("COMMENTS","keysort","B3", "! $line\n"); } next; } } ProcessHistory("COMMENTS","keysort","B4","!\n"); return(0); } # This routine parses "show redundancy" sub ShowRedundancy { print STDERR " In ShowRedundancy: $_" if ($debug); while () { tr/\015//d; last if(/^$prompt/); next if(/^(\s*|\s*$cmd\s*)$/); next if (/^Please wait/i); ProcessHistory("","","","! $_"); } ProcessHistory("","","","!\n"); return(0); } # This routine parses "show environment all" sub ShowEnv { print STDERR " In ShowEnv: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^Please wait/i); return(-1) if (/command authorization failed/i); # fail if the RP is amid the auto-sync process if (/auto-sync enabled/ && !/in sync/) { $in_sync = ; $in_sync =~ s/\015//; print STDERR $in_sync if ($debug); return(-1) if ( $in_sync !~ /in sync/); s/^ //; ProcessHistory("COMMENTS","keysort","D1","! $_"); $_ = $in_sync; } # skip/remove temperatures if (/processor\s+processor/) { ; ; ; next; } if (/^[\d\/]+\s+[-\w\/\s]+\s+\d+.*/) { s/(^[\d\/]+\s+[-\w\/\s]+\s+)(\d+)(.*)/$1 -removed- $3/; } /^\d+\s+\d+\s+\S+/ && next; # strip nvs usage s/, \d+% \S+\)/\)/; s/^ //; ProcessHistory("COMMENTS","keysort","D1","! $_"); } ProcessHistory("COMMENTS","keysort","D1","!\n"); return(0); } # This routine parses "show boot" sub ShowBoot { print STDERR " In ShowBoot: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^Please wait/i); next if (/^\s*$/); return(1) if /^\s*\^\s*$/; return(-1) if (/command authorization failed/i); return(1) if /Ambiguous command/i; /System Release:\s+(.*)/ && ProcessHistory("COMMENTS","keysort","C1","!Boot Release: $1\n") && next; /System Configuration:\s+(.*)/ && ProcessHistory("COMMENTS","keysort","C1", "!Boot Configuration: $1\n") && next; ProcessHistory("COMMENTS","keysort","C1","!$_"); } ProcessHistory("COMMENTS","keysort","C1","!\n"); return(0); } # This routine parses "dir" sub DirSlotN { print STDERR " In DirSlotN: $_" if ($debug); my($dev) = (/\s([^\s]+):/); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^Please wait/i); next if (/^system\.log/); # 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"); return(0); } # This routine parses "show hardware" sub ShowHardware { print STDERR " In ShowHardware: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^Please wait/i); # return(1) if ($type =~ /^(12[40]|7[05])/); return(-1) if (/command authorization failed/i); next if (/^Please wait/i); # wow...a clean table ProcessHistory("","","","!$_"); } ProcessHistory("","","","!\n"); return(0); } # This routine processes a "show configuration" sub WriteTerm { print STDERR " In WriteTerm: $_" if ($debug); my($lineauto) = 0; while () { tr/\015//d; last if(/^$prompt/); next if (/^Please wait/i); return(-1) if (/command authorization failed/i); /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked $lineauto = 0 if (/^[^ ]/); # skip the crap /^! Configuration script /i && next; /^! Copyright /i && next; /^Please wait/i && next; /^(\.+)$/ && next; # Skip variable length pausing dot lines # Dog gone Cool matches to process the rest of the config /^ntp clock-period / && next; # kill ntp clock-period /^ length / && next; # kill length on serial lines /^ width / && next; # kill width on serial lines $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 \n"); next; } if (/^(enable secret) / && $filter_pwds >= 2) { ProcessHistory("ENABLE","","","!$1 \n"); next; } # XXX: ERX appears to not have local usernames, but leaving these in # case I am wrong. if (/^username (\S+)(\s.*)? secret /) { if ($filter_pwds >= 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 secret \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^username (\S+)(\s.*)? password ((\d) \S+|\S+)/) { if ($filter_pwds == 2) { ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } elsif ($filter_pwds == 1 && $4 ne "5"){ ProcessHistory("USER","keysort","$1", "!username $1$2 password \n"); } else { ProcessHistory("USER","keysort","$1","$_"); } next; } if (/^(\s*)password / && $filter_pwds >= 1) { ProcessHistory("LINE-PASS","","","!$1password \n"); next; } if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) { ProcessHistory("","","","! neighbor $1 password \n"); next; } if (/^(ppp .* password) 7 .*/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # isis interface passwords if (/^(\s+isis authentication-key \S+)( \d)? \S+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'\n"); next; } if (/^(\s+isis message-digest-key \d+ hmac-md5)( \d)?( \S+)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # this is reversable, despite 'md5' in the cmd if (/^(\s+ip ospf authentication-key \S+)( \d)? \S+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'\n"); next; } if (/^(\s+ip ospf message-digest-key \d+ hmac-md5)( \d)?( \S+)/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # filter VRRP passwords if (/^(\s+ip vrrp authentication-key \d+)( \d)? \s+ / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # ftp host encrypted password oscillates if (/^(host \S+ \S+ ftp) /) { my($prefix) = $1; if (($filter_osc || $filter_pwds >= 1) && /^host \S+ \S+ ftp \d /) { ProcessHistory("","","","!$prefix \n"); next; } } # mpls ldp encrypted password oscillates if (/^(mpls ldp neighbor \S+ password)/) { my($prefix) = $1; if (($filter_osc || $filter_pwds >= 1) && /^mpls ldp neighbor \S+ password \d /) { ProcessHistory("","","","!$prefix \n"); next; } } # sort ip explicit-paths. if (/^ip explicit-path name (\S+)/) { my($key) = $1; my($expath) = $_; while () { tr/\015//d; last if (/^$prompt/); last if (/^$prompt/ || ! /^(ip explicit-path name |[ !])/); if (/^ip explicit-path name (\S+)/) { ProcessHistory("EXPATH","keysort","$key","$expath"); $key = $1; $expath = $_; } else { $expath .= $_; } } ProcessHistory("EXPATH","keysort","$key","$expath"); } # sort route-maps if (/^route-map (\S+)/) { my($key) = $1; my($routemap) = $_; while () { tr/\015//d; last if (/^$prompt/ || ! /^(route-map |[ !])/); if (/^route-map (\S+)/) { ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); $key = $1; $routemap = $_; } else { $routemap .= $_; } } ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); } # filter out any RCS/CVS tags to avoid confusing local CVS storage s/\$(Revision|Id):/ $1:/; # order arp lists /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ && ProcessHistory("ARP","$aclsort","$1","$_") && next; /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ && ProcessHistory("PACL $1 $3","$aclsort","$4", "ip prefix-list $1 $3 $4$5\n") && next; # order/prune snmp-server host statements # we only prune lines of the form # snmp-server host a.b.c.d if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) { if ($filter_commstr) { my($ip) = $1; my($line) = "snmp-server host $ip"; my(@tokens) = split(' ', $'); my($token); while ($token = shift(@tokens)) { if ($token eq 'version' || $tokens[0] == 1) { $line .= " " . join(' ', ($token, shift(@tokens))); } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) { $line .= " " . $token; } else { $line = "!$line " . join(' ', ("", join(' ',@tokens))); last; } } ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); } else { ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); } next; } if (/^(snmp-server community) (\S+)/) { if ($filter_commstr) { ProcessHistory("SNMPSERVERCOMM","keysort","$_","!$1 $'"); next; } else { ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; } } # prune tacacs/radius server keys if (/^(tacacs-server|radius-server) key / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 key \n"); next; } if (/^((tacacs-server|radius-server) host \S+ key)( \d)? \S+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } if (/^( key )(\d )?\S+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'"); next; } # order clns host statements /^clns host \S+ (\S+)/ && ProcessHistory("CLNS","keysort","$1","$_") && next; # order alias statements /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next; # filter isis keys if (/^( (area|domain)-message-digest-key \d+ hmac-md5)( \d)? \S+/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'\n"); next; } if (/^( (area|domain)-authentication-key)( \d)? \S+( \d)?/ && $filter_pwds >= 1) { ProcessHistory("","","","!$1 $'\n"); next; } # delete ntp auth password - this md5 is a reversable too if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { ProcessHistory("","","","!$1 \n"); next; } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); ProcessHistory("NTP","keysort",$sortkey,"$_"); next; } # catch anything that wasnt matched above. ProcessHistory("","","","$_"); # end of config...is a comment. if (/^! end of /i) { $found_end = 1; return(1); } } return(0); } # Main @commandtable = ( {'show version' => 'ShowVersion'}, {'show redundancy' => 'ShowRedundancy'}, {'show boot' => 'ShowBoot'}, {'show environment all' => 'ShowEnv'}, {'dir' => 'DirSlotN'}, {'show hardware' => 'ShowHardware'}, {'show configuration' => '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); $commandcnt = scalar(keys %commands); $jnxe_cmds=join(";",@commands); $cmds_regexp = join("|", map quotemeta($_), @commands); if (length($host) == 0) { if ($file) { print(STDERR "Too few arguments: file name required\n"); exit(1); } else { print(STDERR "Too few arguments: host name required\n"); exit(1); } } if ($opt_C) { print "clogin -t $timeo -c\'$jnxe_cmds\' $host\n"; exit(0); } open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n"; select(OUTPUT); # make OUTPUT unbuffered if debugging if ($debug) { $| = 1; } if ($file) { print(STDERR "opening file $host\n") if ($debug || $log); open(INPUT,"<$host") || die "open failed for $host: $!\n"; } else { print(STDERR "executing clogin -t $timeo -c\"$jnxe_cmds\" $host\n") if ($debug || $log); system "clogin -t $timeo -c \"$jnxe_cmds\" $host $host.raw 2>&1" || die "clogin failed for $host: $!\n"; open(INPUT, "< $host.raw") || die "clogin failed for $host: $!\n"; } # 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; } if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) { $filter_osc = 0; } else { $filter_osc = 1; } # determine oscillating data filtering mode if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) { $filter_osc = 0; } else { $filter_osc = 1; } # determine password filtering mode if ($ENV{"FILTER_PWDS"} =~ /no/i) { $filter_pwds = 0; } elsif ($ENV{"FILTER_PWDS"} =~ /all/i) { $filter_pwds = 2; } else { $filter_pwds = 1; } ProcessHistory("","","","!RANCID-CONTENT-TYPE: erx\n!\n"); ProcessHistory("COMMENTS","keysort","B0","!\n"); ProcessHistory("COMMENTS","keysort","F0","!\n"); ProcessHistory("COMMENTS","keysort","G0","!\n"); TOP: while() { tr/\015//d; if (/\#\s?exit$/) { $clean_run=1; last; } if (/^Error:/) { print STDOUT ("$host clogin error: $_"); print STDERR ("$host clogin error: $_") if ($debug); $clean_run=0; last; } while (/#\s*($cmds_regexp)\s*$/) { $cmd = $1; if (!defined($prompt)) { $prompt = ($_ =~ /^([^#]+#)/)[0]; $prompt =~ s/([][}{)(\\])/\\$1/g; print STDERR ("PROMPT MATCH: $prompt\n") if ($debug); } print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } print STDOUT "Done $logincmd: $_\n" if ($log); # Flush History ProcessHistory("","","",""); # Cleanup close(INPUT); close(OUTPUT); unlink("$host.raw") if (! $debug); # check for completeness if (scalar(%commands) || !$clean_run || !$found_end) { if (scalar(keys %commands) eq $commandcnt) { printf(STDERR "$host: missed cmd(s): all commands\n"); } elsif (scalar(%commands)) { my($count, $i) = 0; for ($i = 0; $i < $#commands; $i++) { if ($commands{$commands[$i]}) { if (!$count) { printf(STDERR "$host: missed cmd(s): %s", $commands[$i]); } else { printf(STDERR ", %s", $commands[$i]); } $count++; } } if ($count) { printf(STDERR "\n"); } } if (!$clean_run || !$found_end) { print(STDERR "$host: End of run not found\n"); if ($debug) { print(STDERR "$host: clean_run is false\n") if (!$clean_run); print(STDERR "$host: found_end is false\n") if (!$found_end); } system("/usr/bin/tail -1 $host.new"); } unlink "$host.new" if (! $debug); } rancid-3.13/bin/login_top.in000644 015615 000000 00000020516 13476001445 016060 0ustar00heaswheel000000 000000 # Usage line set usage "Usage: $argv0 \[-dhiSV\] \[-m|M\] \[-autoenable\] \[-noenable\] \ \[-c command\] \[-Evar=x\] \[-e enable-password\] \[-f cloginrc-file\] \ \[-p user-password\] \[-r passphrase\] \[-s script-file\] \[-t timeout\] \ \[-u username\] \[-v vty-password\] \[-w enable-username\] \[-x command-file\] \ \[-y ssh_cypher_type\] router \[router...\]\n" # Password file set password_file $env(HOME)/.cloginrc # Default is to login to the router set do_command 0 set do_interact 0 set do_script 0 # The default is to automatically enable if {! [info exists avenable]} { set avenable 1 } # The default is that you login non-enabled (tacacs can have you login already # enabled) 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 set do_enapasswd 1 # Save config, if prompted set do_saveconfig 0 # cloginrc debugging knob set do_cloginrcdbg 0 # Sometimes routers take awhile to answer (the default is 10 sec) if {! [info exists timeoutdflt]} { set timeoutdflt 10 } # spawn tty options set spawnopts {} # intialize cloginrc parsing stacks set int_file {} set int_lineno {} # env(CLOGIN) may contain: # x == do not set xterm banner or name # Find the user in the ENV, or use the unix userid. if {![info exists default_user] && [info exists env(CISCO_USER)]} { if {[string length $env(CISCO_USER)]} { set default_user $env(CISCO_USER) } } if {![info exists default_user] && [info exists env(USER)]} { if {[string length $env(USER)]} { set default_user $env(USER) } } if {![info exists default_user] && [info exists env(LOGNAME)]} { if {[string length $env(LOGNAME)]} { set default_user $env(LOGNAME) } } if (![info exists 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. if [catch {exec id} reason] { send_error "\nError: could not exec id: $reason\n" exit 1 } regexp {\(([^)]*)} "$reason" junk default_user } if {[info exists env(CLOGINRC)]} { set password_file $env(CLOGINRC) } # Process the command line for {set i 0} {$i < $argc} {incr i} { set arg [lindex $argv $i] switch -glob -- $arg { # Expect debug mode -d* { exp_internal 1 # Help } -h* { send_user "$usage" exit 0 # Command to run. } -c* { if {! [regexp .\[cC\](.+) $arg ignore command]} { incr i set command [lindex $argv $i] } set do_command 1 # Enable Password } -e* { if {! [regexp .\[e\](.+) $arg ignore enapasswd]} { incr i set enapasswd [lindex $argv $i] } set do_enapasswd 0 # Environment variable to pass to -s scripts } -E* { if {[regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} { set E$varname $varvalue } else { send_user "\nError: invalid format for -E in $arg\n" exit 1 } # alternate cloginrc file } -f* { if {! [regexp .\[fF\](.+) $arg ignore password_file]} { incr i set password_file [lindex $argv $i] } # interactive } -i* { set do_interact 1 # user Password } -p* { if {! [regexp .\[pP\](.+) $arg ignore userpasswd]} { incr i set userpasswd [lindex $argv $i] } set do_passwd 0 # cloginrc debugging knobs } -m* { set do_cloginrcdbg 1 } -M* { set do_cloginrcdbg 2 # ssh passphrase } -r* { if {! [regexp .\[rR\](.+) $arg ignore passphrase]} { incr i set avpassphrase [lindex $argv $i] } # Expect script to run. } -s* { if {! [regexp .\[sS\](.+) $arg ignore sfile]} { incr i set sfile [lindex $argv $i] } if {! [file readable $sfile]} { send_user "\nError: Can't read $sfile\n" exit 1 } set do_script 1 # save config on exit } -S* { # may not be supported by the script and may not be applicable to # the platform set do_saveconfig 1 # Timeout } -t* { if {! [regexp .\[tT\](.+) $arg ignore timeout]} { incr i set timeoutdflt [lindex $argv $i] } # Username } -u* { if {! [regexp .\[uU\](.+) $arg ignore user]} { incr i set username [lindex $argv $i] } # VTY Password } -v* { # some scripts ignore -v, like jlogin if {! [regexp .\[vV\](.+) $arg ignore passwd]} { incr i set passwd [lindex $argv $i] } set do_passwd 0 # Version string } -V* { send_user "@PACKAGE@ @VERSION@\n" exit 0 # Enable Username } -w* { # may not be supported by the script and may not be applicable to # the platform if {! [regexp .\[wW\](.+) $arg ignore enauser]} { incr i set enausername [lindex $argv $i] } # Command file } -x* { if {! [regexp .\[xX\](.+) $arg ignore cmd_file]} { incr i set cmd_file [lindex $argv $i] } 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 # 'ssh -c' cypher type } -y* { if {! [regexp .\[eE\](.+) $arg ignore cypher]} { incr i set cypher [lindex $argv $i] } # Do we enable? } -noenable { set avenable 0 # Does tacacs automatically enable us? } -autoenable { set avautoenable 1 set avenable 0 } -* { send_user "\nError: Unknown argument! $arg\n" send_user $usage exit 1 } default { break } } } # Process routers...no routers listed is an error. if {$i == $argc} { send_user "\nError: $usage" } # Only be quiet if we are running a script (it can log its output # on its own) if {$do_script} { log_user 0 } else { log_user 1 } # # Done configuration/variable setting. Now run with it... # # 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 } } # take host from ENV(TERM) 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" } } } # This is a helper function to make the password file easier to # maintain. Using this the password file has the form: # add password sl* pete cow # add password at* steve # add password * hanky-pie proc add {var args} { global int_file int_lineno int_$var set file [lindex $int_file 0] set lineno [lindex $int_lineno 0] lappend int_$var "$var:$file:$lineno: $args" } proc include {args} { global env regsub -all "(^{|}$)" $args {} args if {[regexp "^/" $args ignore] == 0} { set args $env(HOME)/$args } source_password_file $args } proc find {var router} { global do_cloginrcdbg upvar int_$var list if {[info exists list]} { foreach line $list { if {[string match -nocase [lindex $line 1] $router]} { if {$do_cloginrcdbg > 0} { send_error -- [join [list [lindex $line 0] [lrange $line 1 end] "\r\n"]] } if {$do_cloginrcdbg == 2} { # save return value if {! [info exists result]} { set result [lrange $line 2 end] } } else { return [lrange $line 2 end] } } } } if {$do_cloginrcdbg == 2} { if {[info exists result]} { return $result } } return {} } # Loads the password file. Note that as this file is tcl, and that # it is sourced, the user better know what to put in there, as it # could install more than just password info... I will assume however, # 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 {file} { global env int_file int_lineno if {! [file exists $file]} { send_user "\nError: password file ($file) does not exist\n" exit 1 } file stat $file fileinfo if {[expr ($fileinfo(mode) & 007)] != 0000} { send_user "\nError: $file must not be world readable/writable\n" exit 1 } if [catch {set fd [open $file "r"]} reason] { send_user "\nError: $reason\n" exit 1 } set int_file [linsert $int_file 0 $file] set int_lineno [linsert $int_lineno 0 0] while {[gets $fd line] >= 0} { set tmp [lindex $int_lineno 0]; incr tmp lset int_lineno 0 $tmp eval $line } set int_file [lrange $int_file 1 end] set int_lineno [lrange $int_lineno 1 end] close $fd } rancid-3.13/bin/nsrancid.in000644 015615 000000 00000023722 13534014765 015675 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # hacked version of Hank's rancid - this one tries to deal with Netscalers. # Hacks from Anshuman Kanwar. # # RANCID - Really Awesome New Cisco confIg Differ # # usage: nsrancid [-dltCV] [-f filename | hostname] # use Getopt::Std; getopts('dflt:CV'); if ($opt_V) { print "@PACKAGE@ @VERSION@\n"; exit(0); } $log = $opt_l; $debug = $opt_d; $file = $opt_f; $host = $ARGV[0]; $clean_run = 0; $found_end = 0; $timeo = 90; # nslogin timeout in seconds my(@commandtable, %commands, @commands);# command lists my($aclsort) = ("ipsort"); # ACL sorting mode my($filter_commstr); # SNMP community string filtering my($filter_osc); # oscillating data filtering mode my($filter_pwds); # password filtering mode $prompt = ">"; # 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)) && scalar(%history)) { print eval "$command \%history"; undef %history; } if (($new_hist_tag) && ($new_command) && ($command_string)) { if ($history{$command_string}) { $history{$command_string} = "$history{$command_string}@string"; } else { $history{$command_string} = "@string"; } } elsif (($new_hist_tag) && ($new_command)) { $history{++$#history} = "@string"; } else { print "@string"; } $hist_tag = $new_hist_tag; $command = $new_command; 1; } sub numerically { $a <=> $b; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort numerically keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort keys(%lines)) { $sorted_lines[$i] = $lines{$key}; $i++; } @sorted_lines; } # 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($i) = 0; local(@sorted_lines); foreach $key (sort values %lines) { $sorted_lines[$i] = $key; $i++; } @sorted_lines; } # This is a numerical sort routine (ascending). sub numsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $num (sort {$a <=> $b} keys %lines) { $sorted_lines[$i] = $lines{$num}; $i++; } @sorted_lines; } # This is a sort routine that will sort on the # ip address when the ip address is anywhere in # the strings. sub ipsort { local(%lines) = @_; local($i) = 0; local(@sorted_lines); foreach $addr (sort sortbyipaddr keys %lines) { $sorted_lines[$i] = $lines{$addr}; $i++; } @sorted_lines; } # 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])); } sub sortbyipaddr { &ipaddrval($a) <=> &ipaddrval($b); } # This routine parses "show ns ns.conf" sub ShowConfig { print STDERR " In ShowConfig: $_" if ($debug); while () { tr/\015//d; last if (/ Done$/); last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); next if (/^Reading configuration information/); next if (/^Can\'t find object or class named \"\-all\"\s*$/); next if (/lock-address .*$/); next if (/^\# *uptime +\d+\s*$/); next if (/^\# last modified/i); if (/community label /) { if ($filter_commstr) { $_ =~ s/community label .*$/community label /; } } return(1) if /(invalid command name)/; ProcessHistory("","","","$_"); } if (/ Done$/) { $found_end = 1; $clean_run = 1; return(1); } return(0); } # This routine parses single command's that return no required info sub RunCommand { print STDERR " In RunCommand: $_" if ($debug); while () { tr/\015//d; last if (/^$prompt/); next if (/^(\s*|\s*$cmd\s*)$/); } return(0) } # Main @commandtable = ( {'show ns ns.conf' => 'ShowConfig'}, ); # 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); $commandcnt = scalar(keys %commands); $commandstr=join(";",@commands); $cmds_regexp = join("|", map quotemeta($_), @commands); if (length($host) == 0) { if ($file) { print(STDERR "Too few arguments: file name required\n"); exit(1); } else { print(STDERR "Too few arguments: host name required\n"); exit(1); } } if ($opt_C) { print "nslogin -t $timeo -c\'$commandstr\' $host\n"; exit(0); } open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n"; select(OUTPUT); # make OUTPUT unbuffered if debugging if ($debug) { $| = 1; } if ($file) { print(STDERR "opening file $host\n") if ($debug || $log); open(INPUT,"<$host") || die "open failed for $host: $!\n"; } else { print(STDERR "executing nslogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log); system "nslogin -t $timeo -c \"$commandstr\" $host $host.raw 2>&1" || die "nslogin failed for $host: $!\n"; open(INPUT, "< $host.raw") || die "nslogin failed for $host: $!\n"; } # 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 oscillating data filtering mode if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) { $filter_osc = 0; } else { $filter_osc = 1; } # determine password filtering mode if ($ENV{"FILTER_PWDS"} =~ /no/i) { $filter_pwds = 0; } elsif ($ENV{"FILTER_PWDS"} =~ /all/i) { $filter_pwds = 2; } else { $filter_pwds = 1; } #print STDOUT "$prompt \n"; ProcessHistory("","","","!RANCID-CONTENT-TYPE: netscaler\n!\n"); TOP: while() { tr/\015//d; if (/^Error:/) { print STDOUT ("$host nslogin error: $_"); print STDERR ("$host nslogin error: $_") if ($debug); $clean_run = 0; last; } while (/$prompt\s*($cmds_regexp)\s*$/) { $cmd = $1; print STDERR ("HIT COMMAND:$_") if ($debug); if (! defined($commands{$cmd})) { print STDERR "$host: found unexpected command - \"$cmd\"\n"; $clean_run = 0; last TOP; } $rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd); delete($commands{$cmd}); if ($rval == -1) { $clean_run = 0; last TOP; } } } print STDOUT "Done $logincmd: $_\n" if ($log); # Flush History ProcessHistory("","","",""); # Cleanup close(INPUT); close(OUTPUT); unlink("$host.raw") if (! $debug); # check for completeness if (scalar(%commands) || !$clean_run || !$found_end) { if (scalar(keys %commands) eq $commandcnt) { printf(STDERR "$host: missed cmd(s): all commands\n"); } elsif (scalar(%commands)) { my($count, $i) = 0; for ($i = 0; $i < $#commands; $i++) { if ($commands{$commands[$i]}) { if (!$count) { printf(STDERR "$host: missed cmd(s): %s", $commands[$i]); } else { printf(STDERR ", %s", $commands[$i]); } $count++; } } if ($count) { printf(STDERR "\n"); } } if (!$clean_run || !$found_end) { print(STDERR "$host: End of run not found\n"); if ($debug) { print(STDERR "$host: clean_run is false\n") if (!$clean_run); print(STDERR "$host: found_end is false\n") if (!$found_end); } system("/usr/bin/tail -1 $host.new"); } unlink "$host.new" if (! $debug); } rancid-3.13/bin/lg.cgi.in000644 015615 000000 00000066637 13713052202 015236 0ustar00heaswheel000000 000000 #! @PERLV_PATH@ ## ## @PACKAGE@ @VERSION@ ## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley ## All rights reserved. ## ## This code is derived from software contributed to and maintained by ## Henry Kilmer, John Heasley, Andrew Partan, ## Pete Whiting, Austin Schutz, and Andrew Fort. ## ## 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. Neither the name of RANCID nor the names of its ## contributors may be used to endorse or promote products derived from ## this software without specific prior written permission. ## ## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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. ## ## It is the request of the authors, but not a condition of license, that ## parties packaging or redistributing RANCID NOT distribute altered versions ## of the etc/rancid.types.base file nor alter how this file is processed nor ## when in relation to etc/rancid.types.conf. The goal of this is to help ## suppress our support costs. If it becomes a problem, this could become a ## condition of license. # # The expect login scripts were based on Erik Sherk's gwtn, by permission. # # The original looking glass software was written by Ed Kern, provided by # permission and modified beyond recognition. # # The original original lookingglass s/w was written by Ed Kern. It was # a single script that used to be available at http://nitrous.digex.net/. # Provided by permission and modified beyond recognition. # # Looking glass # vars: query, router, args BEGIN { $me = $0; $me =~ s/.*\/(\S+)$/$1/; } use CGI qw/:standard escapeHTML/; use POSIX qw(strftime); use Sys::Syslog; 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); my($type, $router_param, $remote_user, $arg, $router, $mfg); my($LG_CACHE_DIR, $LG_CLOGINRC, $LG_IMAGE, $LG_INFO, $LG_LOG, $LG_ROUTERDB); my($LG_AS_REG, $LG_BGP_RT, $LG_CACHE_TIME, $LG_SINGLE, $LG_STRIP); if (!defined($ENV{HOME})) { $ENV{HOME} = "."; } # 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. # it is just easier to be self-contained. # SO, ANY CHANGES HERE SHOULD BE REFLECTED IN THE OTHER .cgi. # logging sub dolog { my($level, $msg) = @_; if (defined($LG_LOG) && $LG_LOG !~ /\//) { openlog($me, "pid", $LG_LOG); syslog($level, "%s", $msg); closelog; } else { local(*LOG); my($file); if (defined($LG_LOG)) { $file = $LG_LOG; } else { $file = "$cache_dir/lg.log"; } # log date, hostname, query, addr if (open(LOG, ">>$file") == 0) { # stderr, if all else fails printf(STDERR "[" . strftime("%a %b %e %H:%M:%S %Y", gmtime) . "] could not open log file $file: $!\n"); printf(STDERR $msg); } else { printf(LOG $msg); close(LOG); } } return; } # read LG configuration file sub readconf { my($conffile, $cmds); local(*CONF); if (defined($ENV{LG_CONF})) { $conffile = $ENV{LG_CONF}; } elsif (-e "lg.conf") { $conffile = "lg.conf"; } else { $conffile = "$SYSCONFDIR/lg.conf"; } if (! -f $conffile) { return; } if (open(CONF, "< $conffile")) { while () { next if (/^\s*(#|$)/); $cmds .= $_; } close(CONF); eval $cmds; } else { printf(STDERR "ERROR: couldn\'t open the configuration file: " . "$conffile: $!\n"); exit(1); } return; } # read router.db file sub readrouters { my($rtrdb); local(*RTR); if (defined($LG_ROUTERDB)) { $rtrdb = $LG_ROUTERDB; } else { $rtrdb = "$SYSCONFDIR/router.db"; } if (! -f $rtrdb) { my(@dirs, $dir); # 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, $LOCALSTATEDIR)) { dolog(LOG_ERR, "ERROR: couldn\'t read $LOCALSTATEDIR: $!\n"); } else { while ($dir = readdir(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, "$LOCALSTATEDIR/$dir")) { dolog(LOG_ERR, "ERROR: couldn\'t read $LOCALSTATEDIR/$dir: $!\n"); next; } closedir(DIR); next if (! -f "$LOCALSTATEDIR/$dir/router.db"); if (open(RTR, "< $LOCALSTATEDIR/$dir/router.db")) { while () { next if (/^\s*(#|$)/); # fqdn;mfg;state @record = split('\;', $_); next if ($record[2] !~ /up/i || $record[1] !~ /(cisco|foundry|juniper)/); push(@rtrlist, join(':', ($record[0], $record[1]))); $rtrlabels{join(':', ($record[0], $record[1]))} = $record[0]; } close(RTR); } else { dolog(LOG_ERR, "ERROR: couldn\'t open the router.db " . "file: $LOCALSTATEDIR/$dir/router.db: $!\n"); } } } } else { if (open(RTR, "< $rtrdb")) { while () { next if (/^\s*(#|$)/); # fqdn;mfg;state @record = split('\;', $_); next if ($record[2] !~ /up/i || $record[1] !~ /(cisco|foundry|juniper)/); push(@rtrlist, join(':', ($record[0], $record[1]))); $rtrlabels{join(':', ($record[0], $record[1]))} = $record[0]; } close(RTR); } else { dolog(LOG_ERR, "ERROR: couldn\'t open the router.db file: " . "$rtrdb: $!\n"); exit(1); } } return; } # the remaining functions are particular to lg.cgi. # return true if $router is a member of @rtrlist sub arraymember { my($rtrlist) = shift; my($router) = shift; my($r); foreach $r (@$rtrlist) { $r = (split(':', $r))[0]; return(1) if ($r eq $router); } return(0); } # check reachability and lock file before attempting to connect to device # return non-zero on error. sub DoRsh { my ($router, $mfg, $cmd, $arg) = @_; my($ctime) = time(); my($val); my($lckobj) = LockFile::Simple->make(-delay => $lock_int, -max => $max_lock_wait, -hold => $max_lock_hold); if ($pingcmd =~ /\d$/) { `$pingcmd $router`; } else { `$pingcmd $router 56 1`; } if ($?) { print "$router is unreachable. Try again later.\n"; return(-1); } if ($LG_SINGLE) { if (! $lckobj->lock("$cache_dir/$router")) { print "$router is busy. Try again later.\n"; return(-1); } } $val = &DoCmd($router, $mfg, $cmd, $arg); if ($LG_SINGLE) { $lckobj->unlock("$cache_dir/$router"); } return($val); } # run commands on the router. return non-zero on error. sub DoCmd { my($rtr, $mfg, $cmd, $arg) = @_; local(*CMD); if ($mfg =~ /foundry/i) { open(CMD, "sh -c \"flogin -f $cloginrc -c \'$cmd $arg\' $rtr\" 2>&1 |"); } elsif ($mfg =~ /juniper/i) { open(CMD, "sh -c \"jlogin -f $cloginrc -c \'$cmd $arg\' $rtr\" 2>&1 |"); } else { open(CMD, "sh -c \"clogin -noenable -f $cloginrc -c \'$cmd $arg\' $rtr\" 2>&1 |"); } while () { tr/\015//d; if (/^error:/i) { dolog(LOG_ERR, $_); if ($LG_STRIP) { undef(@results); } push(@results, $_); print @results; return(-1); } push(@results, $_); if (/$cmd/) { ($prompt) = /^(\S*)[\#>]/; if ($LG_STRIP) { undef(@results); } else { print @results; } last; } } while () { last if /^$prompt[\#>]/; tr/\015//d; print $_; push(@results, $_); } while () {} close(CMD); return(0); } ## # Usage: &Error("msg")); # Description: displays an error and exits. ## sub Error { my($msg) = @_; my($q) = new CGI(); print $q->header; if ($LG_STYLE) { print $query->start_html(-title => "LookingGlass Results - $router", -style => {'src' => $LG_STYLE}); } else { print $query->start_html(-title => "LookingGlass Results - $router"); } # add the company image, LG_IMAGE print $LG_IMAGE; print < Looking Glass Error:

$msg


$LG_INFO EOF print $q->end_html; exit(0); } # convert an ipv4 address mask to prefix length sub mask2len { my($mask) = shift; my($a, $b, $c, $d) = split('\.', $mask); my($p, $len); $p = ~ (($a << 24) + ($b << 16) + ($c << 8) + $d); for ($len = 32; $p > 0; $len --) { $p = $p >> 1; } return($len); } # end the page and exit. sub end_page { print < END print $query->end_html; exit(0); } # start the page and log the transaction... sub start_page { my($mfg) = @_; my($cmd); my($timestr) = strftime("%a %b %e %H:%M:%S %Y", gmtime); dolog(LOG_INFO, sprintf("%s %s %s %s\n", $ENV{REMOTE_HOST}, $ENV{REMOTE_ADDR}, $ENV{REMOTE_USER}, "- - [$timestr] $type $router $arg")); print $query->header; if ($LG_STYLE) { print $query->start_html(-title =>"LookingGlass form", -style => {'src' => $LG_STYLE}); } else { print $query->start_html(-title =>"LookingGlass from"); } $timestr = strftime("%a %b %e %H:%M:%S %Y %Z", gmtime); # add the company image, LG_IMAGE print $LG_IMAGE; if ($mfg =~ /foundry/i) { $cmd = $foundryCmd{$type}; } elsif ($mfg =~ /juniper/i) { $cmd = $juniperCmd{$type}; } else { $cmd = $ciscoCmd{$type}; } print <

Looking Glass Results - $router


Date: $timestr

Query: $cmd
HEAD if ($arg) { print "Argument(s): $arg\n"; } print "

\n"; print <

END

    return;
}


# Main()
# read the configuration file if it exists.
readconf();

# The script will now cache the results as simple files in the $cache_dir,
# named after the type of query (queries must, of course, be one word with
# no spaces).  Modify $LG_CACHE_TIME to set the lifetime for cache entries.
# for most web servers, cache_dir must be writable by uid nobody
if (defined($LG_CACHE_DIR)) {
    $cache_dir = $LG_CACHE_DIR;
} else {
    $cache_dir = "./tmp";
}

# read routers table to get @rtrlist
readrouters();

# when to display cache?  max time difference (in seconds)
if (defined($LG_CACHE_TIME)) {
    $max_time_diff = $LG_CACHE_TIME;
} else {
    $max_time_diff = "600" ;
}

# serialize queries?
if (!defined($LG_SINGLE)) {
    $LG_SINGLE = 1;
}

# max seconds to wait for a 'router' lock to free up
$max_lock_wait = 30;
$lock_int = 5;
$max_lock_hold = 300;

# clogin setup
if (defined($LG_CLOGINRC)) {
    $cloginrc = $LG_CLOGINRC;
} else {
    $cloginrc = $ENV{HOME} . "/.cloginrc";
}

$query = new CGI;

# get form data and validate
$type = ($query->param('query'))[0];
$router_param = ($query->param('router'))[0];
$remote_user = $ENV{REMOTE_USER};
$arg = ($query->param('args'))[0];
# handle multiple args
$arg =~ s/["'`]//g;			# these are BS in any arg for any query
@arg = split(' ', $arg);

# verify router, commands, arguments, etc.
($router, $mfg) = split(':', lc($router_param));
if (!defined($type) || !defined($router) || $router eq "") {
    &Error("You must at least choose a Query and a router.  Try buying " .
								"a clue.\n");
}

if ($arg !~ /^[-A-Za-z0-9|_\/: \.^\$]*$/) {
    &Error("Funny characters in argument; ignoring.\n");
}
if (length($arg) >= 50) {
    &Error("Argument string too long; ignoring. \n");
}

if (! arraymember(\@rtrlist, $router)) {
    my($timestr) = strftime("%a %b %e %H:%M:%S %Y", gmtime);
    dolog(LOG_WARNING, sprintf("%s %s %s %s\n",
	$ENV{REMOTE_HOST}, $ENV{REMOTE_ADDR}, $ENV{REMOTE_USER},
	"- - [$timestr] lg.cgi: attempt to access $router\n"));
    Error("access to $router not permitted");
}

# conversion of command "type" passed from lgform.cgi to the vendor's syntax.
if ($mfg eq "cisco") {
    %mfgCmd = (
		# Debug Queries
		log => "show logging",
		# Interface Queries
		framerelay => "show frame-relay pvc",
		intbrief => "show ip interface",	# switch in {interface}
		intdescr => "show interfaces description",
		interface => "show interface",
		#intoptics => "show controllers",	# XXX whats cmd on ios?
		#intwanphy => "show controllers wanphy",# XXX whats cmd on ios?
		# Routing Queries
		damp => "show ip bgp dampened-paths",
		neighbor => "show ip bgp neighbor",
		# Multicast Queries
		mbgp => "show ip mbgp",
		mbgpsum => "show ip mbgp summary",
		mneighbor => "show ip bgp neighbor",
		msdp => "show ip msdp summary",
		msdpsa => "show ip msdp sa-cache",
		msess => "show ip sdr",
		mroute => "show ip mroute",
		pim_interface => "show ip pim interface",
		pim_neighbor => "show ip pim neighbor",
		pim_rp => "show ip pim rp mapping",
		# IPv6 Queries
		v6_bgp => "show bgp ipv6",
		v6_interface => "show ipv6 interface",
		#v6_route => "show route ipv6",
		v6_summary => "show bgp ipv6 summary",
		#
		#acl => "show access-list",
		#aspath => "show ip as-path-access-list",
		#communitylist => "show ip community-list",
		ping => "ping",
		prefix => "show ip bgp",
		prefixlist => "show ip prefix-list",
		regex => "show ip bgp regex",
		route => "show ip route",
		routemap => "show route-map",
		rpf => "show ip rpf",
		summary => "show ip bgp summary",
		trace => "traceroute"
    );
} elsif ($mfg eq "cisco-xr") {
    %mfgCmd = (
		# Debug Queries
		log => "show logging",
		# Interface Queries
		framerelay => "show frame-relay pvc",
		intbrief => "show ipv4 interface",
		intdescr => "show interfaces description",
		interface => "show interface",
		intoptics => "show controllers",
		intwanphy => "show controllers wanphy",
		# Routing Queries
		damp => "show bgp all all dampened-paths",
		neighbor => "show bgp neighbor",
		# Multicast Queries
		mbgp => "show ip mbgp",
		mbgpsum => "show bgp all multicast summary",
		#mneighbor => "show ip bgp neighbor",
		#msdp => "show ip msdp summary",
		#msdpsa => "show ip msdp sa-cache",
		#msess => "show ip sdr",
		#mroute => "show ip mroute",
		#pim_interface => "show ip pim interface",
		#pim_neighbor => "show ip pim neighbor",
		#pim_rp => "show ip pim rp mapping",
		# IPv6 Queries
		v6_bgp => "show bgp ipv6 all",
		v6_interface => "show ipv6 interface",
		v6_route => "show route ipv6",
		v6_summary => "show bgp ipv6 unicast summary",
		#
		#acl => "show access-list",
		#aspath => "show ip as-path-access-list",
		#communitylist => "show ip community-list",
		ping => "ping",
		prefix => "show ip bgp",
		prefixlist => "show ip prefix-list",
		regex => "show ip bgp regex",
		route => "show route",
		routemap => "show route-map",
		rpf => "show ip rpf",
		summary => "show ip bgp summary",
		trace => "traceroute"
    );
} elsif ($mfg eq "foundry") {
    %mfgCmd = (
		# Debug Queries
		log => "show log",
		ping => "ping",
		trace => "traceroute",
		# Interface Queries
		#framerelay => "show frame-relay pvc",	# no compatible command
		interface => "show interface",
		#intoptics => "show controllers",	# XXX whats cmd on fdry?
		#intwanphy => "show controllers wanphy",# XXX whats cmd on fdry?
		# Routing Queries
		damp => "show ip bgp dampened-paths",
		neighbor => "show ip bgp neighbor",
		#regex => "show ip bgp aspath-regex",
		route => "show ip route",
		summary => "show ip bgp summary",
		# Multicast Queries
		#mbgp => "show ip mbgp",
		#mbgpsum => "show bgp summary",
		#mneighbor => "show ip bgp neighbor",
		mroute => "show ip mroute",
		msdp => "show ip msdp summary",
		msdpsa => "show ip msdp sa-cache",
		msess => "show ip sdr",
		pim_interface => "show ip pim interface",
		pim_neighbor => "show ip pim neighbor",
		pim_rp => "show ip pim rp mapping",
		rpf => "show ip rpf",
		# IPv6 Queries
		# v6_bgp => "show bgp ipv6",
		# v6_interface => "show ipv6 interface",
		# v6_summary => "show bgp ipv6 summary"
		#
		#acl => "show access-list",
		#aspath => "show ip as-path-access-list",
		#communitylist => "show ip community-list",
		routemap => "show route-map",
		prefix => "show ip bgp",
		prefixlist => "show ip prefix-list"
	);
} elsif ($mfg eq "juniper") {
    %mfgCmd = (
		# Debug Queries
		log => "show log messages",
		ping => "ping rapid count 5",
		trace => "traceroute",
		# Interface Queries
		framerelay => "show frame-relay pvc",
		intbrief => "show ip interface",	# switch in {interface}
		intdescr => "show interfaces descriptions",
		interface => "show interface",
		intoptics => "show interfaces diagnostics optics", # 
		intwanphy => "show interface",		# " media detail"
		# Routing Queries
		damp => "show route damping suppressed terse table inet.0",
		neighbor => "show bgp neighbor",
		regex => "show route table inet.0 aspath-regex",
		summary => "show bgp summary",
		# Multicast Queries
		mbgp => "show route table inet.2 terse",
		mbgpsum => "show bgp summary",
		mneighbor => "show bgp neighbor",
		mroute => "show multicast route extensive",
		msdp => "show msdp",
		msdpsa => "show msdp source-active",
		msess => "show multicast sessions",
		pim_interface => "show pim interface",
		pim_neighbor => "show pim neighbors",
		pim_rp => "show pim rps",
		pim_join => "show pim join",
		rpf => "show multicast rpf",
		# IPv6 Queries
		v6_bgp => "show route table inet6.0",
		v6_interface => "show interface",
		v6_summary => "show bgp summary",
		#
		#acl => "show access-list",
		#aspath => "show ip as-path-access-list",
		#communitylist => "show ip community-list",
		prefix => "show route table inet.0",
		prefixlist => "show policy",
		route => "show route table inet.0 terse",
		routemap => "show policy"
	);
} else {
    &Error("Unknown device type: $mfg\n");
}

# construct Display command from configuration
%cmdDisp=();
foreach $qtype (sort keys(%$queries)) {
    next if (! scalar(%{$queries->{$qtype}}));
    foreach $sub_type (sort keys(%{$queries->{$qtype}})) {
	$cmdDisp{$sub_type} = $queries->{$qtype}->{$sub_type};
    }
}

# make sure the command is not disabled
if (! defined($cmdDisp{$type})) {
    &Error("Unknown command type: $type\n");
}

# not all cmds/queries are implemented for all platforms
if (! defined($mfgCmd{$type})) {
    Error("$cmdDisp{$type} not implemented for $mfg or no suitable " .
						"equivalent exists.  sorry.\n");
}
$cmd = $mfgCmd{$type};

# handle each query/command type
if ($type eq "prefix" || $type eq "mbgp" || $type eq "route" ) {
    if ($arg[0] !~ /^\d+\.\d+\.\d+\.\d+$/) {
	&Error("The IP address \"$arg[0]\" is not valid and lacking an " .
				"address would over-burden our router.\n");
    } elsif (defined($arg[1]) && $arg[1] !~ /^\d+\.\d+\.\d+\.\d+$/) {
	&Error("The IP netmask \"$arg[1]\" is not valid.\n");
    }
    if ($mfg =~ /juniper/i && defined($arg[1])) {
	$arg = $arg[0] . "/" . mask2len($arg[1]);
    }
} elsif ($type eq "v6_route" ){
    # XXX: is this check of the address arg correct and pedantic?
    if ($arg[0] !~ /[0-9a-fA-F:]+$/) {
	&Error("The IPv6 address \"$arg[0]\" is not valid.\n");
    }
} elsif ($type eq "framerelay") {
    if ($mfg =~ /juniper/) {
	&Error("Juniper does not have a show frame-relay pvc command.  " .
						"Use show interface.\n");
    }
    if ($arg[0] > 15 && $arg[0] < 1024) {
	$arg = $arg[0];
    } else {
	undef($arg);
    }
} elsif ($type eq "interface" || $type eq "v6_interface") {

	# XXX: wtf is arg[1]?
#    if ($arg[1] =~ /[-\/0-9:.]+/) {
#       $arg = $arg[0] . " " . $arg[1];
#    } else {

    if ($mfg =~ /(cisco|foundry)/) {
	if ($arg[0] !~ /^b[^ ]+[0-9]/i && $arg[0] =~ /^b/i) {
	    $type = "intbrief";
	    $arg = "brief";
	} else {
	    $arg = $arg[0];
	}
    } elsif ($mfg =~ /juniper/) {
	my($optind) = 0;
	# arg 0 may be an intf name or a display option, but there can
	# only be 2 args
	$arg = "";
	while ($optind <= $#arg && $optind < 2) {
	    $arg[$optind] =~ s/brief/terse/;
	    if ($arg[$optind] =~ /^([a-z0-9]{2}\-\d+\/\d+\/\d+(:\d+)?)/i) {
		$arg .= " $1";
	    } elsif ($arg[$optind] =~ /^det/i) {
		$arg .= " detail";
	    } elsif ($arg[$optind] =~ /^ter/i) {
		$arg .= " terse";
	    } elsif ($arg[$optind] =~ /^ext/i) {
		$arg .= " extensive";
	    }
	    $optind += 1;
	}
    }
} elsif ($type eq "intoptics") {
    # arg 0 may be an intf name or a display option, but there can
    # only be 2 args
    if ($#arg < 0 || $arg[0] =~ /^\s*$/) {
&Error("show interface optics requires an interface argument.\n");
    }
    if ($mfg =~ /cisco-xr/) {
	if ($arg[0] =~ /^([^0-9]* ?\d+[^[:space:]]*)/i) {
	    $arg = "$1 phy";
	} else {
	    &Error("Interface argument $arg[0] did not match interface regex.\n");
	}
    } elsif ($mfg =~ /juniper/) {
	if ($arg[0] =~ /^([a-z0-9]{2}\-\d+\/\d+\/\d+(:\d+)?)/i) {
	    $arg = "$1";
	} else {
	    &Error("Interface argument $arg[0] did not match interface regex.\n");
	}
    }
} elsif ($type eq "intwanphy") {
    # arg 0 may be an intf name or a display option, but there can
    # only be 2 args
    if ($#arg < 0 || $arg[0] =~ /^\s*$/) {
	&Error("show interface wanphy requires an interface argument.\n");
    }
    if ($mfg =~ /(cisco-xr)/) {
	if ($arg[0] =~ /^[^0-9]*(\d+[^[:space:]]*)/i) {
	    $arg = "$1 all";
	} else {
	    &Error("Interface argument $arg[0] did not match interface regex.\n");
	}
    } elsif ($mfg =~ /juniper/) {
	if ($arg[0] =~ /^([a-z0-9]{2}\-\d+\/\d+\/\d+(:\d+)?)/i) {
	    $arg = "$1 media detail";
	} else {
	    &Error("Interface argument $arg[0] did not match interface regex.\n");
	}
    }
} elsif ($type eq "log") {
    if ($arg[0] =~ /^\s*\|?$/) {
	shift(@arg);
    }
    $arg[0] =~ s/^\s*\|?//;
    if ($arg[0] !~ /^\s*$/) {
	if ($mfg =~ /cisco/i) {
	    $arg = " | include " . join(' ', @arg);
	} elsif ($mfg =~ /juniper/i) {
	    $arg = " | match \\\"" . join(' ', @arg) . "\\\"";
	} else {
	    undef($arg);
	}
    } else {
	undef($arg);
    }
} elsif ($type eq "ping" || $type eq "trace") {
    # XXX: is this check of the address arg correct and pedantic?
    if ($arg[0] !~ /^\d+\.\d+\.\d+\.\d+$/ && $arg[0] !~ /[0-9a-fA-F:]+$/) {
	if ($arg[0] !~ /^[A-Za-z0-9._-]+$/) {
	    &Error("That argument ($arg[0]) is not valid.\n");
	}
    }
    $arg = $arg[0];
} elsif ($type eq "aspath" || $type eq "communitylist") {
    if ($arg[0] !~ /^\d+$/ || ($arg[0] < 1 && $arg[0] > 199)) {
	&Error("That argument ($arg[0]) is not valid.\n");
    }
    $arg = $arg[0];
} elsif ($type eq "acl") {
    if ($arg[0] !~ /^\d+$/ || ($arg[0] < 100 && $arg[0] > 199) ||
					($arg[0] < 1300 && $arg[0] > 2699)) {
	&Error("That argument ($arg[0]) is not valid.\n");
    }
    $arg = $arg[0];
    # don't show the jewels
    # XXX: this error msg is useless, but show acl is un-implemented.
    &Error($mfg) if ($arg == 98 || $arg == 99);
} elsif ($type eq "prefixlist" || $type eq "routemap") {
    if ($arg[0] !~ /^[0-9A-Za-z][^\s\"]*$/) {
	&Error("That argument ($arg[0]) is not valid.\n");
    }
    $arg = $arg[0];
} elsif ($type eq "regex") {
    # bgp as-path regex
    $arg = $arg[0];
    if ($#arg >= 1) {
	for ($n = 1; $n <= $#arg; $n++) { $arg .= " " . $arg[$n]; }
    }
    # remove leading/trailing whitespace
    $arg =~ s/^\s*//; $arg =~ s/\s*$//;
    if ($arg !~ /^[0-9_ ^.*+?[\])\(-]*\$?$/ || $arg =~ /^\s*$/) {
	&Error("That argument ($arg[0]) is not valid.\n");
    }
    # pathetic excuses for lookups
    if ($arg =~ /^[_.* ^]*(\*|1|701|1239|1280|1740|3561|5462|10303)+[_\$]*$/ ||
	$arg =~ /^[_.* ^]*(1|701|1239|1280|1740|3561|5462|10303)+[_ .]*[\[*.]/) {
	&Error("Get real.  Such a query has potential to over-burden our " .
		"router.\nLook that up on your own router.\n");
    }
    if ($mfg =~ /juniper/) {
	$arg =~ s/_/ /g;
	# pre-junos 4.4 does not allow anchors
	if ($arg =~ /\^\$/) {
	    $arg =~ "()";
	} else {
	    $arg =~ s/[\$^]/ /g;
	}
	$arg = "\\\"$arg\\\"";
    }
    # escape any ()s
    $arg =~ s/([\(\)])/\\$1/g;
} elsif ($type eq "neighbor") {
    if ($arg[0] !~ /^\d+\.\d+\.\d+\.\d+$/) {
	if ($arg[0] !~ /([A-Za-z0-9-]*.)*[A-Za-z0-9-]*.(com|edu|net|org)/) {
	    &Error("That argument ($arg[0]) is not valid.\n");
	}
    }
    $arg = $arg[0];
    if (defined($arg[1]) && $arg[1] =~ /^(a|ro|f|re)/) {
	if ($mfg =~ /juniper/) {
	    if ($arg[1] =~ /^a/) {
		if (defined($LG_BGP_RT)) {
		    $cmd = "show route table inet.0 all advertising-protocol ".
			"bgp";
		}
	    } elsif ($arg[1] =~ /^f/) {
		if (defined($LG_BGP_RT)) {
		    $cmd = "show route damping table inet.0 all ".
			"receive-protocol bgp";
		}
	    } elsif ($arg[1] =~ /^r/) {
		if (defined($LG_BGP_RT)) {
		    $cmd = "show route table inet.0 all receive-protocol bgp";
		}
	    }
	} else {
	    if ($arg[1] =~ /^a/) {
		if (defined($LG_BGP_RT)) { $arg .= " advertised-routes"; }
	    } elsif ($arg[1] =~ /^f/) {
		$arg .= " flap-statistics";
	    } elsif ($arg[1] =~ /^ro/) {
		if (defined($LG_BGP_RT)) { $arg .= " routes"; }
	    } elsif ($arg[1] =~ /^re/) {
		if (defined($LG_BGP_RT)) { $arg .= " received-routes"; }
	    }
	}
    }
} elsif ($type eq "mneighbor") {
    if ($arg[0] !~ /^\d+\.\d+\.\d+\.\d+$/) {
	if ($arg[0] !~ /([A-Za-z0-9-]*.)*[A-Za-z0-9-]*.(com|edu|net|org)/) {
	    &Error("That argument ($arg[0]) is not valid.\n");
	}
    }
    $arg = $arg[0];
    if (defined($arg[1]) && $arg[1] =~ /^(a|ro|f|re)/) {
	if ($mfg =~ /juniper/) {
	    if ($arg[1] =~ /^a/) {
		$cmd .= " advertised-routes";
	    } elsif ($arg[1] =~ /^f/) {
		$cmd .= " flap-statistics";
	    } elsif ($arg[1] =~ /^ro/) {
		$cmd .= " routes";
	    } elsif ($arg[1] =~ /^re/) {
		$cmd .= " received-routes";
	    }
	} else {
	    if ($arg[1] =~ /^a/) {
		$arg .= " advertised-routes";
	    } elsif ($arg[1] =~ /^f/) {
		$arg .= " flap-statistics";
	    } elsif ($arg[1] =~ /^ro/) {
		$arg .= " routes";
	    } elsif ($arg[1] =~ /^re/) {
		$arg .= " received-routes";
	    }
	}
    }
} elsif ($type eq "damp" || $type eq "summary" || $type eq "mbgpsum") {
    undef($arg);
}

# make stdout unbuffered, so result page streams.
$| = 1;
start_page();

# cache the following
if ($type eq "summary" || $type eq "mbgpsu" || $type eq "damp" ||
    $type eq "log") {
    if (!$arg) {
	# cache requests with no addr/argument
	local(*CACHE);

	my($file) = "$cache_dir/$type" ;
	$file =~ s/\s+/_/g;
	$file .= "_$router";

	if (-e $file) {
	    # see if cache exists
	    @stat = stat($file);
	    $ftime = $stat[9];
	    $dtime = time() - $stat[9];

	    # see if we are within cache time
	    if ($dtime <= $max_time_diff) {
		if (open(CACHE, "<$file") == 0) {
		    dolog(LOG_ERR, "couldnt open cache file $file: $!\n");
		} else {
		    print "From cache (number of seconds old (max " .
			"$max_time_diff)): $dtime\n\n";
		    while () { print $_; }
		    close(CACHE);
		    &end_page();
		}
	    }
	}

	# else, execute command and save to a new cache file
	if (! &DoRsh($router, $mfg, $cmd, $arg)) {
	    if (open(CACHE, ">$file") == 0) {
		dolog(LOG_ERR, "couldnt create cache file $file: $!\n");
		exit(1);
	    } else {
		printf(CACHE "@results");
		close(CACHE);
	    }
	}
    } else {
	&DoRsh($router, $mfg, $cmd, $arg);
    }
    &end_page();
} else {
    &DoRsh($router, $mfg, $cmd, $arg);
    &end_page();
}

exit(0);
rancid-3.13/bin/htrancid.in000644 015615 000000 00000022771 13534014744 015670 0ustar00heaswheel000000 000000 #! @PERLV_PATH@
##
## @PACKAGE@ @VERSION@
## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Henry Kilmer, John Heasley, Andrew Partan,
## Pete Whiting, Austin Schutz, and Andrew Fort.
##
## 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. Neither the name of RANCID nor the names of its
##    contributors may be used to endorse or promote products derived from
##    this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
##
## It is the request of the authors, but not a condition of license, that
## parties packaging or redistributing RANCID NOT distribute altered versions
## of the etc/rancid.types.base file nor alter how this file is processed nor
## when in relation to etc/rancid.types.conf.  The goal of this is to help
## suppress our support costs.  If it becomes a problem, this could become a
## condition of license.
# 
#  The expect login scripts were based on Erik Sherk's gwtn, by permission.
# 
#  The original looking glass software was written by Ed Kern, provided by
#  permission and modified beyond recognition.
#
# hacked version of Hank's rancid - this one tries to deal with Hitachi's.
#
#  RANCID - Really Awesome New Cisco confIg Differ
#
# usage: htrancid [-dltCV] [-f filename | hostname]
#
use Getopt::Std;
getopts('dflt:CV');
if ($opt_V) {
    print "@PACKAGE@ @VERSION@\n";
    exit(0);
}
$log = $opt_l;
$debug = $opt_d;
$file = $opt_f;
$host = $ARGV[0];
$clean_run = 0;
$found_end = 0;
$timeo = 90;				# htlogin timeout in seconds

my(@commandtable, %commands, @commands);# command lists
my($aclsort) = ("ipsort");		# ACL sorting mode
my($filter_commstr);			# SNMP community string filtering
my($filter_osc);			# oscillating data filtering mode
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))
	&& scalar(%history)) {
	print eval "$command \%history";
	undef %history;
    }
    if (($new_hist_tag) && ($new_command) && ($command_string)) {
	if ($history{$command_string}) {
	    $history{$command_string} = "$history{$command_string}@string";
	} else {
	    $history{$command_string} = "@string";
	}
    } elsif (($new_hist_tag) && ($new_command)) {
	$history{++$#history} = "@string";
    } else {
	print "@string";
    }
    $hist_tag = $new_hist_tag;
    $command = $new_command;
    1;
}

sub numerically { $a <=> $b; }

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort numerically keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort values %lines) {
	$sorted_lines[$i] = $key;
	$i++;
    }
    @sorted_lines;
}

# This is a numerical sort routine (ascending).
sub numsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $num (sort {$a <=> $b} keys %lines) {
	$sorted_lines[$i] = $lines{$num};
	$i++;
    }
    @sorted_lines;
}

# This is a sort routine that will sort on the
# ip address when the ip address is anywhere in
# the strings.
sub ipsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $addr (sort sortbyipaddr keys %lines) {
	$sorted_lines[$i] = $lines{$addr};
	$i++;
    }
    @sorted_lines;
}

# 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]));
}
sub sortbyipaddr {
    &ipaddrval($a) <=> &ipaddrval($b);
}

# This routine parses "show config"
sub ShowConfig {
    print STDERR "    In ShowConfig: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	ProcessHistory("","","","$_");
    }
    return(0);
}

# This routine parses single command's that return no required info
sub ShowVersion {
    print STDERR "    In ShowVersion: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
    }
    return(0)
}

# Main
@commandtable = (
	{'version -a'			=> 'ShowVersion'},
	{'cat /config/router.cnf'	=> 'ShowConfig'}
);
# 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);
$commandcnt = scalar(keys %commands);

$commandstr=join(";",@commands);
$cmds_regexp = join("|", map quotemeta($_), @commands);

if (length($host) == 0) {
    if ($file) {
	print(STDERR "Too few arguments: file name required\n");
	exit(1);
    } else {
	print(STDERR "Too few arguments: host name required\n");
	exit(1);
    }
}
if ($opt_C) {
    print "htlogin -t $timeo -c\'$commandstr\' $host\n";
    exit(0);
}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
if ($debug) { $| = 1; }

if ($file) {
    print(STDERR "opening file $host\n") if ($debug || $log);
    open(INPUT,"<$host") || die "open failed for $host: $!\n";
} else {
    print(STDERR "executing htlogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log);
    system "htlogin -t $timeo -c \"$commandstr\" $host  $host.raw 2>&1" || die "htlogin failed for $host: $!\n";
    open(INPUT, "< $host.raw") || die "htlogin failed for $host: $!\n";
}

# 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 oscillating data filtering mode
if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) {
    $filter_osc = 0;
} else {
    $filter_osc = 1;
}
# determine password filtering mode
if ($ENV{"FILTER_PWDS"} =~ /no/i) {
    $filter_pwds = 0;
} elsif ($ENV{"FILTER_PWDS"} =~ /all/i) {
    $filter_pwds = 2;
} else {
    $filter_pwds = 1;
}

ProcessHistory("","","","!RANCID-CONTENT-TYPE: hitachi\n!\n");
TOP: while() {
    tr/\015//d;
    if (/^.*logout$/)  {
	$clean_run=1;
	last;
    }
    if (/^Error:/) {
	print STDOUT ("$host htlogin error: $_");
	print STDERR ("$host htlogin error: $_") if ($debug);
	$clean_run=0;
	last;
    }
    while (/command:\s*($cmds_regexp)\s*$/) {
	$cmd = $1;
	if (!defined($prompt)) {
	    $prompt = ($_ =~ /^([^:]+:)/)[0];
	}
	print STDERR ("HIT COMMAND:$_") if ($debug);
	if (! defined($commands{$cmd})) {
	    print STDERR "$host: found unexpected command - \"$cmd\"\n";
	    $clean_run = 0;
	    last TOP;
	}
	$rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd);
	delete($commands{$cmd});
	if ($rval == -1) {
	    $clean_run = 0;
	    last TOP;
	}
    }
}
print STDOUT "Done $logincmd: $_\n" if ($log);
# Flush History
ProcessHistory("","","","");
# Cleanup
close(INPUT);
close(OUTPUT);

unlink("$host.raw") if (! $debug);

# check for completeness
if (scalar(%commands) || !$clean_run ) {
    if (scalar(keys %commands) eq $commandcnt) {
	printf(STDERR "$host: missed cmd(s): all commands\n");
    } elsif (scalar(%commands)) {
	my($count, $i) = 0;
	for ($i = 0; $i < $#commands; $i++) {
	    if ($commands{$commands[$i]}) {
		if (!$count) {
		    printf(STDERR "$host: missed cmd(s): %s", $commands[$i]);
		} else {
		    printf(STDERR ", %s", $commands[$i]);
		}
		$count++;
	    }
	}
	if ($count) {
	    printf(STDERR "\n");
	}
    }
    if (!$clean_run) {
	print(STDERR "$host: End of run not found\n");
	if ($debug) {
	    print(STDERR "$host: clean_run is false\n") if (!$clean_run);
	}
	system("/usr/bin/tail -1 $host.new");
    }
    unlink "$host.new" if (! $debug);
}
rancid-3.13/bin/hpuifilter.c000644 015615 000000 00000051363 13534015132 016052 0ustar00heaswheel000000 000000 /*
 * Copyright (c) 1997-2019 by Henry Kilmer and John Heasley
 * All rights reserved.
 *
 * This code is derived from software contributed to and maintained by
 * Henry Kilmer, John Heasley, Andrew Partan,
 * Pete Whiting, Austin Schutz, and Andrew Fort.
 *
 * 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. Neither the name of RANCID nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
 *
 * It is the request of the authors, but not a condition of license, that
 * parties packaging or redistributing RANCID NOT distribute altered versions
 * of the etc/rancid.types.base file nor alter how this file is processed nor
 * when in relation to etc/rancid.types.conf.  The goal of this is to help
 * suppress our support costs.  If it becomes a problem, this could become a
 * condition of license.
 *
 * Modified openpty() from NetBSD:
 * Copyright (c) 1990, 1993, 1994
 *	The Regents of the University of California.  All rights reserved.
 *
 * 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. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
 */


#include "config.h"
#include "version.h"

#if HAVE_UNISTD_H
# include 
#endif

#if HAVE_CTYPE_H
# include 
#endif
#include 
#include 
#include 
#include 
#if HAVE_PTY_H
# include 
#endif
#include 
#include 
#if HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
#  include 
# endif
# include 
#endif
#if HAVE_STRINGS_H
# include 
#endif
#if HAVE_PTMX && HAVE_STROPTS_H
# include 
#endif
#include 
#if HAVE_SYS_RESOURCE_H
# include 
#endif
#include 
#include 
#include 
#if HAVE_WAIT_H
# include 
#elif HAVE_SYS_WAIT_H
# include 
#endif
#if HAVE_UTIL_H
# include 
#elif HAVE_LIBUTIL_H
# include 
#endif

#define	BUFSZ	(LINE_MAX * 2)
#define	ESC	0x1b

char		**environ,
		*progname;
int		debug,
		sigrx,
		timeo = 5;				/* default timeout   */
pid_t		child;

int		complete_esc(char *buf, int len);
int		filter(char *, int);
size_t		mystrcspn(const char *, const char *);
RETSIGTYPE	reapchild(int);
#if !HAVE_OPENPTY
int		openpty(int *, int *, char *, struct termios *,
			struct winsize *);
#endif
RETSIGTYPE	sighdlr(int);
#if !HAVE_UNSETENV
int		unsetenv(const char *);
#endif
void		usage(void);
void		vers(void);

int
main(int argc, char **argv, char **ev)
{
    extern char		*optarg;
    extern int		optind;
    char		hbuf[BUFSZ],		/* hlogin buffer */
			ptyname[FILENAME_MAX + 1],
			tbuf[BUFSZ],		/* telnet/ssh buffer */
			tbufstr[5] = {ESC, '\x07', '\r', '\n', '\0'};
    int			bytes,			/* bytes read/written */
			devnull,
			i,
			rval = EX_OK,
			ptym,			/* master pty */
			ptys;			/* slave pty */
    ssize_t		idx,			/* strcspan span */
			hlen = 0,		/* len of hbuf */
			tlen = 0;		/* len of tbuf */
    struct pollfd	pfds[3];
    struct termios	tios;

    environ = ev;

    /* get just the basename() of our exec() name and strip a .* off the end */
    if ((progname = strrchr(argv[0], '/')) != NULL)
	progname += 1;
    else
	progname = argv[0];
    if (strrchr(progname, '.') != NULL)
	*(strrchr(progname, '.')) = '\0';

    while ((i = getopt(argc, argv, "dhvt:")) != -1 )
	switch (i) {
	case 'd':
	    debug++;
	    break;
	case 't':
	    timeo = atoi(optarg);
	    if (timeo < 1)
		timeo = 1;
	    break;
	case 'v':
	    vers();
	    return(EX_OK);
	case 'h':
	default:
	    usage();
	    return(EX_USAGE);
	}

    if (argc - optind < 2) {
	usage();
	return(EX_USAGE);
    }

    unsetenv("DISPLAY");

    for (sigrx = 3; sigrx < 10; sigrx++)
	close(sigrx);

    /* allocate pty for telnet/ssh, then fork and exec */
    if (openpty(&ptym, &ptys, ptyname, NULL, NULL)) {
	fprintf(stderr, "%s: could not allocate pty: %s\n", progname,
		strerror(errno));
	return(EX_TEMPFAIL);
    }
    /* make the pty raw */
    if (tcgetattr(ptys, &tios)) {
	fprintf(stderr, "%s: tcgetattr() failed: %s\n", progname,
		strerror(errno));
	return(EX_OSERR);
    }
    tios.c_lflag &= ~ICANON;
#ifdef VMIN
    tios.c_cc[VMIN] = 1;
    tios.c_cc[VTIME] = 0;
#endif
    if (tcsetattr(ptys, TCSANOW, &tios)) {
	fprintf(stderr, "%s: tcsetattr() failed: %s\n", progname,
		strerror(errno));
	return(EX_OSERR);
    }

    /*
     * if a tty, make it raw as the hp echos _everything_, including
     * passwords.
     */
    tios.c_lflag &= ~ECHO;
    if (isatty(fileno(stdin))) {
	if (tcgetattr(fileno(stdin), &tios)) {
	    fprintf(stderr, "%s: tcgetattr() failed: %s\n", progname,
		strerror(errno));
	    return(EX_OSERR);
	}
	tios.c_lflag &= ~ECHO;
	tios.c_lflag &= ~ICANON;
#ifdef VMIN
	tios.c_cc[VMIN] = 1;
	tios.c_cc[VTIME] = 0;
#endif
	if (tcsetattr(fileno(stdin), TCSANOW, &tios)) {
	    fprintf(stderr, "%s: tcsetattr() failed: %s\n", progname,
		strerror(errno));
	    return(EX_OSERR);
	}
    }

    /* zero the buffers */
    memset(hbuf, 0, BUFSZ);
    memset(tbuf, 0, BUFSZ);

    /* reap our children, must be set-up *after* openpty() */
    signal(SIGCHLD, reapchild);

    if ((child = fork()) == -1) {
	fprintf(stderr, "%s: fork() failed: %s\n", progname, strerror(errno));
	return(EX_TEMPFAIL);
    }

    if (child == 0) {
	struct winsize ws;

	/*
	 * Make sure our terminal length and width are something greater
	 * than 1, for pagers on stupid boxes.
	 */
	ioctl(ptys, TIOCGWINSZ, &ws);
	ws.ws_row = 24;
	ws.ws_col = 132;
	ioctl(ptys, TIOCSWINSZ, &ws);

	signal(SIGCHLD, SIG_DFL);
	/* close the master pty & std* inherited from the parent */
	close(ptym);
	if (ptys != 0)
	    close(0);
	if (ptys != 1)
	    close(1);
	if (ptys != 2)
	    close(2);
#ifdef TIOCSCTTY
	setsid();
	if (ioctl(ptys, TIOCSCTTY, NULL) == -1) {
	    snprintf(ptyname, FILENAME_MAX, "%s: could not set controlling "
		     "tty: %s\n", progname, strerror(errno));
	    write(0, ptyname, strlen(ptyname));
	    return(EX_OSERR);
	}
#endif

	/* close stdin/out/err and attach them to the pipes */
	if (dup2(ptys, 0) == -1 || dup2(ptys, 1) == -1 || dup2(ptys, 2) == -1) {
	    snprintf(ptyname, FILENAME_MAX, "%s: dup2() failed: %s\n", progname,
		     strerror(errno));
	    write(0, ptyname, strlen(ptyname));
	    return(EX_OSERR);
	}
	if (ptys > 2)
	    close(ptys);

	/* exec telnet/ssh */
	execvp(argv[optind], argv + optind);
	snprintf(ptyname, FILENAME_MAX, "%s: execvp() failed: %s\n", progname,
		 strerror(errno));
	write(0, ptyname, strlen(ptyname));
	return(EX_TEMPFAIL);
	/*NOTREACHED*/
    }

    /* parent */
    if (debug)
	fprintf(stderr, "child %d\n", (int)child);

    signal(SIGHUP, sighdlr);

    /* close the slave pty */
    close(ptys);

    devnull = open("/dev/null", O_RDWR);

    /* make FDs non-blocking */
    if (fcntl(ptym, F_SETFL, O_NONBLOCK) ||
	fcntl(fileno(stdin), F_SETFL, O_NONBLOCK) ||
	fcntl(fileno(stdout), F_SETFL, O_NONBLOCK)) {
	fprintf(stderr, "%s: fcntl(NONBLOCK) failed: %s\n", progname,
		strerror(errno));
	exit(EX_OSERR);
    }

    /* loop to read on stdin and ptym */
#define	POLLEXP	(POLLERR | POLLHUP | POLLNVAL)
    pfds[0].fd = fileno(stdin);
    pfds[0].events = POLLIN | POLLEXP;
    pfds[1].fd = fileno(stdout);
    pfds[1].events = POLLEXP;
    pfds[2].fd = ptym;
    pfds[2].events = POLLIN | POLLEXP;

    /* shuffle data across the pipes until we see EOF or a read/write error */
    sigrx = 0;
    while (1) {
	bytes = poll(pfds, 3, (timeo * 1000));
	if (bytes == 0) {
	    if (sigrx)
		break;
	    /* timeout */
	    continue;
	}
	if (bytes == -1) {
	    switch (errno) {
	    case EAGAIN:
	    case EINTR:
		break;
	    default:
		rval = EX_IOERR;
		break;
	    }
	    continue;
	}

	/*
	 * write buffers first
	 * write hbuf (aka hlogin/stdin/pfds[0]) -> telnet (aka ptym/pfds[2])
	 */
	if ((pfds[2].revents & POLLOUT) && hlen) {
	    if ((bytes = write(pfds[2].fd, hbuf, hlen)) < 0 &&
		errno != EINTR && errno != EAGAIN) {
		fprintf(stderr, "%s: write() failed: %s\n", progname,
			strerror(errno));
		hlen = 0;
		hbuf[0] = '\0';
		break;
	    } else if (bytes > 0) {
		hlen -= bytes;
		if (hlen < 1) {
		    pfds[2].events &= ~POLLOUT;
		    hbuf[0] = '\0';
		} else
		    memmove(hbuf, hbuf + bytes, hlen + 1);
	    }
	}
	if (pfds[2].revents & POLLEXP) {
	    hlen = 0;
	    hbuf[0] = '\0';
	    break;
	}

	/* write tbuf (aka telnet/ptym/pfds[2]) -> hlogin (stdout/pfds[1]) */
	if ((pfds[1].revents & POLLOUT) && tlen) {
	    /*
	     * if there is an escape char that was not filtered by filter(),
	     * we need to write only up to that point and wait for
	     * the bits that complete the escape sequence.  if at least
	     * two bytes follow it and it doesn't look like we should expect
	     * more data, write it anyway as filter() didnt match it.
	     */
	    bytes = tlen;
	    idx = mystrcspn(tbuf, tbufstr);
	    if (idx) {
		if (tbuf[idx] == ESC)
		    bytes = idx + complete_esc(&tbuf[idx], tlen - idx);
		if (tbuf[idx] == '\r' || tbuf[idx] == '\n') {
		    bytes = ++idx;
		    if (tbuf[idx] == '\r' || tbuf[idx] == '\n')
			bytes++;
		}
	    } else {
		if (tbuf[0] == ESC)
		    bytes = complete_esc(tbuf, tlen);
		if (tbuf[0] == '\r' || tbuf[0] == '\n') {
		    bytes = 1;
		    if (tbuf[1] == '\r' || tbuf[1] == '\n')
			bytes++;
		}
	    }

	    if ((bytes = write(pfds[1].fd, tbuf, bytes)) < 0 &&
		errno != EINTR && errno != EAGAIN) {
		fprintf(stderr, "%s: write() failed: %s\n", progname,
			strerror(errno));
		/* dont bother trying to flush tbuf */
		tlen = 0;
		tbuf[0] = '\0';
		break;
	    } else if (bytes > 0) {
		tlen -= bytes;
		if (tlen < 1) {
		    tbuf[0] = '\0';
		    pfds[1].events &= ~POLLOUT;
		} else
		    memmove(tbuf, tbuf + bytes, tlen + 1);
	    }
	}
	if (pfds[1].revents & POLLEXP) {
	    /* dont bother trying to flush tbuf */
	    tlen = 0;
	    tbuf[0] = '\0';
	    break;
	}

	/* read hlogin (aka stdin/pfds[0]) -> hbuf */
	if (pfds[0].revents & POLLIN) {
	    if (BUFSZ - hlen > 1) {
		bytes = read(pfds[0].fd, hbuf + hlen, (BUFSZ - 1) - hlen);
		if (bytes > 0) {
		    hlen += bytes;
		    hbuf[hlen] = '\0';
		    pfds[2].events |= POLLOUT;
		} else if (bytes < 0 && errno != EAGAIN && errno != EINTR) {
		    /* read error */
		    break;
		}
	    }
	}
	if (pfds[0].revents & POLLEXP)
	    break;

	/* read telnet/ssh (aka ptym/pfds[2]) -> tbuf, then filter */
	if (pfds[2].revents & POLLIN) {
	    if (BUFSZ - tlen > 1) {
		bytes = read(pfds[2].fd, tbuf + tlen, (BUFSZ - 1) - tlen);
		if (bytes > 0) {
		    tlen += bytes;
		    tbuf[tlen] = '\0';
		    tlen = filter(tbuf, tlen);
		    if (tlen > 0)
			pfds[1].events |= POLLOUT;
		} else if (bytes < 0 && errno != EAGAIN && errno != EINTR) {
		    /* read error */
		    break;
		}
	    }
	}
	if (pfds[2].revents & POLLEXP)
	    break;
    }
    /* try to flush any remaining data from our buffers */
    if (hlen) {
	(void)write(pfds[2].fd, hbuf, hlen);
	hlen = 0;
    }
    if (tlen) {
	(void)write(pfds[1].fd, tbuf, tlen);
	tlen = 0;
    }
    if ((bytes = read(pfds[2].fd, tbuf, (BUFSZ - 1))) > 0) {
	tbuf[bytes] = '\0';
	tlen = filter(tbuf, bytes);
	(void)write(pfds[1].fd, tbuf, tlen);
    }
    tcdrain(pfds[1].fd);
    if ((hlen = read(pfds[0].fd, hbuf, (BUFSZ - 1))) > 0) {
	(void)write(pfds[2].fd, hbuf, hlen);
    }
    tcdrain(pfds[2].fd);

    if (child && ! kill(child, SIGINT))
	reapchild(SIGCHLD);

    return(rval);
}

/*
 * return zero if the escape sequence beginning with buf appears to be
 * incomplete (and the caller should wait for more data); else return
 * the index of the first character past the end of the sequence.
 */
int
complete_esc(char *buf, int len)
{
    int	i;

    if (len < 2)
	return 0;
    if (buf[1] == '[' || isdigit((int)buf[1])) {
	/* look for a char that ends the sequence */
	for (i = 2; i < len; i++) {
	    if (isalpha((int)buf[i]))
		return(i + 1);
	}
	return(0);
    }
    if (buf[1] == '#') {
	/* look for terminating digit */
	for (i = 2; i < len; i++) {
	    if (isdigit((int)buf[i]))
		return(i + 1);
	}
	return(0);
    }

    return(1);  /* we don't understand this ESC sequence, consume it */
}

/*
 * Remove/replace vt100/220 screen manipulation escape sequences so they do
 * not litter the output.
 */
int
filter(char *buf, int len)
{
    static regmatch_t	pmatch[1];
#define	N_REG		19		/* number of regexes in reg[][] */
#define	N_CRs		5		/* 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 */
				"\x1B""8",			/* fs */

				"\x1B\\[2J",
				"\x1B\\[2K",			/* kE */

				"\x1B\\[[0-9]+;[0-9]+r",	/* cs */
				"\x1B\\[[0-9]+;[0-9]+H",	/* cm */

				"\x1B\\[\\?6l",
				"\x1B\\[\\?7l",			/* RA */
				"\x1B\\[\\?25h",		/* ve */
				"\x1B\\[\\?25l",		/* vi */
				"\x1B\\[K",			/* ce */
				"\x1B\\[7m",			/* mr - ansi */
				"\x1B\\[6n",			/* u7 - ansi */
				"\x07",				/* bell */

				/* replace these with CR */
				"\x1B\\[0m",			/* me */
				"\x1B""E",
				"\x1B\\[\\?7h",			/* autowrap */
				"\x1B\\[1L",			/* insert line*/
				"\x1B\\[1M",			/* md */
			};
    char		bufstr[3] = {ESC, '\x07', '\0'},
			ebuf[256];
    size_t		nmatch = 1;
    int			err,
			x;
    static int		init = 0;

    if (len == 0 || mystrcspn(buf, bufstr) >= len)
	return(len);

    if (! init) {
	init++;
	for (x = 0; x < N_REG; x++) {
	    memset(&preg[x], 0, sizeof(preg[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,
			ebuf);
		abort();
	    }
	}
    }

    for (x = 0; x < N_REG - N_CRs; x++) {
	if ((err = regexec(&preg[x], buf, nmatch, pmatch, 0))) {
	    if (err != REG_NOMATCH) {
		regerror(err, &preg[x], ebuf, 256);
		fprintf(stderr, "%s: regexec failed: %s\n", progname, ebuf);
		abort();
	    }
	} else {
	    if (len - pmatch[0].rm_eo <= 0) {
		buf[pmatch[0].rm_so] = '\0';
	    } else {
		memmove(buf + pmatch[0].rm_so, buf + pmatch[0].rm_eo,
			len - pmatch[0].rm_eo + 1);
	    }
	    len -= pmatch[0].rm_eo - pmatch[0].rm_so;
	    /* start over with the first regex */
	    x = -1;
	}
    }

    /* now the CR NL replacements */
    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);
		fprintf(stderr, "%s: regexec failed: %s\n", progname, ebuf);
		abort();
	    }
	} else {
	    *(buf + pmatch[0].rm_so++) = '\r';
	    *(buf + pmatch[0].rm_so++) = '\n';
	    if (len - pmatch[0].rm_eo == 0) {
		buf[pmatch[0].rm_so] = '\0';
	    } else {
		memmove(buf + pmatch[0].rm_so, buf + pmatch[0].rm_eo,
			len - pmatch[0].rm_eo + 1);
	    }
	    len -= pmatch[0].rm_eo - pmatch[0].rm_so;
	    /* start over with the first CR regex */
	    x = N_REG - 1 - N_CRs;
	}
    }

    return(len);
}

/* like strcspn(), but works around a bug in a particular O/S */
size_t
mystrcspn(const char *s, const char *charset)
{
    size_t	len;
    const char	*csp;

    for (len = 0; *s != '\0'; s++) {
	for (csp = charset; *csp != '\0'; csp++)
	    if (*s == *csp)
		return(len);
	len++;
    }

    return(len);
}

RETSIGTYPE
reapchild(int sig)
{
    int         status;
    pid_t       pid;

    if (debug)
	fprintf(stderr, "GOT SIGNAL %d\n", sig);

    while ((pid = wait3(&status, WNOHANG, NULL)) > 0) {
	if (debug)
            fprintf(stderr, "reap child %d\n", (int)pid);
	if (pid == child) {
	    child = 0;
	    sigrx = 1;
	    break;
	}
    }
    return;
}

RETSIGTYPE
sighdlr(int sig)
{
    if (debug)
	fprintf(stderr, "GOT SIGNAL %d\n", sig);
    sigrx = 1;
    return;
}

#if !HAVE_UNSETENV
int
unsetenv(const char *name)
{
   char	**victim,
	**end;
   int	len;
   if (environ == NULL)
	return(0);
   len = strlen(name);
   victim = environ;
   while (*victim != NULL) {
	if (strncmp(name, *victim, len) == 0 && victim[0][len] == '=')
	    break;
	victim++;
   }
   if (*victim == NULL)
	return(0);
   end = victim + 1;
   while (*end != NULL)
	end++;
   end--;
   *victim = *end;
   *end = NULL;
   return(0);
}
#endif

void
usage(void)
{
    fprintf(stderr, "usage: %s [-hv] [-t timeout]  []"
	    "  []\n", progname);
    return;
}

void
vers(void)
{
    fprintf(stderr, "%s: %s version %s\n", progname, package, version);
    return;
}


#if !HAVE_OPENPTY
#include 
#define TTY_LETTERS	"pqrstuvwxyzPQRST"
#define TTY_OLD_SUFFIX	"0123456789abcdef"
#define TTY_NEW_SUFFIX	"ghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

int
openpty(int *amaster, int *aslave, char *name, struct termios *term,
	struct winsize *winp)
{
    static char		line[] = "/dev/XtyXX";
    const char		*cp1, *cp2, *cp, *linep;
    int			master, slave;
    gid_t		ttygid;
    mode_t		mode;
    struct group	*gr;

#if HAVE_PTMX
    if ((master =
#if HAVE_PTMX_BSD
	 open("/dev/ptmx_bsd", O_RDWR))
#else
	 open("/dev/ptmx", O_RDWR))
#endif
				    != -1) {
	linep = ptsname(master);
	grantpt(master);
	unlockpt(master);
#ifndef TIOCSCTTY
	setsid();
#endif
	if ((slave = open(linep, O_RDWR)) < 0) {
	    slave = errno;
	    (void) close(master);
	    errno = slave;
	    return(-1);
	}
#if HAVE_PTMX_OSF
	{
	    char buf[10240];
	    if (ioctl (slave, I_LOOK, buf) != 0)
		if (ioctl (slave, I_PUSH, "ldterm")) {
		    close(slave);
		    close(master);
		    return(-1);
		}
	}
#elif HAVE_STROPTS_H
	ioctl(slave, I_PUSH, "ptem");
	ioctl(slave, I_PUSH, "ldterm");
	ioctl(slave, I_PUSH, "ttcompat");
#endif
	goto gotit;
    }
    if (errno != ENOENT)
	return(-1);
#endif

    if ((gr = getgrnam("tty")) != NULL) {
	ttygid = gr->gr_gid;
	mode = S_IRUSR|S_IWUSR|S_IWGRP;
    } else {
	ttygid = getgid();
	mode = S_IRUSR|S_IWUSR;
    }

    for (cp1 = TTY_LETTERS; *cp1; cp1++) {
	line[8] = *cp1;
	for (cp = cp2 = TTY_OLD_SUFFIX TTY_NEW_SUFFIX; *cp2; cp2++) {
	    line[5] = 'p';
	    line[9] = *cp2;
	    if ((master = open(line, O_RDWR, 0)) == -1) {
		if (errno != ENOENT)
			continue;	/* busy */
		if (cp2 - cp + 1 < sizeof(TTY_OLD_SUFFIX))
			return -1;	/* out of ptys */
		else	
			break;		/* out of ptys in this group */
	    }
	    line[5] = 't';
	    linep = line;
	    if (chown(line, getuid(), ttygid) == 0 &&
		chmod(line, mode) == 0 &&
		(slave = open(line, O_RDWR, 0)) != -1) {
gotit:
		*amaster = master;
		*aslave = slave;
		if (name)
		    (void)strcpy(name, linep);
		if (term)
		    (void)tcsetattr(slave, TCSAFLUSH, term);
		if (winp)
		    (void)ioctl(slave, TIOCSWINSZ, winp);
		return 0;
	    }
	    (void)close(master);
	}
    }
    errno = ENOENT;	/* out of ptys */
    return -1;
}
#endif
rancid-3.13/bin/flogin.in000644 015615 000000 00000034562 13657102757 015363 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## @PACKAGE@ @VERSION@
@copyright@
#
# flogin - foundry login
#
# Most options are intuitive for logging into a foundry switch.
# this should be the clogin, but foundry can't seem to dislodge
# their heads and make the UI consistent.  i think the UI
# development has been outsourced to Fisher Price.
# The default is to enable (thus -noenable).  Some folks have
# setup tacacs to have a user login at priv-lvl = 15 (enabled)
# so the -autoenable flag was added for this case (don't go through
# the process of enabling and the prompt will be the "#" prompt.
# The default username password is the same as the vty password.
#

# Sometimes routers take awhile to answer (the default is 10 sec)
set timeoutdflt 45
# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

@login_top@

# Log into the router.
# returns: 0 on success, 1 on failure
proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } {
    global spawn_id in_proc do_command do_script passphrase
    global prompt u_prompt p_prompt e_prompt sshcmd telnetcmd
    set in_proc 1
    set uprompt_seen 0

    # try each of the connection methods in $cmethod until one is successful
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog command suffix port
	    if {"$port" == ""} {
		set retval [ catch {eval spawn [split "$telnetcmd $router"]} reason ]
	    } else {
		set retval [ catch {eval spawn [split "$telnetcmd $router $port"]} reason ]
	    }
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif [string match "ssh*" $prog] {
	    # ssh to the router & try to login with or without an identfile.
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    if {"$identfile" != ""} {
		set cmd "$cmd -i $identfile"
	    }
	    set retval [ catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason ]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	} elseif ![string compare $prog "rsh"] {
	    send_error "\nError: unsupported method: rsh\n"
	    if { $progs == 0 } {
		return 1
	    }
	    continue;
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}
	sleep 0.3

	# This helps cleanup each expect clause.
	expect_after {
	    timeout {
		global in_proc
		send_user "\nError: TIMEOUT reached\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    } eof {
		global in_proc
		send_user "\nError: EOF received\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    }
	}

    # Here we get a little tricky.  There are several possibilities:
    # the router can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the router might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-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
	    }
	}
	-re "Telnet server disabled" {
	    catch {close}; catch {wait};
	    if !$progs {
		send_user "\nError: Connection Refused ($prog): $router\n"
		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 $router\n"; wait; return 1
	}
	"Host is unreachable" {
	    catch {close}; catch {wait};
	    send_user "\nError: Host Unreachable: $router\n"; wait; return 1
	}
	"No address associated with name" {
	    catch {close}; catch {wait};
	    send_user "\nError: Unknown host $router\n"; wait; return 1
	}
	-re "(Host key not found |The authenticity of host .* be established)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-nocase -re "^warning: remote host denied authentication agent forwarding." {
	    exp_continue;
	}
	-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"
				  return 1
				}
	-re "% (Bad passwords|Authentication failed)"	{
				  send_user "\nError: Check your passwd for $router\n"
				  return 1
				}
	-re "@\[^\r\n]+ $p_prompt"	{
					  # ssh pwd prompt
					  send -h -- "$userpswd\r"
					  exp_continue
				}
	-re "Enter passphrase.*: " {
				  # sleep briefly to allow time for stty -echo
				  sleep .3
				  send -- "$passphrase\r"
				  exp_continue
				}
	-re "$u_prompt"		{
				  send -h -- "$user\r"
				  set uprompt_seen 1
				  exp_continue
				}
	-re "$p_prompt"		{
				  if {$uprompt_seen == 1} {
					send -h -- "$userpswd\r"
				  } else {
					send -h -- "$passwd\r"
				  }
				  exp_continue
				}
	"$prompt"		{ break; }
	"Login invalid"		{
				  send_user "\nError: Invalid login: $router\n";
				  catch {close}; catch {wait}; return 1
				}
     }
    }

    set in_proc 0
    return 0
}

# Enable
proc do_enable { enauser enapasswd } {
    global prompt in_proc
    global u_prompt e_prompt
    set in_proc 1

    send -h "enable\r"
    expect {
	-re "$u_prompt"	{ send -h -- "$enauser\r"; exp_continue}
	-re "$e_prompt"	{ send -h -- "$enapasswd\r"; exp_continue}
	"#"		{ set prompt "#" }
	"(enable)"	{ set prompt "> (enable) " }
	denied		{ send_user "\nError: Check your Enable passwd\n";
			  return 1
			}
	"Incorrect username or password" {
			  send_user "\nError: Check your Enable passwd\n";
			  return 1
			}
	"% Bad passwords" { send_user "\nError: Check your Enable passwd\n";
			  return 1
			}
    }
    # We set the prompt variable (above) so script files don't need
    # to know what it is.
    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact do_saveconfig in_proc
    set in_proc 1

    send -h "skip-page-display\r"
    expect -re "$prompt" {}
    # If logging in as an unpriv user (i.e., level 5 read-only), then
    # "skip-page-display" isn't available, unless you also configure:
    # privilege exec level 5 skip-page-display
    #
    # On some platforms, like the MLX, you can work around that
    # with this:
    send "terminal length 0\r"
    expect -re "$prompt" {}

    # match foundry config mode prompts too, such as ssh@router(config-if)#
    # or ssh@truncatedr(config-if)#.  NOTE that, at least, as of v6.0.0
    # (2018?), Foundry NetIron does not truncate, but this shouldnt hurt.
    regsub -lineanchor -- {^(.{1,11}).*([#>])$} $prompt {\1} reprompt
    regsub -all -- {[\\]$} $reprompt {} reprompt
    append reprompt {([^#>\r\n]+)?[#>]([\\r\\n]+)?}

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    for {set i 0} {$i < $num_commands} { incr i} {
	send -h -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
	    -re " *\b+"			{ exp_continue }
	    -re "^\[^\n\r]*$reprompt."	{ exp_continue }
	    -re "^\[^\n\r *]*$reprompt"	{}
	    -re "\[\n\r]"		{ exp_continue }
	    -- "---More---"		{ # EdgeIron cant disable pager
					  send " "
					  exp_continue
					}
	}
    }

    if { $do_interact == 1 } {
	interact
	return 0
    }

    send -h "exit\r"
    expect {
	"\n"					{ exp_continue }
	-re "^\[^ ]+>"				{ send -h "exit\r"
						  exp_continue
						}
	timeout					{ catch {close}; catch {wait};
						  return 0
						}
	eof					{ return 0 }
	-re "Configuration modified, save\? \[\r\n]*" {
						  if {$do_saveconfig} {
						    catch {send "y\r"}
						  } else {
						    catch {send "n\r"}
						  }
						  exp_continue
						}
    }
    set in_proc 0
}

#
# For each router... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # Figure out prompt.
    # Since autoenable is off by default, if we have it defined, it
    # was done on the command line. If it is not specifically set on the
    # command line, check the password file.
    if $avautoenable {
	set autoenable 1
	set enable 0
	set prompt "#"
    } else {
	set ae [find autoenable $router]
	if { "$ae" == "1" } {
	    set autoenable 1
	    set enable 0
	    set prompt "#"
	} else {
	    set autoenable 0
	    set enable $avenable
	    set prompt ">"
	}
    }

    # Figure out passwords
    if { $do_passwd || $do_enapasswd } {
	set pswd [find password $router]
	if { [llength $pswd] == 0 } {
	    send_user -- "\nError: no password for $router in $password_file.\n"
	    continue
	}
	if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } {
	    send_user -- "\nError: no enable password for $router in $password_file.\n"
            continue
	}
	if { $do_passwd } {
	    set passwd [join [lindex $pswd 0] ""]
	} else {
	    set passwd $userpasswd
	}
	if { $do_enapasswd } {
	    set enapasswd [join [lindex $pswd 1] ""]
	} else {
	    set enapasswd $enapasswd
	}
    } else {
	set passwd $userpasswd
	set enapasswd $enapasswd
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } 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 $ruser }
    }

    # Figure out prompts
    set u_prompt [find userprompt $router]
    if { "$u_prompt" == "" } {
	set u_prompt "(Username|login|Name|User Name) *:"
    } else {
	set u_prompt [join [lindex $u_prompt 0] ""]
    }
    set p_prompt [find passprompt $router]
    if { "$p_prompt" == "" } {
	set p_prompt "(\[Pp]assword):"
    } else {
	set p_prompt [join [lindex $p_prompt 0] ""]
    }
    set e_prompt [find enableprompt $router]
    if { "$e_prompt" == "" } {
	set e_prompt "\[Pp]assword:"
    } else {
	set e_prompt [join [lindex $e_prompt 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 cypher tpye
    if {[info exists cypher]} {
      # command line cypher type
      set cyphertype $cypher
    } else {
      set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile ]} {
	incr exitval
	continue
    }
    if { $enable } {
	if {[do_enable $enauser $enapasswd]} {
	    if { $do_command || $do_script } {
		incr exitval
		catch {close}; catch {wait};
		continue
	    }
	}
    }
    # we are logged in, now figure out the full prompt
    send -h "\r"
    expect {
	-re "\[\r\n]+"		{ exp_continue; }
	-re "^.+$prompt"	{ set junk $expect_out(0,string);
				  regsub -all "\[\]\[ ]" $junk {\\&} prompt;
				}
    }


    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	# fucking foundry
	send -h "skip-page-display\r"
	expect -re $prompt	{}
	# If logging in as an unpriv user (i.e., level 5 read-only), then
	# "skip-page-display" isn't available, unless you also configure:
	# privilege exec level 5 skip-page-display
	#
	# On some platforms, like the MLX, you can work around that
	# with this:
	send "terminal length 0\r"
	expect -re "$prompt" {}
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each router
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/blogin.in000644 015615 000000 00000046135 13657102757 015356 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## @PACKAGE@ @VERSION@
@copyright@
#
# blogin - Bay Networks(Nortel) login
#
# Unlike the Cisco's, there is no enable function on the Bay's.  Instead
# there are seperate User and Manager accounts.  A 'system' command exists,
# which I am told does nothing.
#
# The "bcc>" prompt changes to "box#", not "bcc#" after the config command.
#

# XXX need to import login_top.

# Usage line
set usage "Usage: $argv0 \[-diSV\] \[-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\] \
\[-y ssh_cypher_type\] router \[router...\]\n"

# env(CLOGIN) may contain:
#	x == do not set xterm banner or name

# Password file
set password_file $env(HOME)/.cloginrc
# Default is to login to the router
set do_command 0
set do_interact 0
set do_script 0
# The default is to automatically enable
set avenable 0
# The default is that you login non-enabled (tacacs can have you login already
# enabled)
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
set do_enapasswd 0
# Save config, if prompted
set do_saveconfig 0
# cloginrc debugging knob
set do_cloginrcdbg 0
# Sometimes routers take awhile to answer (the default is 10 sec)
set timeoutdflt 45
# intialize cloginrc parsing stacks
set int_file {}
set int_lineno {}
# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

# Find the user in the ENV, or use the unix userid.
if {[ info exists env(CISCO_USER) ]} {
    set default_user $env(CISCO_USER)
} elseif {[ info exists env(USER) ]} {
    set default_user $env(USER)
} elseif {[ info exists env(LOGNAME) ]} {
    set default_user $env(LOGNAME)
} 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.
    if [ catch {exec id} reason ] {
	send_error "\nError: could not exec id: $reason\n"
	exit 1
    }
    regexp {\(([^)]*)} "$reason" junk default_user
}
if {[ info exists env(CLOGINRC) ]} {
    set password_file $env(CLOGINRC)
}

# Process the command line
for {set i 0} {$i < $argc} {incr i} {
    set arg [lindex $argv $i]

    switch  -glob -- $arg {
	# Expect debug mode
	-d* {
	    exp_internal 1
	# Username
	} -u* {
	    if {! [  regexp .\[uU\](.+) $arg ignore user]} {
		incr i
		set username [ lindex $argv $i ]
	    }
	# cloginrc debugging knobs
	} -m* {
	    set do_cloginrcdbg 1
	} -M* {
	    set do_cloginrcdbg 2
	# interactive
	} -i* {
	    set do_interact 1
	# VTY Password
	} -p* {
	    if {! [  regexp .\[pP\](.+) $arg ignore userpasswd]} {
		incr i
		set userpasswd [ lindex $argv $i ]
	    }
	    set do_passwd 0
	# ssh passphrase
	} -r* {
	    # ignore -r
	# VTY Password
	} -v* {
	    if {! [  regexp .\[vV\](.+) $arg ignore passwd]} {
		incr i
		set passwd [ lindex $argv $i ]
	    }
	    set do_passwd 0
	# Version string
	} -V* {
	    send_user "@PACKAGE@ @VERSION@\n"
	    exit 0
	# Enable Username
	} -w* {
	    if {! [  regexp .\[wW\](.+) $arg ignore enauser]} {
		incr i
		set enausername [ lindex $argv $i ]
	    }
        # Environment variable to pass to -s scripts
	} -E* {
	    if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} {
		set E$varname $varvalue
	    } else {
		send_user "\nError: invalid format for -E in $arg\n"
		exit 1
	    }
	# Enable Password
	} -e* {
	    if {! [  regexp .\[eE\](.+) $arg ignore enapasswd]} {
		incr i
		set enapasswd [ lindex $argv $i ]
	    }
	    set do_enapasswd 0
	# Command to run.
	} -c* {
	    if {! [  regexp .\[cC\](.+) $arg ignore command]} {
		incr i
		set command [ lindex $argv $i ]
	    }
	    set do_command 1
	# Expect script to run.
	} -s* {
	    if {! [  regexp .\[sS\](.+) $arg ignore sfile]} {
		incr i
		set sfile [ lindex $argv $i ]
	    }
	    if { ! [ file readable $sfile ] } {
		send_user "\nError: Can't read $sfile\n"
		exit 1
	    }
	    set do_script 1
	# save config on exit
	} -S* {
	    set do_saveconfig 1
	# 'ssh -c' cypher type
	} -y* {
	    if {! [  regexp .\[eE\](.+) $arg ignore cypher]} {
		incr i
		set cypher [ lindex $argv $i ]
	    }
	# alternate cloginrc file
	} -f* {
	    if {! [ regexp .\[fF\](.+) $arg ignore password_file]} {
		incr i
		set password_file [ lindex $argv $i ]
	    }
	# Timeout
	} -t* {
	    if {! [ regexp .\[tT\](.+) $arg ignore timeout]} {
		incr i
	        set timeoutdflt [ lindex $argv $i ]
	    }
	# Command file
	} -x* {
	    if {! [  regexp .\[xX\](.+) $arg ignore cmd_file]} {
		incr i
		set cmd_file [ lindex $argv $i ]
	    }
	    set cmd_fd [open $cmd_file r]
	    set cmd_text [read $cmd_fd]
	    close $cmd_fd
	    set command [join [split $cmd_text \n] \;]
	    set do_command 1
	# Do we enable?
	} -noenable {
	    set avenable 0
	# Does tacacs automatically enable us?
	} -autoenable {
	    set avautoenable 1
	    set avenable 0
	} -* {
	    send_user "\nError: Unknown argument! $arg\n"
	    send_user $usage
	    exit 1
	} default {
	    break
	}
    }
}
# Process routers...no routers listed is an error.
if { $i == $argc } {
    send_user "\nError: $usage"
}

# Only be quiet if we are running a script (it can log its output
# on its own)
if { $do_script } {
    log_user 0
} else {
    log_user 1
}

#
# Done configuration/variable setting.  Now run with it...
#

# 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 }
    }
    # take host from ENV(TERM)
    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"
	}
    }
}

# This is a helper function to make the password file easier to
# maintain.  Using this the password file has the form:
# add password sl*	pete cow
# add password at*	steve
# add password *	hanky-pie
proc add {var args} {
    global int_file int_lineno int_$var
    set file [lindex $int_file 0]
    set lineno [lindex $int_lineno 0]
    lappend int_$var "$var:$file:$lineno: $args"
}
proc include {args} {
    global env
    regsub -all "(^{|}$)" $args {} args
    if {[regexp "^/" $args ignore] == 0} {
	set args $env(HOME)/$args
    }
    source_password_file $args
}

proc find {var router} {
    global do_cloginrcdbg
    upvar int_$var list
    if {[info exists list]} {
	foreach line $list {
	    if {[string match -nocase [lindex $line 1] $router]} {
		if {$do_cloginrcdbg > 0} {
		    send_error -- [join [list [lindex $line 0] [lrange $line 1 end] "\r\n"]]
		}
		if {$do_cloginrcdbg == 2} {
		    # save return value
		    if {! [info exists result]} {
			set result [lrange $line 2 end]
		    }
		} else {
		    return [lrange $line 2 end]
		}
	    }
	}
    }

    if {$do_cloginrcdbg == 2} {
	if {[info exists result]} {
	    return $result
	}
    }
    return {}
}

# Loads the password file.  Note that as this file is tcl, and that
# it is sourced, the user better know what to put in there, as it
# could install more than just password info...  I will assume however,
# 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 {file} {
    global env int_file int_lineno
    if {! [file exists $file]} {
	send_user "\nError: password file ($file) does not exist\n"
	exit 1
    }
    file stat $file fileinfo
    if {[expr ($fileinfo(mode) & 007)] != 0000} {
	send_user "\nError: $file must not be world readable/writable\n"
	exit 1
    }
    if [catch {set fd [open $file "r"]} reason] {
	send_user "\nError: $reason\n"
	exit 1
    }
    set int_file [linsert $int_file 0 $file]
    set int_lineno [linsert $int_lineno 0 0]
    while {[gets $fd line] >= 0} {
	set tmp [lindex $int_lineno 0]; incr tmp
	lset int_lineno 0 $tmp
	eval $line
    }
    set int_file [lrange $int_file 1 end]
    set int_lineno [lrange $int_lineno 1 end]
    close $fd
}

# Log into the router.
# returns: 0 on success, 1 on failure
proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
    global spawn_id in_proc do_command do_script
    global u_prompt p_prompt e_prompt sshcmd telnetcmd
    set in_proc 1

    # try each of the connection methods in $cmethod until one is successful
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog command suffix port
	    if {"$port" == ""} {
		set retval [ catch {eval spawn [split "$telnetcmd $router"]} reason ]
	    } else {
		set retval [ catch {eval spawn [split "$telnetcmd $router $port"]} reason ]
	    }
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif ![string compare $prog "ssh"] {
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    set retval [ catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason ]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	} elseif ![string compare $prog "rsh"] {
	    send_error "\nError: unsupported method: rsh\n"
	    if { $progs == 0 } {
		return 1
	    }
	    continue;
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}
	sleep 0.3

	# This helps cleanup each expect clause.
	expect_after {
	    timeout {
		global in_proc
		send_user "\nError: TIMEOUT reached\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    } eof {
		global in_proc
		send_user "\nError: EOF received\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    }
	}

    # Here we get a little tricky.  There are several possibilities:
    # the router can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the router might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-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
	}
	"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)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-nocase -re "^warning: remote host denied authentication agent forwarding." {
	    exp_continue;
	}
	-re "$u_prompt"	{ send -- "$user\r"
	    expect {
		eof			{ send_user "\nError: Couldn't login\n"; wait; return 1 }
		"Login invalid"		{ send_user "\nError: Invalid login\n";
					  catch {close}; catch {wait};
					  return 1 }
		-re "$p_prompt"		{ send -- "$userpswd\r" }
		"$prompt"		{ set in_proc 0; return 0 }
	    }
	    exp_continue
	}
	-re "$p_prompt"	{
	    if ![string compare $prog "ssh"] {
		send -- "$userpswd\r"
	    } else {
		send -- "$passwd\r"
	    }
	    expect {
		eof		{ send_user "\nError: Couldn't login\n"; wait; return 1 }
		-re "$e_prompt"	{ send -- "$enapasswd\r" }
		"$prompt"	{ set in_proc 0; return 0 }
	    }
	    exp_continue
	}
	"$prompt"	{ break; }
	denied		{ send_user "\nError: Check your passwd for $router\n"
			  catch {close}; catch {wait}; return 1
			}
	"% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
    }
}
    set in_proc 0
    return 0
}

# Enable
proc do_enable { enauser enapasswd } {
    global prompt in_proc
    global u_prompt e_prompt
    set in_proc 1

    send "enable\r"
    expect {
	-re "$u_prompt"	{ send -- "$enauser\r"; exp_continue}
	-re "$e_prompt"	{ send -- "$enapasswd\r"; exp_continue}
	"#"		{ set prompt "#" }
	"(enable)"	{ set prompt "> (enable) " }
	denied		{ send_user "\nError: Check your Enable passwd\n"
			  return 1
			}
	"% Bad passwords" {
			  send_user "\nError: Check your Enable passwd\n"
	  		  return 1
			}
    }
    # We set the prompt variable (above) so script files don't need
    # to know what it is.
    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact in_proc
    set in_proc 1

    send "more off\r"

    expect $prompt {}

    regsub -all "\[)(]" $prompt {\\&} reprompt

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
	    -re "^\[^\n\r *]*$reprompt"		{}
	    -re "^\[^\n\r]*$reprompt."		{ exp_continue }
	    -re "\[\n\r]+"			{ exp_continue }
	}
    }

    if { $do_interact == 1 } {
	interact
	return 0
    }

    send "logout\r"
    expect {
	"\n"					{ exp_continue }
	timeout					{ catch {close}; catch {wait};
						  return 0
						}
	eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each router... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # Figure out prompt.
    # Since autoenable is off by default, if we have it defined, it
    # was done on the command line. If it is not specifically set on the
    # command line, check the password file.
    if $avautoenable {
	set autoenable 1
	set enable 0
	set prompt "#"
    } else {
	set ae [find autoenable $router]
	if { "$ae" == "1" } {
	    set autoenable 1
	    set enable 0
	    set prompt "#"
	} else {
	    set autoenable 0
	    set enable $avenable
	    set prompt ">"
	}
    }

    # look for noenable option in .cloginrc
    if { [find noenable $router] == "1" } {
	set enable 0
    }

    # Figure out passwords
    if { $do_passwd || $do_enapasswd } {
	set pswd [find password $router]
	if { [llength $pswd] == 0 } {
	    send_user -- "\nError: no password for $router in $password_file.\n"
	    continue
	}
	if { $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } {
	    send_user -- "\nError: no enable password for $router in $password_file.\n"
	    continue
	}
	if { $do_passwd } {
	    set passwd [join [lindex $pswd 0] ""]
	} else {
	    set passwd $userpasswd
	}
	if { $do_enapasswd } {
	    set enapasswd [join [lindex $pswd 1] ""]
	} else {
	    set enapasswd $enapasswd
	}
    } else {
	set passwd $userpasswd
	set enapasswd $enapasswd
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } 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 $ruser }
    }

    # Figure out prompts
    set u_prompt [find userprompt $router]
    if { "$u_prompt" == "" } {
	set u_prompt "(Username|login|user name):"
    } else {
	set u_prompt [join [lindex $u_prompt 0] ""]
    }
    set p_prompt [find passprompt $router]
    if { "$p_prompt" == "" } {
	set p_prompt "(\[Pp]assword|passwd):"
    } else {
	set p_prompt [join [lindex $p_prompt 0] ""]
    }
    set e_prompt [find enableprompt $router]
    if { "$e_prompt" == "" } {
	set e_prompt "\[Pp]assword:"
    } else {
	set e_prompt [join [lindex $e_prompt 0] ""]
    }

    # Figure out cypher type
    if {[info exists cypher]} {
      # command line cypher type
      set cyphertype $cypher
    } else {
      set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $enapasswd $prompt $cmethod $cyphertype]} {
	incr exitval
	continue
    }
    if { $enable } {
	if {[do_enable $enauser $enapasswd]} {
	    if { $do_command || $do_script } {
		incr exitval
		catch {close}; catch {wait};
		continue
	    }
	}
    }

    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	send "more off\r"
	expect $prompt	{}
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each router
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/rrancid.in000644 015615 000000 00000032665 13534015003 015506 0ustar00heaswheel000000 000000 #! @PERLV_PATH@
##
## @PACKAGE@ @VERSION@
## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Henry Kilmer, John Heasley, Andrew Partan,
## Pete Whiting, Austin Schutz, and Andrew Fort.
##
## 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. Neither the name of RANCID nor the names of its
##    contributors may be used to endorse or promote products derived from
##    this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
##
## It is the request of the authors, but not a condition of license, that
## parties packaging or redistributing RANCID NOT distribute altered versions
## of the etc/rancid.types.base file nor alter how this file is processed nor
## when in relation to etc/rancid.types.conf.  The goal of this is to help
## suppress our support costs.  If it becomes a problem, this could become a
## condition of license.
# 
#  The expect login scripts were based on Erik Sherk's gwtn, by permission.
# 
#  The original looking glass software was written by Ed Kern, provided by
#  permission and modified beyond recognition.
#
# hacked version of Hank's rancid - this one tries to deal with redbacks.
#
#  RANCID - Really Awesome New Cisco confIg Differ
#
# usage: rrancid [-dltCV] [-f filename | hostname]
#
use Getopt::Std;
getopts('dflt:CV');
if ($opt_V) {
    print "@PACKAGE@ @VERSION@\n";
    exit(0);
}
$log = $opt_l;
$debug = $opt_d;
$file = $opt_f;
$host = $ARGV[0];
$clean_run = 0;
$found_end = 0;
$timeo = 90;				# clogin timeout in seconds

my(@commandtable, %commands, @commands);# command lists
my($aclsort) = ("ipsort");		# ACL sorting mode
my($filter_commstr);			# SNMP community string filtering
my($filter_osc);			# oscillating data filtering mode
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))
	&& scalar(%history)) {
	print eval "$command \%history";
	undef %history;
    }
    if (($new_hist_tag) && ($new_command) && ($command_string)) {
	if ($history{$command_string}) {
	    $history{$command_string} = "$history{$command_string}@string";
	} else {
	    $history{$command_string} = "@string";
	}
    } elsif (($new_hist_tag) && ($new_command)) {
	$history{++$#history} = "@string";
    } else {
	print "@string";
    }
    $hist_tag = $new_hist_tag;
    $command = $new_command;
    1;
}

sub numerically { $a <=> $b; }

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort numerically keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort values %lines) {
	$sorted_lines[$i] = $key;
	$i++;
    }
    @sorted_lines;
}

# This is a numerical sort routine (ascending).
sub numsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $num (sort {$a <=> $b} keys %lines) {
	$sorted_lines[$i] = $lines{$num};
	$i++;
    }
    @sorted_lines;
}

# This is a sort routine that will sort on the
# ip address when the ip address is anywhere in
# the strings.
sub ipsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $addr (sort sortbyipaddr keys %lines) {
	$sorted_lines[$i] = $lines{$addr};
	$i++;
    }
    @sorted_lines;
}

# 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]));
}
sub sortbyipaddr {
    &ipaddrval($a) <=> &ipaddrval($b);
}

# This routine parses "show version"
sub ShowVersion {
    print STDERR "    In ShowVersion: $_" if ($debug);

    while () {
	tr/\015//d;
	last if(/^$prompt/);

	/(Copyright|uptime|restarted|^\s*$)/ && next;
	/(Up Time|Boot Time)/ && next;
	ProcessHistory("COMMENTS","keysort","A1","!Image: $_");
    }
    return;
}

# This routine parses "dir /"
sub DirFlash {
    print STDERR "    In DirFlash: $_" if ($debug);

    my($dev) = (/\/(.*)$/);
    while () {
	tr/\015//d;
	last if(/^$prompt/);
	/^\s*$/ && next;

	/(Can\'t open|No such device)/ && return;
	/is not a valid path on a local file system/ && return;
	ProcessHistory("FLASH","keysort",$dev,"!Flash: $dev: $_");
    }
    ProcessHistory("FLASH","keysort",$dev,"!\n");
    return;
}

# This routine parses "show hardware"
sub ShowHardware {
    print STDERR "    In ShowHardware: $_" if ($debug);

    while () {
	tr/\015//d;
	last if(/^$prompt/);
	s/\s*$/\n/;

	/Can not retrieve information/ && return;
	/^Temperature:/ && next;
	/^Voltage/ && next;
	/^$/ && next;
	#ProcessHistory("","","","!Chassis: $_") && next;
	ProcessHistory("COMMENTS","keysort","B1","!Chassis: $_");
    }
    ProcessHistory("COMMENTS","keysort","B1","!\n");
    return;
}

# This routine parses "show chassis"
sub ShowChassis {
    print STDERR "    In ShowChassis: $_" if ($debug);

    while () {
	tr/\015//d;
	last if(/^$prompt/);
	last if(/^invalid input at/i);
	next if(/^(\s*|\s*$cmd\s*|\s+\^)$/);

	ProcessHistory("COMMENTS","keysort","C1","!Chassis: $_");
    }
    ProcessHistory("COMMENTS","keysort","C1","!\n");
    return;
}

# This routine parses "show slot table"
sub ShowSlotTable {
    print STDERR "    In ShowSlotTable: $_" if ($debug);

    while () {
	tr/\015//d;
	last if(/^$prompt/);

	/(Slot Table|^$)/ && next;
	/^\s+\^/ && next;
	/Invalid input at/ && return;
	s/^\s*//;
	ProcessHistory("COMMENTS","keysort","D1","!Slot Table: $_");
    }
    ProcessHistory("COMMENTS","keysort","D1","!\n");
    return;
}

# This routine processes a "write term"
sub WriteTerm {
    print STDERR "    In WriteTerm: $_" if ($debug);

    while () {
	tr/\015//d;
	last if(/^$prompt/);
	next if(/^\s*$/);

#    /Non-Volatile memory is in use/  && return(-1); # NvRAM is locked
	# Dog gone Cool matches to process the rest of the config
	/^! last updated: .*$/ && next; # kill last updated line
	/^Building configuration/ && next; # kill Building config line
	/^Current configuration/ && next; # kill Current config line
	/^!  Configuration last changed by user / && next;
	/^ length / && next; # kill length on serial lines
	/^ width / && next; # kill width on serial lines
	# filter out any RCS/CVS tags to avoid confusing local CVS storage
	s/\$(Revision|Id):/ $1:/;
	# order access-lists
	/^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ &&
		ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next;
	# prune snmp community statements
	if (/^snmp (group|community) (\S+)/) {
	    if ($filter_commstr) {
		ProcessHistory("SNMPSERVERCOMM","keysort","$_","!snmp $1 $'") && next;
	    } else {
		ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next;
	    }
	}
	ProcessHistory("","","","$_");
	# end of config
	if (/^end$/) {
	    $found_end = 1;
	    last;
	}
    }
    return;
}

# Main subroutine that splits up the work
# All Subs return the name of the next function to use.
# If the sub returns a new funtion name, that name will be used
# else the main loop keeps using the current function
sub FlailHelplessly {
    print STDERR "Flailing: $_" if ($debug);
    print STDOUT "Flailing: $_" if ($log);
    /#(show version)$/ && delete($commands{$1}) && return("ShowVersion");
    /#(show hardware)$/ && delete($commands{$1}) && return("ShowHardware");
    /#(show chassis)$/ && delete($commands{$1}) && return("ShowChassis");
    /#(show slot table)$/ && delete($commands{$1}) && return("ShowSlotTable");
    /#(show config)$/ && delete($commands{$1}) && return("WriteTerm");
    return "FlailHelplessly";
}

# Main
@commandtable = (
	{'show version'		=> 'ShowVersion'},
	{'dir /flash'		=> 'DirFlash'},
	{'dir /pcmcia0'		=> 'DirFlash'},
	{'dir /pcmcia1'		=> 'DirFlash'},
	{'show hardware'	=> 'ShowHardware'},
	{'show chassis'		=> 'ShowChassis'},
	{'show slot table'	=> 'ShowSlotTable'},
	{'show config'		=> '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);
$commandcnt = scalar(keys %commands);

$redback_cmds=join(";",@commands);
$cmds_regexp = join("|", map quotemeta($_), @commands);

if (length($host) == 0) {
    if ($file) {
	print(STDERR "Too few arguments: file name required\n");
	exit(1);
    } else {
	print(STDERR "Too few arguments: host name required\n");
	exit(1);
    }
}
if ($opt_C) {
    print "clogin -t $timeo -c\'$commandstr\' $host\n";
    exit(0);
}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered
if ($debug) { $| = 1; }

if ($file) {
    print(STDERR "opening file $host\n") if ($debug || $log);
    open(INPUT,"<$host") || die "open failed for $host: $!\n";
} else {
    print(STDERR "executing clogin -t $timeo -c\"$redback_cmds\" $host\n") if ($debug || $log);
    system "clogin -t $timeo -c \"$redback_cmds\" $host  $host.raw" || die "clogin failed for $host: $!\n";
    open(INPUT, "< $host.raw") || die "clogin failed for $host: $!\n";
}

# 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 oscillating data filtering mode
if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) {
    $filter_osc = 0;
} else {
    $filter_osc = 1;
}
# determine password filtering mode
if ($ENV{"FILTER_PWDS"} =~ /no/i) {
    $filter_pwds = 0;
} elsif ($ENV{"FILTER_PWDS"} =~ /all/i) {
    $filter_pwds = 2;
} else {
    $filter_pwds = 1;
}

ProcessHistory("","","","!RANCID-CONTENT-TYPE: redback\n!\n");
ProcessHistory("COMMENTS","keysort","B0","!\n");
ProcessHistory("COMMENTS","keysort","C0","!\n");
ProcessHistory("COMMENTS","keysort","E0","!\n");
while() {
    tr/\015//d;
    if (/\#exit$/) {
	$clean_run=1;
	last;
    }
    if (/^Error:/) {
	print STDOUT ("$host clogin error: $_");
	print STDERR ("$host clogin error: $_") if ($debug);
	$clean_run=0;
	last;
    }
    while (/#\s*($cmds_regexp)\s*$/) {
	$cmd = $1;
	if (!defined($prompt)) {
	    $prompt = ($_ =~ /^([^#]*#)/)[0];
	    $prompt =~ s/([][}{)(\\])/\\$1/g; # quote the damn []'s
	    print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);
	}
	print STDERR ("HIT COMMAND:$_") if ($debug);
	if (! defined($commands{$cmd})) {
	    print STDERR "$host: found unexpected command - \"$cmd\"\n";
	    $clean_run = 0;
	    last;
	}
	$rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd);
	delete($commands{$cmd});
	if ($rval == -1) {
	    $clean_run = 0;
	    last;
	}
    }
}
print STDOUT "Done $logincmd: $_\n" if ($log);
# Flush History
ProcessHistory("","","","");
# Cleanup
close(INPUT);
close(OUTPUT);

unlink("$host.raw") if (! $debug);

# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
    if (scalar(keys %commands) eq $commandcnt) {
	printf(STDERR "$host: missed cmd(s): all commands\n");
    } elsif (scalar(%commands)) {
	my($count, $i) = 0;
	for ($i = 0; $i < $#commands; $i++) {
	    if ($commands{$commands[$i]}) {
		if (!$count) {
		    printf(STDERR "$host: missed cmd(s): %s", $commands[$i]);
		} else {
		    printf(STDERR ", %s", $commands[$i]);
		}
		$count++;
	    }
	}
	if ($count) {
	    printf(STDERR "\n");
	}
    }
    if (!$clean_run || !$found_end) {
	print(STDERR "$host: End of run not found\n");
	if ($debug) {
	    print(STDERR "$host: clean_run is false\n") if (!$clean_run);
	    print(STDERR "$host: found_end is false\n") if (!$found_end);
	}
	system("/usr/bin/tail -1 $host.new");
    }
    unlink "$host.new" if (! $debug);
}
rancid-3.13/bin/jlogin.in000644 015615 000000 00000023432 13713052202 015337 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## @PACKAGE@ @VERSION@
@copyright@
#
# jlogin - juniper junos login
#

# Sometimes routers take awhile to answer (the default is 10 sec)
set timeoutdflt 120
# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

@login_top@

# Log into the router.
# returns: 0 on success, 1 on failure
proc login { router user passwd cmethod cyphertype identfile} {
    global spawn_id in_proc do_command do_script passphrase prompt
    global sshcmd telnetcmd
    global spawnopts
    set in_proc 1

    # try each of the connection methods in $cmethod until one is successful
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog command suffix port
	    if {"$port" == ""} {
		set retval [ catch {eval spawn $spawnopts [split "$telnetcmd $router"]} reason ]
	    } else {
		set retval [ catch {eval spawn $spawnopts [split "$telnetcmd $router $port"]} reason ]
	    }
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif [string match "ssh*" $prog] {
	    # ssh to the router & try to login with or without an identfile.
	    # We use two calls to spawn since spawn does not seem to parse
	    # spaces correctly.
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    if {"$identfile" != ""} {
		set cmd "$cmd -i $identfile"
	    }
	        set retval [ catch {eval spawn $spawnopts [split "$cmd -x -l $user $router" { }]} reason ]
	    if { $retval } {
		send_user "\nError: $sshcmd failed: $reason\n"
		return 1
	    }
	} elseif ![string compare $prog "rsh"] {
	    send_error "\nError: unsupported method: rsh\n"
	    if { $progs == 0 } {
		return 1
	    }
	    continue
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}
	sleep 0.3

	# This helps cleanup each expect clause.
	expect_after {
	    timeout {
		global in_proc
		send_user "\nError: TIMEOUT reached\n"
		catch {close}; catch {wait};
		if {$in_proc} {
	            return 1
		} else {
	            continue
		}
            } eof {
		global in_proc
		send_user "\nError: EOF received\n"
		catch {close}; catch {wait};
		if {$in_proc} {
	            return 1
		} else {
	            continue
		}
            }
	}

	# Here we get a little tricky.  There are several possibilities:
	# the router can ask for a username and passwd and then
	# talk to the TACACS server to authenticate you, or if the
	# TACACS server is not working, then it will use the enable
	# passwd.  Or, the router might not have TACACS turned on,
	# then it will just send the passwd.
	expect {
	    -re "(Connection refused|Secure connection \[^\n\r]+ refused|Connection closed by)" {
		catch {close}; catch {wait};
		if !$progs {
		   send_user "\nError: Connection Refused ($prog)\n"; return 1
		}
	    }
            eof { send_user "\nError: Couldn't login\n"; catch {wait}; return 1
	    } -nocase "unknown host\r\n" {
		catch {close}; catch {wait};
		send_user "\nError: Unknown host\n"; catch {wait}; return 1
	    } "Host is unreachable" {
		catch {close}; catch {wait};
		send_user "\nError: Host Unreachable!\n"; catch {wait}; return 1
	    } "No address associated with name" {
		catch {close}; catch {wait};
		send_user "\nError: Unknown host\n"; catch {wait}; return 1
	    }
	    "Login incorrect" {
			  send_user "\nError: Check your password for $router\n"
			  catch {close}; catch {wait}; return 1
			}
	    -re "Enter passphrase.*: " {
		# sleep briefly to allow time for stty -echo
		sleep 1
		send -- "$passphrase\r"
		exp_continue }
	    -re "(Host key not found |The authenticity of host .* be established)" {
		expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
						  send_user "\nHost $router added to the list of known hosts.\n"
						}
		    -re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
		}
		exp_continue
	    }
	    -re "HOST IDENTIFICATION HAS CHANGED" {
		send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
		expect {
		    -re "\\(yes\/no\\)\\?"	{ send "no\r" }
		    -re " strict checking\.\[\r\n]+" { }
		    -re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
		}
		catch {close}; catch {wait};
		return 1
	    }
	    -re "Offending key for " {
		send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
		expect {
		    -re "\\(yes\/no\\)\\?"	{ send "no\r" }
		    -re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
		}
		catch {close}; catch {wait};
		return 1
	    }
	    -nocase -re "^warning: remote host denied authentication agent forwarding." {
		exp_continue;
	    }
	    -re "(Username|\[\r\n]login):"	{
						  send -- "$user\r"
						  exp_continue
	    					}
	    -nocase -re "last login:"		{
						  exp_continue
	    					}
	    -nocase -re "failed login:"		{
						  exp_continue
	    					}
	    -re "\[\r\n\u0001]\[A-Za-z0-9.-]+ login:"	{
						  # Fujitsu t100 
						  # ^ login:
						  send -- "$user\r"
						  exp_continue
	    					}
	    "\[Pp]assword:"			{
						  sleep 1; send -- "$passwd\r"
						  exp_continue
						}
	    -re "<\[^ ]+>"			{ # skip login tips that look
						  # like prompts
						  exp_continue;
						 }
	    -re "$prompt"		{ break; }
	    denied	{ send_user "\nError: Check your password for $router\n"
	                  catch {close}; catch {wait}; return 1
	                }
	}
    }

    # we are logged in, now figure out the full prompt
    send "\r"
    expect {
	-re "(\r\n|\n)"		{ exp_continue; }
	-re "^\[^ ]+$prompt"	{ set prompt $expect_out(0,string);
				  regsub ">" $prompt "\[#>]" prompt;
				}
    }

    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact in_proc
    set in_proc 1

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
	    -re "^\[^\n\r *]*$prompt $"	{}
	    -re "^\[^\n\r]*$prompt."	{ exp_continue }
	    -re "(\r\n|\n)"		{ exp_continue }
	}
    }

    if { $do_interact == 1 } {
	interact
	return 0
    }

    send "quit\r"
    expect {
	"\n"					{ exp_continue }
	timeout					{ catch {close}; catch {wait};
						  return 0
						}
	eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each router... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
# if we have dont have a tty, we need some additional terminal settings
if [catch {open /dev/tty w} ttyid] {
    # no tty, ie: cron
    set spawnopts "-nottycopy"
    set stty_init "cols 132"
} else {
    catch {close ttyid} reason
}
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    set prompt ">"

    # Figure out username
    if {[info exists username]} {
      # command line username
      set loginname $username
    } else {
      set loginname [join [find user $router] ""]
      if { "$loginname" == "" } { set loginname $default_user }
    }

    # Figure out loginname's password (if different from the vty password)
    if {[info exists userpasswd]} {
	# command line passwd
	set passwd $userpasswd
    } else {
	set passwd [join [lindex [find userpassword $router] 0] ""]
	if { "$passwd" == "" } {
            set passwd [join [lindex [find password $router] 0] ""]
            if { "$passwd" == "" } {
		send_user -- "\nError: no password for $router in $password_file.\n"
		continue
            }
	}
    }

    # 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
    if {[info exists cypher]} {
      # command line ssh cypher type
      set cyphertype $cypher
    } else {
      set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $loginname $passwd $cmethod $cyphertype $identfile]} {
	incr exitval
	continue
    }

    if { $do_command || $do_script } {
	send "set cli complete-on-space off\r"
	expect -re $prompt	{}
	send "set cli screen-length 0\r"
	expect -re $prompt	{}
	send "set cli screen-width 0\r"
	expect -re $prompt	{}
    }
    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each router
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/agmrancid.in000644 015615 000000 00000040526 13534014645 016017 0ustar00heaswheel000000 000000 #! @PERLV_PATH@
##
## @PACKAGE@ @VERSION@
## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Henry Kilmer, John Heasley, Andrew Partan,
## Pete Whiting, Austin Schutz, and Andrew Fort.
##
## 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. Neither the name of RANCID nor the names of its
##    contributors may be used to endorse or promote products derived from
##    this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
##
## It is the request of the authors, but not a condition of license, that
## parties packaging or redistributing RANCID NOT distribute altered versions
## of the etc/rancid.types.base file nor alter how this file is processed nor
## when in relation to etc/rancid.types.conf.  The goal of this is to help
## suppress our support costs.  If it becomes a problem, this could become a
## condition of license.
# 
#  The expect login scripts were based on Erik Sherk's gwtn, by permission.
# 
#  The original looking glass software was written by Ed Kern, provided by
#  permission and modified beyond recognition.
#
# Amazingly hacked version of Hank's rancid - this one tries to
# deal with Cisco AGMs.
#
#  RANCID - Really Awesome New Cisco confIg Differ
#
# usage: agmrancid [-dltCV] [-f filename | hostname]
#
use Getopt::Std;
getopts('dflt:CV');
if ($opt_V) {
    print "@PACKAGE@ @VERSION@\n";
    exit(0);
}
$log = $opt_l;
$debug = $opt_d;
$file = $opt_f;
$host = $ARGV[0];
$clean_run = 0;
$found_end = 0;
$found_version = 0;
$found_env = 0;
$found_diag = 0;
$timeo = 90;				# clogin timeout in seconds

# the AGM kicks us off if it does not know our terminal type
$ENV{'TERM'} = "dumb";

my(@commandtable, %commands, @commands);# command lists
my($aclsort) = ("ipsort");		# ACL sorting mode
my($filter_commstr);			# SNMP community string filtering
my($filter_osc);			# oscillating data filtering mode
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))
	&& scalar(%history)) {
	print eval "$command \%history";
	undef %history;
    }
    if (($new_hist_tag) && ($new_command) && ($command_string)) {
	if ($history{$command_string}) {
	    $history{$command_string} = "$history{$command_string}@string";
	} else {
	    $history{$command_string} = "@string";
	}
    } elsif (($new_hist_tag) && ($new_command)) {
	$history{++$#history} = "@string";
    } else {
	print "@string";
    }
    $hist_tag = $new_hist_tag;
    $command = $new_command;
    1;
}

sub numerically { $a <=> $b; }

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort numerically keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort values %lines) {
	$sorted_lines[$i] = $key;
	$i++;
    }
    @sorted_lines;
}

# This is a numerical sort routine (ascending).
sub numsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $num (sort {$a <=> $b} keys %lines) {
	$sorted_lines[$i] = $lines{$num};
	$i++;
    }
    @sorted_lines;
}

# This is a sort routine that will sort on the
# ip address when the ip address is anywhere in
# the strings.
sub ipsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $addr (sort sortbyipaddr keys %lines) {
	$sorted_lines[$i] = $lines{$addr};
	$i++;
    }
    @sorted_lines;
}

# 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]));
}
sub sortbyipaddr {
    &ipaddrval($a) <=> &ipaddrval($b);
}

# This routine parses "show version"
sub ShowVersion {
    print STDERR "    In ShowVersion: $_" if ($debug);
    my($slaveslot);

    while () {
	tr/\015//d;
	if (/^$prompt/) { $found_version=1; last};
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if /Line has invalid autocommand /;
	return(1) if /(Invalid input detected|Type help or )/;
	return(-1) if (/command authorization failed/i);
	return(0) if ($found_version);		# Only do this routine once
	# the pager can not be disabled per-session on the PIX
	if (/^(-+More-+)/i) {
	    my($len) = length($1);
	    s/^$1\s{$len}//;
	}

	/^Cisco Anomaly Guard Image /i &&
	    ProcessHistory("COMMENTS","keysort","B1", "! $_") && next;
	/^MDM agent /i &&
	    ProcessHistory("COMMENTS","keysort","B1", "! $_") && next;
    }
    return(0);
}

# This routine parses "show diag"
# This will create arrarys for hw info.
sub ShowDiag {
    print STDERR "    In ShowDiag: $_" if ($debug);

    while () {
	tr/\015//d;
	if (/^$prompt/) { $found_diag=1; last};
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if /Line has invalid autocommand /;
	return(1) if /(Invalid input detected|Type help or )/;
	return(-1) if (/general error/i);
	return(-1) if (/command authorization failed/i);
	return(0) if ($found_diag);		# Only do this routine once
	return(-1) if (/failed to get counters/i);
	/^$/ && next;
	# the pager can not be disabled per-session on the PIX
	if (/^(-+More-+)/i) {
	    my($len) = length($1);
	    s/^$1\s{$len}//;
	}

	/^Cisco Anomaly Guard Image /i && next;
	/^... ... \d+ \d+:\d+:\d+ \w \d+$/ && next;
	/^Copyright /i && next;
	/^All rights /i && next;
	/sample loss:/i && next;
	/forward failures /i && next;

	ProcessHistory("DIAG","keysort","C1","! $_");
    }
    ProcessHistory("DIAG","","","!\n");
    return(0);
}

# This routine processes a "write term"
sub WriteTerm {
    print STDERR "    In WriteTerm: $_" if ($debug);
    my($lineauto,$comment,$linecnt) = (0,0,0);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	return(1) if /Line has invalid autocommand /;
	return(1) if (/(Invalid input detected|Type help or )/i);
	return(-1) if (/command authorization failed/i);
	# the pager can not be disabled per-session on the PIX
	if (/^(-+More-+)/i) {
	    my($len) = length($1);
	    s/^$1\s{$len}//;
	}

	/Non-Volatile memory is in use/  && return(-1); # NvRAM is locked
	return(0) if ($found_end);		# Only do this routine once
	$linecnt++;
	$lineauto = 0 if (/^[^ ]/);

	# skip consecutive comment/blank lines to avoid oscillating extra
	# comment line on some access servers.  grrr.
	if (/^!/ || /^$/) {
	    next if ($comment);
	    ProcessHistory("","","",$_);
	    $comment++;
	    next;
	}
	$comment = 0;

	# Dog gone Cool matches to process the rest of the config
	/^tftp-server flash /   && next; # kill any tftp remains
	/^ntp clock-period /    && next; # kill ntp clock-period
	/^ length /		&& next; # kill length on serial lines
	/^ width /		&& next; # kill width on serial lines
	$lineauto = 1 if /^ modem auto/;
	/^ speed / && $lineauto	&& next; # kill speed on serial lines
	/^ clockrate /		&& next; # kill clockrate on serial interfaces
	if (/^(enable )?(password|passwd)( level \w+)? encrypted ((.)\S+)/) {
	    if ($filter_pwds >= 2) {
		ProcessHistory("USER","keysort","$1",
			       "!$1$2$3 encrypted \n");
	    } elsif ($filter_pwds >= 1 && $5 ne "\$") {
		ProcessHistory("USER","keysort","$1",
			        "!$1$2$3 encrypted \n");
	    } else {
		ProcessHistory("USER","keysort","$1","$_");
	    }
	    next;
	}

	if ((/^(enable )?(password|passwd)( level \w+)? encrypted [^\$]/ &&
	    $filter_pwds >= 1) ||
	    (/^(enable )?(password|passwd)( level \w+)? encrypted [^\$]/ &&
	    $filter_pwds >= 2)) {
	    ProcessHistory("ENABLE","","","!$1$2$3 \n");
	    next;
	}
	if (/^username (\S+)(\s.*)? encrypted ((.)\S+)/) {
	    if ($filter_pwds >= 2) {
		ProcessHistory("USER","keysort","$1",
			       "!username $1$2 encrypted \n");
	    } elsif ($filter_pwds >= 1 && $4 ne "\$") {
		ProcessHistory("USER","keysort","$1",
			       "!username $1$2 encrypted \n");
	    } else {
		ProcessHistory("USER","keysort","$1","$_");
	    }
	    next;
	}
	if (/^(\s*)password / && $filter_pwds >= 1) {
	    ProcessHistory("LINE-PASS","","","!$1password \n");
	    next;
	}
	if (/^(\s*)secret / && $filter_pwds >= 2) {
	    ProcessHistory("LINE-PASS","","","!$1secret \n");
	    next;
	}
	# filter out any RCS/CVS tags to avoid confusing local CVS storage
	s/\$(Revision|Id):/ $1:/;
	# order arp lists
	/^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ &&
	    ProcessHistory("ARP","$aclsort","$1","$_") && next;

	# order logging statements
	/^logging host (\d+\.\d+\.\d+\.\d+)/ &&
	    ProcessHistory("LOGGING","ipsort","$1","$_") && next;
	# order/prune snmp-server host statements
	# we only prune lines of the form
	# snmp-server host a.b.c.d 
	if (/^snmp-server trap-dest (\d+\.\d+\.\d+\.\d+) /) {
	    if ($filter_commstr) {
		my($ip) = $1;
		my($line) = "snmp-server host $ip";
		my(@tokens) = split(' ', $');
		my($token);
		while ($token = shift(@tokens)) {
		    if ($token eq 'version') {
			$line .= " " . join(' ', ($token, shift(@tokens)));
			if ($token eq '3') {
			    $line .= " " . join(' ', ($token, shift(@tokens)));
			}
		    } elsif ($token eq 'vrf') {
			$line .= " " . join(' ', ($token, shift(@tokens)));
		    } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) {
			$line .= " " . $token;
		    } else {
			$line = "!$line " . join(' ', ("", join(' ',@tokens)));
			last;
		    }
		}
		ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n");
	    } else {
		ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_");
	    }
	    next;
	}
	if (/^(snmp community) (\S+)/) {
	    if ($filter_commstr) {
		ProcessHistory("SNMPSERVERCOMM","keysort","$_","!$1 $'") && next;
	    } else {
		ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next;
	    }
	}
	# prune tacacs/radius server keys
	if (/^((tacacs-server|radius-server)\s(\w*[-\s(\s\S+])*\s?key) \d \w+/
							&& $filter_pwds >= 1) {
	    ProcessHistory("","","","!$1 $'"); next;
	}

	# delete ntp auth password - this md5 is a reversable too
	if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) {
	    ProcessHistory("","","","!$1 \n"); next;
	}
	# order ntp peers/servers
	if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) {
	    $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5);
	    ProcessHistory("NTP","keysort",$sortkey,"$_");
	    next;
	}

	# catch anything that wasnt matched above.
	ProcessHistory("","","","$_");
	# end of config.  the ": " game is for the PIX
	if (/^(: +)?end$/) {
	    $found_end = 1;
	    return(1);
	}
    }
    # The AGM lacks a definitive "end of config" marker.  If we have seen at
    # least 5 lines of write term o/p, we can be reasonably sure that we got
    # the config.
    if ($linecnt > 5) {
	$found_end = 1;
	return(1);
    }

    return(0);
}

# Main
@commandtable = (
	{'show version'			=> 'ShowVersion'},
	{'show diagnostic-info'		=> 'ShowDiag'},
	{'show running-config'		=> '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);
$commandcnt = scalar(keys %commands);

$commandstr=join(";",@commands);
$cmds_regexp = join("|", map quotemeta($_), @commands);

if (length($host) == 0) {
    if ($file) {
	print(STDERR "Too few arguments: file name required\n");
	exit(1);
    } else {
	print(STDERR "Too few arguments: host name required\n");
	exit(1);
    }
}
if ($opt_C) {
    print "hlogin -t $timeo -c\'$commandstr\' $host\n";
    exit(0);
}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
if ($debug) { $| = 1; }

if ($file) {
    print(STDERR "opening file $host\n") if ($debug || $log);
    open(INPUT,"<$host") || die "open failed for $host: $!\n";
} else {
    print(STDERR "executing hlogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log);
    system "hlogin -t $timeo -c \"$commandstr\" $host  $host.raw 2>&1" || die "hlogin failed for $host: $!\n";
    open(INPUT, "< $host.raw") || die "hlogin failed for $host: $!\n";
}

# 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 oscillating data filtering mode
if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) {
    $filter_osc = 0;
} else {
    $filter_osc = 1;
}
# determine password filtering mode
if ($ENV{"FILTER_PWDS"} =~ /no/i) {
    $filter_pwds = 0;
} elsif ($ENV{"FILTER_PWDS"} =~ /all/i) {
    $filter_pwds = 2;
} else {
    $filter_pwds = 1;
}

ProcessHistory("","","","!RANCID-CONTENT-TYPE: AGM\n!\n");
ProcessHistory("COMMENTS","keysort","B0","!\n");
ProcessHistory("COMMENTS","keysort","C0","!\n");
TOP: while() {
    tr/\015//d;
    if (/[>#]\s?exit$/) {
	$clean_run=1;
	last;
    }
    if (/^Error:/) {
	print STDOUT ("$host clogin error: $_");
	print STDERR ("$host clogin error: $_") if ($debug);
	$clean_run=0;
	last;
    }
    while (/#\s*($cmds_regexp)\s*$/) {
	$cmd = $1;
	if (!defined($prompt)) {
	    $prompt = ($_ =~ /^([^#]+#)/)[0];
	    $prompt =~ s/([][}{)(\\])/\\$1/g;
	    print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);
	}
	print STDERR ("HIT COMMAND:$_") if ($debug);
	if (! defined($commands{$cmd})) {
	    print STDERR "$host: found unexpected command - \"$cmd\"\n";
	    $clean_run = 0;
	    last TOP;
	}
	$rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd);
	delete($commands{$cmd});
	if ($rval == -1) {
	    $clean_run = 0;
	    last TOP;
	}
	if (/[>#]\s?exit$/) {
	    $clean_run=1;
	    last;
	}
    }
}
print STDOUT "Done $logincmd: $_\n" if ($log);
# Flush History
ProcessHistory("","","","");
# Cleanup
close(INPUT);
close(OUTPUT);

unlink("$host.raw") if (! $debug);

# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
    if (scalar(keys %commands) eq $commandcnt) {
	printf(STDERR "$host: missed cmd(s): all commands\n");
    } elsif (scalar(%commands)) {
	my($count, $i) = 0;
	for ($i = 0; $i < $#commands; $i++) {
	    if ($commands{$commands[$i]}) {
		if (!$count) {
		    printf(STDERR "$host: missed cmd(s): %s", $commands[$i]);
		} else {
		    printf(STDERR ", %s", $commands[$i]);
		}
		$count++;
	    }
	}
	if ($count) {
	    printf(STDERR "\n");
	}
    }
    if (!$clean_run || !$found_end) {
	print(STDERR "$host: End of run not found\n");
	if ($debug) {
	    print(STDERR "$host: clean_run is false\n") if (!$clean_run);
	    print(STDERR "$host: found_end is false\n") if (!$found_end);
	}
	system("/usr/bin/tail -1 $host.new");
    }
    unlink "$host.new" if (! $debug);
}
rancid-3.13/bin/nlogin.in000644 015615 000000 00000041635 13657102757 015372 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## @PACKAGE@ @VERSION@
@copyright@
#
# Netscreen hacks implemented by Stephen Gill .
#
# nlogin - netscreen login
#
# Most options are intuitive for logging into a netscreen firewall.
#
# Misc notes
#	netscreen does not have the concept of "enable", once logged in, a
#	users permissions can not change.

# XXX need to import login_top.

# Usage line
set usage "Usage: $argv0 \[-diSV\] \[-c command\] \[-Evar=x\] \
\[-f cloginrc-file\] \[-p user-password\] \
\[-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

# Password file
set password_file $env(HOME)/.cloginrc
# Default is to login to the firewall
set do_command 0
set do_interact 0
set do_script 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
set do_enapasswd 1
# Save config, if prompted
set do_saveconfig 0
# cloginrc debugging knob
set do_cloginrcdbg 0
# Sometimes firewall take awhile to answer (the default is 10 sec)
set timeoutdflt 45
# intialize cloginrc parsing stacks
set int_file {}
set int_lineno {}
# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

# Find the user in the ENV, or use the unix userid.
if {[info exists env(CISCO_USER)]} {
    set default_user $env(CISCO_USER)
} elseif {[info exists env(USER)]} {
    set default_user $env(USER)
} elseif {[info exists env(LOGNAME)]} {
    set default_user $env(LOGNAME)
} 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.
    if [catch {exec id} reason] {
	send_error "\nError: could not exec id: $reason\n"
	exit 1
    }
    regexp {\(([^)]*)} "$reason" junk default_user
}
if {[info exists env(CLOGINRC)]} {
    set password_file $env(CLOGINRC)
}

# Process the command line
for {set i 0} {$i < $argc} {incr i} {
    set arg [lindex $argv $i]

    switch  -glob -- $arg {
	# Expect debug mode
	-d* {
	    exp_internal 1
	# Username
	} -u* {
	    if {! [regexp .\[uU\](.+) $arg ignore user] } {
		incr i
		set username [lindex $argv $i]
	    }
	# cloginrc debugging knobs
	} -m* {
	    set do_cloginrcdbg 1
	} -M* {
	    set do_cloginrcdbg 2
	# interactive
	} -i* {
	    set do_interact 1
	# VTY Password
	} -p* {
	    if {! [regexp .\[pP\](.+) $arg ignore userpasswd]} {
		incr i
		set userpasswd [lindex $argv $i]
	    }
	    set do_passwd 0
	# ssh passphrase
	} -r* {
	    # ignore -r
	# Environment variable to pass to -s scripts
	} -E* {
	    if {[regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} {
		set E$varname $varvalue
	    } else {
		send_user "\nError: invalid format for -E in $arg\n"
		exit 1
	    }
	# Command to run.
	} -c* {
	    if {! [regexp .\[cC\](.+) $arg ignore command]} {
		incr i
		set command [lindex $argv $i]
	    }
	    set do_command 1
	# Expect script to run.
	} -s* {
	    if {! [regexp .\[sS\](.+) $arg ignore sfile]} {
		incr i
		set sfile [lindex $argv $i]
	    }
	    if { ! [file readable $sfile] } {
		send_user "\nError: Can't read $sfile\n"
		exit 1
	    }
	    set do_script 1
	# 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* {
	    if {! [regexp .\[fF\](.+) $arg ignore password_file]} {
		incr i
		set password_file [lindex $argv $i]
	    }
	# Timeout
	} -t* {
	    incr i
	    set timeoutdflt [lindex $argv $i]
	# Command file
	} -x* {
	    if {! [regexp .\[xX\](.+) $arg ignore cmd_file]} {
		incr i
		set cmd_file [lindex $argv $i]
	    }
	    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
	# Version string
	} -V* {
	    send_user "@PACKAGE@ @VERSION@\n"
	    exit 0
	# Does tacacs automatically enable us?
	} -autoenable {
	    # ignore autoenable
	} -* {
	    send_user "\nError: Unknown argument! $arg\n"
	    send_user $usage
	    exit 1
	} default {
	    break
	}
    }
}
# Process firewalls...no firewalls listed is an error.
if { $i == $argc } {
    send_user "\nError: $usage"
}

# Only be quiet if we are running a script (it can log its output
# on its own)
if { $do_script } {
    log_user 0
} else {
    log_user 1
}

#
# Done configuration/variable setting.  Now run with it...
#

# 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 }
    }
    # take host from ENV(TERM)
    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"
	}
    }
}

# This is a helper function to make the password file easier to
# maintain.  Using this the password file has the form:
# add password sl*	pete cow
# add password at*	steve
# add password *	hanky-pie
proc add {var args} {
    global int_file int_lineno int_$var
    set file [lindex $int_file 0]
    set lineno [lindex $int_lineno 0]
    lappend int_$var "$var:$file:$lineno: $args"
}
proc include {args} {
    global env
    regsub -all "(^{|}$)" $args {} args
    if {[regexp "^/" $args ignore] == 0} {
	set args $env(HOME)/$args
    }
    source_password_file $args
}

proc find {var router} {
    global do_cloginrcdbg
    upvar int_$var list
    if {[info exists list]} {
	foreach line $list {
	    if {[string match -nocase [lindex $line 1] $router]} {
		if {$do_cloginrcdbg > 0} {
		    send_error -- [join [list [lindex $line 0] [lrange $line 1 end] "\r\n"]]
		}
		if {$do_cloginrcdbg == 2} {
		    # save return value
		    if {! [info exists result]} {
			set result [lrange $line 2 end]
		    }
		} else {
		    return [lrange $line 2 end]
		}
	    }
	}
    }

    if {$do_cloginrcdbg == 2} {
	if {[info exists result]} {
	    return $result
	}
    }
    return {}
}

# Loads the password file.  Note that as this file is tcl, and that
# it is sourced, the user better know what to put in there, as it
# could install more than just password info...  I will assume however,
# 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 {file} {
    global env int_file int_lineno
    if {! [file exists $file]} {
	send_user "\nError: password file ($file) does not exist\n"
	exit 1
    }
    file stat $file fileinfo
    if {[expr ($fileinfo(mode) & 007)] != 0000} {
	send_user "\nError: $file must not be world readable/writable\n"
	exit 1
    }
    if [catch {set fd [open $file "r"]} reason] {
	send_user "\nError: $reason\n"
	exit 1
    }
    set int_file [linsert $int_file 0 $file]
    set int_lineno [linsert $int_lineno 0 0]
    while {[gets $fd line] >= 0} {
	set tmp [lindex $int_lineno 0]; incr tmp
	lset int_lineno 0 $tmp
	eval $line
    }
    set int_file [lrange $int_file 1 end]
    set int_lineno [lrange $int_lineno 1 end]
    close $fd
}

# Log into the firewall.
# returns: 0 on success, 1 on failure
proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } {
    global command spawn_id in_proc do_command do_script passphrase
    global prompt prompt_match u_prompt p_prompt sshcmd telnetcmd
    set in_proc 1
    set uprompt_seen 0

    # try each of the connection methods in $cmethod until one is successful
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port
	    if {"$port" == ""} {
		set retval [catch {eval spawn [split "$telnetcmd $router"]} reason]
	    } else {
		set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason]
	    }
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif [string match "ssh*" $prog] {
	    # ssh to the router & try to login with or without an identfile.
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    if {"$identfile" != ""} {
		set cmd "$cmd -i $identfile"
	    }
	    set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	} elseif ![string compare $prog "rsh"] {
	    send_error "\nError: unsupported method: rsh\n"
	    if { $progs == 0 } {
		return 1
	    }
	    continue;
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}

    sleep 0.3

    # This helps cleanup each expect clause.
    expect_after {
	timeout {
	    global in_proc
	    send_user "\nError: TIMEOUT reached\n"
	    catch {close}; catch {wait};
	    if {$in_proc} {
		return 1
	    } else {
		continue
	    }
	} eof {
	    global in_proc
	    send_user "\nError: EOF received\n"
	    catch {close}; catch {wait};
	    if {$in_proc} {
		return 1
	    } else {
		continue
	    }
	}
    }

    # Here we get a little tricky.  There are several possibilities:
    # the firewall can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the firewall might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-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
	}
	"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)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-nocase -re "^warning: remote host denied authentication agent forwarding." {
	    exp_continue;
	}
	-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"
					  set uprompt_seen 1
					  exp_continue
					}
	-re "@\[^\r\n]+\[Pp]assword:"	{
					  # ssh pwd prompt
					  sleep 1
					  send -- "$userpswd\r"
					  exp_continue
					}
	"\[Pp]assword:"			{
					  sleep 1;
					  if {$uprompt_seen == 1} {
						send -- "$userpswd\r"
					  } else {
						send -- "$passwd\r"
					  }
					  exp_continue
					}
	-- "$prompt"			{ break; }
     }
    }

    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact in_proc
    set in_proc 1

    send "set console page 0\r"
    expect -re $prompt {}

    # this is the only way i see to get rid of more prompts in o/p..grrrrr
    log_user 0

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
	    -re "\[\n\r]+"			{ send_user -- "$expect_out(buffer)"
						  exp_continue
						}
	    -re "$prompt"			{ send_user -- "$expect_out(buffer)" }
	    -re "\[Aa]ccept this agreement y/.n."  {
						  sleep 1
						  send -- "y\r"
						  exp_continue
						}
	    -gl "--- more ---"			{ send " "
						  exp_continue
						}
	}
    }
    log_user 1

    if { $do_interact == 1 } {
	interact
	return 0
    }

    send "exit\r"
    expect {
	-re "$prompt"				{
						  send "exit\r"
						  exp_continue
						}
	-re "\[\n\r]+"				{ exp_continue }
	-gl "Configuration modified, save?"	{
						  send "n\r"
						  exp_continue
						}
	timeout					{ catch {close}; catch {wait};
						  return 0
						}
	eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each firewall... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user -- "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    set prompt {-> }

    # Figure out passwords
    if { $do_passwd || $do_enapasswd } {
	set pswd [find password $router]
	if { [llength $pswd] == 0 } {
	    send_user -- "\nError: no password for $router in $password_file.\n"
	    continue
	}
	if { $do_passwd } {
	    set passwd [join [lindex $pswd 0] ""]
	} else {
	    set passwd $userpasswd
	}
	if { $do_enapasswd } {
	    set enapasswd [join [lindex $pswd 1] ""]
	} else {
	    set enapasswd $enapasswd
	}
    } else {
	set passwd $userpasswd
	set enapasswd $enapasswd
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } else {
      set userpswd [join [find userpassword $router] ""]
      if { "$userpswd" == "" } { set userpswd $passwd }
    }

    # Figure out identity file to use
    set identfile [join [lindex [find identity $router] 0] ""]

    # Figure out cypher type
    if {[info exists cypher]} {
	# command line cypher type
	set cyphertype $cypher
    } else {
	set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} {
	incr exitval
	# if login failed, move on to the next device
	continue
    }

    # we are logged in, now figure out the full prompt
    send "\r"
    expect {
	-re "\[\r\n]+"		{ exp_continue; }
	-re "^(.+$prompt)"	{ set junk $expect_out(0,string);
				  # if it has HA (high avail), the prompt will
				  # be "something-(.)->"
				  regsub -all "\[\]\)\(\[]" $junk {\\&} prompt;
				}
    }

    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	send "set console page 0\r"
	expect -re $prompt	{}
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each firewall
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/dllogin.in000644 015615 000000 00000024431 13657102757 015527 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## patched to accomplish fortinet from nlogin
## in turn patched to accomplish D-Link from fnlogin
## by: Daniel G. Epstein 
## adapted by: Diego Ercolani 
## adapted by: Gavin McCullagh 
##             Griffith College Dublin
##
## @PACKAGE@ @VERSION@
@copyright@
#
# Netscreen hacks implemented by Stephen Gill .
# Fortinet hacks by Daniel G. Epstein 
# D-Link hacks by Gavin McCullagh 
#
# dllogin - D-Link login
#
# Most options are hopefully intuitive for logging into a D-Link switch
#
# Misc notes
#	netscreen does not have the concept of "enable", once logged in, a
#	users permissions can not change.

# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

@login_top@

# Log into the firewall.
# returns: 0 on success, 1 on failure
proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype identfile } {
    global spawn_id in_proc do_command do_script sshcmd telnetcmd
    set in_proc 1
    set uprompt_seen 0

    # Telnet to the firewall & try to login.
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog command suffix port
	    if {"$port" == ""} {
		set retval [ catch {eval spawn [split "$telnetcmd $router"]} reason ]
	    } else {
		set retval [ catch {eval spawn [split "$telnetcmd $router $port"]} reason ]
	    }
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif [string match "ssh*" $prog] {
	    # ssh to the router & try to login with or without an identfile.
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    if {"$identfile" != ""} {
		set cmd "$cmd -i $identfile"
	    }
	    set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	 } elseif ![string compare $prog "rsh"] {
	    send_error "\nError: unsupported method: rsh\n"
	    if { $progs == 0 } {
		return 1
	    }
	    continue;
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}

    sleep 0.3

    # This helps cleanup each expect clause.
    expect_after {
	timeout {
	    global in_proc
	    send_user "\nError: TIMEOUT reached\n"
	    catch {close}; catch {wait};
	    if {$in_proc} {
	        return 1
	    } else {
	        continue
	    }
        } eof {
	    global in_proc
	    send_user "\nError: EOF received\n"
	    catch {close}; catch {wait};
	    if {$in_proc} {
	        return 1
	    } else {
	        continue
	    }
        }
    }

    # Here we get a little tricky.  There are several possibilities:
    # the firewall can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the firewall might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-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
	}
	"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)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-nocase -re "^warning: remote host denied authentication agent forwarding." {
	    exp_continue;
	}
	-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 "\[Uu]ser\[nN]ame:"		{
					  send -h -- "$user\r"
					  set uprompt_seen 1
					  exp_continue
					}
	-re "@\[^\r\n]+\[Pp]assword:"	{
					  # ssh pwd prompt
					  send -h -- "$userpswd\r"
					  exp_continue
					}
	"\[Pp]ass\[Ww]ord:"		{
					  if {$uprompt_seen == 1} {
						send -h -- "$userpswd\r"
					  } else {
						send -h -- "$passwd\r"
					  }
					  exp_continue
					}
	-- "$prompt"			{ break; }
     }
    }
    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact in_proc
    set in_proc 1

    # Disable output paging.
    send -- "disable clipaging\r"
    expect -re $prompt;

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
            -re "$prompt"			{ send -h "\r" }
	    -re "All "				{ send "a"
						  exp_continue
	    -re "\[\n\r]+"			{ exp_continue }
						}
	}
    }

    if { $do_interact == 1 } {
	interact
	return 0
    }

    expect {
	  -re "$prompt$"			{
						  send -h "logout\r"
						  exp_continue
						}
	  -re "\[\n\r]+"			{ exp_continue }
	  -gl "Configuration modified, save?"	{
						  send "n\r"
						  exp_continue
						}
	  timeout				{ catch {close}; catch {wait};
						  return 0
						}
	  eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each firewall... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # FortiOS 2.x prompts can end in either '#' or '$'
    set prompt "\[#\\$]"

    # Figure out passwords
    if { $do_passwd || $do_enapasswd } {
	set pswd [find password $router]
	if { [llength $pswd] == 0 } {
	    send_user -- "\nError: no password for $router in $password_file.\n"
	    continue
	}
	if { $do_passwd } {
	    set passwd [join [lindex $pswd 0] ""]
	} else {
	    set passwd $userpasswd
	}
	if { $do_enapasswd } {
	    set enapasswd [join [lindex $pswd 1] ""]
	} else {
	    set enapasswd $enapasswd
	}
    } else {
	set passwd $userpasswd
	set enapasswd $enapasswd
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } else {
      set userpswd [join [find userpassword $router] ""]
      if { "$userpswd" == "" } { set userpswd $passwd }
    }

    # Figure out identity file to use
    set identfile [join [lindex [find identity $router] 0] ""]

    # Figure out cypher type
    if {[info exists cypher]} {
      # command line cypher type
      set cyphertype $cypher
    } else {
      set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [find sshcmd $router]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $enapasswd $prompt $cmethod $cyphertype $identfile]} {
	incr exitval
	continue
    }

    # we are logged in, now figure out the full prompt based on what the device sends us.
    send "\r"
    expect {
	-re "\[\r\n]+"		{ exp_continue; }
	-re "^(.+$prompt)"	{ set junk $expect_out(0,string); }
	if {[$junk = "(^\\$ $)"]} {
	  set prompt $junk;
	} else {
	  if {[$junk = "(^# $)"]} { set prompt $junk ; }
	};
    }

    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	# Disable output paging.
	send "config system console\r"
	send "set output standard\r"
	send "end\r"
	expect -re $prompt	{}
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each firewall
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/a10login.in000644 015615 000000 00000034500 13713052202 015465 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## @PACKAGE@ @VERSION@
@copyright@
#
# a10login - A10 login
#

# Sometimes routers take awhile to answer (the default is 10 sec)
set timeoutdflt 45
# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

@login_top@

# Log into the router.
# returns: 0 on success, 1 on failure, -1 if rsh was used successfully
proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } {
    global spawn_id in_proc passphrase
    global prompt prompt_match u_prompt p_prompt sshcmd telnetcmd
    set in_proc 1
    set uprompt_seen 0

    # try each of the connection methods in $cmethod until one is successful
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port
	    if {"$port" == ""} {
		set retval [catch {eval spawn [split "$telnetcmd $router"]} reason]
	    } else {
		set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason]
	    }
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif [string match "ssh*" $prog] {
	    # ssh to the router & try to login with or without an identfile.
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    if {"$identfile" != ""} {
		set cmd "$cmd -i $identfile"
	    }
	    set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}
	sleep 0.3

	# This helps cleanup each expect clause.
	expect_after {
	    timeout {
		global in_proc
		send_user "\nError: TIMEOUT reached\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    } eof {
		global in_proc
		send_user "\nError: EOF received\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    }
	}

    # Here we get a little tricky.  There are several possibilities:
    # the router can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the router might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-re "^<-+ More -+>\[^\n\r]*" {
	    # ASA will use the pager for long banners
	    send " ";
	    exp_continue
	}
	-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
	}
	"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)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-nocase -re "^warning: remote host denied authentication agent forwarding." {
	    exp_continue;
	}
	-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 "% (Bad passwords|Authentication failed)"	{
				  send_user "\nError: Check your passwd for $router\n"
				  catch {close}; catch {wait}; return 1
				}
	"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"
				  exp_continue
				}
	-re "Last login:"	{
				  exp_continue
				}
	-re "@\[^\r\n]+ $p_prompt"	{
				  # ssh pwd prompt
				  sleep 1
				  send -- "$userpswd\r"
				  exp_continue
				}
	-re "Enter passphrase.*: " {
				  # sleep briefly to allow time for stty -echo
				  sleep .3
				  send -- "$passphrase\r"
				  exp_continue
				}
	-re "$u_prompt"		{
				  send -- "$user\r"
				  set uprompt_seen 1
				  exp_continue
				}
	-re "$p_prompt"		{
				  sleep 1
				  if {$uprompt_seen == 1} {
					send -- "$userpswd\r"
				  } else {
					send -- "$passwd\r"
				  }
				  exp_continue
				}
	-re "$prompt"		{
				  set prompt_match $expect_out(0,string);
				  break;
				}
	"Login invalid"		{
				  send_user "\nError: Invalid login: $router\n";
				  catch {close}; catch {wait}; return 1
				}
	-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
     }
    }

    set in_proc 0
    return 0
}

# Enable
proc do_enable { enauser enapasswd } {
    global in_proc
    global prompt u_prompt e_prompt enacmd
    set in_proc 1

    send "$enacmd\r"
    expect {
	-re "$u_prompt"	{ send -- "$enauser\r"; exp_continue}
	-re "$e_prompt"	{ send -- "$enapasswd\r"; exp_continue}
	"#"		{ set prompt "#" }
	"(enable)"	{ set prompt "> \\(enable\\) " }
	"% Invalid input" {
			  send_user "\nError: Unrecognized command, check your enable command\n";
			  return 1
			}
	-re "(denied|Sorry|Incorrect)"	{
			  # % Access denied - from local auth and poss. others
			  send_user "\nError: Check your Enable passwd\n";
			  return 1
			}
	"% Error in authentication" {
			  send_user "\nError: Check your Enable passwd\n"
			  return 1
			}
	"% Bad passwords" {
			  send_user "\nError: Check your Enable passwd\n"
			  return 1
			}
    }
    # We set the prompt variable (above) so script files don't need
    # to know what it is.
    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact in_proc
    set in_proc 1

    # match cisco config mode prompts too, such as router(config-if)#,
    # but catalyst does not change in this fashion.
    regsub -all {^(.*)([#>])$} $prompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt

    # this is the only way i see to get rid of more prompts in o/p..grrrrr
    log_user 0

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    # the pager can not be turned off on the PIX, so we have to look
    # for the "More" prompt.  the extreme is equally obnoxious in pre-12.3 XOS,
    # with a global switch in the config.
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
	    -re "\b+"			{ exp_continue }
	    -re "^\[^\n\r *]*$reprompt"	{ send_user -- "$expect_out(buffer)" }
	    -re "^\[^\n\r]*$reprompt."	{
					  send_user -- "$expect_out(buffer)"
					  exp_continue
					}
	    -re "\[^\r\n]*\[\n\r]+"	{
					  send_user -- "$expect_out(buffer)"
					  exp_continue
					}
	}
    }
    log_user 1

    if { $do_interact == 1 } {
	interact
	return 0
    }

    # quit works too
    send -h "exit\r"
    expect {
	-re "^\[^\n\r *]*$reprompt"		{
						  # if in enable mode, quit
						  # returns to non-enabled mode
						  send -h "exit\r"
						  exp_continue;
						}
	-re "Are you sure .*to quit"		{
						  catch {send "y\r"}
						  exp_continue
						}
	-re "\[\n\r]+"				{ exp_continue }
	timeout					{ catch {close}; catch {wait};
						  return 0
						}
	eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each router... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
set prompt_match ""
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user -- "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # Default prompt.
    set prompt [join [find prompt $router] ""]
    if { [llength $prompt] == 0 } {
	set prompt "(>|#)"
    }

    # look for autoenable option in .cloginrc & cmd-line
    set ae [find autoenable $router]
    if { "$ae" == "1" || $avautoenable } {
	set autoenable 1
    } else {
	set autoenable 0
    }
    # look for enable options in .cloginrc & cmd-line
    if { $avenable == 0 } {
	set enable 0
    } else {
	set ne [find noenable $router]
	if { "$ne" == "1" || "$autoenable" == "1" } {
	    set enable 0
	} else {
	    set enable 1
	}
    }

    # Figure out passwords
    if { $do_passwd || $do_enapasswd } {
	set pswd [find password $router]
	if { [llength $pswd] == 0 } {
	    send_user -- "\nError: no password for $router in $password_file.\n"
	    continue
	}
	if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } {
	    send_user -- "\nError: no enable password for $router in $password_file.\n"
	    continue
	}
	if { $do_passwd } {
	    set passwd [join [lindex $pswd 0] ""]
	} else {
	    set passwd $userpasswd
	}
	if { $do_enapasswd } {
	    set enapasswd [join [lindex $pswd 1] ""]
	} else {
	    set enapasswd $enapasswd
	}
    } else {
	set passwd $userpasswd
	set enapasswd $enapasswd
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } 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 $ruser }
    }

    # Figure out enable command
    set enacmd [join [find enablecmd $router] ""]
    if { "$enacmd" == "" } { set enacmd "enable" }

    # Figure out prompts
    set u_prompt [find userprompt $router]
    if { "$u_prompt" == "" } {
	set u_prompt "(\[Uu]sername|Login|login|user name|User):"
    } else {
	set u_prompt [join [lindex $u_prompt 0] ""]
    }
    set p_prompt [find passprompt $router]
    if { "$p_prompt" == "" } {
	set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+):"
    } else {
	set p_prompt [join [lindex $p_prompt 0] ""]
    }
    set e_prompt [find enableprompt $router]
    if { "$e_prompt" == "" } {
	set e_prompt "\[Pp]assword:"
    } else {
	set e_prompt [join [lindex $e_prompt 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 cypher type
    if {[info exists cypher]} {
	# command line cypher type
	set cyphertype $cypher
    } else {
	set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} {
	incr exitval
	# if login failed or rsh was unsuccessful, move on to the next device
	continue
    }
    # Figure out the prompt.
    if { [regexp -- "#" $prompt_match junk] == 1 } {
	set enable 0
    }
    if { $enable } {
	if {[do_enable $enauser $enapasswd]} {
	    if { $do_command || $do_script } {
		incr exitval
		catch {close}; catch {wait};
		continue
	    }
	}
    }
    # we are logged in, now figure out the full prompt
    send "\r"
    regsub -all {^(\^*)(.*)} $prompt {\2} reprompt
    expect {
	-re "\[\r\n]+"		{ exp_continue; }
	-re "^.+$reprompt"	{ set junk $expect_out(0,string);
				  regsub -all "\[\]\[\(\)+]" $junk {\\&} prompt;
				}
    }
    if { $do_command || $do_script } {
	send "terminal length 0\r"
	expect -re $prompt	{}
	send "terminal width 0\r"
	expect -re $prompt	{}
    }
    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each router
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/noklogin.in000644 015615 000000 00000037612 13657102757 015724 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## @PACKAGE@ @VERSION@
@copyright@
#
# noklogin - Nokia (Alcatel-Lucent) SR OS login
#
# Most options are intuitive for logging into a Cisco router.
# The default username password is the same as the vty password.
#

# Sometimes routers take awhile to answer (the default is 10 sec)
set timeoutdflt 45
# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

@login_top@

# Log into the router.
# returns: 0 on success, 1 on failure, -1 if rsh was used successfully
proc login { router user userpswd passwd cmethod cyphertype identfile } {
    global command spawn_id in_proc do_command do_script passphrase
    global prompt prompt_match u_prompt p_prompt e_prompt sshcmd telnetcmd
    global spawnopts
    set in_proc 1
    set uprompt_seen 0

    # try each of the connection methods in $cmethod until one is successful
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port
	    if {"$port" == ""} {
		set retval [catch {eval spawn $spawnopts [split "$telnetcmd $router"]} reason]
	    } else {
		set retval [catch {eval spawn $spawnopts [split "$telnetcmd $router $port"]} reason]
	    }
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif [string match "ssh*" $prog] {
	    # ssh to the router & try to login with or without an identfile.
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    if {"$identfile" != ""} {
		set cmd "$cmd -i $identfile"
	    }
	    set retval [catch {eval spawn $spawnopts [split "$cmd -x -l $user $router" { }]} reason]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	} elseif ![string compare $prog "rsh"] {
	    if { ! $do_command } {
		if { [llength $cmethod] == 1 } {
		    send_user "\nError: rsh is an invalid method for -x and "
		    send_user "interactive logins\n"
		}
		if { $progs == 0 } {
		    return 1
		}
		continue;
	    }

	    # handle escaped ;s in commands, and ;; and ^;
	    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
	    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
	    regsub {^;} $command "\u0002;" esccommand
	    regsub -all {[\\];} $esccommand ";" command
	    regsub -all {\u0002;} $command "\u0002" esccommand
	    set sep "\u0002"
	    set commands [split $esccommand $sep]
	    set num_commands [llength $commands]
	    set rshfail 0
	    for {set i 0} {$i < $num_commands && !$rshfail} { incr i} {
		log_user 0
		set retval [catch {spawn rsh $user@$router [lindex $commands $i] } reason]
		if { $retval } {
		    send_user "\nError: rsh failed: $reason\n"
		    log_user 1; return 1
		}
		send_user "$router# [lindex $commands $i]\n"

		# rcmd does not get a pager and no prompts, so we just have to
		# look for failures & lines.
		expect {
		  "Connection refused"	{ catch {close}; catch {wait};
					  send_user "\nError: Connection\
						    Refused ($prog): $router\n"
					  set rshfail 1
					}
		  -re "(Connection closed by|Connection to \[^\n\r]+ closed)" {
					  catch {close}; catch {wait};
					  send_user "\nError: Connection\
						    closed ($prog): $router\n"
					  set rshfail 1
					}
		  "Host is unreachable"	{ catch {close}; catch {wait};
					  send_user "\nError: Host Unreachable:\
						    $router\n"
					  set rshfail 1
					}
		  "No address associated with" {
					  catch {close}; catch {wait};
					  send_user "\nError: Unknown host\
						    $router\n"
					  set rshfail 1
					}
		  -re "\b+"		{ exp_continue }
		  -re "\[\n\r]+"	{ send_user -- "$expect_out(buffer)"
					  exp_continue
					}
		  timeout		{ catch {close}; catch {wait};
					  send_user "\nError: TIMEOUT reached\n"
					  set rshfail 1
					}
		  eof			{ catch {close}; catch {wait}; }
		}
		log_user 1
	    }
	    if { $rshfail } {
		if { !$progs } {
		    return 1
		} else {
		    continue
		}
	    }
	    # fake the end of the session for rancid.
	    send_user "$router# logout\n"
	    # return rsh "success"
	    return -1
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}
	sleep 0.3

	# This helps cleanup each expect clause.
	expect_after {
	    timeout {
		global in_proc
		send_user "\nError: TIMEOUT reached\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    } eof {
		global in_proc
		send_user "\nError: EOF received\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    }
	}

    # Here we get a little tricky.  There are several possibilities:
    # the router can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the router might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-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
	}
	"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)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-nocase -re "^warning: remote host denied authentication agent forwarding." {
	    exp_continue;
	}
	-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 "% (Bad passwords|Authentication failed)"	{
				  send_user "\nError: Check your passwd for $router\n"
				  catch {close}; catch {wait}; return 1
				}
	-re "Last login:"	{
				  exp_continue
				}
	-re "Press the  key \[^\r\n]+\[\r\n]+"	{
				  exp_continue
				}
	-re "@\[^\r\n]+ $p_prompt"	{
				  # ssh pwd prompt
				  sleep 1
				  send -- "$userpswd\r"
				  exp_continue
				}
	-re "Enter passphrase.*: " {
				  # sleep briefly to allow time for stty -echo
				  sleep .3
				  send -- "$passphrase\r"
				  exp_continue
				}
	-re "$u_prompt"		{
				  send -- "$user\r"
				  set uprompt_seen 1
				  exp_continue
				}
	-re "$p_prompt"		{
				  sleep 1
				  if {$uprompt_seen == 1} {
					send -- "$userpswd\r"
				  } else {
					send -- "$passwd\r"
				  }
				  exp_continue
				}
	-re "$prompt"		{
				  set prompt_match $expect_out(0,string);
				  break;
				}
	"Login invalid"		{
				  send_user "\nError: Invalid login: $router\n";
				  catch {close}; catch {wait}; return 1
				}
	-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
     }
    }

    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact do_saveconfig in_proc
    set in_proc 1

    # match sros config mode prompts too, such as A:name>mode>mode#
    # or *A:name>...#.
    regsub -all -- {#$} $prompt {[^\r\n# ]*#} reprompt

    # this is the only way i see to get rid of more prompts in o/p..grrrrr
    log_user 0

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
	    -re "^\[^\n\r *]*$reprompt"		{ send_user -- "$expect_out(buffer)"
						}
	    -re "^\[^\n\r]*$reprompt."		{ send_user -- "$expect_out(buffer)"
						}
	    -re "\[^\r\n]*\[\n\r]+"		{ send_user -- "$expect_out(buffer)"
						  exp_continue
						}
	    -re "\[^\r\n]*Press any key to continue \\\(Q to quit\\\)" {
						  send " "
						  # bloody ^[[2K after " "
						  expect {
							-re "^\[^\r\n]*\r" {}
						  }
						  exp_continue
						}
	}
    }
    log_user 1

    if { $do_interact == 1 } {
	interact
	return 0
    }

    send -h "logout\r"
    expect {
	-re "^\[^\n\r *]*$reprompt"		{
						  # the Cisco CE and Jnx ERX
						  # return to non-enabled mode
						  # on exit in enabled mode.
						  send -h "logout\r"
						  exp_continue;
						}
	"The system has unsaved changes"	{ # Force10 SFTOS
						  if {$do_saveconfig} {
						    catch {send "y\r"}
						  } else {
						    catch {send "n\r"}
						  }
						  exp_continue
						}
	"Would you like to save them now"	{ # Force10
						  if {$do_saveconfig} {
						    catch {send "y\r"}
						  } else {
						    catch {send "n\r"}
						  }
						  exp_continue
						}
	-re "(Profile|Configuration) changes have occurred.*"	{
						  # Cisco CSS
						  if {$do_saveconfig} {
						    catch {send "y\r"}
						  } else {
						    catch {send "n\r"}
						  }
						  exp_continue
						}
	"Do you wish to save your configuration changes" {
						  if {$do_saveconfig} {
						    catch {send "y\r"}
						  } else {
						    catch {send "n\r"}
						  }
						  exp_continue
						}
	-re "\[\n\r]+"				{ exp_continue }
	timeout					{ catch {close}; catch {wait};
						  return 1
						}
	eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each router... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
set prompt_match ""
# if we have dont have a tty, we need some additional terminal settings
if [catch {open /dev/tty w} ttyid] {
    # no tty, ie: cron
    set spawnopts "-nottycopy"
    set stty_init "cols 132"
} else {
    catch {close ttyid} reason
}
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user -- "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # Default prompt.
    set prompt [join [find prompt $router] ""]
    if { [llength $prompt] == 0 } {
	set prompt "#"
    }

    # 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] ""]
    } else {
	set passwd $userpasswd
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } else {
      set userpswd [join [find userpassword $router] ""]
      if { "$userpswd" == "" } { set userpswd $passwd }
    }

    # Figure out prompts
    set u_prompt [find userprompt $router]
    if { "$u_prompt" == "" } {
	set u_prompt "(\[Uu]sername|Login|login|user name|User):"
    } else {
	set u_prompt [join [lindex $u_prompt 0] ""]
    }
    set p_prompt [find passprompt $router]
    if { "$p_prompt" == "" } {
	set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+):"
    } else {
	set p_prompt [join [lindex $p_prompt 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 cypher type
    if {[info exists cypher]} {
        # command line cypher type
        set cyphertype $cypher
    } else {
        set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $cmethod $cyphertype $identfile]} {
	incr exitval
	# if login failed or rsh was unsuccessful, move on to the next device
	continue
    }
    # we are logged in, now figure out the full prompt:
    # cli prompt:
    # A:some.domain.name# configure
    # cli prompt when config is unsaved:
    # *A:some.domain.name# configure 
    # config prompt:
    # A:some.domain.name>config# vrrp
    # *A:some.domain.name>config>vrrp# 
    send "\r"
    regsub -all {^(\^*)(.*)} $prompt {\2} reprompt
    expect {
	-re "\[\r\n]+"		{ exp_continue; }
	-re "^.+$reprompt"	{ set junk $expect_out(0,string);
				  regsub -all "^\\\*" $junk {} junk
				  regsub -all "\[\]\[\(\)+]" $junk {\\&} prompt;
				  set prompt "\[*]?$prompt";
				}
    }
    if { $do_command || $do_script } {
	# disable the pager
	send "environment no more\r"
	expect {
	  -re "MINOR: CLI Command not allowed"	{
				  send_error "Error: environment no more command is not allowed\n"
				  incr exitval
				  continue
				}
	  -re $prompt	{}
	}
	send "//environment no more\r"
	expect {
	  -re "MINOR: CLI Command not allowed"	{
				  send_error "Error: //environment no more command is not allowed\n"
				  incr exitval
				  continue
				}
	  -re $prompt	{}
	}
	send "environment more false\r"
	expect {
	  -re "MINOR: CLI Command not allowed"	{
				  send_error "Error: environment more false command is not allowed\n"
				  incr exitval
				  continue
				}
	  -re $prompt	{}
	}
	# XXX term length only works on the console?
	# send "environment terminal length 512\r"
	# expect -re $prompt	{}
	# XXX term width only works on the console?
	# send "environment terminal width 132\r"
	# expect -re $prompt	{}
    }
    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each router
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/nslogin.in000644 015615 000000 00000025654 13657102757 015560 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## @PACKAGE@ @VERSION@
@copyright@
#
# nslogin - Netscaler login
#
# Hacks from Anshuman Kanwar.

# The default is to automatically enable
set avenable 0
# Sometimes routers take awhile to answer (the default is 10 sec)
set timeoutdflt 45
# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

@login_top@

# Log into the router.
# returns: 0 on success, 1 on failure
proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
    global spawn_id in_proc do_command do_script
    global prompt u_prompt p_prompt e_prompt sshcmd
    set in_proc 1
    set uprompt_seen 0

    # try each of the connection methods in $cmethod until one is successful
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
        if ![string compare $prog "ssh"] {
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    set retval [ catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason ]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	} elseif ![string compare $prog "telnet"] {
	    send_error "\nError: unsupported method: telnet\n"
	    if { $progs == 0 } {
		return 1
	    }
	    continue
	} elseif ![string compare $prog "rsh"] {
	    send_error "\nError: unsupported method: rsh\n"
	    if { $progs == 0 } {
		return 1
	    }
	    continue
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}
	sleep 0.3

	# This helps cleanup each expect clause.
	expect_after {
	    timeout {
		global in_proc
		send_user "\nError: TIMEOUT reached\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    } eof {
		global in_proc
		send_user "\nError: EOF received\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    }
	}

    # Here we get a little tricky.  There are several possibilities:
    # the router can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the router might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-re "(Connection refused|Secure connection \[^\n\r]+ refused|Connection closed by)" {
	    catch {close}; catch {wait};
	    if !$progs {
		send_user "\nError: Connection Refused ($prog)\n"; 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
	}
	"Host is unreachable" {
	    catch {close}; catch {wait};
	    send_user "\nError: Host Unreachable!\n"; wait; return 1
	}
	"No address associated with name" {
	    catch {close}; catch {wait};
	    send_user "\nError: Unknown host\n"; wait; return 1
	}
	-re "(Host key not found |The authenticity of host .* be established)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    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"
				  return 1
				}
	-re "% (Bad passwords|Authentication failed)"	{
				  send_user "\nError: Check your passwd for $router\n"
				  return 1
				}
	# newer netscaler code (NS8.0: Build 47.8) the password prompt is
	# "Password:" not "user@hosts's password:"
	-re "(@\[^\r\n]+ )?$p_prompt"	{
					  # ssh pwd prompt
					  sleep 1
					  send -- "$userpswd\r"
					  exp_continue
					}

	"$prompt"		{ break; }
	"Login invalid"		{
				  send_user "\nError: Invalid login\n";
				  catch {close}; catch {wait}; return 1
				}
     }
    }

    set in_proc 0
    return 0
}


# Run commands given on the command line.

proc run_commands { prompt command } {
    global do_interact in_proc
    set in_proc 1

    # escape any parens in the prompt, such as "(enable)"
    regsub -all "\[)(]" $prompt {\\&} reprompt
    # this is the only way i see to get rid of more prompts in o/p..grrrrr
    log_user 0

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    # the pager can not be turned off on the PIX, so we have to look
    # for the "More" prompt.  the extreme is equally obnoxious, with a
    # global switch in the config.
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
	    -re "\b+"				{ exp_continue }
	    -re "^\[^\n\r *]*$reprompt"		{ send_user -- "$expect_out(buffer)"
						}
	    -re "^\[^\n\r]*$reprompt."		{ send_user -- "$expect_out(buffer)"
						  exp_continue
						}
	    -re "\[\n\r]+"			{ send_user -- "$expect_out(buffer)"
						  exp_continue
						}
	    -re "\[^\r\n]*Press  to cont\[^\r\n]*" {
						  send " "
						  # bloody ^[[2K after " "
						  expect {
						    -re "^\[^\r\n]*\r" {}
						  }
						  exp_continue
						}
	    -re "^ --More--\[^\n\r]*"		{
						  send " "
						  exp_continue
						}
	    -re "^<-+ More -+>\[^\n\r]*"	{
						  send_user -- "$expect_out(buffer)"
						  send " "
						  exp_continue
						}
	}
    }
    log_user 1

    if { $do_interact == 1 } {
	interact
	return 0
    }

    send "quit\r"
    expect {
        "Do you wish to save your configuration changes" {
                                                  send "n\r"
                                                  exp_continue
                                                }
        "\n"					{ exp_continue }
        timeout					{ catch {close}; catch {wait};
						  return 0
						}
        eof					{ return 0 }
    }
    set in_proc 0
}



#
# For each router... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # Figure out prompt.
    set prompt ">"

    # look for noenable option in .cloginrc
    if { [find noenable $router] == "1" } {
	set enable 0
    } else {
	set enable $avenable
    }

    # 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
	}
	if { $enable && $autoenable == 0 && [llength $pswd] < 2 } {
	    send_user -- "\nError: no enable password for $router in $password_file.\n"
	    continue
	}
	if { $do_passwd } {
	    set passwd [join [lindex $pswd 0] ""]
	} else {
	    set passwd $userpasswd
	}
	if { $do_enapasswd } {
	    set enapasswd [join [lindex $pswd 1] ""]
	} else {
	    set enapasswd $enapasswd
	}
    } else {
	set passwd $userpasswd
	set enapasswd $enapasswd
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } 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 $ruser }
    }

    # Figure out prompts
    set u_prompt [find userprompt $router]
    if { "$u_prompt" == "" } {
	set u_prompt "(Username|Login|login|user name):"
    } else {
	set u_prompt [join [lindex $u_prompt 0] ""]
    }
    set p_prompt [find passprompt $router]
    if { "$p_prompt" == "" } {
	set p_prompt "(\[Pp]assword|passwd):"
    } else {
	set p_prompt [join [lindex $p_prompt 0] ""]
    }
    set e_prompt [find enableprompt $router]
    if { "$e_prompt" == "" } {
	set e_prompt "\[Pp]assword:"
    } else {
	set e_prompt [join [lindex $e_prompt 0] ""]
    }

    # Figure out cypher type
    if {[info exists cypher]} {
      # command line cypher type
      set cyphertype $cypher
    } else {
      set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype]} {
	incr exitval
	continue
    }

    # we are logged in, now figure out the full prompt
    send "\r"
    expect {
	-re "\[\r\n]+"		{ exp_continue; }
	-re "^$prompt"		{ set junk $expect_out(0,string);
				  regsub -all "\[\]\[]" $junk {\\&} prompt; }
    }

    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	# If the prompt is (enable), then we are on a switch and the
	# command is "set length 0"; otherwise its "term length 0".
	if [ regexp -- ".*> .*enable" "$prompt" ] {
	    send "set length 0\r"
	    send "set logging session disable\r"
	} else {
	    send "term length 0\r"
	}
	expect -re $prompt	{}
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each router
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/cat5rancid.in000644 015615 000000 00000112402 13534014721 016073 0ustar00heaswheel000000 000000 #! @PERLV_PATH@
##
## @PACKAGE@ @VERSION@
## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Henry Kilmer, John Heasley, Andrew Partan,
## Pete Whiting, Austin Schutz, and Andrew Fort.
##
## 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. Neither the name of RANCID nor the names of its
##    contributors may be used to endorse or promote products derived from
##    this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
##
## It is the request of the authors, but not a condition of license, that
## parties packaging or redistributing RANCID NOT distribute altered versions
## of the etc/rancid.types.base file nor alter how this file is processed nor
## when in relation to etc/rancid.types.conf.  The goal of this is to help
## suppress our support costs.  If it becomes a problem, this could become a
## condition of license.
# 
#  The expect login scripts were based on Erik Sherk's gwtn, by permission.
# 
#  The original looking glass software was written by Ed Kern, provided by
#  permission and modified beyond recognition.
#
#  RANCID - Really Awesome New Cisco confIg Differ
#
# usage: cat5rancid [-dltCV] [-f filename | hostname]
#
use Getopt::Std;
getopts('dflt:CV');
if ($opt_V) {
    print "@PACKAGE@ @VERSION@\n";
    exit(0);
}
$log = $opt_l;
$debug = $opt_d;
$file = $opt_f;
$host = $ARGV[0];
$clean_run = 0;
$found_end = 0;
$timeo = 90;				# clogin timeout in seconds

my(@commandtable, %commands, @commands);# command lists
my($aclsort) = ("ipsort");		# ACL sorting mode
my($filter_commstr);			# SNMP community string filtering
my($filter_osc);			# oscillating data filtering mode
my($filter_pwds);			# password filtering mode
my(%modules);		# module info (part from sh ver, part from sh module)

# 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))
	&& scalar(%history)) {
	print eval "$command \%history";
	undef %history;
    }
    if (($new_hist_tag) && ($new_command) && ($command_string)) {
	if ($history{$command_string}) {
	    $history{$command_string} = "$history{$command_string}@string";
	} else {
	    $history{$command_string} = "@string";
	}
    } elsif (($new_hist_tag) && ($new_command)) {
	$history{++$#history} = "@string";
    } else {
	print "@string";
    }
    $hist_tag = $new_hist_tag;
    $command = $new_command;
    1;
}

sub numerically { $a <=> $b; }

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort numerically keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort values %lines) {
	$sorted_lines[$i] = $key;
	$i++;
    }
    @sorted_lines;
}

# This is a numerical sort routine (ascending).
sub numsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $num (sort {$a <=> $b} keys %lines) {
	$sorted_lines[$i] = $lines{$num};
	$i++;
    }
    @sorted_lines;
}

# This is a sort routine that will sort on the
# ip address when the ip address is anywhere in
# the strings.
sub ipsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $addr (sort sortbyipaddr keys %lines) {
	$sorted_lines[$i] = $lines{$addr};
	$i++;
    }
    @sorted_lines;
}

# 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]));
}
sub sortbyipaddr {
    &ipaddrval($a) <=> &ipaddrval($b);
}

# This routine parses "show version"
sub ShowVersion {
    print STDERR "    In ShowVersion: $_" if ($debug);

    while () {
	tr/\015//d;
	last if(/^$prompt/);
	next if(/^(\s*|\s*$cmd\s*)$/);
	/^(\S+) Software, Version\s+(.*)$/ &&
	    ProcessHistory("COMMENTS","keysort","F1",
		"!Image: Software: $2\n") && next;
	/^(\S+) S\/W compiled on (.*)$/ &&
	    ProcessHistory("COMMENTS","keysort","F3",
		"!Image: Compiled: $1 on $2\n") && next;
	/^System Bootstrap (Version.*)$/ &&
	    ProcessHistory("COMMENTS","keysort","G1",
		"!Bootstrap: $1\n") && next;
	if (/^Hardware Version: (\S+)  Model: (\S+)  Serial #: (\S+)/) {
	    my($proc) = $2;
	    # Really should figure out types of switches here.
	    $type = $2;
	    ProcessHistory("COMMENTS","keysort","A1",
		"!Chassis type: $proc - a $type switch\n");
	    ProcessHistory("COMMENTS","keysort","C1", "!Serial Number: $3\n");
	    ProcessHistory("COMMENTS","keysort","C2", "!Hardware Version: $1\n");
	    next;
	}
	# stuff module h/w, s/w, ports, etc into %module
	if (/^Mod\s+Port\s+Model/) {
	    ;
	    my($slot);
	    while () {
		tr/\015//d;
		last if (/^\s*$/);
		if (/^(\d+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s?:\s+(\S+)/) {
		    $slot = $1;
		    $modules{$slot}->{ports} = $2;
		    $modules{$slot}->{model} = $3;
		    $modules{$slot}->{serial} = $4;
		    $modules{$slot}->{$5} = $6;		# revision info
		}
		/^\s+(\S+)\s?:\s+(\S+)/ &&
		    ($modules{$slot}->{$1} = $2);
	    }
	    next;
	}
	# stuff module h/w, s/w, ports, etc into %module - yet another format
	if (/^Module\s+Ports\s+Model/) {
	    ;
	    my($slot);
	    while () {
		tr/\015//d;
		last if (/^\s*$/);
		if (/^(\d+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+\s+)?(\S+)\s*$/) {
		    $slot = $1;
		    $modules{$slot}->{ports} = $2;
		    $modules{$slot}->{model} = $3;
		    $modules{$slot}->{serial} = $4;
		    $modules{$slot}->{Hw} = $5;
		    $modules{$slot}->{Fw} = $6;
		    $modules{$slot}->{Sw} = $8;
		    $modules{$slot}->{Fw1} = $7;
		    $modules{$slot}->{Fw1} =~ s/\s*$//;
		    if ($modules{$slot}->{Fw1} =~ /^$/) {delete($modules{$slot}->{Fw1});}
		}
	    }
	    next;
	}
	if (/^       DRAM/) {
	    # Eat 2 lines & then get the total dram, flash, & nvram.
	    $_ = ; $_ = ;
	    $_ = ; tr/\015//d;
	    /\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)/ &&
		ProcessHistory("COMMENTS","keysort","B1",
		    "!Memory: dram $1\n") &&
		ProcessHistory("COMMENTS","keysort","B5",
		    "!Memory: flash $2\n") &&
		ProcessHistory("COMMENTS","keysort","B2",
		    "!Memory: nvram $3\n");
	    next;
	}
	if (/^Module DRAM/) {
	    # Eat a line & then get the total dram, flash, & nvram.
	    $_ = ;
	    $_ = ; tr/\015//d;
	    /\S+\s+(\S+)\s+(\S+)\s+(\S+)/ &&
		ProcessHistory("COMMENTS","keysort","B1",
		    "!Memory: dram $1\n") &&
		ProcessHistory("COMMENTS","keysort","B5",
		    "!Memory: flash $2\n") &&
		ProcessHistory("COMMENTS","keysort","B2",
		    "!Memory: nvram $3\n");
	    next;
	}
    }
    return(0);
}

# This routine parses "show install active"
sub ShowInstallActive {
    print STDERR "    In ShowInstallActive: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if /^\s*\^\s*$/;
	return(1) if /Invalid input detected/;
	return(1) if /Unknown command/;
	ProcessHistory("COMMENTS","keysort","F5","!Image: $_") && next;
    }
    return(0);
}

# This routine parses "show env all"
sub ShowEnv {
    # Skip if this is not a 7500, 7200, or 7000.
    print STDERR "    In ShowEnv: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if ($type !~ /^7/);
	if (!defined($E0)) {
	    $E0=1;
	    ProcessHistory("COMMENTS","keysort","E0","!\n");
	}
	if (/^Arbiter type (\d), backplane type (\S+)/) {
	    if (!defined($C0)) {
		$C0=1; ProcessHistory("COMMENTS","keysort","C0","!\n");
	    }
	    ProcessHistory("COMMENTS","keysort","C1",
		"!Enviromental Arbiter Type: $1\n");
	    ProcessHistory("COMMENTS","keysort","A2",
		"!Chassis type: $2 backplane\n");
	    next;
	}
	/^\s*(Power .*)/ &&
	    ProcessHistory("COMMENTS","keysort","E1","!Power: $1\n") && next;
	/^\s*(Lower Power .*)/i &&
	    ProcessHistory("COMMENTS","keysort","E2","!Power: $1\n") && next;
    }
    ProcessHistory("COMMENTS","","","!\n");
    return(0);
}

# This routine parses "show gsr chassis-info" for the gsr
# This will create arrarys for hw info.
sub ShowGSR {
    # Skip if this is not a 1200n.
    print STDERR "    In ShowGSR: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if ($type !~ /^120/);
	/^$/ && 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;
	/^\s+Chassis S\/N: (.*)$/ &&
	    ProcessHistory("COMMENTS","keysort","D2",
				"!GSR Chassis S/N: $1\n") &&
	    next;
	/^\s+PCA: (\S+)\s*rev: (\S+)\s*dev: \S+\s*HW ver: (\S+)$/ &&
	    ProcessHistory("COMMENTS","keysort","D3",
				"!GSR Backplane PCA: $1, rev $2, ver $3\n") &&
	    next;
	/^\s+Backplane S\/N: (\S+)$/ &&
	    ProcessHistory("COMMENTS","keysort","D4",
				"!GSR Backplane S/N: $1\n") &&
	    next;
    }
    ProcessHistory("COMMENTS","","","!\n");
    return(0);
}

# This routine parses "show boot"
sub ShowBoot {
    print STDERR "    In ShowBoot: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if /^\s*\^\s*$/;
	return(1) if /Ambiguous command/i;
	return(1) if /Invalid input detected/;
	return(1) if /Unknown command/;
	return(1) if /(Open device \S+ failed|Error opening \S+:)/;
	next if /CONFGEN variable/;
	if (!defined($H0)) {
	    $H0=1; ProcessHistory("COMMENTS","keysort","H0","!\n");
	}
	/^(\S+) variable (.*)$/ &&
	    ProcessHistory("COMMENTS","keysort","H1","!Variable: $1 $2\n") &&
	    next;
	if (/^Configuration register is (.*)$/) {
	    $config_register=$1;
	    next;
	}
    }
    ProcessHistory("COMMENTS","","","!\n");
    return(0);
}

# This routine parses "show flash"
sub ShowFlash {
    # skip if this is 7000, 7200, 7500, or 12000.
    print STDERR "    In ShowFlash: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if ($type =~ /^(120|7)/);
	return(1) if /^\s*\^\s*$/;
	return(1) if /Invalid input detected/;
	return(-1) if /session in progress. Try again later/; # Flash is busy
	ProcessHistory("FLASH","","","!Flash: $_");
    }
    ProcessHistory("","","","!\n");
    return;
}

# This routine parses "dir /all ((disk|slot)N|bootflash):"
sub DirSlotN {
    # Skip if this is not a 3600, 7000, 7200, 7500, or 12000.
    print STDERR "    In DirSlotN: $_" if ($debug);

    my($dev) = (/\s([^\s]+):/);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if ($type !~ /^(120|7|36)/);
	return(1) if /^\s*\^\s*$/;
	return(1) if /Invalid input detected/;
	return(1) if /\%Error: No such file or directory/;
	return(1) if /No space information available/;
	return(-1) if /\%Error calling/;
	return(-1) if /: device being squeezed/; # Flash is busy
	return(1) if /(Open device \S+ failed|Error opening \S+:)/;
	ProcessHistory("FLASH","","","!Flash: $dev: $_");
    }
    ProcessHistory("","","","!\n");
    return(0);
}

# This routine parses "show controllers"
sub ShowContAll {
    # Skip if this is a 70[01]0, 7500, or 12000.
    print STDERR "    In ShowContAll: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if ($type =~ /^(120|7[05])/);
	if (/^Interface ([^ \n(]*)/) { $INT = "$1, "; next; }
	/^(BRI unit \d)/ &&
	    ProcessHistory("INT","","","!Interface: $1\n") && next;
	/^LANCE unit \d, NIM/ &&
	    ProcessHistory("INT","","","!Interface: $_") && next;
	/^(LANCE unit \d)/ &&
	    ProcessHistory("INT","","","!Interface: $1\n") && next;
	/(Media Type is \S+),/ &&
	    ProcessHistory("INT","","","!\t$1\n");
	    if (/(M\dT:) show controller:$/) {
		my($ctlr) = $1;
		$_ = ; tr/\015//d; s/ subunit \d,//;
		ProcessHistory("INT","","","!Interface: $ctlr $_");
	    }
	if (/^(\S+) : show controller:$/) {
	    my($ctlr) = $1;
	    $_ = ; tr/\015//d; s/ subunit \d,//;
	    ProcessHistory("INT","","","!Interface: $ctlr: $_");
	}
	/^(HD unit \d), idb/ &&
	    ProcessHistory("INT","","","!Interface: $1\n") && next;
	/^HD unit \d, NIM/ &&
	    ProcessHistory("INT","","","!Interface: $_") && next;
	/^buffer size \d+  HD unit \d, (.*)/ &&
	    ProcessHistory("INT","","","!\t$1\n") && next;
	/^AM79970 / && ProcessHistory("INT","","","!Interface: $_") && next;
	/^buffer size \d+  (Universal Serial: .*)/ &&
	    ProcessHistory("INT","","","!\t$1\n") && next;
	/^Hardware is (.*)/ &&
	    ProcessHistory("INT","","","!Interface: $INT$1\n") && next;
	/^(QUICC Serial unit \d),/ &&
	    ProcessHistory("INT","","","!$1\n") && next;
	/^QUICC Ethernet .*/ &&
	    ProcessHistory("INT","","","!$_") && next;
	/^DTE .*\.$/ &&
	    ProcessHistory("INT","","","!\t$_") && next;
	/^(cable type :.*),/ &&
	    ProcessHistory("INT","","","!\t$1\n") && next;
	/^(.* cable.*), received clockrate \d+$/ &&
	    ProcessHistory("INT","","","!\t$1\n") && next;
	/^.* cable.*$/ &&
	    ProcessHistory("INT","","","!\t$_") && next;
    }
    return(0);
}

# This routine parses "show controllers cbus"
# Some of this is printed out in ShowDiagbus.
sub ShowContCbus {
    # Skip if this is not a 7000 or 7500.
    print STDERR "    In ShowContCbus: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if ($type !~ /^7[05]0/);
	if (/^\s*slot(\d+): ([^,]+), hw (\S+), sw (\S+), ccb/) {
	    $slot = $1;
	    $board{$slot} = $2;
	    $hwver{$slot} = $3;
	    $hwucode{$slot} = $4;
	} elsif (/^\s*(\S+) (\d+), hardware version (\S+), microcode version (\S+)/) {
	    $slot = $2;
	    $board{$slot} = $1;
	    $hwver{$slot} = $3;
	    $hwucode{$slot} = $4;
	} elsif (/(Microcode .*)/) {
	    $ucode{$slot} = $1;
	} elsif (/(software loaded .*)/) {
	    $ucode{$slot} = $1;
	} elsif (/(\d+) Kbytes of main memory, (\d+) Kbytes cache memory/) {
	    $hwmemd{$slot} = $1;
	    $hwmemc{$slot} = $2;
	} elsif (/byte buffers/) {
	    chop;
	    s/^\s*//;
	    $hwbuf{$slot} = $_;
	} elsif (/Interface (\d+) - (\S+ \S+),/) {
	    $interface = $1;
	    ProcessHistory("HW","","",
		"!\n!Int $interface: in slot $slot, named $2\n"); next;
	} elsif (/(\d+) buffer RX queue threshold, (\d+) buffer TX queue limit, buffer size (\d+)/) {
	    ProcessHistory("HW","","","!Int $interface: rxq $1, txq $2, bufsize $3\n");
	    next;
	}
    }
    return(0);
}

# This routine parses "show diagbus"
# This will create arrarys for hw info.
sub ShowDiagbus {
    # Skip if this is not a 7000, 70[01]0, or 7500.
    print STDERR "    In ShowDiagbus: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if ($type !~ /^7[05]/);
	if (/^\s*Slot (\d+):/i) {
	    $slot = $1;
	    next;
	} elsif (/^\s*Slot (\d+) \(virtual\):/i) {
	    $slot = $1;
	    next;
	} elsif (/^\s*(.*Processor.*|.*controller|.*Chassis Interface), HW rev (\S+), board revision (\S+)/i) {
	    $board = $1;
	    $hwver = $2;
	    $boardrev = $3;
	    if ($board =~ /Processor/) {
		if ($board =~ /7000 Route\/Switch/) {
		    $board = "RSP7000";
		} elsif ($board =~ /Route\/Switch Processor (\d)/) {
		    $board = "RSP$1";
		} elsif ($board =~ /Route/) {
		    $board = "RP";
		} elsif ($board =~ /Silicon Switch/) {
		    $board = "SSP";
		} elsif ($board =~ /Switch/) {
		    $board = "SP";
		    $board = "SSP $sspmem" if $ssp;
		} elsif ($board =~ /ATM/) {
		    $board = "AIP";
		}
	    } elsif ($board =~ /(.*) controller/i) {
		$board = $1;
	    }
	    # hwucode{$slot} defined in ShowContCbus
	    if (defined $hwucode{$slot}) {
		ProcessHistory("SLOT","","","!\n!Slot $slot/$board: hvers $hwver rev $boardrev ucode $hwucode{$slot}\n");
	    } else {
		ProcessHistory("SLOT","","","!\n!Slot $slot/$board: hvers $hwver rev $boardrev\n");
	    }
	    # These are also from the ShowContCbus
	    ProcessHistory("SLOT","","","!Slot $slot/$board: $ucode{$slot}\n") if (defined $ucode{$slot});
	    ProcessHistory("SLOT","","","!Slot $slot/$board: memd $hwmemd{$slot}, cache $hwmemc{$slot}\n")
	    if ((defined $hwmemd{$slot}) && (defined $hwmemc{$slot}));
	    ProcessHistory("SLOT","","","!Slot $slot/$board: $hwbuf{$slot}\n") if (defined $hwbuf{$slot});
	    next;
	}
	/Serial number: (\S+)\s*Part number: (\S+)/ &&
	    ProcessHistory("SLOT","","",
			"!Slot $slot/$board: part $2, serial $1\n") &&
	    next;
	/^\s*Controller Memory Size: (.*)$/ &&
	    ProcessHistory("SLOT","","","!Slot $slot/$board: $1\n") &&
	    next;
	if (/PA Bay (\d) Information/) {
	    $pano = $1;
	    if ("PA" =~ /$board/) {
		($s,$c) = split(/\//,$board);
		$board = "$s/$c/PA $pano";
	    } else {
		$board =~ s/\/PA \d//;
		$board = "$board/PA $pano";
	    }
	    next;
	}
	/\s+(.*) PA, (\d) ports?, (\S+)/ &&
	    ProcessHistory("SLOT","","","!Slot $slot/$board: type $3, $2 ports\n") &&
	    next;
	/\s+(.*) PA( \(\S+\))?, (\d) ports?/ &&
	    ProcessHistory("SLOT","","","!Slot $slot/$board: type $1$2, $3 ports\n") &&
	    next;
	/^\s*HW rev (\S+), Board revision (\S+)/ &&
	    ProcessHistory("SLOT","","","!Slot $slot/$board: hvers $1 rev $2\n") &&
	    next;
	/Serial number: (\S+)\s*Part number: (\S+)/ &&
	    ProcessHistory("SLOT","","","!Slot $slot/$board: part $2, serial $1\n") && next;
    }
    return(0);
}

# This routine parses "show diag" for the gsr, 7200, 3600, 2600.
# This will create arrarys for hw info.
sub ShowDiag {
    # Skip if this is not a 12000.
    print STDERR "    In ShowDiag: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if ($type !~ /^(120|720|36|26)/);
	/^$/ && next;
	if (!defined($showdiags)) {$showdiags=1; ProcessHistory("SLOT","","","!\n");}
	s/Port Packet Over SONET/POS/;
	if (/^\s*SLOT (\d+)\s+\(.*\): (.*)/) {
	    $slot = $1;
	    ProcessHistory("SLOT","","","!Slot $slot: $2\n");
	    $board = "RP" if (/Route Processor/);
	    $board = "CLK" if (/Clock Scheduler Card/);
	    next;
	}
	if (/^\s+PCA:\s+(.*)/){
	    local($part) = $1;
	    $_ = ;
	    /^\s+HW version (\S+)\s+S\/N (\S+)/ &&
		ProcessHistory("SLOT","","","!Slot $slot/PCA: part $part, serial $2\n") &&
		ProcessHistory("SLOT","","","!Slot $slot/PCA: hvers $1\n");
	    next;
	}

	if (/^\s+MBUS: .*\)\s+(.*)/) {
	    local($tmp) = "!Slot $slot/MBUS: part $1";
	    $_ = ;
	    /^\s+HW version (\S+)\s+S\/N (\S+)/ &&
		ProcessHistory("SLOT","","","$tmp, serial $2\n") &&
		ProcessHistory("SLOT","","","!Slot $slot/MBUS: hvers $1\n");
	    next;
	}
	if (/^\s+MBUS Agent Software version (.*)/) {
	    local($sw) = $1;
	    local($tail) = "!\n" if ($board =~ /(CLK|RP)/);
	    ProcessHistory("SLOT","","","!Slot $slot/MBUS: software $sw\n$tail");
	    next;
	}
	if (/^\s+DRAM size: (\d+)/) {
	    local($dram) = $1 / 1048576;
	    $_ = ;
	    /^\s+FrFab SDRAM size: (\d+)/ &&
		ProcessHistory("SLOT","","","!Slot $slot/MBUS: $dram Mbytes DRAM, "
			   . $1 / 1024 . " Kbytes SDRAM\n!\n");
	    next;
	}
	# 7200 and 3600 stuff
	if (/^(Slot)\s+(\d+):/ || /^\s+(WIC|VIC) Slot (\d):/) {
	    if ($1 eq "WIC") {
		$WIC = "/$2";
	    } elsif ($1 eq "VIC") {
		$WIC = "/$2";
	    } else {
		$slot = $2;
		undef($WIC);
	    }
	    $_ = ; tr/\015//d;

	    # clean up hideous 7200 format to look more like 7500 output
	    s/Fast-ethernet on C7200 I\/O card/FE-IO/;
	    s/ with MII or RJ45/-TX/;
	    s/Fast-ethernet /100Base/; s/[)(]//g;

	    /\s+(.*) port adapter,?\s+(\d+)\s+/i &&
		ProcessHistory("SLOT","","","!Slot $slot: type $1, $2 ports\n");
	    # I/O controller with no interfaces
	    /\s+(.*)\s+port adapter\s*$/i &&
		ProcessHistory("SLOT","","","!Slot $slot: type $1, 0 ports\n");
	    /\s+(.*)\s+daughter card(.*)$/ &&
		ProcessHistory("SLOT","","","!Slot $slot$WIC: type $1$2\n");
	    /\s+(FT1)$/ &&
		ProcessHistory("SLOT","","","!Slot $slot$WIC: type $1\n");
	    next;
	}
	/revision\s+(\S+).*revision\s+(\S+)/ &&
	    ProcessHistory("SLOT","","","!Slot $slot$WIC: hvers $1 rev $2\n") &&
	    next;
	/number\s+(\S+)\s+Part number\s+(\S+)/ &&
	    ProcessHistory("SLOT","","","!Slot $slot$WIC: part $2, serial $1\n!\n") &&
	    next;
}
    return(0);
}

# This routine parses "show inventory".
sub ShowInventory {
    print STDERR "    In ShowInventory: $_" if ($debug);

    while () {
	tr/\015//d;
	return if (/^\s*\^$/);
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(-1) if (/command authorization failed/i);
	return(1) if (/Unknown command/);
	# the pager can not be disabled per-session on the PIX
	s/^<-+ More -+>\s*//;

	chomp;

	# split PID/VID line
	if (/^(NAME: ".*,) (DESCR: .*)/) {
	    ProcessHistory("INVENTORY","","", sprintf("!%-30s%s\n", $1, $2));
	    next;
	}
	if (/^(PID: \w?) *, (VID: .*), (SN: .*)$/) {
	    ProcessHistory("INVENTORY","","", "!$1\n!$2\n!$3\n");
	    next;
	}

	ProcessHistory("INVENTORY","","","!$_");
    }
    ProcessHistory("INVENTORY","","","");

    return(0);
}

# This routine parses "show module"
sub ShowModule {
    my($slot);
    print STDERR "    In ShowModule: $_" if ($debug);

OUTER:while () {
	tr/\015//d;
	last if(/^$prompt/);
	# stuff module type into %module
	if (/^Mod\s+Slot\s+Ports/) {
	    ;
	    while () {
		tr/\015//d;
		last if (/^\s*$/);
		last OUTER if (/^$prompt/);
		if (/^Module .*mismatch/) {
		    ProcessHistory("MODWARN","","","!\n! WARNING: $_");
		    while () {
			tr/\015//d;
			last OUTER if (/^\s*$/);
			last if (/^\d/);
			ProcessHistory("MODWARN","","","!          $_");
		    }
		}
		if (/^(\d+)\s+\d+\s+\d+\s+(.*)\s+\S+\s+\S+\s*$/) {
		    $modules{$1}->{type} = $2;
		    $modules{$1}->{type} =~ s/\s{2,}.*$//;
		}
	    }
	    next;
	}
	# one does it one way... pita
	if (/^Mod\s+Module-Name\s+Ports/) {
	    ;
	    #my($slot);
	    while () {
		tr/\015//d;
		last if (/^\s*$/);
		last OUTER if (/^$prompt/);
		if (/^(\d+)\s+(.+\s+)?\d+\s+(.*)\s+\S+\s+(\S+)\s+\S+\s*$/) {
		    $modules{$1}->{serial} = $4;
		    $modules{$1}->{type} = $3;
		    #$modules{$1}->{type} =~ s/\s{2,}.*$//;
		    $modules{$1}->{type} =~ s/\s*$//;
		}
	    }
	    next;
	}
	# daughter boards
	if (/^Mod\s+Sub-Type/) {
	    ;
	    my($slot, $board);
	    while () {
		tr/\015//d;
		last if (/^\s*$/);
		last OUTER if (/^$prompt/);
		if (/^(\d+)\s+(\S+.*\s+)?(\S+)\s+(\S+)\s+(\S+)\s*$/) {
		    $board = 0 if ($slot != $1);
		    $slot = $1;
		    $modules{$1}->{daughter}->{$board}->{model} = $3;
		    $modules{$1}->{daughter}->{$board}->{serial} = $4;
		    $modules{$1}->{daughter}->{$board}->{Hw} = $5;
		    $modules{$1}->{daughter}->{$board}->{type} = $2;
		    $modules{$1}->{daughter}->{$board}->{type} =~ s/\s*$//;
		    $board++;
		}
	    }
	    next;
	}
    }

    # dump the module info
    foreach $slot (sort numerically keys(%modules)) {
	my($dboards);
	ProcessHistory("MODS","","","!\n");
	ProcessHistory("MODS","","",sprintf("!Slot $slot: type %s, %d ports\n", $modules{$slot}->{type}, $modules{$slot}->{ports}));
	delete($modules{$slot}->{ports});
	delete($modules{$slot}->{type});
	my($model) = sprintf("!Slot $slot: part %s, serial %s\n", $modules{$slot}->{model}, $modules{$slot}->{serial});
	delete($modules{$slot}->{model});
	delete($modules{$slot}->{serial});
	# deal with daughter boards before slot versions
	if (defined($modules{$slot}->{daughter})) {
	    my($board);
	    foreach $board (sort numerically keys(%{$modules{$slot}->{daughter}})) {
		$dboards .= sprintf("!Slot $slot/$board: type %s\n", $modules{$slot}->{daughter}->{$board}->{type});
		$dboards .= sprintf("!Slot $slot/$board: hvers %s\n", $modules{$slot}->{daughter}->{$board}->{Hw});
		$dboards .= sprintf("!Slot $slot/$board: part %s, serial %s\n", $modules{$slot}->{daughter}->{$board}->{model}, $modules{$slot}->{daughter}->{$board}->{serial});
	    }
	    delete($modules{$slot}->{daughter});
	}
	my($ver); my($i) = 0;
	ProcessHistory("MODS","","","!Slot $slot:");
	foreach $ver (sort keys(%{$modules{$slot}})) {
	    if ($i) {ProcessHistory("MODS","","",",");}
	    ProcessHistory("MODS","","",sprintf(" %s: %s", $ver, $modules{$slot}->{$ver}));
	    $i++;
	}
	ProcessHistory("MODS","","","\n");
	ProcessHistory("MODS","","",$model);
	if ($dboards) {ProcessHistory("MODS","","",$dboards);}
    }
}

# This routine processes a "show port ifindex"
sub ShowPortIfindex {
    print STDERR "    In ShowPortIfindex: $_" if ($debug);

    ProcessHistory("","","","!\n");
    while () {
	tr/\015//d;
	last if(/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	return(1) if /^\s*\^\s*$/;
	return(1) if /Invalid input detected/;
	return(1) if /Unknown command/;
	return(1) if /Usage: /;
	ProcessHistory("","","","! $_");
    }
}

# This routine processes a "write term {all}"
sub WriteTerm {
    print STDERR "    In WriteTerm: $_" if ($debug);

    if (! $found_end) {
	ProcessHistory("","","","!\n");
    }

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	last if (/^Unknown host /);		# error when write term all
						# is not supported
	next if (/^\.+$/ | /^$/);
	return(0) if ($found_end);
	/Non-Volatile memory is in use/  && return(-1); # NvRAM is locked
	# skip the crap
	next if (/^This command shows non-default configurations only./i);
	next if (/^Use 'write terminal all' to show both default and non/i);
	if (/^(\.\.+$|##+$|(Building|Current) configuration)/i) {
	    while () {
		tr/\015//d;
		next if (/^Current configuration:/i);
		next if (/^(\.+|[%!].*|\s*)$/);
		next if (/^ip add.*ipv4:/);	# band-aid for 3620 12.0S
		last;
	    }
	    ProcessHistory("","","","!\n");
	    if (defined($config_register)) {
		ProcessHistory("","","","config-register $config_register\n");
	    }
	    tr/\015//d;
	}
	# some versions have other crap mixed in with the bits in the
	# block above
	/^! (Last configuration|NVRAM config last)/ && next;
	/^#Time: / && next;

	# Dog gone Cool matches to process the rest of the config
	/^#time: /		&& next; # kill time:
	/^tftp-server flash /	&& next; # kill any tftp remains
	/^ntp clock-period /	&& next; # kill ntp clock-period
	/^ length /		&& next; # kill length on serial lines
	/^ width /		&& next; # kill width on serial lines
	if (/^enable password / && $filter_pwds >= 1) {
	    ProcessHistory("ENABLE","","","! $1 \n");
	    next;
	}
	if (/^set enablepass / && $filter_pwds >= 2) {
	    ProcessHistory("ENABLE","","","! $1 \n");
	    next;
	}
	if (/^(username .*) password /) {
	    if (/^(username .*) password / && $filter_pwds >= 1) {
		ProcessHistory("USER","","","! $1 password \n");
	    } else {
		ProcessHistory("USER","","","$_\n");
	    }
	    next;
	}
	if (/^(set localuser user .*) password .* (privilege .*)/) {
	    if (/^(set localuser user .*) password .* (privilege .*)/ &&
		$filter_pwds >= 1) {
		ProcessHistory("","","","! $1 password  $2\n");
	    } else {
		ProcessHistory("","","","$_\n");
	    }
	    next;
	}

	if (/^set password / && $filter_pwds >= 2) {
	    ProcessHistory("","","","! set password \n");
	    next;
	}
	if (/^(\s*)password / && $filter_pwds >= 1) {
	    ProcessHistory("LINE-PASS","","","!$1password \n");
	    next;
	}
	if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) {
	    ProcessHistory("","","","! neighbor $1 password \n");
	    next;
	}
	if (/^(ip ftp password) / && $filter_pwds >= 1) {
	    ProcessHistory("","","","!$1 \n");
	    next;
	}
	if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) {
	    ProcessHistory("","","","!$1 \n");
	    next;
	}
	if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) {
	    ProcessHistory("","","","!$1 \n");
	    next;
	}
	/fair-queue individual-limit/ && next;
	/^set port security \d+\/\d+ \S+-\S+\-/ && next;
	# sort ip explicit-paths.
	if (/^ip explicit-path name (\S+)/) {
	    my($key) = $1;
	    my($expath) = $_;
	    while () {
		tr/\015//d;
		last if (/^$prompt/);
		last if (/^$prompt/ || ! /^(ip explicit-path name |[ !])/);
		if (/^ip explicit-path name (\S+)/) {
		    ProcessHistory("EXPATH","keysort","$key","$expath");
		    $key = $1;
		    $expath = $_;
		} else  {
		    $expath .= $_;
		}
	    }
	    ProcessHistory("EXPATH","keysort","$key","$expath");
	}
	# sort route-maps
	if (/^route-map (\S+)/) {
	    my($key) = $1;
	    my($routemap) = $_;
	    while () {
		tr/\015//d;
		last if (/^$prompt/ || ! /^(route-map |[ !])/);
		if (/^route-map (\S+)/) {
		    ProcessHistory("ROUTEMAP","keysort","$key","$routemap");
		    $key = $1;
		    $routemap = $_;
		} else  {
		    $routemap .= $_;
		}
	    }
	    ProcessHistory("ROUTEMAP","keysort","$key","$routemap");
	}
	# filter out any RCS/CVS tags to avoid confusing local CVS storage
	s/\$(Revision|Id):/ $1:/;
	# order access-lists
	/^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ &&
	    ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next;
	# order extended access-lists
	/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ &&
	    ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next;
	/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ &&
	    ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next;
	/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ &&
	    ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next;
	# order arp lists
	/^set arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ &&
	    ProcessHistory("ARP","$aclsort","$1","$_") && next;
	/^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ &&
	    ProcessHistory("PACL $1 $3","$aclsort","$4","ip prefix-list $1 $3 $4$5\n")
	    && next;
	# order logging statements
	/^set logging server (\d+\.\d+\.\d+\.\d+)/ &&
	    ProcessHistory("LOGGING","ipsort","$1","$_") && next;
	# order/prune snmp-server host statements
	# we only prune lines of the form
	# snmp-server host a.b.c.d 
	if (/^set snmp trap (\d+\.\d+\.\d+\.\d+) /) {
	    if ($filter_commstr) {
		ProcessHistory("SNMPSERVERHOST","ipsort","$1","!set snmp trap $1 \n");
	    } else {
		ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_");
	    }
	    next;
	}
	if (/^(set snmp community) (\S+)\s+(\S+)/) {
	    if ($filter_commstr) {
		ProcessHistory("SNMPSERVERCOMM","keysort","$_","!$1 $2 \n");
	    } else {
		ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_")
	    }
	    next;
	}
	# order tacacs server statements
	/^set (tacacs) key / &&
	    ProcessHistory("","","","!set $1 key \n") && next;
	/^set tacacs server (\d+\.\d+\.\d+\.\d+)/ &&
	    ProcessHistory("TAC","ipsort","$1","$_") && next;
	# order clns host statements
	/^clns host \S+ (\S+)/ &&
	    ProcessHistory("CLNS","keysort","$1","$_") && next;
	# order alias statements
	/^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next;
	# delete ntp auth password
	if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 2) {
	    ProcessHistory("","","","!$1 \n");
	    next;
	}
	# order ntp peers/servers
	if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) {
	    $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5);
	    ProcessHistory("NTP","keysort",$sortkey,"$_");
	    next;
	}
	# order ip host line statements
	/^ip host line(\d+)/ &&
	    ProcessHistory("IPHOST","numsort","$1","$_") && next;
	# order ip nat source static statements
	/^ip nat (\S+) source static (\S+)/ &&
	    ProcessHistory("IP NAT $1","ipsort","$2","$_") && next;
	# order atm map-list statements
	/^\s+ip\s+(\d+\.\d+\.\d+\.\d+)\s+atm-vc/ &&
	    ProcessHistory("ATM map-list","ipsort","$1","$_") && next;
	# order ip rcmd lines
	/^ip rcmd/ && ProcessHistory("RCMD","keysort","$_","$_") && next;

	ProcessHistory("","","","$_");
	# end of config
	if (/^end$/) {
	    $found_end = 1;
	    return(1);
	}
    }
    return(0);
}

# Main
@commandtable = (
	{'show version'		=> 'ShowVersion'},
	{'show boot'		=> 'ShowBoot'},
	{'show flash'		=> 'ShowFlash'},
	{'dir bootflash:'	=> 'DirSlotN'},
	{'dir slot0:'		=> 'DirSlotN'},
	{'dir slot1:'		=> 'DirSlotN'},
	{'dir sup-bootflash:'	=> 'DirSlotN'},
	{'dir sup-microcode:'	=> 'DirSlotN'},
	{'show module'		=> 'ShowModule'},
	{'show inventory raw'	=> 'ShowInventory'},
	{'show port ifindex'	=> 'ShowPortIfindex'},
	{'write term all'	=> 'WriteTerm'},
	{'write term'		=> 'WriteTerm'},
	{'show running-config'	=> '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);
$commandcnt = scalar(keys %commands);

$commandstr=join(";",@commands);
$cmds_regexp = join("|", map quotemeta($_), @commands);

if (length($host) == 0) {
    if ($file) {
	print(STDERR "Too few arguments: file name required\n");
	exit(1);
    } else {
	print(STDERR "Too few arguments: host name required\n");
	exit(1);
    }
}
if ($opt_C) {
    print "clogin -t $timeo -c\'$commandstr\' $host\n";
    exit(0);
}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
if ($debug) { $| = 1; }

if ($file) {
    print(STDERR "opening file $host\n") if ($debug || $log);
    open(INPUT,"<$host") || die "open failed for $host: $!\n";
} else {
    print(STDERR "executing clogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log);
    system "clogin -t $timeo -c \"$commandstr\" $host  $host.raw 2>&1" || die "clogin failed for $host: $!\n";
    open(INPUT, "< $host.raw") || die "clogin failed for $host: $!\n";
}

# 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 oscillating data filtering mode
if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) {
    $filter_osc = 0;
} else {
    $filter_osc = 1;
}
# determine password filtering mode
if ($ENV{"FILTER_PWDS"} =~ /no/i) {
    $filter_pwds = 0;
} elsif ($ENV{"FILTER_PWDS"} =~ /all/i) {
    $filter_pwds = 2;
} else {
    $filter_pwds = 1;
}

ProcessHistory("","","","!RANCID-CONTENT-TYPE: cat5\n!\n");
ProcessHistory("COMMENTS","keysort","B0","!\n");
ProcessHistory("COMMENTS","keysort","F0","!\n");
ProcessHistory("COMMENTS","keysort","G0","!\n");
TOP: while() {
    tr/\015//d;
    if (/> \(enable\) ?exit(?:$|Connection)/) {
	$clean_run = 1;
	last;
    }
    if (/^Error:/) {
	print STDOUT ("$host clogin error: $_");
	print STDERR ("$host clogin error: $_") if ($debug);
	$clean_run = 0;
	last;
    }
    while (/> \(enable\)\s*($cmds_regexp)\s*$/) {
	$cmd = $1;
	if (!defined($prompt)) {
	    $prompt = ($_ =~ /^([^>]+>)/)[0];
	    $prompt =~ s/([][}{)(\\])/\\$1/g;
	    print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);
	}
	print STDERR ("HIT COMMAND:$_") if ($debug);
	if (! defined($commands{$cmd})) {
	    print STDERR "$host: found unexpected command - \"$cmd\"\n";
	    $clean_run = 0;
	    last TOP;
	}
	$rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd);
	delete($commands{$cmd});
	if ($rval == -1) {
	    $clean_run = 0;
	    last TOP;
	}
    }
}
print STDOUT "Done $logincmd: $_\n" if ($log);
# Flush History
ProcessHistory("","","","");
# Cleanup
close(INPUT);
close(OUTPUT);

unlink("$host.raw") if (! $debug);

# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
    if (scalar(keys %commands) eq $commandcnt) {
	printf(STDERR "$host: missed cmd(s): all commands\n");
    } elsif (scalar(%commands)) {
	my($count, $i) = 0;
	for ($i = 0; $i < $#commands; $i++) {
	    if ($commands{$commands[$i]}) {
		if (!$count) {
		    printf(STDERR "$host: missed cmd(s): %s", $commands[$i]);
		} else {
		    printf(STDERR ", %s", $commands[$i]);
		}
		$count++;
	    }
	}
	if ($count) {
	    printf(STDERR "\n");
	}
    }
    if (!$clean_run || !$found_end) {
	print(STDERR "$host: End of run not found\n");
	if ($debug) {
	    print(STDERR "$host: clean_run is false\n") if (!$clean_run);
	    print(STDERR "$host: found_end is false\n") if (!$found_end);
	}
	system("/usr/bin/tail -1 $host.new");
    }
    unlink "$host.new" if (! $debug);
}
rancid-3.13/bin/brancid.in000644 015615 000000 00000024432 13534014715 015470 0ustar00heaswheel000000 000000 #! @PERLV_PATH@
##
## hacked version of Hank's rancid - this one tries to deal with Bay's.
##
## @PACKAGE@ @VERSION@
## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Henry Kilmer, John Heasley, Andrew Partan,
## Pete Whiting, Austin Schutz, and Andrew Fort.
##
## 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. Neither the name of RANCID nor the names of its
##    contributors may be used to endorse or promote products derived from
##    this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
##
## It is the request of the authors, but not a condition of license, that
## parties packaging or redistributing RANCID NOT distribute altered versions
## of the etc/rancid.types.base file nor alter how this file is processed nor
## when in relation to etc/rancid.types.conf.  The goal of this is to help
## suppress our support costs.  If it becomes a problem, this could become a
## condition of license.
# 
#  The expect login scripts were based on Erik Sherk's gwtn, by permission.
# 
#  The original looking glass software was written by Ed Kern, provided by
#  permission and modified beyond recognition.
#
#  RANCID - Really Awesome New Cisco confIg Differ
#
# usage: brancid [-dltCV] [-f filename | hostname]
#
use Getopt::Std;
getopts('dflt:CV');
if ($opt_V) {
    print "@PACKAGE@ @VERSION@\n";
    exit(0);
}
$log = $opt_l;
$debug = $opt_d;
$file = $opt_f;
$host = $ARGV[0];
$clean_run = 0;
$found_end = 0;
$timeo = 90;				# blogin timeout in seconds

my(@commandtable, %commands, @commands);# command lists
my($aclsort) = ("ipsort");		# ACL sorting mode
my($filter_commstr);			# SNMP community string filtering
my($filter_osc);			# oscillating data filtering mode
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))
	&& scalar(%history)) {
	print eval "$command \%history";
	undef %history;
    }
    if (($new_hist_tag) && ($new_command) && ($command_string)) {
	if ($history{$command_string}) {
	    $history{$command_string} = "$history{$command_string}@string";
	} else {
	    $history{$command_string} = "@string";
	}
    } elsif (($new_hist_tag) && ($new_command)) {
	$history{++$#history} = "@string";
    } else {
	print "@string";
    }
    $hist_tag = $new_hist_tag;
    $command = $new_command;
    1;
}

sub numerically { $a <=> $b; }

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort numerically keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort values %lines) {
	$sorted_lines[$i] = $key;
	$i++;
    }
    @sorted_lines;
}

# This is a numerical sort routine (ascending).
sub numsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $num (sort {$a <=> $b} keys %lines) {
	$sorted_lines[$i] = $lines{$num};
	$i++;
    }
    @sorted_lines;
}

# This is a sort routine that will sort on the
# ip address when the ip address is anywhere in
# the strings.
sub ipsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $addr (sort sortbyipaddr keys %lines) {
	$sorted_lines[$i] = $lines{$addr};
	$i++;
    }
    @sorted_lines;
}

# 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]));
}
sub sortbyipaddr {
    &ipaddrval($a) <=> &ipaddrval($b);
}

# This routine parses "show config"
sub ShowConfig {
    print STDERR "    In ShowConfig: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	next if (/^Reading configuration information/);
	next if (/^Can\'t find object or class named \"\-all\"\s*$/);
	next if (/lock-address .*$/);
	next if (/^\# *uptime +\d+\s*$/);
	if (/community label /) {
	    if ($filter_commstr) {
		$_ =~ s/community label .*$/community label /;
	    }
	}
	return(1) if /(invalid command name)/;
	ProcessHistory("","","","$_");
    }
    # ProcessHistory("","","","!$_");
    if (/exit$/) {
	$found_end = 1;
	return(1);
    }
    return(0);
}

# This routine parses single command's that return no required info
sub RunCommand {
    print STDERR "    In RunCommand: $_" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	# prompt may have changed
	if (/\>/) {
	    $prompt = ($_ =~ /^([^>]+>)/)[0];
	    $prompt =~ s/([][])/\\$1/g;
	    last;
	}
    }
    return(0)
}

# Main
@commandtable = (
	{'bcc'			=> 'RunCommand'},
	{'show config'		=> 'ShowConfig'},
	{'show config -all'	=> 'ShowConfig'},
	{'exit'			=> 'RunCommand'}
);
# 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);
$commandcnt = scalar(keys %commands);

$commandstr=join(";",@commands);
$cmds_regexp = join("|", map quotemeta($_), @commands);

if (length($host) == 0) {
    if ($file) {
	print(STDERR "Too few arguments: file name required\n");
	exit(1);
    } else {
	print(STDERR "Too few arguments: host name required\n");
	exit(1);
    }
}
if ($opt_C) {
    print "blogin -t $timeo -c\'$commandstr\' $host\n";
    exit(0);
}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
if ($debug) { $| = 1; }

if ($file) {
    print(STDERR "opening file $host\n") if ($debug || $log);
    open(INPUT,"<$host") || die "open failed for $host: $!\n";
} else {
    print(STDERR "executing blogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log);
    system "blogin -t $timeo -c \"$commandstr\" $host  $host.raw 2>&1" || die "blogin failed for $host: $!\n";
    open(INPUT, "< $host.raw") || die "blogin failed for $host: $!\n";
}

# 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 oscillating data filtering mode
if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) {
    $filter_osc = 0;
} else {
    $filter_osc = 1;
}
# determine password filtering mode
if ($ENV{"FILTER_PWDS"} =~ /no/i) {
    $filter_pwds = 0;
} elsif ($ENV{"FILTER_PWDS"} =~ /all/i) {
    $filter_pwds = 2;
} else {
    $filter_pwds = 1;
}

ProcessHistory("","","","!RANCID-CONTENT-TYPE: baynet\n!\n");
TOP: while() {
    tr/\015//d;
    if ( (/\>\s?logout$/) || $found_end ) {
	$clean_run=1;
	last;
    }
    if (/^Error:/) {
	print STDOUT ("$host blogin error: $_");
	print STDERR ("$host blogin error: $_") if ($debug);
	$clean_run=0;
	last;
    }
    while (/>\s*($cmds_regexp)\s*$/) {
	$cmd = $1;
	if (!defined($prompt)) {
	    $prompt = ($_ =~ /^([^>]+>)/)[0];
	    $prompt =~ s/([][}{)(\\])/\\$1/g;
	    print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);
	}
	print STDERR ("HIT COMMAND:$_") if ($debug);
	if (! defined($commands{$cmd})) {
	    print STDERR "$host: found unexpected command - \"$cmd\"\n";
	    $clean_run = 0;
	    last TOP;
	}
	$rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd);
	delete($commands{$cmd});
	if ($rval == -1) {
	    $clean_run = 0;
	    last TOP;
	}
    }
}
print STDOUT "Done $logincmd: $_\n" if ($log);
# Flush History
ProcessHistory("","","","");
# Cleanup
close(INPUT);
close(OUTPUT);

unlink("$host.raw") if (! $debug);

# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
    if (scalar(keys %commands) eq $commandcnt) {
	printf(STDERR "$host: missed cmd(s): all commands\n");
    } elsif (scalar(%commands)) {
	my($count, $i) = 0;
	for ($i = 0; $i < $#commands; $i++) {
	    if ($commands{$commands[$i]}) {
		if (!$count) {
		    printf(STDERR "$host: missed cmd(s): %s", $commands[$i]);
		} else {
		    printf(STDERR ", %s", $commands[$i]);
		}
		$count++;
	    }
	}
	if ($count) {
	    printf(STDERR "\n");
	}
    }
    if (!$clean_run || !$found_end) {
	print(STDERR "$host: End of run not found\n");
	if ($debug) {
	    print(STDERR "$host: clean_run is false\n") if (!$clean_run);
	    print(STDERR "$host: found_end is false\n") if (!$found_end);
	}
	system("/usr/bin/tail -1 $host.new");
    }
    unlink "$host.new" if (! $debug);
}
rancid-3.13/bin/mrancid.in000644 015615 000000 00000033474 13534014756 015516 0ustar00heaswheel000000 000000 #! @PERLV_PATH@
##
## @PACKAGE@ @VERSION@
## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Henry Kilmer, John Heasley, Andrew Partan,
## Pete Whiting, Austin Schutz, and Andrew Fort.
##
## 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. Neither the name of RANCID nor the names of its
##    contributors may be used to endorse or promote products derived from
##    this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
##
## It is the request of the authors, but not a condition of license, that
## parties packaging or redistributing RANCID NOT distribute altered versions
## of the etc/rancid.types.base file nor alter how this file is processed nor
## when in relation to etc/rancid.types.conf.  The goal of this is to help
## suppress our support costs.  If it becomes a problem, this could become a
## condition of license.
# 
#  The expect login scripts were based on Erik Sherk's gwtn, by permission.
# 
#  The original looking glass software was written by Ed Kern, provided by
#  permission and modified beyond recognition.
#
# Amazingly hacked version of Hank's rancid - this one tries to
# deal with MRTd.
#
#  RANCID - Really Awesome New Cisco confIg Differ
#
# usage: mrancid [-dltCV] [-f filename | hostname]
#
use Getopt::Std;
getopts('dflt:CV');
if ($opt_V) {
    print "@PACKAGE@ @VERSION@\n";
    exit(0);
}
$log = $opt_l;
$debug = $opt_d;
$file = $opt_f;
$host = $ARGV[0];
$clean_run = 0;
$found_end = 0;
$timeo = 90;				# clogin timeout in seconds

my(@commandtable, %commands, @commands);# command lists
my($aclsort) = ("ipsort");		# ACL sorting mode
my($filter_commstr);			# SNMP community string filtering
my($filter_osc);			# oscillating data filtering mode
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))
	&& scalar(%history)) {
	print eval "$command \%history";
	undef %history;
    }
    if (($new_hist_tag) && ($new_command) && ($command_string)) {
	if ($history{$command_string}) {
	    $history{$command_string} = "$history{$command_string}@string";
	} else {
	    $history{$command_string} = "@string";
	}
    } elsif (($new_hist_tag) && ($new_command)) {
	$history{++$#history} = "@string";
    } else {
	print "@string";
    }
    $hist_tag = $new_hist_tag;
    $command = $new_command;
    1;
}

sub numerically { $a <=> $b; }

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort numerically keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort values %lines) {
	$sorted_lines[$i] = $key;
	$i++;
    }
    @sorted_lines;
}

# This is a numerical sort routine (ascending).
sub numsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $num (sort {$a <=> $b} keys %lines) {
	$sorted_lines[$i] = $lines{$num};
	$i++;
    }
    @sorted_lines;
}

# This is a sort routine that will sort on the
# ip address when the ip address is anywhere in
# the strings.
sub ipsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $addr (sort sortbyipaddr keys %lines) {
	$sorted_lines[$i] = $lines{$addr};
	$i++;
    }
    @sorted_lines;
}

# 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]));
}
sub sortbyipaddr {
    &ipaddrval($a) <=> &ipaddrval($b);
}

# This routine parses "show version"
sub ShowVersion {
    print STDERR "    In ShowVersion: $_" if ($debug);

    while () {
	tr/\015//d;
	last if(/^$prompt/);
	next if(/^(\s*|\s*$cmd\s*)$/);
	return(-1) if (/command authorization failed/i);

	/compiled on /i && next;
	/UP for /i && next;

	ProcessHistory("COMMENTS","keysort","A0", "!$_");
    }
    return(0);
}

# This routine processes a "write term"
sub WriteTerm {
    print STDERR "    In WriteTerm: $_" if ($debug);

    while () {
	tr/\015//d;
	if (/$prompt\s*exit\s*$/) {
	    $clean_run=1;
	    last;
	}
	last if(/^$prompt/);
	return(-1) if (/command authorization failed/i);
	# the pager can not be disabled per-session on the PIX
	s/^<-+ More -+>\s*//;
	/Non-Volatile memory is in use/  && return(-1); # NvRAM is locked

	# filter out any RCS/CVS tags to avoid confusing local CVS storage
	s/\$(Revision|Id):/ $1:/;

	if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) {
	    ProcessHistory("ENABLE","","","!$1$2 \n");
	    next;
	}
	if (/^username (\S+)(\s.*)? password /) {
	    if ($filter_pwds >= 1) {
		ProcessHistory("USER","keysort","$1","!username $1$2 password \n");
	    } else {
		ProcessHistory("USER","keysort","$1","$_");
	    }
	    next;
	}
	if (/^(\s*)password / && $filter_pwds >= 1) {
	    ProcessHistory("LINE-PASS","","","!$1password \n"); next;
	}
	if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) {
	    ProcessHistory("","","","! neighbor $1 password \n");
	    next;
	}

	if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) {
	    ProcessHistory("","","","!$1 \n"); next;
	}
	if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) {
	    ProcessHistory("","","","!$1 \n"); next;
	}

	# sort route-maps
	if (/^route-map (\S+)/) {
	    my($key) = $1;
	    my($routemap) = $_;
	    while () {
		tr/\015//d;
		last if (/^$prompt/ || ! /^(route-map |[ !])/);
		if (/^route-map (\S+)/) {
		    ProcessHistory("ROUTEMAP","keysort","$key","$routemap");
		    $key = $1;
		    $routemap = $_;
		} else  {
		    $routemap .= $_;
		}
	    }
	    ProcessHistory("ROUTEMAP","keysort","$key","$routemap");
	}

	# catch anything that wasnt match above.
	ProcessHistory("","","","$_");


	next;
	# order access-lists
	/^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ &&
	    ProcessHistory("ACL $1 $2","$aclsort","$3","$_") && next;
	# order extended access-lists
	/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ &&
	    ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next;
	/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ &&
	    ProcessHistory("EACL $1 $2","$aclsort","$3","$_") && next;
	/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ &&
	    ProcessHistory("EACL $1 $2","$aclsort","0.0.0.0","$_") && next;
	# order arp lists
	/^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ &&
	    ProcessHistory("ARP","$aclsort","$1","$_") && next;
	/^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ &&
	    ProcessHistory("PACL $1 $3","$aclsort","$4","ip prefix-list $1 $3 $4$5\n")
	    && next;
	# order logging statements
	/^logging (\d+\.\d+\.\d+\.\d+)/ &&
	    ProcessHistory("LOGGING","ipsort","$1","$_") && next;
	# order/prune snmp-server host statements
	# we only prune lines of the form
	# snmp-server host a.b.c.d 
	if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) {
	    if ($filter_commstr) {
		my($ip) = $1;
		my($line) = "snmp-server host $ip";
		my(@tokens) = split(' ', $');
		my($token);
		while ($token = shift(@tokens)) {
		    if ($token eq 'version') {
			$line .= " " . join(' ', ($token, shift(@tokens)));
		    } elsif ($token =~ /^(informs?|traps?|(no)?auth)$/) {
			$line .= " " . $token;
		    } else {
			$line = "!$line " . join(' ', ("", join(' ',@tokens)));
			last;
		    }
		}
		ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n");
	    } else {
		ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_");
	    }
	    next;
	}
	if (/^(snmp-server community) (\S+)/) {
	    if ($filter_commstr) {
		ProcessHistory("SNMPSERVERCOMM","keysort","$_","!$1 $'") && next;
	    } else {
		ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next;
	    }
	}
	# order clns host statements
	/^clns host \S+ (\S+)/ &&
	    ProcessHistory("CLNS","keysort","$1","$_") && next;
	# order alias statements
	/^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next;
	# order ntp peers/servers
	if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) {
	    $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5);
	    ProcessHistory("NTP","keysort",$sortkey,"$_");
	    next;
	}
	# order ip host line statements
	/^ip host line(\d+)/ &&
	    ProcessHistory("IPHOST","numsort","$1","$_") && next;

	# end of config
	if (/^(: )?end$/) {
	    $found_end = 1;
	    return(1);
	}
    }
    return(0);
}

# Main
@commandtable = (
	{'show version'		=> 'ShowVersion'},
	{'show config'		=> '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);
$commandcnt = scalar(keys %commands);

$commandstr=join(";",@commands);
$cmds_regexp = join("|", map quotemeta($_), @commands);

if (length($host) == 0) {
    if ($file) {
	print(STDERR "Too few arguments: file name required\n");
	exit(1);
    } else {
	print(STDERR "Too few arguments: host name required\n");
	exit(1);
    }
}
if ($opt_C) {
    print "clogin -t $timeo -c\'$commandstr\' $host\n";
    exit(0);
}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
if ($debug) { $| = 1; }

if ($file) {
    print(STDERR "opening file $host\n") if ($debug || $log);
    open(INPUT,"<$host") || die "open failed for $host: $!\n";
} else {
    print(STDERR "executing clogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log);
    system "clogin -t $timeo -c \"$commandstr\" $host  $host.raw 2>&1" || die "clogin failed for $host: $!\n";
    open(INPUT, "< $host.raw") || die "clogin failed for $host: $!\n";
}

# 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 oscillating data filtering mode
if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) {
    $filter_osc = 0;
} else {
    $filter_osc = 1;
}
# determine password filtering mode
if ($ENV{"FILTER_PWDS"} =~ /no/i) {
    $filter_pwds = 0;
} elsif ($ENV{"FILTER_PWDS"} =~ /all/i) {
    $filter_pwds = 2;
} else {
    $filter_pwds = 1;
}

ProcessHistory("","","","!RANCID-CONTENT-TYPE: mrtd\n!\n");
ProcessHistory("COMMENTS","keysort","B0","!\n");
TOP: while() {
    tr/\015//d;
    if (/^Error:/) {
	print STDOUT ("$host clogin error: $_");
	print STDERR ("$host clogin error: $_") if ($debug);
	$clean_run=0;
	last;
    }
    while (/#\s*($cmds_regexp)\s*$/) {
	$cmd = $1;
	if (!defined($prompt)) {
	    $prompt = ($_ =~ /^([^#]+)/)[0];
	    $prompt =~ s/([][}{)(\\])/\\$1/g;
	    $prompt .= "[#>]";
	    print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);
	}
	print STDERR ("HIT COMMAND:$_") if ($debug);
	if (! defined($commands{$cmd})) {
	    print STDERR "$host: found unexpected command - \"$cmd\"\n";
	    $clean_run = 0;
	    last TOP;
	}
	$rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd);
	delete($commands{$cmd});
	if ($rval == -1) {
	    $clean_run = 0;
	    last TOP;
	}
    }
}
print STDOUT "Done $logincmd: $_\n" if ($log);
# Flush History
ProcessHistory("","","","");
# Cleanup
close(INPUT);
close(OUTPUT);

unlink("$host.raw") if (! $debug);

# check for completeness
if (scalar(%commands) || !$clean_run) {
    if (scalar(keys %commands) eq $commandcnt) {
	printf(STDERR "$host: missed cmd(s): all commands\n");
    } elsif (scalar(%commands)) {
	my($count, $i) = 0;
	for ($i = 0; $i < $#commands; $i++) {
	    if ($commands{$commands[$i]}) {
		if (!$count) {
		    printf(STDERR "$host: missed cmd(s): %s", $commands[$i]);
		} else {
		    printf(STDERR ", %s", $commands[$i]);
		}
		$count++;
	    }
	}
	if ($count) {
	    printf(STDERR "\n");
	}
    }
    if (!$clean_run) {
	print(STDERR "$host: End of run not found\n");
	if ($debug) {
	    print(STDERR "$host: clean_run is false\n") if (!$clean_run);
	}
	system("/usr/bin/tail -1 $host.new");
    }
    unlink "$host.new" if (! $debug);
}
rancid-3.13/bin/anlogin.in000755 015615 000000 00000035623 13657102757 015536 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## @PACKAGE@ @VERSION@
@copyright@
#
# anlogin - Arbor Networks login
#

# Sometimes routers take awhile to answer (the default is 10 sec)
set timeoutdflt 60
# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

@login_top@

# Log into the router.
# returns: 0 on success, 1 on failure, -1 if rsh was used successfully
proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } {
    global command spawn_id in_proc do_command do_script platform passphrase
    global prompt prompt_match u_prompt p_prompt e_prompt sshcmd telnetcmd
    global spawnopts
    set in_proc 1
    set uprompt_seen 0

    # try each of the connection methods in $cmethod until one is successful
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port
	    if {"$port" == ""} {
		set cmd "$telnetcmd $router"
	    } else {
		set cmd "$telnetcmd $router $port"
	    }
	    set retval [catch {eval spawn $spawnopts [split $cmd { }]} reason]
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif [string match "ssh*" $prog] {
	    # ssh to the router & try to login with or without an identfile.
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$identfile" != ""} {
		set cmd "$cmd -i $identfile"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    set retval [catch {eval spawn $spawnopts [split "$cmd -x -l $user $router" { }]} reason]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}
	sleep 0.3

	# This helps cleanup each expect clause.
	expect_after {
	    timeout {
		global in_proc
		send_user "\nError: TIMEOUT reached\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    } eof {
		global in_proc
		send_user "\nError: EOF received\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    }
	}

    # Here we get a little tricky.  There are several possibilities:
    # the router can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the router might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-re "^<-+ More -+>\[^\n\r]*" {
	    # ASA will use the pager for long banners
	    send " ";
	    exp_continue
	}
	-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
	}
	"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)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-nocase -re "^warning: remote host denied authentication agent forwarding." {
	    exp_continue;
	}
	-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 "% (Bad passwords|Authentication failed)"	{
				  send_user "\nError: Check your passwd for $router\n"
				  catch {close}; catch {wait}; return 1
				}
	"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"
				  exp_continue
				}
	-nocase -re "last login:"	{
				  exp_continue
				}
	-nocase -re "failed login:"	{
				  exp_continue
				}
	-re "@\[^\r\n]+ $p_prompt"	{
				  # ssh pwd prompt
				  sleep 1
				  send -- "$userpswd\r"
				  exp_continue
				}
	-re "Enter passphrase.*: " {
				  # sleep briefly to allow time for stty -echo
				  sleep .3
				  send -- "$passphrase\r"
				  exp_continue
				}
	-re "$u_prompt"		{
				  send -- "$user\r"
				  set uprompt_seen 1
				  exp_continue
				}
	-re "$p_prompt"		{
				  sleep 1
				  if {$uprompt_seen == 1} {
					send -- "$userpswd\r"
				  } else {
					send -- "$passwd\r"
				  }
				  exp_continue
				}
	-re "$prompt"		{
				  set prompt_match $expect_out(0,string);
				  break;
				}
	"Login invalid"		{
				  send_user "\nError: Invalid login: $router\n";
				  catch {close}; catch {wait}; return 1
				}
     }
    }

    set in_proc 0
    return 0
}

# Enable
proc do_enable { enauser enapasswd } {
    global do_saveconfig in_proc
    global prompt u_prompt e_prompt
    set in_proc 1

    send "edit\r"
    expect {
	-re "$u_prompt"	{ send -- "$enauser\r"; exp_continue}
	-re "$e_prompt"	{ send -- "$enapasswd\r"; exp_continue}
	"#"		{ set prompt "#" }
	"(enable)"	{ set prompt "> \\(enable\\) " }
	-re "(denied|Sorry|Incorrect)"	{
			  # % Access denied - from local auth and poss. others
			  send_user "\nError: Check your Enable passwd\n";
			  return 1
			}
	"% Error in authentication" {
			  send_user "\nError: Check your Enable passwd\n"
			  return 1
			}
	"% Bad passwords" {
			  send_user "\nError: Check your Enable passwd\n"
			  return 1
			}
    }
    # We set the prompt variable (above) so script files don't need
    # to know what it is.
    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact do_saveconfig in_proc platform
    set in_proc 1

    # match cisco config mode prompts too, such as router(config-if)#,
    # but catalyst does not change in this fashion.
    regsub -all {^(.{1,11}).*([#%])$} $prompt {\1([^#%\r\n]+)?[#%](\\([^)\\r\\n]+\\))?} reprompt

    # this is the only way i see to get rid of more prompts in o/p..grrrrr
    log_user 0

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    # the pager can not be turned off on the PIX, so we have to look
    # for the "More" prompt.  the extreme is equally obnoxious in pre-12.3 XOS,
    # with a global switch in the config.
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
	    -re "\b+"				{ exp_continue }
	    -re "^\[^\n\r *]*$reprompt"		{ send_user -- "$expect_out(buffer)"
						}
	    -re "^\[^\n\r]*$reprompt."		{ send_user -- "$expect_out(buffer)"
						  exp_continue
						}
	    -re "\[^\r\n]*\[\n\r]+"		{ send_user -- "$expect_out(buffer)"
						  exp_continue
						}
	    -re "\\\[more]\[^\r\n]*"		{
						  # XXX send_user -- "$expect_out(buffer)"
						  send " "
						  exp_continue
						}
	    full_buffer				{ send_user -- "$expect_out(buffer)"
						  exp_continue
						}
	}
    }
    log_user 1

    if { $do_interact == 1 } {
	interact
	return 0
    }

    # quit works too
    send -h "exit\r"
    expect {
	-re "^\[^\n\r *]*$reprompt"		{
						  # if in enable mode, quit
						  # returns to non-enabled mode
						  send -h "exit\r"
						  exp_continue;
						}
	"You have uncommitted configuration changes. Exit anyway" {
						  catch {send "y\r"}
						  exp_continue
						}
	-re "\[\n\r]+"				{ exp_continue }
	timeout					{ catch {close}; catch {wait};
						  return 0
						}
	eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each router... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
set prompt_match ""
set enable 0
# if we have dont have a tty, we need some additional terminal settings
if [catch {open /dev/tty w} ttyid] {
    # no tty, ie: cron
    set spawnopts "-nottycopy"  
    set stty_init "cols 132"
} else {
    catch {close ttyid} reason
}
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    # attempt at platform switching.
    set platform ""
    send_user -- "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # Default prompt.
    set prompt "(%|#)"

    # look for noenable option in .cloginrc
    if { [find noenable $router] == "1" } {
	set enable 0
    }

    # Figure out passwords
    if { $do_passwd || $do_enapasswd } {
	set pswd [find password $router]
	if { [llength $pswd] == 0 } {
	    send_user -- "\nError: no password for $router in $password_file.\n"
	    continue
	}
	if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } {
	    send_user -- "\nError: no enable password for $router in $password_file.\n"
	    continue
	}
	if { $do_passwd } {
	    set passwd [join [lindex $pswd 0] ""]
	} else {
	    set passwd $userpasswd
	}
	if { $do_enapasswd } {
	    set enapasswd [join [lindex $pswd 1] ""]
	} else {
	    set enapasswd $enapasswd
	}
    } else {
	set passwd $userpasswd
	set enapasswd $enapasswd
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } 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 $ruser }
    }

    # Figure out prompts
    set u_prompt [find userprompt $router]
    if { "$u_prompt" == "" } {
	set u_prompt "(Username|Login|login|user name|User):"
    } else {
	set u_prompt [join [lindex $u_prompt 0] ""]
    }
    set p_prompt [find passprompt $router]
    if { "$p_prompt" == "" } {
	set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+):"
    } else {
	set p_prompt [join [lindex $p_prompt 0] ""]
    }
    set e_prompt [find enableprompt $router]
    if { "$e_prompt" == "" } {
	set e_prompt "\[Pp]assword:"
    } else {
	set e_prompt [join [lindex $e_prompt 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 cypher type
    if {[info exists cypher]} {
        # command line cypher type
        set cyphertype $cypher
    } else {
        set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} {
	incr exitval
	# if login failed or rsh was unsuccessful, move on to the next device
	continue
    }
    # Figure out the prompt.
    if { [regexp -- "#" $prompt_match junk] == 1 } {
	set enable 0
    } else {
	if { $avenable == 0 } {
	    set enable 0
	} else {
	    set ne [find noenable $router]
	    set ae [find autoenable $router]
	    if { "$ne" == "1" || "$ae" == "1" || $avautoenable } {
		set enable 0
	    } else {
		set enable 1
	    }
	}
    }
    if { $enable } {
	if {[do_enable $enauser $enapasswd]} {
	    if { $do_command || $do_script } {
		incr exitval
		catch {close}; catch {wait};
		continue
	    }
	}
    }
    # we are logged in, now figure out the full prompt
    send "\r"
    expect {
	-re "\[\r\n]+"		{ exp_continue; }
	-re "^(.+\[:.])1 ($prompt)" { # stoopid extreme cmd-line numbers and
				  # prompt based on state of config changes,
				  # which may have an * at the beginning.
				  set junk $expect_out(1,string)
				  regsub -all "^\\\* " $expect_out(1,string) {} junk
				  regsub -all "\[\]\[\(\)]" $junk {\\&} junk;
				  set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)";
				  set platform "extreme"
				}
	-re "^.+$prompt"	{ set junk $expect_out(0,string);
				  regsub -all "\[\]\[\(\)]" $junk {\\&} prompt;
				}
    }
    if { $do_command || $do_script } {
	send "system lines set 0\r"
	expect -re "$prompt"	{}
    }
    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each router
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/erancid.in000644 015615 000000 00000025406 13534014733 015475 0ustar00heaswheel000000 000000 #! @PERLV_PATH@
##
## @PACKAGE@ @VERSION@
## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Henry Kilmer, John Heasley, Andrew Partan,
## Pete Whiting, Austin Schutz, and Andrew Fort.
##
## 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. Neither the name of RANCID nor the names of its
##    contributors may be used to endorse or promote products derived from
##    this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
##
## It is the request of the authors, but not a condition of license, that
## parties packaging or redistributing RANCID NOT distribute altered versions
## of the etc/rancid.types.base file nor alter how this file is processed nor
## when in relation to etc/rancid.types.conf.  The goal of this is to help
## suppress our support costs.  If it becomes a problem, this could become a
## condition of license.
# 
#  The expect login scripts were based on Erik Sherk's gwtn, by permission.
# 
#  The original looking glass software was written by Ed Kern, provided by
#  permission and modified beyond recognition.
#
#  RANCID - Really Awesome New Cisco confIg Differ
#
# usage: erancid [-dltCV] [-f filename | hostname]
#
use Getopt::Std;
getopts('dflt:CV');
if ($opt_V) {
    print "@PACKAGE@ @VERSION@\n";
    exit(0);
}
$log = $opt_l;
$debug = $opt_d;
$file = $opt_f;
$host = $ARGV[0];
$clean_run = 0;
$found_end = 0;
$timeo = 90;				# elogin timeout in seconds

my(@commandtable, %commands, @commands);# command lists
my($aclsort) = ("ipsort");		# ACL sorting mode
my($filter_commstr);			# SNMP community string filtering
my($filter_osc);			# oscillating data filtering mode
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))
	&& scalar(%history)) {
	print eval "$command \%history";
	undef %history;
    }
    if (($new_hist_tag) && ($new_command) && ($command_string)) {
	if ($history{$command_string}) {
	    $history{$command_string} = "$history{$command_string}@string";
	} else {
	    $history{$command_string} = "@string";
	}
    } elsif (($new_hist_tag) && ($new_command)) {
	$history{++$#history} = "@string";
    } else {
	print "@string";
    }
    $hist_tag = $new_hist_tag;
    $command = $new_command;
    1;
}

sub numerically { $a <=> $b; }

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort numerically keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# 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($i) = 0;
    local(@sorted_lines);
    foreach $key (sort values %lines) {
	$sorted_lines[$i] = $key;
	$i++;
    }
    @sorted_lines;
}

# This is a numerical sort routine (ascending).
sub numsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $num (sort {$a <=> $b} keys %lines) {
	$sorted_lines[$i] = $lines{$num};
	$i++;
    }
    @sorted_lines;
}

# This is a sort routine that will sort on the
# ip address when the ip address is anywhere in
# the strings.
sub ipsort {
    local(%lines) = @_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $addr (sort sortbyipaddr keys %lines) {
	$sorted_lines[$i] = $lines{$addr};
	$i++;
    }
    @sorted_lines;
}

# 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]));
}
sub sortbyipaddr {
    &ipaddrval($a) <=> &ipaddrval($b);
}

# This routine parses "show version"
sub ShowVersion {
    print STDERR "    In ShowVersion: $_" if ($debug);

    ProcessHistory("COMMENTS","keysort","A1",
	"- Chassis type: EZT3 - an ADC EZT3 M13 multiplexor\n");

    while () {
	tr/\015//d;
	last if(/Active\) >/);
	next if(/^(\s*|\s*$cmd\s*)$/);

	/Boot Version (\S*)/ &&
	    ProcessHistory("COMMENTS","keysort","G1",
		"- ROM Bootstrap: $1\n") && next;
	/Software Version (\S*)/ &&
	    ProcessHistory("COMMENTS","keysort","F1",
		"- Software: $1\n") && next;
    }
    return(0);
}

# This routine parses "show module"
sub ShowModule {
    print STDERR "    In ShowModule: $_" if ($debug);

    # eat the header line
    $junk = ;

    ProcessHistory("SLOT","","","-\n");

    # now just copy it verbatim to the history file
    while () {
	tr/\015//d;
	last if(/Active\) >/);
	last if(/^$/);
	chop;
	ProcessHistory("SLOT","","","-$_\n");
    }
    ProcessHistory("SLOT","","","-\n");
}

# This routine processes a "write term"
sub WriteTerm {
    print STDERR "    In WriteTerm: $_" if ($debug);

    # eat the header line
    $junk = ;

    # now just copy it verbatim to the history file
    while () {
	tr/\015//d;
	last if(/Active\) >/);
	chop;
	if (/^\s*snmp/ && $filter_commstr) {
	    /snmp (getcomm|setcomm|trapcomm)(\s+)(\S*)/ &&
	    ProcessHistory("","","","-   snmp $1$2\"\"\n") && next;
	}
	# believe it or not, "-" is the "whole line is comment" command
	ProcessHistory("","","","$_\n");
    }
    $found_end = 1;
    return(1);
}

# Main
@commandtable = (
	{'version'		=> 'ShowVersion'},
	{'equipment'		=> 'ShowModule'},
	{'config'		=> '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);
$commandcnt = scalar(keys %commands);

$commandstr=join(";",@commands);
$cmds_regexp = join("|", map quotemeta($_), @commands);

if (length($host) == 0) {
    if ($file) {
	print(STDERR "Too few arguments: file name required\n");
	exit(1);
    } else {
	print(STDERR "Too few arguments: host name required\n");
	exit(1);
    }
}
if ($opt_C) {
    print "elogin -t $timeo -c\'$commandstr\' $host\n";
    exit(0);
}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
if ($debug) { $| = 1; }

if ($file) {
    print(STDERR "opening file $host\n") if ($debug || $log);
    open(INPUT,"<$host") || die "open failed for $host: $!\n";
} else {
    print(STDERR "executing elogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log);
    system "elogin -t $timeo -c \"$commandstr\" $host  $host.raw 2>&1" || die "elogin failed for $host: $!\n";
    open(INPUT, "< $host.raw") || die "elogin failed for $host: $!\n";
}

# 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 oscillating data filtering mode
if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) {
    $filter_osc = 0;
} else {
    $filter_osc = 1;
}
# determine password filtering mode
if ($ENV{"FILTER_PWDS"} =~ /no/i) {
    $filter_pwds = 0;
} elsif ($ENV{"FILTER_PWDS"} =~ /all/i) {
    $filter_pwds = 2;
} else {
    $filter_pwds = 1;
}

ProcessHistory("","","","- RANCID-CONTENT-TYPE: ezt3\n-\n");
ProcessHistory("COMMENTS","keysort","B0","-\n");
ProcessHistory("COMMENTS","keysort","F0","-\n");
ProcessHistory("COMMENTS","keysort","G0","-\n");
while() {
    tr/\015//d;
    if (/Logging out$/) {
	$clean_run=1;
	last;
    }
    if (/^Error:/) {
	print STDOUT ("$host elogin error: $_");
	print STDERR ("$host elogin error: $_") if ($debug);
	$clean_run=0;
	last;
    }
    while (/Active\) >\s*($cmds_regexp)\s*$/) {
	$cmd = $1;
	if (!defined($prompt)) {
	    $prompt = ($_ =~ /^([^#]+#)/)[0];
	    $prompt =~ s/([][}{)(\\])/\\$1/g;
	    print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);
	}
	print STDERR ("HIT COMMAND:$_") if ($debug);
	if (! defined($commands{$cmd})) {
	    print STDERR "$host: found unexpected command - \"$cmd\"\n";
	    $clean_run = 0;
	    last;
	}
	$rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd);
	delete($commands{$cmd});
	if ($rval == -1) {
	    $clean_run = 0;
	    last;
	}
    }
}
print STDOUT "Done $logincmd: $_\n" if ($log);
# Flush History
ProcessHistory("","","","");
# Cleanup
close(INPUT);
close(OUTPUT);

unlink("$host.raw") if (! $debug);

# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
    if (scalar(keys %commands) eq $commandcnt) {
	printf(STDERR "$host: missed cmd(s): all commands\n");
    } elsif (scalar(%commands)) {
	my($count, $i) = 0;
	for ($i = 0; $i < $#commands; $i++) {
	    if ($commands{$commands[$i]}) {
		if (!$count) {
		    printf(STDERR "$host: missed cmd(s): %s", $commands[$i]);
		} else {
		    printf(STDERR ", %s", $commands[$i]);
		}
		$count++;
	    }
	}
	if ($count) {
	    printf(STDERR "\n");
	}
    }
    if (!$clean_run || !$found_end) {
	print(STDERR "$host: End of run not found\n");
	if ($debug) {
	    print(STDERR "$host: clean_run is false\n") if (!$clean_run);
	    print(STDERR "$host: found_end is false\n") if (!$found_end);
	}
	system("/usr/bin/tail -1 $host.new");
    }
    unlink "$host.new" if (! $debug);
}
rancid-3.13/bin/trancid.in000644 015615 000000 00000024114 13534015012 015476 0ustar00heaswheel000000 000000 #! @PERLV_PATH@
##
## @PACKAGE@ @VERSION@
## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Henry Kilmer, John Heasley, Andrew Partan,
## Pete Whiting, Austin Schutz, and Andrew Fort.
##
## 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. Neither the name of RANCID nor the names of its
##    contributors may be used to endorse or promote products derived from
##    this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
##
## It is the request of the authors, but not a condition of license, that
## parties packaging or redistributing RANCID NOT distribute altered versions
## of the etc/rancid.types.base file nor alter how this file is processed nor
## when in relation to etc/rancid.types.conf.  The goal of this is to help
## suppress our support costs.  If it becomes a problem, this could become a
## condition of license.
# 
#  The expect login scripts were based on Erik Sherk's gwtn, by permission.
# 
#  The original looking glass software was written by Ed Kern, provided by
#  permission and modified beyond recognition.
#
#  RANCID - Really Awesome New Cisco confIg Differ
#
# usage: trancid [-dltCV] [-f filename | hostname]
#
# Modified by Ed Ravin for Netopia.
use Getopt::Std;
getopts('dflt:CV');
if ($opt_V) {
    print "@PACKAGE@ @VERSION@\n";
    exit(0);
}
$log = $opt_l;
$debug = $opt_d;
$file = $opt_f;
$host = $ARGV[0];
$clean_run = 0;
$found_end = 0;
$found_version = 0;
$found_env = 0;
$found_diag = 0;
$timeo = 90;			# clogin timeout in seconds

my($filter_osc);			# oscillating data filtering mode
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))
       && scalar(%history)) {
	print eval "$command \%history";
	undef %history;
    }
    if (($new_hist_tag) && ($new_command) && ($command_string)) {
	if ($history{$command_string}) {
	    $history{$command_string} = "$history{$command_string}@string";
	} else {
	    $history{$command_string} = "@string";
	}
    } elsif (($new_hist_tag) && ($new_command)) {
	$history{++$#history} = "@string";
    } else {
	print "@string";
    }
    $hist_tag = $new_hist_tag;
    $command = $new_command;
    1;
}

sub numerically { $a <=> $b; }

# This is a sort routing that will sort numerically on the
# keys of a hash as if it were a normal array.
sub keynsort {
    local(%lines)=@_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $key (sort numerically keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# This is a sort routing that will sort on the
# keys of a hash as if it were a normal array.
sub keysort {
    local(%lines)=@_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $key (sort keys(%lines)) {
	$sorted_lines[$i] = $lines{$key};
	$i++;
    }
    @sorted_lines;
}

# This is a sort routing that will sort on the
# values of a hash as if it were a normal array.
sub valsort{
    local(%lines)=@_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $key (sort values %lines) {
	$sorted_lines[$i] = $key;
	$i++;
    }
    @sorted_lines;
}

# This is a numerical sort routing (ascending).
sub numsort {
    local(%lines)=@_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $num (sort {$a <=> $b} keys %lines) {
	$sorted_lines[$i] = $lines{$num};
	$i++;
    }
    @sorted_lines;
}

# This is a sort routine that will sort on the
# ip address when the ip address is anywhere in
# the strings.
sub ipsort {
    local(%lines)=@_;
    local($i) = 0;
    local(@sorted_lines);
    foreach $addr (sort sortbyipaddr keys %lines) {
	$sorted_lines[$i] = $lines{$addr};
	$i++;
    }
    @sorted_lines;
}

# 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]));
}
sub sortbyipaddr {
    &ipaddrval($a) <=> &ipaddrval($b);
}

# This routine parses "show version"
sub ShowVersion {
    print STDERR "    In ShowVersion: $_" if ($debug);

    while () {
	tr/\015//d;
	if (/^$prompt/) { $found_version=1; last};
	next if(/^(\s*|\s*$cmd\s*)$/);
	return(1) if /(Invalid input detected|Type help or )/;
	return(-1) if (/command authorization failed/i);
	return(0) if ($found_version);		# Only do this routine once

	# no pagers in Netopia-land, but shouldn't hurt
	s/^<-+ More -+>\s*//;

### sample output:
### #show version
### cli      version:  01.00d00
### firmware version:  05.03.09f06
### hardware version:  01.00f00
### mib      version:  01.00f00
### html     version:  01.01d07

	ProcessHistory("COMMENTS","keysort","A1","# $_");
	}
	
    return(0);
}

sub ShowConfig {
    print STDERR "    In ShowConfig: $_" if ($debug);

    while () {
	tr/\015//d;
	if (/^$prompt/) { $found_end=1; $clean_run=1; return 0};
	next if(/^(\s*|\s*$cmd\s*)$/);
	return(1) if /(Invalid input detected|Type help or )/;
	return(-1) if (/command authorization failed/i);

	# no pagers in Netopia-land, but shouldn't hurt
	s/^<-+ More -+>\s*//;

	# no post-processing needed - just file it
	ProcessHistory("","","","$_");
	}
}

# Main
@commandtable=(
	{'show version'		=> "ShowVersion"},
	{'show config'		=> "ShowConfig"},
);

# Use array to preserve order of commands, and hash for mapping to subroutine
my (%commands, @commands);
foreach (@commandtable) {
	push @commands, (keys(%{$_}))[0];
	$commands{$commands[$#commands]}= (values(%{$_}))[0];
};
$commandstr=join(";",@commands);
$cmds_regexp = join("|", map quotemeta($_), @commands);
$commandcnt = scalar(keys %commands);

if (length($host) == 0) {
    if ($file) {
	print(STDERR "Too few arguments: file name required\n");
	exit(1);
    } else {
	print(STDERR "Too few arguments: host name required\n");
	exit(1);
    }
}
if ($opt_C) {
    print "tlogin -t $timeo -c\'$commandstr\' $host\n";
    exit(0);
}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
if ($debug) { $| = 1; }

if ($file) {
    print(STDERR "opening file $host\n") if ($debug || $log);
    open(INPUT,"<$host") || die "open failed for $host: $!\n";
} else {
    print(STDERR "executing tlogin -t $timeo -c\"$commandstr\" $host\n") if ($debug || $log);
    system "tlogin -t $timeo -c \"$commandstr\" $host  $host.raw 2>&1" || die "tlogin failed for $host: $!\n";
    open(INPUT, "< $host.raw") || die "tlogin failed for $host: $!\n";
}

# determine oscillating data filtering mode
if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) {
    $filter_osc = 0;
} else {
    $filter_osc = 1;
}
# determine password filtering mode
if ($ENV{"FILTER_PWDS"} =~ /no/i) {
    $filter_pwds = 0;
} elsif ($ENV{"FILTER_PWDS"} =~ /all/i) {
    $filter_pwds = 2;
} else {
    $filter_pwds = 1;
}

ProcessHistory("","","","#RANCID-CONTENT-TYPE: netopia\n#\n");
ProcessHistory("COMMENTS","keysort","B0","#\n");
ProcessHistory("COMMENTS","keysort","D0","#\n");
ProcessHistory("COMMENTS","keysort","F0","#\n");
ProcessHistory("COMMENTS","keysort","G0","#\n");
TOP: while() {
    tr/\015//d;
    if (/[>#]\s?exit$/) {
	$clean_run=1;
	last;
    }
    if (/^Error:/) {
	print STDOUT ("$host tlogin error: $_");
	print STDERR ("$host tlogin error: $_") if ($debug);
	$clean_run=0;
	last;
    }
    while (/#\s*($cmds_regexp)\s*$/) {
	$cmd = $1;
	if (!defined($prompt)) {
	    $prompt = "#";  # crude but effective
	    $prompt =~ s/([][}{)(\\])/\\$1/g;
	    print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);
	}
	print STDERR ("HIT COMMAND:$_") if ($debug);
	if (! defined($commands{$cmd})) {
	    print STDERR "$host: found unexpected command - \"$cmd\"\n";
	    $clean_run = 0;
	    last TOP;
	}
	$rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd);
	delete($commands{$cmd});
	if ($rval == -1) {
	    $clean_run = 0;
	    last TOP;
	}
    }
}
print STDOUT "Done $logincmd: $_\n" if ($log);
# Flush History
ProcessHistory("","","","");
# Cleanup
close(INPUT);
close(OUTPUT);

unlink("$host.raw") if (! $debug);

# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
    if (scalar(keys %commands) eq $commandcnt) {
	printf(STDERR "$host: missed cmd(s): all commands\n");
    } elsif (scalar(%commands)) {
	my($count, $i) = 0;
	for ($i = 0; $i < $#commands; $i++) {
	    if ($commands{$commands[$i]}) {
		if (!$count) {
		    printf(STDERR "$host: missed cmd(s): %s", $commands[$i]);
		} else {
		    printf(STDERR ", %s", $commands[$i]);
		}
		$count++;
	    }
	}
	if ($count) {
	    printf(STDERR "\n");
	}
    }
    if (!$clean_run || !$found_end) {
	print(STDERR "$host: End of run not found\n");
	if ($debug) {
	    print(STDERR "$host: clean_run is false\n") if (!$clean_run);
	    print(STDERR "$host: found_end is false\n") if (!$found_end);
	}
	system("/usr/bin/tail -1 $host.new");
    }
    unlink "$host.new" if (! $debug);
}
rancid-3.13/bin/rancid-cvs.in000644 015615 000000 00000013476 13534014770 016126 0ustar00heaswheel000000 000000 #! /bin/sh
##
## @PACKAGE@ @VERSION@
## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Henry Kilmer, John Heasley, Andrew Partan,
## Pete Whiting, Austin Schutz, and Andrew Fort.
##
## 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. Neither the name of RANCID nor the names of its
##    contributors may be used to endorse or promote products derived from
##    this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
##
## It is the request of the authors, but not a condition of license, that
## parties packaging or redistributing RANCID NOT distribute altered versions
## of the etc/rancid.types.base file nor alter how this file is processed nor
## when in relation to etc/rancid.types.conf.  The goal of this is to help
## suppress our support costs.  If it becomes a problem, this could become a
## condition of license.
# 
#  The expect login scripts were based on Erik Sherk's gwtn, by permission.
# 
#  The original looking glass software was written by Ed Kern, provided by
#  permission and modified beyond recognition.
#
# Create all of the misc files & dirs needed for each group and import them
# into CVS, git or Subversion.
#
# rancid-cvs
#

# Read in the environment
ENVFILE="@sysconfdir@/rancid.conf"

# print a usage message to stderr
pr_usage() {
    echo "usage: $0 [-V] [-f config_file] [group [group ...]]" >&2;
}

# command-line options
# -V print version string
if [ $# -ge 1 ] ; then
    while [ 1 ] ; do
	case $1 in
	-V)
	    echo "@PACKAGE@ @VERSION@"
	    exit 0
	    ;;
	-f)
	    shift
	    # next arg is the alternate config file name
	    ENVFILE="$1"
	    if [ -z $ENVFILE ]; then
		pr_usage
		exit 1
	    fi
	    shift
	    ;;
	-*)
	    echo "unknown option: $1" >&2
	    pr_usage
	    exit 1
	    ;;
	*)
	    break;
	    ;;
	esac
    done
fi

. $ENVFILE

# Base dir
if [ ! -d $BASEDIR ]; then
    mkdir -p $BASEDIR ||
	(echo "Could not create local state directory: $BASEDIR"; exit 1)
fi

cd $BASEDIR

# RCS system
RCSSYS=${RCSSYS:=cvs};
if [ $RCSSYS != "cvs" -a $RCSSYS != "svn" -a $RCSSYS != "git" ] ; then
    echo "$RCSSYS is not a valid value for RCSSYS. See rancid.conf(5)." >&2
    exit 1
fi

# Top level RCS stuff
case $RCSSYS in
cvs )
    if [ ! -d $CVSROOT ]; then
	cvs -d $CVSROOT init
    fi
    ;;
svn )
    if echo "$CVSROOT" | grep -q "://"; then
	# do nothing because CVSROOT is some sort of a URL
	# also assume the repository has already been provisioned
	:
    else
	if ! svn ls "file://$CVSROOT" >/dev/null 2>&1; then
	    svnadmin create $CVSROOT @SVN_FSTYPE@
	fi
	CVSROOT="file://$CVSROOT"
    fi
    ;;
git)
    if echo "$CVSROOT" | grep -q "://"; then
	# do nothing because CVSROOT is some sort of a URL
	# also assume the repository has already been provisioned
	:
    else
	if [ ! -d $CVSROOT ]; then
	    mkdir $CVSROOT
	fi
    fi
    ;;
esac

# LOGDIR location
LOGDIR=${LOGDIR:=$BASEDIR/logs};
if [ ! -d $LOGDIR ]; then
    mkdir -p $LOGDIR || (echo "Could not create log directory: $LOGDIR" >&2;    
			 exit 1)
fi

# Which groups to do
if [ $# -ge 1 ] ; then
	LIST_OF_GROUPS="$*"; export LIST_OF_GROUPS
elif [ "$LIST_OF_GROUPS" = "" ] ; then
	echo "LIST_OF_GROUPS is empty in $ENVFILE"
	exit 1
fi

for GROUP in `echo $LIST_OF_GROUPS` ;
do
    DIR=$BASEDIR/$GROUP

    # Directory for the group and the configs
    if [ ! -d $DIR ]; then
	mkdir -p $DIR
	cd $DIR
	case $RCSSYS in
	cvs )
	    cvs import -m "$GROUP" $GROUP new rancid
	    cd $BASEDIR
	    cvs checkout $GROUP
	    ;;
	svn )
	    svn import -m "$GROUP" . $CVSROOT/$GROUP
	    cd $BASEDIR
	    svn checkout $CVSROOT/$GROUP $GROUP
	    cd $DIR
	    svn update
	    ;;
	git )
	    git init --bare $CVSROOT/$GROUP
	    echo "$GROUP RANCiD repository" > $CVSROOT/$GROUP/description
	    git clone $CVSROOT/$GROUP .
	    echo "$GROUP RANCiD repository" > .git/description
	    git config user.name RANCiD
	    git config user.email $USER$MAILDOMAIN
	    git config push.default current
	    ;;
	esac
    fi
    cd $DIR
    if [ ! -d configs ]; then
	rm -f configs
	mkdir configs
	if [ $RCSSYS = "git" ]; then
	    cat > configs/.gitignore <>.*$reprompt"	{ exp_continue }
	    -re "\[\n\r]+"			{ exp_continue }
	}
    }

    if { $do_interact == 1 } {
	interact
	return 0
    }

    send "quit\r"
    expect {
	-re "^WARNING: There are unsaved configuration changes." {
						 send "y\r"
						 exp_continue
						}
	"\n"					{ exp_continue }
	"\[^\n\r *]*Session terminated"		{ return 0 }
	timeout					{ catch {close}; catch {wait};
						  return 0
						}
	eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each router... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
# http://www.shrubbery.net/pipermail/rancid-discuss/2015-January/007984.html
# if we have dont have a tty, we need some additional terminal settings
if [catch {open /dev/tty w} ttyid] {
    # no tty, ie: cron
    set spawnopts "-nottycopy"
    set stty_init "cols 132"
} else {
    catch {close ttyid} reason
}
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user "$router\n"

    # Figure out prompt.
    set prompt "] > "
    # alteon only "enables" based on the password used at login time
    set autoenable 1
    set enable 0

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # 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] ""]
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } else {
      set userpswd [join [find userpassword $router] ""]
      if { "$userpswd" == "" } { set userpswd $passwd }
    }

    # Figure out prompts
    set u_prompt [find userprompt $router]
    if { "$u_prompt" == "" } {
	set u_prompt "Login:"
    } else {
	set u_prompt [join [lindex $u_prompt 0] ""]
    }
    set p_prompt [find passprompt $router]
    if { "$p_prompt" == "" } {
	set p_prompt "\[Pp]assword:"
    } else {
	set p_prompt [join [lindex $p_prompt 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 cypher type
    if {[info exists cypher]} {
      # command line cypher type
      set cyphertype $cypher
    } else {
      set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $prompt $cmethod $cyphertype $identfile]} {
	incr exitval
	continue
    }

    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each router
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/fnlogin.in000644 015615 000000 00000043143 13657102757 015534 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## patched to accomplish fortinet from nlogin
## by: Daniel G. Epstein 
## adapted by: Diego Ercolani 
##
## @PACKAGE@ @VERSION@
@copyright@
#
# Netscreen hacks implemented by Stephen Gill .
# Fortinet hacks by Daniel G. Epstein 
#
# fnlogin - fortinet/fortigate login
#
# Most options are intuitive for logging into a netscreen firewall.
#
# Misc notes
#	netscreen does not have the concept of "enable", once logged in, a
#	users permissions can not change.

# XXX need to import login_top.

# Usage line
set usage "Usage: $argv0 \[-diSV\] \[-c command\] \[-Evar=x\] \
\[-f cloginrc-file\] \[-p user-password\] \
\[-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

# Password file
set password_file $env(HOME)/.cloginrc
# Default is to login to the firewall
set do_command 0
set do_interact 0
set do_script 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
set do_enapasswd 1
# cloginrc debugging knob
set do_cloginrcdbg 0
# Sometimes routers take awhile to answer (the default is 10 sec)
set timeoutdflt 45
# intialize cloginrc parsing stacks
set int_file {}
set int_lineno {}
# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 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) ]} {
    set default_user $env(CISCO_USER)
} elseif {[ info exists env(USER) ]} {
    set default_user $env(USER)
} elseif {[ info exists env(LOGNAME) ]} {
    set default_user $env(LOGNAME)
} 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.
    if [ catch {exec id} reason ] {
	send_error "\nError: could not exec id: $reason\n"
	exit 1
    }
    regexp {\(([^)]*)} "$reason" junk default_user
}
if {[ info exists env(CLOGINRC) ]} {
    set password_file $env(CLOGINRC)
}

# Sometimes firewall take awhile to answer (the default is 10 sec)
set timeout 45

# Process the command line
for {set i 0} {$i < $argc} {incr i} {
    set arg [lindex $argv $i]

    switch  -glob -- $arg {
	# Expect debug mode
	-d* {
	    exp_internal 1
	# Username
	} -u* {
	    if {! [  regexp .\[uU\](.+) $arg ignore user]} {
		incr i
		set username [ lindex $argv $i ]
	    }
	# cloginrc debugging knobs
	} -m* {
	    set do_cloginrcdbg 1
	} -M* {
	    set do_cloginrcdbg 2
	# interactive
	} -i* {
	    set do_interact 1
	# VTY Password
	} -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* {
	    if {[ regexp .\[E\](.+)=(.+) $arg ignore varname varvalue]} {
		set E$varname $varvalue
	    } else {
		send_user "\nError: invalid format for -E in $arg\n"
		exit 1
	    }
	# Command to run.
	} -c* {
	    if {! [  regexp .\[cC\](.+) $arg ignore command]} {
		incr i
		set command [ lindex $argv $i ]
	    }
	    set do_command 1
	# Expect script to run.
	} -s* {
	    if {! [  regexp .\[sS\](.+) $arg ignore sfile]} {
		incr i
		set sfile [ lindex $argv $i ]
	    }
	    if { ! [ file readable $sfile ] } {
		send_user "\nError: Can't read $sfile\n"
		exit 1
	    }
	    set do_script 1
	# 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* {
	    if {! [ regexp .\[fF\](.+) $arg ignore password_file]} {
		incr i
		set password_file [ lindex $argv $i ]
	    }
	} -t* {
	    if {! [regexp .\[tT\](.+) $arg ignore timeout]} {
		incr i
		set timeoutdflt [ lindex $argv $i ]
	    }
	# command file
        } -x* {
            if {! [  regexp .\[xX\](.+) $arg ignore cmd_file]} {
                incr i
                set cmd_file [ lindex $argv $i ]
            }
	    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
	# Version string
	} -V* {
	    send_user "@PACKAGE@ @VERSION@\n"
	    exit 0
	# Does tacacs automatically enable us?
        } -autoenable {
	    # ignore autoenable
	} -* {
	    send_user "\nError: Unknown argument! $arg\n"
	    send_user $usage
	    exit 1
	} default {
	    break
	}
    }
}
# Process firewalls...no firewalls listed is an error.
if { $i == $argc } {
    send_user "\nError: $usage"
}

# Only be quiet if we are running a script (it can log its output
# on its own)
if { $do_script } {
    log_user 0
} else {
    log_user 1
}

#
# Done configuration/variable setting.  Now run with it...
#

# 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 }
    }
    # take host from ENV(TERM)
    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"
	}
    }
}

# This is a helper function to make the password file easier to
# maintain.  Using this the password file has the form:
# add password sl*	pete cow
# add password at*	steve
# add password *	hanky-pie
proc add {var args} {
    global int_file int_lineno int_$var
    set file [lindex $int_file 0]
    set lineno [lindex $int_lineno 0]
    lappend int_$var "$var:$file:$lineno: $args"
}
proc include {args} {
    global env
    regsub -all "(^{|}$)" $args {} args
    if {[regexp "^/" $args ignore] == 0} {
	set args $env(HOME)/$args
    }
    source_password_file $args
}

proc find {var router} {
    global do_cloginrcdbg
    upvar int_$var list
    if {[info exists list]} {
	foreach line $list {
	    if {[string match -nocase [lindex $line 1] $router]} {
		if {$do_cloginrcdbg > 0} {
		    send_error -- [join [list [lindex $line 0] [lrange $line 1 end] "\r\n"]]
		}
		if {$do_cloginrcdbg == 2} {
		    # save return value
		    if {! [info exists result]} {
			set result [lrange $line 2 end]
		    }
		} else {
		    return [lrange $line 2 end]
		}
	    }
	}
    }

    if {$do_cloginrcdbg == 2} {
	if {[info exists result]} {
	    return $result
	}
    }
    return {}
}

# Loads the password file.  Note that as this file is tcl, and that
# it is sourced, the user better know what to put in there, as it
# could install more than just password info...  I will assume however,
# 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 {file} {
    global env int_file int_lineno
    if {! [file exists $file]} {
	send_user "\nError: password file ($file) does not exist\n"
	exit 1
    }
    file stat $file fileinfo
    if {[expr ($fileinfo(mode) & 007)] != 0000} {
	send_user "\nError: $file must not be world readable/writable\n"
	exit 1
    }
    if [catch {set fd [open $file "r"]} reason] {
	send_user "\nError: $reason\n"
	exit 1
    }
    set int_file [linsert $int_file 0 $file]
    set int_lineno [linsert $int_lineno 0 0]
    while {[gets $fd line] >= 0} {
	set tmp [lindex $int_lineno 0]; incr tmp
	lset int_lineno 0 $tmp
	eval $line
    }
    set int_file [lrange $int_file 1 end]
    set int_lineno [lrange $int_lineno 1 end]
    close $fd
}

# Log into the firewall.
# returns: 0 on success, 1 on failure
proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
    global spawn_id in_proc do_command do_script sshcmd telnetcmd
    global u_prompt p_prompt
    set in_proc 1
    set uprompt_seen 0

    # Telnet to the firewall & try to login.
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog command suffix port
	    if {"$port" == ""} {
		set retval [ catch {eval spawn [split "$telnetcmd $router"]} reason ]
	    } else {
		set retval [ catch {eval spawn [split "$telnetcmd $router $port"]} reason ]
	    }
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif [string match "ssh*" $prog] {
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    set retval [ catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason ]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	} elseif ![string compare $prog "rsh"] {
	    send_error "\nError: unsupported method: rsh\n"
	    if { $progs == 0 } {
		return 1
	    }
	    continue;
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}

    sleep 0.3

    # This helps cleanup each expect clause.
    expect_after {
	timeout {
	    global in_proc
	    send_user "\nError: TIMEOUT reached\n"
	    catch {close}; catch {wait};
	    if {$in_proc} {
	        return 1
	    } else {
	        continue
	    }
        } eof {
	    global in_proc
	    send_user "\nError: EOF received\n"
	    catch {close}; catch {wait};
	    if {$in_proc} {
	        return 1
	    } else {
	        continue
	    }
        }
    }

    # Here we get a little tricky.  There are several possibilities:
    # the firewall can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the firewall might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-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
	}
	"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)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-nocase -re "^warning: remote host denied authentication agent forwarding." {
	    exp_continue;
	}
	-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 "$u_prompt"			{
					  sleep 1;
					  send -- "$user\r"
					  set uprompt_seen 1
					  exp_continue
					}
	-re "@\[^\r\n]+\[Pp]assword:"	{
					  # ssh pwd prompt
					  sleep 1
					  send -- "$userpswd\r"
					  exp_continue
					}
	-re "$p_prompt"			{
					  sleep 1;
					  if {$uprompt_seen == 1} {
						send -- "$userpswd\r"
					  } else {
						send -- "$passwd\r"
					  }
					  exp_continue
					}
	-nocase "(press 'a' to accept):" {
					  ### accept banner
					  send "a\r"
					  exp_continue
					}
	-- "$prompt"			{ break; }
     }
    }
    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact in_proc
    set in_proc 1

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
            -re "$prompt"			{ }
	    -gl "--More--"			{ send -h " "
						  exp_continue
						}
	    -re "\[\n\r]+"			{ exp_continue }
	}
    }

    if { $do_interact == 1 } {
	interact
	return 0
    }

    send -h "exit\r"
    expect {
	-re "$prompt$"				{
						  send -h "exit\r"
						  exp_continue
						}
	-re "\[\n\r]+"				{ exp_continue }
	-gl "Configuration modified, save?"	{
						  send -h "n\r"
						  exp_continue
						}
	timeout					{ catch {close}; catch {wait};
						  return 0
						}
	eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each firewall... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user "$router\n"

    # FortiOS 2.x prompts can end in either '#' or '$'
    set prompt "\[#\\$] "

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # Figure out passwords
    if { $do_passwd || $do_enapasswd } {
	set pswd [find password $router]
	if { [llength $pswd] == 0 } {
	    send_user -- "\nError: no password for $router in $password_file.\n"
	    continue
	}
	if { $do_passwd } {
	    set passwd [join [lindex $pswd 0] ""]
	} else {
	    set passwd $userpasswd
	}
	if { $do_enapasswd } {
	    set enapasswd [join [lindex $pswd 1] ""]
	} else {
	    set enapasswd $enapasswd
	}
    } else {
	set passwd $userpasswd
	set enapasswd $enapasswd
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } else {
      set userpswd [join [find userpassword $router] ""]
      if { "$userpswd" == "" } { set userpswd $passwd }
    }

    # Figure out prompts
    set u_prompt [find userprompt $router]
    if { "$u_prompt" == "" } {
	set u_prompt "(\[Ll]ogin):"
    } else {
	set u_prompt [join [lindex $u_prompt 0] ""]
    }
    set p_prompt [find passprompt $router]
    if { "$p_prompt" == "" } {
	set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+):"
    } else {
	set p_prompt [join [lindex $p_prompt 0] ""]
    }

    # Figure out cypher type
    if {[info exists cypher]} {
      # command line cypher type
      set cyphertype $cypher
    } else {
      set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $enapasswd $prompt $cmethod $cyphertype]} {
	incr exitval
	continue
    }

    # we are logged in, now figure out the full prompt based on what the
    # device sends us.
    send "\r"
    expect {
	-re "\[\r\n]+"		{ exp_continue; }
	-re "^(.+$prompt)"	{
				  regsub -all "^\[#\\$]+\[#\\$] " $expect_out(0,string) {} junk
				  regsub -all "\[\]\[\(\)]" $junk {\\&} junk;
				  regsub "(.*) (\[#\\$]) " $junk {\1 (\([^ ]+\) )?\\\2 } prompt;
			  	}
    }

    if { $do_command || $do_script } {
	# Disable output paging.
	send "config global\r"
	expect -re $prompt	{}
	send "config system console\r"
	expect -re $prompt	{}
	send "set output standard\r"
	expect -re $prompt	{}
	send "end\r"
	expect -re $prompt	{}
	send "end\r"
	expect -re $prompt	{}
    }
    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each firewall
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/wlogin.in000644 015615 000000 00000033234 13665233101 015362 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## @PACKAGE@ @VERSION@
@copyright@
#
# wlogin - Cisco Wireless Lan Controller login
#
# Modified from clogin for use with WLCs 4/17/2008 - Josh Yost
#
# Most options are intuitive for logging into a Cisco router.
# The WLC does not have an enable mode.
#

# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

@login_top@

# Log into the router.
# returns: 0 on success, 1 on failure, -1 if rsh was used successfully
proc login { router user userpswd passwd cmethod cyphertype } {
    global spawn_id in_proc do_command do_script
    global prompt u_prompt p_prompt e_prompt sshcmd telnetcmd
    set in_proc 1
    set uprompt_seen 0

    # try each of the connection methods in $cmethod until one is successful
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port
	    if {"$port" == ""} {
		set retval [catch {eval spawn [split "$telnetcmd $router"]} reason]
	    } else {
		set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason]
	    }
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif [string match "ssh*" $prog] {
	    # ssh to the router & try to login
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	} elseif ![string compare $prog "rsh"] {
	    global command

	    if { ! $do_command } {
		if { [llength $cmethod] == 1 } {
		    send_user "\nError: rsh is an invalid method for -x and "
		    send_user "interactive logins\n"
		}
		if { $progs == 0 } {
		    return 1
		}
		continue;
	    }

	    # handle escaped ;s in commands, and ;; and ^;
	    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
	    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
	    regsub {^;} $command "\u0002;" esccommand
	    regsub -all {[\\];} $esccommand ";" command
	    regsub -all {\u0002;} $command "\u0002" esccommand
	    set sep "\u0002"
	    set commands [split $esccommand $sep]
	    set num_commands [llength $commands]
	    set rshfail 0
	    for {set i 0} {$i < $num_commands && !$rshfail} { incr i} {
		log_user 0
		set retval [ catch {spawn rsh $user@$router [lindex $commands $i] } reason ]
		if { $retval } {
		    send_user "\nError: rsh failed: $reason\n"
		    log_user 1; return 1
		}
		send_user "$router# [lindex $commands $i]\n"

		# rcmd does not get a pager and no prompts, so we just have to
		# look for failures & lines.
		expect {
		  "Connection refused"	{ catch {close}; wait;
					  send_user "\nError: Connection\
						    Refused ($prog): $router\n"
					  set rshfail 1
					}
		  -re "(Connection closed by|Connection to \[^\n\r]+ closed)" {
					  catch {close}; wait;
					  send_user "\nError: Connection\
						    closed ($prog): $router\n"
					  set rshfail 1
					}
		  "Host is unreachable"	{ catch {close}; wait;
					  send_user "\nError: Host Unreachable:\
						    $router\n"
					  set rshfail 1
					}
		  "No address associated with" {
					  catch {close}; wait;
					  send_user "\nError: Unknown host\
						    $router\n"
					  set rshfail 1
					}
		  -re "\b+"		{ exp_continue }
		  -re "\[\n\r]+"	{ send_user -- "$expect_out(buffer)"
					  exp_continue
					}
		  timeout		{ catch {close}; wait
					  send_user "\nError: TIMEOUT reached\n"
					  set rshfail 1
					}
		  eof			{ catch {close}; wait }
		}
		log_user 1
	    }
	    if { $rshfail } {
		if { !$progs } {
		    return 1
		} else {
		    continue
		}
	    }
	    # fake the end of the session for rancid.
	    send_user "$router# logout\n"
	    # return rsh "success"
	    return -1
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}
	sleep 0.3

	# This helps cleanup each expect clause.
	expect_after {
	    timeout {
		global in_proc
		send_user "\nError: TIMEOUT reached\n"
		catch {close}; wait
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    } eof {
		global in_proc
		send_user "\nError: EOF received\n"
		catch {close}; wait
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    }
	}

    # Here we get a little tricky.  There are several possibilities:
    # the router can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the router might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-re "(Connection refused|Secure connection \[^\n\r]+ refused)" {
	    catch {close}; wait
	    if !$progs {
		send_user "\nError: Connection Refused ($prog): $router\n"
		return 1
	    }
	}
	-re "(Connection closed by|Connection to \[^\n\r]+ closed)" {
	    catch {close}; 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" {
	    catch {close};
	    send_user "\nError: Unknown host $router\n"; wait; return 1
	}
	"Host is unreachable" {
	    catch {close};
	    send_user "\nError: Host Unreachable: $router\n"; wait; return 1
	}
	"No address associated with name" {
	    catch {close};
	    send_user "\nError: Unknown host $router\n"; wait; return 1
	}
	-re "(Host key not found |The authenticity of host .* be established)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-nocase -re "^warning: remote host denied authentication agent forwarding." {
	    exp_continue;
	}
	-re "(denied|Sorry)"	{
				  send_user "\nError: Check your passwd for $router\n"
				  catch {close}; wait; return 1
				}
	"Login failed"		{
				  send_user "\nError: Check your passwd for $router\n"
				  return 1
				}
	-re "% (Bad passwords|Authentication failed)"	{
				  send_user "\nError: Check your passwd for $router\n"
				  return 1
				}
	"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"
				  exp_continue;
				}
	-re "@\[^\r\n]+ $p_prompt"	{
					  # ssh pwd prompt
					  sleep 1
					  send "$userpswd\r"
					  exp_continue
					}
	-re "$u_prompt"		{
				  send "$user\r"
				  set uprompt_seen 1
				  exp_continue
				}
	-re "$p_prompt"		{
				  sleep 1
				  if {$uprompt_seen == 1} {
					send "$userpswd\r"
				  } else {
					send "$passwd\r"
				  }
				  exp_continue
				}
	-re "$prompt"		{ break; }
	"Login invalid"		{
				  send_user "\nError: Invalid login: $router\n";
				  catch {close}; wait; return 1
				}
     }
    }

    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact in_proc do_saveconfig
    set in_proc 1

    # match cisco config mode prompts too, such as router(config-if)#,
    # but catalyst does not change in this fashion.
    regsub -all {^(.*)([#>])$} $prompt {\1} reprompt
    append reprompt {([^#>\r\n]+)?[#>]}

    # this is the only way i see to get rid of more prompts in o/p..grrrrr
    log_user 0

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    # the pager can not be turned off on the PIX, so we have to look
    # for the "More" prompt.  the extreme is equally obnoxious, with a
    # global switch in the config.
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
	    -re "\b+"				{ exp_continue }
	    -re "^\[^\n\r *]*$reprompt"		{ send_user -- "$expect_out(buffer)"
						}
	    -re "^\[^\n\r]*$reprompt."		{ send_user -- "$expect_out(buffer)"
						  exp_continue }
	    -re "^--More--\r\n"			{ # specific match c1900 pager
						  send " "
						  exp_continue }
	    -re "\[\n\r]+"			{ send_user -- "$expect_out(buffer)"
						  exp_continue }
	    -re "\[^\r\n]*Press  to cont\[^\r\n]*"	{
						  send " "
						  # bloody ^[[2K after " "
						  expect {
							-re "^\[^\r\n]*\r" {}
							}
						  exp_continue
						}
	    -re "^Press Enter to continue\.\.\.\[^\n\r]*"		{
						  send "\r"
						  exp_continue }
	    -re "^Press Enter to continue or \[^\n\r]* abort"	{
						  send "\r"
						  exp_continue }
	    -re "^--More or \[^\n\r]* abort"	{
						  send " "
						  exp_continue }
	    -re "^ *--More--\[^\n\r]*"		{
						  send " "
						  exp_continue }
	    -re "^<-+ More -+>\[^\n\r]*"	{
						  send_user -- "$expect_out(buffer)"
						  send " "
						  exp_continue }
	}
    }
    log_user 1

    if { $do_interact == 1 } {
	interact
	return 0
    }

    # Send an Unconditional CTRL Z to exit out of any context the WLC prompt
    # may be in
    send "\032"

    expect {
	-re "(.+)>"				{ # the Cisco CE and Jnx ERX
						  # return to non-enabled mode
						  # on exit in enabled mode.
						  send -h "logout\r"
						  exp_continue;
						}
	-re "Would you like to save them .+"	{
						  if {$do_saveconfig} {
						    catch {send "y\r"}
						  } else {
						    catch {send "n\r"}
						  }
						  exp_continue
						}
	-re "\[\n\r]+"				{ exp_continue }
	timeout					{ return 0 }
	eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each router... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user -- "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # Figure out the prompt.
    set prompt ">"

    # 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] ""]
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } else {
      set userpswd [join [find userpassword $router] ""]
      if { "$userpswd" == "" } { set userpswd $passwd }
    }

    # Figure out prompts
    set u_prompt [find userprompt $router]
    if { "$u_prompt" == "" } {
	set u_prompt "(Username|Login|login|user name|User):"
    } else {
	set u_prompt [join [lindex $u_prompt 0] ""]
    }
    set p_prompt [find passprompt $router]
    if { "$p_prompt" == "" } {
	set p_prompt "(\[Pp]assword|passwd):"
    } else {
	set p_prompt [join [lindex $p_prompt 0] ""]
    }

    # Figure out cypher type
    if {[info exists cypher]} {
        # command line cypher type
        set cyphertype $cypher
    } else {
        set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $cmethod $cyphertype]} {
	incr exitval
	# if login failed or rsh was successful, move on to the next device
	continue
    }

    # we are logged in, now figure out the full prompt
    send "\r"
    expect {
	-re "\[\r\n]+"		{ exp_continue; }
	-re "^.+$prompt"	{ set junk $expect_out(0,string);
				  regsub -all "\[\]\[)(]" $junk {\\&} prompt;
				}
    }

    if { $do_command || $do_script } {
	send "config paging disable\r"
	expect -re $prompt	{}
    }
    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	source $sfile
	close
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each router
    wait
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/par.c000644 015615 000000 00000107434 13534015653 014472 0ustar00heaswheel000000 000000 /*
 * Copyright (c) 1997-2019 by Henry Kilmer and John Heasley
 * All rights reserved.
 *
 * This code is derived from software contributed to and maintained by
 * Henry Kilmer, John Heasley, Andrew Partan,
 * Pete Whiting, Austin Schutz, and Andrew Fort.
 *
 * 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. Neither the name of RANCID nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
 *
 * It is the request of the authors, but not a condition of license, that
 * parties packaging or redistributing RANCID NOT distribute altered versions
 * of the etc/rancid.types.base file nor alter how this file is processed nor
 * when in relation to etc/rancid.types.conf.  The goal of this is to help
 * suppress our support costs.  If it becomes a problem, this could become a
 * condition of license.
 * 
 *  The expect login scripts were based on Erik Sherk's gwtn, by permission.
 * 
 *  The original looking glass software was written by Ed Kern, provided by
 *  permission and modified beyond recognition.
 *
 * perl version of par is Copyright (C) 1997-2002 by Henry Kilmer, Erik
 * Sherk and Pete Whiting.
 *
 * PAR - parallel processing of command
 *
 * par runs a command N times in parallel.  It will accept a list of arguments
 * for command-line replacement in the command.  If the list entry begins
 * with a ":" the remainder of the line is the command to run ("{}" will be
 * replaced with each subsequent item in the list).  If the list entry begins
 * with a "#", the entry is ignored.  If a command is defined (either with
 * the -c or with a : line) any entry thereafter will be applied to the
 * command by replacing the {} brackets.  If no cammand is defined, then each
 * line is assumed to be a command to be run.
 *
 * differences from perl version:
 * - when par rx's a hup/int/term/quit signal, it does not print out the cmds
 *   that will not be run.
 * - when par rx's a hup/int/term/quit signal, it does not exit immediately
 *   after sending kill to running jobs.  it waits for them to exit so that
 *   they are cleaned-up properly.  if a second signal is rx'd, it dies
 *   immediately.
 */
#include "config.h"
#if HAVE_STDARG_H
# include 
#endif
#if HAVE_STDINT_H
# include 
#endif
#if HAVE_STDLIB_H
# include 
#endif
#if HAVE_UNISTD_H
# include 
#endif

#include 
#include 
#include 
#include 
#include 
#include 
#ifdef HAVE_STRING_H
# include 
#endif
#ifdef HAVE_STRINGS_H
# include 
#endif
#include 
#ifdef HAVE_WAIT_H
# include 
#elif HAVE_SYS_WAIT_H
# include 
#endif
#include 
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif
#include 
#include 

#include "version.h"

extern char	**environ;

typedef struct {
	int	n;				/* proc n of n_opt processes */
	pid_t	pid;				/* child pid */
	char	*logfname;			/* logfile name */
	FILE	*logfile;
	int	logfd;				/* logfile FD */
	pid_t	xpid;				/* xterm child pid */
} child;

char		*progname;
child		*progeny;
int		debug = 0,
		chld_wait = 0,			/* there are children */
		signaled = 0;			/* kill signal rx'd */
int		devnull;			/* /dev/null */

/* args */
int		F_opt = 0,
		H_opt = 0,
		e_opt = 0,
		f_opt = 0,
		i_opt = 0,
		n_opt = 3,
		p_opt = 0,
		q_opt = 0,
		x_opt = 0,
		ifile = 0;			/* argv index to input files */
char		*c_opt = NULL,
		*l_opt = "par.log";

FILE		*errfp,				/* stderr fp */
		*logfile;			/* logfile fp */
sigset_t	set_chld;			/* SIGCHLD {un}blocking */

void		arg_free(char ***);
int		arg_mash(char **, char **);
int		arg_replace(char **, char **, char **, char ***);
#ifndef HAVE_ASPRINTF
int		asprintf(char **, char const *, ...);
#endif
int		dispatch_cmd(char **, char **);
int		execcmd(child *, char **);
int		line_split(const char *, char ***);
int		read_input(char *, FILE **, int *, char ***, char ***);
void		reopenfds(child *);
int		run_cmd(child *, char **, char **);
int		shcmd(child *, char **);
void		usage(void);
void		vers(void);
int		xtermcmd(child *, char **);
void		xtermlog(child *);

RETSIGTYPE	handler(int);
RETSIGTYPE	reapchild(int);

int
main(int argc, char **argv, char **envp)
{
    time_t		t;
    int			i,
			line;
    char		**cmd = NULL,		/* cmd (c_opt or from input) */
			**args = NULL;		/* cmd argv */
    FILE		*F;			/* input file */

    /* get just the basename() of our exec() name and strip .* off the end */
    if ((progname = strrchr(argv[0], '/')) != NULL)
	progname += 1;
    else
	progname = argv[0];
    if (strrchr(progname, '.') != NULL)
	*(strrchr(progname, '.')) = '\0';

    /* make sure stderr points to something */
    if ((devnull = open("/dev/null", O_RDWR, 0666)) == -1) {
	printf("Error: can not open /dev/null: %s\n", strerror(errno));
	exit(EX_OSERR);
    }
    if (stderr == NULL) {
	if ((errfp = fdopen(devnull, "w+")) == NULL) {
	    printf("Error: can not open /dev/null: %s\n", strerror(errno));
	    exit(EX_OSERR);
	}
    } else
	errfp = stderr;

    while ((i = getopt(argc, argv, "FHdefhiqxvc:e:l:n:p:")) != -1 )
	switch (i) {
	case 'F':
	    F_opt = 1;
	    break;
	case 'H':
	    H_opt = 1;
	    break;
	case 'c':	/* command to run */
	    c_opt = optarg;
	    break;
	case 'd':
	    debug++;
	    break;
	case 'e':	/* exec args split by spaces rather than using sh -c */
	    e_opt = 1;
	    if (i_opt) {
		fprintf(errfp, "Warning: -e non-sensical with -i\n");
	    }
	    break;
	case 'f':	/* no file or stdin, just run quantity of command */
	    f_opt = 1;
	    break;
	case 'l':	/* logfile */
	    if (q_opt) {
		fprintf(errfp, "Warning: -q non-sensical with -x or -l\n");
		q_opt = 0;
	    }
	    l_opt = optarg;
	    break;
	case 'i':	/* run commands through interactive xterms */
	    i_opt = 1;
	    if (e_opt) {
		fprintf(errfp, "Warning: -i non-sensical with -e\n");
	    }
	    break;
	case 'n':	/* number of processes to run to run at once, dflt 3 */
	    n_opt = atoi(optarg);
	    if (n_opt < 1) {
		fprintf(errfp, "Warning: -n < 1 is non-sensical\n");
		n_opt = 3;
	    }
	    break;
	case 'p':	/* pause # seconds between forks, dflt 0 */
	    p_opt = atoi(optarg);
	    break;
	case 'q':	/* quiet mode (dont log anything to logfiles */
	    if (x_opt) {
		fprintf(errfp, "Warning: -q non-sensical with -x or -l\n");
		x_opt = 0;
	    }
	    q_opt = 1;
	    break;
	case 'x':	/* view par logs as they run through an xterm */
	    if (q_opt) {
		fprintf(errfp, "Warning: -q non-sensical with -x or -l\n");
		q_opt = 0;
	    }
	    x_opt = 1;
	    break;
	case 'v':
	    vers();
	    return(EX_OK);
	case 'h':
	default:
	    usage();
	    return(EX_USAGE);
	}

    /* -f requires -c */
    if (f_opt && ! c_opt) {
	fprintf(errfp, "usage: -f requires -c option\n");
	usage();
	return(EX_USAGE);
    } else if (f_opt && (argc - optind) != 0) {
	/* extraneous command-line arguments with -f */
	fprintf(errfp, "usage: extraneous command-line arguments with -f "
		"option\n");
	usage();
	return(EX_USAGE);
    } else if (argc - optind == 0) {
	/* if no -f and no cmd-line input files, read from stdin */
	ifile = -1;
    } else if (c_opt == NULL && (argc - optind) == 0) {
	/* args after options are input file(s) */
	fprintf(errfp, "usage: either -c or a command file must be supplied\n");
	usage();
	return(EX_USAGE);
    } else
	ifile = optind;

    /* grab space to keep track of our children */
    if ((progeny = (child *)malloc(sizeof(child) * n_opt)) == NULL) {
	fprintf(errfp, "Error: memory allocation failed: %s\n",
		strerror(errno));
	exit(EX_TEMPFAIL);
    } else
	memset((void *)progeny, 0, sizeof(child) * n_opt);

    /* set-up child structures */
    t = time(NULL);
    if (! q_opt) {
	for (i = 0; i < n_opt; i++) {
	    /* open the logfile or use stderr */
	    if (asprintf(&progeny[i].logfname,
			 "%s.%lu.%d", l_opt, (unsigned long)t, i) < 1) {
		fprintf(errfp, "Error: could not allocate space for process "
			"%d's log filename\n", i);
		exit(EX_TEMPFAIL);
	    }
	    if ((progeny[i].logfd = open(progeny[i].logfname,
					 O_WRONLY | O_CREAT, 0666)) == -1) {
		fprintf(errfp, "Error: could not open %s for writing: %s\n",
			progeny[i].logfname, strerror(errno));
		exit(EX_CANTCREAT);
	    }
	    if ((progeny[i].logfile = fdopen(progeny[i].logfd, "w")) == NULL) {
		fprintf(errfp, "Error: could not open %s for writing: %s\n",
			progeny[i].logfname, strerror(errno));
		exit(EX_CANTCREAT);
	    }

	    /* start an xterm for log file */
	    if (x_opt)
		xtermlog(&progeny[i]);
	}
    }

    /* prepare to accept signals */
    signal(SIGHUP, handler);
    signal(SIGINT, handler);
    signal(SIGTERM, handler);
    signal(SIGQUIT, handler);
    signal(SIGCHLD, reapchild);
    sigemptyset(&set_chld);
    sigaddset(&set_chld, SIGCHLD);

    /* if argv[ifile] is NULL and stdin is closed, then f_opt is implicit */
    if (argv[ifile] == NULL && stdin == NULL)
	f_opt = 1;

    /*
     * command dispatch starts here.
     *
     * -f means just run the -c command -n times.  any args become "".
     */
    if (f_opt) {
	if ((i = line_split(c_opt, &cmd))) {
	    fprintf(errfp, "Error: failed to build command");
	    if (i == ENOMEM)
		fprintf(errfp, ": %s\n", strerror(i));
	    else
		fprintf(errfp, "\n");
	} else {
	    for (i = 0; !signaled && i < n_opt; i++) {
		progeny[i].n = i + 1;
			/* XXX: check retcode from *cmd()? */
		run_cmd(&progeny[i], cmd, args);
	    }
	    if (args != NULL)
		arg_free(&args);
	}
    } else if (ifile > 0) {
	/*
	 * input files were specified on the command-line, read each as input
	 */
	F = NULL; cmd = NULL; args = NULL;
	for ( ; !signaled && ifile < argc; ifile++) {
	    while (!signaled &&
		   (i = read_input(argv[ifile], &F, &line, &cmd, &args)) == 0) {
		while (dispatch_cmd(cmd, args) == EAGAIN)
		    pause();
		if (args != NULL)
		    arg_free(&args);
	    }
	    /* XXX: if (i == EOF) */
	    if (cmd != NULL)
		arg_free(&cmd);
	    if (args != NULL)
		arg_free(&args);
	}
    } else {
	/* read stdin as input */
	F = stdin;
	line = 1; cmd = NULL;  args = NULL;
	while (!signaled &&
		(i = read_input("(stdin)", &F, &line, &cmd, &args)) == 0) {
	    while (dispatch_cmd(cmd, args) == EAGAIN)
		pause();
	    if (*args != NULL)
		arg_free(&args);
	}
	if (cmd != NULL)
	    arg_free(&cmd);
	if (args != NULL)
	    arg_free(&args);
    }

    /*
     * after all the work is assigned we wait for all the children to
     * finish and be reaped.  ie: so all the pid's in the child structure
     * will be zero.
     */
    if (debug)
	fprintf(errfp, "All work assigned.  Waiting for remaining processes."
		"\n");
    while (1) {
	/* block sigchld while we search the child table */
	sigprocmask(SIG_BLOCK, &set_chld, NULL);

	for (i = 0; i < n_opt; i++) {
	    if (progeny[i].pid != 0) {
		chld_wait = 1;
		break;
            }
	}

	sigprocmask(SIG_UNBLOCK, &set_chld, NULL);
	if (chld_wait == 1) {
	    pause();
	} else if (chld_wait == 0)
	    break;
	chld_wait = 0;
    }

    /* close the log files */
    for (i = 0; i < n_opt; i++) {
	if (progeny[i].logfile != NULL)
	    fclose(progeny[i].logfile);
    }

    if (debug)
	fprintf(errfp, "Complete\n");

    return(EX_OK);
}

/*
 * free space in and of a char[][] from line_split()/arg_replace()
 */
void
arg_free(char ***args)
{
    int		i;

    if (args == NULL || *args == NULL)
	return;

    for (i = 0; (*args)[i] != NULL; i++)
	free((*args)[i]);

    free(*args);
    *args = NULL;

    return;
}

/*
 * arg to sh -c used in shcmd() must be 1 argument.  returns 0 else errno.
 *
 * NOTE: dst[][] is assumed to have 2 spaces of which [0][] will be used.
 *	 dst[1] is, of course, the NULL terminator.  The caller will have to
 *	 free dst[0].
 */
int
arg_mash(char **dst, char **src)
{
    int		i = 0;
    size_t	len = 0;
    char	*ptr;

    while (src[i] != NULL)
	len += strlen(src[i++]);
    len += i + 1;

    if ((dst[0] = (char *)malloc(sizeof(char *) * len)) == NULL)
	return(errno);
    memset(dst[0], 0, len);

    i = 0; ptr = dst[0];
    while (src[i] != NULL) {
	len = strlen(src[i]);
	memcpy(ptr, src[i++], len);
	ptr += len;
	if (src[i] != NULL)
	    *ptr++ = ' ';
    }

    return(0);
}

/*
 * takes a NULL terminated command (cmd[][]) like {"echo", "{}"} whose args
 * are stored in NULL terminated args[][] and sequentially replaces {}s
 * from args[][].  any {}s not matching up to an arg are replaced with "".
 *
 * args found in tail[][] are concatenated to the end new[][] without any
 * interpretation.  ie: if arg_replace() were already called but something
 * needs to be prepended or appended.
 *
 * it returns an argv[][], in new***, which begins with the command followed
 * by the args and is null terminated so that is suitable for execvp(), and
 * 0 or errno to indicate success or an error.
 *
 * NOTE: if arg_replace() succeeds (returns 0), it is the callers
 *	  responsibility to free the space with arg_free().
 */
int
arg_replace(char **cmd, char **args, char **tail, char ***new)
{
    int			argn = 0,		/* which arg[] is next */
			nargs = 0,		/* # of entries in args[][] */
			ncmds = 0,		/* # of entries in cmd[][] */
			ntail = 0,		/* # of entries in tail[][] */
			atick = 0,		/* single quoted string toggle
						 * in args[][]
						 */
			aquotes = 0,		/* double quoted string toggle
						 * in args[][]
						 */
			quotes = 0;		/* " quoted string toggle */
    size_t		len = 0;		/* length of cmd - leading sp */
    char		*tick = NULL,		/* ' quoted string */
			*ptr;
    register int	a, b, c, n;
    char		buf[LINE_MAX * 2];	/* temporary space */

    /* if new is null, that is an internal error */
    if (new == NULL || (cmd == NULL && args == NULL))
	abort();

    if (cmd != NULL)
	while (cmd[ncmds] != NULL)
	    ncmds++;
    if (args != NULL)
	while (args[nargs] != NULL)
	    nargs++;
    if (tail != NULL)
	while (tail[ntail] != NULL)
	    ntail++;

    /* create space for ncmds + ntail + NULL terminator */
    if ((*new = (char **)malloc(sizeof(char *) * (ncmds + ntail + 1))) == NULL)
	return(ENOMEM);
    memset(*new, 0, sizeof(char *) * (ncmds + ntail + 1));

    /*
     * now look through each cmd[][] for {}s and replace them, taking care to
     * follow shell quoting/escape semantics
     */
    memset(buf, 0, LINE_MAX * 2);
    for (n = 0; n < ncmds; n++) {
	c = b = 0;
	ptr = cmd[n];
	while (cmd[n][c] != '\0') {
	    /* check buf len to be sure space remains */
	    if ((LINE_MAX * 2) - b < 2)
		return(ENOMEM);

	    switch (ptr[c]) {
	    case '\\':
		if (quotes) {
		    if (ptr[c + 1] == 'n') {
			buf[b++] = '\n';
			c += 2;
		    } else {
			buf[b++] = ptr[c++];
			buf[b++] = ptr[c++];
		    }
		} else {
		    if (ptr[c + 1] == 'n') {
			buf[b++] = '\n';
			c += 2;
		    } else if (ptr[c + 1] == 'r') {
			buf[b++] = '\r';
			c += 2;
		    } else if (ptr[c + 1] == 't') {
			buf[b++] = '\t';
			c += 2;
		    } else {
			buf[b++] = ptr[++c];
			c += 2;
		    }
		}
		break;
	    case '\'':
		/*
		 * shell preserves the meaning of all chars between single
		 * quotes, including backslashes.  so, it is not possible to
		 * put a single quote inside a single quoted string in shell.
		 * just copy everything up to the next '.
		 */
		c++;
		if ((tick = index(ptr + c, '\'')) == NULL) {
		    /* unmatched quotes */
		    fprintf(errfp, "Error: unmatched single quotes\n");
		    return(EX_DATAERR);
		}
		len = tick - (ptr + c);
		if ((b + len + 1) > (LINE_MAX * 2))
		    return(ENOMEM);
		memcpy(&buf[b], &ptr[c], len);
		c += len + 1; b += len;
		break;
	    case '"':
		/*
		 * the shell would recognize , , and
		 *  in double-quoted strings.  we will do
		 * like-wise, though  and  are
		 * meaningless to us, and include our {}s.
		 */
		quotes ^= 1;
		if (e_opt)
		    c++;
		else
		    buf[b++] = ptr[c++];
		break;
	    case '{':
		/* insert arg[n], if the next char is '}' */
		if (ptr[c + 1] == '}') {
		    if (argn < nargs) {
			len = strlen(args[argn]);
			/* perform shell quoting on the arg */
			a = 0;
			while (args[argn][a] != '\0') {
			    if (b >= (LINE_MAX * 2 - 1)) {
				fprintf(errfp, "Error: buffer space exhausted"
					"\n");
				return(ENOMEM);
			    }
			    switch (args[argn][a]) {
			    case '\'':
				if (!atick)
				    atick ^= 1;
				a++;
				break;
			    case '\\':
				if (atick) {
				    buf[b++] = args[argn][a++];
				} else if (args[argn][a + 1] == 'n') {
				    buf[b++] = '\n';
				    a += 2;
				} else if (args[argn][a + 1] == 'r') {
				    buf[b++] = '\r';
				    a += 2;
				} else if (args[argn][a + 1] == 't') {
				    buf[b++] = '\t';
				    a += 2;
				} else {
				    buf[b++] = args[argn][++a];
				    a++;
				}
				break;
			    case '"':
				if (!atick) {
				    aquotes ^= 1;
				    a++;
				    break;
				}
			    default:
				buf[b++] = args[argn][a++];
			    }
			}
			argn++;
		    }

		    c += 2;
		    break;
		}

		/* fall-through, if not "{}" */
	    default:
		buf[b++] = ptr[c++];
	    }
	}
	buf[b] = '\0';

	if (quotes) {
	    fprintf(errfp, "Error: unmatched double quotes\n");
	    return(EX_DATAERR);
	}

	/* copy the full arg */
	if (asprintf(&(*new)[n], "%s", buf) == -1)
	    return(errno);
    }

    /* tack on tail[][], if any exist */
    if (ntail) {
	for (b = 0; b < ntail; b++) {
	    if (asprintf(&(*new)[n], "%s", tail[b]) == -1)
		return(errno);
	    n++;
	}
    }

    return(0);
}

#ifndef HAVE_ASPRINTF
/* crude emulation of asprintf() */
int
asprintf(char **ret, const char *format, ...)
{
    va_list	ap;
    char	*newbuf;
    int		len,
		vlen;

    if (ret == NULL) {
	errno = EINVAL;
	return(-1);
    }

    if (format == NULL) {
	*ret = NULL;
	return(0);
    }

    va_start(ap, format);
    len = strlen(format) + 1;
    if (ap != NULL)
	len = len * 2;
    va_end(ap);

    if ((*ret = (char *)malloc(len)) == NULL) {
	errno = ENOMEM;
	*ret = NULL;
	return(-1);
    }

    while (1) {
	va_start(ap, format);
	if ((vlen = vsnprintf(*ret, len, format, ap)) < len &&
	    (vlen != -1)) {
	    va_end(ap);
	    return(vlen);
	}
	va_end(ap);
	len = vlen + 1;
	if ((newbuf = realloc((void *)*ret, len)) == NULL) {
	    free(*ret);
	    *ret = NULL;
	    errno = ENOMEM;
	    return(-1);
	}
	*ret = newbuf;
    }
}
#endif

/*
 * find a child/process slot (one of n_opt) to run the command and use
 * run_cmd() to start it.
 *
 * returns EAGAIN if there were no available child slots else the return
 * value from run_cmd.  0 means success in dispatching the command.
 */
int
dispatch_cmd(char **cmd, char **args)
{
    int		i;
    static int	cmd_num = 1;

    /* block sigchld while we search the child table */
    sigprocmask(SIG_BLOCK, &set_chld, NULL);

    for (i = 0; i < n_opt; i++) {
	if (progeny[i].pid != 0)
	    continue;

	progeny[i].n = cmd_num++;

	sigprocmask(SIG_UNBLOCK, &set_chld, NULL);
	return(run_cmd(&progeny[i], cmd, args));
    }

    sigprocmask(SIG_UNBLOCK, &set_chld, NULL);

    return(EAGAIN);
}

/*
 * start a command via an exec, after breaking up the arguments
 */
int
execcmd(child *c, char **cmd)
{
    char	*mashed[] = { NULL, NULL };
    int		status;
    time_t	t;

    /* XXX: is this right? */
    if (cmd == NULL)
	return(ENOEXEC);

    /* build cmd string for logs */
    if ((status = arg_mash(mashed, cmd))) {
	/* XXX: is this err msg always proper? will only ret true or ENOMEM? */
	fprintf(errfp, "Error: memory allocation failed: %s\n",
		strerror(errno));
	return(status);
    }

    /* block sigchld so we quickly reap it ourselves */
    sigprocmask(SIG_BLOCK, &set_chld, NULL);

    if (c->logfile && !H_opt) {
	char	*ct;
	t = time(NULL);
		/* XXX: build a complete cmd line */
	ct = ctime(&t); ct[strlen(ct) - 1] = '\0';
	fprintf(c->logfile, "!!!!!!!\n!%s: %s\n!!!!!!!\n", ct, mashed[0]);
	fflush(c->logfile);
    }

    if ((c->pid = fork()) == 0) {
	/* child */
	signal(SIGCHLD, SIG_DFL);
        sigprocmask(SIG_UNBLOCK, &set_chld, NULL);
	if (debug > 1) {
	    fprintf(errfp, "fork(sh -c %s ...) pid %d\n", mashed[0],
		    (uint32_t)getpid());
	}
	/* reassign stdout and stderr to the log file, stdin to /dev/null */
	reopenfds(c);

	execvp(cmd[0], cmd);

	/* not reached, unless exec() fails */
	fprintf(errfp, "Error: exec(%s) failed: %s\n", cmd[0], strerror(errno));
		/* XXX: should we return errno instead? */
	exit(EX_UNAVAILABLE);
    } else {
	if (debug)
	    fprintf(errfp, "\nStarting %d/%d %s: process id=%d\n",
		    c->n, n_opt, mashed[0], (uint32_t)c->pid);
	if (c->pid == -1) {
	    fprintf(errfp, "Error: fork() failed: %s\n", strerror(errno));
		/* XXX: wait on c->pid when its -1?  arg is valid, but
			if the fork failed will have a procstruct to return
			status? */
	    waitpid(c->pid, &status, WNOHANG);
	    c->pid = 0;
	}
    }

    if (mashed[0] != NULL)
	free(mashed[0]);

    sigprocmask(SIG_UNBLOCK, &set_chld, NULL);

    return(0);
}

/*
 * split a line into an arg[][] with shell single/double-quoting semantics.
 * quotes are retained and should be handled by arg_replace();
 */
int
line_split(const char *line, char ***args)
{
    char	*cp;
    int		argn = 0;			/* current arg */
    size_t	b,
		c,
		llen,				/* length of line */
		nargs = 0;
    int		quotes = 0;			/* track double quotes */

    if (args == NULL)
	abort();

    /* if line is NULL, just create arg[0][NULL] */
    if (line == NULL) {
        if ((*args = (char **)malloc(sizeof(char **))) == NULL)
	    return(errno);
	memset(*args, 0, sizeof(char **));
    } else {
	/* skip leading/trailing whitespace in line */
        while (*line == ' ' || *line == '\t')
	    line++;
	llen = strlen(line);
        while ((line[llen] == ' ' || line[llen] == '\t') && llen > 0)
	    llen--;

	/*
	 * just count spaces for args[][] malloc, this will waste memory when
	 * spaces are in quoted args, but do not expect it to be a big deal.
	 */
	c = 0;
	while (c < llen) {
	    if (line[c] == ' ' || line[c] == '\t')
		nargs++;
	    c++;
	}
	/* gratuitous last arg and args[][NULL] */
	nargs += 2;

	if ((*args = (char **)malloc(sizeof(char **) * nargs)) == NULL)
	    return(errno);
	memset(*args, 0, sizeof(char **) * nargs);

		/* XXX: do we need checks here for exceeding llen? */
	/*
	 * copy the args into place.
	 * preserve and observe shell style quoting as we go.
	 */
	for (b = c = 0; 1; ) {
	    switch(line[c]) {
	    case '\\':
		c++;
		if (line[c] == '\0') {
		    fprintf(errfp, "Error: premature end of input\n");
				/* XXX: not the right return code */
		    return(ENOMEM);
		}
		c++;
		break;
	    case '\'':
		c++;
		if ((cp = index(&line[c], '\'')) == NULL) {
		    /* unmatched quotes */
		    fprintf(errfp, "Error: unmatched single quotes\n");
		    return(EINVAL);
		}
		c += cp - &line[c] + 1;
		break;
	    case '\"':
		quotes ^= 1;
		c++;
		break;
	    case '\0':
		if (quotes) {
		    fprintf(errfp, "Error: unmatched quotes\n");
			/* XXX: not the right return code */
		    fprintf(errfp, "Error: unmatched single quotes\n");
		    return(EINVAL);
		}
	    case '\t':
	    case ' ':
		if (quotes) {
		    c++;
		    continue;
		}
		if (((*args)[argn] =
		     (char *)malloc(sizeof(char) * (c - b + 1))) == NULL) {
		    return(ENOMEM);
		}

		memcpy((*args)[argn], &line[b], (c - b));
		(*args)[argn][c - b] = '\0';
		argn++;

		if (line[c] == '\0')
		    goto END;

		/* skip adjacent spaces */
		while (line[c] == ' ' || line[c] == '\t')
		    c++;
		b = c;
		break;
	    default:
		c++;
	    }
	}
    }
END:

    return(0);
}

/*
 * if F is NULL, we open fname.
 *
 * read first line as a command and subsequent lines as either commands or
 * args depending upon c_opt and the first line.  basically;
 * - if the first char of the first line is ':', then what follows it is the
 *   command.
 * - if what follows is null, then the command is c_opt (-c) and subsequent
 *   lines are args
 * - if -c was not specified, then each subsequent line is a command without
 *   arg substitution
 * - if the ':' of the first line was ommitted, then we proceed as if it had
 *   been but the command was empty
 *
 * return 0 on success, EOF at end of file, else errno with an errmsg in cmd.
 * note: any space allocated for cmd or args must be free'd by the caller
 *	 with free() or arg_free().
 */
int
read_input(char *fname, FILE **F, int *line, char ***cmd, char ***args)
{
    int		e;
    char	buf[LINE_MAX + 1];

    if (cmd == NULL || args == NULL)
	abort();

    if (*F == NULL) {
	if (fname == NULL)
	    abort();

	if ((*F = fopen(fname, "r")) == NULL) {
	    e = errno;
	    fprintf(errfp, "Error: open(%s) failed: %s\n", fname, strerror(e));
	    return(e);
	}
	*cmd = NULL;  *args = NULL;
	*line = 1;
    }

    /* first line might be a command */
    if (*line == 1) {
	switch ((e = fgetc(*F))) {
	case EOF:
	    goto ERR;
	    break;
	case ':':
	    if (fgets(buf, LINE_MAX + 1, *F) == NULL)
		goto ERR;
	    (*line)++;
	    e = strlen(buf);
	    if (buf[e - 1] == '\n') {
		buf[e - 1] = '\0';
	    } /* else
		XXX: finish this, we didnt get the whole line */
	    if ((e = line_split(buf, cmd))) {
		fprintf(errfp, "Error: parsing command: %s\n", strerror(e));
		fclose(*F); *F = NULL;
		return(e);
	    }
	    break;
	default:
	    ungetc(e, *F);
	    if (*cmd == NULL && c_opt != NULL)
		if ((e = line_split(c_opt, cmd))) {
		    fprintf(errfp, "Error: parsing command: %s\n", strerror(e));
		    fclose(*F); *F = NULL;
		    return(e);
		}
	}
    }

    /* make sure fname isnt NULL for error printfs */
    if (fname == NULL)
	fname = "(unknown)";

NEXT:
    /* next line */
    if (fgets(buf, LINE_MAX + 1, *F) == NULL)
	goto ERR;
    (*line)++;
    if (buf[0] == '#')
	goto NEXT;

    /*
     * if there isnt a \n on the end, either we lacked buffer space or
     * the last line of the file lacks a \n
     */
    e = strlen(buf);
    if (buf[e - 1] == '\n') {
	buf[e - 1] = '\0';
    } /* else
	XXX: finish this */

    /* split the line into an args[][] */
    if ((e = line_split(buf, args))) {
	fprintf(errfp, "Error: parsing args: %s\n", strerror(e));
	return(e);
    }

    return(0);

ERR:
    /* handle FILE error */
    if (feof(*F)) {
	e = EOF;
    } else {
	e = errno;
	fprintf(errfp, "Error: read(%s) failed: %s\n", fname, strerror(e));
    }
    fclose(*F); *F = NULL;
    return(e);
}

/*
 * reassign stdout and stderr to the log file and stdin to /dev/null.
 * called after fork and before exec() of the child processes.
 */
void
reopenfds(child *c)
{
    int		fd = STDERR_FILENO + 1;

    /* stderr */
    if (! q_opt) {
	if (c->logfd != STDERR_FILENO) {
	    if (dup2(c->logfd, STDERR_FILENO) == -1)
		abort();
	    close(c->logfd);
	    c->logfd = STDERR_FILENO;
	}
	/* stdout */
	if (dup2(c->logfd, STDOUT_FILENO) == -1)
	    abort();
    }
    /* stdin */
    if (dup2(devnull, STDIN_FILENO) == -1)
	abort();

    /* close anything above stderr */
    while (fd < 10)
	close(fd++);

    return;
}

/*
 * start a command.
 */
int
run_cmd(child *c, char **cmd, char **args)
{
    char	**newcmd = NULL;
    int		e;

    if (c == NULL)
	return(0);

    if (cmd == NULL && args == NULL)
	return(ENOEXEC);

    /* if cmd is NULL, swap it with args */
    if (cmd == NULL) {
	cmd = args;
	args = NULL;
    }

    /* preform arg subsitution */
    if ((e = arg_replace(cmd, args, NULL, &newcmd)) == 0) {
	if (i_opt) {
	    e = xtermcmd(c, newcmd);
	} else if (e_opt) {
	    e = execcmd(c, newcmd);
	} else
	    e = shcmd(c, newcmd);

	arg_free(&newcmd);
    }

    if (p_opt) {
	sigprocmask(SIG_BLOCK, &set_chld, NULL);
	sleep(p_opt);
	sigprocmask(SIG_UNBLOCK, &set_chld, NULL);
    }

    return(e);
}

/*
 * start a command whose output is concatenated to the childs logfile via
 * sh -c.
 */
int
shcmd(child *c, char **cmd)
{
    char	*sh[] = { "sh", "-c", NULL },
		*mashed[] = { NULL, NULL },
		**new;
    int		status;
    time_t	t;

    /* XXX: is this right? */
    if (cmd == NULL)
	return(ENOEXEC);

    /* build new command */
    if ((status = arg_mash(mashed, cmd))) {
	/* XXX: is this err msg always proper? will only ret true or ENOMEM? */
	fprintf(errfp, "Error: memory allocation failed: %s\n",
		strerror(errno));
	return(status);
    }
    if ((status = arg_replace(sh, NULL, mashed, &new))) {
	/* XXX: is this err msg always proper? will only ret true or ENOMEM? */
	fprintf(errfp, "Error: memory allocation failed: %s\n",
		strerror(errno));
	return(status);
    }

    /* block sigchld so we quickly reap it ourselves */
    sigprocmask(SIG_BLOCK, &set_chld, NULL);

    if (c->logfile && !H_opt) {
	char	*ct;
	t = time(NULL);
	ct = ctime(&t); ct[strlen(ct) - 1] = '\0';
	fprintf(c->logfile, "!!!!!!!\n!%s: %s\n!!!!!!!\n", ct, mashed[0]);
	fflush(c->logfile);
    }

    if ((c->pid = fork()) == 0) {
	/* child */
	signal(SIGCHLD, SIG_DFL);
        sigprocmask(SIG_UNBLOCK, &set_chld, NULL);
	if (debug > 1) {
	    fprintf(errfp, "fork(sh -c %s ...) pid %d\n", mashed[0],
		    (uint32_t)getpid());
	}
	/* reassign stdout and stderr to the log file, stdin to /dev/null */
	reopenfds(c);

	execvp(new[0], new);

	/* not reached, unless exec() fails */
	fprintf(errfp, "Error: exec(%s) failed: %s\n", new[0], strerror(errno));
	exit(EX_UNAVAILABLE);
    } else {
	if (debug)
	    fprintf(errfp, "\nStarting %d/%d %s: process id=%d\n",
		    c->n, n_opt, mashed[0], (uint32_t)c->pid);
	if (c->pid == -1) {
	    fprintf(errfp, "Error: fork() failed: %s\n", strerror(errno));
	    waitpid(c->pid, &status, WNOHANG);
	    c->pid = 0;
	}
    }

    if (mashed[0] != NULL)
	free(mashed[0]);

    sigprocmask(SIG_UNBLOCK, &set_chld, NULL);

    return(0);
}

/*
 * start a command in an interactive xterm.
 */
int
xtermcmd(child *c, char **cmd)
{
    char	*xterm[] = { "xterm", "-e", NULL },
		*mashed[] = { NULL, NULL },
		**new;
    int		status;
    time_t	t;

    /* XXX: is this right? */
    if (cmd == NULL)
	return(ENOEXEC);

    /* build new command */
    if ((status = arg_mash(mashed, cmd))) {
	/* XXX: is this err msg always proper? will only ret true or ENOMEM? */
	fprintf(errfp, "Error: memory allocation failed: %s\n",
		strerror(errno));
	return(status);
    }
    if ((status = arg_replace(xterm, NULL, cmd, &new))) {
	/* XXX: is this err msg always proper? will only ret true or ENOMEM? */
	fprintf(errfp, "Error: memory allocation failed: %s\n",
		strerror(errno));
	return(status);
    }

    /* block sigchld so we quickly reap it ourselves */
    sigprocmask(SIG_BLOCK, &set_chld, NULL);

    if (c->logfile && !H_opt) {
	char	*ct;
	t = time(NULL);
		/* XXX: build a complete cmd line */
	ct = ctime(&t); ct[strlen(ct) - 1] = '\0';
	fprintf(c->logfile, "!!!!!!!\n!%s: %s\n!!!!!!!\n", ct, mashed[0]);
	fflush(c->logfile);
    }

    if ((c->pid = fork()) == 0) {
	/* child */
	signal(SIGCHLD, SIG_DFL);
        sigprocmask(SIG_UNBLOCK, &set_chld, NULL);
	if (debug > 1) {
	    fprintf(errfp, "fork(sh -c %s ...) pid %d\n", mashed[0],
		    (uint32_t)getpid());
	}
	/* reassign stdout and stderr to the log file, stdin to /dev/null */
	reopenfds(c);

	execvp(new[0], new);

	/* not reached, unless exec() fails */
	fprintf(errfp, "Error: exec(xterm failed): %s\n", strerror(errno));
	exit(EX_UNAVAILABLE);
    } else {
	if (debug)
	    fprintf(errfp, "\nStarting %d/%d %s: process id=%d\n",
		    c->n, n_opt, mashed[0], (uint32_t)c->pid);
	if (c->pid == -1) {
	    fprintf(errfp, "Error: fork() failed: %s\n", strerror(errno));
	    waitpid(c->pid, &status, WNOHANG);
	    c->pid = 0;
	}
    }

    if (mashed[0] != NULL)
	free(mashed[0]);

    sigprocmask(SIG_UNBLOCK, &set_chld, NULL);

    return(0);
}

/*
 * start a xterm with the command tail -f on the logfile
 */
void
xtermlog(child *c)
{
    char	*cmd[] = {	"xterm", "-e", "tail", "-f", NULL, NULL };
    int		status;

    if (c->logfname == NULL || c->logfile == NULL) {
	fprintf(errfp, "Error: tried to start xterm to watch NULL log file "
		"for par process\n");
	return;
    }
    cmd[4] = c->logfname;

    if ((c->xpid = fork()) == 0) {
	/* child */
	if (debug > 1) {
	    fprintf(errfp, "fork(xterm tail %s) pid %d\n", c->logfname,
		    (uint32_t)getpid());
	}
	/*
	 * set the process group id so signals are not delivered to the
	 * logging xterms.  in theory, we want them for a reason, so we
	 * dont want them to die when par exits.
	 */
	setpgid(0, getpid());

	execvp(cmd[0], cmd);

	/* not reached, unless exec() fails */
	fprintf(errfp, "Error: exec(xterm) failed: %s\n", strerror(errno));
	exit(EX_UNAVAILABLE);
    } else {
	if (c->xpid == -1) {
	    fprintf(errfp, "Error: fork() failed: %s\n", strerror(errno));
	    waitpid(c->xpid, &status, WNOHANG);
	    c->xpid = 0;
	    return;
	}
    }

    return;
}

/*
 * we are being killed.  kill and reap our sub-processes, except for
 * logging xterms.  if we get a second signal, we give up.
 */
RETSIGTYPE
handler(int sig)
{
    int		i;

    /* block sigchld for the moment, no big deal if it fails */
    sigprocmask(SIG_BLOCK, &set_chld, NULL);

    signaled = 1;

    if (debug > 1)
	fprintf(errfp, "Received signal %d\n", sig);

    for (i = 0; i < n_opt; i++) {
	if (! progeny[i].pid)
	    continue;

	if (debug > 1)
	    fprintf(errfp, "kill(%d, SIGQUIT)\n", (uint32_t)progeny[i].pid);

	if (kill(progeny[i].pid, SIGQUIT))
	    fprintf(errfp, "Error: kill(%d): %s\n", (uint32_t)progeny[i].pid,
		    strerror(errno));
    }

    /* if we rx 2 signals, just give up */
    signal(SIGHUP, SIG_DFL);
    signal(SIGINT, SIG_DFL);
    signal(SIGTERM, SIG_DFL);
    signal(SIGQUIT, SIG_DFL);

    sigprocmask(SIG_UNBLOCK, &set_chld, NULL);

    return;
}

RETSIGTYPE
reapchild(int sig)
{
    int		i,
		status;
    char	*str;
    pid_t	pid;
    time_t	t;

    /* block sigchld for the moment, no big deal if it fails */
    sigprocmask(SIG_BLOCK, &set_chld, NULL);

    if (debug > 1)
	fprintf(errfp, "Received signal SIGCHLD\n");

    /*
     * clean-up hook so we know whether we need to walk the child table
     * again at the end of main()
     */
    chld_wait = -1;
    while ((pid = wait3(&status, WNOHANG, NULL)) > 0) {
	if (debug > 1)
	    fprintf(errfp, "reaped %d\n", (uint32_t)pid);

	t = time(NULL);

	/* search for the pid */
	for (i = 0; i < n_opt; i++) {
	    if (progeny[i].pid == pid) {
		if (debug) {
		    if (progeny[i].logfname == NULL)
			fprintf(errfp, "%d finished\n", (uint32_t)pid);
		    else
			fprintf(errfp, "%d finished (logfile %s)\n",
				(uint32_t)pid, progeny[i].logfname);
		}
		if (progeny[i].logfile != NULL && !F_opt) {
		    str = ctime(&t); str[strlen(str) - 1] = '\0';
		    fprintf(progeny[i].logfile, "Ending: %s: pid = %d\n",
			    str, (uint32_t)pid);
		}
		progeny[i].pid = 0;
		break;
	    } else if (i_opt && progeny[i].xpid == pid) {
		progeny[i].xpid = 0;
		if (debug > 1) {
		    if (progeny[i].logfile != NULL)
			fprintf(errfp, "%d log xterm finished\n",
				(uint32_t)pid);
		    else
			fprintf(errfp, "%d log xterm finished (logfile %s)\n",
				(uint32_t)pid, progeny[i].logfname);
		}
		break;
	    }
	}
    }

    signal(SIGCHLD, reapchild);
    sigprocmask(SIG_UNBLOCK, &set_chld, NULL);

    return;
}

void
usage(void)
{
    fprintf(errfp, "usage: %s [-FHdfiqvx] [-n #] [-p n] [-l logfile] "
		   "[-c command] []\n", progname);
    return;
}

void
vers(void)
{
    fprintf(errfp, "%s: %s version %s\n", progname, package, version);
    return;
}
rancid-3.13/bin/rancid-run.in000644 015615 000000 00000013104 13534014776 016131 0ustar00heaswheel000000 000000 #! /bin/sh
##
## @PACKAGE@ @VERSION@
## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Henry Kilmer, John Heasley, Andrew Partan,
## Pete Whiting, Austin Schutz, and Andrew Fort.
##
## 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. Neither the name of RANCID nor the names of its
##    contributors may be used to endorse or promote products derived from
##    this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
##
## It is the request of the authors, but not a condition of license, that
## parties packaging or redistributing RANCID NOT distribute altered versions
## of the etc/rancid.types.base file nor alter how this file is processed nor
## when in relation to etc/rancid.types.conf.  The goal of this is to help
## suppress our support costs.  If it becomes a problem, this could become a
## condition of license.
# 
#  The expect login scripts were based on Erik Sherk's gwtn, by permission.
# 
#  The original looking glass software was written by Ed Kern, provided by
#  permission and modified beyond recognition.
#
# Run rancid for each of the rancid groups defined by $LIST_OF_GROUPS in
# @sysconfdir@/rancid.conf or those specified on the command-line.
#

# Default ENVFILE, overrideable with -f flag.
ENVFILE="@sysconfdir@/rancid.conf"

TMPDIR=${TMPDIR:=/tmp}; export TMPDIR

# control_rancid argv
CR_ARGV=""; export CR_ARGV

# print a usage message to stderr
pr_usage() {
    echo "usage: $0 [-V] [-c commit_msg] [-f config_file] [-r device_name] [-m mail rcpt] [group [group ...]]" >&2;
}

# command-line options
# -V
# -c 
# -f 
# -m 
# -r 
if [ $# -ge 1 ] ; then
    while [ 1 ] ; do
	case $1 in
	-V)
	    echo "@PACKAGE@ @VERSION@"
	    exit 0
	    ;;
	-c)
	    shift
	    # next arg is the commit message
	    CR_ARGV="$CR_ARGV -c \"$1\""; export CR_ARGV
	    shift
	    ;;
	-f)
	    shift
	    # next arg is the alternate config file name
	    ENVFILE="$1"
	    if [ -z $ENVFILE ]; then
		pr_usage
		exit 1
	    fi
	    CR_ARGV="$CR_ARGV -f $1"; export CR_ARGV
	    shift
	    ;;
	-m)
	    shift
	    # next arg is the mailto name
	    CR_ARGV="$CR_ARGV -m $1"; export CR_ARGV
	    shift
	    ;;
	-r)
	    shift
	    # next arg is the device name
	    CR_ARGV="$CR_ARGV -r $1"; export CR_ARGV
	    shift
	    ;;
	--)
	    shift; break;
	    ;;
	-h)
	    pr_usage
	    exit
	    ;;
	-*)
	    echo "unknown option: $1" >&2
	    pr_usage
	    exit 1
	    ;;
	*)
	    break;
	    ;;
	esac
    done
fi

. $ENVFILE

# SENDMAIL location
SENDMAIL=${SENDMAIL:=sendmail};

if [ $# -ge 1 ] ; then
    LIST_OF_GROUPS="$*"; export LIST_OF_GROUPS
elif [ "$LIST_OF_GROUPS" = "" ] ; then
    echo "LIST_OF_GROUPS is empty in $ENVFILE"
    exit 1
fi

# LOGDIR location
LOGDIR=${LOGDIR:=$BASEDIR/logs};
if [ ! -d $LOGDIR ] ; then
    mkdir -p $LOGDIR || (echo "Could not create log directory: $LOGDIR" >&2;
			 exit 1)
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
	    GRPOLDFILE=`mktemp -q $TMPDIR/.$GROUP.XXXXXX`
	    if [ $? -ne 0 ] ; then
		echo "Could not create temporary file for error email" >&2
		exit 1
	    fi
	    @PERLV@ -e "\$t = (stat(\"$LOCKFILE\"))[9]; print \"OLD\\n\" if (time() - \$t >= $LOCKTIME*60*60);" > $GRPOLDFILE
	    if [ -s $GRPOLDFILE ]
	    then
		(
		  echo "To: @ADMINMAILPLUS@${GROUP}${MAILDOMAIN}"
		  echo "Subject: rancid hung - $GROUP"
		  echo "Precedence: bulk"
		  echo "Auto-submitted: auto-generated"
		  echo "X-Auto-Response-Suppress: All"
		  echo ""

		  cat <$LOGDIR/$GROUP.`date +%Y%m%d.%H%M%S` 2>&1
done
rancid-3.13/bin/avologin.in000644 015615 000000 00000034431 13665233101 015701 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## @PACKAGE@ @VERSION@
@copyright@
#
# avologin - Avocent ACS login (formerly Cyclades)
#
# Most options are intuitive for logging into a Avocent/Cyclades term server.
# The default is to enable (thus -noenable).  Some folks have
# setup tacacs to have a user login at priv-lvl = 15 (enabled)
# so the -autoenable flag was added for this case (don't go through
# the process of enabling and the prompt will be the "#" prompt.
# The default username password is the same as the vty password.
#

# Sometimes routers take awhile to answer (the default is 10 sec)
set timeoutdflt 90
# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

@login_top@

# Log into the router.
# returns: 0 on success, 1 on failure
proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } {
    global spawn_id in_proc do_command do_script passphrase
    global prompt u_prompt p_prompt e_prompt sshcmd telnetcmd
    set in_proc 1
    set uprompt_seen 0

    # try each of the connection methods in $cmethod until one is successful
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog command suffix port
	    if {"$port" == ""} {
		set retval [catch {eval spawn [split "$telnetcmd $router"]} reason]
	    } else {
		set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason]
	    }
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif [string match "ssh*" $prog] {
	    # ssh to the router & try to login with or without an identfile.
	    regexp {ssh(:([^[:space:]]+))*} $prog command suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    if {"$identfile" != ""} {
		set cmd "$cmd -i $identfile"
	    }
	    set retval [ catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason ]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}
	sleep 0.3

	# This helps cleanup each expect clause.
	expect_after {
	    timeout {
		global in_proc
		send_user "\nError: TIMEOUT reached\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    } eof {
		global in_proc
		send_user "\nError: EOF received\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    }
	}

    # Here we get a little tricky.  There are several possibilities:
    # the router can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the router might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-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" {
	    catch {close}; catch {wait};
	    send_user "\nError: Unknown host $router\n"; wait; return 1
	}
	"Host is unreachable" {
	    catch {close}; catch {wait};
	    send_user "\nError: Host Unreachable: $router\n"; wait; return 1
	}
	"No address associated with name" {
	    catch {close}; catch {wait};
	    send_user "\nError: Unknown host $router\n"; wait; return 1
	}
	-re "(Host key not found |The authenticity of host .* be established)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-nocase -re "^warning: remote host denied authentication agent forwarding." {
	    exp_continue;
	}
	-re "(denied|Sorry)"	{
				  send_user "\nError: Check your passwd for $router\n"
				  catch {close}; catch {wait}; return 1
				}
	-nocase -re "last login: \[\r\n]" {
				  exp_continue
				}
	-nocase -re "failed login: \[\r\n]" {
				  exp_continue
				}
	"Login failed"		{
				  send_user "\nError: Check your passwd for $router\n"
				  return 1
				}
	-re "% (Bad passwords|Authentication failed)"	{
				  send_user "\nError: Check your passwd for $router\n"
				  return 1
				}
	-re "@\[^\r\n]+ $p_prompt"	{
				  # ssh pwd prompt
				  sleep 1
				  send -- "$userpswd\r"
				  exp_continue
				}
	-re "Enter passphrase.*: " {
				  # sleep briefly to allow time for stty -echo
				  sleep .3
				  send -- "$passphrase\r"
				  exp_continue
				}
	-re "$u_prompt"		{
				  send -- "$user\r"
				  set uprompt_seen 1
				  exp_continue
				}
	-re "$p_prompt"		{
				  sleep 1
				  if {$uprompt_seen == 1} {
					send -- "$userpswd\r"
				  } else {
					send -- "$passwd\r"
				  }
				  exp_continue
				}
	-re "$prompt"		{ break; }
	"Login invalid"		{
				  send_user "\nError: Invalid login: $router\n";
				  catch {close}; catch {wait}; return 1
				}
     }
    }

    set in_proc 0
    return 0
}

# Enable
proc do_enable { enauser enapasswd } {
    global prompt in_proc
    global u_prompt e_prompt
    set in_proc 1

    send "/bin/su\r"
    expect {
	-re "$u_prompt"	{ send -- "$enauser\r"; exp_continue}
	-re "$e_prompt"	{ send -- "$enapasswd\r"; exp_continue}
	"#"		{ set prompt "#" }
	-re "su: User not allowed access" {
			  send_user "\nError: Enable access not allowed\n";
			  return 1
			}
	-re "(denied|Sorry|Incorrect)" {
			  # % Access denied - from local auth and poss. others
			  send_user "\nError: Check your Enable passwd\n";
			  return 1
			}
	"% Error in authentication" {
			  send_user "\nError: Check your Enable passwd\n"
			  return 1
			}
	"% Bad passwords" {
			  send_user "\nError: Check your Enable passwd\n"
			  return 1
			}
    }
    # We set the prompt variable (above) so script files don't need
    # to know what it is.
    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact in_proc
    set in_proc 1

    # The pager cant be completely disabled
    send "stty rows 1024\r"

    # match cisco config mode prompts too, such as router(config-if)#,
    # but catalyst does not change in this fashion.
    regsub -lineanchor -- {^(.{1,14}).*([#$])$} $prompt {\1} reprompt
    # escape any parens in the prompt, such as "(enable)"
    regsub -all {[)(]} $reprompt {\\&} reprompt
    append reprompt {([^#>\r\n]+)?[#$](\\([^)\\r\\n]+\\))?}
    expect {
	-re $reprompt	{}
	-re "\[\n\r]+"	{ exp_continue }
    }

    # this is the only way i see to get rid of more prompts in o/p..grrrrr
    log_user 0

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    # the pager can not be turned off on the PIX, so we have to look
    # for the "More" prompt.  the extreme is equally obnoxious, with a
    # global switch in the config.
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
	    -re "\b+"			{ exp_continue }
	    -re "^\[^\n\r *]*$reprompt"	{ send_user -- "$expect_out(buffer)" }
	    -re "^\[^\n\r]*$reprompt."	{ send_user -- "$expect_out(buffer)"
					  exp_continue }
	    -re "\[\n\r]+"		{ send_user -- "$expect_out(buffer)"
					  exp_continue }
	    -re "\[^\r\n]*Press  to cont\[^\r\n]*"	{
					  send " "
					  # bloody ^[[2K after " "
					  expect {
						-re "^\[^\r\n]*\r" {}
					  }
					  exp_continue
					}
	    -re "^ *--More--\[^\n\r]*"	{ send " "
					  exp_continue }
	    -re "^<-+ More -+>\[^\n\r]*" {
					  send_user -- "$expect_out(buffer)"
					  send " "
					  exp_continue }
	}
    }
    log_user 1

    if { $do_interact == 1 } {
	interact
	return 0
    }

    send "exit\r"
    expect {
	-re "^\[^\n\r *]*$reprompt"		{
						  # the Cisco CE and Jnx ERX
						  # return to non-enabled mode
						  # on exit in enabled mode.
						  send "exit\r"
						  exp_continue;
						}
	"Do you wish to save your configuration changes" {
						  send "n\r"
						  exp_continue
						}
	-re "\[\n\r]+"				{ exp_continue }
	timeout					{ return 0 }
	eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each router... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # Figure out the prompt.
    # autoenable is off by default.  If we have it defined, it was done
    # on the command line.  If it is not specifically set on the command
    # line, check the password file.
    if $avautoenable {
	set autoenable 1
	set enable 0
	set prompt "#"
    } else {
	set ae [find autoenable $router]
	if { "$ae" == "1" } {
	    set autoenable 1
	    set enable 0
	    set prompt "#"
	} else {
	    set autoenable 0
	    set enable $avenable
	    set prompt "\\\$"
	}
    }

    # look for noenable option in .cloginrc
    if { [find noenable $router] == "1" } {
	set enable 0
    }

    # Figure out passwords
    if { $do_passwd || $do_enapasswd } {
	set pswd [find password $router]
	if { [llength $pswd] == 0 } {
	    send_user -- "\nError: no password for $router in $password_file.\n"
	    continue
	}
	if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } {
	    send_user -- "\nError: no enable password for $router in $password_file.\n"
	    continue
	}
	if { $do_passwd } {
	    set passwd [join [lindex $pswd 0] ""]
	} else {
	    set passwd $userpasswd
	}
	if { $do_enapasswd } {
	    set enapasswd [join [lindex $pswd 1] ""]
	} else {
	    set enapasswd $enapasswd
	}
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } 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 $ruser }
    }

    # Figure out prompts
    set u_prompt [find userprompt $router]
    if { "$u_prompt" == "" } {
	set u_prompt "(Username|Login|login|user name):"
    } else {
	set u_prompt [join [lindex $u_prompt 0] ""]
    }
    set p_prompt [find passprompt $router]
    if { "$p_prompt" == "" } {
	set p_prompt "(\[Pp]assword|passwd):"
    } else {
	set p_prompt [join [lindex $p_prompt 0] ""]
    }
    set e_prompt [find enableprompt $router]
    if { "$e_prompt" == "" } {
	set e_prompt "\[Pp]assword:"
    } else {
	set e_prompt [join [lindex $e_prompt 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 cypher type
    if {[info exists cypher]} {
        # command line cypher type
        set cyphertype $cypher
    } else {
        set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} {
	# if login failed, move on to the next device
	incr exitval
	continue
    }
    if { $enable } {
	if {[do_enable $enauser $enapasswd]} {
	    if { $do_command || $do_script } {
		incr exitval
		catch {close}; catch {wait};
		continue
	    }
	}
    }
    # we are logged in, now figure out the full prompt
    send "\r"
    expect {
	-re "\[\r\n]+"		{ exp_continue; }
	-re "^.+$prompt"	{ set junk $expect_out(0,string);
				  regsub -all "\[\]\[\$]" $junk {\\&} prompt;
				}
    }

    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each router
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/bin/xirancid.in000644 015615 000000 00000016702 13534015016 015663 0ustar00heaswheel000000 000000 #! @PERLV_PATH@
##
## @PACKAGE@ @VERSION@
## Copyright (c) @COPYYEARS@ by Henry Kilmer and John Heasley
## All rights reserved.
##
## This code is derived from software contributed to and maintained by
## Henry Kilmer, John Heasley, Andrew Partan,
## Pete Whiting, Austin Schutz, and Andrew Fort.
##
## 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. Neither the name of RANCID nor the names of its
##    contributors may be used to endorse or promote products derived from
##    this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY Henry Kilmer, John Heasley 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.
##
## It is the request of the authors, but not a condition of license, that
## parties packaging or redistributing RANCID NOT distribute altered versions
## of the etc/rancid.types.base file nor alter how this file is processed nor
## when in relation to etc/rancid.types.conf.  The goal of this is to help
## suppress our support costs.  If it becomes a problem, this could become a
## condition of license.
# 
#  The expect login scripts were based on Erik Sherk's gwtn, by permission.
# 
#  The original looking glass software was written by Ed Kern, provided by
#  permission and modified beyond recognition.
#
# hacked version of Hank's rancid - this one tries to deal with Xirrus arrays.
#
#  RANXID - Really Awesome New Xirrus confIg Differ
#
# usage: xirancid [-dltCV] [-f filename | hostname]
#
use Getopt::Std;
getopts('dflt:CV');
if ($opt_V) {
    print "@PACKAGE@ @VERSION@\n";
    exit(0);
}
$log = $opt_l;
$debug = $opt_d;
$file = $opt_f;
$host = $ARGV[0];
$clean_run = 0;
$timeo = 90;				# xilogin timeout in seconds

my(@commandtable, %commands, @commands);# command lists
my($filter_commstr);			# SNMP community string filtering
my($filter_osc);			# oscillating data filtering mode
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))
	&& scalar(%history)) {
	print eval "$command \%history";
	undef %history;
    }
    if (($new_hist_tag) && ($new_command) && ($command_string)) {
	if ($history{$command_string}) {
	    $history{$command_string} = "$history{$command_string}@string";
	} else {
	    $history{$command_string} = "@string";
	}
    } elsif (($new_hist_tag) && ($new_command)) {
	$history{++$#history} = "@string";
    } else {
	print "@string";
    }
    $hist_tag = $new_hist_tag;
    $command = $new_command;
    1;
}

# This routine parses "show config"
sub ShowConfig {
    print STDERR "    In ShowConfig: $_\n" if ($debug);

    while () {
	tr/\015//d;
	last if (/^$prompt/);
	next if (/^(\s*|\s*$cmd\s*)$/);
	ProcessHistory("","","","$_");
    }
    return(0);
}

# Main
@commandtable = (
	{'show boot-env' 			=> "ShowConfig"},
	{'show running-config inc-defaults'	=> "ShowConfig"}
);
# 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);
$commandcnt = scalar(keys %commands);

$xirrus_cmds=join(";",@commands);
$cmds_regexp = join("|", map quotemeta($_), @commands);

if (length($host) == 0) {
    if ($file) {
	print(STDERR "Too few arguments: file name required\n");
	exit(1);
    } else {
	print(STDERR "Too few arguments: host name required\n");
	exit(1);
    }
}
if ($opt_C) {
    print "xilogin -t $timeo -c\'$xirrus_cmds\' $host\n";
    exit(0);
}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
if ($debug) { $| = 1; }

if ($file) {
    print(STDERR "opening file $host\n") if ($debug || $log);
    open(INPUT,"<$host") || die "open failed for $host: $!\n";
} else {
    print(STDERR "executing xilogin -t $timeo -c\"$xirrus_cmds\" $host\n") if ($debug || $log);
    system "xilogin -t $timeo -c \"$xirrus_cmds\" $host  $host.raw 2>&1" || die "xilogin failed for $host: $!\n";
    open(INPUT, "< $host.raw") || die "xilogin failed for $host: $!\n";
}

# determine community string filtering mode
if (defined($ENV{"NOCOMMSTR"}) &&
    ($ENV{"NOCOMMSTR"} =~ /yes/i || $ENV{"NOCOMMSTR"} =~ /^$/)) {
    $filter_commstr = 1;
} else {
    $filter_commstr = 0;
}
# determine oscillating data filtering mode
if (defined($ENV{"FILTER_OSC"}) && $ENV{"FILTER_OSC"} =~ /no/i) {
    $filter_osc = 0;
} else {
    $filter_osc = 1;
}
# determine password filtering mode
if ($ENV{"FILTER_PWDS"} =~ /no/i) {
    $filter_pwds = 0;
} elsif ($ENV{"FILTER_PWDS"} =~ /all/i) {
    $filter_pwds = 2;
} else {
    $filter_pwds = 1;
}

ProcessHistory("","","","!RANCID-CONTENT-TYPE: xirrus\n!\n");
TOP: while() {
    tr/\015//d;
    if (/^end/)  {
	$clean_run=1;
        last;
    }
    if (/^Error:/) {
	print STDOUT ("$host xilogin error: $_");
	print STDERR ("$host xilogin error: $_") if ($debug);
	$clean_run=0;
	last;
    }
    while (/[>#]\s*($cmds_regexp)\s*$/) {
	$cmd = $1;
	if (!defined($prompt)) {
	    $prompt = ($_ =~ /^([^:]+:)/)[0];
	}
	print STDERR ("HIT COMMAND:$_") if ($debug);
	if (! defined($commands{$cmd})) {
	    print STDERR "$host: found unexpected command - \"$cmd\"\n";
	    $clean_run = 0;
	    last TOP;
	}
	$rval = &{$commands{$cmd}}(*INPUT, *OUTPUT, $cmd);
	delete($commands{$cmd});
	if ($rval == -1) {
	    $clean_run = 0;
	    last TOP;
	}
    }
}
print STDOUT "Done $logincmd: $_\n" if ($log);
# Flush History
ProcessHistory("","","","");
# Cleanup
close(INPUT);
close(OUTPUT);

unlink("$host.raw") if (! $debug);

# check for completeness
if (scalar(%commands) || !$clean_run ) {
    if (scalar(keys %commands) eq $commandcnt) {
	printf(STDERR "$host: missed cmd(s): all commands\n");
    } elsif (scalar(%commands)) {
	my($count, $i) = 0;
	for ($i = 0; $i < $#commands; $i++) {
	    if ($commands{$commands[$i]}) {
		if (!$count) {
		    printf(STDERR "$host: missed cmd(s): %s", $commands[$i]);
		} else {
		    printf(STDERR ", %s", $commands[$i]);
		}
		$count++;
	    }
	}
	if ($count) {
	    printf(STDERR "\n");
	}
    }
    if (!$clean_run) {
	print(STDERR "$host: End of run not found\n");
	if ($debug) {
	    print(STDERR "$host: clean_run is false\n") if (!$clean_run);
	}
	system("/usr/bin/tail -1 $host.new");
    }
    unlink "$host.new" if (! $debug);
}
rancid-3.13/bin/clogin.in000644 015615 000000 00000050461 13657102757 015354 0ustar00heaswheel000000 000000 #! @EXPECT_PATH@ --
##
## @PACKAGE@ @VERSION@
@copyright@
#
# clogin - Cisco login
#
# Most options are intuitive for logging into a Cisco router.
# The default is to enable (thus -noenable).  Some folks have
# setup tacacs to have a user login at priv-lvl = 15 (enabled)
# so the -autoenable flag was added for this case (don't go through
# the process of enabling and the prompt will be the "#" prompt.
# The default username password is the same as the vty password.
#

# Sometimes routers take awhile to answer (the default is 10 sec)
set timeoutdflt 45
# Some CLIs having problems if we write too fast (Extreme, PIX, Cat)
set send_human {.2 .1 .4 .2 1}

@login_top@

# Log into the router.
# returns: 0 on success, 1 on failure, -1 if rsh was used successfully
proc login { router user userpswd passwd enapasswd cmethod cyphertype identfile } {
    global command spawn_id in_proc do_command do_script platform passphrase
    global prompt prompt_match u_prompt p_prompt e_prompt sshcmd telnetcmd
    set in_proc 1
    set uprompt_seen 0

    # try each of the connection methods in $cmethod until one is successful
    set progs [llength $cmethod]
    foreach prog [lrange $cmethod 0 end] {
	incr progs -1
	if [string match "telnet*" $prog] {
	    regexp {telnet(:([^[:space:]]+))*} $prog methcmd suffix port
	    if {"$port" == ""} {
		set retval [catch {eval spawn [split "$telnetcmd $router"]} reason]
	    } else {
		set retval [catch {eval spawn [split "$telnetcmd $router $port"]} reason]
	    }
	    if { $retval } {
		send_user "\nError: telnet failed: $reason\n"
		return 1
	    }
	} elseif [string match "ssh*" $prog] {
	    # ssh to the router & try to login with or without an identfile.
	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
	    set cmd $sshcmd
	    if {"$port" != ""} {
		set cmd "$cmd -p $port"
	    }
	    if {"$cyphertype" != ""} {
		set cmd "$cmd -c $cyphertype"
	    }
	    if {"$identfile" != ""} {
		set cmd "$cmd -i $identfile"
	    }
	    set retval [catch {eval spawn [split "$cmd -x -l $user $router" { }]} reason]
	    if { $retval } {
		send_user "\nError: $cmd failed: $reason\n"
		return 1
	    }
	} elseif ![string compare $prog "rsh"] {
	    if { ! $do_command } {
		if { [llength $cmethod] == 1 } {
		    send_user "\nError: rsh is an invalid method for -x and "
		    send_user "interactive logins\n"
		}
		if { $progs == 0 } {
		    return 1
		}
		continue;
	    }

	    # handle escaped ;s in commands, and ;; and ^;
	    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
	    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
	    regsub {^;} $command "\u0002;" esccommand
	    regsub -all {[\\];} $esccommand ";" command
	    regsub -all {\u0002;} $command "\u0002" esccommand
	    set sep "\u0002;"
	    set commands [split $esccommand $sep]
	    set num_commands [llength $commands]
	    set rshfail 0
	    for {set i 0} {$i < $num_commands && !$rshfail} { incr i} {
		log_user 0
		set retval [catch {spawn rsh $user@$router [lindex $commands $i] } reason]
		if { $retval } {
		    send_user "\nError: rsh failed: $reason\n"
		    log_user 1; return 1
		}
		send_user "$router# [lindex $commands $i]\n"

		# rcmd does not get a pager and no prompts, so we just have to
		# look for failures & lines.
		expect {
		  "Connection refused"	{ catch {close}; catch {wait};
					  send_user "\nError: Connection\
						    Refused ($prog): $router\n"
					  set rshfail 1
					}
		  -re "(Connection closed by|Connection to \[^\n\r]+ closed)" {
					  catch {close}; catch {wait};
					  send_user "\nError: Connection\
						    closed ($prog): $router\n"
					  set rshfail 1
					}
		  "Host is unreachable"	{ catch {close}; catch {wait};
					  send_user "\nError: Host Unreachable:\
						    $router\n"
					  set rshfail 1
					}
		  "No address associated with" {
					  catch {close}; catch {wait};
					  send_user "\nError: Unknown host\
						    $router\n"
					  set rshfail 1
					}
		  -re "\b+"		{ exp_continue }
		  -re "\[\n\r]+"	{ send_user -- "$expect_out(buffer)"
					  exp_continue
					}
		  timeout		{ catch {close}; catch {wait};
					  send_user "\nError: TIMEOUT reached\n"
					  set rshfail 1
					}
		  eof			{ catch {close}; catch {wait}; }
		}
		log_user 1
	    }
	    if { $rshfail } {
		if { !$progs } {
		    return 1
		} else {
		    continue
		}
	    }
	    # fake the end of the session for rancid.
	    send_user "$router# exit\n"
	    # return rsh "success"
	    return -1
	} else {
	    send_user "\nError: unknown connection method: $prog\n"
	    return 1
	}
	sleep 0.3

	# This helps cleanup each expect clause.
	expect_after {
	    timeout {
		global in_proc
		send_user "\nError: TIMEOUT reached\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    } eof {
		global in_proc
		send_user "\nError: EOF received\n"
		catch {close}; catch {wait};
		if {$in_proc} {
		    return 1
		} else {
		    continue
		}
	    }
	}

    # Here we get a little tricky.  There are several possibilities:
    # the router can ask for a username and passwd and then
    # talk to the TACACS server to authenticate you, or if the
    # TACACS server is not working, then it will use the enable
    # passwd.  Or, the router might not have TACACS turned on,
    # then it will just send the passwd.
    # if telnet fails with connection refused, try ssh
    expect {
	-re "^<-+ More -+>\[^\n\r]*" {
	    # ASA will use the pager for long banners
	    send " ";
	    exp_continue
	}
	-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
	}
	"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)" {
	    expect {
		-re "\\(yes\/no\[^\\)]*\\)\\?" {
					  send "yes\r";
					  send_user "\nHost $router added to the list of known hosts.\n"
					 }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    exp_continue
	}
	-re "HOST IDENTIFICATION HAS CHANGED" {
	    send_user "\nError: The host key for $router has changed.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re " strict checking\.\[\r\n]+" { }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-re "Offending key for " {
	    send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts file accordingly.\n"
	    expect {
		-re "\\(yes\/no\\)\\?"	{ send "no\r" }
		-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
	    }
	    catch {close}; catch {wait};
	    return 1
	}
	-nocase -re "^warning: remote host denied authentication agent forwarding." {
	    exp_continue;
	}
	-re "(denied|Sorry)"	{
				  send_user "\nError: Check your passwd for $router\n"
				  catch {close}; catch {wait}; return 1
				}
	-nocase -re "last login:"	{
				  exp_continue
				}
	-nocase -re "failed login:"	{
				  exp_continue
				}
	"Login failed"		{
				  send_user "\nError: Check your passwd for $router\n"
				  catch {close}; catch {wait}; return 1
				}
	-re "% (Bad passwords|Authentication failed)"	{
				  send_user "\nError: Check your passwd for $router\n"
				  catch {close}; catch {wait}; return 1
				}
	"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"
				  exp_continue
				}
	-re "Press the  key \[^\r\n]+\[\r\n]+"	{
				  exp_continue
				}
	-re "@\[^\r\n]+ $p_prompt"	{
				  # ssh pwd prompt
				  sleep 1
				  send -- "$userpswd\r"
				  exp_continue
				}
	-re "Enter passphrase.*: " {
				  # sleep briefly to allow time for stty -echo
				  sleep .3
				  send -- "$passphrase\r"
				  exp_continue
				}
	-re "$u_prompt"		{
				  send -- "$user\r"
				  set uprompt_seen 1
				  exp_continue
				}
	-re "$p_prompt"		{
				  sleep 1
				  if {$uprompt_seen == 1} {
					send -- "$userpswd\r"
				  } else {
					send -- "$passwd\r"
				  }
				  exp_continue
				}
	-re "$prompt"		{
				  set prompt_match $expect_out(0,string);
				  break;
				}
	"Login invalid"		{
				  send_user "\nError: Invalid login: $router\n";
				  catch {close}; catch {wait}; return 1
				}
	-re "\[^\r\n]*\[\r\n]+"	{ exp_continue; }
     }
    }

    set in_proc 0
    return 0
}

# Enable
proc do_enable { enauser enapasswd } {
    global in_proc
    global prompt u_prompt e_prompt enacmd
    set in_proc 1

    send "$enacmd\r"
    expect {
	-re "$u_prompt"	{ send -- "$enauser\r"; exp_continue}
	-re "$e_prompt"	{ send -- "$enapasswd\r"; exp_continue}
	"#"		{ set prompt "#" }
	"(enable)"	{ set prompt "> \\(enable\\) " }
	"% Invalid input" {
			  send_user "\nError: Unrecognized command, check your enable command\n";
			  return 1
			}
	-re "(denied|Sorry|Incorrect)"	{
			  # % Access denied - from local auth and poss. others
			  send_user "\nError: Check your Enable passwd\n";
			  return 1
			}
	"% Error in authentication" {
			  send_user "\nError: Check your Enable passwd\n"
			  return 1
			}
	"% Bad passwords" {
			  send_user "\nError: Check your Enable passwd\n"
			  return 1
			}
    }
    # We set the prompt variable (above) so script files don't need
    # to know what it is.
    set in_proc 0
    return 0
}

# Run commands given on the command line.
proc run_commands { prompt command } {
    global do_interact do_saveconfig in_proc platform
    set in_proc 1

    if { [string compare "extreme" "$platform"] } {
	# match cisco config mode prompts too, such as router(config-if)#
	# and truncatedr(config-if)#.
	# catalyst does not change in this fashion, but does have its
	# abnormal format, router> (enable).
	# first, drop the "> (enable) " from the catos prompt.
	regsub -lineanchor -- {> *\\\(enable\\\) *} $prompt {} reprompt
	regsub -lineanchor -- {^(.{1,11}).*([#>])$} $reprompt {\1} reprompt
	regsub -all -- {[\\]$} $reprompt {} reprompt
	append reprompt {([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?}
    } else {
	set reprompt $prompt
    }

    # this is the only way i see to get rid of more prompts in o/p..grrrrr
    log_user 0

    # handle escaped ;s in commands, and ;; and ^;
    regsub -all {([^\\]);} $command "\\1\u0002;" esccommand
    regsub -all {([^\\]);;} $esccommand "\\1;\u0002;" command
    regsub {^;} $command "\u0002;" esccommand
    regsub -all {[\\];} $esccommand ";" command
    regsub -all {\u0002;} $command "\u0002" esccommand
    set sep "\u0002"
    set commands [split $esccommand $sep]
    set num_commands [llength $commands]
    # the pager can not be turned off on the PIX, so we have to look
    # for the "More" prompt.  the extreme is equally obnoxious in pre-12.3 XOS,
    # with a global switch in the config.
    for {set i 0} {$i < $num_commands} { incr i} {
	send -- "[subst -nocommands [lindex $commands $i]]\r"
	expect {
	    -re "^\b+"				{ exp_continue }
	    -re "^\[^\n\r *]*$reprompt"		{ send_user -- "$expect_out(buffer)"
						}
	    -re "^\[^\n\r]*$reprompt."		{ send_user -- "$expect_out(buffer)"
						  exp_continue
						}
	    -re "^--More--\[\r\n]+"		{ # specific match c1900 pager
						  send " "
						  exp_continue
						}
	    -re "\[^\r\n]*\[\n\r]+"		{ send_user -- "$expect_out(buffer)"
						  exp_continue
						}
	    # respond to prompt from "file prompt noisy" config
	    -nocase -re "^display filename \\\[\[^]]*]\\?" 	{
						  send "\r"
						  exp_continue
						}
	    -re "\[^\r\n]*Press  to cont\[^\r\n]*"	{
						  send " "
						  # bloody ^[[2K after " "
						  expect {
							-re "^\[^\r\n]*\r" {}
							}
						  exp_continue
						}
	    -re "^ *--More--\[^\n\r]*"		{
						  send " "
						  exp_continue }
	    -re "^<-+ More -+>\[^\n\r]*"	{
						  send_user -- "$expect_out(buffer)"
						  send " "
						  exp_continue }
	}
    }
    log_user 1

    if { $do_interact == 1 } {
	interact
	return 0
    }

    if { [string compare "extreme" "$platform"] } {
	send -h "exit\r"
    } else {
	send -h "quit\r"
    }
    expect {
	-re "^\[^\n\r *]*$reprompt"		{
						  # the Cisco CE and Jnx ERX
						  # return to non-enabled mode
						  # on exit in enabled mode.
						  send -h "exit\r"
						  exp_continue;
						}
	-re "^\[^\n\r *]*Use .quit. to end"	{
						  # the F5 >=11 uses quit
						  send -h "quit\r"
						  exp_continue;
						}
	"The system has unsaved changes"	{ # Force10 SFTOS
						  if {$do_saveconfig} {
						    catch {send "y\r"}
						  } else {
						    catch {send "n\r"}
						  }
						  exp_continue
						}
	"Would you like to save them now"	{ # Force10
						  if {$do_saveconfig} {
						    catch {send "y\r"}
						  } else {
						    catch {send "n\r"}
						  }
						  exp_continue
						}
	-re "(Profile|Configuration) changes have occurred.*"	{
						  # Cisco CSS
						  if {$do_saveconfig} {
						    catch {send "y\r"}
						  } else {
						    catch {send "n\r"}
						  }
						  exp_continue
						}
	"Do you wish to save your configuration changes" {
						  if {$do_saveconfig} {
						    catch {send "y\r"}
						  } else {
						    catch {send "n\r"}
						  }
						  exp_continue
						}
	-re "\[\n\r]+"				{ exp_continue }
	timeout					{ catch {close}; catch {wait};
						  return 1
						}
	eof					{ return 0 }
    }
    set in_proc 0
}

#
# For each router... (this is main loop)
#
source_password_file $password_file
set in_proc 0
set exitval 0
set prompt_match ""
# if we have dont have a tty, we need some additional terminal settings
if [catch {open /dev/tty w} ttyid] {
    # no tty, ie: cron
    set spawnopts "-nottycopy"
    set stty_init "cols 132"
} else {
    catch {close ttyid} reason
}
foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    # attempt at platform switching.
    set platform ""
    send_user -- "$router\n"

    # device timeout
    set timeout [find timeout $router]
    if { [llength $timeout] == 0 } {
	set timeout $timeoutdflt
    }

    # Default prompt.
    set prompt [join [find prompt $router] ""]
    if { [llength $prompt] == 0 } {
	set prompt "(>|#| \\(enable\\))"
    }

    # look for autoenable option in .cloginrc & cmd-line
    set ae [find autoenable $router]
    if { "$ae" == "1" || $avautoenable } {
	set autoenable 1
    } else {
	set autoenable 0
    }
    # look for enable options in .cloginrc & cmd-line
    if { $avenable == 0 } {
	set enable 0
    } else {
	set ne [find noenable $router]
	if { "$ne" == "1" || "$autoenable" == "1" } {
	    set enable 0
	} else {
	    set enable 1
	}
    }

    # Figure out passwords
    if { $do_passwd || $do_enapasswd } {
	set pswd [find password $router]
	if { [llength $pswd] == 0 } {
	    send_user -- "\nError: no password for $router in $password_file.\n"
	    continue
	}
	if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } {
	    send_user -- "\nError: no enable password for $router in $password_file.\n"
	    continue
	}
	if { $do_passwd } {
	    set passwd [join [lindex $pswd 0] ""]
	} else {
	    set passwd $userpasswd
	}
	if { $do_enapasswd } {
	    set enapasswd [join [lindex $pswd 1] ""]
	} else {
	    set enapasswd $enapasswd
	}
    } else {
	set passwd $userpasswd
	set enapasswd $enapasswd
    }

    # Figure out username
    if {[info exists username]} {
      # command line username
      set ruser $username
    } else {
      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
    } 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 $ruser }
    }

    # Figure out enable command
    set enacmd [join [find enablecmd $router] ""]
    if { "$enacmd" == "" } { set enacmd "enable" }

    # Figure out prompts
    set u_prompt [find userprompt $router]
    if { "$u_prompt" == "" } {
	set u_prompt "(\[Uu]sername|\[Ll]ogin|\[Uu]ser \[Nn]ame|User):"
    } else {
	set u_prompt [join [lindex $u_prompt 0] ""]
    }
    set p_prompt [find passprompt $router]
    if { "$p_prompt" == "" } {
	set p_prompt "(\[Pp]assword|passwd|Enter password for \[^ :]+):"
    } else {
	set p_prompt [join [lindex $p_prompt 0] ""]
    }
    set e_prompt [find enableprompt $router]
    if { "$e_prompt" == "" } {
	set e_prompt "\[Pp]assword:"
    } else {
	set e_prompt [join [lindex $e_prompt 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 cypher type
    if {[info exists cypher]} {
        # command line cypher type
        set cyphertype $cypher
    } else {
        set cyphertype [find cyphertype $router]
    }

    # Figure out connection method
    set cmethod [find method $router]
    if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }

    # Figure out the SSH executable name
    set sshcmd [join [lindex [find sshcmd $router] 0] ""]
    if { "$sshcmd" == "" } { set sshcmd {ssh} }

    # Figure out the telnet executable name
    set telnetcmd [join [lindex [find telnetcmd $router] 0] ""]
    if { "$telnetcmd" == "" } { set telnetcmd "@TELNET_CMD@" }

    # if [-mM], skip do not login
    if { $do_cloginrcdbg > 0 } { continue; }

    # Login to the router
    if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype $identfile]} {
	incr exitval
	# if login failed or rsh was unsuccessful, move on to the next device
	continue
    }
    # Figure out the prompt.
    if { [regexp -- "(#| \\(enable\\))" $prompt_match junk] == 1 } {
	set enable 0
    }
    if { $enable } {
	if {[do_enable $enauser $enapasswd]} {
	    if { $do_command || $do_script } {
		incr exitval
		catch {close}; catch {wait};
		continue
	    }
	}
    }
    # we are logged in, now figure out the full prompt
    send "\r"
    regsub -all {^(\^*)(.*)} $prompt {\2} reprompt
    expect {
	-re "\[\r\n]+"		{ exp_continue; }
	-re "^(.+\[:.])1 ($reprompt)" { # stoopid extreme cmd-line numbers and
				  # prompt based on state of config changes,
				  # which may have an * at the beginning.
				  set junk $expect_out(1,string)
				  regsub -all "^\\\* " $expect_out(1,string) {} junk
				  regsub -all "\[\]\[\(\)]" $junk {\\&} junk;
				  set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)";
				  set platform "extreme"
				}
	-re "^.+$reprompt"	{ set junk $expect_out(0,string);
				  regsub -all "\[\]\[\(\)\*+]" $junk {\\&} prompt;
				}
    }
    if { $do_command || $do_script } {
	if { [string compare "extreme" "$platform"] } {
	    # If the prompt is (enable), then we are on a cataylyst switch and
	    # the command is "set length 0"; otherwise its "terminal length 0".
	    if [regexp -- ".*> .*enable" "$prompt"] {
		send "set length 0\r"
		expect -re $prompt  	{}
		send "set width 132\r"
		expect -re $prompt	{}
		send "set logging session disable\r"
	    } else {
		send "terminal length 0\r"
		expect -re $prompt  	{}
		send "terminal width 132\r"
	    }
	    expect -re $prompt		{}
	} else {
	    send "disable clipaging\r"
	    expect -re $prompt		{}
	}
    }
    if { $do_command } {
	if {[run_commands $prompt $command]} {
	    incr exitval
	    continue
	}
    } elseif { $do_script } {
	source $sfile
	catch {close};
    } else {
	label $router
	log_user 1
	interact
    }

    # End of for each router
    catch {wait};
    sleep 0.3
}
exit $exitval
rancid-3.13/include/version.h000644 015615 000000 00000000164 13735706327 016255 0ustar00heaswheel000000 000000 #ifndef VERSION_H

#define VERSION_H

/* pkg version */
char package[] = "rancid";
char version[] = "3.13";

#endif
rancid-3.13/include/config.h.in000644 015615 000000 00000013310 13735672073 016437 0ustar00heaswheel000000 000000 /* include/config.h.in.  Generated from configure.ac by autoheader.  */


#ifndef	CONFIG_H
#define	CONFIG_H	1


/* Define to 1 if you have the `asprintf' function. */
#undef HAVE_ASPRINTF

/* Define to 1 if you have the  header file. */
#undef HAVE_CTYPE_H

/* Define to 1 if you have the  header file. */
#undef HAVE_ERRNO_H

/* Define to 1 if you have the  header file. */
#undef HAVE_FCNTL_H

/* Define to 1 if you have the `index' function. */
#undef HAVE_INDEX

/* Define to 1 if you have the  header file. */
#undef HAVE_INTTYPES_H

/* Define to 1 if you have the  header file. */
#undef HAVE_LIBUTIL_H

/* Define to 1 if you have the  header file. */
#undef HAVE_LIMITS_H

/* Define to 1 if you have the  header file. */
#undef HAVE_MALLOC_H

/* Define to 1 if you have the `memcpy' function. */
#undef HAVE_MEMCPY

/* Define to 1 if you have the `memmove' function. */
#undef HAVE_MEMMOVE

/* Define to 1 if you have the  header file. */
#undef HAVE_MEMORY_H

/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET

/* Define to 1 if you have the `openpty' function. */
#undef HAVE_OPENPTY

/* "define this if your o/s has /dev/ptmx" */
#undef HAVE_PTMX

/* "define this for OSF/1 ptmx" */
#undef HAVE_PTMX_OSF

/* Define to 1 if you have the `ptsname' function. */
#undef HAVE_PTSNAME

/* Define to 1 if you have the  header file. */
#undef HAVE_PTY_H

/* Define to 1 if you have the `rindex' function. */
#undef HAVE_RINDEX

/* Define to 1 if you have the  header file. */
#undef HAVE_SIGINFO_H

/* Define to 1 if you have the  header file. */
#undef HAVE_STDARG_H

/* Define to 1 if you have the  header file. */
#undef HAVE_STDINT_H

/* Define to 1 if you have the  header file. */
#undef HAVE_STDLIB_H

/* Define to 1 if you have the `strchr' function. */
#undef HAVE_STRCHR

/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR

/* Define to 1 if cpp supports the ANSI # stringizing operator. */
#undef HAVE_STRINGIZE

/* Define to 1 if you have the  header file. */
#undef HAVE_STRINGS_H

/* Define to 1 if you have the  header file. */
#undef HAVE_STRING_H

/* Define to 1 if you have the  header file. */
#undef HAVE_STROPTS_H

/* Define to 1 if you have the `strrchr' function. */
#undef HAVE_STRRCHR

/* Define to 1 if you have the `strrtok' function. */
#undef HAVE_STRRTOK

/* Define to 1 if you have the `strstr' function. */
#undef HAVE_STRSTR

/* Define to 1 if you have the `strtok' function. */
#undef HAVE_STRTOK

/* Define to 1 if you have the  header file. */
#undef HAVE_SYSEXITS_H

/* Define to 1 if you have the  header file. */
#undef HAVE_SYS_RESOURCE_H

/* Define to 1 if you have the  header file. */
#undef HAVE_SYS_STAT_H

/* Define to 1 if you have the  header file. */
#undef HAVE_SYS_TIME_H

/* Define to 1 if you have the  header file. */
#undef HAVE_SYS_TYPES_H

/* Define to 1 if you have the  header file. */
#undef HAVE_SYS_WAIT_H

/* Define to 1 if you have the  header file. */
#undef HAVE_UNISTD_H

/* Define to 1 if you have the `unsetenv' function. */
#undef HAVE_UNSETENV

/* Define to 1 if you have the  header file. */
#undef HAVE_UTIL_H

/* Define to 1 if you have the  header file. */
#undef HAVE_WAIT_H

/* Name of package */
#undef PACKAGE

/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

/* Define to the full name of this package. */
#undef PACKAGE_NAME

/* Define to the full name and version of this package. */
#undef PACKAGE_STRING

/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME

/* Define to the home page for this package. */
#undef PACKAGE_URL

/* Define to the version of this package. */
#undef PACKAGE_VERSION

/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE

/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS

/* Version number of package */
#undef VERSION

/* Define to empty if `const' does not conform to ANSI C. */
#undef const

/* Define to `__inline__' or `__inline' if that's what the C compiler
   calls it, or to nothing if 'inline' is not supported under any name.  */
#ifndef __cplusplus
#undef inline
#endif

/* Define to `unsigned int' if  does not define. */
#undef size_t



/* damned linux... */
#if defined(LINUX) || defined(linux)
# define _GNU_SOURCE
#endif

#ifndef __P
# if STDC_HEADERS
#  define __P(a)	a
# else
#  define __P(a)	()
# endif
#endif

#if HAVE_STDLIB_H
# include 
#endif

#if HAVE_UNISTD_H
# include 
# include 
#elif HAVE_SYS_TYPES_H
# include 
#endif

#if HAVE_ERRNO_H
# include 
#endif
extern int		errno;

#if HAVE_STRING_H
# include 
#endif
#if HAVE_STRINGS_H
# include 
#endif

#if ! HAVE_STRERROR
# define strerror(n)	sys_errlist[n];
#endif

#if HAVE_WAIT_H
# include 
#elif HAVE_SYS_WAIT_H
# include 
#endif
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif

#if HAVE_SYSEXITS_H
# include 
#else
					/* missing sysexits.h */
# define EX_OK		0
# define EX_USAGE	64		/* command line usage error */
# define EX_NOINPUT	66		/* cannot open input */
# define EX_TEMPFAIL	75		/* temp failure */
# define EX_OSERR	71		/* system error */
# define EX_CANTCREAT	73		/* can't create (user) output file */
# define EX_IOERR	74		/* input/output error */
# define EX_CONFIG	78		/* configuration error */
#endif

#endif	/* CONFIG_H */

rancid-3.13/include/version.h.in000644 015615 000000 00000000164 13735672055 016662 0ustar00heaswheel000000 000000 #ifndef VERSION_H

#define VERSION_H

/* pkg version */
char package[] = "rancid";
char version[] = "3.13";

#endif
rancid-3.13/include/Makefile.in000644 015615 000000 00000035043 13735672075 016472 0ustar00heaswheel000000 000000 # Makefile.in generated by automake 1.16.2 from Makefile.am.
# @configure_input@

# Copyright (C) 1994-2020 Free Software Foundation, Inc.

# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

@SET_MAKE@

VPATH = @srcdir@
am__is_gnu_make = { \
  if test -z '$(MAKELEVEL)'; then \
    false; \
  elif test -n '$(MAKE_HOST)'; then \
    true; \
  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
    true; \
  else \
    false; \
  fi; \
}
am__make_running_with_option = \
  case $${target_option-} in \
      ?) ;; \
      *) echo "am__make_running_with_option: internal error: invalid" \
              "target option '$${target_option-}' specified" >&2; \
         exit 1;; \
  esac; \
  has_opt=no; \
  sane_makeflags=$$MAKEFLAGS; \
  if $(am__is_gnu_make); then \
    sane_makeflags=$$MFLAGS; \
  else \
    case $$MAKEFLAGS in \
      *\\[\ \	]*) \
        bs=\\; \
        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
    esac; \
  fi; \
  skip_next=no; \
  strip_trailopt () \
  { \
    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
  }; \
  for flg in $$sane_makeflags; do \
    test $$skip_next = yes && { skip_next=no; continue; }; \
    case $$flg in \
      *=*|--*) continue;; \
        -*I) strip_trailopt 'I'; skip_next=yes;; \
      -*I?*) strip_trailopt 'I';; \
        -*O) strip_trailopt 'O'; skip_next=yes;; \
      -*O?*) strip_trailopt 'O';; \
        -*l) strip_trailopt 'l'; skip_next=yes;; \
      -*l?*) strip_trailopt 'l';; \
      -[dEDm]) skip_next=yes;; \
      -[JT]) skip_next=yes;; \
    esac; \
    case $$flg in \
      *$$target_option*) has_opt=yes; break;; \
    esac; \
  done; \
  test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
subdir = include
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
	$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
	$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
	$(am__DIST_COMMON)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES = version.h
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo "  GEN     " $@;
am__v_GEN_1 = 
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 = 
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
  case $$AM_UPDATE_INFO_DIR in \
    n|no|NO) false;; \
    *) (install-info --version) >/dev/null 2>&1;; \
  esac
HEADERS = $(noinst_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
	config.h.in
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates.  Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
  BEGIN { nonempty = 0; } \
  { items[$$0] = 1; nonempty = 1; } \
  END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique.  This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
  list='$(am__tagged_files)'; \
  unique=`for i in $$list; do \
    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
  done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
	$(srcdir)/version.h.in $(top_srcdir)/mkinstalldirs
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ADMINMAILPLUS = @ADMINMAILPLUS@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
COMM = @COMM@
COPYYEARS = @COPYYEARS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CVS = @CVS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DIFF = @DIFF@
DIFF_CMD = @DIFF_CMD@
DIRNAME = @DIRNAME@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ENV_PATH = @ENV_PATH@
EXEEXT = @EXEEXT@
EXPECT_PATH = @EXPECT_PATH@
FIND = @FIND@
GIT = @GIT@
GREP = @GREP@
ID = @ID@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LG_PING_CMD = @LG_PING_CMD@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAILPLUS = @MAILPLUS@
MAINT = @MAINT@
MAKE = @MAKE@
MAKEINFO = @MAKEINFO@
MKDIR = @MKDIR@
MKDIR_P = @MKDIR_P@
MKTEMP = @MKTEMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERLV = @PERLV@
PERLV_PATH = @PERLV_PATH@
PING_PATH = @PING_PATH@
PYTHON3 = @PYTHON3@
PYTHON3_PATH = @PYTHON3_PATH@
RCSSYS = @RCSSYS@
RSH = @RSH@
SENDMAIL = @SENDMAIL@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SORT = @SORT@
SSH = @SSH@
STRIP = @STRIP@
SVN = @SVN@
SVN_FSTYPE = @SVN_FSTYPE@
TAR = @TAR@
TELNET = @TELNET@
TELNET_CMD = @TELNET_CMD@
TOUCH = @TOUCH@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@

#AUTOMAKE_OPTIONS=foreign no-dependencies
AUTOMAKE_OPTIONS = foreign
noinst_HEADERS = config.h version.h

# no idea why automake doesnt clean these targets
CLEANFILES = stamp-h stamp-h1
all: config.h
	$(MAKE) $(AM_MAKEFLAGS) all-am

.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
	@for dep in $?; do \
	  case '$(am__configure_deps)' in \
	    *$$dep*) \
	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
	        && { if test -f $@; then exit 0; else break; fi; }; \
	      exit 1;; \
	  esac; \
	done; \
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
	$(am__cd) $(top_srcdir) && \
	  $(AUTOMAKE) --foreign include/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	@case '$?' in \
	  *config.status*) \
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
	  *) \
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
	esac;

$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh

$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):

config.h: stamp-h1
	@test -f $@ || rm -f stamp-h1
	@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1

stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
	@rm -f stamp-h1
	cd $(top_builddir) && $(SHELL) ./config.status include/config.h
$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
	rm -f stamp-h1
	touch $@

distclean-hdr:
	-rm -f config.h stamp-h1
version.h: $(top_builddir)/config.status $(srcdir)/version.h.in
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@

ID: $(am__tagged_files)
	$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags

tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
	set x; \
	here=`pwd`; \
	$(am__define_uniq_tagged_files); \
	shift; \
	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
	  test -n "$$unique" || unique=$$empty_fix; \
	  if test $$# -gt 0; then \
	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
	      "$$@" $$unique; \
	  else \
	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
	      $$unique; \
	  fi; \
	fi
ctags: ctags-am

CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
	$(am__define_uniq_tagged_files); \
	test -z "$(CTAGS_ARGS)$$unique" \
	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
	     $$unique

GTAGS:
	here=`$(am__cd) $(top_builddir) && pwd` \
	  && $(am__cd) $(top_srcdir) \
	  && gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am

cscopelist-am: $(am__tagged_files)
	list='$(am__tagged_files)'; \
	case "$(srcdir)" in \
	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
	  *) sdir=$(subdir)/$(srcdir) ;; \
	esac; \
	for i in $$list; do \
	  if test -f "$$i"; then \
	    echo "$(subdir)/$$i"; \
	  else \
	    echo "$$sdir/$$i"; \
	  fi; \
	done >> $(top_builddir)/cscope.files

distclean-tags:
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags

distdir: $(BUILT_SOURCES)
	$(MAKE) $(AM_MAKEFLAGS) distdir-am

distdir-am: $(DISTFILES)
	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	list='$(DISTFILES)'; \
	  dist_files=`for file in $$list; do echo $$file; done | \
	  sed -e "s|^$$srcdirstrip/||;t" \
	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
	case $$dist_files in \
	  */*) $(MKDIR_P) `echo "$$dist_files" | \
			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
			   sort -u` ;; \
	esac; \
	for file in $$dist_files; do \
	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
	  if test -d $$d/$$file; then \
	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
	    if test -d "$(distdir)/$$file"; then \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
	  else \
	    test -f "$(distdir)/$$file" \
	    || cp -p $$d/$$file "$(distdir)/$$file" \
	    || exit 1; \
	  fi; \
	done
check-am: all-am
check: check-am
all-am: Makefile $(HEADERS) config.h
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am

installcheck: installcheck-am
install-strip:
	if test -z '$(STRIP)'; then \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	      install; \
	else \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
	fi
mostlyclean-generic:

clean-generic:
	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)

distclean-generic:
	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)

maintainer-clean-generic:
	@echo "This command is intended for maintainers to use"
	@echo "it deletes files that may require special tools to rebuild."
clean: clean-am

clean-am: clean-generic mostlyclean-am

distclean: distclean-am
	-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-hdr distclean-tags

dvi: dvi-am

dvi-am:

html: html-am

html-am:

info: info-am

info-am:

install-data-am:

install-dvi: install-dvi-am

install-dvi-am:

install-exec-am:

install-html: install-html-am

install-html-am:

install-info: install-info-am

install-info-am:

install-man:

install-pdf: install-pdf-am

install-pdf-am:

install-ps: install-ps-am

install-ps-am:

installcheck-am:

maintainer-clean: maintainer-clean-am
	-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic

mostlyclean: mostlyclean-am

mostlyclean-am: mostlyclean-generic

pdf: pdf-am

pdf-am:

ps: ps-am

ps-am:

uninstall-am:

.MAKE: all install-am install-strip

.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
	cscopelist-am ctags ctags-am distclean distclean-generic \
	distclean-hdr distclean-tags distdir dvi dvi-am html html-am \
	info info-am install install-am install-data install-data-am \
	install-dvi install-dvi-am install-exec install-exec-am \
	install-html install-html-am install-info install-info-am \
	install-man install-pdf install-pdf-am install-ps \
	install-ps-am install-strip installcheck installcheck-am \
	installdirs maintainer-clean maintainer-clean-generic \
	mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \
	tags-am uninstall uninstall-am

.PRECIOUS: Makefile


@SET_MAKE@

all:

# 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:
rancid-3.13/include/config.h000644 015615 000000 00000014036 13735706327 016040 0ustar00heaswheel000000 000000 /* include/config.h.  Generated from config.h.in by configure.  */
/* include/config.h.in.  Generated from configure.ac by autoheader.  */


#ifndef	CONFIG_H
#define	CONFIG_H	1


/* Define to 1 if you have the `asprintf' function. */
#define HAVE_ASPRINTF 1

/* Define to 1 if you have the  header file. */
#define HAVE_CTYPE_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_ERRNO_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_FCNTL_H 1

/* Define to 1 if you have the `index' function. */
#define HAVE_INDEX 1

/* Define to 1 if you have the  header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_LIBUTIL_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_LIMITS_H 1

/* Define to 1 if you have the  header file. */
/* #undef HAVE_MALLOC_H */

/* Define to 1 if you have the `memcpy' function. */
#define HAVE_MEMCPY 1

/* Define to 1 if you have the `memmove' function. */
#define HAVE_MEMMOVE 1

/* Define to 1 if you have the  header file. */
#define HAVE_MEMORY_H 1

/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1

/* Define to 1 if you have the `openpty' function. */
#define HAVE_OPENPTY 1

/* "define this if your o/s has /dev/ptmx" */
/* #undef HAVE_PTMX */

/* "define this for OSF/1 ptmx" */
/* #undef HAVE_PTMX_OSF */

/* Define to 1 if you have the `ptsname' function. */
/* #undef HAVE_PTSNAME */

/* Define to 1 if you have the  header file. */
/* #undef HAVE_PTY_H */

/* Define to 1 if you have the `rindex' function. */
#define HAVE_RINDEX 1

/* Define to 1 if you have the  header file. */
/* #undef HAVE_SIGINFO_H */

/* Define to 1 if you have the  header file. */
#define HAVE_STDARG_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the `strchr' function. */
#define HAVE_STRCHR 1

/* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 1

/* Define to 1 if cpp supports the ANSI # stringizing operator. */
#define HAVE_STRINGIZE 1

/* Define to 1 if you have the  header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the  header file. */
/* #undef HAVE_STROPTS_H */

/* Define to 1 if you have the `strrchr' function. */
#define HAVE_STRRCHR 1

/* Define to 1 if you have the `strrtok' function. */
/* #undef HAVE_STRRTOK */

/* Define to 1 if you have the `strstr' function. */
#define HAVE_STRSTR 1

/* Define to 1 if you have the `strtok' function. */
#define HAVE_STRTOK 1

/* Define to 1 if you have the  header file. */
#define HAVE_SYSEXITS_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_SYS_RESOURCE_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_SYS_TIME_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_SYS_WAIT_H 1

/* Define to 1 if you have the  header file. */
#define HAVE_UNISTD_H 1

/* Define to 1 if you have the `unsetenv' function. */
#define HAVE_UNSETENV 1

/* Define to 1 if you have the  header file. */
/* #undef HAVE_UTIL_H */

/* Define to 1 if you have the  header file. */
/* #undef HAVE_WAIT_H */

/* Name of package */
#define PACKAGE "rancid"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "rancid@shrubbery.net"

/* Define to the full name of this package. */
#define PACKAGE_NAME "rancid"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "rancid 3.13"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "rancid"

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "3.13"

/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Version number of package */
#define VERSION "3.13"

/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */

/* Define to `__inline__' or `__inline' if that's what the C compiler
   calls it, or to nothing if 'inline' is not supported under any name.  */
#ifndef __cplusplus
/* #undef inline */
#endif

/* Define to `unsigned int' if  does not define. */
/* #undef size_t */



/* damned linux... */
#if defined(LINUX) || defined(linux)
# define _GNU_SOURCE
#endif

#ifndef __P
# if STDC_HEADERS
#  define __P(a)	a
# else
#  define __P(a)	()
# endif
#endif

#if HAVE_STDLIB_H
# include 
#endif

#if HAVE_UNISTD_H
# include 
# include 
#elif HAVE_SYS_TYPES_H
# include 
#endif

#if HAVE_ERRNO_H
# include 
#endif
extern int		errno;

#if HAVE_STRING_H
# include 
#endif
#if HAVE_STRINGS_H
# include 
#endif

#if ! HAVE_STRERROR
# define strerror(n)	sys_errlist[n];
#endif

#if HAVE_WAIT_H
# include 
#elif HAVE_SYS_WAIT_H
# include 
#endif
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif

#if HAVE_SYSEXITS_H
# include 
#else
					/* missing sysexits.h */
# define EX_OK		0
# define EX_USAGE	64		/* command line usage error */
# define EX_NOINPUT	66		/* cannot open input */
# define EX_TEMPFAIL	75		/* temp failure */
# define EX_OSERR	71		/* system error */
# define EX_CANTCREAT	73		/* can't create (user) output file */
# define EX_IOERR	74		/* input/output error */
# define EX_CONFIG	78		/* configuration error */
#endif

#endif	/* CONFIG_H */

rancid-3.13/include/Makefile.am000644 015615 000000 00000000731 13534015662 016443 0ustar00heaswheel000000 000000 ## Process this file with automake to produce Makefile.in
## A Makefile.in is supplied, in case you do not have automake.

## Copyright (c) 1997-2019 by Henry Kilmer and John Heasley
## All rights reserved.
##
## Please see the file COPYING for the text of the license.

#AUTOMAKE_OPTIONS=foreign no-dependencies
AUTOMAKE_OPTIONS=foreign

@SET_MAKE@

noinst_HEADERS= config.h version.h

# no idea why automake doesnt clean these targets
CLEANFILES= stamp-h stamp-h1

all:

rancid-3.13/etc/Makefile.in000644 015615 000000 00000042636 13735672075 015630 0ustar00heaswheel000000 000000 # Makefile.in generated by automake 1.16.2 from Makefile.am.
# @configure_input@

# Copyright (C) 1994-2020 Free Software Foundation, Inc.

# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

@SET_MAKE@

VPATH = @srcdir@
am__is_gnu_make = { \
  if test -z '$(MAKELEVEL)'; then \
    false; \
  elif test -n '$(MAKE_HOST)'; then \
    true; \
  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
    true; \
  else \
    false; \
  fi; \
}
am__make_running_with_option = \
  case $${target_option-} in \
      ?) ;; \
      *) echo "am__make_running_with_option: internal error: invalid" \
              "target option '$${target_option-}' specified" >&2; \
         exit 1;; \
  esac; \
  has_opt=no; \
  sane_makeflags=$$MAKEFLAGS; \
  if $(am__is_gnu_make); then \
    sane_makeflags=$$MFLAGS; \
  else \
    case $$MAKEFLAGS in \
      *\\[\ \	]*) \
        bs=\\; \
        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
    esac; \
  fi; \
  skip_next=no; \
  strip_trailopt () \
  { \
    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
  }; \
  for flg in $$sane_makeflags; do \
    test $$skip_next = yes && { skip_next=no; continue; }; \
    case $$flg in \
      *=*|--*) continue;; \
        -*I) strip_trailopt 'I'; skip_next=yes;; \
      -*I?*) strip_trailopt 'I';; \
        -*O) strip_trailopt 'O'; skip_next=yes;; \
      -*O?*) strip_trailopt 'O';; \
        -*l) strip_trailopt 'l'; skip_next=yes;; \
      -*l?*) strip_trailopt 'l';; \
      -[dEDm]) skip_next=yes;; \
      -[JT]) skip_next=yes;; \
    esac; \
    case $$flg in \
      *$$target_option*) has_opt=yes; break;; \
    esac; \
  done; \
  test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
subdir = etc
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
	$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
	$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo "  GEN     " $@;
am__v_GEN_1 = 
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 = 
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
  case $$AM_UPDATE_INFO_DIR in \
    n|no|NO) false;; \
    *) (install-info --version) >/dev/null 2>&1;; \
  esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
    *) f=$$p;; \
  esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
  for p in $$list; do echo "$$p $$p"; done | \
  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
    if (++n[$$2] == $(am__install_max)) \
      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
    END { for (dir in files) print dir, files[dir] }'
am__base_list = \
  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
  test -z "$$files" \
    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
         $(am__cd) "$$dir" && rm -f $$files; }; \
  }
am__installdirs = "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(sysconfdir)"
DATA = $(pkgdata_DATA) $(sysconf_DATA)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/mkinstalldirs
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ADMINMAILPLUS = @ADMINMAILPLUS@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
COMM = @COMM@
COPYYEARS = @COPYYEARS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CVS = @CVS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DIFF = @DIFF@
DIFF_CMD = @DIFF_CMD@
DIRNAME = @DIRNAME@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ENV_PATH = @ENV_PATH@
EXEEXT = @EXEEXT@
EXPECT_PATH = @EXPECT_PATH@
FIND = @FIND@
GIT = @GIT@
GREP = @GREP@
ID = @ID@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LG_PING_CMD = @LG_PING_CMD@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAILPLUS = @MAILPLUS@
MAINT = @MAINT@
MAKE = @MAKE@
MAKEINFO = @MAKEINFO@
MKDIR = @MKDIR@
MKDIR_P = @MKDIR_P@
MKTEMP = @MKTEMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERLV = @PERLV@
PERLV_PATH = @PERLV_PATH@
PING_PATH = @PING_PATH@
PYTHON3 = @PYTHON3@
PYTHON3_PATH = @PYTHON3_PATH@
RCSSYS = @RCSSYS@
RSH = @RSH@
SENDMAIL = @SENDMAIL@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SORT = @SORT@
SSH = @SSH@
STRIP = @STRIP@
SVN = @SVN@
SVN_FSTYPE = @SVN_FSTYPE@
TAR = @TAR@
TELNET = @TELNET@
TELNET_CMD = @TELNET_CMD@
TOUCH = @TOUCH@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build_alias = @build_alias@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@

#AUTOMAKE_OPTIONS=foreign no-dependencies
AUTOMAKE_OPTIONS = foreign
sysconf_DATA = rancid.types.base
pkgdata_nogen = rancid.types.conf
pkgdata_gen = lg.conf.sample rancid.conf.sample
pkgdata_DATA = $(pkgdata_nogen) $(pkgdata_gen)
EXTRA_DIST = $(pkgdata_gen:%=%.in) $(pkgdata_nogen) $(sysconf_DATA)
CLEANFILES = $(pkgdata_gen)
@CONF_INSTALL_TRUE@DO_CONF_INSTALL = yes

#clean:
#	rm -f Makefile rancid.conf $(BIN_DATAS) $(BIN_PROGS)

# auto_edit does the autoconf variable substitution.  This allows the
# substitution to have the full expansion of the variables, e.g.: $sysconfdir
# will be /prefix/etc instead of ${prefix}/etc.
#
# This is a bit of a PITA, but is the method recommended by the autoconf
# documentation.
auto_edit = sed \
	-e 's,@bindir\@,$(bindir),g' \
	-e 's,@prefix\@,$(prefix),g' \
	-e 's,@localstatedir\@,$(localstatedir),g' \
	-e 's,@pkglibdir\@,$(pkglibdir),g' \
	-e 's,@sysconfdir\@,$(sysconfdir),g' \
	-e 's,@EXPECT_PATH\@,$(EXPECT_PATH),g' \
	-e 's,@PERLV_PATH\@,$(PERLV_PATH),g' \
	-e 's,@PYTHON3\@,$(PYTHON3),g' \
	-e 's,@PYTHON3_PATH\@,$(PYTHON3_PATH),g' \
	-e 's,@ENV_PATH\@,$(ENV_PATH),g' \
	-e 's,@RCSSYS\@,$(RCSSYS),g' \
	-e 's,@PACKAGE\@,$(PACKAGE),g' \
	-e 's,@SENDMAIL\@,$(SENDMAIL),g' \
	-e 's,@VERSION\@,$(VERSION),g'

all: all-am

.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
	@for dep in $?; do \
	  case '$(am__configure_deps)' in \
	    *$$dep*) \
	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
	        && { if test -f $@; then exit 0; else break; fi; }; \
	      exit 1;; \
	  esac; \
	done; \
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign etc/Makefile'; \
	$(am__cd) $(top_srcdir) && \
	  $(AUTOMAKE) --foreign etc/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	@case '$?' in \
	  *config.status*) \
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
	  *) \
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
	esac;

$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh

$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-pkgdataDATA: $(pkgdata_DATA)
	@$(NORMAL_INSTALL)
	@list='$(pkgdata_DATA)'; test -n "$(pkgdatadir)" || list=; \
	if test -n "$$list"; then \
	  echo " $(MKDIR_P) '$(DESTDIR)$(pkgdatadir)'"; \
	  $(MKDIR_P) "$(DESTDIR)$(pkgdatadir)" || exit 1; \
	fi; \
	for p in $$list; do \
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
	  echo "$$d$$p"; \
	done | $(am__base_list) | \
	while read files; do \
	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgdatadir)'"; \
	  $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgdatadir)" || exit $$?; \
	done

uninstall-pkgdataDATA:
	@$(NORMAL_UNINSTALL)
	@list='$(pkgdata_DATA)'; test -n "$(pkgdatadir)" || list=; \
	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
	dir='$(DESTDIR)$(pkgdatadir)'; $(am__uninstall_files_from_dir)
install-sysconfDATA: $(sysconf_DATA)
	@$(NORMAL_INSTALL)
	@list='$(sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \
	if test -n "$$list"; then \
	  echo " $(MKDIR_P) '$(DESTDIR)$(sysconfdir)'"; \
	  $(MKDIR_P) "$(DESTDIR)$(sysconfdir)" || exit 1; \
	fi; \
	for p in $$list; do \
	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
	  echo "$$d$$p"; \
	done | $(am__base_list) | \
	while read files; do \
	  echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(sysconfdir)'"; \
	  $(INSTALL_DATA) $$files "$(DESTDIR)$(sysconfdir)" || exit $$?; \
	done

uninstall-sysconfDATA:
	@$(NORMAL_UNINSTALL)
	@list='$(sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \
	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
	dir='$(DESTDIR)$(sysconfdir)'; $(am__uninstall_files_from_dir)
tags TAGS:

ctags CTAGS:

cscope cscopelist:


distdir: $(BUILT_SOURCES)
	$(MAKE) $(AM_MAKEFLAGS) distdir-am

distdir-am: $(DISTFILES)
	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	list='$(DISTFILES)'; \
	  dist_files=`for file in $$list; do echo $$file; done | \
	  sed -e "s|^$$srcdirstrip/||;t" \
	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
	case $$dist_files in \
	  */*) $(MKDIR_P) `echo "$$dist_files" | \
			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
			   sort -u` ;; \
	esac; \
	for file in $$dist_files; do \
	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
	  if test -d $$d/$$file; then \
	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
	    if test -d "$(distdir)/$$file"; then \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
	    fi; \
	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
	  else \
	    test -f "$(distdir)/$$file" \
	    || cp -p $$d/$$file "$(distdir)/$$file" \
	    || exit 1; \
	  fi; \
	done
check-am: all-am
check: check-am
all-am: Makefile $(DATA)
installdirs:
	for dir in "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(sysconfdir)"; do \
	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
	done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am

installcheck: installcheck-am
install-strip:
	if test -z '$(STRIP)'; then \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	      install; \
	else \
	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
	fi
mostlyclean-generic:

clean-generic:
	-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)

distclean-generic:
	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)

maintainer-clean-generic:
	@echo "This command is intended for maintainers to use"
	@echo "it deletes files that may require special tools to rebuild."
clean: clean-am

clean-am: clean-generic mostlyclean-am

distclean: distclean-am
	-rm -f Makefile
distclean-am: clean-am distclean-generic

dvi: dvi-am

dvi-am:

html: html-am

html-am:

info: info-am

info-am:

install-data-am: install-data-local install-pkgdataDATA

install-dvi: install-dvi-am

install-dvi-am:

install-exec-am: install-sysconfDATA

install-html: install-html-am

install-html-am:

install-info: install-info-am

install-info-am:

install-man:

install-pdf: install-pdf-am

install-pdf-am:

install-ps: install-ps-am

install-ps-am:

installcheck-am:

maintainer-clean: maintainer-clean-am
	-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic

mostlyclean: mostlyclean-am

mostlyclean-am: mostlyclean-generic

pdf: pdf-am

pdf-am:

ps: ps-am

ps-am:

uninstall-am: uninstall-pkgdataDATA uninstall-sysconfDATA

.MAKE: install-am install-strip

.PHONY: all all-am check check-am clean clean-generic cscopelist-am \
	ctags-am distclean distclean-generic distdir dvi dvi-am html \
	html-am info info-am install install-am install-data \
	install-data-am install-data-local install-dvi install-dvi-am \
	install-exec install-exec-am install-html install-html-am \
	install-info install-info-am install-man install-pdf \
	install-pdf-am install-pkgdataDATA install-ps install-ps-am \
	install-strip install-sysconfDATA installcheck installcheck-am \
	installdirs maintainer-clean maintainer-clean-generic \
	mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags-am \
	uninstall uninstall-am uninstall-pkgdataDATA \
	uninstall-sysconfDATA

.PRECIOUS: Makefile


install-data-local: all
	@if test "$(DO_CONF_INSTALL)" = "yes"; then \
	if test -f $(DESTDIR)$(sysconfdir)/rancid.conf ; then \
	    echo ""; \
	    echo "WARNING: *** $(DESTDIR)$(sysconfdir)/rancid.conf exists.  See "; \
	    echo "         *** $(pkgdatadir)/rancid.conf.sample for new"; \
	    echo "         *** examples."; \
	    echo ""; \
	else \
	    $(INSTALL_DATA) rancid.conf.sample $(DESTDIR)$(sysconfdir)/rancid.conf; \
	fi; \
	if test ! -f $(DESTDIR)$(sysconfdir)/rancid.types.conf ; then \
	    $(INSTALL_DATA) rancid.types.conf $(DESTDIR)$(sysconfdir)/rancid.types.conf; \
	fi; \
	if test -f $(DESTDIR)$(sysconfdir)/lg.conf ; then \
	    echo ""; \
	    echo "WARNING: *** $(DESTDIR)$(sysconfdir)/lg.conf exists.  See "; \
	    echo "         *** $(pkgdatadir)/lg.conf.sample for new"; \
	    echo "         *** examples."; \
	    echo ""; \
	else \
	    $(INSTALL_DATA) lg.conf.sample $(DESTDIR)$(sysconfdir)/lg.conf; \
	fi; \
	fi; \
	$(INSTALL_DATA) rancid.types.base $(DESTDIR)$(sysconfdir)/rancid.types.base

lg.conf.sample: Makefile $(srcdir)/lg.conf.sample.in
	rm -f lg.conf.sample lg.conf.sample.tmp; \
	$(auto_edit) $(srcdir)/lg.conf.sample.in >lg.conf.sample.tmp; \
	mv lg.conf.sample.tmp lg.conf.sample

rancid.conf.sample: Makefile $(srcdir)/rancid.conf.sample.in
	rm -f rancid.conf.sample rancid.conf.sample.tmp; \
	$(auto_edit) $(srcdir)/rancid.conf.sample.in >rancid.conf.sample.tmp; \
	mv rancid.conf.sample.tmp rancid.conf.sample

# 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:
rancid-3.13/etc/Makefile.am000644 015615 000000 00000005432 13534015140 015565 0ustar00heaswheel000000 000000 ## Process this file with automake to produce Makefile.in
## A Makefile.in is supplied, in case you do not have automake.

#AUTOMAKE_OPTIONS=foreign no-dependencies
AUTOMAKE_OPTIONS=foreign

sysconf_DATA= rancid.types.base
pkgdata_nogen = rancid.types.conf
pkgdata_gen = lg.conf.sample rancid.conf.sample
pkgdata_DATA = $(pkgdata_nogen) $(pkgdata_gen)

EXTRA_DIST= $(pkgdata_gen:%=%.in) $(pkgdata_nogen) $(sysconf_DATA)

CLEANFILES= $(pkgdata_gen)

if CONF_INSTALL
DO_CONF_INSTALL=yes
endif

install-data-local: all
	@if test "$(DO_CONF_INSTALL)" = "yes"; then \
	if test -f $(DESTDIR)$(sysconfdir)/rancid.conf ; then \
	    echo ""; \
	    echo "WARNING: *** $(DESTDIR)$(sysconfdir)/rancid.conf exists.  See "; \
	    echo "         *** $(pkgdatadir)/rancid.conf.sample for new"; \
	    echo "         *** examples."; \
	    echo ""; \
	else \
	    $(INSTALL_DATA) rancid.conf.sample $(DESTDIR)$(sysconfdir)/rancid.conf; \
	fi; \
	if test ! -f $(DESTDIR)$(sysconfdir)/rancid.types.conf ; then \
	    $(INSTALL_DATA) rancid.types.conf $(DESTDIR)$(sysconfdir)/rancid.types.conf; \
	fi; \
	if test -f $(DESTDIR)$(sysconfdir)/lg.conf ; then \
	    echo ""; \
	    echo "WARNING: *** $(DESTDIR)$(sysconfdir)/lg.conf exists.  See "; \
	    echo "         *** $(pkgdatadir)/lg.conf.sample for new"; \
	    echo "         *** examples."; \
	    echo ""; \
	else \
	    $(INSTALL_DATA) lg.conf.sample $(DESTDIR)$(sysconfdir)/lg.conf; \
	fi; \
	fi; \
	$(INSTALL_DATA) rancid.types.base $(DESTDIR)$(sysconfdir)/rancid.types.base

#clean:
#	rm -f Makefile rancid.conf $(BIN_DATAS) $(BIN_PROGS)

# auto_edit does the autoconf variable substitution.  This allows the
# substitution to have the full expansion of the variables, e.g.: $sysconfdir
# will be /prefix/etc instead of ${prefix}/etc.
#
# This is a bit of a PITA, but is the method recommended by the autoconf
# documentation.
auto_edit = sed \
	-e 's,@bindir\@,$(bindir),g' \
	-e 's,@prefix\@,$(prefix),g' \
	-e 's,@localstatedir\@,$(localstatedir),g' \
	-e 's,@pkglibdir\@,$(pkglibdir),g' \
	-e 's,@sysconfdir\@,$(sysconfdir),g' \
	-e 's,@EXPECT_PATH\@,$(EXPECT_PATH),g' \
	-e 's,@PERLV_PATH\@,$(PERLV_PATH),g' \
	-e 's,@PYTHON3\@,$(PYTHON3),g' \
	-e 's,@PYTHON3_PATH\@,$(PYTHON3_PATH),g' \
	-e 's,@ENV_PATH\@,$(ENV_PATH),g' \
	-e 's,@RCSSYS\@,$(RCSSYS),g' \
	-e 's,@PACKAGE\@,$(PACKAGE),g' \
	-e 's,@SENDMAIL\@,$(SENDMAIL),g' \
	-e 's,@VERSION\@,$(VERSION),g'

lg.conf.sample: Makefile $(srcdir)/lg.conf.sample.in
	rm -f lg.conf.sample lg.conf.sample.tmp; \
	$(auto_edit) $(srcdir)/lg.conf.sample.in >lg.conf.sample.tmp; \
	mv lg.conf.sample.tmp lg.conf.sample

rancid.conf.sample: Makefile $(srcdir)/rancid.conf.sample.in
	rm -f rancid.conf.sample rancid.conf.sample.tmp; \
	$(auto_edit) $(srcdir)/rancid.conf.sample.in >rancid.conf.sample.tmp; \
	mv rancid.conf.sample.tmp rancid.conf.sample
rancid-3.13/etc/rancid.types.conf000644 015615 000000 00000013340 13465702362 017014 0ustar00heaswheel000000 000000 # RANCiD device type configuration.
#
# DO NOT override the base types.  Copy them from rancid.types.base and rename
# them.  If you override existing types, it will be harder to provide support
# to you and we will secretly despise you.
#
# The jlocal example device type for Juniper JUNOS is a copy of the normal
# juniper type, except that it pipes the show configuration output to display
# set.
#
jlocal;script;rancid -t jlocal
jlocal;login;jlogin
jlocal;module;junos
jlocal;inloop;junos::inloop
jlocal;command;junos::ShowChassisClocks;show chassis clocks
jlocal;command;junos::ShowChassisEnvironment;show chassis environment
jlocal;command;junos::ShowChassisFirmware;show chassis firmware
jlocal;command;junos::ShowChassisFpcDetail;show chassis fpc detail
jlocal;command;junos::ShowChassisHardware;show chassis hardware detail
jlocal;command;junos::ShowChassisHardware;show chassis hardware models
jlocal;command;junos::ShowChassisRoutingEngine;show chassis routing-engine
jlocal;command;junos::ShowChassisSCB;show chassis scb
jlocal;command;junos::ShowChassisSCB;show chassis sfm detail
jlocal;command;junos::ShowChassisSCB;show chassis ssb
jlocal;command;junos::ShowChassisSCB;show chassis feb detail
jlocal;command;junos::ShowChassisSCB;show chassis feb
jlocal;command;junos::ShowChassisSCB;show chassis cfeb
jlocal;command;junos::ShowChassisAlarms;show chassis alarms
jlocal;command;junos::ShowSystemLicense;show system license
jlocal;command;junos::ShowSystemBootMessages;show system boot-messages
jlocal;command;junos::ShowSystemCoreDumps;show system core-dumps
jlocal;command;junos::ShowVersion;show version detail
jlocal;command;junos::ShowConfiguration;show configuration | display set
#
# juniper configuration database tracking
juniper-cdb;script;rancid -t juniper-cdb
juniper-cdb;login;jlogin
juniper-cdb;module;junos
juniper-cdb;inloop;junos::inloop
juniper-cdb;command;junos::ShowSystemConfDB;show system configuration database usage
#
# save copies in rancid of configs from /tftpboot
tftpcopy;script;rtftpcopy
#
# Like type cisco, but uses show tech instead of show running-config, which
# does not display passwords.  This is a good example of using two modules
# together to augment the base module.
ciscoshtech;script;rancid -t ciscoshtech
ciscoshtech;login;clogin
ciscoshtech;module;ios
ciscoshtech;module;iosshtech
ciscoshtech;inloop;ios::inloop
ciscoshtech;command;ios::ShowVersion;show version
ciscoshtech;command;ios::ShowRedundancy;show redundancy secondary
ciscoshtech;command;ios::ShowIDprom;show idprom backplane
ciscoshtech;command;ios::ShowInstallActive;show install active
ciscoshtech;command;ios::ShowEnv;show env all
ciscoshtech;command;ios::ShowRSP;show rsp chassis-info
ciscoshtech;command;ios::ShowGSR;show gsr chassis
ciscoshtech;command;ios::ShowGSR;show diag chassis-info
ciscoshtech;command;ios::ShowBoot;show boot
ciscoshtech;command;ios::ShowBoot;show bootvar
ciscoshtech;command;ios::ShowBoot;show variables boot
ciscoshtech;command;ios::ShowLicense;show license udi
ciscoshtech;command;ios::ShowLicense;show license feature
ciscoshtech;command;ios::ShowLicense;show license
ciscoshtech;command;ios::ShowLicense;show license summary
ciscoshtech;command;ios::ShowFlash;show flash:
ciscoshtech;command;ios::DirSlotN;dir /all nvram:
ciscoshtech;command;ios::DirSlotN;dir /all bootflash:
ciscoshtech;command;ios::DirSlotN;dir /all slot0:
ciscoshtech;command;ios::DirSlotN;dir /all disk0:
ciscoshtech;command;ios::DirSlotN;dir /all slot1:
ciscoshtech;command;ios::DirSlotN;dir /all disk1:
ciscoshtech;command;ios::DirSlotN;dir /all slot2:
ciscoshtech;command;ios::DirSlotN;dir /all disk2:
ciscoshtech;command;ios::DirSlotN;dir /all harddisk:
ciscoshtech;command;ios::DirSlotN;dir /all harddiska:
ciscoshtech;command;ios::DirSlotN;dir /all harddiskb:
ciscoshtech;command;ios::DirSlotN;dir /all sup-bootdisk:;c6500 sup32
ciscoshtech;command;ios::DirSlotN;dir /all sup-bootflash:;c6500 ios
ciscoshtech;command;ios::DirSlotN;dir /all sup-microcode:;c6500 ios
ciscoshtech;command;ios::DirSlotN;dir /all slavenvram:
ciscoshtech;command;ios::DirSlotN;dir /all slavebootflash:
ciscoshtech;command;ios::DirSlotN;dir /all slaveslot0:
ciscoshtech;command;ios::DirSlotN;dir /all slavedisk0:
ciscoshtech;command;ios::DirSlotN;dir /all slaveslot1:
ciscoshtech;command;ios::DirSlotN;dir /all slavedisk1:
ciscoshtech;command;ios::DirSlotN;dir /all slaveslot2:
ciscoshtech;command;ios::DirSlotN;dir /all slavedisk2:
ciscoshtech;command;ios::DirSlotN;dir /all slavesup-bootflash:;c7600
ciscoshtech;command;ios::DirSlotN;dir /all sec-nvram:
ciscoshtech;command;ios::DirSlotN;dir /all sec-bootflash:
ciscoshtech;command;ios::DirSlotN;dir /all sec-slot0:
ciscoshtech;command;ios::DirSlotN;dir /all sec-disk0:
ciscoshtech;command;ios::DirSlotN;dir /all sec-slot1:
ciscoshtech;command;ios::DirSlotN;dir /all sec-disk1:
ciscoshtech;command;ios::DirSlotN;dir /all sec-slot2:
ciscoshtech;command;ios::DirSlotN;dir /all sec-disk2:
ciscoshtech;command;ios::ShowContAll;show controllers
ciscoshtech;command;ios::ShowContCbus;show controllers cbus
ciscoshtech;command;ios::ShowDiagbus;show diagbus
ciscoshtech;command;ios::ShowDiag;show diag
ciscoshtech;command;ios::ShowModule;show module;c6500 ios
ciscoshtech;command;ios::ShowSpeVersion;show spe version
ciscoshtech;command;ios::ShowC7200;show c7200
ciscoshtech;command;ios::ShowCellular;show cellular 0 profile;Cellular modem
ciscoshtech;command;ios::ShowInventory;show inventory raw
ciscoshtech;command;ios::ShowVTP;show vtp status
ciscoshtech;command;ios::ShowVLAN;show vlan
ciscoshtech;command;ios::ShowVLAN;show vlan-switch
ciscoshtech;command;ios::ShowDetail;show switch detail
ciscoshtech;command;ios::ShowSDM;show sdm prefer
ciscoshtech;command;ios::ShowMTU;show system mtu
ciscoshtech;command;ios::ShowDebug;show debug
ciscoshtech;command;iosshtech::WriteTerm;show tech-support
#
rancid-3.13/etc/lg.conf.sample.in000644 015615 000000 00000014604 13465702362 016704 0ustar00heaswheel000000 000000 # @PACKAGE@ @VERSION@
# configuration file for the looking glass
#
# note: these are perl statements!  Mind the syntax.  "perl -c lg.conf"
#	should succeed.
#
# adjust the path to find [cfj]login, telnet, ssh, rsh, etc.
#
$ENV{PATH}="@prefix@/bin:@ENV_PATH@";
#
#
# LG_CACHE_DIR	is the location of the cache directory.  the LG uses this
#		to hold lock files, the default log file (lg.log), and o/p from
#		commands that can be very verbose.  it defaults to "tmp",
#		i.e.: relative to the directory where lg.cgi runs in your
#		server's (httpd) DocumentRoot (e.g.:
#		/usr/local/www/data/lg/tmp).
#
#$LG_CACHE_DIR="./tmp";
#
#
# LG_CACHE_TIME	is the number of seconds the LG should cache o/p from certain
#		commands; those that tend to produce a lot of o/p, such as
#		'show ip bgp dampened-paths'.  it defaults to 600 seconds
#		(10 minutes).
#
#$LG_CACHE_TIME=600;
#
#
# LG_CLOGINRC	is the .cloginrc that the LG should use.  it defaults to
#		/.cloginrc.  note that the .cloginrc must be readable
#		by the user or group (UID / GID) that will be running the CGI
#		and the clogin (and friends) will not allow a world readable
#		.cloginrc.  this is normally the user the server (httpd) runs
#		under.
#
#$LG_CLOGINRC="$ENV(HOME)/.cloginrc";
#
#
# LG_IMAGE	is the filename of an image you wish to appear at the top
#		of the LG pages.  it can also be other html goo, like
#		the first example.  this is just handed to print, so \n and
#		the like will work and mind the character escapes (backslashes).
#
#$LG_IMAGE="\n FOO";
#$LG_IMAGE="\n";
#
#
# LG_INFO	is info in html format to output at the bottom of main form.
#		it might be local contact information, disclaimer, etc.  this
#		is just handed to print, so \n and the like will work and mind
#		the character escapes (backslashes).
#
#$LG_INFO="For support, contact webmaster";
#
#
# LG_LOG	is either a FQPN (fully qualified path name) or the syslog
#		facility to use for logging.  if not defined, the LG
#		will log to LG_CACHE_DIR/lg.log.  possible syslog facility
#		values are from the facility codes in /usr/include/syslog.h
#		minus the 'LOG_' and lower case.
#
#$LG_LOG="$LG_CACHE_DIR/lg.log";
#$LG_LOG="/tmp/lg.log";
#$LG_LOG="local0";
#
#
# LG_ROUTERDB	is the router.db in rancid's router.db format, listing
#		the routers and their platform that should be available in
#		the looking glass.  if defined, the LG will use this variable
#		to find the router.db.  if not defined, it will look for it
#		at //router.db.  if it does not exist, it
#		will build the list from /*/router.db (i.e.: the
#		router.db's from all your groups).  note that if you choose
#		this last option; the group directories and router.db files'
#		modes may have to be changed, depending upon the UID/GID of
#		the user your server (httpd) runs under, since rancid's default
#		mask is 007 (see etc/rancid.conf).  routers not marked 'up' are
#		skipped.
#
#$LG_ROUTERDB="@sysconfdir@/router.db";
#
#
# LG_STYLE	define a style sheet to be used for formatting HTML.
#
#$LG_STYLE="http://www.your.site/style/style.css";
#
#
# Options:
#
# LG_AS_REG	*** not implemented.
#
#@LG_AS_REG=();
#
#
# LG_BGP_RT	allows a few bgp commands which can produce long output (heavy
#		router load), such as sh ip bgp neighbor  advertised-routes
#		would for a transit customer or sh ip b neigh 
#		received-routes would for a transit provider.
#
#$LG_BGP_RT=1;
#
#
# LG_SINGLE	serializes and limits queries per-router to one at a time via
#		per-router lock files.
#
#$LG_SINGLE=0;
#
# LG_STRIP	strips login o/p from the looking glass results.  Expect
#		occassionally screws up disabling echo when passwords are
#		entered (NOTE: SECURITY CONCERN).  However, this o/p can be
#		very useful for debugging clogin/flogin/jlogin problems.
#
$LG_STRIP=1;
#
#
# Commands/Queries:
#		Un-comment/Comment the commands that are desired/not desired.
#		The Commands are separated into a few categories.  The value
#		of each variable is the string which will appear in the
#		(lgform.cgi) menu.  Mind the ,'s within hash assignments.
#
#		The double-commented (##) queries are not implemented or have
#		not been tested.
#
$queries = {};
#
# Interface queries
$queries->{"interface"} = {
	framerelay => "show frame-relay PVC [DLCI]",
	intdescr => "show interface description",
	interface => "show interface [interface]",
	intoptics => "show interface optics ",
	intwanphy => "show interface wanphy "
};
#
# Routing queries
$queries->{"routing"} = {
	damp => "show ip bgp dampened-paths",
	neighbor => "show ip bgp neighbor ",
	prefix => "show ip bgp  [netmask]",
	prefixlist => "show ip prefix-list ",
	regex => "show ip bgp regex ",
	route => "show ip route  [netmask]",
	routemap => "show route-map ",
	summary => "show ip bgp summary"
};
#
# Debug queries
$queries->{"debug"} = {
	log => "Show Logs [ | ]",
	ping => "ping ",
	trace => "traceroute "
};
#
# Multicast queries
$queries->{"multicast"} = {
	mbgp => "Show ip mbgp  [netmask]",
	mbgpsum => "Show ip mbgp summary",
	# show ip pim interface/show pim interface
	## pim_interface => "Show PIM Interfaces",
	# ???/show pim join (extensive)
	## pim_join => "Show PIM Join [group_address]",
	# show ip mroute/show multicast route [active]
	## mroute => "Show Multicast Forwarding Table [active]",
	# show ip msdp summary/show msdp
	## msdp => "Show MSDP Peering Status",
	# show ip msdp sa cache/show msdp source-active
	## msdpsa => "Show MSDP Source Active Table",
	# show ip sdr|show multicast sessions
	## msess => "Show Multicast SDR sessions [detail]",
	# show ip pim neighbor/show pim neighbors
	## pim_neighbor => "Show PIM Neighbors [detail]",
	# show ip pim rp mapping/show pim rps
	## pim_rp => "Show PIM Rendez-vous Points [detail]",
	# show ip rpf [address] /show multicast rpf [address]
	## rpf => "Test Multicast RPF 
" }; # # IPv6 commands $queries->{"ipv6"} = { # show bgp ipv6 / ??? ## v6_bgp => "Show IPv6 BGP table"; # show ipv6 interface / show interface ## v6_interface => "Show IPv6 interface parameters [interface]"; # show bgp ipv6 summary / show bgp summary ## v6_summary => "Show IPv6 BGP Summary"; # show ipv6 route / show route table inet6.0 ## v6_route => "Show IPv6 Routes "; }; # # %EOF% rancid-3.13/etc/rancid.conf.sample.in000644 015615 000000 00000013212 13657102757 017541 0ustar00heaswheel000000 000000 # @PACKAGE@ @VERSION@ # This file sets up the environment used for rancid. see rancid.conf(5) # # This will be site specific # TERM=network;export TERM # # Collating locale LC_COLLATE="POSIX"; export LC_COLLATE # # Create files w/o world read/write/exec permissions, but read/exec permissions # for group. umask 027 # # Set the perl module search path. perl -V shows the default PERL5LIB="@pkglibdir@"; export PERL5LIB # # Under BASEDIR (i.e.: --localstatedir), there will be a "logs" directory for # the logs from rancid and a directory for each group of routers defined in # LIST_OF_GROUPS (below). In addition to these, there will be a "CVS" # directory which is the cvs (or Subversion) repository. # # Use a full path (no sym-links) for BASEDIR. # TMPDIR=/tmp; export TMPDIR # Be careful changing this, it affects CVSROOT below. It should be a FQPN, not # relative. BASEDIR=@localstatedir@; export BASEDIR PATH=@bindir@:@ENV_PATH@; export PATH # # Check that the effective UID is not root, which could lead to permissions # problems for user who is supposed to be running rancid. If you know what # you are doing, disable this check by commenting these lines. uid=`perl -e 'print "$>"'` if [ -e /proc/1/cgroup ] ; then DOCKER=`cat /proc/1/cgroup | grep "cpu.*\/docker"` fi test "x$DOCKER" = "x" && test "$uid" -eq 0 && echo "Do not run $0 as root!" && exit 1 # # Set to the name of the sendmail executable (or script) that will accept the # -t option to take its rcpt and other headers from stdin and $MAILOPTS (see # below). SENDMAIL="@SENDMAIL@" # # Location of the CVS/SVN/GIT repository(ies). Be careful changing this. # If RCSSYS is svn or git, this can be: # - an (absolute) path (a subdirectory of BASEDIR by default). BASEDIR/CVS, # BASEDIR/.svn, or BASEDIR/.scm; the name does not matter, but do not use # BASEDIR/.git, as it will confuse git. # - for git, there will be a repository under CVSROOT for each rancid group. # - any URL that git or subversion understand, but beware that: # - no attempt will be made to create the repository when running rancid-cvs. # - authentication credentials, if necessary, MUST be cached (see the SVN # book, Ch. 3, Network Model, Caching credentials) before non-interactive # commands can run, e.g. by running rancid-cvs after installation. # - for git, it is likely easiest to leave CVSROOT as a local path, use # rancid-cvs to create the repository for groups, then move those # repositories to the remote and update the group's .git/config. CVSROOT=$BASEDIR/CVS; export CVSROOT # Location of log files produced by rancid-run(1). LOGDIR=$BASEDIR/logs; export LOGDIR # # Select which RCS system to use, "cvs" (default), "svn" or "git". Do not # change this after CVSROOT has been created with rancid-cvs. Changing between # these requires manual conversions. RCSSYS=@RCSSYS@; export RCSSYS # # if ACLFILTERSEQ is NO, prefix-list/access-list sequence numbers will NOT be # filtered. this option implies ACLSORT=NO for lists with sequence numbers. #ACLFILTERSEQ=YES; export FILTERSEQ # # if ACLSORT is NO, access-lists will NOT be sorted. #ACLSORT=YES; export ACLSORT # # FILTER_PWDS determines which passwords are filtered from configs by the # value set (NO | YES | ALL). see rancid.conf(5). #FILTER_PWDS=YES; export FILTER_PWDS # # if NOCOMMSTR is set to YES, snmp community strings will be stripped from the # configs. #NOCOMMSTR=YES; export NOCOMMSTR # # FILTER_OSC determines if oscillating data such as keys, passwords, etc are # filtered from configs by the value set (NO | YES | ALL). FILTER_PWDS may # override this. see rancid.conf(5). #FILTER_OSC=YES; export FILTER_OSC # # How many times failed collections are retried (for each run) before # giving up. Minimum: 0 #MAX_ROUNDS=4; export MAX_ROUNDS # # How many hours should pass before complaining about routers that # can not be reached. The value should be greater than the number # of hours between your rancid-run cron job. Default: 24 #OLDTIME=4; export OLDTIME # # How many hours should pass before complaining that a group's collection # (the age of it's lock file) is hung. #LOCKTIME=4; export LOCKTIME # # The number of devices to collect simultaneously. #PAR_COUNT=5; export PAR_COUNT # # list of rancid groups #LIST_OF_GROUPS="sl joebobisp"; export LIST_OF_GROUPS # more groups... #LIST_OF_GROUPS="$LIST_OF_GROUPS noc billybobisp"; export LIST_OF_GROUPS # # Define an alternate filter for the output of the RCS diff. The filter # should read from stdin and write to stdout. The default is defined in # control_rancid and just improves readability. #DIFFSCRIPT="filter1 | filter2"; export DIFFSCRIPT # # For each group, define a list of people to receive the diffs. # in sendmail's /etc/aliases. # rancid-group: joe,moe@foo # rancid-admin-group: hostmaster # be sure to read ../README regarding aliases. # # If your MTA configuration is broken or you want mail to be forwarded to a # domain not the same as the local one, define that domain here. "@" must be # included, as this is simply appended to the usual recipients. It is NOT # appended to recipients specified in rancid-run's -m option. #MAILDOMAIN="@example.com"; export MAILDOMAIN # # By default, rancid mail is marked with precedence "bulk" and etc, as in the # example. This may be changed by setting the MAILHEADERS variable; for # example no header by setting it to "" or adding X- style headers. Individual # headers must be separated by a \n. #MAILHEADERS="Precedence: bulk\nAuto-submitted: auto-generated\nX-Auto-Response-Suppress: All"; export MAILHEADERS # # Additional options for sendmail(8). #MAILOPTS="-f bounces.go.here@example.com"; export MAILOPTS # # Split diffs larger then N kbytes #MAILSPLIT=0; export MAILSPLIT rancid-3.13/etc/rancid.types.base000644 015615 000000 00000111472 13735654704 017014 0ustar00heaswheel000000 000000 # RANCiD base device type configuration. # # DO NOT alter the base device types, they WILL be over-written by future RANCiD # release installations. Customize them by creating clones in rancid.types.conf # with a different type name. If you override existing types, it will be harder # to provide support to you and I will make a voodoo doll in your likeness. # a10;script;rancid -t a10 a10;login;a10login a10;module;acos a10;inloop;acos::inloop a10;command;acos::ShowVersion;show version a10;command;acos::ShowLicense;show license a10;command;acos::ShowBootimage;show bootimage a10;command;acos::ShowAdmin;show admin a10;command;acos::ShowVlan;show vlan a10;command;acos::ShowVlan;show vlans a10;command;acos::ShowAflex;show aflex all-partitions a10;command;acos::ShowRunningConfig;show running-config all-partitions a10;command;acos::ShowRunningConfig;show partition-config all # agm;script;agmrancid # # XXX This was the start of support for adtran, but it is incomplete. #adtran;script;rancid -t adtran #adtran;module;adtran #adtran;inloop;adtran::inloop #adtran;login;clogin # TA5000 #adtran;command;adtran::ShowVersion;show version #adtran;command;adtran::ShowSystemInventory;show system inventory #adtran;command;adtran::ShowTableInterfaces;show table interfaces #adtran;command;adtran::ShowEvc;show evc #adtran;command;adtran::ShowEvcmap;show evc-map #adtran;command;adtran::ShowEfmgroup;show efm-group 1 #adtran;command;adtran::ShowInterfacesShdsl;show interfaces shdsl #adtran;command;adtran::ShowInterfacesAdsl;show interfaces adsl # EFM NTU #adtran;command;adtran::ShowInterfaces;show interfaces #adtran;command;adtran::WriteTerm;show running-config # alteon;script;arancid alteon;login;alogin # arbor;script;rancid -t arbor arbor;login;anlogin arbor;module;arbor arbor;inloop;arbor::inloop arbor;command;arbor::ShowVersion;system version arbor;command;arbor::ShowVersion;system file show arbor;command;arbor::ShowHardware;system hardware arbor;command;arbor::ShowHardware;system show arbor;command;arbor::ShowFlash;system disk show arbor;command;arbor::ShowConfig;config show # # Arrcus arcos;script;rancid -t arcos arcos;login;xilogin arcos;module;arcos arcos;inloop;arcos::inloop arcos:command;rancid::RunCommand;timestamp disable arcos;command;arcos::ShowVersion;show version arcos;command;arcos::ShowHardware;show hardware | notab # perhaps replace/augment show hardware with show component #XXX arcos;command;arcos::ShowHardware;show component host* #XXX arcos;command;arcos::ShowHardware;show component fan* #XXX arcos;command;arcos::ShowHardware;show component psu* #XXX arcos;command;arcos::ShowHardware;show component sfp* arcos;command;arcos::WriteTerm;show running-config # arista;script;rancid -t arista arista;login;clogin arista;module;aeos arista;inloop;aeos::inloop arista;command;aeos::ShowVersion;show version arista;command;aeos::ShowBoot;show boot-config arista;command;aeos::ShowEnv;show env all arista;command;aeos::ShowFlash;dir flash: arista;command;aeos::ShowInventory;show inventory arista;command;aeos::ShowBootExt;show boot-extensions arista;command;aeos::ShowExt;show extensions arista;command;aeos::DiffConfig;diff startup-config running-config #arista;command;aeos::WriteRibd;show tech ribd running arista;command;aeos::WriteTerm;show running-config # # AXIS T8504R switch # This reportedly resembles Cisco IOS sufficiently that this works. axis;script;rancid -t axis axis;login;clogin axis;module;ios axis;inloop;ios::inloop axis;command;ios::ShowVersion;show version axis;command;ios::ShowVLAN;show vlan axis;command;ios::WriteTerm;show running-config # baynet;script;brancid baynet;login;blogin # # Brocade #XXX brocade;script;rancid -t brocade brocade;login;brlogin #XXX brocade;module; XXX #XXX brocade;inloop; XXX #XXX brocade;command;XXX::ChassisShow;chassisShow #XXX brocade;command;XXX::FirmwareShow;firmwareShow #XXX brocade;command;XXX::FirmwareShow;version #XXX brocade;command;XXX::FirmwareShow;zoneshow #XXX brocade;command;XXX::FirmwareShow;portcfgshow #XXX brocade;command;XXX::Fosconfig;fosConfig --show #XXX brocade;command;XXX::IpAddrShow;ipAddrShow #XXX brocade;command;XXX::LicenseShow;licenseShow #XXX brocade;command;XXX::DomainsShow;domainsShow #XXX brocade;command;XXX::ConfigShow;configShow # # Ciena Waveserver ciena-ws;script;rancid -t ciena-ws ciena-ws;login;hlogin ciena-ws;timeout;120 ciena-ws;module;wavesvros ciena-ws;inloop;wavesvros::inloop ciena-ws;command;wavesvros::ShowVersion;software show ciena-ws;command;wavesvros::GenericCmd;license file list ciena-ws;command;wavesvros::ShowChassis;chassis show ciena-ws;command;wavesvros::GenericCmd;blade show ciena-ws;command;wavesvros::GenericCmd;alarm show ciena-ws;command;wavesvros::WriteTerm;configuration show # # Cisco Catalyst 5k (all catalyst o/s switches) cat5;script;cat5rancid cat5;login;clogin # # Cisco IOS device & Allied Telesis AW+ ios;alias;cisco cisco;script;rancid -t cisco cisco;login;clogin cisco;module;ios cisco;inloop;ios::inloop cisco;command;ios::ShowVersion;show version cisco;command;ios::ShowRedundancy;show redundancy secondary cisco;command;ios::ShowIDprom;show idprom backplane cisco;command;ios::ShowInstallActive;show install active cisco;command;ios::ShowEnv;show env all cisco;command;ios::ShowRSP;show rsp chassis-info cisco;command;ios::ShowGSR;show gsr chassis cisco;command;ios::ShowGSR;show diag chassis-info cisco;command;ios::ShowBoot;show boot cisco;command;ios::ShowBoot;show bootvar cisco;command;ios::ShowBoot;show variables boot cisco;command;ios::ShowLicense;show license udi cisco;command;ios::ShowLicense;show license feature cisco;command;ios::ShowLicense;show license cisco;command;ios::ShowLicense;show license summary cisco;command;ios::ShowActivationKey;show activation-key;ASA/PIX cisco;command;ios::ShowFlash;show flash: cisco;command;ios::DirSlotN;dir /all nvram: cisco;command;ios::DirSlotN;dir /all bootflash: cisco;command;ios::DirSlotN;dir /all slot0: cisco;command;ios::DirSlotN;dir /all disk0: cisco;command;ios::DirSlotN;dir /all slot1: cisco;command;ios::DirSlotN;dir /all disk1: cisco;command;ios::DirSlotN;dir /all slot2: cisco;command;ios::DirSlotN;dir /all disk2: cisco;command;ios::DirSlotN;dir /all harddisk: cisco;command;ios::DirSlotN;dir /all harddiska: cisco;command;ios::DirSlotN;dir /all harddiskb: cisco;command;ios::DirSlotN;dir /all sup-bootdisk:;c6500 sup32 cisco;command;ios::DirSlotN;dir /all sup-bootflash:;c6500 ios cisco;command;ios::DirSlotN;dir /all sup-microcode:;c6500 ios cisco;command;ios::DirSlotN;dir /all slavenvram: cisco;command;ios::DirSlotN;dir /all slavebootflash: cisco;command;ios::DirSlotN;dir /all slaveslot0: cisco;command;ios::DirSlotN;dir /all slavedisk0: cisco;command;ios::DirSlotN;dir /all slaveslot1: cisco;command;ios::DirSlotN;dir /all slavedisk1: cisco;command;ios::DirSlotN;dir /all slaveslot2: cisco;command;ios::DirSlotN;dir /all slavedisk2: cisco;command;ios::DirSlotN;dir /all slavesup-bootflash:;c7600 cisco;command;ios::DirSlotN;dir /all sec-nvram: cisco;command;ios::DirSlotN;dir /all sec-bootflash: cisco;command;ios::DirSlotN;dir /all sec-slot0: cisco;command;ios::DirSlotN;dir /all sec-disk0: cisco;command;ios::DirSlotN;dir /all sec-slot1: cisco;command;ios::DirSlotN;dir /all sec-disk1: cisco;command;ios::DirSlotN;dir /all sec-slot2: cisco;command;ios::DirSlotN;dir /all sec-disk2: cisco;command;ios::ShowContAll;show controllers cisco;command;ios::ShowContCbus;show controllers cbus cisco;command;ios::ShowDiagbus;show diagbus cisco;command;ios::ShowDiag;show diag cisco;command;ios::ShowCapture;show capture;ASA/PIX cisco;command;ios::ShowModule;show module switch;c6500 ios vss cisco;command;ios::ShowModule;show module;c6500 ios cisco;command;ios::ShowSpeVersion;show spe version cisco;command;ios::ShowC7200;show c7200 cisco;command;ios::ShowCellular;show cellular 0 profile;Cellular modem cisco;command;ios::ShowHWProgrammable;show hw-programmable all cisco;command;ios::ShowInventory;show inventory raw cisco;command;ios::ShowInventory;show inventory;ASA/PIX cisco;command;ios::ShowVTP;show vtp status cisco;command;ios::ShowDot1x;show dot1x cisco;command;ios::ShowVLAN;show vlan cisco;command;ios::ShowVLAN;show vlan-switch cisco;command;ios::ShowDetail;show switch detail cisco;command;ios::ShowSDM;show sdm prefer cisco;command;ios::ShowMTU;show system mtu cisco;command;ios::ShowDebug;show debug cisco;command;ios::ShowShun;show shun;ASA/PIX cisco;command;ios::WriteTerm;more system:running-config;ASA/PIX cisco;command;ios::WriteTerm;show running-config view full;workaround for role-based CLI cisco;command;ios::WriteTerm;show running-config cisco;command;ios::WriteTerm;write term # ios-nx;alias;cisco-nx cisco-nx;script;rancid -t cisco-nx cisco-nx;login;clogin cisco-nx;module;nxos cisco-nx;inloop;nxos::inloop cisco-nx;command;rancid::RunCommand;term no monitor-force cisco-nx;command;nxos::ShowVersion;show version cisco-nx;command;nxos::ShowVersionBuild;show version build-info all cisco-nx;command;nxos::ShowLicense;show license cisco-nx;command;nxos::ShowLicense;show license usage cisco-nx;command;nxos::ShowLicense;show license host-id cisco-nx;command;nxos::ShowRedundancy;show system redundancy status cisco-nx;command;nxos::ShowEnv;show environment clock cisco-nx;command;nxos::ShowEnv;show environment fan cisco-nx;command;nxos::ShowEnv;show environment fex all fan cisco-nx;command;nxos::ShowEnvTemp;show environment temperature cisco-nx;command;nxos::ShowEnvPower;show environment power cisco-nx;command;nxos::ShowBoot;show boot cisco-nx;command;nxos::DirSlotN;dir bootflash: cisco-nx;command;nxos::DirSlotN;dir debug: cisco-nx;command;nxos::DirSlotN;dir logflash: cisco-nx;command;nxos::DirSlotN;dir slot0: cisco-nx;command;nxos::DirSlotN;dir usb1: cisco-nx;command;nxos::DirSlotN;dir usb2: cisco-nx;command;nxos::DirSlotN;dir volatile: cisco-nx;command;nxos::ShowModule;show module cisco-nx;command;nxos::ShowModule;show module xbar #cisco-nx;command;nxos::ShowModule;show module X;add, but wait for show all #cisco-nx;command;nxos::ShowModule;show module X epld;add, but wait for show all cisco-nx;command;nxos::ShowInventory;show inventory cisco-nx;command;nxos::ShowIntTransceiver;show interface transceiver cisco-nx;command;nxos::ShowVTP;show vtp status;drop? cisco-nx;command;nxos::ShowVLAN;show vlan cisco-nx;command;nxos::ShowDebug;show debug cisco-nx;command;nxos::ShowCores;show cores vdc-all cisco-nx;command;nxos::ShowProcLog;show processes log vdc-all cisco-nx;command;nxos::ShowFex;show module fex cisco-nx;command;nxos::ShowFex;show fex cisco-nx;command;nxos::WriteTerm;show running-config # # Cisco small business devices. These are peculiar; most likely this will not # work with all of them, but is also reported to work with other Marvell OEMs, # including PowerConnect 5448 ios-sb;alias;cisco-sb cisco-sb;script;rancid -t cisco-sb cisco-sb;login;csblogin cisco-sb;module;iossb cisco-sb;inloop;iossb::inloop cisco-sb;command;iossb::ShowVersion;show version cisco-sb;command;iossb::ShowSystem;show system cisco-sb;command;iossb::WriteTerm;show running-config # # IOS-XR or IOS-cXR (Classic XR) ios-xr;alias;cisco-xr cisco-xr;script;rancid -t cisco-xr cisco-xr;login;clogin cisco-xr;module;iosxr cisco-xr;inloop;iosxr::inloop cisco-xr;command;rancid::RunCommand;terminal no-timestamp;Disable timestamps XR 3.6 cisco-xr;command;rancid::RunCommand;terminal exec prompt no-timestamp;Disable timestamps XR 3.8 cisco-xr;command;iosxr::ShowVersion;admin show version cisco-xr;command;iosxr::ShowInstallSummary;admin show install active cisco-xr;command;iosxr::ShowLicense;admin show license udi;XR image cisco-xr;command;iosxr::ShowLicense;admin show license;XR image cisco-xr;command;iosxr::ShowBootVar;admin show variables boot;XR image cisco-xr;command;iosxr::ShowHWfpd;admin show hw-module fpd location all;XR LC images cisco-xr;command;iosxr::ShowRedundancy;show redundancy cisco-xr;command;iosxr::ShowInstallActive;show install active cisco-xr;command;iosxr::ShowEnv;admin show env all cisco-xr;command;iosxr::DirSlotN;dir /all nvram: cisco-xr;command;iosxr::DirSlotN;dir /all bootflash: cisco-xr;command;iosxr::DirSlotN;dir /all compactflash: cisco-xr;command;iosxr::DirSlotN;dir /all compactflasha: cisco-xr;command;iosxr::DirSlotN;dir /all slot0: cisco-xr;command;iosxr::DirSlotN;dir /all disk0: cisco-xr;command;iosxr::DirSlotN;dir /all disk0a: cisco-xr;command;iosxr::DirSlotN;dir /all slot1: cisco-xr;command;iosxr::DirSlotN;dir /all disk1: cisco-xr;command;iosxr::DirSlotN;dir /all disk1a: cisco-xr;command;iosxr::DirSlotN;dir /all slot2: cisco-xr;command;iosxr::DirSlotN;dir /all disk2: cisco-xr;command;iosxr::DirSlotN;dir /all harddisk: cisco-xr;command;iosxr::DirSlotN;dir /all harddiska: cisco-xr;command;iosxr::DirSlotN;dir /all harddiskb: cisco-xr;command;iosxr::ShowContAll;show controllers cisco-xr;command;iosxr::AdminShowDiag;admin show diag cisco-xr;command;iosxr::ShowInventory;admin show inventory raw cisco-xr;command;iosxr::ShowVLAN;show vlan cisco-xr;command;iosxr::ShowDebug;show debug cisco-xr;command;iosxr::ShowRPL;show rpl maximum cisco-xr;command;iosxr::AdminShowRunning;admin show running cisco-xr;command;iosxr::WriteTerm;show running-config # # Variant cisco-xr/ios-xr commands for IOS-XR 7.x on NCS. Presumably, this # and ios-exr will eventually merge. cisco-xr7;alias;ios-xr7 ios-xr7;script;rancid -t ios-xr7 ios-xr7;login;clogin ios-xr7;module;iosxr ios-xr7;inloop;iosxr::inloop ios-xr7;command;rancid::RunCommand;terminal exec prompt no-timestamp ios-xr7;command;iosxr::ShowVersion;show version ios-xr7;command;iosxr::ShowMemorySum;show memory summary ios-xr7;command;iosxr::ShowInstallActive;show install active ios-xr7;command;iosxr::ShowLicense;show license udi ios-xr7;command;iosxr::ShowLicense;show license summary ios-xr7;command;iosxr::ShowHWfpd;show hw-module fpd ios-xr7;command;iosxr::ShowRedundancy;show redundancy ios-xr7;command;iosxr::ShowEnv;show env all ios-xr7;command;iosxr::DirSlotN;dir /all config: ios-xr7;command;iosxr::DirSlotN;dir /all disk0: ios-xr7;command;iosxr::DirSlotN;dir /all harddisk: ios-xr7;command;iosxr::ShowContAll;show controllers description ios-xr7;command;iosxr::AdminShowDiag;show diag ios-xr7;command;iosxr::ShowInventory;show inventory raw ios-xr7;command;iosxr::ShowDebug;show debug ios-xr7;command;iosxr::ShowRPL;show rpl maximum ios-xr7;command;iosxr::WriteTerm;show running-config # # IOS-eXR (enhanced XR, aka 64bit). IOS-eXR (>= 6.0) and ios-exr-lite (>=7.0); # not all versions >= 6.0 are eXR(-lite), some are cXR! cisco-exr;alias;ios-exr ios-exr;script;rancid -t ios-exr ios-exr;login;clogin ios-exr;module;iosxr ios-exr;inloop;iosxr::inloop ios-exr;command;rancid::RunCommand;terminal exec prompt no-timestamp;Disable timestamps ios-exr;command;iosxr::ShowVersion;show version ios-exr;command;iosxr::ShowMemorySum;show memory summary;XXX does this display secondary RP info? ios-exr;command;iosxr::ShowInstallSummary;admin show install active ios-exr;command;iosxr::ShowLicense;show license all # ios-exr;command;iosxr::ShowBootVar;show variables boot;XXX this command is broken ios-exr;command;iosxr::ShowHWfpd;show hw-module fpd;eXR LC images ios-exr;command;iosxr::ShowRedundancy;show redundancy ios-exr;command;iosxr::ShowInstallActive;show install active ios-exr;command;iosxr::ShowEnv;admin show env all ios-exr;command;iosxr::DirSlotN;dir /all nvram: ios-exr;command;iosxr::DirSlotN;dir /all bootflash: ios-exr;command;iosxr::DirSlotN;dir /all compactflash: ios-exr;command;iosxr::DirSlotN;dir /all compactflasha: ios-exr;command;iosxr::DirSlotN;dir /all slot0: ios-exr;command;iosxr::DirSlotN;dir /all disk0: ios-exr;command;iosxr::DirSlotN;dir /all disk0a: ios-exr;command;iosxr::DirSlotN;dir /all slot1: ios-exr;command;iosxr::DirSlotN;dir /all disk1: ios-exr;command;iosxr::DirSlotN;dir /all disk1a: ios-exr;command;iosxr::DirSlotN;dir /all slot2: ios-exr;command;iosxr::DirSlotN;dir /all disk2: ios-exr;command;iosxr::DirSlotN;dir /all harddisk: ios-exr;command;iosxr::DirSlotN;dir /all harddiska: ios-exr;command;iosxr::DirSlotN;dir /all harddiskb: ios-exr;command;iosxr::ShowDiag;show diag ios-exr;command;iosxr::ShowInventory;show inventory raw ios-exr;command;iosxr::ShowDebug;show debug ios-exr;command;iosxr::ShowRPL;show rpl maximum ios-exr;command;iosxr::AdminShowRunning;admin show running ios-exr;command;iosxr::WriteTerm;show running-config # # Cisco Wireless Lan Controller (WLC) # The WLC login/user that RANCiD uses on the WLC must NOT use the MONITOR role, # lacks sufficient privileges to run all of the commands. # In addition to these commands, wlogin uses "config paging disable". cisco-wlc4;script;rancid -t cisco-wlc4 cisco-wlc4;login;wlogin cisco-wlc4;module;ciscowlc cisco-wlc4;inloop;ciscowlc::inloop cisco-wlc4;command;ciscowlc::ShowUdi;show udi cisco-wlc4;command;ciscowlc::ShowSysinfo;show sysinfo cisco-wlc4;command;ciscowlc::ShowConfig;show runnning-config # cisco-wlc5;script;rancid -t cisco-wlc5 cisco-wlc5;login;wlogin cisco-wlc5;module;ciscowlc cisco-wlc5;inloop;ciscowlc::inloop cisco-wlc5;command;ciscowlc::ShowUdi;show udi cisco-wlc5;command;ciscowlc::ShowSysinfo;show sysinfo cisco-wlc5;command;ciscowlc::ShowConfig;show run-config commands # cisco-wlc8;script;rancid -t cisco-wlc8 cisco-wlc8;login;wlogin cisco-wlc8;timeout;120 cisco-wlc8;module;ciscowlc cisco-wlc8;inloop;ciscowlc::inloop cisco-wlc8;command;ciscowlc::ShowUdi;show udi cisco-wlc8;command;ciscowlc::ShowSysinfo;show sysinfo cisco-wlc8;command;ciscowlc::ShowConfig;show run-config commands # css;script;cssrancid css;login;clogin # # Dell DES-3010F, DES-3052P, DES-3526, DES-3550 # Some of these devices are remarkably slow to read config, so the timeout is # rather long. dell;script;rancid -t dell dell;login;dllogin dell;timeout;300 dell;module;dell dell;inloop;dell::inloop dell;command;dell::GetSystem;show switch dell;command;dell::GetConf;show config current_config # # Dell NOS9 (aka Force 10 and Dell Force10) dnos9;script;rancid -t dnos9 dnos9;login;clogin dnos9;module;dnos9 dnos9;inloop;dnos9::inloop dnos9;command;dnos9::ShowVersion;show version dnos9;command;dnos9::ShowBoot;show bootvar dnos9;command;dnos9::DirSlotN;dir flash: dnos9;command;dnos9::DirSlotN;dir slot0: dnos9;command;dnos9::ShowChassis;show chassis dnos9;command;dnos9::ShowChassis;show system dnos9;command;dnos9::ShowInventory;show inventory dnos9;command;dnos9::ShowVLAN;show vlan dnos9;command;dnos9::WriteTerm;show running # # Dell NOS10 device (*NOT* Force 10) # Dell EMC S5200-ON # Dell S3048-ON dnos10;script;rancid -t dnos10 dnos10;login;hlogin dnos10;module;dnos10 dnos10;inloop;dnos10::inloop dnos10;command;rancid::RunCommand;terminal length 0 dnos10;command;dnos10::ShowSys;show system dnos10;command;dnos10::ShowVer;show version dnos10;command;dnos10::ShowInventory;show inventory dnos10;command;dnos10::ShowInventoryMedia;show inventory media dnos10;command;dnos10::ShowVlan;show vlan dnos10;command;dnos10::WriteTerm;show running-configuration # # UBNT EdgeMAX edgemax;script;rancid -t edgemax edgemax;login;clogin edgemax;module;edgemax edgemax;inloop;edgemax::inloop edgemax;command;edgemax::ShowVersion;show version edgemax;command;edgemax::ShowHardware;show hardware edgemax;command;edgemax::ShowBootvar;show bootvar edgemax;command;edgemax::ShowEnvironment;show environment edgemax;command;edgemax::ShowDebug;show debug edgemax;command;edgemax::WriteTerm;show running-config # # UBNT EdgeRouter edgerouter;script;rancid -t edgerouter edgerouter;login;ulogin -noenable edgerouter;module;edgerouter edgerouter;inloop;edgerouter::inloop edgerouter;command;rancid::RunCommand;terminal length 0 edgerouter;command;edgerouter::ShowVersion;show version edgerouter;command;edgerouter::ShowHardware;show hardware cpu edgerouter;command;edgerouter::ShowOffload;show ubnt offload edgerouter;command;edgerouter::WriteTerm;cli-shell-api showConfig --show-active-only # XXX show configuration | no-more # # UBNT EdgeRouter - according to Clemens, ie: with bird. edgerouterbird;script;rancid -t edgerouterbird edgerouterbird;login;ulogin -noenable edgerouterbird;module;edgerouter edgerouterbird;inloop;edgerouter::inloop edgerouterbird;command;rancid::RunCommand;terminal length 0 edgerouterbird;command;edgerouter::ShowVersion;show version edgerouterbird;command;edgerouter::ShowHardware;show hardware cpu edgerouterbird;command;edgerouter::ShowOffload;show ubnt offload #edgerouterbird;command;edgerouter::WriteTerm;cat /config/config.boot edgerouterbird;command;edgerouter::WriteTerm;cli-shell-api showConfig --show-active-only edgerouterbird;command;edgerouter::WriteTerm;cat /config/opt/bird/etc/bird.conf edgerouterbird;command;edgerouter::WriteTerm;cat /config/opt/bird/etc/bird6.conf # enterasys;script;rivrancid enterasys;login;rivlogin # erx;script;jerancid erx;login;clogin # extreme;script;rancid -t extreme extreme;login;xlogin extreme;module;exos extreme;inloop;exos::inloop extreme;command;exos::ShowVersion;show version extreme;command;exos::ShowMemory;show memory extreme;command;exos::ShowDiag;show diag extreme;command;exos::ShowSwitch;show switch extreme;command;exos::ShowSlot;show slot extreme;command;exos::ShowPolicy;show policy detail extreme;command;exos::WriteTerm;show configuration detail extreme;command;exos::WriteTerm;show configuration # ezt3;script;erancid ezt3;login;elogin # # f5 big-ip <=v10 f5;script;f5rancid f5;login;clogin # # f5 big-ip v11 bigip;script;rancid -t bigip bigip;login;clogin bigip;module;bigip bigip;inloop;bigip::inloop bigip;command;bigip::ShowVersion;tmsh show /sys version bigip;command;bigip::ShowHardware;tmsh show /sys hardware bigip;command;bigip::ShowLicense;tmsh show /sys license bigip;command;bigip::ShowZebOSconf;cat /config/ZebOS.conf bigip;command;bigip::ShowZebOSsockets;lsof -i :179 bigip;command;bigip::ShowRouteStatic;tmsh show /net route static bigip;command;bigip::WriteTerm;tmsh -q list # # f5 big-ip v13 bigip13;script;rancid -t bigip13 bigip13;login;clogin bigip13;module;bigip bigip13;inloop;bigip::inloop bigip13;command;rancid::RunCommand;modify cli preference pager disabled display-threshold 0 bigip13;command;bigip::ShowVersion;show sys version bigip13;command;bigip::ShowHardware;show sys hardware bigip13;command;bigip::ShowLicense;show sys license bigip13;command;bigip::RunCommandTMSH;cd / bigip13;command;bigip::ShowRouteStatic;show /net recursive route static bigip13;command;bigip::WriteTerm;list all-properties recursive # # Force 10 and Dell Force10 (aka Dell NOS9). force10;alias;dnos9 # # Fortinet Fortigate firewall # Normal or FULL (with defaults) configuration fortigate;script;rancid -t fortigate fortigate;login;fnlogin fortigate;timeout;90 fortigate;module;fortigate fortigate;inloop;fortigate::inloop fortigate;command;fortigate::GetSystem;get system status fortigate;command;fortigate::GetConf;show # fortigate-full;script;rancid -t fortigate-full fortigate-full;login;fnlogin fortigate-full;timeout;90 fortigate-full;module;fortigate fortigate-full;inloop;fortigate::inloop fortigate-full;command;fortigate::GetSystem;get system status fortigate-full;command;fortigate::GetConf;show full-configuration # # Foundry and HP procurve OEMs of Foundry. # Reportedly functional on: # J4899[BC] 2650, # J4899C 2650, # J4900[AB] 2626, # J4903A 2824, # J9019A 2510-24, # J9019B 2510B-24, # J9020A 2510-48, # J9021A 2810-24G, # J9022A 2810-48G, # J9145A 2910al-24G, # J9279A 2510G-24, # J9280A 2510G-48, # J9772A 2530-48G-PoEP, # J9775A 2530-48G, # J9778A 2530-48-PoEP, # J9779A 2530-24-PoEP, # J9780A 2530-8-PoEP # 29[12]0 # Brocade HP9304M # ICX-6450s # Ruckus ICX 7250 foundry;script;rancid -t foundry foundry;login;flogin foundry;module;foundry foundry;inloop;foundry::inloop foundry;command;foundry::ShowVersion;show version foundry;command;foundry::ShowChassis;show chassis foundry;command;foundry::ShowModule;show module foundry;command;foundry::ShowMedia;show media foundry;command;foundry::ShowMedia;show media validation foundry;command;foundry::ShowFlash;show flash foundry;command;foundry::WriteTerm;write term foundry;command;foundry::WriteTerm;show running-config # # Fujitsu T100 FSS2/1finity fss2;script;rancid -t fss2 fss2;login;jlogin fss2;module;fss2 fss2;inloop;fss2::inloop fss2;command;rancid::RunCommand;set complete-on-space false fss2;command;rancid::RunCommand;set screen width 132 fss2;command;rancid::RunCommand;set paginate false fss2;command;fss2::ShowSystem;show system fss2;command;fss2::ShowInventory;show inventory fss2;command;fss2::ShowFWinfo;show fw-info fss2;command;fss2::WriteTerm;show configuration # # Cisco FirePower / FX-OS fxos;script;rancid -t fxos fxos;login;fxlogin fxos;module;fxos fxos;inloop;fxos::inloop fxos;command;fxos::ShowModel;show model fxos;command;fxos::ShowInventory;show inventory fxos;command;fxos::DirSlotN;dir /all fxos;command;fxos::ShowMode;show mode fxos;command;fxos::ShowManagers;show managers fxos;command;fxos::ShowNetwork;show network fxos;command;fxos::ShowNetwork;show network-static-routes fxos;command;fxos::ShowNetwork;show network-dhcp-server fxos;command;fxos::WriteTermFTD;show running-config fxos;command;fxos::RunCommand;connect fxos; prompt changes fxos;command;fxos::RunCommand;term len 0 fxos;command;fxos::ShowFirmware;show system firmware detail fxos;command;fxos::ShowChassis;show chassis detail fxos;command;fxos::ShowChassis;show chassis inventory detail fxos;command;fxos::ShowChassis;show chassis environment expand detail fxos;command;fxos::WriteTerm;show configuration # hitachi;script;htrancid hitachi;login;htlogin # # HP Procurve switch such as the 2524, 4108 or J9086A (aka. 2610) procurve # switches, J9091A, and J8698A. # Aruba 2530-48G & 5400R series. hp;script;hrancid -t hp hp;login;hlogin # juniper;alias;junos junos;script;rancid -t junos junos;login;jlogin junos;timeout;120 junos;module;junos junos;inloop;junos::inloop junos;command;junos::ShowChassisClocks;show chassis clocks junos;command;junos::ShowChassisEnvironment;show chassis environment junos;command;junos::ShowChassisFirmware;show chassis firmware local junos;command;junos::ShowChassisFirmware;show chassis firmware junos;command;junos::ShowChassisFpcDetail;show chassis fpc detail junos;command;junos::ShowChassisHardware;show chassis hardware detail junos;command;junos::ShowChassisHardware;show chassis hardware models junos;command;junos::ShowChassisRoutingEngine;show chassis routing-engine junos;command;junos::ShowChassisSCB;show chassis scb junos;command;junos::ShowChassisSCB;show chassis sfm detail junos;command;junos::ShowChassisSCB;show chassis ssb junos;command;junos::ShowChassisSCB;show chassis feb detail junos;command;junos::ShowChassisSCB;show chassis feb junos;command;junos::ShowChassisSCB;show chassis cfeb junos;command;junos::ShowChassisAlarms;show chassis alarms junos;command;junos::ShowSystemLicense;show system license junos;command;junos::ShowSystemBootMessages;show system boot-messages junos;command;junos::ShowSystemCoreDumps;show system core-dumps junos;command;junos::ShowVersion;show version detail junos;command;junos::ShowVersion;show version invoke-on other-routing-engine junos;command;junos::ShowConfiguration;show configuration # junos-evo;script;rancid -t junos-evo junos-evo;login;jlogin junos-evo;timeout;120 junos-evo;module;junos junos-evo;inloop;junos::inloop # XXX broken in 19.1R2.1-EVO on some platforms #junos-evo;command;junos::ShowChassisClocks;show chassis clocks junos-evo;command;junos::ShowChassisEnvironment;show chassis environment junos-evo;command;junos::ShowChassisFirmware;show chassis firmware local junos-evo;command;junos::ShowChassisFirmware;show chassis firmware junos-evo;command;junos::ShowChassisFpcDetail;show chassis fpc detail junos-evo;command;junos::ShowChassisHardware;show chassis hardware detail junos-evo;command;junos::ShowChassisHardware;show chassis hardware models junos-evo;command;junos::ShowChassisRoutingEngine;show chassis routing-engine junos-evo;command;junos::ShowChassisSCB;show chassis scb junos-evo;command;junos::ShowChassisSCB;show chassis sfm detail junos-evo;command;junos::ShowChassisSCB;show chassis ssb junos-evo;command;junos::ShowChassisSCB;show chassis feb detail junos-evo;command;junos::ShowChassisSCB;show chassis feb junos-evo;command;junos::ShowChassisSCB;show chassis cfeb junos-evo;command;junos::ShowChassisAlarms;show chassis alarms junos-evo;command;junos::ShowSystemLicense;show system license # XXX this command does not work properly #junos-evo;command;junos::ShowSystemBootMessages;show system boot-messages junos-evo;command;junos::ShowSystemCoreDumps;show system core-dumps junos-evo;command;junos::ShowVersion;show version node all junos-evo;command;junos::ShowConfiguration;show configuration # # juniper-srx type is for SRX with ThreatSTOP; it displays the configuration # by section, omitting policy-options, which changes frequently. juniper-srx;script;rancid -t juniper-srx juniper-srx;login;jlogin juniper-srx;module;junos juniper-srx;inloop;junos::inloop juniper-srx;command;junos::ShowChassisClocks;show chassis clocks juniper-srx;command;junos::ShowChassisEnvironment;show chassis environment juniper-srx;command;junos::ShowChassisFirmware;show chassis firmware juniper-srx;command;junos::ShowChassisFpcDetail;show chassis fpc detail juniper-srx;command;junos::ShowChassisHardware;show chassis hardware detail juniper-srx;command;junos::ShowChassisHardware;show chassis hardware models juniper-srx;command;junos::ShowChassisRoutingEngine;show chassis routing-engine juniper-srx;command;junos::ShowChassisSCB;show chassis scb juniper-srx;command;junos::ShowChassisSCB;show chassis sfm detail juniper-srx;command;junos::ShowChassisSCB;show chassis ssb juniper-srx;command;junos::ShowChassisSCB;show chassis feb detail juniper-srx;command;junos::ShowChassisSCB;show chassis feb juniper-srx;command;junos::ShowChassisSCB;show chassis cfeb juniper-srx;command;junos::ShowChassisAlarms;show chassis alarms juniper-srx;command;junos::ShowSystemLicense;show system license juniper-srx;command;junos::ShowSystemLicense;show system license keys juniper-srx;command;junos::ShowSystemBootMessages;show system boot-messages juniper-srx;command;junos::ShowSystemCoreDumps;show system core-dumps juniper-srx;command;junos::ShowVersion;show version detail juniper-srx;command;junos::ShowConfiguration;show configuration groups juniper-srx;command;junos::ShowConfiguration;show configuration apply-groups juniper-srx;command;junos::ShowConfiguration;show configuration access juniper-srx;command;junos::ShowConfiguration;show configuration applications juniper-srx;command;junos::ShowConfiguration;show configuration bridge-domains juniper-srx;command;junos::ShowConfiguration;show configuration chassis juniper-srx;command;junos::ShowConfiguration;show configuration class-of-service juniper-srx;command;junos::ShowConfiguration;show configuration ethernet-switching-options juniper-srx;command;junos::ShowConfiguration;show configuration event-options juniper-srx;command;junos::ShowConfiguration;show configuration firewall juniper-srx;command;junos::ShowConfiguration;show configuration forwarding-options juniper-srx;command;junos::ShowConfiguration;show configuration interfaces juniper-srx;command;junos::ShowConfiguration;show configuration protocols juniper-srx;command;junos::ShowConfiguration;show configuration routing-instances juniper-srx;command;junos::ShowConfiguration;show configuration routing-options juniper-srx;command;junos::ShowConfiguration;show configuration security juniper-srx;command;junos::ShowConfiguration;show configuration services juniper-srx;command;junos::ShowConfiguration;show configuration smtp juniper-srx;command;junos::ShowConfiguration;show configuration snmp juniper-srx;command;junos::ShowConfiguration;show configuration switch-options juniper-srx;command;junos::ShowConfiguration;show configuration system juniper-srx;command;junos::ShowConfiguration;show configuration vlans # mikrotik;alias;routeros routeros;script;rancid -t routeros routeros;login;mtlogin routeros;module;routeros routeros;inloop;routeros::inloop routeros;command;routeros::SystemPackagePrintDetail;system package print detail without-paging routeros;command;routeros::SystemRouterboardPrint;system routerboard print routeros;command;routeros::SystemLicensePrint;system license print routeros;command;routeros::Export;export # mrtd;script;mrancid mrtd;login;clogin # # MRV optical switches (NC316, OptiSwitch 904, OptiSwitch 906G, OptiSwitch 912C, # OptiSwitch 940) mrv;script;rancid -t mrv mrv;login;mrvlogin mrv;module;mrv mrv;inloop;mrv::inloop mrv;command;mrv::ShowVersion;show version mrv;command;mrv::ShowChassis;show chassis mrv;command;mrv::ShowSlots;show slots mrv;command;mrv::ShowInventory;show inventory mrv;command;mrv::WriteTerm;show running-config # netopia;script;trancid netopia;login;tlogin # netscaler;script;nsrancid netscaler;login;nslogin # netscreen;script;nrancid netscreen;login;nlogin # paloalto;script;rancid -t paloalto paloalto;login;panlogin paloalto;module;panos paloalto;inloop;panos::inloop paloalto;command;panos::ShowInfo;show system info paloalto;command;panos::ShowInventory;show chassis inventory paloalto;command;panos::ShowConfig;show config running # redback;script;rrancid redback;login;clogin # riverbed;script;rancid -t riverbed riverbed;login;rblogin riverbed;module;rbt riverbed;inloop;rbt::inloop riverbed;command;rbt::ShowVersion;show version riverbed;command;rbt::ShowLicenses;show licenses riverbed;command;rbt::ShowHardware;show hardware all riverbed;command;rbt::ShowInfo;show info riverbed;command;rbt::ShowPeers;show peers riverbed;command;rbt::WriteTerm;show configuration # riverstone;script;rivrancid riverstone;login;rivlogin # # SMC and Dell PowerConnect N2048, 34xx (config is incomplete), 35xx (3524, # 3524P, 3548, 3548P), N4032F, N4064, 62xxx, M6348, 64xx (6428), 7048, # M8024(-k), and R1-2401. smc;script;rancid -t smc smc;login;hlogin smc;timeout;90 smc;module;smc smc;inloop;smc::inloop smc;command;rancid::RunCommand;terminal datadump smc;command;smc::ShowSys;show system smc;command;smc::ShowVer;show version smc;command;smc::Dir;dir smc;command;smc::ShowVlan;show vlan smc;command;smc::WriteTerm;show running-config # # Nokia (Alcatel-Lucent) SR OS Classic CLI (TiMOS) # 7210 SAS, 7250 IXR, 7450 ESS, 7705 SAR, 7750 SR, 7950 XRS, CMG and VSR routers sros;script;rancid -t sros sros;login;noklogin sros;module;sros sros;inloop;sros::inloop sros;command;sros::ShowSystemInfo;show system information sros;command;sros::BootLog;file type bootlog.txt sros;command;sros::ShowRedundancy;show redundancy synchronization sros;command;sros::ShowChassis;show chassis sros;command;sros::ShowChassisEnv;show chassis environment sros;command;sros::ShowChassisPS;show chassis power-supply sros;command;sros::ShowChassisPM;show chassis power-management sros;command;sros::ShowCardState;show card state sros;command;sros::ShowCardDetail;show card detail sros;command;sros::ShowDebug;show debug sros;command;sros::ShowBOF;show bof sros;command;sros::WriteTermIndex;admin display-config index sros;command;sros::WriteTerm;admin display-config # # Nokia (Alcatel-Lucent) SR OS MD-CLI (TiMOS) # 7750 SR and 7950 XRS routers sros-md;script;rancid -t sros-md sros-md;login;noklogin sros-md;module;sros sros-md;inloop;sros::inloop sros-md;command;sros::ShowSystemInfo;show system information sros-md;command;sros::BootLog;//file type bootlog.txt sros-md;command;sros::ShowRedundancy;show redundancy synchronization sros-md;command;sros::ShowChassis;show chassis sros-md;command;sros::ShowChassisEnv;show chassis environment sros-md;command;sros::ShowChassisPS;show chassis power-supply sros-md;command;sros::ShowChassisPM;show chassis power-management sros-md;command;sros::ShowCardState;show card state sros-md;command;sros::ShowCardDetail;show card detail sros-md;command;sros::ShowDebug;//show debug sros-md;command;sros::ShowBOF;//show bof sros-md;command;sros::WriteTermMD;admin show configuration # # Avocent ACS (Advanced Console Server) (formerly Cyclades) avocent;script;rancid -t avocent avocent;login;avologin avocent;module;avocent avocent;inloop;avocent::inloop avocent;command;avocent::CatFileComment;config show version avocent;command;avocent::Meminfo;cat /proc/meminfo avocent;command;avocent::CatFileComment;cat /proc/version avocent;command;avocent::CatFile;cat /etc/hostname avocent;command;avocent::CatFile;cat /etc/domainname.conf avocent;command;avocent::CatFile;cat /etc/resolv.conf avocent;command;avocent::CatFile;cat /etc/syslog-ng/syslog-ng.conf avocent;command;avocent::CatFile;cat /etc/portslave/pslave.conf avocent;command;avocent::CatFile;cat /etc/passwd avocent;command;avocent::CatFile;cat /etc/snmp/snmpd.conf avocent;command;avocent::CatFile;cat /etc/network/ifcfg_eth0 avocent;command;avocent::CatFile;cat /etc/network/st_routes avocent;command;avocent::CatFile;cat /etc/security.opts avocent;command;avocent::CatFile;cat /etc/pmdgrp.conf # # Hauwei VRP (S5720) vrp;script;rancid -t vrp vrp;login;xilogin vrp;module;vrp vrp;inloop;vrp::inloop vrp;command;vrp::DispVersion;display version vrp;command;vrp::DispStartup;display startup vrp;command;vrp::DispDevice;display device vrp;command;vrp::DispDeviceMfg;display device manufacture-info vrp;command;vrp::DispTransciever;display transceiver verbose vrp;command;vrp::DispDebug;display debugging vrp;command;vrp::DirSlotN;dir /all /all-filesystems vrp;command;vrp::WriteTerm;display current-configuration # xirrus;script;xirancid xirrus;login;xilogin # zebra;alias;frr frr;script;rancid -t frr frr;login;clogin frr;module;frr frr;inloop;frr::inloop frr;command;frr::ShowVersion;show version frr;command;frr::WriteTerm;write term rancid-3.13/man/plogin.1000644 015615 000000 00000000022 13465702362 015105 0ustar00heaswheel000000 000000 .so man1/clogin.1 rancid-3.13/man/fnlogin.1000644 015615 000000 00000000022 13465702362 015251 0ustar00heaswheel000000 000000 .so man1/clogin.1 rancid-3.13/man/trancid.1000644 015615 000000 00000000022 13465702362 015241 0ustar00heaswheel000000 000000 .so man1/rancid.1 rancid-3.13/man/jlogin.1000644 015615 000000 00000000022 13465702362 015077 0ustar00heaswheel000000 000000 .so man1/clogin.1 rancid-3.13/man/rancid-run.1000644 015615 000000 00000006525 13465702362 015675 0ustar00heaswheel000000 000000 .\" .hys 50 .TH "rancid-run" "1" "22 December 2016" .SH NAME rancid-run \- run rancid for each of the groups .SH SYNOPSIS .B rancid-run [\fB\-V\fR] [\c .BI \-c\ \c commit_msg]\ \c [\c .BI \-f\ \c rancid.conf]\ \c [\c .BI \-m\ \c mail_rcpt]\ \c [\c .BI \-r\ \c device_name]\ \c [group [group ...]] .SH DESCRIPTION .B rancid-run is a .IR sh (1) script to run .IR rancid (1) for a set of rancid group(s). .PP .B rancid-run reads .BR rancid.conf (5) to configure itself, then uses .IR control_rancid (1) to run .IR rancid (1) for each rancid group. The set of rancid groups can either be provided as command-line arguments or via the .I LIST_OF_GROUPS variable in .BR rancid.conf (5), if the group argument is omitted. .PP A lock file is maintained per-group to prevent simultaneous runs for a given group by .IR rancid-run (1). The lock file will be named .IR ..run.lock and will be located in .IR $TMPDIR (see below). .PP A log file is produced under .IR $LOGDIR/logs for each rancid group processed. The file name will be .YYYYMMDD.HHMMSS (year month day . hour minute second). .PP .B rancid-run is normally used to run rancid from .BR cron (8). For example: .PP .in +1i .nf 0 * * * * /usr/local/rancid/bin/rancid-run .fi .in -1i .\" .PP .\" The command-line options are as follows: .TP .B \-V Prints package name and version strings. .TP .B \-c commit_msg Specify an alternative SCM commit message. .TP .B \-f rancid.conf Specify an alternate configuration file. .TP .B \-m mail_rcpt Specify the recipient of diff mail, which is normally rancid-. The argument may be a single address, multiple comma separated addresses, or .B \-m may be specified multiple times. .\" .TP .B \-r device_name Run rancid for a single device, .IR device_name . .IR device_name should be name, as it appears in a group's router.db. The device must be marked "up". If a group is not specified on the command-line, rancid will be run against any group in which the device_name appears. .sp The .B \-r option alters the subject line of the diff mail. It will begin with / rather than just the group name alone. .\" .SH ENVIRONMENT .B rancid-run utilizes the following environment variables from .BR rancid.conf (5). .\" .TP .B BASEDIR Location of group directories, etc. This is set to the "localstatedir" by the configure script at installation time. .\" .TP .B LIST_OF_GROUPS List of rancid groups to collect. .\" .TP .B PATH Search path for utilities. .\" .TP .B TMPDIR Directory to hold temporary and lock files. .SH ERRORS If rancid fails to run or collect a device's configuration, the particular group's log file (mentioned above) should be consulted. Any errors produced by the revision control system (CVS, Subversion, or git) or any of the rancid scripts should be included there, whether they be a botched cvs tree, login authentication failure, rancid configuration error, etc. If the log file produces no clues, the next debugging step should be run the commands manually. For example, can the user who runs rancid login to the device with 'clogin hostname', and so on. .BR .SH FILES .TP .B $BASEDIR/etc/rancid.conf .B rancid-run configuration file. .El .SH "SEE ALSO" .BR control_rancid (1), .BR rancid.conf (5), .BR router.db (5) .SH "CAVEATS" DO NOT leave temporary files in the /configs directory, they WILL be removed by .BR control_rancid (1). rancid-3.13/man/rivlogin.1000644 015615 000000 00000000022 13465702362 015446 0ustar00heaswheel000000 000000 .so man1/clogin.1 rancid-3.13/man/cssrancid.1000644 015615 000000 00000000022 13465702362 015566 0ustar00heaswheel000000 000000 .so man1/rancid.1 rancid-3.13/man/hrancid.1000644 015615 000000 00000000022 13465702362 015225 0ustar00heaswheel000000 000000 .so man1/rancid.1 rancid-3.13/man/cat5rancid.1000644 015615 000000 00000000022 13465702362 015632 0ustar00heaswheel000000 000000 .so man1/rancid.1 rancid-3.13/man/lg.conf.5.in000644 015615 000000 00000011426 13657102757 015573 0ustar00heaswheel000000 000000 .\" .hys 50 .TH "lg.conf" "5" "7 Jan 2004" .SH NAME lg.conf \- looking glass configuration file .SH DESCRIPTION .B lg.conf contains configuration for the looking glass scripts. .PP The syntax is that of .IR perl (1). It is used to set variables that affect run-time behavior and/or to locate resources. .\" .SH VARIABLES The following variables are used (alphabetically): .Bl -tag -width flag .\" .TP .B LG_AS_REG *** not implemented. .\" .TP .B LG_BGP_RT Allows show ip bgp neighbor commands that can produce heavy output, such as sh ip bgp neighbor advertised-routes for a transit customer when the neighbor address is followed by 'advertised-routes' for the sh ip bgp neighbor query. .\" .TP .B LG_CACHE_DIR Sets the location of the cache directory. The looking glass uses this to hold lock files, log files, and output from cached commands. .sp Default: ./tmp .sp Note that the default is relative to the directory where .IR lg.cgi runs in the server's document root (e.g.: /usr/local/www/data/lg/tmp). .\" .TP .B LG_CACHE_TIME Sets the number of seconds that the looking glass should cache output from commands that tend to produce a lot of output, such as 'show ip bgp dampened-paths'. .sp Default: 600 .\" .TP .B LG_CLOGINRC Defines the location of the .BR cloginrc (5) that the looking glass should use. The path may be relative to the directory where the CGI scripts run in the server's document root. .sp Default: $HOME/.cloginrc .sp Note that the .cloginrc must be readable by the user or group that will be running the CGI and that .BR clogin (1) will not allow a world readable .IR .cloginrc . The user is normally that of the http server (httpd). .\" .TP .B LG_IMAGE Defines a html image tag () which, if defined, will be included at the top of the looking glass pages. It may contain any html as it is simply handed off to print(). .sp Example: $LG_IMAGE="\\n FOO"; .\" .TP .B LG_INFO Defines information in html format which, if defined, will be included at the bottom of the looking glass form page. It may contain any html as it is simply handed off to print(). .sp Example: $LG_INFO="For Support contact webmaster"; .\" .TP .B LG_LOG Defines the fully qualified path name (i.e.: begins with '/') for the log file or the .BR syslog (3) facility to use for logging. For syslog, the argument is the lowercase name of a syslog facility (see syslog.h) without the 'LOG_' prefix. .sp Example: local0 .sp Default: $LG_CACHE_DIR/lg.log .\" .TP .B LG_ROUTERDB Sets the location for the .IR router.db file in rancid's .BR router.db (5) format. It lists the devices that should be available to the looking glass users. Only those devices of supported types and with state 'up' are made available. If not defined and the default file does not exist, the looking glass will compile a list from the router.db files of all the groups present in rancid, that is, the list will be a concatenation of the available .IR router.db (5) files. .sp Note that if the concatenation method is used, it may be necessary to alter the mode of the router.db files in the rancid group directories, since rancid's default umask is 027 (see .BR rancid.conf (5)). .\" .TP .B LG_STRIP Causes the LG to strip login information from the looking glass results. Since Expect often munges disabling echo when passwords are entered, this is a SECURITY CONCERN! However, this output can be very useful for debugging clogin problems. .\" .TP .B LG_STYLE Defines the URL of a style sheet to be used for HTML formatting. .\" .TP .B PATH Is a colon separated list of directory pathnames in the file system where rancid's login scripts, .IR clogin (1) etc.) and programs needed within these, such as .IR telnet (1), are located. Its value is set by configure. Should it be necessary to modify PATH, note that it must include $BASEDIR/bin (see above). .\" .TP Queries ................................... .\" .El .\" .SH ENVIRONMENT .Bl -tag -width LG_CONF -compact .TP .B LG_CONF Location of .B lg.conf file. See the .IR FILES section for more information. .El .\" .SH ERRORS .B lg.conf is interpreted directly by .IR perl (1), so its syntax follows that of perl. Syntax errors may produce quite unexpected results. .SH FILES .Bl -tag -width @sysconfdir@/rancid.conf -compact .TP .B @sysconfdir@/lg.conf Configuration file described here. .sp .B lg.conf is located by the value of the environment variable LG_CONF, in the CWD (current working directory), or the sysconfdir defined when rancid was installed, in that order. .El .SH "SEE ALSO" .BR cloginrc (5), .BR lg_intro (7), .BR router.db (5) .\" .SH HISTORY In RANCID releases prior to 2.3, .B lg.conf was located in the util/lg sub-directory of the install path. This was changed to be more consistent with common file location practices. rancid-3.13/man/rivrancid.1000644 015615 000000 00000000022 13465702362 015576 0ustar00heaswheel000000 000000 .so man1/rancid.1 rancid-3.13/man/hlogin.1000644 015615 000000 00000000022 13465702362 015075 0ustar00heaswheel000000 000000 .so man1/clogin.1 rancid-3.13/man/control_rancid.1000644 015615 000000 00000003775 13465702362 016637 0ustar00heaswheel000000 000000 .\" .hys 50 .TH "control_rancid" "1" "22 December 2016" .SH NAME control_rancid \- run rancid for devices of a group .SH SYNOPSIS .B control_rancid [\fB\-V\fR] [\c .BI \-c\ \c commit_msg]\ \c [\c .BI \-f\ \c config_file]\ \c [\c .BI \-m\ \c mail_rcpt]\ \c [\c .BI \-r\ \c device_name]\ \c group .SH DESCRIPTION .B control_rancid is a .IR sh (1) script to parse a group's .BR router.db (5), run rancid for each of the devices, possibly re-run rancid for devices that failed collection, e-mail diffs, and e-mail error reports. .\" .PP .B control_rancid also creates and/or re-creates the .cvsignore/.gitignore files for each group. For the configs sub-directory, it includes ".old", where a user may keep files they would like to be ignored. .\" .PP The command-line options are as follows: .TP .B \-V Prints package name and version strings. .TP .B \-c commit_msg Specify an alternative SCM commit message. .TP .B \-f group_config_file Specify an alternative rancid.conf. The global rancid.conf file is read by .B rancid-run, which calls .B control_rancid for each group, and .B control_rancid reads the group-specific rancid.conf, thereby overriding the global file. .sp The group-specific rancid.conf may not exist. .sp Default: //rancid.conf .TP .B \-m mail_rcpt Specify the recipient of diff mail, which is normally rancid-. The argument may be a single address, multiple comma separated addresses, or .B \-m may be specified multiple times. .\" .TP .B \-r device_name Specify the name, as it appears in the router.db, of a particular device to collect and generate diffs for. The device must be marked "up". .sp The .B \-r option alters the subject line of the diff mail. It will begin with / rather than just the group name alone. .\" .PP .B control_rancid is normally (and best) run via .BR rancid-run (1) which provides a locking mechanism on a group basis and saves output in a log file for each group. .\" .SH "SEE ALSO" .BR rancid-run (1), .BR rancid.conf (5), .BR router.db (5) rancid-3.13/man/csblogin.1000644 015615 000000 00000000022 13465702362 015415 0ustar00heaswheel000000 000000 .so man1/clogin.1 rancid-3.13/man/elogin.1000644 015615 000000 00000000022 13465702362 015072 0ustar00heaswheel000000 000000 .so man1/clogin.1 rancid-3.13/man/agmrancid.1000644 015615 000000 00000000022 13465702362 015542 0ustar00heaswheel000000 000000 .so man1/rancid.1 rancid-3.13/man/rancid.types.base.5000644 015615 000000 00000000035 13465702362 017141 0ustar00heaswheel000000 000000 .so man5/rancid.types.conf.5 rancid-3.13/man/cloginrc.5.in000644 015615 000000 00000024513 13534015162 016031 0ustar00heaswheel000000 000000 .\" .hys 50 .TH "cloginrc" "5" "12 April 2017" .SH NAME \.cloginrc \- clogin configuration file .SH DESCRIPTION .B .cloginrc contains configuration information for .BR alogin (1), .BR blogin (1), .BR clogin (1), .BR csblogin (1), .BR elogin (1), .BR flogin (1), .BR fnlogin (1), .BR hlogin (1), .BR htlogin (1), .BR jlogin (1), .BR nlogin (1), .BR nslogin (1), .BR rivlogin (1), and .BR wlogin (1), such as usernames, passwords, ssh encryption type, etc., and is read at run-time. .PP Each line contains either white-space (blank line), a comment which begins with the comment character '#' and may be preceded by white-space, or one of the directives listed below. .PP Each line containing a directive is of the form: .PP .in +1i .nf add {} [{} ...] .sp or .sp include {} .fi .in -1i .PP Note: the braces ({}) surrounding the values is significant when the values include TCL meta-characters. Best common practice is to always enclose the values in braces. If a value includes a (left or right) brace, space character, ampersand or blackslash, those characters must be backslash-escaped, as in: .PP .in +1i .nf add user {foo\\}bar} add user {foo\\ bar} .fi .in -1i .PP Other special characters may be escaped without error, if desired. .PP As .B .cloginrc is searched for a directive matching a hostname, it is always the first matching instance of a directive, one whose hostname glob expression matches the hostname, which is used. For example; looking up the "password" directive for hostname foo in a .B .cloginrc file containing .sp .in +1i .nf add password * {bar} {table} add password foo {bar} {table} .fi .in -1i .sp would return the first line, even though the second is an exact match. .PP .B .cloginrc is expected to exist in the user's home directory and must not be readable, writable, or executable by "others". .B .cloginrc should be mode 0600, or 0640 if it is to be shared with other users who are members of the same unix group. See .BR chgrp (1) and .BR chmod (1) for more information on ownership and file modes. .SH DIRECTIVES The accepted directives are (alphabetically): .PP .\" .TP .B add autoenable {[01]} When using locally defined usernames or AAA, it is possible to have a login which is automatically enabled. This is, that user has enable privileges without the need to execute the enable command. The router's prompt is different for enabled mode, ending with a # rather than a >. .sp Example: add autoenable * {1} .sp Default: 0 .sp zero, meaning that the user is not automatically enabled and .IR clogin should execute the enable command to gain enable privileges, unless negated by the noenable directive or \-noenable command\-line option. .sp Also see the .B noenable directive. .\" .TP .B add cyphertype {} cyphertype defines which encryption algorithm is used with ssh version 1. A device may not support the type ssh uses by default. See .BR ssh (1)'s\c \-c option for details. .sp Default: empty .\" .TP .B add enableprompt {""} When using AAA with a Cisco router or switch, it is possible to redefine the prompt the device presents to the user for the enable password. enableprompt may be used to adjust the prompt that .IR clogin should look for when trying to login. Note that enableprompt can be a Tcl style regular expression. .sp Example: add enableprompt rc*.example.net {"\\[Ee]nter\\ the\\ enable\\ password:"} .sp Default: "\\[Pp]assword:" .\" .TP .B add enablecmd {} .\" This defines the command on the device used to enter enabled or super-user mode. For example, in Cisco IOS the command is "enable". .TP .B add enauser {} This is only needed if a device prompts for a username when gaining enable privileges and where this username is different from that defined by or the default of the user directive. .\" .TP .B add identity {} May be used to specify an alternate identity file for use with ssh(1). See ssh's \-i option for details. .sp Default: your default identity file. see ssh(1). .\" .TP .B add method {ssh} [{...}] Defines, in order, the connection methods to use for a device from the set {ssh, telnet, rsh}. Method ssh and telnet may have a suffix, indicating an alternate TCP port, of the form ":port". .sp Note: Different versions of telnet treat the specification of a port differently. In particular, BSD derived telnets do not do option negotiation when a port is given. Some devices, Extreme switches for example, have undesirable telnet default options such as linemode. In the BSD case, to enable option negotiation when specifying a port the method should be "{telnet:-23}" or, better, add "mode character" to .telnetrc. See .BR telnet (1) for more information on telnet command-line syntax, telnet options, and .telnetrc. .sp Example: add method * {ssh} {telnet:3000} {rsh} .sp Which would cause .IR clogin to first attempt an ssh connection to the device and if that were to fail with connection refused, a telnet connection to port 3000 would be tried, and then a rsh connection. .sp Note that not all platforms support all of these connection methods. .sp Default: {telnet} {ssh} .\" .TP .B add noenable {1} .IR clogin will not try to gain enable privileges when noenable is matched for a device. This is equivalent to .IR "clogin" 's -noenable command-line option. .sp Note that this directive is meaningless for .BR jlogin (1), .BR nlogin (1) and .BR clogin (1) [for Extreme] which do not have the concept of "enabled" and/or no way to elevate privleges once logged in; a user either has the necessary privleges or doesn't. .\" .TP .B add passphrase {""} Specify the SSH passphrase. Note that this may be particular to an .B identity directive. The passphrase will default to the .B password for the given router. .sp Example: add passphrase rc*.example.net {the\\ bird\\ goes\\ tweet} .\" .TP .B add passprompt {""} When using AAA with a Cisco router or switch, it is possible to redefine the prompt the device presents to the user for the password. passprompt may be used to adjust the prompt that .IR clogin should look for when trying to login. Note that passprompt can be a Tcl style regular expression. .sp Example: add passprompt rc*.example.net {"\\[Ee]nter\\ the\\ password:"} .sp Default: "(\\[Pp]assword|passwd):" .\" .TP .B add password {} [{}] Specifies a vty password, that which is prompted for upon the connection to the router. The last argument is the enable password and need not be specified if the device also has a matching noenable or autoenable directive or the corresponding command-line options are used. .\" .TP .B add prompt {} Match login prompt, or initial login prompt in the case of some of the login scripts. This is provided only as a work-around for login banners that contain forbidden characters that conflict with CLI prompt markers. .sp Note that not all login scripts support this. .\" .TP .B add sshcmd {} is the name of the ssh executable. OpenSSH uses a command-line option to specify the protocol version, but other implementations use a separate binary such as "ssh1". .B sshcmd allows this to be adjusted as necessary for the local environment. .sp .B sshcmd also allows the user to add any other command-line options, such as altering the offered key exchange algorithms. For example: add sshcmd * {ssh\\ -o\\ KexAlgorithms=+diffie-hellman-group1-sha1} .sp Default: ssh .\" .TP .B add timeout {} Time in seconds that the login script will wait for input from the device before timeout. .sp Default: device dependent .\" .\" .TP .\" .B add rc {} .\" rc is used to specifies a command that will be run by .\" .IR clogin .\" immediately after logging into the device. Multiple commands may be .\" specified by separating them with semi-colons (;). The command must .\" not be one which expects additional input from the user, such as 'copy .\" rcp startup-config' on a Cisco. .\" .sp .\" Example: add rc *.domain.net {terminal monitor;show version} .\" .\" .TP .B add telnetcmd {} is the name of the telnet executable. .B telnetcmd allows this to be adjusted as necessary for the local environment. .sp .B telnetcmd also allows the user to add any other command-line options, such as force IPv4. For example: add telnetcmd * {telnet\\ -K4} .sp Default: @TELNET_CMD@ .TP .B add user {} Specifies a username .IR clogin should use if or when prompted for one. .sp Default: $USER (or $LOGNAME), i.e.: your Unix username. .\" .TP .B add userpassword {} Specifies a password to be associated with a user, if different from that defined with the password directive. .\" .TP .B add userprompt {""} When using AAA with a Cisco router or switch, it is possible to redefine the prompt the device presents to the user for the username. userprompt may be used to adjust the prompt that .IR clogin should look for when trying to login. Note that userprompt can be a Tcl style regular expression. .sp Example: add userprompt rc*.example.net {"\\[Ee]nter\\ your\\ username:"} .sp Default: "(Username|login|user name):" .\" .TP .B include {} is the pathname of an additional .B .cloginrc file to include at that point. It is evaluated immediately. That is important with regard to the order of matching hostnames for a given directive, as mentioned above. This is useful if you have your own .B .cloginrc plus an additional .B .cloginrc file that is shared among a group of folks. .sp If is not a full pathname, $HOME/ will be prepended. .sp Example: include {.cloginrc.group} .El .SH FILES .br .nf .\" set tabstop to longest possible filename, plus a wee bit .ta \w'xHOME/xcloginrc 'u \fI$HOME/.cloginrc\fR Configuration file described here. .\" \fIshare/rancid/cloginrc.sample\fR A sample \fB.cloginrc\fR. .\" .SH ERRORS .B .cloginrc is interpreted directly by Tcl, so its syntax follows that of Tcl. Errors may produce quite unexpected results. .SH "SEE ALSO" .BR clogin (1), .BR glob (3), .BR tclsh (1) rancid-3.13/man/tlogin.1000644 015615 000000 00000000022 13465702362 015111 0ustar00heaswheel000000 000000 .so man1/clogin.1 rancid-3.13/man/clogin.1000644 015615 000000 00000017072 13665233101 015075 0ustar00heaswheel000000 000000 .\" .hys 50 .TH "clogin" "1" "5 May 2020" .SH NAME clogin \- Cisco login script .SH SYNOPSIS .B clogin [\fB\-autoenable\fP] [\fB\-noenable\fP] [\fB\-dhiSV\fR] [\fB\-m|M\fR] [\c .BI \-c\ command] [\c .BI \-E\ var=x] [\c .BI \-e\ enable-password] [\c .BI \-f\ cloginrc-file] [\c .BI \-p\ user-password] [\c .BI \-s\ script-file] [\c .BI \-t\ timeout] [\c .BI \-u\ username] [\c .BI \-v\ vty-password] [\c .BI \-w\ enable-username] [\c .BI \-x\ command-file] [\c .BI \-y\ ssh_cypher_type] router [router...] .SH DESCRIPTION .B clogin is an .BR expect (1) script to automate the process of logging into a Cisco router, Catalyst switch, Arista switch, Extreme switch, Juniper ERX/E-series, or Redback router. There are complementary scripts for A10, Alteon, Avocent (Cyclades), Bay Networks (nortel), Brocade, Cisco Small Business devices, ADC-kentrox EZ-T3 mux, Fortinet firewalls, Foundry, Cisco Firepower, HP Procurve switches and Cisco AGMs, Hitachi routers, Juniper Networks, MRV optical switch, Mikrotik routers, Netscreen firewalls, Nokia (Alcatel-Lucent), Netscaler, Riverbed Steelhead, Riverstone, Netopia, Cisco WLCs, Extreme devices and Xirrus arrays or Arrcus routers, named .B a10login, .B alogin, .B avologin, .B blogin, .B brlogin, .B csblogin, .B elogin, .B flogin, .B fnlogin, .B fxlogin, .B hlogin, .B htlogin, .B jlogin, .B mrvlogin, .B mtlogin, .B nlogin, .B noklogin, .B nslogin, .B rblogin, .B rivlogin, .B tlogin, .B wlogin, .B xlogin, and .B xilogin, respectively. Lastly, .B plogin is a poly-login script using the .BR router.db (5) files of rancid groups and the .BR rancid.types.base (5) and .BR rancid.types.conf (5) files to determine which login script to execute for the device type of the given device. .PP .B clogin reads the .IR .cloginrc file for its configuration, then connects and logs into each of the routers specified on the command line in the order listed. Command-line options exist to override some of the directives found in the .IR .cloginrc configuration file. .PP The command-line options are as follows: .TP .B \-S Save the configuration on exit, if the device prompts at logout time. This only has affect when used with -c. .TP .B \-V Prints package name and version strings. .\" .TP .B \-c Command to be run on each router list on the command-line. Multiple commands maybe listed by separating them with semi-colons (;). The argument should be quoted to avoid shell expansion. .\" .TP .B \-d Enable expect debugging. .\" .TP .B \-E Specifies a variable to pass through to scripts (\-s). For example, the command-line option \-Efoo=bar will produce a global variable by the name Efoo with the initial value "bar". .\" .TP .B \-e Specify a password to be supplied when gaining enable privileges on the router(s). Also see the password directive of the .IR .cloginrc file. .\" .TP .B \-f Specifies an alternate configuration file. The default is .IR "$HOME/.cloginrc" . .\" .TP .B \-h Display usage line and exit. .\" .TP .B \-i Enter interactive mode after processing -[cx] options. .\" .TP .B \-[mM] Display .IR .cloginrc information for matching lines; either the first match (-m) or all matches (-M), then exit. The display format is: .sp look-up variable:filename:line number: glob .\" .TP .B \-p Specifies a password associated with the user specified by the .B \-u option, user directive of the .IR .cloginrc file, or the Unix username of the user. .\" .TP .B \-s The filename of an .BR expect (1) script which will be sourced after the login is successful and is expected to return control to .B clogin, with the connection to the router intact, when it is done. Note that .B clogin disables .IR log_user of .BR expect (1) when .B \-s is used. Example script(s) can be found in share/rancid/*.exp. .\" .TP .B \-t Alters the timeout interval; the period that .B clogin waits for an individual command to return a prompt or the login process to produce a prompt or failure. The argument is in seconds. .\" .TP .B \-u Specifies the username used when prompted. The command-line option overrides any user directive found in .IR .cloginrc . The default is the current Unix username. .\" .TP .B \-v Specifies a vty password, that which is prompted for upon connection to the router. This overrides the vty password of the .IR .cloginrc file's password directive. .\" .TP .B \-w Specifies the username used if prompted when gaining enable privileges. The command-line option overrides any user or enauser directives found in .IR .cloginrc . The default is the current Unix username. .\" .TP .B \-x Similar to the .B \-c option; .B \-x specifies a file with commands to run on each of the routers. The commands must not expect additional input, such as 'copy rcp startup-config' does. For example: .PP .in +1i .nf show version show logging .fi .in -1i .\" .TP .B \-y Specifies the encryption algorithm for use with the .BR ssh (1) \-c option. The default encryption type is often not supported. See the .BR ssh (1) man page for details. The default is 3des. .El .\" .SH RETURNS If the login script fails for any of the devices on the command-line, the exit value of the script will be non-zero and the value will be the number of failures. .\" .SH ENVIRONMENT .B clogin recognizes the following environment variables. .PP .TP .B CISCO_USER Overrides the user directive found in the .IR .cloginrc file, but may be overridden by the .B \-u option. .\" .TP .B CLOGIN .B clogin will not change the banner on your xterm window if this includes the character 'x'. .\" .TP .B CLOGINRC Specifies an alternative location for the .IR .cloginrc file, like the \fB\-f\fP option. .\" .TP .B HOME Normally set by .BR login (1) to the user's home directory, HOME is used by .B clogin to locate the .IR .cloginrc configuration file. .El .SH FILES .ta \w'xHOME/xcloginrc 'u \fI$HOME/.cloginrc\fR Configuration file. .SH "SEE ALSO" .BR cloginrc (5), .BR expect (1) .\" .SH CAVEATS .B clogin expects CatOS devices to have a prompt which includes a '>', such as "router> (enable)". It uses this to determine, for example, whether the command to disable the pager is "set length 0" or "term length 0". .PP The HP Procurve switches that are Foundry OEMs use flogin, not hlogin. .PP The -S option is a recent addition, it may not be supported in all of the login scripts or for every target device. .\" .SH BUGS Do not use greater than (>) or pound sign (#) in device banners or hostnames or prompts. These are the normal terminating characters of device prompts and the login scripts need to locate the initial prompt. Afterward, the full prompt is collected and makes a more precise match so that the scripts know when the device is ready for the next command. .PP All these login scripts for separate devices should be rolled into one. This goal is exceedingly difficult. .PP The HP Procurve switch, Motorola BSR, and Cisco AGM CLIs rely heavily upon terminal escape codes for cursor/screen manipulation and assumes a vt100 terminal type. They do not provide a way to set a different terminal type or adjust this behavior. The resulting escape codes make automating interaction with these devices very difficult or impossible. Thus bin/hpuifilter, which must be found in the user's PATH, is used by hlogin to filter these escape sequences. While this works for rancid's collection, there are side effects for interactive logins via hlogin; most of which are formatting annoyances that may be remedied by typing CTRL-R to reprint the current line. .PP WARNING: repeated ssh login failures to HP Procurves cause the switch's management interface to lock-up (this includes snmp, ping) and sometimes it will crash. This is with the latest firmware; 5.33 at the time of this writing. rancid-3.13/man/nlogin.1000644 015615 000000 00000000022 13465702362 015103 0ustar00heaswheel000000 000000 .so man1/clogin.1 rancid-3.13/man/htrancid.1000644 015615 000000 00000000022 13465702362 015411 0ustar00heaswheel000000 000000 .so man1/rancid.1 rancid-3.13/man/f5rancid.1000644 015615 000000 00000000022 13465702362 015310 0ustar00heaswheel000000 000000 .so man1/rancid.1 rancid-3.13/man/par.1000644 015615 000000 00000006263 13534015231 014401 0ustar00heaswheel000000 000000 .\" .hys 50 .TH "par" "1" "29 July 2019" .SH NAME par \- parallel command processing .SH SYNOPSIS .B par [\fB\-FHdefiqx\fP] [\c .BI \-c\ command] [\c .BI \-l\ logfile] [\c .BI \-n\c #] [\c .BI \-p\c #] [file [file...]] .SH DESCRIPTION .B par takes a list of files to run a command on. The first line of each file begins with a colon (:) or a pound-sign (#). If a colon, the remainder of the line is a command to run for each of the subsequent lines. If a pound-sign, then each subsequent line is a (self-contained) command, unless the .B \-c option was specified, in which case the lines become the arguments replacing the braces ({}s) in the .B \-c argument. .PP The input file may also be specified on stdin, in the format as previously described. .PP In each of the cases where the lines of the file, following the first, are not commands (ie: colon or -c), instances of open-close braces ({}) in the command will be replaced by these values. .PP For example, an inputfile whose contents is: .sp : echo {} .br a .br b .br c .sp run with .B par like so: .sp %par -q inputfile .sp will produce the following output (order will vary): .sp b .br a .br c .PP The command-line options are as follows: .PP .TP .B \-F Omit the footer that normally follows the output of each job. .\" .TP .B \-H Omit the header that normally precedes the output of each job. .\" .TP .B \-c Command to be run on each of the arguments following the command-line options, where the first line of the input file(s) begins with a pound-sign (#). .\" .TP .B \-d Print debugging information on standard error (stderr). Repeat the option up to three times for more verbosity. .\" .TP .B \-e Split args by spaces, rather than using sh -c. Note: .B \-e is incompatible with the .B \-i option. .\" .TP .B \-f No input file or STDIN, just run a quantity of the command specified with -c. .\" .TP .B \-i Run commands interactively through (multiple) .BR xterm (1) processes. .\" .TP .B \-l Prefix of logfile name, as in prefix.N where N is the .B par process number ([0..]). .sp Default: par.log.