[SLUG] Re: Killfile howto

From: R P Herrold (herrold@owlriver.com)
Date: Mon May 28 2001 - 19:35:47 EDT


Off the list, on Mon, 28 May 2001, user Watson wrote:

> Other than just tweaking .procmailrc with a recipe every
> time some idiot shows up, how would one go about setting
> up a killfile?

Watson, you know my methods ...

I have added some tweaks so that careful readers of How-To's
cannot circumvent my site local killfiles by adding the magic
pass phrase ... 'cheeseburger' and 'olive' are NOT my magic
words.

see the 'Best of procmail' compilation, at:

        http://www.hcs.harvard.edu/~thurston/ua/\
                pm-tips.html#kill_simple_killfile_recipe_with

14.12 Kill: simple killfile recipe with procmail [toc]

    Killfiles are widely used with newsreaders to delete
    uninteresting posts when you enter a
    newsgroup. A killfile usually contains one single entry
    per line to match the message
    content and this can be easily done with procmail.
    Remember however that for every
    message procmail forks a process, so before you apply the
    killfile rules to the messages, be
    sure your recipes are in this order: the killfile rules
    are applied only to unknown messages

[Russ: this is pseudo-code imediately below]

          SINK MAILING-LISTS
          SINK ANNOUNCEMENTS
          SINK WORK MESSAGES
          OTHER DELIVERIES
          apply killfile rules and UBE recipes to the rest

    Recipe will drop the message (i.e. consider it
    'delivered') if one of its headers matches a
    pattern in killfile.

[Russ: for ~/.procmailrc -- also needs the pattern file in
~/.killfile]

          :0 hW: $HOME/.killfile.lock
          | egrep -i -f $HOME/.killfile

    The reason why there is explicit lockfile is that you must
    be able to update the killfile while
    your procmail is running. An example edit script is
    presented below.

          #!/bin/sh
          # program: killfile.sh
          #
          file=$HOME/.killfile
          lock=$file.lock
          cp $file $file.tmp
          emacs -q $file # or use whatever you prefer: vi, pico
          lockfile $lock
          mv $file.tmp $file
          rm -f $lock

-------------------------------

See also: man procmailsc

Also the procmail list recently had an extended treatment,
with a additive procmail recipe to 'catch' a pattern mailed to
it, and to append it to a killfile --easy to add idiots --
required shelling in to remove them ... the author considered
this a Good Thing.

I use a two step variant variant of the above:

          :0 fhW: $HOME/.killfile.lock
                  | egrep -i -f $HOME/.killfile | \
                        formail -A "X-killfile: cheeseburger"

... that is the first is a unix filter rather than a
delivering recipe -- I also allow for exemption from killfile
screening by a 'passfile' which over-rides the killfile
marker.

and then later, I use:

        :0 h
        * ^X-killfile: cheseburger
        * !^X-passfile: olive
                | ~/$MAILDIR/killfile-dump.$DOM

--------------------

At the TOP of my .procmailrc,

DOM=`date +%d`

... and outside of that, I have a cron process to the effect:

1 1 * * * ( DOM=`date +%d` ; > ~/$MAILDIR/killfile-dump.$DOM )

I figure that if I haven't needed it in a month, I'm not
likely to need it ...

(it actually is a custom script that does lots more, but you
get the idea ...)

--------------------------

That is, I keep 31 killfile result files, with the last
month's killfile dump's with a suffix of the day of month, so
that I might grep for a 'killfilled' piece

-- Russ



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:59:07 EDT