[rancid] How to implement a diff filter?

Lee ler762 at gmail.com
Sat Feb 18 13:13:24 UTC 2012


On 2/17/12, jean.benoit at crc.u-strasbg.fr <jean.benoit at crc.u-strasbg.fr> wrote:
> On Fri, Feb 17, 2012 at 08:37:29PM +0000, James Bensley wrote:
> [...]
>> If that were how Rancid runs, I'd ideally like to insert a call to a
>> script in section 3, which would parse the diff to my script. My
>> script would look at a folder I have populated with diff's like those
>> above, I don't want to be notified about, and not parse them onto to
>> the final email that Rancid sends out when a match is found.
>>
>> Has anyone done this already perhaps?
>
> We do this by redefining PATH to intercept the call to sendmail
> in rancid-run :
>
>     export PATH=/my/dir:$PATH
>     rancid-run
>
> A script named sendmail in /my/dir reads stdin and could apply any changes
> to the message: add or remove some lines, send an email or not etc.

I like having everything in the saved configs, but don't like mailing
out diffs with sensitive information (eg. lines containing " password
7 ") so I added

~/bin/sanitize.sh $TMP.diff >$TMP.diff2
/bin/mv  $TMP.diff2 $TMP.diff

to control_rancid just before where it mails out the diffs.

If enough people are modifying the diff output it might be worthwhile
to add something like

PRE_EMAIL_SCRIPT=""

in /etc/rancid.conf and in bin/control_rancid add

if [ "X$PRE_EMAIL_SCRIPT" != "X" -a -x $PRE_EMAIL_SCRIPT ]; then
   export MAILFILE="$TMP.diff"
   $PRE_EMAIL_SCRIPT
fi

just before
# Mail out the diffs (if there are any).

Lee


More information about the Rancid-discuss mailing list