From 9f2402b0d86333f5f7e9d50437036cd3124bde47 Mon Sep 17 00:00:00 2001 From: Tar Committer Date: Fri, 4 Jan 2002 21:31:49 +0000 Subject: Imported from rancid-2.2.tar.gz. --- BUGS | 1 + CHANGES | 66 ++ FAQ | 48 +- Makefile.am | 9 +- Makefile.in | 21 +- README | 27 +- Todo | 23 +- aclocal.m4 | 147 ++++- bin/Makefile.am | 69 ++ bin/Makefile.in | 423 +++++++++++- bin/alogin.in | 61 +- bin/arancid.in | 13 +- bin/blogin.in | 14 +- bin/brancid.in | 30 +- bin/cat5rancid.in | 123 ++-- bin/clogin.in | 182 +++--- bin/configure | 904 -------------------------- bin/configure.in | 35 - bin/control_rancid.in | 50 +- bin/do-diffs.in | 33 +- bin/elogin.in | 79 ++- bin/env.in | 4 + bin/erancid.in | 23 +- bin/flogin.in | 87 ++- bin/francid.in | 53 +- bin/hlogin.in | 50 +- bin/hpfilter.c | 398 ++++++++++++ bin/hrancid.in | 515 +++++---------- bin/jlogin.in | 57 +- bin/jrancid.in | 48 +- bin/mrancid.in | 397 ++++++++++++ bin/rancid-fe.in | 36 +- bin/rancid.in | 146 +++-- bin/rrancid.in | 72 ++- bin/xrancid.in | 48 +- cloginrc.sample | 28 +- configure | 1717 ++++++++++++++++++++++++++++++++++++++++++------- configure.in | 91 ++- include/Makefile.am | 12 + include/Makefile.in | 264 ++++++++ include/config.h | 177 +++++ include/config.h.in | 176 +++++ include/stamp-h.in | 1 + include/version.h | 9 + include/version.h.in | 9 + man/Makefile.am | 11 +- man/Makefile.in | 21 +- man/clogin.1 | 30 +- man/cloginrc.5 | 59 +- man/control_rancid.1 | 11 + man/do-diffs.1 | 14 + man/env.5.in | 17 +- man/hlogin.1 | 1 + man/hrancid.1 | 1 + man/lg.conf.5.in | 18 +- man/mrancid.1 | 1 + man/par.1 | 109 ++++ man/rancid.1 | 24 +- man/rancid_intro.1 | 17 +- man/router.db.5 | 41 +- util/Makefile.in | 9 +- util/lg/Makefile.in | 2 +- util/lg/README | 2 +- util/lg/lg.cgi.in | 87 ++- util/lg/lg.conf.in | 11 +- util/lg/lgform.cgi.in | 3 + 66 files changed, 5081 insertions(+), 2184 deletions(-) create mode 100644 BUGS create mode 100644 bin/Makefile.am mode change 100755 => 100644 bin/alogin.in mode change 100755 => 100644 bin/arancid.in mode change 100755 => 100644 bin/blogin.in mode change 100755 => 100644 bin/brancid.in delete mode 100755 bin/configure delete mode 100644 bin/configure.in create mode 100644 bin/hpfilter.c create mode 100755 bin/mrancid.in create mode 100644 include/Makefile.am create mode 100644 include/Makefile.in create mode 100644 include/config.h create mode 100644 include/config.h.in create mode 100644 include/stamp-h.in create mode 100644 include/version.h create mode 100644 include/version.h.in create mode 100644 man/hlogin.1 create mode 100644 man/hrancid.1 create mode 100644 man/mrancid.1 create mode 100644 man/par.1 diff --git a/BUGS b/BUGS new file mode 100644 index 0000000..697eeaf --- /dev/null +++ b/BUGS @@ -0,0 +1 @@ +See the the file Todo for known bugs. diff --git a/CHANGES b/CHANGES index cc8ec27..b11996e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,69 @@ +2.2 + rancid: filter vpdn passwords on PIX - from eric greenwood + + *rancid: handle variable amounts of spaces in front of + ' password' correctly. + + rancid: remove key from "crypto isakmp key". + + *login: cleanup login() to be more generic and handle openssh password + reprompting + + clogin: fix clogin -x for config mode by adjusting the prompt regex + + lg.conf: add LG_INFO to append local information to the main form + + {cat5}rancid: add dir of sup-{bootflash,microcode} for 6500 + + *rancid: print $host before "missed cmds", "unexpected command", + and "End of run" messages. + + cat5 module type match failed when user module name contained spaces + + add FILTER_PWDS switch to env(5) + + add merit MRTd support + + add -r option to do-diffs and control_rancid + + brancid: handle []'s in bay prompts and drop lock-address from config + - from mark cooper + + extreme: strip password if config|configure. Strip ^M + right after ssh key. + + Look for BOOTLDR: on ciscos. + + add par.1 manpage + + allow a TCP port suffix to telnet in .cloginrc - from Alex Bochannek + + Fixed RANCID-CONTENT-TYPE to be more consistant. Changes are + brancid bay + cat5rancid cisco-cat + erancid adc-ezt3 + + jlogin should not look for username@router in .cloginrc + + filter foundry ssh private key + + filter '#Time" from catalyst 4 write term + + display platform specific command in lookingglass results - patch + from Janos Mohacsi + + add support for HP procurve switches, in particular 2524M and 4108gl. + thanks to hp for the loaners. + + filter encrypted passwords on alteon as the change for each display + + More support for Redbacks. + + rancid now looks for "[kK] bytes" and "slot|disk". + + clogin now looks for "login:" as well as "Login:" and + escapes "[]" in $prompt. + 2.2b8 add PAR_COUNT variable to bin/env for adjusting the number of simultaneous collections. see bin/env (or bin/env.new for those with diff --git a/FAQ b/FAQ index 45b88d0..242770d 100644 --- a/FAQ +++ b/FAQ @@ -1,31 +1,31 @@ -Frequently Asked Questions about rancid - last updated 20010926 +Frequently Asked Questions about rancid - last updated 20011121. 1) Platform specific Q. I have a Cisco Catalyst 6500 series switch running the IOS (NOT catOS) software, is the router.db device type cisco or cat5? -A. A catalyst running IOS is type "cisco". see the router.db(5) manual page. +A. A catalyst running IOS is type "cisco". See the router.db(5) manual page. Q. I have a Cisco ??? on which collection stopped working, but clogin works as expected. -A. Check if 'write term' produces output. Some IOS combinated with large - configs and low free memory produce zero 'write term' output. The device - will have to be rebooted. +A. Check if 'write term' produces output. Some IOS combined with large + configs and low free memory produce zero 'write term' output, esp. combined + with a memory leak. The device will have to be rebooted or upgraded. 2) CVS and filesystem permissions -Q. I am new to cvs, where can i find additional information? -A. The manual page for cvs is quite complete, but can be be overwhelming even - for someone familiar with rcs. There are some excellent resources on the - pages http://www.loria.fr/~molli/cvs-index.html +Q. I am new to CVS, where can I find additional information? +A. The manual page for CVS is quite complete, but can be be overwhelming even + for someone familiar with RCS. There are some excellent resources on the + web. See http://www.loria.fr/~molli/cvs-index.html Q. Errors are showing up in the logs like: cvs [diff aborted]: there is no version here; run 'cvs checkout' first A. The directory was not imported into CVS properly or was not properly checked out afterward, so CVS control files or directories do not exist. create_cvs should always be used to create the directories and perform the CVS work. - If it is just the directories have been created manually, save a copy of + If it is just the directories that have been created manually, save a copy of the router.db file, then remove the group's directory, use create_cvs, and replace the router.db file. If the CVS import was also performed manually, cd to and use 'cvs co ' to create all the CVS @@ -33,14 +33,15 @@ A. The directory was not imported into CVS properly or was not properly checked Q. I keep receiving the same diff for a (or set of) devices, but I know the data is not changing repeatedly. Why? -A. This is most likely either a cvs or filesystem permissions problem. Check +A. This is most likely either a CVS or filesystem permissions problem. Check the log file from the last run for that group first; it may provide the exact cause. - note: it is very important the following be done as the user who normally + Note: It is very important the following be done as the user who normally runs the rancid collection from cron. Check the cvs status of the device's file. eg: + guelah [2704] cvs status rtr.shrubbery.net =================================================================== File: yogi.shrubbery.net Status: Up-to-date @@ -50,6 +51,7 @@ A. This is most likely either a cvs or filesystem permissions problem. Check Sticky Tag: (none) Sticky Date: (none) Sticky Options: (none) + The Status: should be Up-to-date. If the status is "Unknown", then somehow the file has been created without being cvs add'ed. This should be corrected by removing that device's entry from the group's router.db file, @@ -70,13 +72,14 @@ A. This is most likely either a cvs or filesystem permissions problem. Check 3) General -Q. I have a (set of) device(s) on which collection fails. How can i debug +Q. I have a (set of) device(s) on which collection fails. How can I debug this? A. Our usual diagnostic procedure for this is: - Make sure that the appropriate *login (eg: clogin for cisco) works. This tests to make sure you don't have routing or firewall issues, DNS - or hostname errors, that your .cloginrc is correct, and that the *login - script doesnt have a bug of some sort. For example: + or hostname errors, that your .cloginrc is correct, your banner does + not have some character that *login does not like, and that the *login + script doesn't have a bug of some sort. For example: clogin cisco_router @@ -106,9 +109,18 @@ A. Our usual diagnostic procedure for this is: If all of these work, make sure that the device's entry in the group's router.db file is correct and check the group's last log file for errors. -Q. I'm still stuck on this problem. Where can i get more help? +Q. Are there any characters in the banner that rancid has problems with OR + I changed the device's command prompt? +A. The trickest part about clogin (et al) is recognizing the prompt + correctly. clogin looks for '>' and '#' to figure out if it is logged + in or in enable mode. So if you have a '>' or '#' in your login banner + (other other motd), then clogin gets all confused and will not be + able to log in correctly, and thus rancid will fail. + + Don't use '>' or '#' in your prompt or in your banner or other motd. + +Q. I'm still stuck on this problem. Where can I get more help? A. A discussion list is available, rancid-discuss@shrubbery.net. You must - be a subscriber to post. subscribe like this: + be a subscriber to post. Subscribe like this: shell% echo "subscribe" | mail rancid-discuss-request@shrubbery.net - diff --git a/Makefile.am b/Makefile.am index ed81cf3..6ad5316 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,19 +4,22 @@ AUTOMAKE_OPTIONS=foreign no-dependencies @SET_MAKE@ -EXTRA_DIST = CHANGES COPYING FAQ README Todo cloginrc.sample configure \ +EXTRA_DIST = BUGS CHANGES COPYING FAQ README Todo cloginrc.sample configure \ install-sh \ mkinstalldirs Makefile.in Todo #DIST_COMMON = # '.' is here (and at the beginnging of the macro) so that distclean-recursive # will run make distclean in . after the other dirs (preserving Makefile) -SUBDIRS = . bin man util +SUBDIRS = . include bin man util all: +# install-exec-local: +# $(mkinstalldirs) $(prefix) $(prefix)/bin $(prefix)/man $(prefix)/util $(prefix)/util/lg + install-exec-local: - $(mkinstalldirs) $(prefix) $(prefix)/bin $(prefix)/man $(prefix)/util $(prefix)/util/lg + $(mkinstalldirs) $(prefix)/util $(prefix)/util/lg install: for file in CHANGES README cloginrc.sample ; do \ diff --git a/Makefile.in b/Makefile.in index 33e8807..52e2caa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,6 +1,6 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am +# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am -# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# 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. @@ -58,7 +58,9 @@ NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : AUTOMAKE = @AUTOMAKE@ +CC = @CC@ COMM = @COMM@ +CPP = @CPP@ CVS = @CVS@ DIFF = @DIFF@ DIFF_CMD = @DIFF_CMD@ @@ -90,19 +92,21 @@ SSH = @SSH@ TAR = @TAR@ TELNET = @TELNET@ TOUCH = @TOUCH@ +U = @U@ VERSION = @VERSION@ AUTOMAKE_OPTIONS = foreign no-dependencies -EXTRA_DIST = CHANGES COPYING FAQ README Todo cloginrc.sample configure install-sh mkinstalldirs Makefile.in Todo +EXTRA_DIST = BUGS CHANGES COPYING FAQ README Todo cloginrc.sample configure install-sh mkinstalldirs Makefile.in Todo #DIST_COMMON = # '.' is here (and at the beginnging of the macro) so that distclean-recursive # will run make distclean in . after the other dirs (preserving Makefile) -SUBDIRS = . bin man util +SUBDIRS = . include bin man util ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ./include/config.h CONFIG_CLEAN_FILES = DIST_COMMON = README COPYING Makefile.am Makefile.in acinclude.m4 \ aclocal.m4 configure configure.in install-sh missing mkinstalldirs @@ -164,7 +168,7 @@ maintainer-clean-recursive: dot_seen=no; \ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ rev="$$subdir $$rev"; \ - test "$$subdir" = "." && dot_seen=yes; \ + test "$$subdir" != "." || dot_seen=yes; \ done; \ test "$$dot_seen" = "no" && rev=". $$rev"; \ target=`echo $@ | sed s/-recursive//`; \ @@ -250,7 +254,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ @@ -343,8 +347,11 @@ mostlyclean distclean maintainer-clean all: +# install-exec-local: +# $(mkinstalldirs) $(prefix) $(prefix)/bin $(prefix)/man $(prefix)/util $(prefix)/util/lg + install-exec-local: - $(mkinstalldirs) $(prefix) $(prefix)/bin $(prefix)/man $(prefix)/util $(prefix)/util/lg + $(mkinstalldirs) $(prefix)/util $(prefix)/util/lg install: for file in CHANGES README cloginrc.sample ; do \ diff --git a/README b/README index 589cdc6..ab8684f 100644 --- a/README +++ b/README @@ -6,22 +6,23 @@ the files below by configure with substitutions completed: README This file. CHANGES List of changes to Rancid. -Todo partial Todo list of what needs to be done. +Todo partial list of what needs to be done. env.in Environment settings needed. do-diffs.in Script designed to be run from cron calling control_rancid. control_rancid.in Builds router list, calls rancid on each router and handles cvs routines. -rancid-fe.in chooses between rancid/[efjr]rancid/cat5rancid. +rancid-fe.in chooses between rancid/[abefhjrx]rancid/cat5rancid. rancid.in Runs commands on cisco routers and processes the output. brancid.in Runs commands on baynet/nortel routers and processes the output. erancid.in Runs commands on ADC EZ-T3 muxes and processes the output. francid.in Runs commands on foundry switches and processes the output. hrancid.in Runs commands on hp procurve switches and processes the output. jrancid.in Runs commands on juniper routers and processes the output. +mrancid.in Runs commands on MRT daemons and processes the output. rrancid.in Runs commands on redback routers and processes the output. -xancid.in Runs commands on extreme switches and processes the output. -cat5rancid.in Runs commands on cisco cat5 switches and processes the output. +xrancid.in Runs commands on extreme switches and processes the output. +cat5rancid.in Runs commands on cisco Cat switches and processes the output. blogin.in Expect script that logs into baynet/nortel routers either interactively, runs a set of commands, or runs another expect script. @@ -32,7 +33,7 @@ elogin.in Expect script that logs into ADC EZ-T3 muxes either script. flogin.in Expect script that logs into foundry switches. Once foundry cleans up their bloody UI, clogin should do the job. -blogin.in Expect script that logs into hp procurve switches either +hlogin.in Expect script that logs into hp procurve switches either interactively, runs a set of commands, or runs another expect script. jlogin.in Expect script that logs into juniper routers similarly to @@ -43,6 +44,7 @@ jlogin.in Expect script that logs into juniper routers similarly to par.in Parallel processing of commands - any commands. rename.in Perl script to rename files. create_cvs.in Creates all of the CVS and config directories. +hpfilter.c HP procurve login filter - see end of hlogin(1). man/ man pages util/ utilities / contribs util/lg looking glass @@ -57,7 +59,8 @@ mkinstalldirs GNU autoconf shell script to make installation directories rancid will also need to have the following packages: cvs code revision system available from prep.ai.mit.edu:/pub/gnu gnudiff gnudiff provides the uni-diff (-u) option. if you do not have - gnudiff, configure will use 'diff -c' or 'diff -C'. + gnudiff, configure will set-up rancid to use 'diff -c' or + 'diff -C'. perl5 perl version 5 or greater available from www.cpan.org expect http://expect.nist.gov/ we highly suggest that you stick to expect 5.24.1 (or so). this seems to work best. note that @@ -133,10 +136,12 @@ Quick Installation Guide (an example): 8) For each "group", modify the router.db file in the group directory. The file is of the form "router:mfg:state" where "router" is the name (we use FQDN) of the router, mfg is the manufacturer - from the set of (cisco|ezt3|extreme|foundry|juniper|redback|cat5), and - "state" is either up or down. Each router listed as "up" will have the - configuration grabbed. Note: manufacturer cat5 is intended only for - catalyst switches running catalyst (not IOS) code. + from the set of + (alteon|baynet|cat5|cisco|extreme|ezt3|foundry|hp|juniper|redback), + and "state" is either up or down. Each router listed as "up" + will have the configuration grabbed. Note: manufacturer cat5 + is intended only for cisco catalyst switches running catalyst (not + IOS) code. eg //router.db: cisco-router.domain.com:cisco:up @@ -157,7 +162,7 @@ Quick Installation Guide (an example): # run config differ hourly 1 * * * * /bin/do-diffs # clean out config differ logs - 50 23 * * * /usr/bin/find /logs -mtime +2 -exec rm {} \; + 50 23 * * * /usr/bin/find /logs -type f -mtime +2 -exec rm {} \; 11) Note: If you are using any of these programs (other than do-diffs) out of cron, make sure that you set your $PATH diff --git a/Todo b/Todo index 0a9c5fe..ed1fbcf 100644 --- a/Todo +++ b/Todo @@ -1,18 +1,18 @@ -- extreme collections loses when the config on the switch is in an unsaved - state, probably due to the prompt changing or rather the regex clogin - formulates for the prompt. -- cat4 support? +- extreme collections lose when the config on the switch is in an unsaved + state, probably due to the prompt changing or rather how clogin formulates + the prompt used by expect{ -re }'s. +- extreme collection fails for tacacs-enabled boxen due to diffs in UI - blech! +- should par's -c override an input files' : cmd? +- *login should emmit "clogin error:" or "*login error:" to make matches for + login failures definitive? +- would like hpfilter to be more friendly to interactive logins +- rancid with zebra? via vtysh? +- rancid for unix? - would be nice if it were possible to add additional commands to be run per-platform as a user desires. how could the user also provide a filtering routine? -- need par.1 manpage -- need to make sure the following patch was applied to the lookingglass - All routers not listed as 'up' in router.db are considered down. - This allows values other than down to mean 'not up'. for use - by util/downreport. - a format such as {} as the pwd in .cloginrc to indicate *login should prompt the user for the password -- handle redback in the looking glass - implement the bits marked unimplemented in lg.conf - detect 'same' vty configs - ignoring length/width/passwd is a start, but need more @@ -24,5 +24,6 @@ - rancid needs to treat the 3600s like the 7Ks and 12Ks... Also, need to allow 12012s, and force 700s to not be treated like 7Ks. - clogin/jlogin rsh is munged -- LG additions +- LG {requested} additions - show controllers T3 (data) + - handle redback in the looking glass diff --git a/aclocal.m4 b/aclocal.m4 index 4483bca..c6f5608 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4 +dnl aclocal.m4 generated automatically by aclocal 1.4-p5 -dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -21,7 +21,7 @@ AUTOMAKE_OPTIONS=no-dependencies foreign dnl Usage: dnl AM_INIT_AUTOMAKE(package,version, [no-define]) -AC_DEFUN(AM_INIT_AUTOMAKE, +AC_DEFUN([AM_INIT_AUTOMAKE], [AC_REQUIRE([AC_PROG_INSTALL]) PACKAGE=[$1] AC_SUBST(PACKAGE) @@ -49,7 +49,7 @@ AC_REQUIRE([AC_PROG_MAKE_SET])]) # Check to make sure that the build environment is sane. # -AC_DEFUN(AM_SANITY_CHECK, +AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 @@ -90,7 +90,7 @@ AC_MSG_RESULT(yes)]) dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) dnl The program must properly implement --version. -AC_DEFUN(AM_MISSING_PROG, +AC_DEFUN([AM_MISSING_PROG], [AC_MSG_CHECKING(for working $2) # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. @@ -104,12 +104,35 @@ else fi AC_SUBST($1)]) +# Like AC_CONFIG_HEADER, but automatically create stamp file. + +AC_DEFUN([AM_CONFIG_HEADER], +[AC_PREREQ([2.12]) +AC_CONFIG_HEADER([$1]) +dnl When config.status generates a header, we must update the stamp-h file. +dnl This file resides in the same directory as the config header +dnl that is generated. We must strip everything past the first ":", +dnl and everything past the last "/". +AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl +ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, +<>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, +<>; do + case " <<$>>CONFIG_HEADERS " in + *" <<$>>am_file "*<<)>> + echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx + ;; + esac + am_indx=`expr "<<$>>am_indx" + 1` +done<<>>dnl>>) +changequote([,]))]) + # Add --enable-maintainer-mode option to configure. # From Jim Meyering # serial 1 -AC_DEFUN(AM_MAINTAINER_MODE, +AC_DEFUN([AM_MAINTAINER_MODE], [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode is disabled by default AC_ARG_ENABLE(maintainer-mode, @@ -126,7 +149,7 @@ AC_DEFUN(AM_MAINTAINER_MODE, # Define a conditional. -AC_DEFUN(AM_CONDITIONAL, +AC_DEFUN([AM_CONDITIONAL], [AC_SUBST($1_TRUE) AC_SUBST($1_FALSE) if $2; then @@ -137,3 +160,113 @@ else $1_FALSE= fi]) + +# serial 1 + +AC_DEFUN([AM_C_PROTOTYPES], +[AC_REQUIRE([AM_PROG_CC_STDC]) +AC_REQUIRE([AC_PROG_CPP]) +AC_MSG_CHECKING([for function prototypes]) +if test "$am_cv_prog_cc_stdc" != no; then + AC_MSG_RESULT(yes) + AC_DEFINE(PROTOTYPES,1,[Define if compiler has function prototypes]) + U= ANSI2KNR= +else + AC_MSG_RESULT(no) + U=_ ANSI2KNR=./ansi2knr + # Ensure some checks needed by ansi2knr itself. + AC_HEADER_STDC + AC_CHECK_HEADERS(string.h) +fi +AC_SUBST(U)dnl +AC_SUBST(ANSI2KNR)dnl +]) + + +# serial 1 + +# @defmac AC_PROG_CC_STDC +# @maindex PROG_CC_STDC +# @ovindex CC +# If the C compiler in not in ANSI C mode by default, try to add an option +# to output variable @code{CC} to make it so. This macro tries various +# options that select ANSI C on some system or another. It considers the +# compiler to be in ANSI C mode if it handles function prototypes correctly. +# +# If you use this macro, you should check after calling it whether the C +# compiler has been set to accept ANSI C; if not, the shell variable +# @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source +# code in ANSI C, you can make an un-ANSIfied copy of it by using the +# program @code{ansi2knr}, which comes with Ghostscript. +# @end defmac + +AC_DEFUN([AM_PROG_CC_STDC], +[AC_REQUIRE([AC_PROG_CC]) +AC_BEFORE([$0], [AC_C_INLINE]) +AC_BEFORE([$0], [AC_C_CONST]) +dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require +dnl a magic option to avoid problems with ANSI preprocessor commands +dnl like #elif. +dnl FIXME: can't do this because then AC_AIX won't work due to a +dnl circular dependency. +dnl AC_BEFORE([$0], [AC_PROG_CPP]) +AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) +AC_CACHE_VAL(am_cv_prog_cc_stdc, +[am_cv_prog_cc_stdc=no +ac_save_CC="$CC" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + AC_TRY_COMPILE( +[#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +], [ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; +], +[am_cv_prog_cc_stdc="$ac_arg"; break]) +done +CC="$ac_save_CC" +]) +if test -z "$am_cv_prog_cc_stdc"; then + AC_MSG_RESULT([none needed]) +else + AC_MSG_RESULT($am_cv_prog_cc_stdc) +fi +case "x$am_cv_prog_cc_stdc" in + x|xno) ;; + *) CC="$CC $am_cv_prog_cc_stdc" ;; +esac +]) + 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 old mode 100755 new mode 100644 index 8ccf37b..9ffb9e8 --- 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 old mode 100755 new mode 100644 index f27e2ec..f51a6c3 --- a/bin/arancid.in +++ b/bin/arancid.in @@ -174,6 +174,9 @@ sub WriteTerm { defined($ENV{'NOCOMMSTR'})) { ProcessHistory("","","","\/\*\t$1$2\"\"\n") && next; } + /^(\s+.{2,3}pw )\S+/ && + ProcessHistory("","","","\/\*$1\n") && next; + next if (/^\/\* Configuration dump taken/i); next if (/^\/\* Version.*Base MAC.*/i); @@ -240,7 +243,7 @@ TOP: while() { 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 old mode 100755 new mode 100644 index ceb58e6..cae1bce --- 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 old mode 100755 new mode 100644 index fd8e5aa..2ea7e3b --- 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() { tr/\015//d; if ( (/\>\s?logout$/) || $found_end ) { @@ -231,10 +244,13 @@ TOP: while() { } 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 () { 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 () { } } -# 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 () { - tr/\015//d; - last if (/^$prompt/); - next if (/^(\s*|\s*$cmd\s*)$/); - return(1) if ($type !~ /^72/); - /^$/ && next; - if (/C7200 Midplane EEPROM:/) { - $_ = ; - /revision\s+(\S+).*revision\s+(\S+)/; - ProcessHistory("SLOT","","","!Slot Midplane: hvers $1 rev $2\n"); - $_ = ; - /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:/) { - $_ = ; - /revision\s+(\S+).*revision\s+(\S+)/ && - ProcessHistory("SLOT","","","!Slot CPU: hvers $1 rev $2\n"); - $_ = ; - /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 () { 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 \n") && + if (/^enable password / && $filter_pwds >= 1) { + ProcessHistory("ENABLE","","","! $1 \n"); + next; + } + if (/^set enablepass / && $filter_pwds >= 2) { + ProcessHistory("ENABLE","","","! $1 \n"); next; - /^(username .*) password /&& - ProcessHistory("USER","","","!$1 password \n") && next; - /^\s*password / && - ProcessHistory("LINE-PASS","","","! password \n") && next; - /^\s*neighbor (\S*) password / && - ProcessHistory("","","","! neighbor $1 password \n") && + } + if (/^(username .*) password /) { + if (/^(username .*) password / && $filter_pwds >= 1) { + ProcessHistory("USER","","","! $1 password \n"); + } else { + ProcessHistory("USER","","","$_\n"); + } + next; + } + if (/^set password / && $filter_pwds >= 2) { + ProcessHistory("","","","! set password \n"); + next; + } + if (/^(\s*)password / && $filter_pwds >= 1) { + ProcessHistory("LINE-PASS","","","!$1password \n"); + next; + } + if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) { + ProcessHistory("","","","! neighbor $1 password \n"); + next; + } + if (/^(ip ftp password) / && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \n"); next; - /^(ip ftp password) / && - ProcessHistory("","","","!$1 \n") && next; - /^( ip ospf authentication-key) / && - ProcessHistory("","","","!$1 \n") && next; - /^( ip ospf message-digest-key \d+ md5) / && - ProcessHistory("","","","!$1 \n") && next; + } + if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \n"); + next; + } + if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \n"); + next; + } /fair-queue individual-limit/ && next; # 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 \n") && next; + if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 2) { + ProcessHistory("","","","!$1 \n"); + next; + } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); @@ -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() { 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 to cont\[^\r\n]*" { send " " + -re "\[^\r\n]*Press to cont\[^\r\n]*" { + send " " + # bloody ^[[2K after " " expect { - # gag, 2 more prompts - -re "\[\r\n]*\r" {} - -re "\[^\r\n]*Press 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 to cont\[^\r\n]*" { send " " + -re "\[^\r\n]*Press 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 </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 < 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 <> $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 <> $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 +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 +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() { } 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\n") && next; - /^tacacs-server host (\d+\.\d+\.\d+\.\d+)/ && - ProcessHistory("TAC","ipsort","$1","$_") && next; - + if (/^(tacacs-server key )/ && $filter_pwds >= 1) { + ProcessHistory("","","","! $1\n"); + next; + } # delete ntp auth password - /^(ntp authentication-key \d+ md5) / && - ProcessHistory("","","","!$1 \n") && next; + if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 2) { + ProcessHistory("","","","!$1 \n"); + next; + } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); @@ -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 \n"); + next; + } + # filter ssh private key + if (/^(crypto key generate (rsa|dsa) private_key)/ && + $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \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() { tr/\015//d; @@ -355,7 +380,7 @@ TOP: while() { } 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 +#include + +#include +#include +#include +#include +#include +#include + +#include + +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] +", 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. - $_ = ; 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; - $_ = ; tr/\015//d; s/ subunit \d,//; - ProcessHistory("INT","","","!Interface: $ctlr $_"); - } - if (/^(\S+) : show controller:$/) { - my($ctlr) = $1; - $_ = ; tr/\015//d; s/ subunit \d,//; - ProcessHistory("INT","","","!Interface: $ctlr: $_"); - } - /^(HD unit \d), idb/ && - ProcessHistory("INT","","","!Interface: $1\n") && next; - /^HD unit \d, NIM/ && - ProcessHistory("INT","","","!Interface: $_") && next; - /^buffer size \d+ HD unit \d, (.*)/ && - ProcessHistory("INT","","","!\t$1\n") && next; - /^AM79970 / && ProcessHistory("INT","","","!Interface: $_") && next; - /^buffer size \d+ (Universal Serial: .*)/ && - ProcessHistory("INT","","","!\t$1\n") && next; - /^Hardware is (.*)/ && - ProcessHistory("INT","","","!Interface: $INT$1\n") && next; - /^(QUICC Serial unit \d),/ && - ProcessHistory("INT","","","!$1\n") && next; - /^QUICC Ethernet .*/ && - ProcessHistory("INT","","","!$_") && next; - /^DTE .*\.$/ && - ProcessHistory("INT","","","!\t$_") && next; - /^(cable type :.*),/ && - ProcessHistory("INT","","","!\t$1\n") && next; - /^(.* cable.*), received clockrate \d+$/ && - ProcessHistory("INT","","","!\t$1\n") && next; - /^.* cable.*$/ && - ProcessHistory("INT","","","!\t$_") && next; + return(-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:/) { - $_ = ; - /revision\s+(\S+).*revision\s+(\S+)/; - ProcessHistory("SLOT","","","!Slot Midplane: hvers $1 rev $2\n"); - $_ = ; - /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:/) { - $_ = ; - /revision\s+(\S+).*revision\s+(\S+)/ && - ProcessHistory("SLOT","","","!Slot CPU: hvers $1 rev $2\n"); - $_ = ; - /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 () { - 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 \n"); + next; + } + + if (/^(snmp-server community) (\S+)/) { + if (defined($ENV{'NOCOMMSTR'})) { + ProcessHistory("SNMPSERVERCOMM","keysort","$_", + ";$1 $'") && 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 + 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(' ', ("", 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 \n"); + next; + } + if (/^(tacacs-server host \d+\.\S+) key / && $filter_pwds >= 1) { + ProcessHistory("","","",";$1 key \n"); + next; + } + + # prune passwords from stack member statements + if (/^(stack member .* password )\S+/ && $filter_pwds >= 1) { + ProcessHistory("","","",";$1$'"); + next; + } + + # order arp lists + /^ip arp\s+(\d+\.\d+\.\d+\.\d+)/ && + ProcessHistory("ARP","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 \n") && + if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) { + ProcessHistory("ENABLE","","",";$1$2 \n"); next; - /^username (\S+)(\s.*)? password /&& - ProcessHistory("USER","keysort","$1","!username $1$2 password \n") && next; - /^\s*password / && - ProcessHistory("LINE-PASS","","","! password \n") && next; - /^\s*neighbor (\S*) password / && - ProcessHistory("","","","! neighbor $1 password \n") && - next; - /^(ip ftp password) / && - ProcessHistory("","","","!$1 \n") && next; - /^( ip ospf authentication-key) / && - ProcessHistory("","","","!$1 \n") && next; - /^( ip ospf message-digest-key \d+ md5) / && - ProcessHistory("","","","!$1 \n") && next; - /fair-queue individual-limit/ && next; - # sort ip explicit-paths. - if (/^ip explicit-path name (\S+)/) { - my($key) = $1; - my($expath) = $_; - while () { - tr/\015//d; - last if (/^$prompt/); - last if (/^$prompt/ || ! /^(ip explicit-path name |[ !])/); - if (/^ip explicit-path name (\S+)/) { - ProcessHistory("EXPATH","keysort","$key","$expath"); - $key = $1; - $expath = $_; - } else { - $expath .= $_; - } + } + if (/^username (\S+)(\s.*)? password /) { + if ($filter_pwds >= 1) { + ProcessHistory("USER","keysort","$1",";username $1$2 password \n"); + } else { + ProcessHistory("USER","keysort","$1","$_"); } - ProcessHistory("EXPATH","keysort","$key","$expath"); + next; + } + + if (/^(ip ftp password) / && $filter_pwds >= 1) { + ProcessHistory("","","",";$1 \n"); next; + } + if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { + ProcessHistory("","","",";$1 \n"); next; + } + if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { + ProcessHistory("","","",";$1 \n"); next; } # sort route-maps if (/^route-map (\S+)/) { @@ -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 - 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(' ', ("", join(' ',@tokens))); - last; - } - } - ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); - } else { - ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); - } - next; - } - if (/^(snmp-server community) (\S+)/) { - if (defined($ENV{'NOCOMMSTR'})) { - ProcessHistory("SNMPSERVERCOMM","keysort","$_","!$1 $'") && next; - } else { - ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; - } - } - # order/prune tacacs/radius server statements - /^(tacacs-server|radius-server) key / && - ProcessHistory("","","","!$1 key \n") && next; - # order clns host statements - /^clns host \S+ (\S+)/ && - ProcessHistory("CLNS","keysort","$1","$_") && next; + # order alias statements /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next; # delete ntp auth password - /^(ntp authentication-key \d+ md5) / && - ProcessHistory("","","","!$1 \n") && next; + if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { + ProcessHistory("","","",";$1 \n"); next; + } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); @@ -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 \n") && - next; - /^syscon password (\S*)/ && - ProcessHistory("","","","!syscon password \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() { tr/\015//d; - if (/\#\s?exit$/) { + if (/$prompt\s*exit\s*$/i) { $clean_run=1; last; } @@ -675,10 +493,11 @@ TOP: while() { } 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\"\"$3\n"; + $_ = "$1$2 \"\"$3\n"; } } - s/(\s*authentication-key ).*$/#$1;/; - s/^(.*\ssecret \")\$9\$.*(\".*)$/#$1$2/; + if (/(\s*authentication-key ).*$/ && $filter_pwds >= 1) { + s/(\s*authentication-key ).*$/#$1;/; + } + if (/^(.*\ssecret \")\$9\$.*(\".*)$/ && $filter_pwds >= 1) { + s/^(.*\ssecret \")\$9\$.*(\".*)$/#$1$2/; + } + if (/(\s+encrypted-password ).*$/ && $filter_pwds >= 2) { + ProcessHistory("","","","#$1;\n"); + next; + } + if (/(\s+ssh-(rsa|dsa) )\"/ && $filter_pwds >= 2) { + ProcessHistory("","","","#$1;\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() { tr/\015//d; @@ -484,7 +512,7 @@ TOP: while() { } 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 () { + tr/\015//d; + last if(/^$prompt/); + next if(/^(\s*|\s*$cmd\s*)$/); + return(-1) if (/command authorization failed/i); + + /compiled on /i && next; + /UP for /i && next; + + ProcessHistory("COMMENTS","keysort","A0", "!$_"); + } + return(0); +} + +# This routine processes a "write term" +sub WriteTerm { + print STDERR " In WriteTerm: $_" if ($debug); + + while () { + tr/\015//d; + if (/$prompt\s*exit\s*$/) { + $clean_run=1; + last; + } + last if(/^$prompt/); + return(-1) if (/command authorization failed/i); + # the pager can not be disabled per-session on the PIX + s/^<-+ More -+>\s*//; + /Non-Volatile memory is in use/ && return(-1); # NvRAM is locked + + # filter out any RCS/CVS tags to avoid confusing local CVS storage + s/\$(Revision|Id):/ $1:/; + + if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) { + ProcessHistory("ENABLE","","","!$1$2 \n"); + next; + } + if (/^username (\S+)(\s.*)? password /) { + if ($filter_pwds >= 1) { + ProcessHistory("USER","keysort","$1","!username $1$2 password \n"); + } else { + ProcessHistory("USER","keysort","$1","$_"); + } + next; + } + if (/^(\s*)password / && $filter_pwds >= 1) { + ProcessHistory("LINE-PASS","","","!$1password \n"); next; + } + if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) { + ProcessHistory("","","","! neighbor $1 password \n"); + next; + } + + if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \n"); next; + } + if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \n"); next; + } + + # sort route-maps + if (/^route-map (\S+)/) { + my($key) = $1; + my($routemap) = $_; + while () { + tr/\015//d; + last if (/^$prompt/ || ! /^(route-map |[ !])/); + if (/^route-map (\S+)/) { + ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); + $key = $1; + $routemap = $_; + } else { + $routemap .= $_; + } + } + ProcessHistory("ROUTEMAP","keysort","$key","$routemap"); + } + + # catch anything that wasnt match above. + ProcessHistory("","","","$_"); + + + next; + # order access-lists + /^access-list\s+(\d\d?)\s+(\S+)\s+(\S+)/ && + ProcessHistory("ACL $1 $2","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 + 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(' ', ("", join(' ',@tokens))); + last; + } + } + ProcessHistory("SNMPSERVERHOST","ipsort","$ip","$line\n"); + } else { + ProcessHistory("SNMPSERVERHOST","ipsort","$1","$_"); + } + next; + } + if (/^(snmp-server community) (\S+)/) { + if (defined($ENV{'NOCOMMSTR'})) { + ProcessHistory("SNMPSERVERCOMM","keysort","$_","!$1 $'") && next; + } else { + ProcessHistory("SNMPSERVERCOMM","keysort","$_","$_") && next; + } + } + # 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 $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 ) { + 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 () { 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 () { 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 () { 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 () { 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 () { 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 () { 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 \n") && + if (/^(enable )?(password|passwd) / && $filter_pwds >= 1) { + ProcessHistory("ENABLE","","","!$1$2 \n"); + next; + } + if (/^(enable secret) / && $filter_pwds >= 2) { + ProcessHistory("ENABLE","","","!$1 \n"); + next; + } + if (/^username (\S+)(\s.*)? secret /) { + if ($filter_pwds >= 2) { + ProcessHistory("USER","keysort","$1","!username $1$2 secret \n"); + } else { + ProcessHistory("USER","keysort","$1","$_"); + } + next; + } + if (/^username (\S+)(\s.*)? password /) { + if ($filter_pwds >= 1) { + ProcessHistory("USER","keysort","$1","!username $1$2 password \n"); + } else { + ProcessHistory("USER","keysort","$1","$_"); + } + next; + } + if (/^(\s*)password / && $filter_pwds >= 1) { + ProcessHistory("LINE-PASS","","","!$1password \n"); next; - /^username (\S+)(\s.*)? password /&& - ProcessHistory("USER","keysort","$1","!username $1$2 password \n") && next; - /^\s*password / && - ProcessHistory("LINE-PASS","","","! password \n") && next; - /^\s*neighbor (\S*) password / && - ProcessHistory("","","","! neighbor $1 password \n") && + } + if (/^\s*neighbor (\S*) password / && $filter_pwds >= 1) { + ProcessHistory("","","","! neighbor $1 password \n"); next; - /^(ppp .* password) 7 .*/ && - ProcessHistory("","","","!$1 \n") && next; - /^(ip ftp password) / && - ProcessHistory("","","","!$1 \n") && next; - /^( ip ospf authentication-key) / && - ProcessHistory("","","","!$1 \n") && next; - /^( ip ospf message-digest-key \d+ md5) / && - ProcessHistory("","","","!$1 \n") && next; + } + if (/^(ppp .* password) 7 .*/ && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \n"); next; + } + if (/^(ip ftp password) / && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \n"); next; + } + if (/^( ip ospf authentication-key) / && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \n"); next; + } + # this is reversable, despite 'md5' in the cmd + if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \n"); next; + } + if (/^((crypto )?isakmp key) \S+ / && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 $'"); next; + } + # i am told these are plain-text on the PIX + if (/^(vpdn username \S+ password)/ && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \n"); next; + } /fair-queue individual-limit/ && next; # sort ip explicit-paths. if (/^ip explicit-path name (\S+)/) { @@ -985,16 +1030,18 @@ sub WriteTerm { } } # order/prune tacacs/radius server statements - /^(tacacs-server|radius-server) key / && - ProcessHistory("","","","!$1 key \n") && next; + if (/^(tacacs-server|radius-server) key / && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 key \n"); next; + } # order clns host statements /^clns host \S+ (\S+)/ && ProcessHistory("CLNS","keysort","$1","$_") && next; # order alias statements /^alias / && ProcessHistory("ALIAS","keysort","$_","$_") && next; - # delete ntp auth password - /^(ntp authentication-key \d+ md5) / && - ProcessHistory("","","","!$1 \n") && next; + # delete ntp auth password - this md5 is a reversable too + if (/^(ntp authentication-key \d+ md5) / && $filter_pwds >= 1) { + ProcessHistory("","","","!$1 \n"); next; + } # order ntp peers/servers if (/^ntp (server|peer) (\d+)\.(\d+)\.(\d+)\.(\d+)/) { $sortkey = sprintf("$1 %03d%03d%03d%03d",$2,$3,$4,$5); @@ -1017,15 +1064,15 @@ sub WriteTerm { /^syscon address (\S*) (\S*)/ && ProcessHistory("","","","!syscon address $1 \n") && next; - /^syscon password (\S*)/ && - ProcessHistory("","","","!syscon password \n") && + if (/^syscon password (\S*)/ && $filter_pwds >= 1) { + ProcessHistory("","","","!syscon password \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() { 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 () { + tr/\015//d; + last if(/^$prompt/); + + /(Copyright|uptime|restarted|^\s*$)/ && next; + /(Up Time|Boot Time)/ && next; + ProcessHistory("COMMENTS","keysort","A1","!Image: $_"); + } + return; +} + # This routine parses "dir /" sub DirFlash { print STDERR " In DirFlash: $_" if ($debug); @@ -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 () { 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 () { 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 $'") && next; + ProcessHistory("SNMPSERVERCOMM","keysort","$_","!snmp $1 $'") && 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 $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() { } 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 () { 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 \n"); + next; + } + if (/configure ssh2 key/ && $filter_pwds >= 1) { ProcessHistory("","","","# $_# \n"); while () { 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 \n") && + if (/^((config|configure) bgp (neighbor|peer-group) \S+ password encrypted)/i && $filter_pwds >= 1) { + ProcessHistory("","","","# $1 \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 $'"); 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 \n") && next; + if (/^(configure radius (primary|secondary) (tacacs-server|radius-server) shared-secret encrypted)/ && $filter_pwds >= 1) { + ProcessHistory("","","","# $1 \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() { # 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() { } 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); diff --git a/cloginrc.sample b/cloginrc.sample index dc040b4..da66459 100644 --- a/cloginrc.sample +++ b/cloginrc.sample @@ -1,5 +1,5 @@ # comments are cool, as is whitespace -# currently clogin supports a number of add directives: +# clogin supports a number of add directives: # password # user # userprompt @@ -13,26 +13,26 @@ # cyphertype # identity # -# Details on each of these follows. +# Details on each of these follows. Also see cloginrc(5). # -# add password +# add password # -# add user +# add user # The default user is $USER (i.e.: the user running clogin). # -# add userprompt +# add userprompt # What the router prints to prompt for the username. # Default: {"(Username|login|user name):"} # -# add userpassword +# add userpassword # The password for user if different than the password set # using 'add password'. # -# add passprompt +# add passprompt # What the router prints to prompt for the password. # Default: {"(\[Pp]assword|passwd):"} # -# add method {ssh} [...] +# add method {ssh} [...] # Defines, in order, which connection method(s) to use for a device # from the set {ssh,telnet,rsh}. eg: add method * {ssh} {telnet} {rsh} # will attempt ssh connection first. if ssh fails with connection @@ -40,24 +40,24 @@ # then rsh. # Default: {telnet} {ssh} # -# add noenable +# add noenable # equivalent of -noenable on the cmd line to not enable at login. # -# add enableprompt +# add enableprompt # What the router prints to prompt for the enable password. # Default: {"\[Pp]assword:"} # -# add enauser +# add enauser # This is only needed if enable asks for a username and this # username is different from what user is set to. # -# add autoenable <1/0> +# add autoenable <1/0> # This is used if you are automatically enabled by the login process. # -# add cyphertype +# add cyphertype # Default is 3des. # -# add identity +# add identity # Default is your default ssh identity. # # include diff --git a/configure b/configure index 80ad8fa..1acab2c 100755 --- a/configure +++ b/configure @@ -457,7 +457,7 @@ 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= +ac_unique_file=CHANGES # Find the source files, if location was not specified. if test -z "$srcdir"; then @@ -528,6 +528,11 @@ fi +VERSION=`sed -n 's/.*version.*"\(.*\)".*/\1/p' $srcdir/include/version.h.in|tr -d ' '` +PACKAGE=`sed -n 's/.*package.*"\(.*\)".*/\1/p' $srcdir/include/version.h.in|tr -d ' '` + + + ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then @@ -559,7 +564,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # 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:563: checking for a BSD compatible install" >&5 +echo "configure:568: 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 @@ -612,7 +617,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:616: checking whether build environment is sane" >&5 +echo "configure:621: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -669,7 +674,7 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:673: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:678: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -696,9 +701,9 @@ else fi -PACKAGE=PACKAGE +PACKAGE=$PACKAGE -VERSION=VERSION +VERSION=$VERSION if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } @@ -715,7 +720,7 @@ EOF missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:719: checking for working aclocal" >&5 +echo "configure:724: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -723,105 +728,1347 @@ if (aclocal --version) < /dev/null > /dev/null 2>&1; then ACLOCAL=aclocal echo "$ac_t""found" 1>&6 else - ACLOCAL="$missing_dir/missing aclocal" - echo "$ac_t""missing" 1>&6 + ACLOCAL="$missing_dir/missing aclocal" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 +echo "configure:737: checking for working autoconf" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (autoconf --version) < /dev/null > /dev/null 2>&1; then + AUTOCONF=autoconf + echo "$ac_t""found" 1>&6 +else + AUTOCONF="$missing_dir/missing autoconf" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working automake""... $ac_c" 1>&6 +echo "configure:750: checking for working automake" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (automake --version) < /dev/null > /dev/null 2>&1; then + AUTOMAKE=automake + echo "$ac_t""found" 1>&6 +else + AUTOMAKE="$missing_dir/missing automake" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 +echo "configure:763: checking for working autoheader" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (autoheader --version) < /dev/null > /dev/null 2>&1; then + AUTOHEADER=autoheader + echo "$ac_t""found" 1>&6 +else + AUTOHEADER="$missing_dir/missing autoheader" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 +echo "configure:776: checking for working makeinfo" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (makeinfo --version) < /dev/null > /dev/null 2>&1; then + MAKEINFO=makeinfo + echo "$ac_t""found" 1>&6 +else + MAKEINFO="$missing_dir/missing makeinfo" + echo "$ac_t""missing" 1>&6 +fi + + + + + + + + + +echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 +echo "configure:797: checking whether to enable maintainer-specific portions of Makefiles" >&5 + # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then + enableval="$enable_maintainer_mode" + USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi + + echo "$ac_t""$USE_MAINTAINER_MODE" 1>&6 + + +if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + MAINT=$MAINTAINER_MODE_TRUE + + + +subdirs="util" + + +# make sure MAKE sets ${MAKE} +# Extract the first word of "gmake", so it can be a program name with args. +set dummy gmake; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:827: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_MAKE'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$MAKE" in + /*) + ac_cv_path_MAKE="$MAKE" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_MAKE="$MAKE" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_MAKE="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_MAKE" && ac_cv_path_MAKE="no" + ;; +esac +fi +MAKE="$ac_cv_path_MAKE" +if test -n "$MAKE"; then + echo "$ac_t""$MAKE" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test $MAKE = no; then + unset ac_cv_path_MAKE + # Extract the first word of "make", so it can be a program name with args. +set dummy make; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:865: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_MAKE'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$MAKE" in + /*) + ac_cv_path_MAKE="$MAKE" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_MAKE="$MAKE" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_MAKE="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_MAKE" && ac_cv_path_MAKE="no" + ;; +esac +fi +MAKE="$ac_cv_path_MAKE" +if test -n "$MAKE"; then + echo "$ac_t""$MAKE" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test $MAKE = no; then + { echo "configure: error: can't locate a make." 1>&2; exit 1; } + exit 1 + fi +fi +echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 +echo "configure:904: checking whether ${MAKE-make} sets \${MAKE}" >&5 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftestmake <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftestmake +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$ac_t""yes" 1>&6 + SET_MAKE= +else + echo "$ac_t""no" 1>&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + + +# compiler specifics +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:935: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:965: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1016: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:1048: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +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 + +cat > conftest.$ac_ext << EOF + +#line 1059 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:1064: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +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 + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:1090: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:1095: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:1123: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + + + + +echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6 +echo "configure:1158: checking for ${CC-cc} option to accept ANSI C" >&5 +if eval "test \"`echo '$''{'am_cv_prog_cc_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + am_cv_prog_cc_stdc=no +ac_save_CC="$CC" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + cat > conftest.$ac_ext < +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; + +int main() { + +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + +; return 0; } +EOF +if { (eval echo configure:1211: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + am_cv_prog_cc_stdc="$ac_arg"; break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done +CC="$ac_save_CC" + +fi + +if test -z "$am_cv_prog_cc_stdc"; then + echo "$ac_t""none needed" 1>&6 +else + echo "$ac_t""$am_cv_prog_cc_stdc" 1>&6 +fi +case "x$am_cv_prog_cc_stdc" in + x|xno) ;; + *) CC="$CC $am_cv_prog_cc_stdc" ;; +esac + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1235: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1256: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1273: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1290: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + + + +echo $ac_n "checking for function prototypes""... $ac_c" 1>&6 +echo "configure:1317: checking for function prototypes" >&5 +if test "$am_cv_prog_cc_stdc" != no; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define PROTOTYPES 1 +EOF + + U= ANSI2KNR= +else + echo "$ac_t""no" 1>&6 + U=_ ANSI2KNR=./ansi2knr + # Ensure some checks needed by ansi2knr itself. + echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1330: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1343: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + + for ac_hdr in string.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1437: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1447: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +fi + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1476: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1497: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1514: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1531: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +echo "configure:1556: checking for working const" >&5 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:1610: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_const=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + +echo $ac_n "checking for inline""... $ac_c" 1>&6 +echo "configure:1631: checking for inline" >&5 +if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_inline=$ac_kw; break +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* +done + +fi + +echo "$ac_t""$ac_cv_c_inline" 1>&6 +case "$ac_cv_c_inline" in + inline | yes) ;; + no) cat >> confdefs.h <<\EOF +#define inline +EOF + ;; + *) cat >> confdefs.h <&6 +echo "configure:1673: checking for preprocessor stringizing operator" >&5 +if eval "test \"`echo '$''{'ac_cv_c_stringize'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <&5 | + egrep "#teststring" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_c_stringize=no +else + rm -rf conftest* + ac_cv_c_stringize=yes +fi +rm -f conftest* + +fi + +if test "${ac_cv_c_stringize}" = yes +then + cat >> confdefs.h <<\EOF +#define HAVE_STRINGIZE 1 +EOF + +fi +echo "$ac_t""${ac_cv_c_stringize}" 1>&6 + + +# check includes/headers +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1710: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1723: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +for ac_hdr in limits.h memory.h siginfo.h string.h strings.h unistd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1817: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 fi +done -echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:732: checking for working autoconf" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (autoconf --version) < /dev/null > /dev/null 2>&1; then - AUTOCONF=autoconf - echo "$ac_t""found" 1>&6 + +for ac_hdr in errno.h fcntl.h sys/types.h sys/wait.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1858: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else - AUTOCONF="$missing_dir/missing autoconf" - echo "$ac_t""missing" 1>&6 + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1868: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" fi - -echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:745: checking for working automake" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (automake --version) < /dev/null > /dev/null 2>&1; then - AUTOMAKE=automake - echo "$ac_t""found" 1>&6 +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 + echo "$ac_t""no" 1>&6 fi +done -echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:758: checking for working autoheader" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (autoheader --version) < /dev/null > /dev/null 2>&1; then - AUTOHEADER=autoheader - echo "$ac_t""found" 1>&6 +for ac_hdr in sysexits.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1898: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else - AUTOHEADER="$missing_dir/missing autoheader" - echo "$ac_t""missing" 1>&6 + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1908: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" fi - -echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:771: checking for working makeinfo" >&5 -# Run test in a subshell; some versions of sh will print an error if -# an executable is not found, even if stderr is redirected. -# Redirect stdin to placate older versions of autoconf. Sigh. -if (makeinfo --version) < /dev/null > /dev/null 2>&1; then - MAKEINFO=makeinfo - echo "$ac_t""found" 1>&6 +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 + echo "$ac_t""no" 1>&6 fi +done +# check functions +for ac_func in memcpy memmove memset bcopy bzero strerror strchr strrchr \ + strstr strtok strrtok index rindex +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1940: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi -subdirs="bin util" - - - +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done -PACKAGE=rancid +# type checks +echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 +echo "configure:1995: checking return type of signal handlers" >&5 +if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#ifdef signal +#undef signal +#endif +#ifdef __cplusplus +extern "C" void (*signal (int, void (*)(int)))(int); +#else +void (*signal ()) (); +#endif + +int main() { +int i; +; return 0; } +EOF +if { (eval echo configure:2017: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_type_signal=void +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_type_signal=int +fi +rm -f conftest* +fi -# VERSION needs to be updated such that 'make dist' uses the correct -# filename for the directory name and tarball. +echo "$ac_t""$ac_cv_type_signal" 1>&6 +cat >> confdefs.h <&6 -echo "configure:799: checking whether to enable maintainer-specific portions of Makefiles" >&5 - # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. -if test "${enable_maintainer_mode+set}" = set; then - enableval="$enable_maintainer_mode" - USE_MAINTAINER_MODE=$enableval +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +echo "configure:2036: checking for size_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else - USE_MAINTAINER_MODE=no + cat > conftest.$ac_ext < +#if STDC_HEADERS +#include +#include +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_size_t=yes +else + rm -rf conftest* + ac_cv_type_size_t=no fi +rm -f conftest* - echo "$ac_t""$USE_MAINTAINER_MODE" 1>&6 - +fi +echo "$ac_t""$ac_cv_type_size_t" 1>&6 +if test $ac_cv_type_size_t = no; then + cat >> confdefs.h <<\EOF +#define size_t unsigned +EOF -if test $USE_MAINTAINER_MODE = yes; then - MAINTAINER_MODE_TRUE= - MAINTAINER_MODE_FALSE='#' -else - MAINTAINER_MODE_TRUE='#' - MAINTAINER_MODE_FALSE= fi - MAINT=$MAINTAINER_MODE_TRUE - # Check for a preference for using mail addresses like rancid+admin-group # instead of the standard rancid-admin-group echo $ac_n "checking whether mail addresses should be in the rancid+ form""... $ac_c" 1>&6 -echo "configure:825: checking whether mail addresses should be in the rancid+ form" >&5 +echo "configure:2072: checking whether mail addresses should be in the rancid+ form" >&5 # Check whether --enable-mail-plus or --disable-mail-plus was given. if test "${enable_mail_plus+set}" = set; then enableval="$enable_mail_plus" @@ -846,7 +2093,7 @@ rd_cv_MAILPLUS=$MAILPLUS # Extract the first word of "dirname", so it can be a program name with args. set dummy dirname; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:850: checking for $ac_word" >&5 +echo "configure:2097: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_DIRNAME'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -883,7 +2130,7 @@ fi # Extract the first word of "diff", so it can be a program name with args. set dummy diff; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:887: checking for $ac_word" >&5 +echo "configure:2134: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_DIFF'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -944,7 +2191,7 @@ rd_cv_DIFF_CMD=$DIFF_CMD # Extract the first word of "sendmail", so it can be a program name with args. set dummy sendmail; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:948: checking for $ac_word" >&5 +echo "configure:2195: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_SENDMAIL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -978,113 +2225,6 @@ else fi -# Extract the first word of "gmake", so it can be a program name with args. -set dummy gmake; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:985: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_MAKE'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$MAKE" in - /*) - ac_cv_path_MAKE="$MAKE" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_MAKE="$MAKE" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_MAKE="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_path_MAKE" && ac_cv_path_MAKE="no" - ;; -esac -fi -MAKE="$ac_cv_path_MAKE" -if test -n "$MAKE"; then - echo "$ac_t""$MAKE" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - -if test $MAKE = no; then - unset ac_cv_path_MAKE - # Extract the first word of "make", so it can be a program name with args. -set dummy make; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1023: checking for $ac_word" >&5 -if eval "test \"`echo '$''{'ac_cv_path_MAKE'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - case "$MAKE" in - /*) - ac_cv_path_MAKE="$MAKE" # Let the user override the test with a path. - ;; - ?:/*) - ac_cv_path_MAKE="$MAKE" # Let the user override the test with a dos path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" - ac_dummy="$PATH" - for ac_dir in $ac_dummy; do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - ac_cv_path_MAKE="$ac_dir/$ac_word" - break - fi - done - IFS="$ac_save_ifs" - test -z "$ac_cv_path_MAKE" && ac_cv_path_MAKE="no" - ;; -esac -fi -MAKE="$ac_cv_path_MAKE" -if test -n "$MAKE"; then - echo "$ac_t""$MAKE" 1>&6 -else - echo "$ac_t""no" 1>&6 -fi - - if test $MAKE = no; then - { echo "configure: error: can't locate a make." 1>&2; exit 1; } - exit 1 - fi -fi -echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:1062: checking whether ${MAKE-make} sets \${MAKE}" >&5 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` -if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftestmake <<\EOF -all: - @echo 'ac_maketemp="${MAKE}"' -EOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` -if test -n "$ac_maketemp"; then - eval ac_cv_prog_make_${ac_make}_set=yes -else - eval ac_cv_prog_make_${ac_make}_set=no -fi -rm -f conftestmake -fi -if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$ac_t""yes" 1>&6 - SET_MAKE= -else - echo "$ac_t""no" 1>&6 - SET_MAKE="MAKE=${MAKE-make}" -fi - - # Find an appropriate tar for use in "dist" targets. A "best guess" # is good enough -- if we can't find GNU tar, we don't really care. for ac_prog in gnutar gtar tar @@ -1092,7 +2232,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1096: checking for $ac_word" >&5 +echo "configure:2236: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_TAR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1127,7 +2267,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1131: checking for $ac_word" >&5 +echo "configure:2271: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AUTOMAKE'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1169,7 +2309,7 @@ done # 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:1173: checking for a BSD compatible install" >&5 +echo "configure:2313: 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 @@ -1224,7 +2364,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Extract the first word of "perl5", so it can be a program name with args. set dummy perl5; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1228: checking for $ac_word" >&5 +echo "configure:2368: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_PERLV_PATH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1262,7 +2402,7 @@ if test $PERLV_PATH = no; then # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1266: checking for $ac_word" >&5 +echo "configure:2406: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_PERLV_PATH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1307,13 +2447,13 @@ fi fi fi -ac_cv_PERLV=`basename $PERLV_PATH` +PERLV=`basename $PERLV_PATH` # Extract the first word of "expect", so it can be a program name with args. set dummy expect; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1317: checking for $ac_word" >&5 +echo "configure:2457: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_EXPECT_PATH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1355,7 +2495,7 @@ fi # Extract the first word of "ping", so it can be a program name with args. set dummy ping; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1359: checking for $ac_word" >&5 +echo "configure:2499: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_PING_PATH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1420,7 +2560,7 @@ rd_cv_rd_bin_datas=$RD_BIN_DATAS # RD_BIN_PROGS are bin/ .in's that need to be installed with execute perms. RD_BIN_PROGS="cat5rancid control_rancid \ alogin arancid clogin create_cvs blogin brancid do-diffs elogin erancid \ -flogin francid jlogin jrancid hlogin hrancid par rancid-fe \ +flogin francid jlogin jrancid hlogin hrancid mrancid par rancid-fe \ rancid rename rrancid xrancid" rd_cv_rd_bin_progs=$RD_BIN_PROGS @@ -1447,7 +2587,7 @@ ENV_PATH="$ENV_PATH:`dirname $DIRNAME`:`dirname $DIFF`" # Extract the first word of "cvs", so it can be a program name with args. set dummy cvs; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1451: checking for $ac_word" >&5 +echo "configure:2591: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_CVS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1484,7 +2624,7 @@ ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_CVS`" # Extract the first word of "comm", so it can be a program name with args. set dummy comm; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1488: checking for $ac_word" >&5 +echo "configure:2628: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_COMM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1521,7 +2661,7 @@ ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_COMM`" # Extract the first word of "find", so it can be a program name with args. set dummy find; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1525: checking for $ac_word" >&5 +echo "configure:2665: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_FIND'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1558,7 +2698,7 @@ ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_FIND`" # Extract the first word of "grep", so it can be a program name with args. set dummy grep; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1562: checking for $ac_word" >&5 +echo "configure:2702: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GREP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1595,7 +2735,7 @@ ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_GREP`" # Extract the first word of "id", so it can be a program name with args. set dummy id; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1599: checking for $ac_word" >&5 +echo "configure:2739: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_ID'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1632,7 +2772,7 @@ ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_ID`" # Extract the first word of "mkdir", so it can be a program name with args. set dummy mkdir; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1636: checking for $ac_word" >&5 +echo "configure:2776: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_MKDIR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1669,7 +2809,7 @@ ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_MKDIR`" # Extract the first word of "rsh", so it can be a program name with args. set dummy rsh; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1673: checking for $ac_word" >&5 +echo "configure:2813: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_RSH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1706,7 +2846,7 @@ ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_RSH`" # Extract the first word of "sort", so it can be a program name with args. set dummy sort; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1710: checking for $ac_word" >&5 +echo "configure:2850: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_SORT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1743,7 +2883,7 @@ ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_SORT`" # Extract the first word of "ssh", so it can be a program name with args. set dummy ssh; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1747: checking for $ac_word" >&5 +echo "configure:2887: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_SSH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1783,7 +2923,7 @@ unset ac_cv_path_SSH # Extract the first word of "telnet", so it can be a program name with args. set dummy telnet; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1787: checking for $ac_word" >&5 +echo "configure:2927: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TELNET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1820,7 +2960,7 @@ ENV_PATH="$ENV_PATH:`dirname $ac_cv_path_TELNET`" # Extract the first word of "touch", so it can be a program name with args. set dummy touch; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1824: checking for $ac_word" >&5 +echo "configure:2964: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TOUCH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1924,19 +3064,7 @@ 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 - +DEFS=-DHAVE_CONFIG_H # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} @@ -1974,8 +3102,16 @@ done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr `echo "Makefile \ - man/Makefile man/env.5 man/lg.conf.5 man/lg_intro.1" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo " Makefile include/Makefile bin/Makefile util/Makefile \ + bin/alogin bin/arancid bin/blogin bin/brancid bin/cat5rancid \ + bin/clogin bin/control_rancid bin/create_cvs bin/do-diffs bin/elogin \ + bin/env bin/erancid bin/flogin bin/francid bin/jlogin bin/jrancid \ + bin/hlogin \ + bin/hrancid bin/mrancid bin/par bin/rancid-fe bin/rancid bin/rename \ + bin/rrancid bin/xrancid \ + man/Makefile man/env.5 man/lg.conf.5 man/lg_intro.1 \ + include/version.h \ + util/rtrfilter util/downreport include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then @@ -2152,12 +3300,123 @@ s%@INSTALL@%$INSTALL%g fi; done rm -f conftest.s* +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; 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 + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # 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" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +test -z "$CONFIG_HEADERS" || echo timestamp > include/stamp-h +\ + chmod a+x bin/*login bin/*rancid bin/par + exit 0 EOF chmod +x $CONFIG_STATUS @@ -2189,7 +3448,7 @@ if test "$no_recursion" != yes; then esac done - for ac_config_dir in bin util; do + for ac_config_dir in util; do # Do not complain, so a configure script can configure whichever # parts of a large source tree are present. diff --git a/configure.in b/configure.in index 698d307..dbd4cfb 100644 --- a/configure.in +++ b/configure.in @@ -1,22 +1,64 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT() -AM_INIT_AUTOMAKE(PACKAGE, VERSION) +AC_PREREQ(2.13) +AC_INIT(CHANGES) -AC_CONFIG_SUBDIRS(bin util) +dnl VERSION needs to be updated such that 'make dist' uses the correct +dnl filename for the directory name and tarball. +VERSION=`sed -n 's/.*version.*"\(.*\)".*/\1/p' $srcdir/include/version.h.in|tr -d ' '` +PACKAGE=`sed -n 's/.*package.*"\(.*\)".*/\1/p' $srcdir/include/version.h.in|tr -d ' '` +AC_SUBST(VERSION) +AC_SUBST(PACKAGE) + +AM_INIT_AUTOMAKE($PACKAGE, $VERSION) + +AM_CONFIG_HEADER(include/config.h) dnl default install location AC_PREFIX_DEFAULT(/usr/local/rancid) -AC_SUBST(PACKAGE) -PACKAGE=rancid +AM_MAINTAINER_MODE() -# VERSION needs to be updated such that 'make dist' uses the correct -# filename for the directory name and tarball. -AC_SUBST(VERSION) -VERSION=2.2b8 +dnl AC_CONFIG_SUBDIRS(bin util) +AC_CONFIG_SUBDIRS(util) -AM_MAINTAINER_MODE() +# make sure MAKE sets ${MAKE} +AC_PATH_PROG(MAKE,gmake,no) +if test $MAKE = no; then + unset ac_cv_path_MAKE + AC_PATH_PROG(MAKE,make,no) + if test $MAKE = no; then + AC_MSG_ERROR([can't locate a make.]) + exit 1 + fi +fi +AC_PROG_MAKE_SET() + +# compiler specifics +AC_PROG_CC +AM_C_PROTOTYPES +AC_PROG_CPP +AC_C_CONST +AC_C_INLINE +AC_C_STRINGIZE + +# check includes/headers +AC_HEADER_STDC +AC_CHECK_HEADERS(limits.h memory.h siginfo.h string.h strings.h unistd.h) + +AC_CHECK_HEADERS(errno.h fcntl.h sys/types.h sys/wait.h) +dnl AC_CHECK_HEADERS(errno.h stdlib.h sys/types.h sys/wait.h) +dnl AC_CHECK_HEADERS(malloc.h) +AC_CHECK_HEADERS(sysexits.h) + +# check functions +AC_CHECK_FUNCS(memcpy memmove memset bcopy bzero strerror strchr strrchr \ + strstr strtok strrtok index rindex) +dnl AC_FUNC_VPRINTF + +# type checks +AC_TYPE_SIGNAL +AC_TYPE_SIZE_T # Check for a preference for using mail addresses like rancid+admin-group # instead of the standard rancid-admin-group @@ -68,17 +110,6 @@ AC_SUBST(DIFF_CMD) AC_PATH_PROG(SENDMAIL,sendmail,no, /usr/sbin:/usr/bin:/usr/lib) -AC_PATH_PROG(MAKE,gmake,no) -if test $MAKE = no; then - unset ac_cv_path_MAKE - AC_PATH_PROG(MAKE,make,no) - if test $MAKE = no; then - AC_MSG_ERROR([can't locate a make.]) - exit 1 - fi -fi -AC_PROG_MAKE_SET() - # Find an appropriate tar for use in "dist" targets. A "best guess" # is good enough -- if we can't find GNU tar, we don't really care. AC_CHECK_PROGS(TAR, gnutar gtar tar) @@ -103,7 +134,7 @@ if test $PERLV_PATH = no; then fi fi AC_SUBST(PERLV_PATH) -ac_cv_PERLV=`basename $PERLV_PATH` +PERLV=`basename $PERLV_PATH` AC_SUBST(PERLV) AC_PATH_PROG(EXPECT_PATH,expect,no) @@ -146,7 +177,7 @@ rd_cv_rd_bin_datas=$RD_BIN_DATAS # RD_BIN_PROGS are bin/ .in's that need to be installed with execute perms. RD_BIN_PROGS="cat5rancid control_rancid \ alogin arancid clogin create_cvs blogin brancid do-diffs elogin erancid \ -flogin francid jlogin jrancid hlogin hrancid par rancid-fe \ +flogin francid jlogin jrancid hlogin hrancid mrancid par rancid-fe \ rancid rename rrancid xrancid" AC_SUBST(RD_BIN_PROGS) rd_cv_rd_bin_progs=$RD_BIN_PROGS @@ -202,8 +233,18 @@ ENV_PATH=`echo $ENV_PATH | $PERLV_PATH -e 'foreach $x(split(":",<>)){next unless ac_cv_env_path=$ENV_PATH AC_SUBST(ENV_PATH) -AC_OUTPUT(Makefile \ - man/Makefile man/env.5 man/lg.conf.5 man/lg_intro.1) +AC_OUTPUT([ Makefile include/Makefile bin/Makefile util/Makefile \ + bin/alogin bin/arancid bin/blogin bin/brancid bin/cat5rancid \ + bin/clogin bin/control_rancid bin/create_cvs bin/do-diffs bin/elogin \ + bin/env bin/erancid bin/flogin bin/francid bin/jlogin bin/jrancid \ + bin/hlogin \ + bin/hrancid bin/mrancid bin/par bin/rancid-fe bin/rancid bin/rename \ + bin/rrancid bin/xrancid \ + man/Makefile man/env.5 man/lg.conf.5 man/lg_intro.1 \ + include/version.h \ + util/rtrfilter util/downreport ], \ + [ chmod a+x bin/*login bin/*rancid bin/par ] + ) # fix permissions on scripts. for file in $progs; do chmod a+x $file; done diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..23fb6fe --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1,12 @@ +## Process this file with automake to produce Makefile.in +## A Makefile.in is supplied, in case you do not have automake. + +#AUTOMAKE_OPTIONS=foreign no-dependencies +AUTOMAKE_OPTIONS=foreign + +noinst_HEADERS= config.h version.h + +@SET_MAKE@ + +all: + diff --git a/include/Makefile.in b/include/Makefile.in new file mode 100644 index 0000000..deda786 --- /dev/null +++ b/include/Makefile.in @@ -0,0 +1,264 @@ +# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am + +# 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 + +noinst_HEADERS = config.h version.h +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = version.h +HEADERS = $(noinst_HEADERS) + +DIST_COMMON = ./stamp-h.in Makefile.am Makefile.in config.h.in \ +version.h.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps include/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +config.h: stamp-h + @if test ! -f $@; then \ + rm -f stamp-h; \ + $(MAKE) stamp-h; \ + else :; fi +stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES= CONFIG_HEADERS=include/config.h \ + $(SHELL) ./config.status + @echo timestamp > stamp-h 2> /dev/null +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@$(srcdir)/stamp-h.in + @if test ! -f $@; then \ + rm -f $(srcdir)/stamp-h.in; \ + $(MAKE) $(srcdir)/stamp-h.in; \ + else :; fi +$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOHEADER) + @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null + +mostlyclean-hdr: + +clean-hdr: + +distclean-hdr: + -rm -f config.h + +maintainer-clean-hdr: +version.h: $(top_builddir)/config.status version.h.in + cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) config.h.in $(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)config.h.in$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$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 = include + +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 +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +all-recursive-am: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +install-exec-am: +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: uninstall-am +all-am: Makefile $(HEADERS) config.h +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + + +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-hdr mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-hdr clean-tags clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-hdr distclean-tags distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-hdr 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-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ +tags mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ +distdir info-am info dvi-am dvi check check-am installcheck-am \ +installcheck all-recursive-am 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 + + +@SET_MAKE@ + +all: + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/include/config.h b/include/config.h new file mode 100644 index 0000000..50a84e7 --- /dev/null +++ b/include/config.h @@ -0,0 +1,177 @@ +/* include/config.h. Generated automatically by configure. */ +/* include/config.h.in. Generated automatically from configure.in by autoheader. */ +#ifndef CONFIG_H +#define CONFIG_H 1 + + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if you have the ANSI # stringizing operator in cpp. */ +#define HAVE_STRINGIZE 1 + +/* Define as __inline if that's what the C compiler calls it. */ +/* #undef inline */ + +/* Define as the return type of signal handlers (int or void). */ +#define RETSIGTYPE void + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you have the bcopy function. */ +#define HAVE_BCOPY 1 + +/* Define if you have the bzero function. */ +#define HAVE_BZERO 1 + +/* Define if you have the index function. */ +#define HAVE_INDEX 1 + +/* Define if you have the memcpy function. */ +#define HAVE_MEMCPY 1 + +/* Define if you have the memmove function. */ +#define HAVE_MEMMOVE 1 + +/* Define if you have the memset function. */ +#define HAVE_MEMSET 1 + +/* Define if you have the rindex function. */ +#define HAVE_RINDEX 1 + +/* Define if you have the strchr function. */ +#define HAVE_STRCHR 1 + +/* Define if you have the strerror function. */ +#define HAVE_STRERROR 1 + +/* Define if you have the strrchr function. */ +#define HAVE_STRRCHR 1 + +/* Define if you have the strrtok function. */ +/* #undef HAVE_STRRTOK */ + +/* Define if you have the strstr function. */ +#define HAVE_STRSTR 1 + +/* Define if you have the strtok function. */ +#define HAVE_STRTOK 1 + +/* Define if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define if you have the header file. */ +/* #undef HAVE_SIGINFO_H */ + +/* Define if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Name of package */ +#define PACKAGE "rancid" + +/* Version number of package */ +#define VERSION "2.2" + +/* Define if compiler has function prototypes */ +#define PROTOTYPES 1 + + +#ifndef __P +# if STDC_HEADERS +# define __P(a) a +# else +# define __P(a) () +# endif +#endif + +#define BUF_SZ LINE_MAX /* (increments of) size of bufs */ + +#if HAVE_STDLIB_H +# include +#endif + +#if HAVE_UNISTD_H +# include +# include +#elif HAVE_SYS_TYPES_H +# include +#endif + +#if HAVE_ERRNO_H +# include +#endif +extern int errno; + +#if HAVE_STRING_H +# include +#endif +#if HAVE_STRINGS_H +# include +#endif + +#if ! HAVE_STRERROR +# define strerror(n) sys_errlist[n]; +#endif + +#if HAVE_SYS_WAIT_H +# include +#endif +#ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif +#ifndef WIFEXITED +# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif + +#if HAVE_MEMSET +# define bzero(p,s) memset(p, 0, s) +# define bcopy(s,d,l) memcpy(d, s, l) +#endif + +#if HAVE_INDEX && ! HAVE_STRCHR +# define index(s,c) strchr(s,c) +#endif + +#if HAVE_SYSEXITS_H +# include +#else + /* missing sysexits.h */ +# define EX_OK 0 +# define EX_USAGE 64 /* command line usage error */ +# define EX_NOINPUT 66 /* cannot open input */ +# define EX_TEMPFAIL 75 /* temp failure */ +# define EX_OSERR 71 /* system error */ +# define EX_CANTCREAT 73 /* can't create (user) output file */ +# define EX_IOERR 74 /* input/output error */ +# define EX_CONFIG 78 /* configuration error */ +#endif + +#endif /* CONFIG_H */ diff --git a/include/config.h.in b/include/config.h.in new file mode 100644 index 0000000..8d5931b --- /dev/null +++ b/include/config.h.in @@ -0,0 +1,176 @@ +/* include/config.h.in. Generated automatically from configure.in by autoheader. */ +#ifndef CONFIG_H +#define CONFIG_H 1 + + +/* Define to empty if the keyword does not work. */ +#undef const + +/* Define if you have the ANSI # stringizing operator in cpp. */ +#undef HAVE_STRINGIZE + +/* Define as __inline if that's what the C compiler calls it. */ +#undef inline + +/* Define as the return type of signal handlers (int or void). */ +#undef RETSIGTYPE + +/* Define to `unsigned' if doesn't define. */ +#undef size_t + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define if you have the bcopy function. */ +#undef HAVE_BCOPY + +/* Define if you have the bzero function. */ +#undef HAVE_BZERO + +/* Define if you have the index function. */ +#undef HAVE_INDEX + +/* Define if you have the memcpy function. */ +#undef HAVE_MEMCPY + +/* Define if you have the memmove function. */ +#undef HAVE_MEMMOVE + +/* Define if you have the memset function. */ +#undef HAVE_MEMSET + +/* Define if you have the rindex function. */ +#undef HAVE_RINDEX + +/* Define if you have the strchr function. */ +#undef HAVE_STRCHR + +/* Define if you have the strerror function. */ +#undef HAVE_STRERROR + +/* Define if you have the strrchr function. */ +#undef HAVE_STRRCHR + +/* Define if you have the strrtok function. */ +#undef HAVE_STRRTOK + +/* Define if you have the strstr function. */ +#undef HAVE_STRSTR + +/* Define if you have the strtok function. */ +#undef HAVE_STRTOK + +/* Define if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define if you have the header file. */ +#undef HAVE_SIGINFO_H + +/* Define if you have the header file. */ +#undef HAVE_STRING_H + +/* Define if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_WAIT_H + +/* Define if you have the header file. */ +#undef HAVE_SYSEXITS_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Name of package */ +#undef PACKAGE + +/* Version number of package */ +#undef VERSION + +/* Define if compiler has function prototypes */ +#undef PROTOTYPES + + +#ifndef __P +# if STDC_HEADERS +# define __P(a) a +# else +# define __P(a) () +# endif +#endif + +#define BUF_SZ LINE_MAX /* (increments of) size of bufs */ + +#if HAVE_STDLIB_H +# include +#endif + +#if HAVE_UNISTD_H +# include +# include +#elif HAVE_SYS_TYPES_H +# include +#endif + +#if HAVE_ERRNO_H +# include +#endif +extern int errno; + +#if HAVE_STRING_H +# include +#endif +#if HAVE_STRINGS_H +# include +#endif + +#if ! HAVE_STRERROR +# define strerror(n) sys_errlist[n]; +#endif + +#if HAVE_SYS_WAIT_H +# include +#endif +#ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif +#ifndef WIFEXITED +# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif + +#if HAVE_MEMSET +# define bzero(p,s) memset(p, 0, s) +# define bcopy(s,d,l) memcpy(d, s, l) +#endif + +#if HAVE_INDEX && ! HAVE_STRCHR +# define index(s,c) strchr(s,c) +#endif + +#if HAVE_SYSEXITS_H +# include +#else + /* missing sysexits.h */ +# define EX_OK 0 +# define EX_USAGE 64 /* command line usage error */ +# define EX_NOINPUT 66 /* cannot open input */ +# define EX_TEMPFAIL 75 /* temp failure */ +# define EX_OSERR 71 /* system error */ +# define EX_CANTCREAT 73 /* can't create (user) output file */ +# define EX_IOERR 74 /* input/output error */ +# define EX_CONFIG 78 /* configuration error */ +#endif + +#endif /* CONFIG_H */ diff --git a/include/stamp-h.in b/include/stamp-h.in new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/include/stamp-h.in @@ -0,0 +1 @@ +timestamp diff --git a/include/version.h b/include/version.h new file mode 100644 index 0000000..d70f183 --- /dev/null +++ b/include/version.h @@ -0,0 +1,9 @@ +#ifndef VERSION_H + +#define VERSION_H + +/* pkg version */ +char package[] = "rancid"; +char version[] = "2.2"; + +#endif diff --git a/include/version.h.in b/include/version.h.in new file mode 100644 index 0000000..d70f183 --- /dev/null +++ b/include/version.h.in @@ -0,0 +1,9 @@ +#ifndef VERSION_H + +#define VERSION_H + +/* pkg version */ +char package[] = "rancid"; +char version[] = "2.2"; + +#endif diff --git a/man/Makefile.am b/man/Makefile.am index 845cba6..b9e5b04 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -9,11 +9,16 @@ man_gen_MANS = env.5 lg.conf.5 lg_intro.1 man_nogen_MANS = do-diffs.1 alogin.1 blogin.1 clogin.1 control_rancid.1 \ create_cvs.1 rancid.1 \ rancid_intro.1 cloginrc.5 router.db.5 \ - elogin.1 flogin.1 jlogin.1 \ - jrancid.1 francid.1 cat5rancid.1 erancid.1 xrancid.1 + elogin.1 flogin.1 hlogin.1 hrancid.1 jlogin.1 \ + jrancid.1 francid.1 cat5rancid.1 erancid.1 mrancid.1 \ + par.1 xrancid.1 man_MANS = $(man_gen_MANS) $(man_nogen_MANS) EXTRA_DIST = $(man_nogen_MANS) -CLEANFILES = Makefile env.5 lg.conf.5 lg_intro.1 +#CLEANFILES = Makefile env.5 lg.conf.5 lg_intro.1 + +all: + +distclean: clean diff --git a/man/Makefile.in b/man/Makefile.in index 598e4f7..ae55555 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -1,6 +1,6 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am +# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am -# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# 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. @@ -58,7 +58,9 @@ NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : AUTOMAKE = @AUTOMAKE@ +CC = @CC@ COMM = @COMM@ +CPP = @CPP@ CVS = @CVS@ DIFF = @DIFF@ DIFF_CMD = @DIFF_CMD@ @@ -90,20 +92,20 @@ SSH = @SSH@ TAR = @TAR@ TELNET = @TELNET@ TOUCH = @TOUCH@ +U = @U@ VERSION = @VERSION@ AUTOMAKE_OPTIONS = foreign no-dependencies man_gen_MANS = env.5 lg.conf.5 lg_intro.1 -man_nogen_MANS = do-diffs.1 alogin.1 blogin.1 clogin.1 control_rancid.1 create_cvs.1 rancid.1 rancid_intro.1 cloginrc.5 router.db.5 elogin.1 flogin.1 jlogin.1 jrancid.1 francid.1 cat5rancid.1 erancid.1 xrancid.1 +man_nogen_MANS = do-diffs.1 alogin.1 blogin.1 clogin.1 control_rancid.1 create_cvs.1 rancid.1 rancid_intro.1 cloginrc.5 router.db.5 elogin.1 flogin.1 hlogin.1 hrancid.1 jlogin.1 jrancid.1 francid.1 cat5rancid.1 erancid.1 mrancid.1 par.1 xrancid.1 man_MANS = $(man_gen_MANS) $(man_nogen_MANS) EXTRA_DIST = $(man_nogen_MANS) - -CLEANFILES = Makefile env.5 lg.conf.5 lg_intro.1 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../include/config.h CONFIG_CLEAN_FILES = env.5 lg.conf.5 lg_intro.1 man1dir = $(mandir)/man1 man5dir = $(mandir)/man5 @@ -216,7 +218,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ @@ -253,7 +255,6 @@ installdirs: mostlyclean-generic: clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) @@ -289,6 +290,12 @@ mostlyclean distclean maintainer-clean @SET_MAKE@ +#CLEANFILES = Makefile env.5 lg.conf.5 lg_intro.1 + +all: + +distclean: clean + # 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/man/clogin.1 b/man/clogin.1 index d257a5f..a888d99 100644 --- a/man/clogin.1 +++ b/man/clogin.1 @@ -49,16 +49,23 @@ router .B clogin is an .BR expect (1) -script to automate the process of logging into a Cisco router, catalyst -switch, Extreme switch, or Redback router. There are complementary scripts -for Alteon, Bay Networks (nortel), Juniper, Foundry, and ADC-kentrox EZ-T3 mux -named +script to automate the process of logging into a Cisco router, +catalyst switch, Extreme switch, or Redback router. There are +complementary scripts for +Alteon, +Bay Networks (nortel), +ADC-kentrox EZ-T3 mux, +Foundry, +HP Procurve Switches, +and Juniper, +named .B alogin, .B blogin, -.B jlogin, +.B elogin, .B flogin, +.B hlogin, and -.B elogin, +.B jlogin, respectively. .PP .B clogin @@ -202,5 +209,16 @@ configuration file. .SH "SEE ALSO" .BR cloginrc (5), .BR expect (1) +.SH CAVEATS +The HP Procurve switches that are Foundry OEMs use flogin, not hlogin. .SH BUGS All these login scripts for separate devices should be rolled into one. +.PP +The HP Procurve switch CLI relies heavily upon curses based cursor/screen +manipulation and assumes a vt100 terminal type. They do not provide a way +to set a different terminal type or adjust this behavior. The resulting +escape codes make automating interaction with these devices very difficult +or impossible. Therefore, bin/hpfilter is used by hlogin to filter these. +While this works for rancid's collection, there are side effects for +interactive logins via hlogin; most of which are formatting annoyances that +may be remedied by hitting CTRL-R to reprint the current line. diff --git a/man/cloginrc.5 b/man/cloginrc.5 index d9ee4ed..e91bfea 100644 --- a/man/cloginrc.5 +++ b/man/cloginrc.5 @@ -7,9 +7,11 @@ .B .cloginrc contains configuration information for .BR alogin (1), +.BR blogin (1), .BR clogin (1), .BR elogin (1), .BR flogin (1), +.BR hlogin (1), and .BR jlogin (1), such as usernames, passwords, ssh encryption type, etc., and is read at @@ -23,7 +25,7 @@ Each line containing a directive is of the form: .PP .in +1i .nf -add {} [{} ...] +add {} [{} ...] .sp or .sp @@ -34,7 +36,7 @@ include {} As .B .cloginrc is searched for a directive for a hostname, it is always the first instance -of a directive, whose hostname regular expression matches the hostname, that +of a directive, whose hostname glob expression matches the hostname, that is used. For example; looking up the password for hostname foo in a .B .cloginrc file containing @@ -70,7 +72,7 @@ The accepted directives are (alphabetically): .PP .\" .TP -.B add autoenable {[01]} +.B add autoenable {[01]} When using locally defined usernames or AAA, it is possible to have a login which is automatically enabled. This is, that user has enable privileges without the need to execute the enable command. The router's prompt is @@ -87,7 +89,7 @@ should execute the enable command to gain enable privileges, unless negated by the noenable directive or \-noenable command\-line option. .\" .TP -.B add cyphertype {} +.B add cyphertype {} cyphertype defines which encryption algorithm is used with ssh. A device may not support the type ssh uses by default. See .BR ssh (1)'s\c @@ -96,7 +98,7 @@ may not support the type ssh uses by default. See Default: {3des} .\" .TP -.B add enableprompt {""} +.B add enableprompt {""} When using AAA with a Cisco router or switch, it is possible to redefine the prompt the device presents to the user for the enable password. enableprompt may be used to adjust the prompt that @@ -109,35 +111,47 @@ Example: add enableprompt rc*.example.net {"\\[Ee]nter the enable password:"} Default: "\\[Pp]assword:" .\" .TP -.B add enauser {} +.B add enauser {} This is only needed if a device prompts for a username when gaining enable privileges and where this username is different from that defined by or the default of the user directive. .\" .TP -.B add identity {} +.B add identity {} May be used to specify an alternate identity file for use with ssh(1). See ssh's \-i option for details. .sp Default: your default identity file. see ssh(1). .\" .TP -.B add method {ssh} [{...}] +.B add method {ssh} [{...}] Defines, in order, the connection methods to use for a device from the -set {ssh, telnet, rsh}. -.sp -Example: add method * {ssh} {telnet} {rsh} +set {ssh, telnet, rsh}. Method telnet may have a suffix, indicating an +alternate TCP port, of the form ":port". +.sp +Note: Different versions of telnet treat the specification of a +port differently. In particular, BSD derived telnets do not do +option negotiation when a port is given. Some devices, Extreme +switches for example, have undesirable telnet default options such +as linemode. In the BSD case, to enable option negotiation when +specifying a port the method should be "{telnet:-23}" or you should +add "mode character" to .telnetrc. See +.BR telnet (1) +for more information on telnet command-line syntax, telnet options, +and .telnetrc. +.sp +Example: add method * {ssh} {telnet:3000} {rsh} .sp Which would cause .IR clogin -to first attempt an ssh connection to the device and if that were to -fail with connection refused, a telnet connection would be tried, and -then rsh. +to first attempt an ssh connection to the device and if that were +to fail with connection refused, a telnet connection to port 3000 +would be tried, and then a rsh connection. .sp Default: {telnet} {ssh} .\" .TP -.B add noenable +.B add noenable .IR clogin will not try to gain enable privileges when noenable is matched for a device. This is equivalent to @@ -146,7 +160,7 @@ device. This is equivalent to .BR jlogin (1). .\" .TP -.B add passprompt {""} +.B add passprompt {""} When using AAA with a Cisco router or switch, it is possible to redefine the prompt the device presents to the user for the password. passprompt may be used to adjust the prompt that @@ -159,14 +173,14 @@ Example: add passprompt rc*.example.net {"\\[Ee]nter the password:"} Default: "(\\[Pp]assword|passwd):" .\" .TP -.B add password {} [{}] +.B add password {} [{}] Specifies a vty password, that which is prompted for upon the connection to the router. The last argument is the enable password and need not be specified if the device also has a matching noenable or autoenable directive or the corresponding command-line options are used. .\" .\" .TP -.\" .B add rc {} +.\" .B add rc {} .\" rc is used to specifies a command that will be run by .\" .IR clogin .\" immediately after logging into the device. Multiple commands may be @@ -177,7 +191,7 @@ directive or the corresponding command-line options are used. .\" Example: add rc *.domain.net {terminal monitor;show version} .\" .TP -.B add user {} +.B add user {} Specifies a username .IR clogin should use if or when prompted for one. @@ -185,12 +199,12 @@ should use if or when prompted for one. Default: $USER, ie: your Unix username. .\" .TP -.B add userpassword {} +.B add userpassword {} Specifies a password to be associated with a user, if different from that defined with the password directive. .\" .TP -.B add userprompt {""} +.B add userprompt {""} When using AAA with a Cisco router or switch, it is possible to redefine the prompt the device presents to the user for the username. userprompt may be used to adjust the prompt that @@ -229,4 +243,5 @@ Example: include {.cloginrc.group} is interpreted directly by Tcl, so its syntax follows that of Tcl. Errors may produce quite unexpected results. .SH "SEE ALSO" -.BR clogin (1) +.BR clogin (1), +.BR glob (3) diff --git a/man/control_rancid.1 b/man/control_rancid.1 index b5b31c4..8bd719f 100644 --- a/man/control_rancid.1 +++ b/man/control_rancid.1 @@ -5,6 +5,9 @@ control_rancid \- run rancid for devices of a group .SH SYNOPSIS .B create_cvs +[\c +.BI \-r\ \c +device_name]\ \c group .SH DESCRIPTION .B control_rancid @@ -16,6 +19,14 @@ run rancid for each of the devices, possibly re-run rancid for missed devices, e-mail diffs, and e-mail error reports. .\" .PP +.\" +The command-line options are as follows: +.TP +.B \-r device_name +Specify the name, as it appears in the router.db, of a particular device +to collect and generate diffs for. The device must be marked "up". +.\" +.PP .B control_rancid is normally (and best) run via .BR do-diffs (1). diff --git a/man/do-diffs.1 b/man/do-diffs.1 index cb42bb5..6202227 100644 --- a/man/do-diffs.1 +++ b/man/do-diffs.1 @@ -5,6 +5,9 @@ do-diffs \- run rancid for each of the groups .SH SYNOPSIS .B do-diffs +[\c +.BI \-r\ \c +device_name]\ \c [group [group ...]] .SH DESCRIPTION .B do-diffs @@ -53,6 +56,16 @@ For example: .fi .in -1i .\" +.PP +.\" +The command-line options are as follows: +.TP +.B \-r device_name +Specify the name, as it appears in a group's router.db, of a particular +device to collect and generate diffs for. The device must be marked "up". +If a group is not specified on the command-line, rancid will be run +against any group in which the device_name appears. +.\" .SH ENVIRONMENT .B do-diffs utilizes the following environment variables from @@ -92,4 +105,5 @@ configuration file. .El .SH SEE ALSO .BR control_rancid (1), +.BR router.db (5), .BR env (5) diff --git a/man/env.5.in b/man/env.5.in index 854edbb..1050ac7 100644 --- a/man/env.5.in +++ b/man/env.5.in @@ -45,6 +45,17 @@ not be necessary to alter CVSROOT. Default: $BASEDIR/CVS .\" .TP +.B FILTER_PWDS +Determines which passwords will be filtered from configs. The value may be +"NO", "YES", or "ALL" to filter none of the passwords, only those which are +reversable or plain-text, or all (plus ssh keys, etc), respectively. +Note that passwords whose value cycles and would produce erroneous diffs +are always filtered (eg: Alteon passwords). Note that a value of "NO" could +be a security issue. +.sp +Default: YES +.\" +.TP .B LIST_OF_GROUPS Defines a list of group names of routers separated by white-space. These names become the directory names in $BASEDIR which contain the data @@ -112,9 +123,9 @@ will start simultaneously as .IR control_rancid (1) attempts to perform collections. Raising this value will decrease the amount of time necessary for a complete collection of a (or all) rancid groups at the -of system load. The default is relatively cautious. If collections are not -completing quickly enough for users, use trial and error of speed versus -system load to find a suitable value. +expense of system load. The default is relatively cautious. If collections +are not completing quickly enough for users, use trial and error of speed +versus system load to find a suitable value. .sp Default: 5 .\" diff --git a/man/hlogin.1 b/man/hlogin.1 new file mode 100644 index 0000000..4c83247 --- /dev/null +++ b/man/hlogin.1 @@ -0,0 +1 @@ +.so man1/clogin.1 diff --git a/man/hrancid.1 b/man/hrancid.1 new file mode 100644 index 0000000..b4633ee --- /dev/null +++ b/man/hrancid.1 @@ -0,0 +1 @@ +.so man1/rancid.1 diff --git a/man/lg.conf.5.in b/man/lg.conf.5.in index 3b07f75..cb052f7 100644 --- a/man/lg.conf.5.in +++ b/man/lg.conf.5.in @@ -70,6 +70,14 @@ simply handed off to print(). Example: $LG_IMAGE="\n FOO"; .\" .TP +.B LG_INFO +Defines information in html format which, if defined, will be included at +the bottom of the looking glass form page. It may contain any html as it is +simply handed off to print(). +.sp +Example: $LG_INFO="For Support contact webmaster"; +.\" +.TP .B LG_LOG Defines the fully qualified path name for the log file or the .BR syslog (3) @@ -87,7 +95,7 @@ Sets the location for the file in rancid's .BR router.db (5) format. It lists the devices that should be available to the looking glass -users. Only those devices of supported types and with status 'up' are made +users. Only those devices of supported types and with state 'up' are made available. If not defined and the default file does not exist, the looking glass will compile a list from the router.db files of all the groups present in rancid, that is a concatenation of $BASEDIR/*/router.db. @@ -108,7 +116,7 @@ debugging clogin problems. .\" .TP .B PATH -Is a colon separated list of directory pathnames in the the file system +Is a colon separated list of directory pathnames in the file system where rancid's login scripts, .IR clogin (1) etc. ) @@ -133,7 +141,11 @@ results. Configuration file described here, where $BASEDIR is set at the time that the rancid package was configured. In this case, $BASEDIR is .IR @prefix@ . +.B lg.conf +is located by the value of the environment variable LG_CONF, in the CWD +(current working directory), or rancid install directory ($BASEDIR/util/lg). .El .SH SEE ALSO .BR cloginrc (5), -.BR lg_intro (1) +.BR lg_intro (1), +.BR router.db (5) diff --git a/man/mrancid.1 b/man/mrancid.1 new file mode 100644 index 0000000..b4633ee --- /dev/null +++ b/man/mrancid.1 @@ -0,0 +1 @@ +.so man1/rancid.1 diff --git a/man/par.1 b/man/par.1 new file mode 100644 index 0000000..b0f0cee --- /dev/null +++ b/man/par.1 @@ -0,0 +1,109 @@ +.\" +.hys 50 +.TH "par" "1" "17 Nov 2001" +.SH NAME +par \- parallel command processing +.SH SYNOPSIS +.B par +[\fB\-diqx\fP] +[\c +.BI \-c\ +command] +[\c +.BI \-l\ +logfile] +[\c +.BI \-n\c + #] +file +[file...] +.SH DESCRIPTION +.B par +takes a list of files to run a command on. The first line of each file begins +with a colon (:) or a pound-sign (#). If a colon, the remainder of the +line is a command to run for each of the subsequent lines. If a pound-sign, +then each subsequent line is command, unless the +.B \-c +option was specified, in which case it operates as if the argument to +.B \-c +had followed a colon on the first line. +.PP +In each of the cases where the lines of the file following the first are +not commands (ie: colon or -c), instances of open-close braces ({}) in the +command will be replaced by these values. +.PP +For example, a inputfile whose contents is: +.sp + : echo {} +.br + a +.br + b +.br + c +.sp +run with +.B par +like so: +.sp + %par -q inputfile +.sp +will produce the following output (order will vary): +.sp + b +.br + a +.br + c +.PP +The command-line options are as follows: +.PP +.TP +.B \-c +Command to be run on each each of the arguments following the command-line +options, when the first line of the input file(s) begin with a pound-sign +(#). +.\" +.TP +.B \-d +Print debugging information on standard error (stderr). +.\" +.TP +.B \-i +Run commands interactively though (multiple) +.BR xterm (1) +processes. +.\" +.TP +.B \-l +Prefix of logfile name, as in prefix.N where N is the +.B par +process number ([0..]). +.sp +Default: par.log.