summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTar Committer <tar@ocjtech.us>2006-05-04 21:40:56 +0000
committerTar Committer <tar@ocjtech.us>2006-05-04 21:40:56 +0000
commit1cc9f22072de1d314a67387aac57740fb25c5258 (patch)
treef59aa9d622175580add0923bfac8963dc946e98e
parentc0482931956d127b5f09d4a8d72758cd4cb1f097 (diff)
downloadrancid-1cc9f22072de1d314a67387aac57740fb25c5258.zip
rancid-1cc9f22072de1d314a67387aac57740fb25c5258.tar.gz
rancid-1cc9f22072de1d314a67387aac57740fb25c5258.tar.xz
Imported from rancid-2.3.2a4.tar.gz.rancid-2.3.2a4
-rw-r--r--CHANGES45
-rw-r--r--FAQ37
-rw-r--r--Makefile.am6
-rw-r--r--Makefile.in11
-rw-r--r--README123
-rw-r--r--Todo11
-rw-r--r--acconfig.h78
-rw-r--r--aclocal.m44
-rw-r--r--bin/Makefile.in4
-rw-r--r--bin/arancid.in13
-rw-r--r--bin/brancid.in13
-rw-r--r--bin/cat5rancid.in13
-rw-r--r--bin/clogin.in22
-rw-r--r--bin/control_rancid.in35
-rw-r--r--bin/cssrancid.in13
-rw-r--r--bin/erancid.in13
-rw-r--r--bin/f10rancid.in13
-rw-r--r--bin/fnrancid.in13
-rw-r--r--bin/francid.in13
-rw-r--r--bin/hlogin.in29
-rw-r--r--bin/hpuifilter.c662
-rw-r--r--bin/hrancid.in13
-rw-r--r--bin/htrancid.in13
-rw-r--r--bin/jerancid.in13
-rw-r--r--bin/jrancid.in22
-rw-r--r--bin/lg.cgi.in6
-rw-r--r--bin/mrancid.in13
-rw-r--r--bin/nlogin.in4
-rw-r--r--bin/nrancid.in59
-rw-r--r--bin/nsrancid.in13
-rwxr-xr-xbin/prancid.in13
-rw-r--r--bin/rancid.in270
-rw-r--r--bin/rivrancid.in13
-rw-r--r--bin/rrancid.in13
-rw-r--r--bin/tntrancid.in13
-rw-r--r--bin/xrancid.in15
-rwxr-xr-xbin/zrancid.in13
-rwxr-xr-xconfigure476
-rw-r--r--configure.in135
-rw-r--r--etc/Makefile.in2
-rw-r--r--include/Makefile.in4
-rw-r--r--include/config.h48
-rw-r--r--include/config.h.in48
-rw-r--r--include/version.h2
-rw-r--r--include/version.h.in2
-rw-r--r--man/Makefile.in2
-rw-r--r--man/clogin.16
-rw-r--r--man/cloginrc.524
-rw-r--r--man/rancid.conf.5.in12
-rw-r--r--share/Makefile.in2
50 files changed, 1813 insertions, 627 deletions
diff --git a/CHANGES b/CHANGES
index 0ba1786..95caf90 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,49 @@
2.3.2
+ rancid: new format for PIX 7.0 license string - Aaron Gee-clough
+
+ clogin: older CatOS for 1900s has a CR after the pager prompt
+
+ clogin & xrancid: Extreme XOS prompt format changed - Tore Anderson
+
+ User a .cvsignore file to prevent non-cvs'd control files from appearing
+ in cvs update output.
+
+ rancid: include _ in IOS version strings
+
+ clogin: reduce the number of leading prompt characters used in
+ run_commands to accomodate change seen in cat6500
+ 12.1(13)E14 - Charles Aresenault
+
+ hlogin: fix ssh hanging on press any key prompt - Ryan Mooney
+
+ rancid: more support for HFRs
+
+ nlogin: fix missing -re option for password matching - Jee Kay
+
+ lg: fix quoting of juniper command arguments - Richard Doty
+
+ rancid: also match _ in software image names - Stafford A. Rau
+
+ nrancid: fix config comment character & more filtering - Stoned Elipot
+
+ hlogin: look for the 'press any key' prompt after ssh authentication,
+ unlike telnet, where it appears before authentication.
+
+ hpuifilter: allocate a pty to interact with ssh/telnet, so that we
+ interact with ssh for the password exchange.
+ WARNING: repeated ssh login failures to HP Procurves cause the switch's
+ management interface to lock-up (this includes snmp, ping) and sometimes
+ it will crash. This is with the latest firmware; 5.33 at the time of
+ this writing.
+
+ *rancid: check hostname, or filename, before opening the output file.
+
+ rancid: better filtering of {tacacs,radius}-server - Patrick Adlam
+
+ rancid: better filtering of PIX pager prompt - Aaron Gee-clough
+
+ rancid: collect show debug - Ed Ravin
+
add subversion support - mostly from Justin Grote
clogin: support rsh method - partly from James Stahr
diff --git a/FAQ b/FAQ
index e3a4283..394c6ef 100644
--- a/FAQ
+++ b/FAQ
@@ -144,6 +144,16 @@ A. As far as I know, CVS does not provide a way to remove directories. First,
% cd <LOCALSTATEDIR>
% rm -rf fubar CVS/fubar
+Q. I would like to place my CVS repository on a remote machine. How do I do
+ that?
+A. Assuming that you're starting fresh, its quite simply. Before running
+ rancid-cvs for the first time, adjust CVS_RSH & CVSROOT in rancid.conf
+ similar to the following:
+ CVS_RSH=ssh; export CVS_RSH
+ CVSROOT="myhost:/fqpn/CVS"; export CVSROOT
+ Note that CVS_RSH is not found in the rancid.conf sample that is distributed
+ with rancid.
+
Q. I need a web interface to the rancid CVS repository, for the CVS unsavvy.
A. cvsweb works with rancid. Other similar software may as well.
http://www.freebsd.org/projects/cvsweb.html
@@ -152,6 +162,7 @@ A. cvsweb works with rancid. Other similar software may as well.
'rancid' => ['RANCID CVS, '/full_path_to_the_RANCID_CVS'],
where the path will be <LOCALSTATEDIR>/CVS.
+
3) General
Q. I have a (set of) device(s) on which collection fails. How can I debug
@@ -215,6 +226,7 @@ A. Two methods will work. Write an expect script to be used with clogin's
The specific return (\n) will be entered after 'clear counters' followed
by the normal return after the command.
+
Q. I would like to collect device configurations every hour, but only receive
diffs every Nth collection or every N hours. Is this possible?
A. Certainly, but rancid does not provide such a mechanism natively. Two
@@ -235,6 +247,31 @@ A. Certainly, but rancid does not provide such a mechanism natively. Two
Obviously, the first option is the cleanest and most featureful, which is
why the script mention in the second option is not provided.
+
+Q. I would like to limit the permissions of the rancid user on my devices. Is
+ this possible?
+A. Strictly speaking, no. Rancid needs permission to read device configuration
+ and other data which is often not available to underprivileged users.
+ However, if you use TACACS+, you can limit the commands that are available
+ to a user.
+
+ For example, to allow ping and show, but not "show tcp", and nothing else:
+
+ user = rancid {
+ cmd = "ping" {
+ permit .*
+ }
+ cmd = "show" {
+ deny tcp.*
+ permit .*
+ }
+ # the default is to deny other commands
+ }
+
+ For RADIUS, Justin Grote suggested privilege levels:
+ http://www.cisco.com/univercd/cc/td/doc/product/software/ios122/122newft/122t/122t13/ftprienh.htm
+
+
Q. For approximately X hosts (configs) what size server should we be
considering - speed and data storage?
A. On modern machines it is unlikely you will have issues with disk space or
diff --git a/Makefile.am b/Makefile.am
index 01866f2..2d4f2fb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in
## A Makefile.in is supplied, in case you do not have automake.
-## $Id: Makefile.am,v 1.20 2004/01/13 17:24:49 heas Exp $
+## $Id: Makefile.am,v 1.21 2005/09/29 01:14:59 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -37,9 +37,9 @@ SUBDIRS = . include etc bin man share
# sysconfdir is here because etc/Makefile uses a script to be careful about
# installing rancid.conf, not over-writing an existing one.
-DIRS2_CREATE=$(prefix) $(sysconfdir)
+DIRS2_CREATE=$(DESTDIR)$(prefix) $(DESTDIR)$(sysconfdir)
if MK_LCLSTATEDIR
-DIRS2_CREATE+=$(localstatedir)
+DIRS2_CREATE+=$(DESTDIR)$(localstatedir)
endif
install-data-hook:
$(mkinstalldirs) $(DIRS2_CREATE);
diff --git a/Makefile.in b/Makefile.in
index 73b3fe3..b804e00 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -34,11 +34,11 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
-@MK_LCLSTATEDIR_TRUE@am__append_1 = $(localstatedir)
+@MK_LCLSTATEDIR_TRUE@am__append_1 = $(DESTDIR)$(localstatedir)
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
- $(srcdir)/Makefile.in $(top_srcdir)/configure COPYING \
- acconfig.h depcomp install-sh missing mkinstalldirs
+ $(srcdir)/Makefile.in $(top_srcdir)/configure COPYING depcomp \
+ install-sh missing mkinstalldirs
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
@@ -200,7 +200,8 @@ SUBDIRS = . include etc bin man share
# sysconfdir is here because etc/Makefile uses a script to be careful about
# installing rancid.conf, not over-writing an existing one.
-DIRS2_CREATE = $(prefix) $(sysconfdir) $(am__append_1)
+DIRS2_CREATE = $(DESTDIR)$(prefix) $(DESTDIR)$(sysconfdir) \
+ $(am__append_1)
all: all-recursive
.SUFFIXES:
diff --git a/README b/README
index ae21efc..4e433e7 100644
--- a/README
+++ b/README
@@ -13,58 +13,76 @@ NetBSD pkgsrc, FreeBSD port, Linux RPM, etc.
Please please please please read the UPGRADING file for more information.
**********
-The following is the packing list for Rancid. .in is stripped from
-the files below by configure with substitutions completed:
+The following is the packing list for Rancid, excluding files supporting
+configure (autoconf) and make. .in is stripped from the files below by
+configure as substitutions are completed:
README This file.
+README.lg Information about the Looking Glass.
CHANGES List of changes to Rancid.
+COPYING RANCID license.
+FAQ Frequently Asked Questions
Todo Partial list of what needs to be done.
-rancid.conf.in Environment settings needed.
-rancid-run.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/[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.
-f10rancid.in Runs commands on Force10 routers 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.
-nrancid.in Runs commands on netscreen routers and processes the output.
-rrancid.in Runs commands on redback routers 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.
-clogin.in Expect script that logs into routers either interactively,
- runs a set of commands, or runs another expect script.
-elogin.in Expect script that logs into ADC EZ-T3 muxes either
- interactively, runs a set of commands, or runs another expect
- script.
-flogin.in Expect script that logs into foundry switches. Once foundry
- cleans up their bloody UI, clogin should do the job.
-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
- clogin. It is not terribly robust, but mainly used for it's
- -c and -s options.
-.cloginrc TCL commands to set passwords, usernames etc. used by clogin
- and jlogin.
-par.in Parallel processing of commands - any commands.
-rancid-cvs.in Creates all of the CVS and config directories.
-hpuifilter.c HP procurve login filter - see end of hlogin(1).
-etc/ Configuration file samples
-etc/lg.conf.sample
-etc/rancid.conf.sample
+cloginrc.sample TCL commands to set passwords, usernames etc. used by clogin
+ and jlogin. See cloginrc(5)
+etc/
+ lg.conf.sample Sample Looking Glass configuration
+ rancid.conf.sample Sample RANCID configuration
+bin/
+ clogin.in Expect script that logs into routers and either presents
+ an interactive shell, runs a set of commands, or runs
+ another expect script. It handles Cisco, Extreme,
+ Force10, Juniper E-series, Procket, Redback, Zebra/MRT.
+ control_rancid.in
+ Builds router list, calls rancid on each router and
+ handles cvs routines.
+ hpuifilter.c HP procurve login filter - see hlogin(1).
+ par.in Parallel processing of commands - any commands.
+ rancid-cvs.in Creates all of the CVS and config directories.
+ rancid-run.in Script designed to be run from cron.
+ rancid-fe.in Chooses between rancid/[abefhjrx]rancid/cat5rancid.
+ rancid.in Runs commands on cisco routers and processes the output.
+
+ arancid.in Version of rancid.in for Alteon switches.
+ brancid.in Version of rancid.in for baynet/nortel routers.
+ cat5rancid.in Version of rancid.in for Cisco Catalyst switches.
+ cssrancid.in Version of rancid.in for Cisco CSS switches.
+ erancid.in Version of rancid.in for ADC EZ-T3 muxes.
+ f10rancid.in Version of rancid.in for Force10 routers.
+ francid.in Version of rancid.in for Foundry switches.
+ hrancid.in Version of rancid.in for HP Procurve switches.
+ htrancid.in Version of rancid.in for Hitatchi routers.
+ jerancid.in Version of rancid.in for Juniper E-series routers.
+ jrancid.in Version of rancid.in for Juniper routers.
+ mrancid.in Version of rancid.in for MRT daemons.
+ nrancid.in Version of rancid.in for Netscreen firewalls.
+ nsrancid.in Version of rancid.in for Netscalars.
+ prancid.in Version of rancid.in for Procket routers.
+ rivancid.in Version of rancid.in for Riverstone routers.
+ rrancid.in Version of rancid.in for Redback routers.
+ tntrancid.in Version of rancid.in for TNT access servers.
+ xrancid.in Version of rancid.in for Extreme switches.
+ zrancid.in Version of rancid.in for Zebra routers.
+
+ alogin.in Version of clogin.in for Alteon switches.
+ blogin.in Version of clogin.in for baynet/Nortel routers.
+ elogin.in Version of clogin.in for ADC EZ-T3 muxes.
+ flogin.in Version of clogin.in for Foundry switches. If foundry
+ cleaned-up their bloody UI, clogin should do the job.
+ hlogin.in Version of clogin.in for HP procurve switches.
+ htlogin.in Version of clogin.in for Hitatchi routers.
+ jlogin.in Version of clogin.in for Juniper routers.
+ nlogin.in Version of clogin.in for Netscreen firewalls.
+ nslogin.in Version of clogin.in for Netscalars.
+ rivlogin.in Version of clogin.in for Riverstone routers.
+ tntlogin.in Version of clogin.in for TNT access servers.
man/ man pages
share/ Readmes, samples, utilities, contribs, etc
-The following are included as part of the installation tools:
+Also see rancid_intro(1), rancid(1), and clogin(1).
+
+The following (non-exhaustive list) are included as part of the installation
+and configuration tools:
Makefile.in processed by configure to produce Makefiles
configure GNU autoconf script
@@ -222,7 +240,7 @@ Quick Installation Guide (an example):
Problem with clogin/telnet hanging within rancid or scripts?
If you have experienced rancid (or more precisely, telnet) hanging on a
-solaris 2.6 box; check to be sure you have the following two patches
+solaris 2.6 box; check to be sure you have the following two o/s patches
installed (see showrev -p). There may be more recent versions of these
patches and they are likely included with 2.7 and 2.8:
@@ -234,16 +252,15 @@ Patch-ID# 105786-11
Keywords: security ip tcp_priv_stream routing ip_enable_group_ifs ndd
Synopsis: SunOS 5.6: /kernel/drv/ip patch
-Another possibile contributor is expect/tcl. We've noticed that expect
-5.24.1 (possibly 5.28.*) and whatever tcl happens to compile with it,
-seems to not exhibit this problem, while 5.32.* appears to on linux and
-solaris but not on netbsd 1.5.
+Another contributor to rancid "hanging", with or without the o/s patches
+mentioned above, is a bug in expect/tcl. We've noticed that expect (from
+5.24.1 forward), and whatever tcl happens to compile with it, exhibits a
+problem on Linux and Solaris where rancid's scripts hang waiting for input
+from the device. Patches to expect are available on the rancid web page.
Also, for rancid 2.3 and later, changes were made to the login scripts
which use some more elaborate regexes that have failed with expect versions
prior to 5.40. While 5.40 works, it still seems to need the patch offered
-on the rancid web page.
+on the rancid web page for Linux and Solaris.
See www.shrubbery.net/rancid for additional notes on this.
-
--Hank
diff --git a/Todo b/Todo
index 6af136e..d457091 100644
--- a/Todo
+++ b/Todo
@@ -1,6 +1,12 @@
-- jrancid doesnt use $timeo
+- why does hlogin fail when the host key is not yet known? eg:
+ unix% ./hlogin procurve
+ procurve
+ spawn hpuifilter -- ssh -c 3des -x -l user procurve
+ Host key verification failed.
+
+ Error: Couldn't login
+ This happens on solaris only; linux and netbsd seem to be ok.
- lg.conf(5) needs the query stuff documented.
-- subversion support in addition to CVS
- configure OLDTIME per-group
- could the cloginrc match function do a longest-match search instead of
first match?
@@ -22,7 +28,6 @@
- fix varargs for knf in util.c
- isis filtering for foundry?
- hlogin hangs when the procurve does not ask for passwords
-- hlogin does not work with ssh, needs to alloc a pty?
- share/ tool to prune cvs versions, excluding those with tags, by (all but
latest | keep N versions | keep N days/months/years)
- extreme collection fails for tacacs-enabled boxen due to diffs in UI - blech!
diff --git a/acconfig.h b/acconfig.h
deleted file mode 100644
index 87d5f53..0000000
--- a/acconfig.h
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef CONFIG_H
-#define CONFIG_H 1
-
-@TOP@
-
-@BOTTOM@
-
-#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 <stdlib.h>
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-# include <sys/types.h>
-#elif HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_ERRNO_H
-# include <errno.h>
-#endif
-extern int errno;
-
-#if HAVE_STRING_H
-# include <string.h>
-#endif
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
-
-#if ! HAVE_STRERROR
-# define strerror(n) sys_errlist[n];
-#endif
-
-#if HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#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 <sysexits.h>
-#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/aclocal.m4 b/aclocal.m4
index 3ebc46f..0b73749 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.9.5 -*- Autoconf -*-
+# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005 Free Software Foundation, Inc.
@@ -28,7 +28,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
- [AM_AUTOMAKE_VERSION([1.9.5])])
+ [AM_AUTOMAKE_VERSION([1.9.6])])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
diff --git a/bin/Makefile.in b/bin/Makefile.in
index ec13f2d..bdee0d6 100644
--- a/bin/Makefile.in
+++ b/bin/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -15,8 +15,6 @@
@SET_MAKE@
-SOURCES = $(hpuifilter_SOURCES)
-
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
diff --git a/bin/arancid.in b/bin/arancid.in
index 4c843b2..36ff3bd 100644
--- a/bin/arancid.in
+++ b/bin/arancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: arancid.in,v 1.19 2005/06/15 20:55:12 heas Exp $
+## $Id: arancid.in,v 1.20 2005/09/25 17:48:28 heas Exp $
##
## Hacked version of rancid for Alteon WebOS switches
## tested with: ad3 v8.1.18
@@ -27,7 +27,7 @@
#
# arancid - Alteon WebOS plugin for rancid
#
-# usage: arancid [-d] [-l] [-f filename | $host]
+# usage: arancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -213,6 +213,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/brancid.in b/bin/brancid.in
index 8cb3e69..59d168b 100644
--- a/bin/brancid.in
+++ b/bin/brancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: brancid.in,v 1.21 2005/06/15 20:55:13 heas Exp $
+## $Id: brancid.in,v 1.22 2005/09/25 17:48:28 heas Exp $
## hacked version of Hank's rancid - this one tries to deal with Bay's.
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
@@ -22,7 +22,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -201,6 +201,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/cat5rancid.in b/bin/cat5rancid.in
index c79fc91..ca2ae36 100644
--- a/bin/cat5rancid.in
+++ b/bin/cat5rancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: cat5rancid.in,v 1.44 2005/08/14 01:04:07 heas Exp $
+## $Id: cat5rancid.in,v 1.45 2005/09/25 17:48:29 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -21,7 +21,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -1051,6 +1051,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/clogin.in b/bin/clogin.in
index d03feb9..1a265a8 100644
--- a/bin/clogin.in
+++ b/bin/clogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: clogin.in,v 1.89 2005/08/14 20:18:19 heas Exp $
+## $Id: clogin.in,v 1.94 2006/04/28 15:37:40 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -55,8 +55,6 @@ set avautoenable 0
# tracks if we receive them on the command line.
set do_passwd 1
set do_enapasswd 1
-# attempt at platform switching.
-set platform ""
# Find the user in the ENV, or use the unix userid.
if {[ info exists env(CISCO_USER) ]} {
@@ -577,7 +575,7 @@ proc run_commands { prompt command } {
regsub -all {[)(]} $prompt {\\&} reprompt
# match cisco config mode prompts too, such as router(config-if)#,
# but catalyst does not change in this fashion.
- regsub -all {^(.{1,14}).*([#>])$} $reprompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt
+ regsub -all {^(.{1,11}).*([#>])$} $reprompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt
expect {
-re $reprompt {}
-re "\[\n\r]+" { exp_continue }
@@ -603,6 +601,9 @@ proc run_commands { prompt command } {
}
-re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)"
exp_continue }
+ -re "^--More--\r\n" { # specific match c1900 pager
+ send " "
+ exp_continue }
-re "\[\n\r]+" { send_user -- "$expect_out(buffer)"
exp_continue }
-re "\[^\r\n]*Press <SPACE> to cont\[^\r\n]*" {
@@ -633,6 +634,9 @@ proc run_commands { prompt command } {
}
-re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)"
exp_continue }
+ -re "^--More--\r\n" { # specific match c1900 pager
+ send " "
+ exp_continue }
-re "\[\n\r]+" { send_user -- "$expect_out(buffer)"
exp_continue }
-re "\[^\r\n]*Press <SPACE> to cont\[^\r\n]*" {
@@ -685,7 +689,9 @@ source_password_file $password_file
set in_proc 0
foreach router [lrange $argv $i end] {
set router [string tolower $router]
- send_user "$router\n"
+ # attempt at platform switching.
+ set platform ""
+ send_user -- "$router\n"
# Figure out the prompt.
# autoenable is off by default. If we have it defined, it was done
@@ -717,11 +723,11 @@ foreach router [lrange $argv $i end] {
if { $do_passwd || $do_enapasswd } {
set pswd [find password $router]
if { [llength $pswd] == 0 } {
- send_user "\nError: no password for $router in $password_file.\n"
+ send_user -- "\nError: no password for $router in $password_file.\n"
continue
}
if { $enable && $do_enapasswd && $autoenable == 0 && [llength $pswd] < 2 } {
- send_user "\nError: no enable password for $router in $password_file.\n"
+ send_user -- "\nError: no enable password for $router in $password_file.\n"
continue
}
set passwd [join [lindex $pswd 0] ""]
@@ -809,7 +815,7 @@ foreach router [lrange $argv $i end] {
send "\r"
expect {
-re "\[\r\n]+" { exp_continue; }
- -re "^(.+:)1 $prompt" { # stoopid extreme cmd-line numbers and
+ -re "^(.+\[:.])1 $prompt" { # stoopid extreme cmd-line numbers and
# prompt based on state of config changes,
# which may have an * at the beginning.
set junk $expect_out(1,string)
diff --git a/bin/control_rancid.in b/bin/control_rancid.in
index 98bc630..cf601c4 100644
--- a/bin/control_rancid.in
+++ b/bin/control_rancid.in
@@ -1,6 +1,6 @@
#! /bin/sh
##
-## $Id: control_rancid.in,v 1.71 2005/08/15 00:42:50 heas Exp $
+## $Id: control_rancid.in,v 1.76 2006/05/04 21:31:20 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -114,16 +114,32 @@ then
(
echo "To: $adminmailrcpt"
echo "Subject: no $GROUP directory"
- echo "$MAILHEADERS" | awk '{gsub(/\\n/,"\n");print;}'
+ echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/) { I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN = substr(LN,I+2,length(LN)-I-1);}print L LN;}'
echo ""
echo "$DIR does not exist."
echo "Run bin/rancid-cvs $GROUP to make all of the needed directories."
) | sendmail -t
exit 1
fi
+cd $DIR
+
+# create a .cvsignore
+if [ ! -f .cvsignore ]
+then
+ rm -f .cvsignore
+ cat >.cvsignore <<EOF
+.cvsignore
+routers.all
+routers.down
+routers.up
+EOF
+ if [ $RCSSYS = svn ]
+ then
+ svn propset svn:ignore -F .cvsignore .
+ fi
+fi
# do cvs update of router.db in case anyone has fiddled.
-cd $DIR
$RCSSYS update router.db > $TMP 2>&1
grep "^C" $TMP > /dev/null
if [ $? -eq 0 ] ; then
@@ -137,10 +153,11 @@ rm -f $TMP
if [ ! -f $DIR/router.db ]
then
+ echo "$DIR/router.db does not exist."
(
echo "To: $adminmailrcpt"
echo "Subject: no $GROUP/router.db file"
- echo "$MAILHEADERS" | awk '{gsub(/\\n/,"\n");print;}'
+ echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/) { I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN = substr(LN,I+2,length(LN)-I-1);}print L LN;}'
echo ""
echo "$DIR/router.db does not exist."
) | sendmail -t
@@ -229,7 +246,7 @@ then
(
echo "To: $adminmailrcpt"
echo "Subject: changes in $GROUP routers"
- echo "$MAILHEADERS" | awk '{gsub(/\\n/,"\n");print;}'
+ echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/) { I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN = substr(LN,I+2,length(LN)-I-1);}print L LN;}'
echo ""
cat routers.mail
) | sendmail -t
@@ -310,7 +327,7 @@ cd $DIR
if [ ! -s routers.up ]
then
# commit router.db
- $RCSSYS commit -m updates router.db > /dev/null
+ $RCSSYS commit -m updates router.db
exit;
fi
@@ -424,7 +441,7 @@ then
(
echo "To: $mailrcpt"
echo "Subject: $subject"
- echo "$MAILHEADERS" | awk '{gsub(/\\n/,"\n");print;}'
+ echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/) { I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN = substr(LN,I+2,length(LN)-I-1);}print L LN;}'
echo ""
cat $TMP.diff
) | sendmail -t
@@ -444,7 +461,7 @@ then
(
echo "To: $adminmailrcpt"
echo "Subject: config fetcher problems - $GROUP"
- echo "$MAILHEADERS" | awk '{gsub(/\\n/,"\n");print;}'
+ echo "$MAILHEADERS" | awk '{L = "";LN = $0;while (LN ~ /\\n/) { I = index(LN,"\\n");L = L substr(LN,0,I-1) "\n";LN = substr(LN,I+2,length(LN)-I-1);}print L LN;}'
echo ""
echo "The following routers have not been successfully contacted for"
echo "more than $OLDTIME hours."
@@ -454,5 +471,5 @@ then
fi
# Cleanup
-rm -f $TMP.diff $DIR/routers.single
+rm -f $TMP.diff $DIR/routers.single $DIR/routers.failed
trap '' 1 2 15
diff --git a/bin/cssrancid.in b/bin/cssrancid.in
index 4b6afae..993f615 100644
--- a/bin/cssrancid.in
+++ b/bin/cssrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: cssrancid.in,v 1.10 2005/06/15 20:55:13 heas Exp $
+## $Id: cssrancid.in,v 1.11 2005/09/25 17:48:29 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -21,7 +21,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -564,6 +564,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/erancid.in b/bin/erancid.in
index 8f08721..d60dc03 100644
--- a/bin/erancid.in
+++ b/bin/erancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: erancid.in,v 1.23 2005/06/15 20:54:40 heas Exp $
+## $Id: erancid.in,v 1.24 2005/09/25 17:48:29 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -21,7 +21,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -218,6 +218,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/f10rancid.in b/bin/f10rancid.in
index 56ef691..6dc62f6 100644
--- a/bin/f10rancid.in
+++ b/bin/f10rancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: f10rancid.in,v 1.16 2005/06/15 20:54:40 heas Exp $
+## $Id: f10rancid.in,v 1.17 2005/09/25 17:48:29 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -23,7 +23,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -1145,6 +1145,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/fnrancid.in b/bin/fnrancid.in
index 6965f7b..7757139 100644
--- a/bin/fnrancid.in
+++ b/bin/fnrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: fnrancid.in,v 1.8 2005/06/15 20:54:40 heas Exp $
+## $Id: fnrancid.in,v 1.9 2005/09/25 17:48:29 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -24,7 +24,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -197,6 +197,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/francid.in b/bin/francid.in
index 78bdc62..e7d77b7 100644
--- a/bin/francid.in
+++ b/bin/francid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: francid.in,v 1.34 2005/06/15 20:54:40 heas Exp $
+## $Id: francid.in,v 1.35 2005/09/25 17:48:29 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -24,7 +24,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -362,6 +362,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/hlogin.in b/bin/hlogin.in
index ab02f4f..f50891a 100644
--- a/bin/hlogin.in
+++ b/bin/hlogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: hlogin.in,v 1.28 2005/06/13 03:11:45 heas Exp $
+## $Id: hlogin.in,v 1.31 2006/02/07 19:06:55 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -369,11 +369,6 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
send_user "\nError: Connection Refused ($prog)\n"; return 1
}
}
- eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
- -nocase "unknown host\r" {
- catch {close};
- send_user "\nError: Unknown host\n"; wait; return 1
- }
"Host is unreachable" {
catch {close};
send_user "\nError: Host Unreachable!\n"; wait; return 1
@@ -394,12 +389,21 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
send "no\r"
send_user "\nError: host key mismatch for $router. Update the SSH known_hosts file accordingly.\n"
return 1 }
+ 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
+ }
-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 }
+ "Press any key to continue" {
+ send " "
+ exp_continue
+ }
}
exp_continue
}
@@ -410,9 +414,18 @@ proc login { router user userpswd passwd enapasswd cmethod cyphertype } {
send "$passwd\r"
}
expect {
- eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
+ eof { send_user "\nError: Couldn't login\n";
+ wait;
+ return 1
+ }
+ "Press any key to continue" {
+ send " ";
+ exp_continue
+ }
-re "$e_prompt" { send "$enapasswd\r" }
- "$prompt" { set in_proc 0; return 0 }
+ "$prompt" { set in_proc 0;
+ return 0
+ }
}
exp_continue
}
diff --git a/bin/hpuifilter.c b/bin/hpuifilter.c
index 4747299..a13c223 100644
--- a/bin/hpuifilter.c
+++ b/bin/hpuifilter.c
@@ -1,5 +1,5 @@
/*
- * $Id: hpuifilter.c,v 1.21 2005/06/14 20:20:43 heas Exp $
+ * $Id: hpuifilter.c,v 1.30 2005/09/29 16:58:16 heas Exp $
*
* Copyright (C) 1997-2004 by Terrapin Communications, Inc.
* All rights reserved.
@@ -21,53 +21,117 @@
* point of hpfilter is to filter all the bloody vt100 (curses) escape codes
* that the HP procurve switches belch out, which are a real bitch to handle
* in hlogin.
+ *
+ * Modified openpty() from NetBSD:
+ * Copyright (c) 1990, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*/
-#define DFLT_TO 60 /* default timeout */
#include "config.h"
#include "version.h"
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
#include <stdio.h>
#include <limits.h>
#include <fcntl.h>
+#include <poll.h>
+#if HAVE_PTY_H
+# include <pty.h>
+#endif
+#include <regex.h>
#include <signal.h>
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_PTMX && HAVE_STROPTS_H
+# include <stropts.h>
+#endif
+#include <sys/ioctl.h>
+#include <sys/stat.h>
#include <sys/time.h>
-#include <regex.h>
-
#include <termios.h>
+#if HAVE_UTIL_H
+# include <util.h>
+#endif
#define BUFSZ (LINE_MAX * 2)
-char *progname;
-int debug = 0;
+char **environ,
+ *progname;
+int child,
+ debug,
+ drain,
+ timeo = 5; /* default timeout */
int filter __P((char *, int));
+RETSIGTYPE reapchild __P((void));
+#if !HAVE_OPENPTY
+int openpty(int *, int *, char *, struct termios *,
+ struct winsize *);
+#endif
+RETSIGTYPE sighdlr __P((int));
+#if !HAVE_UNSETENV
+int unsetenv __P((const char *));
+#endif
void usage __P((void));
void vers __P((void));
-RETSIGTYPE reapchild __P((void));
int
-main(int argc, char **argv)
+main(int argc, char **argv, char **ev)
{
extern char *optarg;
extern int optind;
char ch,
hbuf[BUFSZ], /* hlogin buffer */
- *hbufp,
+ ptyname[FILENAME_MAX + 1],
tbuf[BUFSZ], /* telnet/ssh buffer */
*tbufp;
int bytes, /* bytes read/written */
- child,
- r[2], /* recv pipe */
- s[2]; /* send pipe */
+ devnull,
+ rval = EX_OK,
+ ptym, /* master pty */
+ ptys; /* slave pty */
ssize_t hlen = 0, /* len of hbuf */
tlen = 0; /* len of tbuf */
- struct timeval to = { DFLT_TO, 0 };
- fd_set rfds, /* select() */
- wfds;
+ struct pollfd pfds[3];
struct termios tios;
+ environ = ev;
+
/* get just the basename() of our exec() name and strip a .* off the end */
if ((progname = strrchr(argv[0], '/')) != NULL)
progname += 1;
@@ -76,11 +140,16 @@ main(int argc, char **argv)
if (strrchr(progname, '.') != NULL)
*(strrchr(progname, '.')) = '\0';
- while ((ch = getopt(argc, argv, "dhv")) != -1 )
+ while ((ch = getopt(argc, argv, "dhvt:")) != -1 )
switch (ch) {
case 'd':
debug++;
break;
+ case 't':
+ timeo = atoi(optarg);
+ if (timeo < 1)
+ timeo = 1;
+ break;
case 'v':
vers();
return(EX_OK);
@@ -95,26 +164,40 @@ main(int argc, char **argv)
return(EX_USAGE);
}
- /* reap our children */
- signal(SIGCHLD, (void *) reapchild);
- signal(SIGHUP, (void *) reapchild);
- signal(SIGINT, (void *) reapchild);
- signal(SIGTERM, (void *) reapchild);
+ unsetenv("DISPLAY");
- /* create 2 pipes for send/recv and then fork and exec telnet/ssh */
+ /* allocate pty for telnet/ssh, then fork and exec */
for (child = 3; child < 10; child++)
close(child);
- if (pipe(s) || pipe(r)) {
- fprintf(stderr, "%s: pipe() failed: %s\n", progname,
+ if (openpty(&ptym, &ptys, ptyname, NULL, NULL)) {
+ fprintf(stderr, "%s: could not allocate pty: %s\n", progname,
strerror(errno));
return(EX_TEMPFAIL);
}
+ /* make the pty raw */
+ if (tcgetattr(ptys, &tios)) {
+ fprintf(stderr, "%s: tcgetattr() failed: %s\n", progname,
+ strerror(errno));
+ return(EX_OSERR);
+ }
+ tios.c_lflag &= ~ECHO;
+ tios.c_lflag &= ~ICANON;
+#ifdef VMIN
+ tios.c_cc[VMIN] = 1;
+ tios.c_cc[VTIME] = 0;
+#endif
+ if (tcsetattr(ptys, TCSANOW, &tios)) {
+ fprintf(stderr, "%s: tcsetattr() failed: %s\n", progname,
+ strerror(errno));
+ return(EX_OSERR);
+ }
- /* if a tty, make it raw as the hp echos _everything_, including
+ /*
+ * if a tty, make it raw as the hp echos _everything_, including
* passwords.
*/
- if (isatty(0)) {
- if (tcgetattr(0, &tios)) {
+ if (isatty(fileno(stdin))) {
+ if (tcgetattr(fileno(stdin), &tios)) {
fprintf(stderr, "%s: tcgetattr() failed: %s\n", progname,
strerror(errno));
return(EX_OSERR);
@@ -125,164 +208,249 @@ main(int argc, char **argv)
tios.c_cc[VMIN] = 1;
tios.c_cc[VTIME] = 0;
#endif
- if (tcsetattr(0, TCSANOW, &tios)) {
+ if (tcsetattr(fileno(stdin), TCSANOW, &tios)) {
fprintf(stderr, "%s: tcsetattr() failed: %s\n", progname,
strerror(errno));
return(EX_OSERR);
}
}
+ /* zero the buffers */
+ memset(hbuf, 0, BUFSZ);
+ memset(tbuf, 0, BUFSZ);
+
+ /* reap our children, must be set-up *after* openpty() */
+ signal(SIGCHLD, (void *) reapchild);
+
if ((child = fork()) == -1) {
- fprintf(stderr, "%s: fork() failed: %s\n", progname,
- strerror(errno));
+ fprintf(stderr, "%s: fork() failed: %s\n", progname, strerror(errno));
return(EX_TEMPFAIL);
}
- /* zero the buffers */
- bzero(hbuf, BUFSZ);
- bzero(tbuf, BUFSZ);
-
if (child == 0) {
- /* close the parent's side of the pipes; we write r[1], read s[0] */
- close(s[1]);
- close(r[0]);
+ signal(SIGCHLD, SIG_DFL);
+ /* close the master pty & std* inherited from the parent */
+ close(ptym);
+ setsid();
+ if (ptys != 0)
+ close(0);
+ if (ptys != 1)
+ close(1);
+ if (ptys != 2)
+ close(2);
+#ifdef TIOCSCTTY
+ if (ioctl(ptys, TIOCSCTTY, NULL) == -1) {
+ snprintf(ptyname, FILENAME_MAX, "%s: could not set controlling "
+ "tty: %s\n", progname, strerror(errno));
+ write(ptys, ptyname, strlen(ptyname));
+ return(EX_OSERR);
+ }
+#endif
+
/* 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));
+ if (dup2(ptys, 0) == -1 || dup2(ptys, 1) == -1 || dup2(ptys, 2) == -1) {
+ snprintf(ptyname, FILENAME_MAX, "%s: dup2() failed: %s\n", progname,
+ strerror(errno));
+ write(ptys, ptyname, strlen(ptyname));
return(EX_OSERR);
}
- close(s[0]);
- close(r[1]);
+ if (ptys > 2)
+ close(ptys);
+
/* exec telnet/ssh */
- if (execvp(argv[optind], argv + optind)) {
- fprintf(stderr, "%s: execlp() failed: %s\n", progname,
+ execvp(argv[optind], argv + optind);
+ snprintf(ptyname, FILENAME_MAX, "%s: execvp() failed: %s\n", progname,
+ strerror(errno));
+ write(ptys, ptyname, strlen(ptyname));
+ return(EX_TEMPFAIL);
+ /*NOTREACHED*/
+ }
+
+ /* parent */
+ if (debug)
+ fprintf(stderr, "child %d\n", child);
+
+ signal(SIGHUP, (void *) sighdlr);
+
+ /* close the slave pty */
+ close(ptys);
+
+ devnull = open("/dev/null", O_RDWR);
+
+ /* make FDs non-blocking */
+ if (fcntl(ptym, F_SETFL, O_NONBLOCK) ||
+ fcntl(fileno(stdin), F_SETFL, O_NONBLOCK) ||
+ fcntl(fileno(stdout), F_SETFL, O_NONBLOCK)) {
+ fprintf(stderr, "%s: fcntl(NONBLOCK) failed: %s\n", progname,
strerror(errno));
- return(EX_TEMPFAIL);
+ exit(EX_OSERR);
+ }
+
+ /* loop to read on stdin and ptym */
+#define POLLEXP (POLLERR | POLLHUP | POLLNVAL)
+ pfds[0].fd = fileno(stdin);
+ pfds[0].events = POLLIN | POLLEXP;
+ pfds[1].fd = fileno(stdout);
+ pfds[2].fd = ptym;
+ pfds[2].events = POLLIN | POLLEXP;
+
+ while (1) {
+ bytes = poll(pfds, 3, (timeo * 1000));
+ if (bytes == 0) {
+ if (drain)
+ break;
+ /* timeout */
+ continue;
}
- /* 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);
+ if (bytes == -1) {
+ switch (errno) {
+ case EAGAIN:
+ case EINTR:
+ break;
+ default:
+ rval = EX_IOERR;
+ break;
+ }
+ continue;
}
- /* loop to read on stdin and r[0] */
- FD_ZERO(&rfds); FD_ZERO(&wfds);
- hbufp = hbuf; tbufp = tbuf;
+ /*
+ * write buffers first
+ * write hbuf (stdin) -> ptym
+ */
+ if ((pfds[2].revents & POLLOUT) && hlen) {
+ if ((bytes = write(pfds[2].fd, hbuf, hlen)) < 0 &&
+ errno != EINTR && errno != EAGAIN) {
+ fprintf(stderr, "%s: write() failed: %s\n", progname,
+ strerror(errno));
+ hbuf[0] = '\0';
+ hlen = 0;
+ drain = 1;
+ pfds[2].events &= ~POLLOUT;
- 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);
+ break;
+ } else if (bytes > 0) {
+ strcpy(hbuf, hbuf + bytes);
+ hlen -= bytes;
+ if (hlen < 1)
+ pfds[2].events &= ~POLLOUT;
}
+ } else if (pfds[2].revents & POLLEXP) {
+ hbuf[0] = '\0';
+ hlen = 0;
+ pfds[2].events &= POLLIN;
+ break;
+ }
- switch (select(r[1], &rfds, &wfds, NULL, &to)) {
- case 0:
- /* timeout */
- /* XXX what do i do here? */
+ /* write tbuf -> stdout */
+ if ((pfds[1].revents & POLLOUT) && tlen) {
+ /*
+ * if there is an escape char that didnt get filter()'d,
+ * we need to write only up to that point and wait for
+ * the bits that complete the escape sequence. if at least
+ * two bytes follow it, write it anyway as filter() didnt
+ * match it.
+ */
+ bytes = tlen;
+ if ((tbufp = index(tbuf, 0x1b)) != NULL)
+ if (tlen - (tbufp - tbuf) < 2)
+ bytes = tbufp - tbuf;
+
+ if ((bytes = write(pfds[1].fd, tbuf, bytes)) < 0 &&
+ errno != EINTR && errno != EAGAIN) {
+ fprintf(stderr, "%s: write() failed: %s\n", progname,
+ strerror(errno));
break;
- case -1:
- switch (errno) {
- case EINTR: /* interrupted syscall */
+ tbuf[0] = '\0';
+ tlen = 0;
+ drain = 1;
+ pfds[1].events = 0;
+ } else if (bytes > 0) {
+ strcpy(tbuf, tbuf + bytes);
+ tlen -= bytes;
+ if (tlen < 1)
+ pfds[1].events &= ~POLLOUT;
+ }
+ } else if (pfds[1].revents & POLLEXP) {
+ break;
+ tbuf[0] = '\0';
+ tlen = 0;
+ pfds[1].fd = devnull;
+ pfds[1].events = 0;
+ }
+
+ /* read stdin -> hbuf */
+ if (pfds[0].revents & POLLIN) {
+ if (BUFSZ - hlen > 1) {
+ bytes = read(pfds[0].fd, hbuf + hlen, (BUFSZ - 1) - hlen);
+ if (bytes > 0) {
+ hlen += bytes;
+ hbuf[hlen] = '\0';
+ pfds[2].events |= POLLOUT;
+ } else if (bytes == 0 && errno != EAGAIN && errno != EINTR) {
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);
+ /* EOF or read error */
+ drain = 1;
+ pfds[0].fd = devnull;
+ pfds[0].events = 0;
}
- if (FD_ISSET(0, &rfds)) {
- /* read stdin into hbuf */
- if (BUFSZ - hlen > 1) {
- hlen += read(0, hbuf + hlen, (BUFSZ - 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/ssh into tbuf, then filter */
- if (BUFSZ - tlen > 1) {
- tlen += read(r[0], tbuf + tlen, (BUFSZ - 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;
}
+ } else if (pfds[0].revents & POLLEXP) {
+ break;
+ drain = 1;
+ pfds[0].fd = devnull;
+ pfds[0].events = 0;
}
- /* close */
- close(0);
- close(1);
- close(s[1]);
- close(r[0]);
+ /* read telnet/ssh -> tbuf, then filter */
+ if (pfds[2].revents & POLLIN) {
+ if (BUFSZ - tlen > 1) {
+ bytes = read(pfds[2].fd, tbuf + tlen, (BUFSZ - 1) - tlen);
+ if (bytes > 0) {
+ tlen += bytes;
+ tbuf[tlen] = '\0';
+ tlen = filter(tbuf, tlen);
+ if (tlen > 0)
+ pfds[1].events |= POLLOUT;
+ } else if (bytes == 0 && errno != EAGAIN && errno != EINTR) {
+ /* EOF or read error */
+ break;
+ drain = 1;
+ pfds[2].fd = devnull;
+ pfds[2].events = 0;
+ }
+ }
+ } else if (pfds[2].revents & POLLEXP) {
+ break;
+ drain = 1;
+ pfds[2].fd = devnull;
+ pfds[2].events = 0;
+ }
+ }
+ /* try to flush buffers */
+ if (hlen) {
+ (void) write(pfds[2].fd, hbuf, hlen);
+ hlen = 0;
+ }
+ if (tlen) {
+ (void) write(pfds[1].fd, tbuf, tlen);
+ tlen = 0;
+ }
+ if ((bytes = read(pfds[2].fd, tbuf, (BUFSZ - 1))) > 0) {
+ tbuf[bytes] = '\0';
+ tlen = filter(tbuf, bytes);
+ (void) write(pfds[1].fd, tbuf, tlen);
}
+ tcdrain(pfds[1].fd);
+ if ((hlen = read(pfds[0].fd, hbuf, (BUFSZ - 1))) > 0) {
+ (void) write(pfds[2].fd, hbuf, hlen);
+ }
+ tcdrain(pfds[2].fd);
- if (! kill(child, SIGQUIT))
+ if (child && ! kill(child, SIGINT))
reapchild();
- return(EX_OK);
+ return(rval);
}
int
@@ -291,7 +459,7 @@ filter(buf, len)
int len;
{
static regmatch_t pmatch[1];
-#define N_REG 11 /* number of regexes in reg[][] */
+#define N_REG 13 /* 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 */
@@ -307,8 +475,11 @@ filter(buf, len)
"\e\\[\\?7l", /* RA */
"\e\\[\\?25h", /* ve */
"\e\\[\\?25l", /* vi */
+ "\e\\[K", /* ce */
- "\eE", /* replace w/ CR */
+ /* replace these with CR */
+ "\e\\[0m", /* me */
+ "\eE",
};
char ebuf[256];
size_t nmatch = 1;
@@ -319,7 +490,7 @@ filter(buf, len)
if (index(buf, 0x1b) == 0 || len == 0)
return(len);
- for (x = 0; x < N_REG - 1; x++) {
+ for (x = 0; x < N_REG - 2; x++) {
if (! init) {
if ((err = regcomp(&preg[x], reg[x], REG_EXTENDED))) {
regerror(err, &preg[x], ebuf, 256);
@@ -342,27 +513,28 @@ filter(buf, len)
/* 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();
- }
+ for (x = N_REG - 2; x < N_REG; x++)
+ if ((err = regcomp(&preg[x], reg[x], REG_EXTENDED))) {
+ regerror(err, &preg[x], ebuf, 256);
+ fprintf(stderr, "%s: regex compile failed: %s\n", progname,
+ ebuf);
+ abort();
+ }
}
- while (1)
- if ((err = regexec(&preg[N_REG - 1], buf, nmatch, pmatch, 0))) {
+ for (x = N_REG - 2; x < N_REG; x++) {
+ if ((err = regexec(&preg[x], buf, nmatch, pmatch, 0))) {
if (err != REG_NOMATCH) {
- regerror(err, &preg[N_REG - 1], ebuf, 256);
+ regerror(err, &preg[x], 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;
+ *(buf + pmatch[0].rm_so) = '\r';
+ *(buf + pmatch[0].rm_so + 1) = '\n';
+ strcpy(buf + pmatch[0].rm_so + 2, buf + pmatch[0].rm_eo);
+ x = N_REG - 2;
}
-
+ }
return(strlen(buf));
}
@@ -376,19 +548,54 @@ reapchild(void)
while ((pid = wait3(&status, WNOHANG, 0)) > 0)
if (debug)
fprintf(stderr, "reap child %d\n", pid);
+ if (pid == child)
+ child = 0;
- /*exit(1);*/
-return;
+ return;
+}
+
+RETSIGTYPE
+sighdlr(int sig)
+{
+ if (debug)
+ fprintf(stderr, "GOT SIGNAL %d\n", sig);
+ drain = 1;
+ return;
+}
- /* not reached */
+#if !HAVE_UNSETENV
+int
+unsetenv(const char *name)
+{
+ char **victim,
+ **end;
+ int len;
+ if (environ == NULL)
+ return(0);
+ len = strlen(name);
+ victim = environ;
+ while (*victim != NULL) {
+ if (strncmp(name, *victim, len) == 0 && victim[0][len] == '=')
+ break;
+ victim++;
+ }
+ if (*victim == NULL)
+ return(0);
+ end = victim + 1;
+ while (*end != NULL)
+ end++;
+ end--;
+ *victim = *end;
+ *end = NULL;
+ return(0);
}
+#endif
void
usage(void)
{
- fprintf(stderr,
-"usage: %s [-hv] <telnet|ssh> [<ssh options>] <hostname> [<telnet_port>]\n",
- progname);
+ fprintf(stderr, "usage: %s [-hv] [-t timeout] <telnet|ssh> [<ssh options>]"
+ " <hostname> [<telnet_port>]\n", progname);
return;
}
@@ -398,3 +605,104 @@ vers(void)
fprintf(stderr, "%s: %s version %s\n", progname, package, version);
return;
}
+
+
+#if !HAVE_OPENPTY
+#include <grp.h>
+#define TTY_LETTERS "pqrstuvwxyzPQRST"
+#define TTY_OLD_SUFFIX "0123456789abcdef"
+#define TTY_NEW_SUFFIX "ghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+
+int
+openpty(int *amaster, int *aslave, char *name, struct termios *term,
+ struct winsize *winp)
+{
+ static char line[] = "/dev/XtyXX";
+ const char *cp1, *cp2, *cp, *linep;
+ int master, slave;
+ gid_t ttygid;
+ mode_t mode;
+ struct group *gr;
+
+#if HAVE_PTMX
+ if ((master =
+#if HAVE_PTMX_BSD
+ open("/dev/ptmx_bsd", O_RDWR))
+#else
+ open("/dev/ptmx", O_RDWR))
+#endif
+ != -1) {
+ linep = ptsname(master);
+ grantpt(master);
+ unlockpt(master);
+ if ((slave = open(linep, O_RDWR)) < 0) {
+ slave = errno;
+ (void) close(master);
+ errno = slave;
+ return(-1);
+ }
+#if HAVE_PTMX_OSF
+ {
+ char buf[10240];
+ if (ioctl (slave, I_LOOK, buf) != 0)
+ if (ioctl (slave, I_PUSH, "ldterm")) {
+ close(slave);
+ close(master);
+ return(-1);
+ }
+ }
+#elif HAVE_STROPTS_H
+ ioctl(slave, I_PUSH, "ptem");
+ ioctl(slave, I_PUSH, "ldterm");
+ ioctl(slave, I_PUSH, "ttcompat");
+#endif
+ goto gotit;
+ }
+ if (errno != ENOENT)
+ return(-1);
+#endif
+
+ if ((gr = getgrnam("tty")) != NULL) {
+ ttygid = gr->gr_gid;
+ mode = S_IRUSR|S_IWUSR|S_IWGRP;
+ } else {
+ ttygid = getgid();
+ mode = S_IRUSR|S_IWUSR;
+ }
+
+ for (cp1 = TTY_LETTERS; *cp1; cp1++) {
+ line[8] = *cp1;
+ for (cp = cp2 = TTY_OLD_SUFFIX TTY_NEW_SUFFIX; *cp2; cp2++) {
+ line[5] = 'p';
+ line[9] = *cp2;
+ if ((master = open(line, O_RDWR, 0)) == -1) {
+ if (errno != ENOENT)
+ continue; /* busy */
+ if (cp2 - cp + 1 < sizeof(TTY_OLD_SUFFIX))
+ return -1; /* out of ptys */
+ else
+ break; /* out of ptys in this group */
+ }
+ line[5] = 't';
+ linep = line;
+ if (chown(line, getuid(), ttygid) == 0 &&
+ chmod(line, mode) == 0 &&
+ (slave = open(line, O_RDWR, 0)) != -1) {
+gotit:
+ *amaster = master;
+ *aslave = slave;
+ if (name)
+ (void)strcpy(name, linep);
+ if (term)
+ (void)tcsetattr(slave, TCSAFLUSH, term);
+ if (winp)
+ (void)ioctl(slave, TIOCSWINSZ, winp);
+ return 0;
+ }
+ (void)close(master);
+ }
+ }
+ errno = ENOENT; /* out of ptys */
+ return -1;
+}
+#endif
diff --git a/bin/hrancid.in b/bin/hrancid.in
index 4eb77e1..5e54bdc 100644
--- a/bin/hrancid.in
+++ b/bin/hrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: hrancid.in,v 1.22 2005/06/15 20:54:41 heas Exp $
+## $Id: hrancid.in,v 1.23 2005/09/25 17:48:29 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -24,7 +24,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -443,6 +443,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/htrancid.in b/bin/htrancid.in
index 5f05a00..e1082c9 100644
--- a/bin/htrancid.in
+++ b/bin/htrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: htrancid.in,v 1.10 2005/06/15 20:54:41 heas Exp $
+## $Id: htrancid.in,v 1.11 2005/09/25 17:48:30 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -23,7 +23,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: htrancid [-d] [-l] [-f filename | $host]
+# usage: htrancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -179,6 +179,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/jerancid.in b/bin/jerancid.in
index 7455b1d..656da3c 100644
--- a/bin/jerancid.in
+++ b/bin/jerancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: jerancid.in,v 1.33 2005/06/15 20:54:41 heas Exp $
+## $Id: jerancid.in,v 1.34 2005/09/25 17:48:30 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -23,7 +23,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -554,6 +554,15 @@ sub DoNothing {print STDOUT;}
$jnxe_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/jrancid.in b/bin/jrancid.in
index 8b7f2bf..ab35fad 100644
--- a/bin/jrancid.in
+++ b/bin/jrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: jrancid.in,v 1.68 2005/06/15 20:54:41 heas Exp $
+## $Id: jrancid.in,v 1.70 2005/09/28 22:07:57 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -24,7 +24,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: jrancid [-d] [-l] [-f filename | $host]
+# usage: jrancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -35,6 +35,7 @@ $host = $ARGV[0];
$clean_run = 0;
$found_end = 0;
+$timeo = 120; # clogin timeout in seconds
my(@commandtable, %commands, @commands);# command lists
my(%filter_pwds); # password filtering mode
@@ -588,6 +589,15 @@ sub DoNothing {print STDOUT;}
$jnx_commands=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered
@@ -598,14 +608,14 @@ if ($file) {
print STDOUT "opening file $host\n" if ($log);
open(INPUT,"< $host") || die "open failed for $host: $!\n";
} else {
- print(STDERR "executing echo jlogin -c\"$jnx_commands\" $host\n") if ($debug);
- print(STDOUT "executing echo jlogin -c\"$jnx_commands\" $host\n") if ($debug);
+ print(STDERR "executing echo jlogin -t $timeo -c\"$jnx_commands\" $host\n") if ($debug);
+ print(STDOUT "executing echo jlogin -t $timeo -c\"$jnx_commands\" $host\n") if ($debug);
if (defined($ENV{NOPIPE})) {
- system "jlogin -c \"$jnx_commands\" $host </dev/null > $host.raw" || die "jlogin failed for $host: $!\n";
+ system "jlogin -t $timeo -c \"$jnx_commands\" $host </dev/null > $host.raw" || die "jlogin failed for $host: $!\n";
open(INPUT, "< $host.raw") || die "jlogin failed for $host: $!\n";
} else {
- open(INPUT,"jlogin -c \"$jnx_commands\" $host </dev/null |") || die "jlogin failed for $host: $!\n";
+ open(INPUT,"jlogin -t $timeo -c \"$jnx_commands\" $host </dev/null |") || die "jlogin failed for $host: $!\n";
}
}
diff --git a/bin/lg.cgi.in b/bin/lg.cgi.in
index ea0b54e..93e9797 100644
--- a/bin/lg.cgi.in
+++ b/bin/lg.cgi.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: lg.cgi.in,v 1.51 2004/05/19 22:59:18 heas Exp $
+## $Id: lg.cgi.in,v 1.52 2005/12/07 19:19:46 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -680,7 +680,7 @@ if ($type eq "prefix" || $type eq "mbgp" || $type eq "route" ) {
if ($mfg =~ /cisco/i) {
$arg = " | include " . join(' ', @arg);
} elsif ($mfg =~ /juniper/i) {
- $arg = " | match \"" . join(' ', @arg) . "\"";
+ $arg = " | match \\\"" . join(' ', @arg) . "\\\"";
} else {
undef($arg);
}
@@ -738,7 +738,7 @@ if ($type eq "prefix" || $type eq "mbgp" || $type eq "route" ) {
} else {
$arg =~ s/[\$^]/ /g;
}
- $arg = "\"$arg\"";
+ $arg = "\\\"$arg\\\"";
}
# escape any ()s
$arg =~ s/([\(\)])/\\$1/g;
diff --git a/bin/mrancid.in b/bin/mrancid.in
index 80bc206..7186717 100644
--- a/bin/mrancid.in
+++ b/bin/mrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: mrancid.in,v 1.15 2005/06/15 20:54:41 heas Exp $
+## $Id: mrancid.in,v 1.16 2005/09/25 17:48:30 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -24,7 +24,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -318,6 +318,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/nlogin.in b/bin/nlogin.in
index e10db1e..b5058bc 100644
--- a/bin/nlogin.in
+++ b/bin/nlogin.in
@@ -1,6 +1,6 @@
#! @EXPECT_PATH@ --
##
-## $Id: nlogin.in,v 1.26 2005/06/14 20:20:44 heas Exp $
+## $Id: nlogin.in,v 1.27 2006/01/26 22:14:28 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -355,7 +355,7 @@ cyphertype } {
set uprompt_seen 1
exp_continue
}
- "@\[^\r\n]+\[Pp]assword:" {
+ -re "@\[^\r\n]+\[Pp]assword:" {
# ssh pwd prompt
sleep 1
send "$userpswd\r"
diff --git a/bin/nrancid.in b/bin/nrancid.in
index b7305e5..04f38b0 100644
--- a/bin/nrancid.in
+++ b/bin/nrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: nrancid.in,v 1.23 2005/06/24 16:01:19 heas Exp $
+## $Id: nrancid.in,v 1.25 2005/10/12 01:35:31 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -26,7 +26,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -152,22 +152,22 @@ sub GetSystem {
next if /^--- more ---/;
/^Serial Number: (\d+), Control Number: \d+$/ &&
- ProcessHistory("SYSTEM","","", "!SN: $1\n") && next;
+ ProcessHistory("SYSTEM","","", "#SN: $1\n") && next;
/^Product Name: (\S+)$/ &&
- ProcessHistory("SYSTEM","","", "!Product: $1\n") && next;
+ ProcessHistory("SYSTEM","","", "#Product: $1\n") && next;
/^Hardware Version: (\S+), / &&
- ProcessHistory("SYSTEM","","", "!HW: $1\n") && next;
+ ProcessHistory("SYSTEM","","", "#HW: $1\n") && next;
/^Software Version: (\S+), Type: (\S+)$/ &&
- ProcessHistory("SYSTEM","","", "!Netscreen Type: $2\n!Software Version: $1\n") && next;
+ ProcessHistory("SYSTEM","","", "#Netscreen Type: $2\n#Software Version: $1\n") && next;
/^Image: (\S+), / &&
- ProcessHistory("SYSTEM","","", "!Image: $1\n") && next;
+ ProcessHistory("SYSTEM","","", "#Image: $1\n") && next;
/^Feature: (\S+)$/ &&
- ProcessHistory("SYSTEM","","", "!Feature: $1\n") && next;
+ ProcessHistory("SYSTEM","","", "#Feature: $1\n") && next;
/^File Name: (\S+), Checksum: (\S+)$/ &&
- ProcessHistory("SYSTEM","","", "!File Name: $1, Checksum: $2\n") && next;
+ ProcessHistory("SYSTEM","","", "#File Name: $1, Checksum: $2\n") && next;
}
- ProcessHistory("SYSTEM","","","!\n");
+ ProcessHistory("SYSTEM","","","#\n");
return(0);
}
@@ -176,7 +176,7 @@ sub GetFile {
while (<INPUT>) {
last if(/$prompt/);
}
- ProcessHistory("FILE","","","!\n");
+ ProcessHistory("FILE","","","#\n");
return(0);
}
@@ -191,22 +191,40 @@ sub GetConf {
next if /^--- more ---/;
if (/^set admin name "(\S+)"$/ && $filter_pwds >= 1) {
- ProcessHistory("ADMIN","","","!set admin name <removed>\n");
+ ProcessHistory("ADMIN","","","#set admin name <removed>\n");
next;
}
if (/^set admin password (\S+)$/ && $filter_pwds >= 1) {
- ProcessHistory("ADMIN","","","!set admin password <removed>\n");
+ ProcessHistory("ADMIN","","","#set admin password <removed>\n");
next;
}
if (/^set admin user (\S+) password (\S+) privilege (\S+)$/ &&
$filter_pwds >= 1) {
ProcessHistory("ADMIN","","",
- "!set admin user $1 password <removed> privilege $3\n");
+ "#set admin user $1 password <removed> privilege $3\n");
next;
}
if (/^set auth-server (\S+) radius secret / && $filter_pwds >= 1 ) {
ProcessHistory("ADMIN","","",
- "!set auth-server $1 radius secret <removed>\n");
+ "#set auth-server $1 radius secret <removed>\n");
+ next;
+ }
+ if (/^set ike gateway (.*) username (\S+)(.*) password (\S+)(.*)$/ &&
+ $filter_pwds >= 1) {
+ ProcessHistory("ADMIN","","",
+ "#set ike gateway $1 username <removed>$3 password <removed>$5\n");
+ next;
+ }
+ if (/^set ike gateway (.*) preshare "(\S+)"(.*)$/ &&
+ $filter_pwds >= 1) {
+ ProcessHistory("ADMIN","","",
+ "#set ike gateway $1 preshare <removed>$3\n");
+ next;
+ }
+ if (/^set auth-server (.*) secret "(\S+)"(.*)$/ &&
+ $filter_pwds >= 1) {
+ ProcessHistory("ADMIN","","",
+ "#set auth-server $1 secret <removed>$3\n");
next;
}
ProcessHistory("","","","$_");
@@ -231,6 +249,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
@@ -260,7 +287,7 @@ if ($ENV{"FILTER_PWDS"} =~ /no/i) {
$filter_pwds = 1;
}
-ProcessHistory("","","","!RANCID-CONTENT-TYPE: netscreen\n!\n");
+ProcessHistory("","","","#RANCID-CONTENT-TYPE: netscreen\n#\n");
TOP: while(<INPUT>) {
tr/\015//d;
if (/^Error:/) {
diff --git a/bin/nsrancid.in b/bin/nsrancid.in
index c0a9a73..61aa9e5 100644
--- a/bin/nsrancid.in
+++ b/bin/nsrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: nsrancid.in,v 1.11 2005/06/15 20:54:41 heas Exp $
+## $Id: nsrancid.in,v 1.12 2005/09/25 17:48:30 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -24,7 +24,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -217,6 +217,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/prancid.in b/bin/prancid.in
index d3e71a4..47eda29 100755
--- a/bin/prancid.in
+++ b/bin/prancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: prancid.in,v 1.32 2005/06/15 20:54:41 heas Exp $
+## $Id: prancid.in,v 1.33 2005/09/25 17:48:30 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -23,7 +23,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -476,6 +476,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/rancid.in b/bin/rancid.in
index 3183dca..4afe73a 100644
--- a/bin/rancid.in
+++ b/bin/rancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: rancid.in,v 1.193 2005/08/14 22:29:29 heas Exp $
+## $Id: rancid.in,v 1.203 2006/04/06 21:14:05 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -21,7 +21,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -147,13 +147,17 @@ sub ShowVersion {
while (<INPUT>) {
tr/\015//d;
if (/^$prompt/) { $found_version=1; last};
- next if(/^(\s*|\s*$cmd\s*)$/);
+ next if (/^(\s*|\s*$cmd\s*)$/);
return(1) if /Line has invalid autocommand /;
return(1) if /(Invalid input detected|Type help or )/;
return(-1) if (/command authorization failed/i);
return(0) if ($found_version); # Only do this routine once
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
if (/^Slave in slot (\d+) is running/) {
$slave = " Slave:";
$slaveslot = ", slot $1";
@@ -164,10 +168,11 @@ sub ShowVersion {
ProcessHistory("COMMENTS","keysort","F1", "!Image: $_") && next;
/^Cisco Secure PIX /i &&
ProcessHistory("COMMENTS","keysort","F1", "!Image: $_") && next;
- # PIX fail-over license
- /^This PIX has an?\s+(.*)$/ &&
- ProcessHistory("COMMENTS","keysort","C1", "!$_") && next;
- /^(Cisco )?IOS .* Software,? \(([A-Za-z-0-9]*)\), .*Version\s+(.*)$/ &&
+ # PIX 6 fail-over license, as in "This PIX has an Unrestricted (UR)
+ # license." PIX 7 as "his platform has ..."
+ /^This (PIX|platform) has an?\s+(.*)$/ &&
+ ProcessHistory("COMMENTS","keysort","D1", "!$_") && next;
+ /^(Cisco )?IOS .* Software,? \(([A-Za-z-0-9_]*)\), .*Version\s+(.*)$/ &&
ProcessHistory("COMMENTS","keysort","F1",
"!Image:$slave Software: $2, $3\n") && next;
/^([A-Za-z-0-9_]*) Synced to mainline version: (.*)$/ &&
@@ -188,6 +193,16 @@ sub ShowVersion {
}
/^Serial Number:\s+(.*)$/ &&
ProcessHistory("COMMENTS","keysort","C1", "!$_") && next;
+ # More PIX stuff
+ /^Encryption hardware device\s+:\s+(.*)/ &&
+ ProcessHistory("COMMENTS","keysort","A3", "!Encryption: $1\n") &&
+ next;
+ /^Flash\s+\S+ \@ 0x\S+,\s+(\S+)/ &&
+ ProcessHistory("COMMENTS","keysort","B2", "!Memory: Flash $1\n") &&
+ next;
+ /^running activation key\s*:\s+(.*)/i &&
+ ProcessHistory("COMMENTS","keysort","D2", "!Key: $1\n") &&
+ next;
# CatOS 3500xl stuff
/^System serial number(:\s+.*)$/ &&
ProcessHistory("COMMENTS","keysort","C1", "!Serial Number$1\n") &&
@@ -333,12 +348,12 @@ sub ShowVersion {
/^(\d+[kK]) bytes of Flash internal/ &&
ProcessHistory("COMMENTS","keysort","B4",
"!Memory: bootflash $1\n") && next;
- if(/^(\d+[kK]) bytes of (Flash|ATA)?.*PCMCIA .*(slot|disk) ?(\d)/i) {
+ if (/^(\d+[kK]) bytes of (Flash|ATA)?.*PCMCIA .*(slot|disk) ?(\d)/i) {
ProcessHistory("COMMENTS","keysort","B7",
"!Memory: pcmcia $2 $3$4 $1\n");
next;
}
- if(/^WARNING/) {
+ if (/^WARNING/) {
if (!defined($I0)) {
$I0=1;
ProcessHistory("COMMENTS","keysort","I0","!\n");
@@ -349,6 +364,10 @@ sub ShowVersion {
$config_register=$1;
next;
}
+ if (/^Configuration register on node \S+ is (.*)$/) {
+ $config_register=$1 if $config_register eq "";
+ next;
+ }
}
return(0);
}
@@ -359,14 +378,17 @@ sub ShowRedundancy {
while (<INPUT>) {
tr/\015//d;
- last if(/^$prompt/);
- next if(/^(\s*|\s*$cmd\s*)$/);
+ last if (/^$prompt/);
+ next if (/^(\s*|\s*$cmd\s*)$/);
return(1) if /Line has invalid autocommand /;
return(1) if /(Invalid input detected|Type help or )/;
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
- /^IOS .* Software \(([A-Za-z-0-9]*)\), .*Version\s+(.*)$/ &&
+ /^IOS .* Software \(([A-Za-z-0-9_]*)\), .*Version\s+(.*)$/ &&
ProcessHistory("COMMENTS","keysort","F1",
"!Image:$slave Software: $1, $2\n") && next;
/^Compiled (.*)$/ &&
@@ -384,12 +406,15 @@ sub ShowIDprom {
while (<INPUT>) {
tr/\015//d;
- last if(/^$prompt/);
- next if(/^(\s*|\s*$cmd\s*)$/);
+ last if (/^$prompt/);
+ next if (/^(\s*|\s*$cmd\s*)$/);
return(1) if /Line has invalid autocommand /;
return(1) if /(Invalid input detected|Type help or )/;
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
/FRU is .(.*)\'/ && ($tmp = $1);
/Product Number = .(.*)\'/ &&
@@ -420,7 +445,11 @@ sub ShowInstallActive {
return(1) if /(Invalid input detected|Type help or )/;
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
ProcessHistory("COMMENTS","keysort","F5","!Image: $_") && next;
}
return(0);
@@ -441,7 +470,11 @@ sub ShowEnv {
return(-1) if (/command authorization failed/i);
return(0) if ($found_env); # Only do this routine once
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
if (!defined($E0)) {
$E0=1;
ProcessHistory("COMMENTS","keysort","E0","!\n");
@@ -456,6 +489,8 @@ sub ShowEnv {
"!Chassis type: $2 backplane\n");
next;
}
+ /^Power Supply Information$/ && next;
+ /^\s*Power Module\s+Voltage\s+Current$/ && next;
/^\s*(Power [^:\n]+)$/ &&
ProcessHistory("COMMENTS","keysort","E1","!Power: $1\n") && next;
/^\s*(Lower Power .*)/i &&
@@ -481,7 +516,10 @@ sub ShowRSP {
return(-1) if (/command authorization failed/i);
# return(1) if ($type !~ /^12[40]/);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
/^$/ && next;
/^\s+Chassis model: (\S+)/ &&
@@ -510,8 +548,12 @@ sub ShowGSR {
return(-1) if (/command authorization failed/i);
# return(1) if ($type !~ /^12[40]/);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
/^$/ && next;
+
/^\s+Chassis: type (\S+) Fab Ver: (\S+)/ &&
ProcessHistory("COMMENTS","keysort","D1",
"!GSR Chassis type: $1 Fab Ver: $2\n") &&
@@ -550,7 +592,11 @@ sub ShowBoot {
return(1) if /(Open device \S+ failed|Error opening \S+:)/;
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
next if /CONFGEN variable/;
if (!defined($H0)) {
$H0=1; ProcessHistory("COMMENTS","keysort","H0","!\n");
@@ -585,7 +631,11 @@ sub ShowFlash {
return(1) if /(Invalid input detected|Type help or )/;
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
/\s+(multiple-fs|nv_hdr|vlan\.dat)$/ && next;
ProcessHistory("FLASH","","","!Flash: $_");
}
@@ -616,7 +666,11 @@ sub DirSlotN {
return(-1) if (/command authorization failed/i);
return(1) if /(Open device \S+ failed|Error opening \S+:)/;
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
ProcessHistory("FLASH","","","!Flash: $dev: $_");
}
ProcessHistory("","","","!\n");
@@ -635,7 +689,11 @@ sub ShowContAll {
# return(1) if ($type =~ /^(12[40]|7[05])/);
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
if (/^Interface ([^ \n(]*)/) { $INT = "$1, "; next; }
/^(BRI unit \d)/ &&
ProcessHistory("INT","","","!Interface: $1\n") && next;
@@ -695,7 +753,11 @@ sub ShowContCbus {
#return(1) if ($type !~ /^7[05]0/);
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
if (/^\s*slot(\d+): ([^,]+), hw (\S+), sw (\S+), ccb/) {
$slot = $1;
$board{$slot} = $2;
@@ -729,6 +791,34 @@ sub ShowContCbus {
return(0);
}
+# This routine parses "show debug"
+sub ShowDebug {
+ print STDERR " In ShowDebug: $_" if ($debug);
+ my($lines) = 0;
+
+ while (<INPUT>) {
+ tr/\015//d;
+ last if (/^$prompt/);
+ next if (/^(\s*|\s*$cmd\s*)$/);
+ return(1) if /Line has invalid autocommand /;
+ return(1) if /(Invalid input detected|Type help or )/;
+ return(-1) if (/command authorization failed/i);
+ # the pager can not be disabled per-session on the PIX
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
+ /^No matching debug flags set$/ && next;
+ ProcessHistory("COMMENTS","keysort","J1","!DEBUG: $_");
+ $lines++;
+ }
+ if ($lines) {
+ ProcessHistory("COMMENTS","keysort","J0","!\n");
+ }
+ return(0);
+}
+
# This routine parses "show diagbus"
# This will create arrarys for hw info.
sub ShowDiagbus {
@@ -744,7 +834,11 @@ sub ShowDiagbus {
return(1) if /(Invalid input detected|Type help or )/;
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
if (/^\s*Slot (\d+):/i) {
$slot = $1;
next;
@@ -836,7 +930,10 @@ REDUX: tr/\015//d;
return(0) if ($found_diag); # Only do this routine once
/^$/ && next;
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
s/Port Packet Over SONET/POS/;
if (/^\s*SLOT\s+(\d+)\s+\((.*)\): (.*)/) {
@@ -851,13 +948,19 @@ REDUX: tr/\015//d;
ProcessHistory("SLOT","keysort","A","!Slot $slot: $2\n");
next;
}
+ if (/^\s*PLIM\s+(\S+) : (.*)/) {
+ $slot = $1 . " PLIM";
+ ProcessHistory("SLOT","","","!\n");
+ ProcessHistory("SLOT","keysort","A","!Slot $slot: $2\n");
+ next;
+ }
if (/^\s*RACK\s+(\S+) : (.*)/) {
$slot = "Rack/" . $1;
ProcessHistory("SLOT","","","!\n");
ProcessHistory("SLOT","keysort","A","!Slot $slot: $2\n");
next;
}
- if (/^\s+MAIN:\s* type \d+,\s+(.*)/) {
+ if (/^\s+MAIN:\s* type \S+,\s+(.*)/) {
local($part) = $1;
$_ = <INPUT>;
if (/^\s+(HW version|Design Release) (\S+)\s+S\/N (\S+)/i) {
@@ -869,6 +972,31 @@ REDUX: tr/\015//d;
}
next;
}
+ if (/^\s+MAIN:\s* board type \S+$/) {
+ $_ = <INPUT>;
+ tr/\015//d;
+ if (/^\s+(.+)$/) {
+ local($part) = $1;
+ $_ = <INPUT>;
+ tr/\015//d;
+ if (/^\s+dev (.*)$/) {
+ local($dev) = $1;
+ $_ = <INPUT>;
+ if (/^\s+S\/N (\S+)/) {
+ ProcessHistory("SLOT","keysort","AM","!Slot $slot/MAIN: part $part, dev $dev, serial $1\n");
+ } else {
+ ProcessHistory("SLOT","keysort","AM","!Slot $slot/MAIN: part $part, dev $dev\n");
+ goto REDUX;
+ }
+ } else {
+ ProcessHistory("SLOT","keysort","AM","!Slot $slot/MAIN: part $part\n");
+ goto REDUX;
+ }
+ } else {
+ goto REDUX;
+ }
+ next;
+ }
if (/^c3700\s+(io-board|mid-plane)/i) {
$slot=$1;
ProcessHistory("SLOT","","","!\n");
@@ -882,6 +1010,14 @@ REDUX: tr/\015//d;
ProcessHistory("SLOT","keysort","AF","!Slot $slot/FRU: Linecard/Module: $1\n");
next;
}
+ if (/\s+Processor Memory:\s+(\S+)/) {
+ ProcessHistory("SLOT","keysort","AF","!Slot $slot/FRU: Processor Memory: $1\n");
+ next;
+ }
+ if (/\s+Packet Memory:\s+(\S+)/) {
+ ProcessHistory("SLOT","keysort","AF","!Slot $slot/FRU: Packet Memory: $1\n");
+ next;
+ }
if (/^\s+PCA:\s+(.*)/) {
local($part) = $1;
$_ = <INPUT>;
@@ -1041,22 +1177,24 @@ sub ShowInventory {
return if (/^\s*\^$/);
last if (/^$prompt/);
next if (/^(\s*|\s*$cmd\s*)$/);
+ return(1) if /Line has invalid autocommand /;
+ return(1) if /(Invalid input detected|Type help or )/;
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
-
- chomp;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
- # split PID/VID line
- if (/^(NAME: ".*,) (DESCR: .*)/) {
- ProcessHistory("INVENTORY","","", sprintf("!%-30s%s\n", $1, $2));
+ if (/^(NAME: "[^"]*",) (DESCR: "[^"]+")/) {
+ ProcessHistory("INVENTORY","","", sprintf("!%-30s %s\n", $1, $2));
next;
}
- if (/^(PID: \w?) *, (VID: .*), (SN: .*)$/) {
+ # split PID/VID line
+ if (/^(PID: \S*)\s*, (VID: \S*)\s*, (SN: \S*)\s*$/) {
ProcessHistory("INVENTORY","","", "!$1\n!$2\n!$3\n");
next;
}
-
ProcessHistory("INVENTORY","","","!$_");
}
ProcessHistory("INVENTORY","","","!\n");
@@ -1079,7 +1217,10 @@ sub ShowModule {
next if (/^(\s*|\s*$cmd\s*)$/);
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
# match slot/card info line
if (/^ *(\d+)\s+(\d+)\s+(.*)\s+(\S+)\s+(\S+)\s*$/) {
@@ -1147,7 +1288,11 @@ sub ShowC7200 {
return(-1) if (/command authorization failed/i);
/^$/ && next;
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
if (/^(C7200 )?Midplane EEPROM:/) {
$_ = <INPUT>;
/revision\s+(\S+).*revision\s+(\S+)/;
@@ -1194,7 +1339,11 @@ sub ShowVTP {
return(-1) if (/command authorization failed/i);
next if (/^Configuration last modified by/);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
if (/^VTP Operating Mode\s+:\s+(Transparent|Server)/) {
$DO_SHOW_VLAN = 1;
}
@@ -1222,7 +1371,11 @@ sub ShowVLAN {
#return(1) if ($type !~ /^(2900XL|3500XL|6000)$/);
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
ProcessHistory("COMMENTS","keysort","IO","!VLAN: $_");
}
ProcessHistory("COMMENTS","keysort","IO","!\n");
@@ -1236,12 +1389,16 @@ sub WriteTerm {
while (<INPUT>) {
tr/\015//d;
- last if(/^$prompt/);
+ last if (/^$prompt/);
return(1) if /Line has invalid autocommand /;
- return(1) if /(Invalid input detected|Type help or )/;
+ return(1) if (/(Invalid input detected|Type help or )/i);
return(-1) if (/command authorization failed/i);
# the pager can not be disabled per-session on the PIX
- s/^<-+ More -+>\s*//;
+ if (/^(<-+ More -+>)/) {
+ my($len) = length($1);
+ s/^$1\s{$len}//;
+ }
+
/Non-Volatile memory is in use/ && return(-1); # NvRAM is locked
return(0) if ($found_end); # Only do this routine once
$linecnt++;
@@ -1358,6 +1515,10 @@ sub WriteTerm {
if (/^( ip ospf message-digest-key \d+ md5) / && $filter_pwds >= 1) {
ProcessHistory("","","","!$1 <removed>\n"); next;
}
+ # this is also reversable, despite 'md5 encrypted' in the cmd
+ if (/^( message-digest-key \d+ md5 (7|encrypted)) / && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>\n"); next;
+ }
if (/^((crypto )?isakmp key) \S+ / && $filter_pwds >= 1) {
ProcessHistory("","","","!$1 <removed> $'"); next;
}
@@ -1480,12 +1641,9 @@ sub WriteTerm {
}
}
# prune tacacs/radius server keys
- if (/^(tacacs-server|radius-server) key / && $filter_pwds >= 1) {
- ProcessHistory("","","","!$1 key <removed>\n"); next;
- }
- if (/^((tacacs-server|radius-server) host \S+ key) / &&
- $filter_pwds >= 1) {
- ProcessHistory("","","","!$1 <removed>\n"); next;
+ if (/^((tacacs-server|radius-server)\s(\w*[-\s(\s\S+])*\s?key) \d \w+/
+ && $filter_pwds >= 1) {
+ ProcessHistory("","","","!$1 <removed>$'\n"); next;
}
# order clns host statements
/^clns host \S+ (\S+)/ &&
@@ -1556,8 +1714,10 @@ sub DoNothing {print STDOUT;}
{'show env all' => 'ShowEnv'},
{'show rsp chassis-info', => 'ShowRSP'},
{'show gsr chassis' => 'ShowGSR'},
+ {'show diag chassis-info' => 'ShowGSR'},
{'show boot' => 'ShowBoot'},
{'show bootvar' => 'ShowBoot'},
+ {'admin show variables boot' => 'ShowBoot'},
{'show variables boot' => 'ShowBoot'},
{'show flash' => 'ShowFlash'},
{'dir /all nvram:' => 'DirSlotN'},
@@ -1601,6 +1761,7 @@ sub DoNothing {print STDOUT;}
{'show inventory raw' => 'ShowInventory'},
{'show vtp status' => 'ShowVTP'},
{'show vlan' => 'ShowVLAN'},
+ {'show debug' => 'ShowDebug'},
{'show running-config' => 'WriteTerm'},
{'write term' => 'WriteTerm'},
);
@@ -1612,6 +1773,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/rivrancid.in b/bin/rivrancid.in
index 6d5f869..e069b3b 100644
--- a/bin/rivrancid.in
+++ b/bin/rivrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: rivrancid.in,v 1.14 2005/06/15 20:54:41 heas Exp $
+## $Id: rivrancid.in,v 1.15 2005/09/25 17:48:30 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -27,7 +27,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rivrancid [-d] [-l] [-f filename | $host]
+# usage: rivrancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -242,6 +242,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/rrancid.in b/bin/rrancid.in
index fdfb39c..1bc688f 100644
--- a/bin/rrancid.in
+++ b/bin/rrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: rrancid.in,v 1.23 2005/06/15 20:54:41 heas Exp $
+## $Id: rrancid.in,v 1.24 2005/09/25 17:48:31 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -23,7 +23,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -302,6 +302,15 @@ sub FlailHelplessly {
$redback_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered
diff --git a/bin/tntrancid.in b/bin/tntrancid.in
index ac3bbee..94a3120 100644
--- a/bin/tntrancid.in
+++ b/bin/tntrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: tntrancid.in,v 1.14 2005/06/15 20:54:41 heas Exp $
+## $Id: tntrancid.in,v 1.15 2005/09/25 17:48:31 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -24,7 +24,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: tntrancid [-d] [-l] [-f filename | $host]
+# usage: tntrancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -195,6 +195,15 @@ sub DoNothing {print STDOUT;}
$tnt_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/bin/xrancid.in b/bin/xrancid.in
index 718c699..80e7e5b 100644
--- a/bin/xrancid.in
+++ b/bin/xrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: xrancid.in,v 1.37 2005/06/15 20:54:41 heas Exp $
+## $Id: xrancid.in,v 1.39 2006/03/23 18:43:01 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -21,7 +21,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -391,6 +391,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
@@ -448,7 +457,7 @@ TOP: while(<INPUT>) {
if (!defined($prompt)) {
$prompt = ($_ =~ /^([^#]+#)/)[0];
$prompt =~ s/([][}{)(\\])/\\$1/g;
- $prompt =~ s/:(\d+ ?)#/:\\d+ ?#/;
+ $prompt =~ s/[:.](\d+ ?)#/:\\d+ ?#/;
$prompt =~ s/\*/\\\*/;
print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);
}
diff --git a/bin/zrancid.in b/bin/zrancid.in
index 0eae9ef..f98c762 100755
--- a/bin/zrancid.in
+++ b/bin/zrancid.in
@@ -1,6 +1,6 @@
#! @PERLV_PATH@
##
-## $Id: zrancid.in,v 1.11 2005/06/15 20:54:41 heas Exp $
+## $Id: zrancid.in,v 1.12 2005/09/25 17:48:31 heas Exp $
##
## Copyright (C) 1997-2004 by Terrapin Communications, Inc.
## All rights reserved.
@@ -23,7 +23,7 @@
#
# RANCID - Really Awesome New Cisco confIg Differ
#
-# usage: rancid [-d] [-l] [-f filename | $host]
+# usage: rancid [-d] [-l] [-f filename | hostname]
#
use Getopt::Std;
getopts('dfl');
@@ -319,6 +319,15 @@ sub DoNothing {print STDOUT;}
$cisco_cmds=join(";",@commands);
$cmds_regexp=join("|",@commands);
+if (length($host) == 0) {
+ if ($file) {
+ print(STDERR "Too few arguments: file name required\n");
+ exit(1);
+ } else {
+ print(STDERR "Too few arguments: host name required\n");
+ exit(1);
+ }
+}
open(OUTPUT,">$host.new") || die "Can't open $host.new for writing: $!\n";
select(OUTPUT);
# make OUTPUT unbuffered if debugging
diff --git a/configure b/configure
index c88aca6..e91ff04 100755
--- a/configure
+++ b/configure
@@ -4257,7 +4257,17 @@ fi
-for ac_header in limits.h memory.h siginfo.h string.h strings.h unistd.h
+
+
+
+
+
+
+
+
+for ac_header in errno.h fcntl.h limits.h pty.h malloc.h memory.h siginfo.h \
+ string.h strings.h stropts.h sys/types.h sys/wait.h unistd.h \
+ util.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -4407,11 +4417,7 @@ fi
done
-
-
-
-
-for ac_header in errno.h fcntl.h sys/types.h sys/wait.h
+for ac_header in sysexits.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -4561,33 +4567,82 @@ fi
done
-for ac_header in sysexits.h
+# check functions
+
+
+
+
+
+
+
+
+
+
+
+
+for ac_func in memcpy memmove memset strerror strchr \
+ strrchr strstr strtok strrtok index rindex unsetenv
do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* 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 ();
+/* 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
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
@@ -4601,132 +4656,232 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
+ { ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ac_header_compiler=yes
+ eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-ac_header_compiler=no
+eval "$as_ac_var=no"
fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
+fi
+done
+
+
+for ac_func in openpty
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <$ac_header>
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* 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 ();
+/* 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
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## ------------------------------------------ ##
-## Report this to the AC_PACKAGE_NAME lists. ##
-## ------------------------------------------ ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
+eval "$as_ac_var=no"
fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
-
+ openpty=1
+else
+ openpty=0
fi
-
done
+# openlog() is not in the default libraries. See if it is in some other lib.
+if test $openpty = 0; then
+ for lib in util; do
+ as_ac_Lib=`echo "ac_cv_lib_$lib''_openpty" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for openpty in -l$lib" >&5
+echo $ECHO_N "checking for openpty in -l$lib... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Lib+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-l$lib $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
-# check functions
-
-
-
-
-
-
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char openpty ();
+int
+main ()
+{
+openpty ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Lib=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+eval "$as_ac_Lib=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
+if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_OPENPTY 1
+_ACEOF
+ LIBS="$LIBS -l$lib"; openpty=1; break
+fi
+ done
+fi
+# If we dont have openpty, then look for /dev/ptmx for use by our own
+# openpty().
+if test $openpty = 0; then
+ # This check (partially) comes from expect's configure
+ echo "$as_me:$LINENO: checking for SVR4 style pty allocation" >&5
+echo $ECHO_N "checking for SVR4 style pty allocation... $ECHO_C" >&6
+ if test -r /dev/ptmx ; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_PTMX 1
+_ACEOF
+ # Some systems need libpt.a to use /dev/ptmx
-for ac_func in memcpy memmove memset bcopy bzero strerror strchr strrchr \
- strstr strtok strrtok index rindex
+for ac_func in ptsname
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -4827,6 +4982,103 @@ _ACEOF
fi
done
+ if test $ac_cv_func_ptsname+set != set; then
+ # ptsname is not in the default libraries.
+ for lib in pt; do
+ as_ac_Lib=`echo "ac_cv_lib_$lib''_ptsname" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for ptsname in -l$lib" >&5
+echo $ECHO_N "checking for ptsname in -l$lib... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Lib+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-l$lib $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char ptsname ();
+int
+main ()
+{
+ptsname ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Lib=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Lib=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6
+if test `eval echo '${'$as_ac_Lib'}'` = yes; then
+ LIBS="$LIBS -l$lib"; break
+fi
+
+ done
+ fi
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ fi
+ # In OSF/1 case, SVR4 are somewhat different.
+ # Gregory Depp <depp@osf.org> 17Aug93
+ echo "$as_me:$LINENO: checking for OSF/1 style pty allocation" >&5
+echo $ECHO_N "checking for OSF/1 style pty allocation... $ECHO_C" >&6
+
+
+ if test -r /dev/ptmx_bsd ; then
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_PTMX_OSF 1
+_ACEOF
+
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ fi
+fi
+
# type checks
echo "$as_me:$LINENO: checking return type of signal handlers" >&5
@@ -6139,8 +6391,14 @@ ac_cv_env_path=$ENV_PATH
# AC_CONFIG_HEADERS will cause
# autoheader to overwrite it, while all
# want is simple variable replacement
+# autoheader bits
+
+
+
+
ac_config_headers="$ac_config_headers include/config.h"
+
ac_config_files="$ac_config_files bin/control_rancid bin/par bin/rancid-fe"
ac_config_files="$ac_config_files bin/alogin bin/arancid"
diff --git a/configure.in b/configure.in
index ab63ac4..b5856ae 100644
--- a/configure.in
+++ b/configure.in
@@ -41,16 +41,54 @@ 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(errno.h fcntl.h limits.h pty.h malloc.h memory.h siginfo.h \
+ string.h strings.h stropts.h sys/types.h sys/wait.h unistd.h \
+ util.h)
AC_CHECK_HEADERS(sysexits.h)
# check functions
-AC_CHECK_FUNCS(memcpy memmove memset bcopy bzero strerror strchr strrchr \
- strstr strtok strrtok index rindex)
+AC_CHECK_FUNCS(memcpy memmove memset strerror strchr \
+ strrchr strstr strtok strrtok index rindex unsetenv)
+AC_CHECK_FUNCS(openpty, openpty=1, openpty=0)
+# openlog() is not in the default libraries. See if it is in some other lib.
+if test $openpty = 0; then
+ for lib in util; do
+ AC_CHECK_LIB($lib, openpty, [AC_DEFINE(HAVE_OPENPTY)
+ LIBS="$LIBS -l$lib"; openpty=1; break])
+ done
+fi
+# If we dont have openpty, then look for /dev/ptmx for use by our own
+# openpty().
+if test $openpty = 0; then
+ # This check (partially) comes from expect's configure
+ AC_MSG_CHECKING([for SVR4 style pty allocation])
+ AH_TEMPLATE(HAVE_PTMX, "define this if your o/s has /dev/ptmx")
+ if test -r /dev/ptmx ; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_PTMX)
+ # Some systems need libpt.a to use /dev/ptmx
+ AC_CHECK_FUNCS(ptsname)
+ if test $ac_cv_func_ptsname+set != set; then
+ # ptsname is not in the default libraries.
+ for lib in pt; do
+ AC_CHECK_LIB($lib, ptsname, [LIBS="$LIBS -l$lib"; break])
+ done
+ fi
+ else
+ AC_MSG_RESULT(no)
+ fi
+ # In OSF/1 case, SVR4 are somewhat different.
+ # Gregory Depp <depp@osf.org> 17Aug93
+ AC_MSG_CHECKING([for OSF/1 style pty allocation])
+ AH_TEMPLATE(HAVE_PTMX_OSF, "define this for OSF/1 ptmx")
+ if test -r /dev/ptmx_bsd ; then
+ AC_DEFINE(HAVE_PTMX_OSF)
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ fi
+fi
+
dnl AC_FUNC_VPRINTF
# type checks
@@ -299,7 +337,90 @@ AC_CONFIG_FILES(include/version.h) # this is not a header in the sense of
# AC_CONFIG_HEADERS will cause
# autoheader to overwrite it, while all
# want is simple variable replacement
+# autoheader bits
+AH_TOP([
+#ifndef CONFIG_H
+#define CONFIG_H 1
+])
+AH_BOTTOM([
+
+/* damned linux... */
+#ifdef LINUX
+# define _GNU_SOURCE
+#endif
+
+#ifndef __P
+# if STDC_HEADERS
+# define __P(a) a
+# else
+# define __P(a) ()
+# endif
+#endif
+
+#if HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+# include <sys/types.h>
+#elif HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#if HAVE_ERRNO_H
+# include <errno.h>
+#endif
+extern int errno;
+
+#if HAVE_STRING_H
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+
+#if ! HAVE_STRERROR
+# define strerror(n) sys_errlist[n];
+#endif
+
+#if HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#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 <sysexits.h>
+#else
+ /* missing sysexits.h */
+# define EX_OK 0
+# define EX_USAGE 64 /* command line usage error */
+# define EX_NOINPUT 66 /* cannot open input */
+# define EX_TEMPFAIL 75 /* temp failure */
+# define EX_OSERR 71 /* system error */
+# define EX_CANTCREAT 73 /* can't create (user) output file */
+# define EX_IOERR 74 /* input/output error */
+# define EX_CONFIG 78 /* configuration error */
+#endif
+
+#endif /* CONFIG_H */
+])
AC_CONFIG_HEADERS(include/config.h)
+
AC_CONFIG_FILES(bin/control_rancid bin/par bin/rancid-fe, [chmod a+x $ac_file])
AC_CONFIG_FILES(bin/alogin bin/arancid, [chmod a+x $ac_file])
AC_CONFIG_FILES(bin/blogin bin/brancid, [chmod a+x $ac_file])
diff --git a/etc/Makefile.in b/etc/Makefile.in
index f625e2f..bc6f079 100644
--- a/etc/Makefile.in
+++ b/etc/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/include/Makefile.in b/include/Makefile.in
index c31b905..ed2c23f 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -205,7 +205,7 @@ config.h: stamp-h1
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status include/config.h
-$(srcdir)/config.h.in: $(am__configure_deps) $(top_srcdir)/acconfig.h
+$(srcdir)/config.h.in: $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
diff --git a/include/config.h b/include/config.h
index 5648d5d..c2bb7cc 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1,15 +1,10 @@
/* include/config.h. Generated by configure. */
/* include/config.h.in. Generated from configure.in by autoheader. */
-#ifndef CONFIG_H
-#define CONFIG_H 1
+#ifndef CONFIG_H
+#define CONFIG_H 1
-/* Define to 1 if you have the `bcopy' function. */
-#define HAVE_BCOPY 1
-
-/* Define to 1 if you have the `bzero' function. */
-#define HAVE_BZERO 1
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
@@ -26,6 +21,9 @@
/* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
+/* Define to 1 if you have the <malloc.h> header file. */
+#define HAVE_MALLOC_H 1
+
/* Define to 1 if you have the `memcpy' function. */
#define HAVE_MEMCPY 1
@@ -38,6 +36,21 @@
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
+/* Define to 1 if you have the `openpty' function. */
+#define HAVE_OPENPTY 1
+
+/* "define this if your o/s has /dev/ptmx" */
+/* #undef HAVE_PTMX */
+
+/* "define this for OSF/1 ptmx" */
+/* #undef HAVE_PTMX_OSF */
+
+/* Define to 1 if you have the `ptsname' function. */
+/* #undef HAVE_PTSNAME */
+
+/* Define to 1 if you have the <pty.h> header file. */
+/* #undef HAVE_PTY_H */
+
/* Define to 1 if you have the `rindex' function. */
#define HAVE_RINDEX 1
@@ -65,6 +78,9 @@
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
+/* Define to 1 if you have the <stropts.h> header file. */
+/* #undef HAVE_STROPTS_H */
+
/* Define to 1 if you have the `strrchr' function. */
#define HAVE_STRRCHR 1
@@ -92,6 +108,12 @@
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
+/* Define to 1 if you have the `unsetenv' function. */
+#define HAVE_UNSETENV 1
+
+/* Define to 1 if you have the <util.h> header file. */
+#define HAVE_UTIL_H 1
+
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
@@ -131,6 +153,13 @@
/* Define to `unsigned' if <sys/types.h> does not define. */
/* #undef size_t */
+
+
+/* damned linux... */
+#ifdef LINUX
+# define _GNU_SOURCE
+#endif
+
#ifndef __P
# if STDC_HEADERS
# define __P(a) a
@@ -139,8 +168,6 @@
# endif
#endif
-#define BUF_SZ LINE_MAX /* (increments of) size of bufs */
-
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
@@ -201,4 +228,5 @@ extern int errno;
# define EX_CONFIG 78 /* configuration error */
#endif
-#endif /* CONFIG_H */
+#endif /* CONFIG_H */
+
diff --git a/include/config.h.in b/include/config.h.in
index 6a867fd..2574de8 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -1,14 +1,9 @@
/* include/config.h.in. Generated from configure.in by autoheader. */
-#ifndef CONFIG_H
-#define CONFIG_H 1
+#ifndef CONFIG_H
+#define CONFIG_H 1
-/* Define to 1 if you have the `bcopy' function. */
-#undef HAVE_BCOPY
-
-/* Define to 1 if you have the `bzero' function. */
-#undef HAVE_BZERO
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
@@ -25,6 +20,9 @@
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
+/* Define to 1 if you have the <malloc.h> header file. */
+#undef HAVE_MALLOC_H
+
/* Define to 1 if you have the `memcpy' function. */
#undef HAVE_MEMCPY
@@ -37,6 +35,21 @@
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
+/* Define to 1 if you have the `openpty' function. */
+#undef HAVE_OPENPTY
+
+/* "define this if your o/s has /dev/ptmx" */
+#undef HAVE_PTMX
+
+/* "define this for OSF/1 ptmx" */
+#undef HAVE_PTMX_OSF
+
+/* Define to 1 if you have the `ptsname' function. */
+#undef HAVE_PTSNAME
+
+/* Define to 1 if you have the <pty.h> header file. */
+#undef HAVE_PTY_H
+
/* Define to 1 if you have the `rindex' function. */
#undef HAVE_RINDEX
@@ -64,6 +77,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if you have the <stropts.h> header file. */
+#undef HAVE_STROPTS_H
+
/* Define to 1 if you have the `strrchr' function. */
#undef HAVE_STRRCHR
@@ -91,6 +107,12 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* Define to 1 if you have the `unsetenv' function. */
+#undef HAVE_UNSETENV
+
+/* Define to 1 if you have the <util.h> header file. */
+#undef HAVE_UTIL_H
+
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
@@ -130,6 +152,13 @@
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
+
+
+/* damned linux... */
+#ifdef LINUX
+# define _GNU_SOURCE
+#endif
+
#ifndef __P
# if STDC_HEADERS
# define __P(a) a
@@ -138,8 +167,6 @@
# endif
#endif
-#define BUF_SZ LINE_MAX /* (increments of) size of bufs */
-
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
@@ -200,4 +227,5 @@ extern int errno;
# define EX_CONFIG 78 /* configuration error */
#endif
-#endif /* CONFIG_H */
+#endif /* CONFIG_H */
+
diff --git a/include/version.h b/include/version.h
index c51c1ae..a5b65c8 100644
--- a/include/version.h
+++ b/include/version.h
@@ -4,6 +4,6 @@
/* pkg version */
char package[] = "rancid";
-char version[] = "2.3.2a3";
+char version[] = "2.3.2a4";
#endif
diff --git a/include/version.h.in b/include/version.h.in
index c51c1ae..a5b65c8 100644
--- a/include/version.h.in
+++ b/include/version.h.in
@@ -4,6 +4,6 @@
/* pkg version */
char package[] = "rancid";
-char version[] = "2.3.2a3";
+char version[] = "2.3.2a4";
#endif
diff --git a/man/Makefile.in b/man/Makefile.in
index 2bcf956..43d1c07 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/man/clogin.1 b/man/clogin.1
index 49093ee..28ea7fd 100644
--- a/man/clogin.1
+++ b/man/clogin.1
@@ -1,6 +1,6 @@
.\"
.hys 50
-.TH "clogin" "1" "6 Jan 2004"
+.TH "clogin" "1" "26 September 2005"
.SH NAME
clogin \- Cisco/Foundry login script
.SH SYNOPSIS
@@ -262,3 +262,7 @@ there are side effects for interactive logins via hlogin; most of which are
formatting annoyances that may be remedied by typing CTRL-R to reprint the
current line.
.PP
+WARNING: repeated ssh login failures to HP Procurves cause the switch's
+management interface to lock-up (this includes snmp, ping) and sometimes
+it will crash. This is with the latest firmware; 5.33 at the time of this
+writing.
diff --git a/man/cloginrc.5 b/man/cloginrc.5
index d8fc6a0..49553fd 100644
--- a/man/cloginrc.5
+++ b/man/cloginrc.5
@@ -1,8 +1,8 @@
.\"
-.\" $Id: cloginrc.5,v 1.36 2004/06/24 16:03:24 heas Exp $
+.\" $Id: cloginrc.5,v 1.37 2005/09/12 18:48:19 heas Exp $
.\"
.hys 50
-.TH "cloginrc" "5" "23 June 2004"
+.TH "cloginrc" "5" "12 September 2005"
.SH NAME
\.cloginrc \- clogin configuration file
.SH DESCRIPTION
@@ -218,6 +218,16 @@ 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 sshcmd <router name glob> {<ssh>}
+<ssh> is the name of the ssh executable. OpenSSH uses a command-line
+option to specify the protocol version, but other implementations use
+a separate binary such as "ssh1".
+.B sshcmd
+allows this to be adjusted as necessary for the local environment.
+.sp
+Default: ssh
+.\"
.\" .TP
.\" .B add rc <router name glob> {<cmd;cmd>}
.\" rc is used to specifies a command that will be run by
@@ -270,16 +280,6 @@ file that is shared among a group of folks.
If <file> is not a full pathname, $HOME/ will be prepended.
.sp
Example: include {.cloginrc.group}
-.\"
-.TP
-.B add sshcmd {<ssh>}
-<ssh> is the name of the ssh executable. OpenSSH uses a command-line
-option to specify the protocol version, but other implementations use
-a separate binary such as "ssh1".
-.B sshcmd
-allows this to be adjusted as necessary for the local environment.
-.sp
-Default: ssh
.El
.SH FILES
.br
diff --git a/man/rancid.conf.5.in b/man/rancid.conf.5.in
index e89568a..a3735eb 100644
--- a/man/rancid.conf.5.in
+++ b/man/rancid.conf.5.in
@@ -1,8 +1,8 @@
.\"
-.\" $Id: rancid.conf.5.in,v 1.15 2005/08/15 00:41:51 heas Exp $
+.\" $Id: rancid.conf.5.in,v 1.16 2005/09/27 16:39:27 heas Exp $
.\"
.hys 50
-.TH "rancid.conf" "5" "13 August 2005"
+.TH "rancid.conf" "5" "23 September 2005"
.SH NAME
rancid.conf \- rancid environment configuration file
.SH DESCRIPTION
@@ -10,10 +10,10 @@ rancid.conf \- rancid environment configuration file
contains environment configuration information for
.BR rancid-run (1)
and
-.BR rancid (1)
-including shell PATH, list of rancid groups, etc. and is read by several
-scripts at run-time, including
-.BR rancid-run (1).
+.BR rancid-cvs (1),
+including shell PATH, list of rancid groups, etc.
+It is read by several scripts at run-time and others inherit the
+configration from a parent process which has read it.
.PP
The syntax of
.B rancid.conf
diff --git a/share/Makefile.in b/share/Makefile.in
index b9d183d..5ac7283 100644
--- a/share/Makefile.in
+++ b/share/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,