summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-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
29 files changed, 1041 insertions, 321 deletions
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