summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorTar Committer <tar@ocjtech.us>2002-01-04 21:31:49 +0000
committerTar Committer <tar@ocjtech.us>2002-01-04 21:31:49 +0000
commit9f2402b0d86333f5f7e9d50437036cd3124bde47 (patch)
tree163861dc0a0052447f838d3674a35870a80026f5 /bin
parentb0d71377c1854271b4511488422427f73d9473d1 (diff)
downloadrancid-9f2402b0d86333f5f7e9d50437036cd3124bde47.tar.gz
rancid-9f2402b0d86333f5f7e9d50437036cd3124bde47.tar.xz
rancid-9f2402b0d86333f5f7e9d50437036cd3124bde47.zip
Imported from rancid-2.2.tar.gz.rancid-2.2
Diffstat (limited to 'bin')
-rw-r--r--bin/Makefile.am69
-rw-r--r--bin/Makefile.in423
-rw-r--r--[-rwxr-xr-x]bin/alogin.in61
-rw-r--r--[-rwxr-xr-x]bin/arancid.in13
-rw-r--r--[-rwxr-xr-x]bin/blogin.in14
-rw-r--r--[-rwxr-xr-x]bin/brancid.in30
-rwxr-xr-xbin/cat5rancid.in123
-rwxr-xr-xbin/clogin.in182
-rwxr-xr-xbin/configure904
-rw-r--r--bin/configure.in35
-rwxr-xr-xbin/control_rancid.in50
-rwxr-xr-xbin/do-diffs.in33
-rwxr-xr-xbin/elogin.in79
-rw-r--r--bin/env.in4
-rwxr-xr-xbin/erancid.in23
-rwxr-xr-xbin/flogin.in87
-rwxr-xr-xbin/francid.in53
-rwxr-xr-xbin/hlogin.in50
-rw-r--r--bin/hpfilter.c398
-rwxr-xr-xbin/hrancid.in515
-rwxr-xr-xbin/jlogin.in57
-rwxr-xr-xbin/jrancid.in48
-rwxr-xr-xbin/mrancid.in397
-rwxr-xr-xbin/rancid-fe.in36
-rwxr-xr-xbin/rancid.in146
-rwxr-xr-xbin/rrancid.in72
-rwxr-xr-xbin/xrancid.in48
27 files changed, 2203 insertions, 1747 deletions
diff --git a/bin/Makefile.am b/bin/Makefile.am
new file mode 100644
index 0000000..67c8966
--- /dev/null
+++ b/bin/Makefile.am
@@ -0,0 +1,69 @@
+## Process this file with automake to produce Makefile.in
+## A Makefile.in is supplied, in case you do not have automake.
+
+## Copyright (C) 1997-2001 by Henry Kilmer, Erik Sherk and Pete Whiting.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## There is no warranty or other guarantee of fitness of this software.
+## It is provided solely "as is". The author(s) disclaim(s) all
+## responsibility and liability with respect to this software's usage
+## or its effect upon hardware, computer systems, other software, or
+## anything else.
+
+#AUTOMAKE_OPTIONS=foreign no-dependencies
+AUTOMAKE_OPTIONS=foreign
+
+PREFIX = @prefix@
+
+bin_PROGRAMS = hpfilter
+hpfilter_SOURCES = hpfilter.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
+
+BIN_PROGS=@RD_BIN_PROGS@
+BIN_DATAS=@RD_BIN_DATAS@
+
+install: all
+ for prog in $(BIN_PROGS) ; do \
+ $(INSTALL) $$prog $(bindir); \
+ done; \
+ if test -f $(bindir)/env ; then \
+ echo "WARNING: *** $(bindir)/env exists: installing as env.new."; \
+ echo " *** review env.new for new/deprecated switches"; \
+ $(INSTALL_DATA) env $(bindir)/env.new; \
+ else \
+ $(INSTALL_DATA) env $(bindir); \
+ fi
+# BIN_DATAS are empty at the moment.
+# for prog in $(BIN_DATAS) ; do \
+# $(INSTALL_DATA) $$prog $(PREFIX)/bin; \
+# done; \
+
+#clean:
+# rm -f Makefile env $(BIN_DATAS) $(BIN_PROGS)
+
+#distclean: clean
+# rm -f config.log config.status
+
+#distdir:
+# for file in Makefile.in configure.in env.in $(BIN_DATAS:=.in) ; do \
+# $(INSTALL_DATA) $$file $(distdir); \
+# done
+# for file in configure $(BIN_PROGS:=.in) ; do \
+# $(INSTALL) $$file $(distdir); \
+# done
diff --git a/bin/Makefile.in b/bin/Makefile.in
index 511ad6b..77c15a6 100644
--- a/bin/Makefile.in
+++ b/bin/Makefile.in
@@ -1,52 +1,405 @@
-## Copyright (C) 1997-2001 by Henry Kilmer, Erik Sherk and Pete Whiting.
-## All rights reserved.
-##
-## This software may be freely copied, modified and redistributed without
-## fee for non-commerical purposes provided that this copyright notice is
-## preserved intact on all copies and modified copies.
-##
-## There is no warranty or other guarantee of fitness of this software.
-## It is provided solely "as is". The author(s) disclaim(s) all
-## responsibility and liability with respect to this software's usage
-## or its effect upon hardware, computer systems, other software, or
-## anything else.
+# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
-PREFIX = @prefix@
+# Copyright (C) 1994, 1995-8, 1999, 2001 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.
+
+#AUTOMAKE_OPTIONS=foreign no-dependencies
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+AUTOMAKE = @AUTOMAKE@
+CC = @CC@
+COMM = @COMM@
+CPP = @CPP@
+CVS = @CVS@
+DIFF = @DIFF@
+DIFF_CMD = @DIFF_CMD@
+DIRNAME = @DIRNAME@
+ENV_PATH = @ENV_PATH@
+EXPECT_PATH = @EXPECT_PATH@
+FIND = @FIND@
+GREP = @GREP@
+ID = @ID@
+INST_PROGS = @INST_PROGS@
+LG_PING_CMD = @LG_PING_CMD@
+MAILPLUS = @MAILPLUS@
+MAINT = @MAINT@
+MAKE = @MAKE@
+MAKEINFO = @MAKEINFO@
+MKDIR = @MKDIR@
+PACKAGE = @PACKAGE@
+PERLV = @PERLV@
+PERLV_PATH = @PERLV_PATH@
+PING_PATH = @PING_PATH@
+RD_BIN_DATAS = @RD_BIN_DATAS@
+RD_BIN_PROGS = @RD_BIN_PROGS@
+RD_UTIL_LG_PROGS = @RD_UTIL_LG_PROGS@
+RD_UTIL_PROGS = @RD_UTIL_PROGS@
+RSH = @RSH@
+SENDMAIL = @SENDMAIL@
+SORT = @SORT@
+SSH = @SSH@
+TAR = @TAR@
+TELNET = @TELNET@
+TOUCH = @TOUCH@
+U = @U@
+VERSION = @VERSION@
+
+AUTOMAKE_OPTIONS = foreign
+
+PREFIX = @prefix@
+
+bin_PROGRAMS = hpfilter
+hpfilter_SOURCES = hpfilter.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
+
+BIN_PROGS = @RD_BIN_PROGS@
+BIN_DATAS = @RD_BIN_DATAS@
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = ../include/config.h
+CONFIG_CLEAN_FILES = alogin arancid blogin brancid cat5rancid clogin \
+control_rancid create_cvs do-diffs elogin env erancid flogin francid \
+jlogin jrancid hlogin hrancid mrancid par rancid-fe rancid rename \
+rrancid xrancid
+PROGRAMS = $(bin_PROGRAMS)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I../include
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+hpfilter_OBJECTS = hpfilter.o
+hpfilter_LDADD = $(LDADD)
+hpfilter_DEPENDENCIES =
+hpfilter_LDFLAGS =
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON = Makefile.am Makefile.in alogin.in arancid.in blogin.in \
+brancid.in cat5rancid.in clogin.in control_rancid.in create_cvs.in \
+do-diffs.in elogin.in env.in erancid.in flogin.in francid.in hlogin.in \
+hrancid.in jlogin.in jrancid.in mrancid.in par.in rancid-fe.in \
+rancid.in rename.in rrancid.in xrancid.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+GZIP_ENV = --best
+SOURCES = $(hpfilter_SOURCES)
+OBJECTS = $(hpfilter_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .o .s
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
+ cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps bin/Makefile
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ cd $(top_builddir) \
+ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+alogin: $(top_builddir)/config.status alogin.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+arancid: $(top_builddir)/config.status arancid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+blogin: $(top_builddir)/config.status blogin.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+brancid: $(top_builddir)/config.status brancid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+cat5rancid: $(top_builddir)/config.status cat5rancid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+clogin: $(top_builddir)/config.status clogin.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+control_rancid: $(top_builddir)/config.status control_rancid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+create_cvs: $(top_builddir)/config.status create_cvs.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+do-diffs: $(top_builddir)/config.status do-diffs.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+elogin: $(top_builddir)/config.status elogin.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+env: $(top_builddir)/config.status env.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+erancid: $(top_builddir)/config.status erancid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+flogin: $(top_builddir)/config.status flogin.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+francid: $(top_builddir)/config.status francid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+jlogin: $(top_builddir)/config.status jlogin.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+jrancid: $(top_builddir)/config.status jrancid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+hlogin: $(top_builddir)/config.status hlogin.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+hrancid: $(top_builddir)/config.status hrancid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+mrancid: $(top_builddir)/config.status mrancid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+par: $(top_builddir)/config.status par.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+rancid-fe: $(top_builddir)/config.status rancid-fe.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+rancid: $(top_builddir)/config.status rancid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+rename: $(top_builddir)/config.status rename.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+rrancid: $(top_builddir)/config.status rrancid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+xrancid: $(top_builddir)/config.status xrancid.in
+ cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+mostlyclean-binPROGRAMS:
+
+clean-binPROGRAMS:
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+distclean-binPROGRAMS:
+
+maintainer-clean-binPROGRAMS:
+
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ if test -f $$p; then \
+ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
+ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ list='$(bin_PROGRAMS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
+ done
-BIN_PROGS=@RD_BIN_PROGS@
-BIN_DATAS=@RD_BIN_DATAS@
+.c.o:
+ $(COMPILE) -c $<
+
+.s.o:
+ $(COMPILE) -c $<
+
+.S.o:
+ $(COMPILE) -c $<
+
+mostlyclean-compile:
+ -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+ -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+hpfilter: $(hpfilter_OBJECTS) $(hpfilter_DEPENDENCIES)
+ @rm -f hpfilter
+ $(LINK) $(hpfilter_LDFLAGS) $(hpfilter_OBJECTS) $(hpfilter_LDADD) $(LIBS)
+
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS)'; \
+ unique=`for i in $$list; do echo $$i; done | \
+ awk ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+ -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = bin
+
+distdir: $(DISTFILES)
+ @for file in $(DISTFILES); do \
+ d=$(srcdir); \
+ if test -d $$d/$$file; then \
+ cp -pr $$d/$$file $(distdir)/$$file; \
+ else \
+ test -f $(distdir)/$$file \
+ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+ || cp -p $$d/$$file $(distdir)/$$file || :; \
+ fi; \
+ done
+hpfilter.o: hpfilter.c ../include/config.h ../include/version.h
+
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am: install-binPROGRAMS
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am: uninstall-binPROGRAMS
+uninstall: uninstall-am
+all-am: Makefile $(PROGRAMS)
+all-redirect: all-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+ $(mkinstalldirs) $(DESTDIR)$(bindir)
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -rm -f Makefile $(CONFIG_CLEAN_FILES)
+ -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
+ mostlyclean-tags mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am: clean-binPROGRAMS clean-compile clean-tags clean-generic \
+ mostlyclean-am
+
+clean: clean-am
+
+distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \
+ distclean-generic clean-am
+
+distclean: distclean-am
+
+maintainer-clean-am: maintainer-clean-binPROGRAMS \
+ maintainer-clean-compile maintainer-clean-tags \
+ maintainer-clean-generic distclean-am
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
+maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile tags mostlyclean-tags distclean-tags \
+clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
+check-am installcheck-am installcheck install-exec-am install-exec \
+install-data-am install-data install-am install uninstall-am uninstall \
+all-redirect all-am all installdirs mostlyclean-generic \
+distclean-generic clean-generic maintainer-clean-generic clean \
+mostlyclean distclean maintainer-clean
-all:
install: all
for prog in $(BIN_PROGS) ; do \
- $(INSTALL) $$prog $(PREFIX)/bin; \
+ $(INSTALL) $$prog $(bindir); \
done; \
- if test -f $(PREFIX)/bin/env ; then \
- echo "WARNING: *** $(PREFIX)/bin/env exists: installing as env.new."; \
+ if test -f $(bindir)/env ; then \
+ echo "WARNING: *** $(bindir)/env exists: installing as env.new."; \
echo " *** review env.new for new/deprecated switches"; \
- $(INSTALL_DATA) env $(PREFIX)/bin/env.new; \
+ $(INSTALL_DATA) env $(bindir)/env.new; \
else \
- $(INSTALL_DATA) env $(PREFIX)/bin; \
+ $(INSTALL_DATA) env $(bindir); \
fi
# BIN_DATAS are empty at the moment.
-# for prog in $(BIN_DATAS) ; do \
-# $(INSTALL_DATA) $$prog $(PREFIX)/bin; \
-# done; \
+# for prog in $(BIN_DATAS) ; do \
+# $(INSTALL_DATA) $$prog $(PREFIX)/bin; \
+# done; \
-clean:
- rm -f Makefile env $(BIN_DATAS) $(BIN_PROGS)
+#clean:
+# rm -f Makefile env $(BIN_DATAS) $(BIN_PROGS)
-distclean: clean
- rm -f config.log config.status
+#distclean: clean
+# rm -f config.log config.status
-distdir:
- for file in Makefile.in configure.in env.in $(BIN_DATAS:=.in) ; do \
- $(INSTALL_DATA) $$file $(distdir); \
- done
- for file in configure $(BIN_PROGS:=.in) ; do \
- $(INSTALL) $$file $(distdir); \
- done
+#distdir:
+# for file in Makefile.in configure.in env.in $(BIN_DATAS:=.in) ; do \
+# $(INSTALL_DATA) $$file $(distdir); \
+# done
+# for file in configure $(BIN_PROGS:=.in) ; do \
+# $(INSTALL) $$file $(distdir); \
+# done
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/bin/alogin.in b/bin/alogin.in
index 8ccf37b..9ffb9e8 100755..100644
--- a/bin/alogin.in
+++ b/bin/alogin.in
@@ -233,7 +233,6 @@ proc find {var router} {
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,
@@ -256,22 +255,27 @@ proc source_password_file { password_file } {
}
}
-
# Log into the router.
proc login { router user userpswd passwd prompt cmethod cyphertype } {
global spawn_id in_proc do_command do_script
global u_prompt p_prompt
set in_proc 1
- set tryssh 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 compare $prog "telnet"] {
- if [ catch {spawn telnet $router} reason ] {
- send_user "Error: telnet failed: $reason\n"
- exit 1
- }
+ if [string match "telnet*" $prog] {
+ regexp {telnet(:([^[:space:]]+))*} $prog command suffix port
+ if {"$port" == ""} {
+ set retval [ catch {spawn telnet $router} reason ]
+ } else {
+ set retval [ catch {spawn telnet $router $port} reason ]
+ }
+ if { $retval } {
+ send_user "\nError: telnet failed: $reason\n"
+ exit 1
+ }
} elseif ![string compare $prog "ssh"] {
if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
send_user "Error: ssh failed: $reason\n"
@@ -327,30 +331,27 @@ proc login { router user userpswd passwd prompt cmethod cyphertype } {
expect eof
send_user "Error: Unknown host\n"; wait; return 1
}
- -re "$u_prompt" { send "$user\r"
- expect {
- "Login incorrect" { send_user "Error: Couldn't login\n";
- catch {close}; wait; return 1 }
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
- -re "$p_prompt" { send "$userpswd\r" }
- -re "$prompt" { set in_proc 0; return 0 }
- }
- exp_continue
- }
- -re "$p_prompt" { send "$passwd\r"
- expect {
- "Password incorrect" { send_user "Error: Couldn't login\n";
- catch {close}; wait; return 1 }
- eof { send_user "Error: Couldn't login\n"; wait; return 1 }
- -re "$prompt" { set in_proc 0; return 0 }
- "Confirm seeing above note" { send "y\r" }
- }
- exp_continue
- }
- -re "^Confirm seeing above note" { send "y\r" }
+ -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
+ }
"Password incorrect" { send_user "Error: Check your password for $router\n";
catch {close}; wait; return 1 }
- -re "$prompt" { }
+ -re "$prompt" { break; }
denied { send_user "Error: Check your passwd for $router\n"
if { $do_command || $do_script } {
send "exit\r"
diff --git a/bin/arancid.in b/bin/arancid.in
index f27e2ec..f51a6c3 100755..100644
--- a/bin/arancid.in
+++ b/bin/arancid.in
@@ -174,6 +174,9 @@ sub WriteTerm {
defined($ENV{'NOCOMMSTR'})) {
ProcessHistory("","","","\/\*\t$1$2\"<removed>\"\n") && next;
}
+ /^(\s+.{2,3}pw )\S+/ &&
+ ProcessHistory("","","","\/\*$1<removed>\n") && next;
+
next if (/^\/\* Configuration dump taken/i);
next if (/^\/\* Version.*Base MAC.*/i);
@@ -240,7 +243,7 @@ TOP: while(<INPUT>) {
if (!defined($prompt)) {$prompt = ($_ =~ /^([^#]+#)/)[0]; }
print STDERR ("HIT COMMAND:$_") if ($debug);
if (!defined($commands{$cmd})) {
- print STDERR "found unexpected command - \"$cmd\"\n";
+ print STDERR "$host: found unexpected command - \"$cmd\"\n";
$clean_run = 0;
last TOP;
}
@@ -266,12 +269,12 @@ if (defined($ENV{NOPIPE})) {
# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
if (scalar(%commands)) {
- printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
- printf(STDERR "missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug);
+ 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 "End of run not found\n";
- print STDERR "End of run not found\n" if ($debug);
+ 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);
diff --git a/bin/blogin.in b/bin/blogin.in
index ceb58e6..cae1bce 100755..100644
--- a/bin/blogin.in
+++ b/bin/blogin.in
@@ -278,8 +278,14 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
# try each of the connection methods in $cmethod until one is successful
set progs [llength $cmethod]
foreach prog [lrange $cmethod 0 end] {
- if ![string compare $prog "telnet"] {
- if [ catch {spawn telnet $router} reason ] {
+ if [string match "telnet*" $prog] {
+ regexp {telnet(:([^[:space:]]+))*} $prog command suffix port
+ if {"$port" == ""} {
+ set retval [ catch {spawn telnet $router} reason ]
+ } else {
+ set retval [ catch {spawn telnet $router $port} reason ]
+ }
+ if { $retval } {
send_user "\nError: telnet failed: $reason\n"
exit 1
}
@@ -351,7 +357,7 @@ proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
exp_continue }
-re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
- send_user "\nError: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n"
return 1 }
-re "$u_prompt" { send "$user\r"
expect {
@@ -549,7 +555,7 @@ foreach router [lrange $argv $i end] {
# Figure out connection method
set cmethod [find method $router]
- if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }
+ if { "$cmethod" == "" } { set cmethod {{telnet}} }
# Login to the router
if {[login $router $ruser $userpswd $passwd $enapasswd $prompt $cmethod $cyphertype]} {
diff --git a/bin/brancid.in b/bin/brancid.in
index fd8e5aa..2ea7e3b 100755..100644
--- a/bin/brancid.in
+++ b/bin/brancid.in
@@ -31,6 +31,8 @@ $clean_run = 0;
$found_end = 0;
$timeo = 90; # blogin timeout in seconds
+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)=(@_);
@@ -141,6 +143,7 @@ sub ShowConfig {
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 (defined($ENV{'NOCOMMSTR'})) {
@@ -169,6 +172,7 @@ sub RunCommand {
# prompt may have changed
if (/\>/) {
$prompt = ($_ =~ /^([^>]+>)/)[0];
+ $prompt =~ s/([][])/\\$1/g;
last;
}
}
@@ -216,7 +220,16 @@ if ($file) {
}
}
-ProcessHistory("","","","!RANCID-CONTENT-TYPE: Bay Networks\n!\n");
+# 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: bay\n!\n");
TOP: while(<INPUT>) {
tr/\015//d;
if ( (/\>\s?logout$/) || $found_end ) {
@@ -231,10 +244,13 @@ TOP: while(<INPUT>) {
}
while (/>\s*($cmds_regexp)\s*$/) {
$cmd = $1;
- if (!defined($prompt)) {$prompt = ($_ =~ /^([^>]+>)/)[0]; }
+ if (!defined($prompt)) {
+ $prompt = ($_ =~ /^([^>]+>)/)[0];
+ $prompt =~ s/([][])/\\$1/g;
+ }
print STDERR ("HIT COMMAND:$_") if ($debug);
if (! defined($commands{$cmd})) {
- print STDERR "found unexpected command - \"$cmd\"\n";
+ print STDERR "$host: found unexpected command - \"$cmd\"\n";
$clean_run = 0;
last TOP;
}
@@ -260,12 +276,12 @@ if (defined($ENV{NOPIPE})) {
# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
if (scalar(%commands)) {
- printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
- printf(STDERR "missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug);
+ 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 "End of run not found\n";
- print STDERR "End of run not found\n" if ($debug);
+ 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);
diff --git a/bin/cat5rancid.in b/bin/cat5rancid.in
index 055ea04..c8219d8 100755
--- a/bin/cat5rancid.in
+++ b/bin/cat5rancid.in
@@ -30,6 +30,7 @@ $clean_run = 0;
$found_end = 0;
$timeo = 90; # clogin timeout in seconds
+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
@@ -700,7 +701,7 @@ OUTER:while (<INPUT>) {
tr/\015//d;
last if (/^\s*$/);
last OUTER if (/^$prompt/);
- if (/^(\d+)\s+(\S+\s+)?\d+\s+(.*)\s+\S+\s+(\S+)\s+\S+\s*$/) {
+ 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,}.*$//;
@@ -765,40 +766,6 @@ OUTER:while (<INPUT>) {
}
}
-# This routine parses "show c7200" for the 7200
-# This will create arrarys for hw info.
-sub ShowC7200 {
- # 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*)$/);
- return(1) if ($type !~ /^72/);
- /^$/ && next;
- 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:/) {
- $_ = <INPUT>;
- /revision\s+(\S+).*revision\s+(\S+)/ &&
- ProcessHistory("SLOT","","","!Slot CPU: hvers $1 rev $2\n");
- $_ = <INPUT>;
- /number\s+(\S+)\s+Part number\s+(\S+)/ &&
- ProcessHistory("SLOT","","","!Slot CPU: part $2, serial $1\n!\n");
- next;
- }
- }
- return(0);
-}
-
# This routine processes a "show port ifindex"
sub ShowPortIfindex {
print STDERR " In ShowPortIfindex: $_" if ($debug);
@@ -829,7 +796,7 @@ sub WriteTerm {
# 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 configuration...)/i) {
+ if (/^(\.\.+$|##+$|(Building|Current) configuration)/i) {
while (<INPUT>) {
tr/\015//d;
next if (/^Current configuration:/i);
@@ -846,6 +813,7 @@ sub WriteTerm {
# 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:
@@ -853,22 +821,46 @@ sub WriteTerm {
/^ntp clock-period / && next; # kill ntp clock-period
/^ length / && next; # kill length on serial lines
/^ width / && next; # kill width on serial lines
- /^enable password / &&
- ProcessHistory("ENABLE","","","!enable password <removed>\n") &&
+ if (/^enable password / && $filter_pwds >= 1) {
+ ProcessHistory("ENABLE","","","! $1 <removed>\n");
+ next;
+ }
+ if (/^set enablepass / && $filter_pwds >= 2) {
+ ProcessHistory("ENABLE","","","! $1 <removed>\n");
next;
- /^(username .*) password /&&
- ProcessHistory("USER","","","!$1 password <removed>\n") && next;
- /^\s*password / &&
- ProcessHistory("LINE-PASS","","","! password <removed>\n") && next;
- /^\s*neighbor (\S*) password / &&
- ProcessHistory("","","","! neighbor $1 password <removed>\n") &&
+ }
+ if (/^(username .*) password /) {
+ if (/^(username .*) password / && $filter_pwds >= 1) {
+ ProcessHistory("USER","","","! $1 password <removed>\n");
+ } else {
+ ProcessHistory("USER","","","$_\n");
+ }
+ next;
+ }
+ if (/^set password / && $filter_pwds >= 2) {
+ ProcessHistory("","","","! set password <removed>\n");
+ next;
+ }
+ if (/^(\s*)password / && $filter_pwds >= 1) {
+ ProcessHistory("LINE-PASS","","","!$1password <removed>\n");
+ next;
+ }
+ if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) {
+ ProcessHistory("","","","! neighbor $1 password <removed>\n");
+ next;
+ }
+ if (/^(ip ftp password) / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\n");
next;
- /^(ip ftp password) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
- /^( ip ospf authentication-key) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
- /^( ip ospf message-digest-key \d+ md5) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
+ }
+ if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\n");
+ next;
+ }
+ if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\n");
+ next;
+ }
/fair-queue individual-limit/ && next;
# sort ip explicit-paths.
if (/^ip explicit-path name (\S+)/) {
@@ -956,8 +948,10 @@ sub WriteTerm {
# order alias statements
/^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next;
# delete ntp auth password
- /^(ntp authentication-key \d+ md5) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
+ if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 2) {
+ ProcessHistory("","","","!$1 <removed>\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);
@@ -997,6 +991,8 @@ sub DoNothing {print STDOUT;}
'dir bootflash:' => "DirSlotN",
'dir slot0:' => "DirSlotN",
'dir slot1:' => "DirSlotN",
+ 'dir sup-bootflash:' => "DirSlotN",
+ 'dir sup-microcode:' => "DirSlotN",
'show module' => "ShowModule",
'show port ifindex' => "ShowPortIfindex",
'write term' => "WriteTerm"
@@ -1010,6 +1006,8 @@ sub DoNothing {print STDOUT;}
"dir bootflash:",
"dir slot0:",
"dir slot1:",
+ "dir sup-bootflash:",
+ "dir sup-microcode:",
"show module",
"show port ifindex",
"write term"
@@ -1037,7 +1035,16 @@ if ($file) {
}
}
-ProcessHistory("","","","!RANCID-CONTENT-TYPE: cat5\n!\n");
+# 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: cisco-cat\n!\n");
ProcessHistory("COMMENTS","keysort","B0","!\n");
ProcessHistory("COMMENTS","keysort","F0","!\n");
ProcessHistory("COMMENTS","keysort","G0","!\n");
@@ -1058,7 +1065,7 @@ TOP: while(<INPUT>) {
if (!defined($prompt)) {$prompt = ($_ =~ /^([^>]+>)/)[0]; }
print STDERR ("HIT COMMAND:$_") if ($debug);
if (! defined($commands{$cmd})) {
- print STDERR "found unexpected command - \"$cmd\"\n";
+ print STDERR "$host: found unexpected command - \"$cmd\"\n";
$clean_run = 0;
last TOP;
}
@@ -1084,12 +1091,12 @@ if (defined($ENV{NOPIPE})) {
# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
if (scalar(%commands)) {
- printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
- printf(STDERR "missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug);
+ 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 "End of run not found\n";
- print STDERR "End of run not found\n" if ($debug);
+ 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);
diff --git a/bin/clogin.in b/bin/clogin.in
index 4ebe2ac..afb18e3 100755
--- a/bin/clogin.in
+++ b/bin/clogin.in
@@ -173,8 +173,8 @@ for {set i 0} {$i < $argc} {incr i} {
}
if [ catch {set cmd_fd [open $cmd_file r]} reason ] {
send_user "\nError: $reason\n"
- exit 1
- }
+ exit 1
+ }
set cmd_text [read $cmd_fd]
close $cmd_fd
set command [join [split $cmd_text \n] \;]
@@ -235,25 +235,25 @@ proc label { host } {
# add password * hanky-pie
proc add {var args} { global int_$var ; lappend int_$var $args}
proc include {args} {
- global env
- regsub -all "(^{|}$)" $args {} 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} {
- upvar int_$var list
+ upvar int_$var list
if { [info exists list] } {
foreach line $list {
if { [string match [lindex $line 0] $router ] } {
return [lrange $line 1 end]
- }
- }
- }
- return {}
-}
+ }
+ }
+ }
+ 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
@@ -282,12 +282,19 @@ 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
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 compare $prog "telnet"] {
- if [ catch {spawn telnet $router} reason ] {
+ if [string match "telnet*" $prog] {
+ regexp {telnet(:([^[:space:]]+))*} $prog command suffix port
+ if {"$port" == ""} {
+ set retval [ catch {spawn telnet $router} reason ]
+ } else {
+ set retval [ catch {spawn telnet $router $port} reason ]
+ }
+ if { $retval } {
send_user "\nError: telnet failed: $reason\n"
exit 1
}
@@ -342,14 +349,17 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
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" {
+ }
+ eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
+ -nocase "unknown host\r" {
catch {close};
send_user "\nError: Unknown host\n"; wait; return 1
- } "Host is unreachable" {
+ }
+ "Host is unreachable" {
catch {close};
send_user "\nError: Host Unreachable!\n"; wait; return 1
- } "No address associated with name" {
+ }
+ "No address associated with name" {
catch {close};
send_user "\nError: Unknown host\n"; wait; return 1
}
@@ -359,41 +369,51 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
exp_continue }
-re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
- send_user "\nError: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n"
return 1 }
- -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"; vatch {close}; 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"
- if { $do_command || $do_script } {
- send "exit\r"
- wait
- return 1
- } else {
- return 1
- }
- }
- "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
+ -re "(denied|Sorry)" {
+ send_user "\nError: Check your passwd for $router\n"
+ if { $do_command || $do_script } {
+ send "exit\r"
+ wait
+ return 1
+ } else {
+ 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
+ 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
+ }
+ "$prompt" { break; }
+ "Login invalid" {
+ send_user "\nError: Invalid login\n";
+ catch {close}; wait; return 1
+ }
}
}
@@ -431,7 +451,7 @@ proc run_commands { prompt command } {
# 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 and extreme.
+ # skip if its an extreme.
if { [ string compare "extreme" "$platform" ] } {
if [ regexp -- ".*> .*enable" "$prompt" ] {
send "set length 0\r"
@@ -439,6 +459,8 @@ proc run_commands { prompt command } {
send "term length 0\r"
}
regsub -all "\[)(]" $prompt {\\&} reprompt
+ # match cisco config mode prompts too, but not for catalyst ie: (enable)
+ regsub -all "\[#>]$" $reprompt {(\\([^\\r\\n]+\\))?&} reprompt
expect {
-re $reprompt {}
-re "\[\n\r]+" { exp_continue }
@@ -446,7 +468,7 @@ proc run_commands { prompt command } {
} else {
regsub -all "\[)(]" $prompt {\\&} reprompt
}
- # this is the only way i see to get rid for more prompts in o/p..grrrrr
+ # this is the only way i see to get rid of more prompts in o/p..grrrrr
log_user 0
# Is this a multi-command?
if [ string match "*\;*" "$command" ] {
@@ -458,23 +480,28 @@ proc run_commands { prompt command } {
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 <SPACE> to cont\[^\r\n]*" { send " "
+ -re "\[^\r\n]*Press <SPACE> to cont\[^\r\n]*" {
+ send " "
+ # bloody ^[[2K after " "
expect {
- # gag, 2 more prompts
- -re "\[\r\n]*\r" {}
- -re "\[^\r\n]*Press <SPACE> to cont\[^\r\n]*" { send " "; exp_continue }
- }
+ -re "^\[^\r\n]*\r" {}
+ }
exp_continue
}
- -re "^<-+ More -+>\[^\n\r]*" { send " "
+ -re "^ --More--\[^\n\r]*" {
+ send " "
+ exp_continue }
+ -re "^<-+ More -+>\[^\n\r]*" {
+ send_user -- "$expect_out(buffer)"
+ send " "
exp_continue }
- -re "\b+" { exp_continue }
}
}
} else {
@@ -483,21 +510,28 @@ proc run_commands { prompt command } {
# global switch in the config.
send "[subst -nocommands $command]\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 <SPACE> to cont\[^\r\n]*" { send " "
+ -re "\[^\r\n]*Press <SPACE> to cont\[^\r\n]*" {
+ send " "
+ # bloody ^[[2K after " "
expect {
- -re "\[\r\n]*\r\r" {}
- }
+ -re "^\[^\r\n]*\r" {}
+ }
exp_continue
}
- -re "^<-+ More -+>\[^\n\r]*" { send " "
+ -re "^ --More--\[^\n\r]*" {
+ send " "
+ exp_continue }
+ -re "^<-+ More -+>\[^\n\r]*" {
+ send_user -- "$expect_out(buffer)"
+ send " "
exp_continue }
- -re "\b+" { exp_continue }
}
}
log_user 1
@@ -595,7 +629,7 @@ foreach router [lrange $argv $i end] {
# Figure out prompts
set u_prompt [find userprompt $router]
- if { "$u_prompt" == "" } { set u_prompt "(Username|login|user name):" }
+ if { "$u_prompt" == "" } { set u_prompt "(Username|Login|login|user name):" }
set p_prompt [find passprompt $router]
if { "$p_prompt" == "" } { set p_prompt "(\[Pp]assword|passwd):" }
set e_prompt [find enableprompt $router]
@@ -627,8 +661,8 @@ foreach router [lrange $argv $i end] {
}
}
# we are logged in, now figure out the full prompt
- send "\r"
- expect {
+ send "\r"
+ expect {
-re "\[\r\n]+" { exp_continue; }
-re "^(.+:)1 $prompt" { # stoopid extreme cmd-line numbers and
# prompt based on state of config changes
@@ -637,9 +671,11 @@ foreach router [lrange $argv $i end] {
set prompt ".? ?$junk\[0-9]+ $prompt";
set platform "extreme"
}
- -re "^.+$prompt" { set prompt $expect_out(0,string); }
- -re "^.+> \\\(enable\\\)" { set prompt $expect_out(0,string); }
- }
+ -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]} {
diff --git a/bin/configure b/bin/configure
deleted file mode 100755
index 69078a7..0000000
--- a/bin/configure
+++ /dev/null
@@ -1,904 +0,0 @@
-#! /bin/sh
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13
-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-ac_default_prefix=/usr/local/rancid
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-# Maximum number of lines to put in a shell here document.
-ac_max_here_lines=12
-
-ac_prev=
-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=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case "$ac_option" in
-
- -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 ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build="$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" ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir="$ac_optarg" ;;
-
- -disable-* | --disable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- eval "enable_${ac_feature}=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_${ac_feature}='$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)
- # 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 << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
- --cache-file=FILE cache test results in FILE
- --help print this message
- --no-create do not create output files
- --quiet, --silent do not print \`checking...' messages
- --version print the version of autoconf that created configure
-Directory and file names:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- --bindir=DIR user executables in DIR [EPREFIX/bin]
- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
- --includedir=DIR C header files in DIR [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- --infodir=DIR info documentation in DIR [PREFIX/info]
- --mandir=DIR man documentation in DIR [PREFIX/man]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --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
-EOF
- cat << EOF
-Host type:
- --build=BUILD configure for building on BUILD [BUILD=HOST]
- --host=HOST configure for HOST [guessed]
- --target=TARGET configure for TARGET [TARGET=HOST]
-Features and packages:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --x-includes=DIR X include files are in DIR
- --x-libraries=DIR X library files are in DIR
-EOF
- if test -n "$ac_help"; then
- echo "--enable and --with options recognized:$ac_help"
- fi
- exit 0 ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host="$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" ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- 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)
- 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" ;;
-
- -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 ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target="$ac_optarg" ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.13"
- exit 0 ;;
-
- -with-* | --with-*)
- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "with_${ac_package}='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- eval "with_${ac_package}=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" ;;
-
- -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
- ;;
-
- *)
- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
- echo "configure: warning: $ac_option: invalid host type" 1>&2
- fi
- if test "x$nonopt" != xNONE; then
- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
- fi
- nonopt="$ac_option"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
- exec 6>/dev/null
-else
- exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
- case "$ac_arg" in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
- esac
-done
-
-# NLS nuisances.
-# Only set these to C if already set. These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=
-
-# 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 its parent.
- ac_prog=$0
- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
- 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
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
- else
- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
- fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- echo "loading site script $ac_site_file"
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- echo "loading cache $cache_file"
- . $cache_file
-else
- echo "creating cache $cache_file"
- > $cache_file
-fi
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-ac_exeext=
-ac_objext=o
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
- # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
- ac_n= ac_c='
-' ac_t=' '
- else
- ac_n=-n ac_c= ac_t=
- fi
-else
- ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-
-
-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
- fi
-done
-if test -z "$ac_aux_dir"; then
- { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
-fi
-ac_config_guess=$ac_aux_dir/config.guess
-ac_config_sub=$ac_aux_dir/config.sub
-ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
-
-# 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
-# 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"
-# ./install, which can be erroneously created by make from ./install.sh.
-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:560: checking for a BSD compatible install" >&5
-if test -z "$INSTALL"; then
-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
- for ac_dir in $PATH; do
- # Account for people who put trailing slashes in PATH elements.
- case "$ac_dir/" in
- /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/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
- if test -f $ac_dir/$ac_prog; then
- if test $ac_prog = install &&
- grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- :
- else
- ac_cv_path_install="$ac_dir/$ac_prog -c"
- break 2
- fi
- fi
- done
- ;;
- esac
- done
- IFS="$ac_save_IFS"
-
-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. We don't cache a
- # path for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the path is relative.
- INSTALL="$ac_install_sh"
- fi
-fi
-echo "$ac_t""$INSTALL" 1>&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_PROGRAM}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-
-RD_BIN_DATAS=$rd_cv_rd_bin_datas
-
-RD_BIN_PROGS=$rd_cv_rd_bin_progs
-
-
-PERLV_PATH=$ac_cv_path_PERLV_PATH
-
-PERLV=$ac_cv_PERLV
-
-
-EXPECT_PATH=$ac_cv_path_EXPECT_PATH
-
-
-ENV_PATH=$ac_cv_env_path
-
-
-MAILPLUS=$rd_cv_MAILPLUS
-
-
-DIFF_CMD=$rd_cv_DIFF_CMD
-
-
-trap '' 1 2 15
-cat > confcache <<\EOF
-# 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. It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already. You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# 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.
-(set) 2>&1 |
- case `(ac_space=' '; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote substitution
- # turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- -e "s/'/'\\\\''/g" \
- -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
- ;;
- esac >> confcache
-if cmp -s $cache_file confcache; then
- :
-else
- if test -w $cache_file; then
- echo "updating cache $cache_file"
- cat confcache > $cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-# Transform confdefs.h into DEFS.
-# Protect against shell expansion while executing Makefile rules.
-# Protect against Makefile macro expansion.
-cat > conftest.defs <<\EOF
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
-s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
-s%\[%\\&%g
-s%\]%\\&%g
-s%\$%$$%g
-EOF
-DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
-rm -f conftest.defs
-
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
- case "\$ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.13"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "\$ac_cs_usage"; exit 0 ;;
- *) echo "\$ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-ac_given_INSTALL="$INSTALL"
-
-trap 'rm -fr `echo "Makefile env $RD_BIN_DATAS $RD_BIN_PROGS" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@SHELL@%$SHELL%g
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@FFLAGS@%$FFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
-s%@RD_BIN_DATAS@%$RD_BIN_DATAS%g
-s%@RD_BIN_PROGS@%$RD_BIN_PROGS%g
-s%@PERLV_PATH@%$PERLV_PATH%g
-s%@PERLV@%$PERLV%g
-s%@EXPECT_PATH@%$EXPECT_PATH%g
-s%@ENV_PATH@%$ENV_PATH%g
-s%@MAILPLUS@%$MAILPLUS%g
-s%@DIFF_CMD@%$DIFF_CMD%g
-
-CEOF
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
-
-# Split the substitutions into bite-sized pieces for seds with
-# small command number limits, like on Digital OSF/1 and HP-UX.
-ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
-ac_file=1 # Number of current file.
-ac_beg=1 # First line for current file.
-ac_end=$ac_max_sed_cmds # Line after last line for current file.
-ac_more_lines=:
-ac_sed_cmds=""
-while $ac_more_lines; do
- if test $ac_beg -gt 1; then
- sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
- else
- sed "${ac_end}q" conftest.subs > conftest.s$ac_file
- fi
- if test ! -s conftest.s$ac_file; then
- ac_more_lines=false
- rm -f conftest.s$ac_file
- else
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f conftest.s$ac_file"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
- fi
- ac_file=`expr $ac_file + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_cmds`
- fi
-done
-if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
-fi
-EOF
-
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile env $RD_BIN_DATAS $RD_BIN_PROGS"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
-
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
- else
- ac_dir_suffix= ac_dots=
- fi
-
- case "$ac_given_srcdir" in
- .) srcdir=.
- if test -z "$ac_dots"; then top_srcdir=.
- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
- *) # Relative path.
- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
- top_srcdir="$ac_dots$ac_given_srcdir" ;;
- esac
-
- case "$ac_given_INSTALL" in
- [/$]*) INSTALL="$ac_given_INSTALL" ;;
- *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
- esac
-
- echo creating "$ac_file"
- rm -f "$ac_file"
- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
- case "$ac_file" in
- *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
- *) ac_comsub= ;;
- esac
-
- ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
- sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-s%@INSTALL@%$INSTALL%g
-" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
-fi; done
-rm -f conftest.s*
-
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
-
-# fix permissions on scripts.
-for file in $RD_BIN_PROGS; do chmod a+x $file; done
diff --git a/bin/configure.in b/bin/configure.in
deleted file mode 100644
index d78d758..0000000
--- a/bin/configure.in
+++ /dev/null
@@ -1,35 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT()
-
-dnl default install location
-AC_PREFIX_DEFAULT(/usr/local/rancid)
-
-dnl install program(s)
-AC_PROG_INSTALL
-
-RD_BIN_DATAS=$rd_cv_rd_bin_datas
-AC_SUBST(RD_BIN_DATAS)
-RD_BIN_PROGS=$rd_cv_rd_bin_progs
-AC_SUBST(RD_BIN_PROGS)
-
-PERLV_PATH=$ac_cv_path_PERLV_PATH
-AC_SUBST(PERLV_PATH)
-PERLV=$ac_cv_PERLV
-AC_SUBST(PERLV)
-
-EXPECT_PATH=$ac_cv_path_EXPECT_PATH
-AC_SUBST(EXPECT_PATH)
-
-ENV_PATH=$ac_cv_env_path
-AC_SUBST(ENV_PATH)
-
-MAILPLUS=$rd_cv_MAILPLUS
-AC_SUBST(MAILPLUS)
-
-DIFF_CMD=$rd_cv_DIFF_CMD
-AC_SUBST(DIFF_CMD)
-
-AC_OUTPUT(Makefile env $RD_BIN_DATAS $RD_BIN_PROGS)
-
-# fix permissions on scripts.
-for file in $RD_BIN_PROGS; do chmod a+x $file; done
diff --git a/bin/control_rancid.in b/bin/control_rancid.in
index 3d4935e..6e13f7b 100755
--- a/bin/control_rancid.in
+++ b/bin/control_rancid.in
@@ -19,10 +19,36 @@
# control_rancid $GROUP
#
+# command-line options
+# -r <device name>
+if [ $# -ge 1 ] ; then
+
+ while [ 1 ] ; do
+ case $1 in
+ -r)
+ shift
+ # next arg is the device name
+ device="$1"
+ shift
+ ;;
+ --)
+ shift; break;
+ ;;
+ -*)
+ echo "unknown option: $1" >&2
+ exit 1
+ ;;
+ *)
+ break;
+ ;;
+ esac
+ done
+fi
+
# Number of things par should run in parallel.
PAR_COUNT=${PAR_COUNT:-5}
-# Must specify a group to run rancid
+# Must specify a group on which to run rancid
if [ $# -lt 1 ]; then
echo 'must specify group'; exit 1
else
@@ -194,13 +220,25 @@ then
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 "^$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 "Trying to get all of the configs."
-par -q -n $PAR_COUNT -c "rancid-fe \{}" $DIR/routers.up
+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
@@ -212,7 +250,7 @@ if [ -f $DIR/routers.up.missed ]; then
fi
while [ $round -le $pass ]
do
- for router in `cat $DIR/routers.up`
+ for router in `cat $devlistfile`
do
OFS=$IFS
IFS=':'
@@ -255,7 +293,7 @@ rename 's/.new$//' *.new
# This has been different for different machines...
# Diff the directory and then checkin.
-trap 'rm -fr $TMP $TMP.diff;' 1 2 15
+trap 'rm -fr $TMP $TMP.diff $DIR/routers.single;' 1 2 15
cd $DIR
cvs -f @DIFF_CMD@ | sed -e '/^RCS file: /d' -e '/^--- /d' \
-e '/^+++ /d' -e 's/^\([-+ ]\)/\1 /' >$TMP.diff
@@ -281,7 +319,7 @@ 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);}" $DIR/routers.up | sort -u > $DIR/routers.failed
+ if (time() - \$t >= $OLDTIME*60*60);}" $devlistfile | sort -u > $DIR/routers.failed
if [ -s $DIR/routers.failed ]
then
(
@@ -297,5 +335,5 @@ then
fi
# Cleanup
-rm -f $TMP.diff
+rm -f $TMP.diff $DIR/routers.single
trap '' 1 2 15
diff --git a/bin/do-diffs.in b/bin/do-diffs.in
index 940203f..a8d4800 100755
--- a/bin/do-diffs.in
+++ b/bin/do-diffs.in
@@ -21,6 +21,32 @@ ENVFILE="`dirname $0`/env"
TMPDIR=${TMPDIR:=/tmp}; export TMPDIR
+# command-line options
+# -r <device name>
+if [ $# -ge 1 ] ; then
+
+ while [ 1 ] ; do
+ case $1 in
+ -r)
+ shift
+ # next arg is the device name
+ device="$1"
+ shift
+ ;;
+ --)
+ shift; break;
+ ;;
+ -*)
+ echo "unknown option: $1" >&2
+ exit 1
+ ;;
+ *)
+ break;
+ ;;
+ esac
+ done
+fi
+
if [ $# -ge 1 ] ; then
LIST_OF_GROUPS="$*"; export LIST_OF_GROUPS
elif [ "$LIST_OF_GROUPS" = "" ] ; then
@@ -32,7 +58,6 @@ if [ ! -d $BASEDIR/logs ] ; then
mkdir $BASEDIR/logs
fi
-
for GROUP in $LIST_OF_GROUPS
do
@@ -72,7 +97,11 @@ END
trap 'rm -fr $LOCKFILE;exit 1' 1 2 3 6 10 15
touch $LOCKFILE
if [ $? -eq 0 ] ; then
- control_rancid $GROUP
+ if [ "X$device" = "X" ] ; then
+ control_rancid $GROUP
+ else
+ control_rancid -r $device $GROUP
+ fi
rm -f $LOCKFILE
fi
trap '' 1 2 3 6 10 15
diff --git a/bin/elogin.in b/bin/elogin.in
index 1affce7..56eab56 100755
--- a/bin/elogin.in
+++ b/bin/elogin.in
@@ -239,7 +239,6 @@ proc find {var router} {
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,
@@ -262,20 +261,33 @@ proc source_password_file { password_file } {
}
}
-
# Log into the router.
-proc login { router user userpswd passwd prompt cyphertype } {
+proc login { router user userpswd passwd prompt cmethod cyphertype } {
global spawn_id in_proc do_command do_script
global u_prompt p_prompt
set in_proc 1
- set tryssh 1
-
- # Telnet to the router & try to login.
- if [ catch {spawn telnet $router} reason ] {
- send_user "\nError: failed to telnet: $reason\n"
- exit 1
- }
- sleep 0.3
+ 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 {spawn telnet $router} reason ]
+ } else {
+ set retval [ catch {spawn telnet $router $port} reason ]
+ }
+ if { $retval } {
+ send_user "\nError: telnet 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 {
@@ -315,28 +327,24 @@ proc login { router user userpswd passwd prompt cyphertype } {
expect eof
send_user "\nError: Unknown host\n"; wait; return 1
}
- -re "$u_prompt" { send "$user\r"
- expect {
- "Login incorrect" { send_user "\nError: Couldn't login\n";
- catch {close}; wait; return 1 }
- eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
- -re "$p_prompt" { send "$userpswd\r" }
- "$prompt" { set in_proc 0; return 0 }
- }
- exp_continue
- }
- -re "$p_prompt" { send "$passwd\r"
- expect {
- "Password incorrect" { send_user "\nError: Couldn't login\n";
- catch {close}; wait; return 1 }
- eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
- "$prompt" { set in_proc 0; return 0 }
- }
- 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
+ }
"Password incorrect" { send_user "\nError: Check your password for $router\n";
- catch {close}; wait; return 1 }
- "$prompt" { }
+ catch {close}; wait; return 1
+ }
+ "$prompt" { break; }
denied { send_user "\nError: Check your passwd for $router\n"
if { $do_command || $do_script } {
send "exit\r"
@@ -347,6 +355,7 @@ proc login { router user userpswd passwd prompt cyphertype } {
}
}
"\r\n" { exp_continue; }
+ }
}
set in_proc 0
return 0
@@ -449,8 +458,12 @@ foreach router [lrange $argv $i end] {
if { "$cyphertype" == "" } { set cyphertype "3des" }
}
+ # Figure out connection method
+ set cmethod [find method $router]
+ if { "$cmethod" == "" } { set cmethod {{telnet}} }
+
# Login to the router
- if {[login $router $ruser $userpswd $passwd $prompt $cyphertype]} {
+ if {[login $router $ruser $userpswd $passwd $prompt $cmethod $cyphertype]} {
continue
}
diff --git a/bin/env.in b/bin/env.in
index 1f58c7d..e3c2ba4 100644
--- a/bin/env.in
+++ b/bin/env.in
@@ -21,6 +21,10 @@ CVSROOT=$BASEDIR/CVS; export CVSROOT
# collection from the router(s).
#NOPIPE=YES; export NOPIPE
#
+# FILTER_PWDS determines which passwords are filtered from configs by the
+# value set (NO | YES | ALL). see env(5).
+#FILTER_PWDS=YES; export FILTER_PWDS
+#
# if NOCOMMSTR is set, snmp community strings will be stripped from the configs
#NOCOMMSTR=YES; export NOCOMMSTR
#
diff --git a/bin/erancid.in b/bin/erancid.in
index aac7ea0..01a6268 100755
--- a/bin/erancid.in
+++ b/bin/erancid.in
@@ -33,6 +33,8 @@ $clean_run = 0;
$found_end = 0;
$timeo = 90; # clogin timeout in seconds
+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)=(@_);
@@ -237,7 +239,16 @@ if ($file) {
}
}
-ProcessHistory("","","","- RANCID-CONTENT-TYPE: ezt3\n-\n");
+# 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: adc-ezt3\n-\n");
ProcessHistory("COMMENTS","keysort","B0","-\n");
ProcessHistory("COMMENTS","keysort","F0","-\n");
ProcessHistory("COMMENTS","keysort","G0","-\n");
@@ -261,7 +272,7 @@ while(<INPUT>) {
}
print STDERR ("HIT COMMAND:$_") if ($debug);
if (! defined($commands{$cmd})) {
- print STDERR "found unexpected command - \"$cmd\"\n";
+ print STDERR "$host: found unexpected command - \"$cmd\"\n";
$clean_run = 0;
last;
}
@@ -287,12 +298,12 @@ if (defined($ENV{NOPIPE})) {
# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
if (scalar(%commands)) {
- printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
- printf(STDERR "missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug);
+ 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 "End of run not found\n";
- print STDERR "End of run not found\n" if ($debug);
+ 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);
diff --git a/bin/flogin.in b/bin/flogin.in
index 85f77d6..a913b56 100755
--- a/bin/flogin.in
+++ b/bin/flogin.in
@@ -275,16 +275,41 @@ proc source_password_file { password_file } {
}
# Log into the router.
-proc login { router user userpswd passwd enapasswd prompt cyphertype } {
+proc login { router user userpswd passwd enapasswd prompt cmethod cyphertype } {
global spawn_id in_proc do_command do_script
set in_proc 1
- set tryssh 1
+ set uprompt_seen 0
# Telnet to the router & try to login.
- if [ catch {spawn telnet $router} reason ] {
- send_user "\nError: failed to telnet: $reason\n"
- exit 1
- }
+ 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 {spawn telnet $router} reason ]
+ } else {
+ set retval [ catch {spawn telnet $router $port} reason ]
+ }
+ if { $retval } {
+ send_user "\nError: telnet failed: $reason\n"
+ exit 1
+ }
+ } elseif ![string compare $prog "ssh"] {
+ if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
+ send_user "\nError: ssh failed: $reason\n"
+ exit 1
+ }
+ } 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.
@@ -347,27 +372,8 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
exp_continue }
-re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
- send_user "\nError: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n"
return 1 }
- -re "(Username:|login:|Name :)" {
- sleep 1;
- send "$user\r"
- expect {
- eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
- -re "\[Pp]assword:" { send "$userpswd\r" }
- "$prompt" { set in_proc 0; return 0 }
- }
- exp_continue
- }
- "\[Pp]assword:" { send "$passwd\r"
- expect {
- eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
- "Password:" { send "$enapasswd\r" }
- "$prompt" { set in_proc 0; return 0 }
- }
- exp_continue
- }
- "$prompt" { }
denied { send_user "\nError: Check your passwd for $router\n"
if { $do_command || $do_script } {
send "quit"
@@ -378,6 +384,29 @@ proc login { router user userpswd passwd enapasswd prompt cyphertype } {
}
}
"% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
+ -re "(Username:|login:|Name :)" {
+ sleep 1;
+ send "$user\r"
+ set uprompt_seen 1
+ exp_continue
+ }
+ "@\[^\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
@@ -524,8 +553,12 @@ foreach router [lrange $argv $i end] {
if { "$cyphertype" == "" } { set cyphertype "3des" }
}
+ # Figure out connection method
+ set cmethod [find method $router]
+ if { "$cmethod" == "" } { set cmethod {{telnet} {ssh}} }
+
# Login to the router
- if {[login $router $ruser $userpswd $passwd $enapasswd $prompt $cyphertype]} {
+ if {[login $router $ruser $userpswd $passwd $enapasswd $prompt $cmethod $cyphertype]} {
continue
}
if { $enable } {
diff --git a/bin/francid.in b/bin/francid.in
index f494ea6..b03052e 100755
--- a/bin/francid.in
+++ b/bin/francid.in
@@ -1,7 +1,7 @@
#!@PERLV_PATH@
##
## Amazingly hacked version of Hank's rancid - this one tries to
-## deal with foundrys.
+## deal with foundrys and foundrys OEM'd by HP as Procurves.
##
## Copyright (C) 1997-2001 by Henry Kilmer.
## All rights reserved.
@@ -32,6 +32,8 @@ $clean_run = 0;
$found_end = 0;
$timeo = 90; # flogin timeout in seconds
+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)=(@_);
@@ -143,7 +145,7 @@ sub ShowVersion {
next if /^\s*$/;
last if(/^$prompt/);
- next if (/^The system /);
+ next if (/^(The system |Crash time)/);
s/^\s*(HW|SW)/$1/;
s/^\s*(Compiled on)/SW: $1/;
@@ -260,14 +262,15 @@ sub WriteTerm {
}
}
# order tacacs server statements
- /^(tacacs-server key )/ &&
- ProcessHistory("","","","! $1<removed>\n") && next;
- /^tacacs-server host (\d+\.\d+\.\d+\.\d+)/ &&
- ProcessHistory("TAC","ipsort","$1","$_") && next;
-
+ if (/^(tacacs-server key )/ && $filter_pwds >= 1) {
+ ProcessHistory("","","","! $1<removed>\n");
+ next;
+ }
# delete ntp auth password
- /^(ntp authentication-key \d+ md5) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
+ if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 2) {
+ ProcessHistory("","","","!$1 <removed>\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);
@@ -281,6 +284,19 @@ sub WriteTerm {
/^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 <removed>\n");
+ next;
+ }
+ # filter ssh private key
+ if (/^(crypto key generate (rsa|dsa) private_key)/ &&
+ $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\n");
+ next;
+ }
+
ProcessHistory("","","","$_");
# end of config
if (/^end$/) {
@@ -334,6 +350,15 @@ if ($file) {
}
}
+# 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: foundry\n!\n");
TOP: while(<INPUT>) {
tr/\015//d;
@@ -355,7 +380,7 @@ TOP: while(<INPUT>) {
}
print STDERR ("HIT COMMAND:$_") if ($debug);
if (! defined($commands{$cmd})) {
- print STDERR "found unexpected command - \"$cmd\"\n";
+ print STDERR "$host: found unexpected command - \"$cmd\"\n";
$clean_run = 0;
last TOP;
}
@@ -381,12 +406,12 @@ if (defined($ENV{NOPIPE})) {
# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
if (scalar(%commands)) {
- printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
- printf(STDERR "missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug);
+ 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 "End of run not found\n";
- print STDERR "End of run not found\n" if ($debug);
+ 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);
diff --git a/bin/hlogin.in b/bin/hlogin.in
index 66f8859..caabd31 100755
--- a/bin/hlogin.in
+++ b/bin/hlogin.in
@@ -287,18 +287,24 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
# try each of the connection methods in $cmethod until one is successful
set progs [llength $cmethod]
foreach prog [lrange $cmethod 0 end] {
- if ![string compare $prog "telnet"] {
- if [ catch {spawn telnet $router} reason ] {
+ if [string match "telnet*" $prog] {
+ regexp {telnet(:([^[:space:]]+))*} $prog command suffix port
+ if {"$port" == ""} {
+ set retval [ catch {spawn hpfilter telnet $router} reason ]
+ } else {
+ set retval [ catch {spawn hpfilter telnet $router $port} reason ]
+ }
+ if { $retval } {
send_user "\nError: telnet failed: $reason\n"
exit 1
}
} elseif ![string compare $prog "ssh"] {
- if [ catch {spawn ssh -c $cyphertype -x -l $user $router} reason ] {
+ if [ catch {spawn hpfilter ssh -c $cyphertype -x -l $user $router} reason ] {
send_user "\nError: ssh failed: $reason\n"
exit 1
}
} elseif ![string compare $prog "rsh"] {
- if [ catch {spawn rsh -l $user $router} reason ] {
+ if [ catch {spawn hpfilter rsh -l $user $router} reason ] {
send_user "\nError: rsh failed: $reason\n"
exit 1
}
@@ -364,7 +370,7 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
exp_continue }
-re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
- send_user "\nError: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n"
return 1 }
-re "$u_prompt" { send "$user\r"
expect {
@@ -500,21 +506,31 @@ proc run_commands { prompt command } {
}
-re "^<-+ More -+>\[^\n\r]*" { send " "
exp_continue }
+ -re "^-+ MORE -+\[^\n\r]*" { send " "
+ exp_continue }
-re "\b+" { exp_continue }
}
}
log_user 1
send "exit\r"
expect {
- "Do you want to log out" {
- send "y\r"
+ "Do you want to save current configuration" {
+ send "n\r"
exp_continue
}
"Do you wish to save " {
send "n\r"
exp_continue
}
- "\n" { exp_continue }
+ "Do you want to log out" {
+ send "y\r"
+ exp_continue
+ }
+ -re "\[\r\n]+" { exp_continue }
+ -re "^.+>" {
+ send "exit\r"
+ exp_continue
+ }
timeout { return 0 }
eof { return 0 }
}
@@ -632,15 +648,7 @@ foreach router [lrange $argv $i end] {
send "\r"
expect {
-re "\[\r\n]+" { exp_continue; }
- -re "^(.+:)1 $prompt" { # stoopid extreme cmd-line numbers and
- # prompt based on state of config changes
- set junk $expect_out(1,string)
- regsub -all "^\\\* " $expect_out(1,string) {} junk
- set prompt ".? ?$junk\[0-9]+ $prompt";
- set platform "extreme"
- }
-re "^.+$prompt" { set prompt $expect_out(0,string); }
- -re "^.+> \\\(enable\\\)" { set prompt $expect_out(0,string); }
}
if { $do_command } {
@@ -648,14 +656,8 @@ foreach router [lrange $argv $i end] {
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"
- }
+ # disable the pager
+ send "no page\r"
expect -re $prompt {}
source $sfile
close
diff --git a/bin/hpfilter.c b/bin/hpfilter.c
new file mode 100644
index 0000000..7c00997
--- /dev/null
+++ b/bin/hpfilter.c
@@ -0,0 +1,398 @@
+/*
+ * Copyright (C) 1997-2002 by Henry Kilmer, Erik Sherk and Pete Whiting.
+ * All rights reserved.
+ *
+ * This software may be freely copied, modified and redistributed without
+ * fee for non-commerical purposes provided that this copyright notice is
+ * preserved intact on all copies and modified copies.
+ *
+ * There is no warranty or other guarantee of fitness of this software.
+ * It is provided solely "as is". The author(s) disclaim(s) all
+ * responsibility and liability with respect to this software's usage
+ * or its effect upon hardware, computer systems, other software, or
+ * anything else.
+ *
+ *
+ * run telnet or ssh to connect to device specified on the command line. the
+ * point of hpfilter is to filter all the bloody vt100 (curses) escape codes
+ * that the HP procurve switches belch and make hlogin a real bitch.
+ */
+
+#define DFLT_TO 60 /* default timeout */
+
+#include <config.h>
+#include <version.h>
+
+#include <stdio.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <regex.h>
+
+#include <termios.h>
+
+char *progname;
+int debug = 0;
+
+int filter __P((char *, int));
+void usage __P((void));
+void vers __P((void));
+RETSIGTYPE reapchild __P((void));
+
+int
+main(int argc, char **argv)
+{
+ extern char *optarg;
+ extern int optind;
+ char ch,
+ hbuf[LINE_MAX * 2], /* hlogin buffer */
+ *hbufp,
+ tbuf[LINE_MAX * 2], /* telnet buffer */
+ *tbufp;
+ int bytes, /* bytes read/written */
+ child,
+ r[2], /* recv pipe */
+ s[2]; /* send pipe */
+ ssize_t hlen = 0, /* len of hbuf */
+ tlen = 0; /* len of tbuf */
+ struct timeval to = { DFLT_TO, 0 };
+ fd_set rfds, /* select() */
+ wfds;
+ struct termios tios;
+
+ /* 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 ((ch = getopt(argc, argv, "dhv")) != -1 )
+ switch (ch) {
+ case 'd':
+ debug++;
+ break;
+ case 'v':
+ vers();
+ return(EX_OK);
+ case 'h':
+ default:
+ usage();
+ return(EX_USAGE);
+ }
+
+ if (argc - optind != 2) {
+ usage();
+ return(EX_USAGE);
+ }
+
+ /* reap our children */
+ signal(SIGCHLD, (void *) reapchild);
+ signal(SIGHUP, (void *) reapchild);
+ signal(SIGINT, (void *) reapchild);
+ signal(SIGKILL, (void *) reapchild);
+ signal(SIGTERM, (void *) reapchild);
+
+ /* create 2 pipes for send/recv and then fork and exec telnet */
+ for (child = 3; child < 10; child++)
+ close(child);
+ if (pipe(s) || pipe(r)) {
+ fprintf(stderr, "%s: pipe() failed: %s\n", progname,
+ strerror(errno));
+ return(EX_TEMPFAIL);
+ }
+
+ /* if a tty, make it raw as the hp echos _everything_, including
+ * passwords.
+ */
+ if (isatty(0)) {
+ if (tcgetattr(0, &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(0, TCSANOW, &tios)) {
+ fprintf(stderr, "%s: tcsetattr() failed: %s\n", progname,
+ strerror(errno));
+ return(EX_OSERR);
+ }
+ }
+
+ if ((child = fork()) == -1) {
+ fprintf(stderr, "%s: fork() failed: %s\n", progname,
+ strerror(errno));
+ return(EX_TEMPFAIL);
+ }
+
+ /* zero the buffers */
+ bzero(hbuf, LINE_MAX * 2);
+ bzero(tbuf, LINE_MAX * 2);
+
+ if (child == 0) {
+ /* close the parent's side of the pipes; we write r[1], read s[0] */
+ close(s[1]);
+ close(r[0]);
+ /* close stdin/out/err and attach them to the pipes */
+ if (dup2(s[0], 0) == -1 || dup2(r[1], 1) == -1 || dup2(r[1], 2) == -1) {
+ fprintf(stderr, "%s: dup2() failed: %s\n", progname,
+ strerror(errno));
+ return(EX_OSERR);
+ }
+ close(s[0]);
+ close(r[1]);
+ /* exec telnet */
+ if (execvp(argv[optind], argv + optind)) {
+ fprintf(stderr, "%s: execlp() failed: %s\n", progname,
+ strerror(errno));
+ return(EX_TEMPFAIL);
+ }
+ /* not reached */
+ } else {
+ /* parent */
+ if (debug)
+ fprintf(stderr, "child %d\n", child);
+
+ /* close the child's side of the pipes; we write s[1], read r[0] */
+ close(s[0]);
+ close(r[1]);
+
+ /* make FDs non-blocking */
+ if (fcntl(s[1], F_SETFL, O_NONBLOCK) ||
+ fcntl(r[0], F_SETFL, O_NONBLOCK) ||
+ fcntl(0, F_SETFL, O_NONBLOCK) ||
+ fcntl(1, F_SETFL, O_NONBLOCK)) {
+ fprintf(stderr, "%s: fcntl(NONBLOCK) failed: %s\n", progname,
+ strerror(errno));
+ exit(EX_OSERR);
+ }
+
+ /* loop to read on stdin and r[0] */
+ FD_ZERO(&rfds); FD_ZERO(&wfds);
+ hbufp = hbuf; tbufp = tbuf;
+
+ while (1) {
+ FD_SET(0, &rfds); FD_SET(r[0], &rfds);
+ /* if we have stuff in our buffer(s), we select on writes too */
+ FD_ZERO(&wfds);
+ if (hlen) {
+ FD_SET(s[1], &wfds);
+ }
+ if (tlen) {
+ FD_SET(1, &wfds);
+ }
+
+ switch (select(r[1], &rfds, &wfds, NULL, &to)) {
+ case 0:
+ /* timeout */
+ /* HEAS: what do i do here? */
+ break;
+ case -1:
+ switch (errno) {
+ case EINTR: /* interrupted syscall */
+ break;
+ default:
+ exit(EX_IOERR);
+ }
+ break;
+ default:
+ /* check exceptions first */
+
+ /* which FD is ready? write our buffers asap. */
+ /* write hbuf (stdin) -> s[1] */
+ if (FD_ISSET(s[1], &wfds) && hlen) {
+ if ((hlen = write(s[1], hbuf, hlen)) < 0) {
+ fprintf(stderr, "%s: write() failed: %s\n", progname,
+ strerror(errno));
+ close(s[1]);
+ } else
+ strcpy(hbuf, hbuf + hlen);
+
+ hlen = strlen(hbuf);
+ }
+ /* write tbuf -> stdout */
+ if (FD_ISSET(1, &wfds) && tlen) {
+ /* if there is an escape char that didnt get filter()'d,
+ * we need to only write up to that point and wait for
+ * the bits that complete the escape sequence
+ */
+ if ((tbufp = index(tbuf, 0x1b)) != NULL)
+ tlen = tbufp - tbuf;
+
+ if ((tlen = write(1, tbuf, tlen)) < 0) {
+ fprintf(stderr, "%s: write() failed: %s\n", progname,
+ strerror(errno));
+ close(1);
+ } else
+ strcpy(tbuf, tbuf + tlen);
+
+ tlen = strlen(tbuf);
+ }
+ if (FD_ISSET(0, &rfds)) {
+ /* read stdin into hbuf */
+ if (LINE_MAX * 2 - hlen > 1) {
+ hlen += read(0, hbuf + hlen,
+ (LINE_MAX * 2 - 1) - hlen);
+ if (hlen > 0) {
+ hbuf[hlen] = '\0';
+ } else if (hlen == 0 || errno != EAGAIN)
+ /* EOF or read error */
+ close(0);
+
+ hlen = strlen(hbuf);
+ }
+ } else if (FD_ISSET(r[0], &rfds)) {
+ /* read telnet into tbuf, then filter */
+ if (LINE_MAX * 2 - tlen > 1) {
+ tlen += read(r[0], tbuf + tlen,
+ (LINE_MAX * 2 - 1) - tlen);
+ if (tlen > 0) {
+ tbuf[tlen] = '\0';
+ tlen = filter(tbuf, tlen);
+ } else if (tlen == 0 || errno != EAGAIN)
+ /* EOF or read error */
+ close(r[0]);
+
+ tlen = strlen(tbuf);
+ }
+ }
+
+ break;
+ }
+ }
+ /* close */
+ close(0);
+ close(1);
+ close(s[1]);
+ close(r[0]);
+
+ }
+
+ if (! kill(child, SIGQUIT))
+ reapchild();
+
+ return(EX_OK);
+}
+
+int
+filter(buf, len)
+ char *buf;
+ int len;
+{
+ static regmatch_t pmatch[1];
+#define N_REG 11 /* number of regexes in reg[][] */
+ static regex_t preg[N_REG];
+ static char reg[N_REG][50] = { /* vt100/220 escape codes */
+ "\e7\e\\[1;24r\e8", /* ds */
+ "\e8", /* fs */
+
+ "\e\\[2J",
+ "\e\\[2K", /* kE */
+
+ "\e\\[[0-9]+;[0-9]+r", /* cs */
+ "\e\\[[0-9]+;[0-9]+H", /* cm */
+
+ "\e\\[\\?6l",
+ "\e\\[\\?7l", /* RA */
+ "\e\\[\\?25h", /* ve */
+ "\e\\[\\?25l", /* vi */
+
+ "\eE", /* replace w/ CR */
+ };
+ char ebuf[256];
+ size_t nmatch = 1;
+ int err,
+ x;
+ static int init = 0;
+
+ if (index(buf, 0x1b) == 0 || len == 0)
+ return(len);
+
+ for (x = 0; x < N_REG - 1; x++) {
+ if (! init) {
+ 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();
+ }
+ }
+ 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 {
+ strcpy(buf + pmatch[0].rm_so, buf + pmatch[0].rm_eo);
+ x = 0;
+ }
+ }
+
+ /* replace \eE w/ CR NL */
+ if (! init++) {
+ if ((err = regcomp(&preg[N_REG - 1], reg[N_REG - 1], REG_EXTENDED))) {
+ regerror(err, &preg[N_REG - 1], ebuf, 256);
+ fprintf(stderr, "%s: regex compile failed: %s\n", progname,
+ ebuf);
+ abort();
+ }
+ }
+ while (1)
+ if ((err = regexec(&preg[N_REG - 1], buf, nmatch, pmatch, 0))) {
+ if (err != REG_NOMATCH) {
+ regerror(err, &preg[N_REG - 1], ebuf, 256);
+ fprintf(stderr, "%s: regexec failed: %s\n", progname, ebuf);
+ abort();
+ } else
+ break;
+ } else {
+ *(buf + pmatch[0].rm_so) = '\n';
+ strcpy(buf + pmatch[0].rm_so + 1, buf + pmatch[0].rm_eo);
+ x = 0;
+ }
+
+ return(strlen(buf));
+}
+
+RETSIGTYPE
+reapchild(void)
+{
+ int status;
+ pid_t pid;
+
+ /* HEAS: this needs to deal with/without wait3 via HAVE_WAIT3 */
+ while ((pid = wait3(&status, WNOHANG, 0)) > 0)
+ if (debug)
+ fprintf(stderr, "reap child %d\n", pid);
+
+ /*exit(1);*/
+return;
+
+ /* not reached */
+}
+
+void
+usage(void)
+{
+ fprintf(stderr,
+"usage: %s [-h] <telnet|ssh> <hostname>
+", progname);
+ return;
+}
+
+void
+vers(void)
+{
+ fprintf(stderr,
+"%s: %s version %s
+", progname, package, version);
+ return;
+}
diff --git a/bin/hrancid.in b/bin/hrancid.in
index a02ab81..d0bcc55 100755
--- a/bin/hrancid.in
+++ b/bin/hrancid.in
@@ -1,7 +1,7 @@
#!@PERLV_PATH@
##
## Amazingly hacked version of Hank's rancid - this one tries to
-## deal with HPs.
+## deal with HP procurves.
##
## Copyright (C) 1997-2001 by Henry Kilmer.
## All rights reserved.
@@ -29,9 +29,11 @@ $debug = $opt_d;
$file = $opt_f;
$host = $ARGV[0];
$clean_run = 0;
-$found_end = 0;
+$found_end = 0; # unused - hp lacks an end-of-config tag.
$timeo = 90; # clogin timeout in seconds
+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)=(@_);
@@ -141,142 +143,12 @@ sub ShowVersion {
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;
- /^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+)\s+\((\S+)\)\s+processor.*with (\S+K) bytes/) {
- my($proc) = $1;
- my($cpu) = $2;
- my($mem) = $3;
- my($device) = "router";
- if ( $1 eq "CSC") {
- $type = "AGS";
- } elsif ( $1 eq "CSC4") {
- $type = "AGS+";
- } elsif ( $1 eq "2511" || $1 eq "2524" || $1 eq "AS2511-RJ") {
- $type = "2500";
- } elsif ( $1 =~ /261[01]/ || $1 =~ /262[01]/ ) {
- $type = "2600";
- } elsif ( $1 eq "3620" || $1 eq "3640") {
- $type = "3600";
- } elsif ( $1 eq "RSP7000") {
- $type = "7500";
- } elsif ( $1 =~ /RSP\d/) {
- $type = "7500";
- } elsif ( $1 eq "RP1") {
- $type = "7000";
- } elsif ( $1 eq "RP") {
- $type = "7000";
- } elsif ( $1 =~ /720[246]/) {
- $type = "7200";
- } elsif ( $1 =~ /1200[48]\/GRP/ || $1 =~ /1201[26]\/GRP/) {
- $type = "12000";
- } elsif ( $1 =~ /1201[26]-8R\/GRP/) {
- $type = "12000";
- } elsif ( $1 =~ /WS-C29/) {
- $type = "2900XL";
- $device = "switch";
- } elsif ( $1 =~ /WS-C35/) {
- $type = "3500XL";
- $device = "switch";
- } elsif ( $1 =~ /6000/) {
- $type = "6000";
- $device = "switch";
- } else {
- $type = $1;
- }
- 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+K) bytes of multibus/ &&
- ProcessHistory("COMMENTS","keysort","B2",
- "!Memory: multibus $1\n") && next;
- /^(\d+K) bytes of non-volatile/ &&
- ProcessHistory("COMMENTS","keysort","B3",
- "!Memory: nvram $1\n") && next;
- /^(\d+K) bytes of flash memory/ &&
- ProcessHistory("COMMENTS","keysort","B5","!Memory: flash $1\n") &&
- next;
- /^(\d+K) bytes of .*flash partition/ &&
- ProcessHistory("COMMENTS","keysort","B6",
- "!Memory: flash partition $1\n") && next;
- /^(\d+K) bytes of Flash internal/ &&
- ProcessHistory("COMMENTS","keysort","B4",
- "!Memory: bootflash $1\n") && next;
- if(/^(\d+K) bytes of (Flash|ATA)?.*PCMCIA .*slot ?(\d)/i) {
- ProcessHistory("COMMENTS","keysort","B7",
- "!Memory: pcmcia $2 slot$3 $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.
- $_ = <INPUT>; tr/\015//d;
- ProcessHistory("COMMENTS","keysort","I1","! $_");
- }
- if (/^Configuration register is (.*)$/) {
- $config_register=$1;
- next;
- }
+ return(-1) if /^(Invalid|Ambiguous) input:/i;
+
+ s/^image//i;
+ s/^\s*//g;
+
+ ProcessHistory("COMMENTS","keysort","C1", ";Image: $_") && next;
}
return(0);
}
@@ -291,13 +163,13 @@ sub ShowFlash {
tr/\015//d;
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
- return(1) if ($type =~ /^(12[40]|7)/);
return(-1) if (/command authorization failed/i);
+ return(1) if /^(Invalid|Ambiguous) input:/i;
return(1) if /^\s*\^\s*$/;
- return(1) if /(Invalid input detected|Type help or )/;
- ProcessHistory("FLASH","","","!Flash: $_");
+
+ ProcessHistory("COMMENTS","keysort","D0",";Flash: $_");
}
- ProcessHistory("","","","!\n");
+
return;
}
@@ -309,50 +181,17 @@ sub ShowSystem {
tr/\015//d;
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
- # 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(-1) if /^(Invalid|Ambiguous) input:/i;
+
+ /memory\s+-\s+total\s+:\s+(\S+)/i &&
+ ProcessHistory("COMMENTS","keysort","B0",";Memory: $1\n");
+ /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");
}
return(0);
}
@@ -370,22 +209,9 @@ sub ShowModule {
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
return(-1) if (/command authorization failed/i);
+ return(1) if /^(Invalid|Ambiguous) input:/i;
- # match slot/card info line
- if (/^ *(\d+)\s+(\d+)\s+(.*)\s+(\S+)\s+(\S+)\s*$/) {
- $lines[$1] .= "!Slot $1: type $3, $2 ports\n!Slot $1: part $4, serial $5\n";
- $lines[$1] =~ s/\s+,/,/g;
- }
- # 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*$/) {
- $lines[$1] .= "!Slot $1: hvers $2, firmware $3, sw $4\n";
- $lines[$1] =~ s/\s+,/,/g;
- }
- }
- foreach $slot (@lines) {
- next if ($slot =~ /^\s*$/);
- ProcessHistory("Module","","","$slot!\n");
+ ProcessHistory("COMMENTS","keysort","E0","; $_") && next;
}
return(0);
@@ -400,25 +226,14 @@ sub ShowStack {
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
return(-1) if (/command authorization failed/i);
- /^$/ && next;
- 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:/) {
- $_ = <INPUT>;
- /revision\s+(\S+).*revision\s+(\S+)/ &&
- ProcessHistory("SLOT","","","!Slot CPU: hvers $1 rev $2\n");
- $_ = <INPUT>;
- /number\s+(\S+)\s+Part number\s+(\S+)/ &&
- ProcessHistory("SLOT","","","!Slot CPU: part $2, serial $1\n!\n");
- next;
- }
+ return(-1) if /^(Invalid|Ambiguous) input:/i;
+
+ s/stacking - (Stacking Status).*/$1/i;
+ s/\s*members unreachable .*$//i;
+
+ ProcessHistory("COMMENTS","keysort","F0",";$_");
+
+ /auto grab/i && last;
}
return(0);
}
@@ -433,65 +248,120 @@ sub WriteTerm {
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
+ s/^$/;/;
+
# skip the crap
- if (/^(##+$|Building 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;
+ /^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") &&
+ 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 <removed>\n");
+ next;
+ }
+
+ if (/^(snmp-server community) (\S+)/) {
+ if (defined($ENV{'NOCOMMSTR'})) {
+ ProcessHistory("SNMPSERVERCOMM","keysort","$_",
+ ";$1 <removed>$'") && next;
+ } else {
+ ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next;
}
- if (defined($config_register)) {
- ProcessHistory("","","","!\nconfig-register $config_register\n");
+ }
+ # 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 <community>
+ if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) {
+ if (defined($ENV{'NOCOMMSTR'})) {
+ 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(' ', ("<removed>", join(' ',@tokens)));
+ last;
+ }
+ }
+ ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n");
+ } else {
+ ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_");
}
- tr/\015//d;
+ next;
}
- # some versions have other crap mixed in with the bits in the
- # block above
- /^! (Last configuration|NVRAM config last)/ && next;
- # Dog gone Cool matches to process the rest of the config
+ # order/prune tacacs/radius server statements
+ if (/^(tacacs-server|radius-server) key / && $filter_pwds >= 1) {
+ ProcessHistory("","","",";$1 key <removed>\n");
+ next;
+ }
+ if (/^(tacacs-server host \d+\.\S+) key / && $filter_pwds >= 1) {
+ ProcessHistory("","","",";$1 key <removed>\n");
+ next;
+ }
+
+ # prune passwords from stack member statements
+ if (/^(stack member .* password )\S+/ && $filter_pwds >= 1) {
+ ProcessHistory("","","",";$1<removed>$'");
+ next;
+ }
+
+ # order arp lists
+ /^ip arp\s+(\d+\.\d+\.\d+\.\d+)/ &&
+ ProcessHistory("ARP","ipsort","$1","$_") && next;
+
+ /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ &&
+ ProcessHistory("PACL $1 $3","ipsort","$4","ip prefix-list $1 $3 $4$5\n")
+ && next;
+
+ # blech!!!!
+ /^auto-tftp / &&
+ ProcessHistory("","","",";$_") && next;
+
+
+ # the rest are from rancid (ie: 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
- /^ clockrate / && next; # kill clockrate on serial interfaces
- /^(enable )?(password|passwd) / &&
- ProcessHistory("ENABLE","","","!$1$2 <removed>\n") &&
+ if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) {
+ ProcessHistory("ENABLE","","",";$1$2 <removed>\n");
next;
- /^username (\S+)(\s.*)? password /&&
- ProcessHistory("USER","keysort","$1","!username $1$2 password <removed>\n") && next;
- /^\s*password / &&
- ProcessHistory("LINE-PASS","","","! password <removed>\n") && next;
- /^\s*neighbor (\S*) password / &&
- ProcessHistory("","","","! neighbor $1 password <removed>\n") &&
- next;
- /^(ip ftp password) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
- /^( ip ospf authentication-key) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
- /^( ip ospf message-digest-key \d+ md5) / &&
- ProcessHistory("","","","!$1 <removed>\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 .= $_;
- }
+ }
+ if (/^username (\S+)(\s.*)? password /) {
+ if ($filter_pwds >= 1) {
+ ProcessHistory("USER","keysort","$1",";username $1$2 password <removed>\n");
+ } else {
+ ProcessHistory("USER","keysort","$1","$_");
}
- ProcessHistory("EXPATH","keysort","$key","$expath");
+ next;
+ }
+
+ if (/^(ip ftp password) / && $filter_pwds >= 1) {
+ ProcessHistory("","","",";$1 <removed>\n"); next;
+ }
+ if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) {
+ ProcessHistory("","","",";$1 <removed>\n"); next;
+ }
+ if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) {
+ ProcessHistory("","","",";$1 <removed>\n"); next;
}
# sort route-maps
if (/^route-map (\S+)/) {
@@ -510,8 +380,6 @@ sub WriteTerm {
}
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","ipsort","$3","$_") && next;
@@ -522,58 +390,13 @@ sub WriteTerm {
ProcessHistory("EACL $1 $2","ipsort","$3","$_") && next;
/^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ &&
ProcessHistory("EACL $1 $2","ipsort","0.0.0.0","$_") && next;
- # order arp lists
- /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ &&
- ProcessHistory("ARP","ipsort","$1","$_") && next;
- /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ &&
- ProcessHistory("PACL $1 $3","ipsort","$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 <community>
- if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) {
- if (defined($ENV{'NOCOMMSTR'})) {
- 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(' ', ("<removed>", 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 <removed>$'") && next;
- } else {
- ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next;
- }
- }
- # order/prune tacacs/radius server statements
- /^(tacacs-server|radius-server) key / &&
- ProcessHistory("","","","!$1 key <removed>\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
- /^(ntp authentication-key \d+ md5) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
+ if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) {
+ ProcessHistory("","","",";$1 <removed>\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);
@@ -586,28 +409,11 @@ sub WriteTerm {
# 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 <removed>\n") &&
- next;
- /^syscon password (\S*)/ &&
- ProcessHistory("","","","!syscon password <removed>\n") &&
- next;
-
# catch anything that wasnt match above.
ProcessHistory("","","","$_");
- # end of config
- #if (/^end(\n\[OK])?$/) {
- if (/^(: )?end$/) {
- $found_end = 1;
- return(1);
- }
}
return(0);
}
@@ -657,13 +463,25 @@ if ($file) {
}
}
-ProcessHistory("","","","!RANCID-CONTENT-TYPE: hp\n!\n");
-ProcessHistory("COMMENTS","keysort","B0","!\n");
-ProcessHistory("COMMENTS","keysort","F0","!\n");
-ProcessHistory("COMMENTS","keysort","G0","!\n");
+# 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-procurve\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");
TOP: while(<INPUT>) {
tr/\015//d;
- if (/\#\s?exit$/) {
+ if (/$prompt\s*exit\s*$/i) {
$clean_run=1;
last;
}
@@ -675,10 +493,11 @@ TOP: while(<INPUT>) {
}
while (/#\s*($cmds_regexp)\s*$/) {
$cmd = $1;
- if (!defined($prompt)) {$prompt = ($_ =~ /^([^#]+#)/)[0]; }
+ if (!defined($prompt)) {$prompt = ($_ =~ /^([^#]+)/)[0];
+ $prompt .= "[#>]"; }
print STDERR ("HIT COMMAND:$_") if ($debug);
if (! defined($commands{$cmd})) {
- print STDERR "found unexpected command - \"$cmd\"\n";
+ print STDERR "$host: found unexpected command - \"$cmd\"\n";
$clean_run = 0;
last TOP;
}
@@ -702,14 +521,14 @@ if (defined($ENV{NOPIPE})) {
}
# check for completeness
-if (scalar(%commands) || !$clean_run || !$found_end) {
+if (scalar(%commands) || !$clean_run) {
if (scalar(%commands)) {
- printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
- printf(STDERR "missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug);
+ 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 "End of run not found\n";
- print STDERR "End of run not found\n" if ($debug);
+ if (!$clean_run) {
+ 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);
diff --git a/bin/jlogin.in b/bin/jlogin.in
index 6081365..2b10558 100755
--- a/bin/jlogin.in
+++ b/bin/jlogin.in
@@ -254,8 +254,14 @@ proc login { router user passwd cmethod cyphertype identfile} {
# try each of the connection methods in $cmethod until one is successful
set progs [llength $cmethod]
foreach prog [lrange $cmethod 0 end] {
- if ![string compare $prog "telnet"] {
- if [ catch {spawn telnet $router} reason ] {
+ if [string match "telnet*" $prog] {
+ regexp {telnet(:([^[:space:]]+))*} $prog command suffix port
+ if {"$port" == ""} {
+ set retval [ catch {spawn telnet $router} reason ]
+ } else {
+ set retval [ catch {spawn telnet $router $port} reason ]
+ }
+ if { $retval } {
send_user "\nError: telnet failed: $reason\n"
exit 1
}
@@ -342,26 +348,18 @@ proc login { router user passwd cmethod cyphertype identfile} {
exp_continue }
-re "HOST IDENTIFICATION HAS CHANGED.* \(yes\/no\)\?" {
send "no\r"
- send_user "\nError: The host key for $router has changed. update the known_hosts file accordingly.\n"
+ send_user "\nError: The host key for $router has changed. Update the SSH known_hosts file accordingly.\n"
return 1 }
- -re "(Username|\[\r\n]login):" { send "$user\r"
- expect {
- eof { send_user "\nError: Couldn't login\n";
- wait; return 1 }
- -re "\[Pp]assword:" { sleep 1; send "$passwd\r" }
- -re "$prompt" { break; }
- }
- exp_continue
- }
- "\[Pp]assword:" { sleep 1; send "$passwd\r"
- expect {
- eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
- -re "$prompt" { break; }
- }
- exp_continue
- }
- -re "$prompt" { break; }
- denied { send_user "\nError: Check your passwd for $router\n"
+ -re "(Username|\[\r\n]login):" {
+ send "$user\r"
+ exp_continue
+ }
+ "\[Pp]assword:" {
+ sleep 1; send "$passwd\r"
+ exp_continue
+ }
+ -re "$prompt" { break; }
+ denied { send_user "\nError: Check your password for $router\n"
if { $do_command || $do_script } {
send "quit"
wait
@@ -370,9 +368,8 @@ proc login { router user passwd cmethod cyphertype identfile} {
return 1
}
}
- "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
+ }
}
- }
# we are logged in, now figure out the full prompt
send "\r"
@@ -452,17 +449,13 @@ foreach router [lrange $argv $i end] {
# command line passwd
set passwd $userpasswd
} else {
- set userpswd [lindex [find userpassword $loginname@$router] 0]
- if { "$userpswd" == "" } {
- set userpswd [lindex [find userpassword $router] 0]
- }
- if { "$userpswd" == "" } {
- set passwd [lindex [find password $loginname@$router] 0]
+ set passwd [lindex [find userpassword $router] 0]
+ if { "$passwd" == "" } {
+ set passwd [lindex [find password $router] 0]
if { "$passwd" == "" } {
- set passwd [lindex [find password $router] 0]
+ send_user "Error: no password for $router in $password_file.\n"
+ continue
}
- } else {
- set passwd $userpswd
}
}
diff --git a/bin/jrancid.in b/bin/jrancid.in
index b75c8e7..4eb6ee3 100755
--- a/bin/jrancid.in
+++ b/bin/jrancid.in
@@ -32,6 +32,8 @@ $host = $ARGV[0];
$clean_run = 0;
$found_end = 0;
+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)=(@_);
@@ -354,6 +356,7 @@ sub ShowVersion {
# This routine parses "show configuration"
sub ShowConfiguration {
my($lines) = 0;
+ my($snmp) = 0;
print STDERR " In ShowConfiguration: $_" if ($debug);
s/^[a-z]+@//;
@@ -371,19 +374,35 @@ sub ShowConfiguration {
/^database header mismatch: / && return(-1);
/^version .*;\d+$/ && return(-1);
- if (/^(\s*)(community |trap-group )[^ ;]+(\s?[;{])$/) {
+
+ # filter snmp community, when in snmp { stanza }
+ /^snmp/ && $snmp++;
+ /^}/ && ($snmp = 0);
+ if ($snmp && /^(\s*)(community|trap-group) [^ ;]+(\s?[;{])$/) {
if (defined($ENV{'NOCOMMSTR'})) {
- $_ = "$1$2\"<removed>\"$3\n";
+ $_ = "$1$2 \"<removed>\"$3\n";
}
}
- s/(\s*authentication-key ).*$/#$1<removed>;/;
- s/^(.*\ssecret \")\$9\$.*(\".*)$/#$1<removed>$2/;
+ if (/(\s*authentication-key ).*$/ && $filter_pwds >= 1) {
+ s/(\s*authentication-key ).*$/#$1<removed>;/;
+ }
+ if (/^(.*\ssecret \")\$9\$.*(\".*)$/ && $filter_pwds >= 1) {
+ s/^(.*\ssecret \")\$9\$.*(\".*)$/#$1<removed>$2/;
+ }
+ if (/(\s+encrypted-password ).*$/ && $filter_pwds >= 2) {
+ ProcessHistory("","","","#$1<removed>;\n");
+ next;
+ }
+ if (/(\s+ssh-(rsa|dsa) )\"/ && $filter_pwds >= 2) {
+ ProcessHistory("","","","#$1<removed>;\n");
+ next;
+ }
s/ # SECRET-DATA$//;
ProcessHistory("","","","$_");
}
if ($lines < 3) {
- printf(STDERR "ERROR: configuration appears truncated.\n");
+ printf(STDERR "ERROR: $host configuration appears truncated.\n");
$found_end = 0;
return(-1);
}
@@ -455,6 +474,15 @@ if ($file) {
}
+# 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: juniper\n#\n");
TOP: while(<INPUT>) {
tr/\015//d;
@@ -484,7 +512,7 @@ TOP: while(<INPUT>) {
}
print STDERR ("HIT COMMAND:$_") if ($debug);
if (! defined($commands{$cmd})) {
- print STDERR "found unexpected command - \"$cmd\"\n";
+ print STDERR "$host: found unexpected command - \"$cmd\"\n";
$clean_run = 0;
last TOP;
}
@@ -515,12 +543,12 @@ if (defined($ENV{NOPIPE})) {
$commands = join(", ", keys(%commands));
if (scalar(%commands) || !$clean_run || !$found_end) {
if (scalar(%commands)) {
- printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
- printf(STDERR "missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug);
+ 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 "End of run not found\n";
- print STDERR "End of run not found\n" if ($debug);
+ 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);
diff --git a/bin/mrancid.in b/bin/mrancid.in
new file mode 100755
index 0000000..8054917
--- /dev/null
+++ b/bin/mrancid.in
@@ -0,0 +1,397 @@
+#!@PERLV_PATH@
+##
+## Amazingly hacked version of Hank's rancid - this one tries to
+## deal with MRTd.
+##
+## Copyright (C) 1997-2001 by Henry Kilmer.
+## All rights reserved.
+##
+## This software may be freely copied, modified and redistributed without
+## fee for non-commerical purposes provided that this copyright notice is
+## preserved intact on all copies and modified copies.
+##
+## There is no warranty or other guarantee of fitness of this software.
+## It is provided solely "as is". The author(s) disclaim(s) all
+## responsibility and liability with respect to this software's usage
+## or its effect upon hardware, computer systems, other software, or
+## anything else.
+##
+##
+#
+# RANCID - Really Awesome New Cisco confIg Differ
+#
+# usage: rancid [-d] [-l] [-f filename | $host]
+#
+use Getopt::Std;
+getopts('dflm');
+$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(%filter_pwds); # password filtering mode
+
+# This routine is used to print out the router configuration
+sub ProcessHistory {
+ my($new_hist_tag,$new_command,$command_string,@string)=(@_);
+ if((($new_hist_tag ne $hist_tag) || ($new_command ne $command))
+ && defined %history) {
+ 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 (<INPUT>) {
+ 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 (<INPUT>) {
+ 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 <removed>\n");
+ next;
+ }
+ if (/^username (\S+)(\s.*)? password /) {
+ if ($filter_pwds >= 1) {
+ ProcessHistory("USER","keysort","$1","!username $1$2 password <removed>\n");
+ } else {
+ ProcessHistory("USER","keysort","$1","$_");
+ }
+ next;
+ }
+ if (/^(\s*)password / && $filter_pwds >= 1) {
+ ProcessHistory("LINE-PASS","","","!$1password <removed>\n"); next;
+ }
+ if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) {
+ ProcessHistory("","","","! neighbor $1 password <removed>\n");
+ next;
+ }
+
+ if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\n"); next;
+ }
+ if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\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");
+ }
+
+ # catch anything that wasnt match above.
+ ProcessHistory("","","","$_");
+
+
+ next;
+ # order access-lists
+ /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ &&
+ ProcessHistory("ACL $1 $2","ipsort","$3","$_") && next;
+ # order extended access-lists
+ /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+host\s+(\S+)/ &&
+ ProcessHistory("EACL $1 $2","ipsort","$3","$_") && next;
+ /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+(\d\S+)/ &&
+ ProcessHistory("EACL $1 $2","ipsort","$3","$_") && next;
+ /^access-list\s+(\d\d\d)\s+(\S+)\s+ip\s+any/ &&
+ ProcessHistory("EACL $1 $2","ipsort","0.0.0.0","$_") && next;
+ # order arp lists
+ /^arp\s+(\d+\.\d+\.\d+\.\d+)\s+/ &&
+ ProcessHistory("ARP","ipsort","$1","$_") && next;
+ /^ip prefix-list\s+(\S+)\s+seq\s+(\d+)\s+(permit|deny)\s+(\d\S+)(\/.*)$/ &&
+ ProcessHistory("PACL $1 $3","ipsort","$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 <community>
+ if (/^snmp-server host (\d+\.\d+\.\d+\.\d+) /) {
+ if (defined($ENV{'NOCOMMSTR'})) {
+ 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(' ', ("<removed>", 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 <removed>$'") && 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(\n\[OK])?$/) {
+ if (/^(: )?end$/) {
+ $found_end = 1;
+ return(1);
+ }
+ }
+ return(0);
+}
+
+# dummy function
+sub DoNothing {print STDOUT;}
+
+# Main
+%commands=(
+ 'show version' => "ShowVersion",
+ 'show config' => "WriteTerm"
+);
+# keys() doesnt return things in the order entered and the order of the
+# cmds is important (show version first and write term last). pita
+@commands=(
+ "show version",
+ "show config"
+);
+$cisco_cmds=join(";",@commands);
+$cmds_regexp=join("|",@commands);
+
+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);
+ print STDOUT "opening file $host\n" if ($log);
+ open(INPUT,"<$host") || die "open failed for $host: $!\n";
+} else {
+ print STDERR "executing clogin -t $timeo -c\"$cisco_cmds\" $host\n" if ($debug);
+ print STDOUT "executing clogin -t $timeo -c\"$cisco_cmds\" $host\n" if ($log);
+ if (defined($ENV{NOPIPE})) {
+ system "clogin -t $timeo -c \"$cisco_cmds\" $host </dev/null > $host.raw 2>&1" || die "clogin failed for $host: $!\n";
+ open(INPUT, "< $host.raw") || die "clogin failed for $host: $!\n";
+ } else {
+ open(INPUT,"clogin -t $timeo -c \"$cisco_cmds\" $host </dev/null |") || die "clogin failed for $host: $!\n";
+ }
+}
+
+# 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(<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 .= "[#>]"; }
+ 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}};
+ 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);
+
+if (defined($ENV{NOPIPE})) {
+ unlink("$host.raw") if (! $debug);
+}
+
+# check for completeness
+if (scalar(%commands) || !$clean_run) {
+ if (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) {
+ 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);
+}
diff --git a/bin/rancid-fe.in b/bin/rancid-fe.in
index a09d937..98f2ebc 100755
--- a/bin/rancid-fe.in
+++ b/bin/rancid-fe.in
@@ -25,27 +25,21 @@ require 5;
($router, $vendor) = split('\:', $ARGV[0]);
-if ($vendor =~ /^baynet$/i) {
- exec('brancid', $router);
-} elsif ($vendor =~ /^cisco$/i) {
- exec('rancid', $router);
-} elsif ($vendor =~ /^cat5$/i) {
- exec('cat5rancid', $router);
-} elsif ($vendor =~ /^ezt3$/i) {
- exec('erancid', $router);
-} elsif ($vendor =~ /^hp$/i) {
- exec('hrancid', $router);
-} elsif ($vendor =~ /^juniper$/i) {
- exec('jrancid', $router);
-} elsif ($vendor =~ /^foundry$/i) {
- exec('francid', $router);
-} elsif ($vendor =~ /^redback$/i) {
- exec('rrancid', $router);
-} elsif ($vendor =~ /^alteon$/i) {
- exec('arancid', $router);
-} elsif ($vendor =~ /^extreme$/i) {
- exec('xrancid', $router);
+ if ($vendor =~ /^alteon$/i) { exec('arancid', $router); }
+elsif ($vendor =~ /^baynet$/i) { exec('brancid', $router); }
+elsif ($vendor =~ /^cat5$/i) { exec('cat5rancid', $router); }
+elsif ($vendor =~ /^cisco$/i) { exec('rancid', $router); }
+elsif ($vendor =~ /^extreme$/i) { exec('xrancid', $router); }
+elsif ($vendor =~ /^ezt3$/i) { exec('erancid', $router); }
+elsif ($vendor =~ /^foundry$/i) { exec('francid', $router); }
+elsif ($vendor =~ /^hp$/i) { exec('hrancid', $router); }
+elsif ($vendor =~ /^juniper$/i) { exec('jrancid', $router); }
+elsif ($vendor =~ /^mrtd$/i) { exec('mrancid', $router); }
+elsif ($vendor =~ /^redback$/i) { exec('rrancid', $router); }
+else {
+ printf(STDERR "unknown router manufacturer for $router: $vendor\n");
+ exit(-1);
}
-printf(STDERR "unknown router manufacturer for $router: $vendor\n");
+printf(STDERR "exec failed router manufacturer $vendor: $!\n");
exit(-1);
diff --git a/bin/rancid.in b/bin/rancid.in
index 811cf37..0948cca 100755
--- a/bin/rancid.in
+++ b/bin/rancid.in
@@ -30,6 +30,8 @@ $clean_run = 0;
$found_end = 0;
$timeo = 90; # clogin timeout in seconds
+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)=(@_);
@@ -136,6 +138,7 @@ sub ShowVersion {
while (<INPUT>) {
tr/\015//d;
+ study;
last if(/^$prompt/);
next if(/^(\s*|\s*$cmd\s*)$/);
return(-1) if (/command authorization failed/i);
@@ -175,6 +178,8 @@ sub ShowVersion {
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'
@@ -183,7 +188,7 @@ sub ShowVersion {
next;
/^System image file is "([^\"]*)"$/ &&
ProcessHistory("COMMENTS","keysort","F5","!Image: $1\n") && next;
- if (/(\S+)\s+\((\S+)\)\s+processor.*with (\S+K) bytes/) {
+ if (/(\S+)\s+\((\S+)\)\s+processor.*with (\S+[kK]) bytes/) {
my($proc) = $1;
my($cpu) = $2;
my($mem) = $3;
@@ -241,24 +246,24 @@ sub ShowVersion {
$sspmem = $1;
next;
}
- /^(\d+K) bytes of multibus/ &&
+ /^(\d+[kK]) bytes of multibus/ &&
ProcessHistory("COMMENTS","keysort","B2",
"!Memory: multibus $1\n") && next;
- /^(\d+K) bytes of non-volatile/ &&
+ /^(\d+[kK]) bytes of non-volatile/ &&
ProcessHistory("COMMENTS","keysort","B3",
"!Memory: nvram $1\n") && next;
- /^(\d+K) bytes of flash memory/ &&
+ /^(\d+[kK]) bytes of flash memory/ &&
ProcessHistory("COMMENTS","keysort","B5","!Memory: flash $1\n") &&
next;
- /^(\d+K) bytes of .*flash partition/ &&
+ /^(\d+[kK]) bytes of .*flash partition/ &&
ProcessHistory("COMMENTS","keysort","B6",
"!Memory: flash partition $1\n") && next;
- /^(\d+K) bytes of Flash internal/ &&
+ /^(\d+[kK]) bytes of Flash internal/ &&
ProcessHistory("COMMENTS","keysort","B4",
"!Memory: bootflash $1\n") && next;
- if(/^(\d+K) bytes of (Flash|ATA)?.*PCMCIA .*slot ?(\d)/i) {
+ if(/^(\d+[kK]) bytes of (Flash|ATA)?.*PCMCIA .*(slot|disk) ?(\d)/i) {
ProcessHistory("COMMENTS","keysort","B7",
- "!Memory: pcmcia $2 slot$3 $1\n");
+ "!Memory: pcmcia $2 $3$4 $1\n");
next;
}
if(/^WARNING/) {
@@ -320,10 +325,12 @@ sub ShowEnv {
"!Chassis type: $2 backplane\n");
next;
}
- /^\s*(Power .*)/ &&
+ /^\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;
}
ProcessHistory("COMMENTS","","","!\n");
return(0);
@@ -451,6 +458,7 @@ sub ShowContAll {
while (<INPUT>) {
tr/\015//d;
+ study;
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
# return(1) if ($type =~ /^(12[40]|7[05])/);
@@ -554,6 +562,7 @@ sub ShowDiagbus {
while (<INPUT>) {
tr/\015//d;
+ study;
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
#return(1) if ($type !~ /^7[05]/);
@@ -640,6 +649,7 @@ sub ShowDiag {
while (<INPUT>) {
tr/\015//d;
+ study;
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
# return(1) if ($type !~ /^(12[40]|720|36|26)/);
@@ -753,7 +763,7 @@ sub ShowModule {
}
# 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*$/) {
+ if (/^ *(\d+)\s+\S+\s+to\s+\S+\s+(\S+)\s+(\S*)\s+(\S+)(\s+\S+)?\s*$/) {
$lines[$1] .= "!Slot $1: hvers $2, firmware $3, sw $4\n";
$lines[$1] =~ s/\s+,/,/g;
}
@@ -848,13 +858,14 @@ sub WriteTerm {
while (<INPUT>) {
tr/\015//d;
+ study;
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
# skip the crap
- if (/^(##+$|Building configuration...)/i) {
+ if (/^(##+$|(Building|Current) configuration)/i) {
while (<INPUT>) {
next if (/^Current configuration\s*:/i);
next if (/^:/);
@@ -877,24 +888,58 @@ sub WriteTerm {
/^ length / && next; # kill length on serial lines
/^ width / && next; # kill width on serial lines
/^ clockrate / && next; # kill clockrate on serial interfaces
- /^(enable )?(password|passwd) / &&
- ProcessHistory("ENABLE","","","!$1$2 <removed>\n") &&
+ if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) {
+ ProcessHistory("ENABLE","","","!$1$2 <removed>\n");
+ next;
+ }
+ if (/^(enable secret) / && $filter_pwds >= 2) {
+ ProcessHistory("ENABLE","","","!$1 <removed>\n");
+ next;
+ }
+ if (/^username (\S+)(\s.*)? secret /) {
+ if ($filter_pwds >= 2) {
+ ProcessHistory("USER","keysort","$1","!username $1$2 secret <removed>\n");
+ } else {
+ ProcessHistory("USER","keysort","$1","$_");
+ }
+ next;
+ }
+ if (/^username (\S+)(\s.*)? password /) {
+ if ($filter_pwds >= 1) {
+ ProcessHistory("USER","keysort","$1","!username $1$2 password <removed>\n");
+ } else {
+ ProcessHistory("USER","keysort","$1","$_");
+ }
+ next;
+ }
+ if (/^(\s*)password / && $filter_pwds >= 1) {
+ ProcessHistory("LINE-PASS","","","!$1password <removed>\n");
next;
- /^username (\S+)(\s.*)? password /&&
- ProcessHistory("USER","keysort","$1","!username $1$2 password <removed>\n") && next;
- /^\s*password / &&
- ProcessHistory("LINE-PASS","","","! password <removed>\n") && next;
- /^\s*neighbor (\S*) password / &&
- ProcessHistory("","","","! neighbor $1 password <removed>\n") &&
+ }
+ if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) {
+ ProcessHistory("","","","! neighbor $1 password <removed>\n");
next;
- /^(ppp .* password) 7 .*/ &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
- /^(ip ftp password) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
- /^( ip ospf authentication-key) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
- /^( ip ospf message-digest-key \d+ md5) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
+ }
+ if (/^(ppp .* password) 7 .*/ && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\n"); next;
+ }
+ if (/^(ip ftp password) / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\n"); next;
+ }
+ if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\n"); next;
+ }
+ # this is reversable, despite 'md5' in the cmd
+ if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\n"); next;
+ }
+ if (/^((crypto )?isakmp key) \S+ / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed> $'"); next;
+ }
+ # i am told these are plain-text on the PIX
+ if (/^(vpdn username \S+ password)/ && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\n"); next;
+ }
/fair-queue individual-limit/ && next;
# sort ip explicit-paths.
if (/^ip explicit-path name (\S+)/) {
@@ -985,16 +1030,18 @@ sub WriteTerm {
}
}
# order/prune tacacs/radius server statements
- /^(tacacs-server|radius-server) key / &&
- ProcessHistory("","","","!$1 key <removed>\n") && next;
+ if (/^(tacacs-server|radius-server) key / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 key <removed>\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
- /^(ntp authentication-key \d+ md5) / &&
- ProcessHistory("","","","!$1 <removed>\n") && next;
+ # delete ntp auth password - this md5 is a reversable too
+ if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\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);
@@ -1017,15 +1064,15 @@ sub WriteTerm {
/^syscon address (\S*) (\S*)/ &&
ProcessHistory("","","","!syscon address $1 <removed>\n") &&
next;
- /^syscon password (\S*)/ &&
- ProcessHistory("","","","!syscon password <removed>\n") &&
+ if (/^syscon password (\S*)/ && $filter_pwds >= 1) {
+ ProcessHistory("","","","!syscon password <removed>\n");
next;
+ }
- # catch anything that wasnt match above.
+ # catch anything that wasnt matched above.
ProcessHistory("","","","$_");
- # end of config
- #if (/^end(\n\[OK])?$/) {
- if (/^(: )?end$/) {
+ # end of config. the ": " game is for the PIX
+ if (/^(: +)?end$/) {
$found_end = 1;
return(1);
}
@@ -1052,6 +1099,8 @@ sub DoNothing {print STDOUT;}
'dir /all disk0:' => "DirSlotN",
'dir /all slot1:' => "DirSlotN",
'dir /all disk1:' => "DirSlotN",
+ "dir /all sup-bootflash:"=> "DirSlotN", # cat 6500-ios
+ "dir /all sup-microcode:"=> "DirSlotN", # cat 6500-ios
'show controllers' => "ShowContAll",
'show controllers cbus' => "ShowContCbus",
'show diagbus' => "ShowDiagbus",
@@ -1079,6 +1128,8 @@ sub DoNothing {print STDOUT;}
"dir /all disk0:",
"dir /all slot1:",
"dir /all disk1:",
+ "dir /all sup-bootflash:",
+ "dir /all sup-microcode:",
"show controllers",
"show controllers cbus",
"show diagbus",
@@ -1112,6 +1163,15 @@ if ($file) {
}
}
+# 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: cisco\n!\n");
ProcessHistory("COMMENTS","keysort","B0","!\n");
ProcessHistory("COMMENTS","keysort","F0","!\n");
@@ -1133,7 +1193,7 @@ TOP: while(<INPUT>) {
if (!defined($prompt)) {$prompt = ($_ =~ /^([^#]+#)/)[0]; }
print STDERR ("HIT COMMAND:$_") if ($debug);
if (! defined($commands{$cmd})) {
- print STDERR "found unexpected command - \"$cmd\"\n";
+ print STDERR "$host: found unexpected command - \"$cmd\"\n";
$clean_run = 0;
last TOP;
}
@@ -1159,12 +1219,12 @@ if (defined($ENV{NOPIPE})) {
# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
if (scalar(%commands)) {
- printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
- printf(STDERR "missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug);
+ 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 "End of run not found\n";
- print STDERR "End of run not found\n" if ($debug);
+ 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);
diff --git a/bin/rrancid.in b/bin/rrancid.in
index ab196c2..f242ec4 100755
--- a/bin/rrancid.in
+++ b/bin/rrancid.in
@@ -31,6 +31,8 @@ $clean_run = 0;
$found_end = 0;
$timeo = 90; # clogin timeout in seconds
+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)=(@_);
@@ -131,6 +133,21 @@ sub sortbyipaddr {
&ipaddrval($a) <=> &ipaddrval($b);
}
+# This routine parses "show version"
+sub ShowVersion {
+ print STDERR " In ShowVersion: $_" if ($debug);
+
+ while (<INPUT>) {
+ 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 /<fsys>"
sub DirFlash {
print STDERR " In DirFlash: $_" if ($debug);
@@ -142,6 +159,7 @@ sub DirFlash {
/^\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");
@@ -157,6 +175,10 @@ sub ShowHardware {
last if(/^$prompt/);
s/\s*$/\n/;
+ /Can not retrieve information/ && return;
+ /^Temperature:/ && next;
+ /^Voltage/ && next;
+ /^$/ && next;
#ProcessHistory("","","","!Chassis: $_") && next;
ProcessHistory("COMMENTS","keysort","B1","!Chassis: $_");
}
@@ -164,17 +186,19 @@ sub ShowHardware {
return;
}
-# This routine parses "show version"
-sub ShowVersion {
- print STDERR " In ShowVersion: $_" if ($debug);
+# This routine parses "show chassis"
+sub ShowChassis {
+ print STDERR " In ShowChassis: $_" if ($debug);
while (<INPUT>) {
tr/\015//d;
last if(/^$prompt/);
+ last if(/^invalid input at/i);
+ next if(/^(\s*|\s*$cmd\s*|\s+\^)$/);
- /(uptime|restarted|^\s*$)/ && next;
- ProcessHistory("COMMENTS","keysort","A1","!Image: $_");
+ ProcessHistory("COMMENTS","keysort","C1","!Chassis: $_");
}
+ ProcessHistory("COMMENTS","keysort","C1","!\n");
return;
}
@@ -187,6 +211,8 @@ sub ShowSlotTable {
last if(/^$prompt/);
/(Slot Table|^$)/ && next;
+ /^\s+\^/ && next;
+ /Invalid input at/ && return;
s/^\s*//;
ProcessHistory("COMMENTS","keysort","D1","!Slot Table: $_");
}
@@ -201,21 +227,25 @@ sub WriteTerm {
while (<INPUT>) {
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","ipsort","$3","$_") && next;
+ ProcessHistory("ACL $1 $2","ipsort","$3","$_") && next;
# prune snmp community statements
if (/^snmp (group|community) (\S+)/) {
if (defined($ENV{'NOCOMMSTR'})) {
- ProcessHistory("SNMPSERVERCOMM","keysort","$_","!snmp $1 <removed>$'") && next;
+ ProcessHistory("SNMPSERVERCOMM","keysort","$_","!snmp $1 <removed>$'") && next;
} else {
ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next;
}
@@ -240,8 +270,9 @@ sub DoNothing {print STDOUT;}
sub FlailHelplessly {
print STDERR "Flailing: $_" if ($debug);
print STDOUT "Flailing: $_" if ($log);
- /#(show hardware)$/ && delete($commands{$1}) && return("ShowHardware");
/#(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";
@@ -254,6 +285,7 @@ sub FlailHelplessly {
"dir /pcmcia0" => "DirFlash",
"dir /pcmcia1" => "DirFlash",
'show hardware' => "ShowHardware",
+ 'show chassis' => "ShowChassis",
'show slot table' => "ShowSlotTable",
'show config' => "WriteTerm"
);
@@ -263,6 +295,7 @@ sub FlailHelplessly {
"dir /pcmcia0",
"dir /pcmcia1",
"show hardware",
+ "show chassis",
"show slot table",
"show config"
);
@@ -280,8 +313,8 @@ if ($file) {
print STDOUT "opening file $host\n" if ($log);
open(INPUT,"<$host") || die "open failed for $host: $!\n";
} else {
- print STDERR "executing clogin -t $timeo -c\"$cisco_cmds\" $host\n" if ($debug);
- print STDOUT "executing clogin -t $timeo -c\"$cisco_cmds\" $host\n" if ($log);
+ print STDERR "executing clogin -t $timeo -c\"$redback_cmds\" $host\n" if ($debug);
+ print STDOUT "executing clogin -t $timeo -c\"$redback_cmds\" $host\n" if ($log);
if (defined($ENV{NOPIPE})) {
system "clogin -t $timeo -c \"$redback_cmds\" $host </dev/null > $host.raw" || die "clogin failed for $host: $!\n";
@@ -291,6 +324,15 @@ if ($file) {
}
}
+# 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");
@@ -315,7 +357,7 @@ while(<INPUT>) {
}
print STDERR ("HIT COMMAND:$_") if ($debug);
if (! defined($commands{$cmd})) {
- print STDERR "found unexpected command - \"$cmd\"\n";
+ print STDERR "$host: found unexpected command - \"$cmd\"\n";
$clean_run = 0;
last;
}
@@ -341,12 +383,12 @@ if (defined($ENV{NOPIPE})) {
# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
if (scalar(%commands)) {
- printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
- printf(STDERR "missed cmd(s): %s\n", join(',', keys(%commands))) if ($debug);
+ 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 "End of run not found\n";
- print STDERR "End of run not found\n" if ($debug);
+ 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);
diff --git a/bin/xrancid.in b/bin/xrancid.in
index ace12b7..ecc6807 100755
--- a/bin/xrancid.in
+++ b/bin/xrancid.in
@@ -30,6 +30,8 @@ $clean_run = 0;
$found_end = 0;
$timeo = 90; # clogin timeout in seconds
+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)=(@_);
@@ -182,6 +184,7 @@ sub ShowDiag {
while (<INPUT>) {
tr/\015//d;
last if (/^$prompt/);
+ last if (/^Syntax error at token/);
next if (/^(\s*|\s*$cmd\s*)$/);
/platform\s+:\s+(.*)$/i &&
@@ -274,7 +277,7 @@ sub WriteTerm {
s/^\s*$/#/;
# filter extra comments and lead comments in config so we can preserve
- # the chassis type at the top of muched o/p before the processhistory
+ # the chassis type at the top of muched o/p before the process history
# key changes.
if (/^#\s*$/) {
if ($comment) {
@@ -297,10 +300,15 @@ sub WriteTerm {
/# system name/i && next;
/# software version/i && next;
- if (/configure ssh2 key/) {
+ if (/((create|configure) account \S+ \S+) / && $filter_pwds >= 2) {
+ ProcessHistory("","","","# $1 <key removed>\n");
+ next;
+ }
+ if (/configure ssh2 key/ && $filter_pwds >= 1) {
ProcessHistory("","","","# $_# <key removed>\n");
while (<INPUT>) {
if (/^(#|enable|conf|disable|unconf)/) {
+ tr/\015//d;
last;
}
}
@@ -308,9 +316,10 @@ sub WriteTerm {
# filter out any RCS/CVS tags to avoid confusing local CVS storage
s/\$(Revision|Id):/ $1:/;
- /^(config bgp (neighbor|peer-group) \S+ password encrypted)/i &&
- ProcessHistory("","","","# $1 <removed>\n") &&
+ if (/^((config|configure) bgp (neighbor|peer-group) \S+ password encrypted)/i && $filter_pwds >= 1) {
+ ProcessHistory("","","","# $1 <removed>\n");
next;
+ }
# order logging statements
/^configure syslog add logging (\d+\.\d+\.\d+\.\d+)/ &&
@@ -327,7 +336,7 @@ sub WriteTerm {
}
next;
}
- if (/^(configure snmp community (readonly|readwrite)) (\S+)/) {
+ if (/^(configure snmp community (readonly|readwrite)( encrypted)?) (\S+)/) {
if (defined($ENV{'NOCOMMSTR'})) {
ProcessHistory("SNMPSVRCOMM","keysort","$_","#$1 <removed>$'");
next;
@@ -336,8 +345,10 @@ sub WriteTerm {
}
}
# order/prune tacacs/radius server statements
- /^(configure radius (primary|secondary) (tacacs-server|radius-server) shared-secret encrypted)/ &&
- ProcessHistory("","","","# $1 <removed>\n") && next;
+ if (/^(configure radius (primary|secondary) (tacacs-server|radius-server) shared-secret encrypted)/ && $filter_pwds >= 1) {
+ ProcessHistory("","","","# $1 <removed>\n");
+ next;
+ }
# catch anything that wasnt match above.
ProcessHistory("","","","$_");
@@ -396,6 +407,15 @@ if ($file) {
}
}
+# 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: extreme\n#\n");
ProcessHistory("COMMENTS","keysort","B0","#\n"); # chassis info
ProcessHistory("COMMENTS","keysort","C0","#\n"); # power supply info
@@ -408,7 +428,7 @@ TOP: while(<INPUT>) {
# 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?(exit$|Connection closed)/ && $found_end) {
+ if (/$prompt\s?(quit|exit|Connection closed)/ && $found_end) {
$clean_run=1;
last;
}
@@ -427,7 +447,7 @@ TOP: while(<INPUT>) {
}
print STDERR ("HIT COMMAND:$_") if ($debug);
if (! defined($commands{$cmd})) {
- print STDERR "found unexpected command - \"$cmd\"\n";
+ print STDERR "$host: found unexpected command - \"$cmd\"\n";
$clean_run = 0;
last TOP;
}
@@ -454,14 +474,12 @@ if (defined($ENV{NOPIPE})) {
# check for completeness
if (scalar(%commands) || !$clean_run || !$found_end) {
if (scalar(%commands)) {
- printf(STDOUT "missed cmd(s): %s\n", join(',', keys(%commands)));
- if ($debug) {
- printf(STDERR "missed cmd(s): %s\n", join(',', keys(%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 "End of run not found\n";
- print STDERR "End of run not found\n" if ($debug);
+ 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);