Re: [rancid] router config diffs

2018-10-25 Thread heasley
Thu, Oct 25, 2018 at 04:33:45PM -0400, Lee:
> On 10/25/18, heasley  wrote:
> > Thu, Oct 25, 2018 at 04:46:48AM +, Wayne Eisenberg:
> >> > I'd go with changing control_rancid.  Search for
> >> >
> >> > # Mail out the diffs (if there are any).
> >> > if [ -s $TMP.diff ] ; then
> >>
> >> Bingo. I found my tweak. Thanks, Lee! Instead of actually sending the
> >> email, I had just redirected it to /dev/null.
> >>
> >> -) | $SENDMAIL -t $MAILOPTS
> >> +   ) > /dev/null
> >>
> >> Maybe that could be a config choice in rancid.conf (if it were a global
> >> switch) or .cloginrc (if you wanted to turn off mail for specific devices
> >> or groups)?
> >>
> >>
> >> -Original Message-
> >> From: Lee [mailto:ler...@gmail.com]
> >> Sent: Sunday, October 21, 2018 5:46 PM
> >> To: Wayne Eisenberg 
> >> Cc: rancid-discuss@shrubbery.net
> >> Subject: Re: [rancid] router config diffs
> >>
> >> On 10/21/18, Wayne Eisenberg  wrote:
>   <.. snip ..>
> >> > I probably didn't do a good job of explaining. I'm not getting the
> >> > same diff over and over. They are new versions, valid diffs. I don't
> >> > see how svn could get out of sync, when the crontab was inactive
> >> > (everything rem'ed out) so there was no activity during the upgrade.
> >> > Before the upgrade, I know there were router config changes taking
> >> > place and I did not get an email about them. Now I do. So I'm hunting
> >> > for how to turn the notifications off.
> >>
> >> I'd go with changing control_rancid.  Search for
> >
> > why?  there are 3 manners of affecting the same result, but without
> > modifying the installed base and without needing to remember that
> > change following the next upgrade.  embrace the unix
> > methodology - assemble (pipe) simple tools for complex results.
> 
> I haven't tried this, but it sure looks like one could build rancid with
> export SENDMAIL=/usr/local/bin/sendmail_alt
> ./configure --prefix= ..etc..
> 
> and have /usr/local/bin/sendmail_alt be just
> exit

youre making that more difficult than necessary,

export SENDMAIL="dd of=/dev/null bs=32k"

but, you still want the admin email, imiho, and that will break it.

> and that would take care of not sending emails or doing something
> other than sending mail.  Yes?   but that means you'd have to build
> rancid instead of just installing from some repository..
> 
> In any case, I went with changing control_rancid because there were a
> few other things I wanted to do like filtering out passwords, keys,
> hashes, etc. from the mail msg before sending it. So right after the
>   # Diff the directory and then checkin.
> section I added
> 
> # -LR- begin: remove passwords, etc. from diff listing
> /usr/local/bin/sanitize.sh $TMP.diff >$TMP.diff2
> /bin/mv  $TMP.diff2 $TMP.diff
> # -LR- end  : remove passwords etc. from diff listing

this too is possible without changing control_rancid; see rancid.conf(5)
for FILTER_PWDS & DIFFSCRIPT.

___
Rancid-discuss mailing list
Rancid-discuss@shrubbery.net
http://www.shrubbery.net/mailman/listinfo/rancid-discuss


Re: [rancid] clogin commenting script commands following multiple blanks lines

2018-10-25 Thread Erik Muller

On 10/25/18 16:02 , Heasley wrote:




Am 25.10.2018 um 12:53 schrieb Erik Muller :


On 10/24/18 18:32 , heasley wrote:
Wed, Oct 24, 2018 at 09:19:31PM +, heasley:

I missed that in your example, but noticed it in testing...after I sent that
patch.  This is my final patch, i think.  I havent committed it yet, as I
want to review it once more.


ok; committed.  Either the alpha tarball or the svn repo.  Welcome testers,
esp for palo alto, of which I have none.


That one was really close, but still didn't pass through ^; from command files 
properly.
After a bit more tweaking, the following change seems to get it to handle all 
my test cases correctly.



You have to escape the ; in the file (\;). The An argument could be made either 
way, i leN toward not altering the behavior of -x.


I can live with that.  Looks like ^; was equally broken in 2.x as well, and 
really it should be !comments instead since ~ios 10 anyway ;)


___
Rancid-discuss mailing list
Rancid-discuss@shrubbery.net
http://www.shrubbery.net/mailman/listinfo/rancid-discuss


Re: [rancid] router config diffs

2018-10-25 Thread Lee
On 10/25/18, heasley  wrote:
> Thu, Oct 25, 2018 at 04:46:48AM +, Wayne Eisenberg:
>> > I'd go with changing control_rancid.  Search for
>> >
>> > # Mail out the diffs (if there are any).
>> > if [ -s $TMP.diff ] ; then
>>
>> Bingo. I found my tweak. Thanks, Lee! Instead of actually sending the
>> email, I had just redirected it to /dev/null.
>>
>> -) | $SENDMAIL -t $MAILOPTS
>> +   ) > /dev/null
>>
>> Maybe that could be a config choice in rancid.conf (if it were a global
>> switch) or .cloginrc (if you wanted to turn off mail for specific devices
>> or groups)?
>>
>>
>> -Original Message-
>> From: Lee [mailto:ler...@gmail.com]
>> Sent: Sunday, October 21, 2018 5:46 PM
>> To: Wayne Eisenberg 
>> Cc: rancid-discuss@shrubbery.net
>> Subject: Re: [rancid] router config diffs
>>
>> On 10/21/18, Wayne Eisenberg  wrote:
  <.. snip ..>
>> > I probably didn't do a good job of explaining. I'm not getting the
>> > same diff over and over. They are new versions, valid diffs. I don't
>> > see how svn could get out of sync, when the crontab was inactive
>> > (everything rem'ed out) so there was no activity during the upgrade.
>> > Before the upgrade, I know there were router config changes taking
>> > place and I did not get an email about them. Now I do. So I'm hunting
>> > for how to turn the notifications off.
>>
>> I'd go with changing control_rancid.  Search for
>
> why?  there are 3 manners of affecting the same result, but without
> modifying the installed base and without needing to remember that
> change following the next upgrade.  embrace the unix
> methodology - assemble (pipe) simple tools for complex results.

I haven't tried this, but it sure looks like one could build rancid with
export SENDMAIL=/usr/local/bin/sendmail_alt
./configure --prefix= ..etc..

and have /usr/local/bin/sendmail_alt be just
exit

and that would take care of not sending emails or doing something
other than sending mail.  Yes?   but that means you'd have to build
rancid instead of just installing from some repository..

In any case, I went with changing control_rancid because there were a
few other things I wanted to do like filtering out passwords, keys,
hashes, etc. from the mail msg before sending it. So right after the
  # Diff the directory and then checkin.
section I added

# -LR- begin: remove passwords, etc. from diff listing
/usr/local/bin/sanitize.sh $TMP.diff >$TMP.diff2
/bin/mv  $TMP.diff2 $TMP.diff
# -LR- end  : remove passwords etc. from diff listing

Regards,
Lee

___
Rancid-discuss mailing list
Rancid-discuss@shrubbery.net
http://www.shrubbery.net/mailman/listinfo/rancid-discuss


Re: [rancid] clogin commenting script commands following multiple blanks lines

2018-10-25 Thread Heasley



> Am 25.10.2018 um 12:53 schrieb Erik Muller :
> 
>> On 10/24/18 18:32 , heasley wrote:
>> Wed, Oct 24, 2018 at 09:19:31PM +, heasley:
>>> I missed that in your example, but noticed it in testing...after I sent that
>>> patch.  This is my final patch, i think.  I havent committed it yet, as I
>>> want to review it once more.
>> 
>> ok; committed.  Either the alpha tarball or the svn repo.  Welcome testers,
>> esp for palo alto, of which I have none.
> 
> That one was really close, but still didn't pass through ^; from command 
> files properly.
> After a bit more tweaking, the following change seems to get it to handle all 
> my test cases correctly.
> 

You have to escape the ; in the file (\;). The An argument could be made either 
way, i leN toward not altering the behavior of -x. 

> erikm@vpn41:~/ports-dev [15:21 - 1497]$ diff -Naur 
> /opt/local/libexec/rancid/clogin-3.99.99.bak 
> /opt/local/libexec/rancid/clogin-3.99.99
> --- /opt/local/libexec/rancid/clogin-3.99.99.bak2018-10-24 
> 19:46:30.0 -0400
> +++ /opt/local/libexec/rancid/clogin-3.99.992018-10-25 15:21:18.0 
> -0400
> @@ -253,7 +253,8 @@
>}
>set cmd_text [read $cmd_fd]
>close $cmd_fd
> -set command [join [split $cmd_text \n] \;]
> +regsub -all {;} $cmd_text "\\;" cmd_text
> +set command [join [split $cmd_text \n] \u002;]
>set do_command 1
># 'ssh -c' cypher type
>} -y* {
> @@ -444,13 +445,8 @@
>continue;
>}
> 
> -# handle escaped ;s in commands, and ;; and ^;
> -regsub -all {([^\\]);} $command "\\1\u002;" esccommand
> -regsub -all {([^\\]);;} $esccommand "\\1;\u002;" command
> -regsub {^;} $command "\u002;" esccommand
> -regsub -all {[\\];} $esccommand ";" command
> -regsub -all {\u002;} $command "\u002" esccommand
> -set sep "\u002;"
> +set esccommand [escapecommandlist $command]
> +set sep "\u002"
>set commands [split $esccommand $sep]
>set num_commands [llength $commands]
>set rshfail 0
> @@ -724,6 +720,21 @@
> return 0
> }
> 
> +# handle escaped ;s in commands, and ;; and ^;
> +proc escapecommandlist {command} {
> +# \; should be passed through as a ;
> +# ^; should be treated as a comment (when coming from a command file)
> +# ;; represents a literal ; before a subsequent command (?)
> +# other ;s are separators between items in a sequence of commands
> +# note this is processed as one big multiline text blob, so ^ anchors may
> +# not work as expected
> +regsub -all {([^\\\u002]);} $command "\\1\u002;" esccommand
> +regsub -all {([^\\\u00a\u00d\u002]);;} $esccommand "\\1;\u002;" command
> +regsub -all {\u002;} $command "\u002" esccommand
> +regsub -all {[\\];} $esccommand ";" command
> +return $command
> +}
> +
> # Run commands given on the command line.
> proc run_commands { prompt command } {
> global do_interact do_saveconfig in_proc platform
> @@ -742,12 +753,7 @@
> # this is the only way i see to get rid of more prompts in o/p..gr
> log_user 0
> 
> -# handle escaped ;s in commands, and ;; and ^;
> -regsub -all {([^\\]);} $command "\\1\u002;" esccommand
> -regsub -all {([^\\]);;} $esccommand "\\1;\u002;" command
> -regsub {^;} $command "\u002;" esccommand
> -regsub -all {[\\];} $esccommand ";" command
> -regsub -all {\u002;} $command "\u002" esccommand
> +set esccommand [escapecommandlist $command]
> set sep "\u002"
> set commands [split $esccommand $sep]
> set num_commands [llength $commands]
> 

___
Rancid-discuss mailing list
Rancid-discuss@shrubbery.net
http://www.shrubbery.net/mailman/listinfo/rancid-discuss


Re: [rancid] clogin commenting script commands following multiple blanks lines

2018-10-25 Thread Erik Muller
On 10/24/18 18:32 , heasley wrote:
> Wed, Oct 24, 2018 at 09:19:31PM +, heasley:
>> I missed that in your example, but noticed it in testing...after I sent that
>> patch.  This is my final patch, i think.  I havent committed it yet, as I
>> want to review it once more.
> 
> ok; committed.  Either the alpha tarball or the svn repo.  Welcome testers,
> esp for palo alto, of which I have none.

That one was really close, but still didn't pass through ^; from command files 
properly.
After a bit more tweaking, the following change seems to get it to handle all 
my test cases correctly.

erikm@vpn41:~/ports-dev [15:21 - 1497]$ diff -Naur 
/opt/local/libexec/rancid/clogin-3.99.99.bak 
/opt/local/libexec/rancid/clogin-3.99.99
--- /opt/local/libexec/rancid/clogin-3.99.99.bak2018-10-24 
19:46:30.0 -0400
+++ /opt/local/libexec/rancid/clogin-3.99.992018-10-25 15:21:18.0 
-0400
@@ -253,7 +253,8 @@
}
set cmd_text [read $cmd_fd]
close $cmd_fd
-   set command [join [split $cmd_text \n] \;]
+   regsub -all {;} $cmd_text "\\;" cmd_text
+   set command [join [split $cmd_text \n] \u002;]
set do_command 1
# 'ssh -c' cypher type
} -y* {
@@ -444,13 +445,8 @@
continue;
}

-   # handle escaped ;s in commands, and ;; and ^;
-   regsub -all {([^\\]);} $command "\\1\u002;" esccommand
-   regsub -all {([^\\]);;} $esccommand "\\1;\u002;" command
-   regsub {^;} $command "\u002;" esccommand
-   regsub -all {[\\];} $esccommand ";" command
-   regsub -all {\u002;} $command "\u002" esccommand
-   set sep "\u002;"
+   set esccommand [escapecommandlist $command]
+   set sep "\u002"
set commands [split $esccommand $sep]
set num_commands [llength $commands]
set rshfail 0
@@ -724,6 +720,21 @@
 return 0
 }

+# handle escaped ;s in commands, and ;; and ^;
+proc escapecommandlist {command} {
+# \; should be passed through as a ;
+# ^; should be treated as a comment (when coming from a command file)
+# ;; represents a literal ; before a subsequent command (?)
+# other ;s are separators between items in a sequence of commands
+# note this is processed as one big multiline text blob, so ^ anchors may
+# not work as expected
+regsub -all {([^\\\u002]);} $command "\\1\u002;" esccommand
+regsub -all {([^\\\u00a\u00d\u002]);;} $esccommand "\\1;\u002;" command
+regsub -all {\u002;} $command "\u002" esccommand
+regsub -all {[\\];} $esccommand ";" command
+return $command
+}
+
 # Run commands given on the command line.
 proc run_commands { prompt command } {
 global do_interact do_saveconfig in_proc platform
@@ -742,12 +753,7 @@
 # this is the only way i see to get rid of more prompts in o/p..gr
 log_user 0

-# handle escaped ;s in commands, and ;; and ^;
-regsub -all {([^\\]);} $command "\\1\u002;" esccommand
-regsub -all {([^\\]);;} $esccommand "\\1;\u002;" command
-regsub {^;} $command "\u002;" esccommand
-regsub -all {[\\];} $esccommand ";" command
-regsub -all {\u002;} $command "\u002" esccommand
+set esccommand [escapecommandlist $command]
 set sep "\u002"
 set commands [split $esccommand $sep]
 set num_commands [llength $commands]


___
Rancid-discuss mailing list
Rancid-discuss@shrubbery.net
http://www.shrubbery.net/mailman/listinfo/rancid-discuss