diff options
-rw-r--r-- | bin/clogin.in | 65 | ||||
-rw-r--r-- | bin/xrancid.in | 31 |
2 files changed, 57 insertions, 39 deletions
diff --git a/bin/clogin.in b/bin/clogin.in index 81c654e..725bca8 100644 --- a/bin/clogin.in +++ b/bin/clogin.in @@ -572,28 +572,28 @@ proc run_commands { prompt command } { # If the prompt is (enable), then we are on a switch and the # command is "set length 0"; otherwise its "term length 0". - # skip if its an extreme (since the pager can not be disabled on a - # per-vty basis). - if { [ string compare "extreme" "$platform" ] } { - if [ regexp -- ".*> .*enable" "$prompt" ] { - send "set length 0\r" - # This is ugly, but reduces code duplication, allowing the - # subsequent expects to handle everything as normal. - set command "set logging session disable;$command" - } else { - send "term length 0\r" - } - # escape any parens in the prompt, such as "(enable)" - 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,11}).*([#>])$} $reprompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt - expect { - -re $reprompt {} - -re "\[\n\r]+" { exp_continue } - } + # ExtremeWare uses "disable clipaging session", XOS + # "disable clipaging". + if [ regexp -- ".*> .*enable" "$prompt" ] { + send "set length 0\r" + # This is ugly, but reduces code duplication, allowing the + # subsequent expects to handle everything as normal. + set command "set logging session disable;$command" + } elseif { ! [ string compare "extreme" "$platform" ] } { + send "disable clipaging session\r" + } elseif { ! [ string compare "extremexos" "$platform" ] } { + send "disable clipaging\r" } else { - regsub -all "\[)(]" $prompt {\\&} reprompt + send "term length 0\r" + } + # escape any parens in the prompt, such as "(enable)" + 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,11}).*([#>])$} $reprompt {\1([^#>\r\n]+)?[#>](\\([^)\\r\\n]+\\))?} reprompt + expect { + -re $reprompt {} + -re "\[\n\r]+" { exp_continue } } # this is the only way i see to get rid of more prompts in o/p..grrrrr @@ -603,8 +603,7 @@ proc run_commands { prompt command } { set commands [split $command \;] set num_commands [llength $commands] # the pager can not be turned off on the PIX, so we have to look - # for the "More" prompt. the extreme is equally obnoxious, with a - # global switch in the config. + # for the "More" prompt. for {set i 0} {$i < $num_commands} { incr i} { send "[subst -nocommands [lindex $commands $i]]\r" expect { @@ -637,8 +636,7 @@ proc run_commands { prompt command } { } } else { # the pager can not be turned off on the PIX, so we have to look - # for the "More" prompt. the extreme is equally obnoxious, with a - # global switch in the config. + # for the "More" prompt. send "[subst -nocommands $command]\r" expect { -re "\b+" { exp_continue } @@ -670,11 +668,8 @@ proc run_commands { prompt command } { } log_user 1 - if { [ string compare "extreme" "$platform" ] } { - send -h "exit\r" - } else { - send -h "quit\r" - } + send -h "quit\r" + expect { -re "^\[^\n\r *]*$reprompt" { # the Cisco CE and Jnx ERX @@ -837,7 +832,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) @@ -845,6 +840,14 @@ foreach router [lrange $argv $i end] { set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)"; set platform "extreme" } + -re "^(.+\.)1 ($prompt)" { # stoopid extreme cmd-line numbers and + # prompt based on state of config changes, + # which may have an * at the beginning. + set junk $expect_out(1,string) + regsub -all "^\\\* " $expect_out(1,string) {} junk + set prompt ".? ?$junk\[0-9]+ $expect_out(2,string)"; + set platform "extremexos" + } -re "^.+$prompt" { set junk $expect_out(0,string); regsub -all "\[\]\[]" $junk {\\&} prompt; } diff --git a/bin/xrancid.in b/bin/xrancid.in index 96b99ef..4a34fca 100644 --- a/bin/xrancid.in +++ b/bin/xrancid.in @@ -279,9 +279,10 @@ sub WriteTerm { while (<INPUT>) { tr/\015//d; - last if(/^$prompt/); + tr/\007//d; next if(/^\s*$/); return(0) if(/^syntax error at token /i); + return(0) if(/^%% Invalid input detected at /i); # the pager can not be disabled per-session on the PIX s/^<-+ More -+>\s*//; return(0) if ($found_end); @@ -317,14 +318,28 @@ sub WriteTerm { ProcessHistory("COMMENTS","keysort","H0","# $1 <key removed>\n"); next; } - if (/configure ssh2 key/ && $filter_pwds >= 1) { + # XOS (at least version 11.3.3.7) is buggy and sometimees outputs only + # the last 702 octets of the SSH key... make sure to strip it anyway + print STDERR "D \"$_\" D\n"; + if (/^(configure ssh2 key pregenerated|[a-f\d]{2}(:[a-f\d]{2}){700,}\s*$)/ && $filter_pwds >= 1) { + ProcessHistory("COMMENTS","keysort","H0","# configure ssh2 key <key removed>\n"); + # Only EW has a multiline key (terminated by a blank line) + # XOS has only one line so jump to the next iteration immediately + # to make sure we don't lose the next config statement + next unless /^configure ssh2 key pregenerated$/; + while (<INPUT>) { + last if (/^\s*\r?$/); + } + next; + } + # This changes each time the configuration is shown, so remove it + # unconditionally as it is documented in rancid.conf(5). + if (/configure ssl privkey/) { ProcessHistory("COMMENTS","keysort","H0","# $_# <key removed>\n"); while (<INPUT>) { - if (/^(#|enable|conf|disable|unconf)/) { - tr/\015//d; - last; - } + last if (/^\.\r?$/); } + next; } # filter out any RCS/CVS tags to avoid confusing local CVS storage @@ -366,7 +381,7 @@ sub WriteTerm { # catch anything that wasnt match above. ProcessHistory("COMMENTS","keysort","H0","$_"); # end of config - if (/^# End of configuration file/i) { + if (/^($prompt|# End of configuration file)/i) { printf STDERR " End WriteTerm: $_" if ($debug); $found_end = 1; return(0); @@ -462,7 +477,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); } |