procmail
[Top] [All Lists]

Re: recipe to add names to a whitelist

2001-11-10 12:40:39
At 09:21 2001-11-10 -0800, Timothy J. Luoma wrote:

I want to write a recipe which will let me add names to the whitelist.

For example if I want to add "ed(_at_)aol(_dot_)com" and "john(_at_)msn(_dot_)com" I would send an email with the Subject:

     add2white ed(_at_)aol(_dot_)com john(_at_)msn(_dot_)com

The esteemed Mr. Tamkin has already raised the issue of the format of the whitelist. Let me interject that I believe that adding to (and removing from) the file will be easiest if it is a one-address-per-line affair. This does add some overhead for splitting your multiple-address subject when inserting, but this is infrequent at best. I won't cover removal, but basically, an inverse grep:

        grep -v -i ^addr$ file

would net you everything except lines matching the FULL address. Also, you can sort the list (less of an issue here, but it can come in handy). Line elements are also how I spool lists into my "megagrep" utility which uses AVL trees for matching elements in message headers, etc.

My scheme here is a one-address per line thing. However, you could tweak the sed invocation to churn out a progressive OR condition (exception: it would expect a "primed" file, so that the emitted text would always start with an or pipe, but never end with one). I think though that if you want to generate a includerc, you'd still be better off with a one-line-per type file, and use THAT to regenerate your includerc (though you'd need locking on it to prevent it from being used while the file was being updated).

I use plussed addresses for my spam/twit/whitelist subission facilities. If you have plussed address capability, you may want to use it, since it further obscures the submission process.

I chopped out my own twit sumission process, made some tweaks for you, and put it into a minimal test wrapper, so you should be able to take the following and save it to a file, then pipe some test messages at it via commandline invocation of procmail until you're comfortable with how it works:

# settings for establishing a test environment
LOGFILE=$HOME/test/procmail.log
VERBOSE=ON
# Caution! Don't migrate to non-test environ!
DEFAULT=/dev/null

#-- begin core rule
SPAMDIR=$HOME/test
WHITELIST=$SPAMDIR/whitelist.dat
SPAMSUB=addr\\+plussed(_at_)domain\\(_dot_)tld

:0
* $ ^TO.*$SPAMSUB
{
        # whitelist.
        :0
        * ^Subject:[    ]*add2white[    ]*\/[^  ].+
        {
                WHITE=$MATCH
                LOG="WHITELIST added $WHITE
"
                # the sed line *IS* broken in two, and the second
                # line shouldn't be indented.
                :0i:whitelist.lck
                |(echo $WHITE | \
                sed -e "s/  */ /g" -e "s/ /\\
/g" ) >> $WHITELIST
        }

        # you could process subject for twitfilters and spamdomains too...
        # add2twit, add2spam, etc.
}
#-- end core rule


I want to make sure that by adding the names to the list I don't screw up the existing list.

You're appending to the list, not inserting into it. Now, if you send junk as your subject, that could be an issue, but GIGO is a risk with any insertion.

If someone has a less ugly equivalent to the sed above (which because it is inserting a newline, requires that linebreak), I'm all ears.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>