procmail
[Top] [All Lists]

Re: whitelist matching (was: How do I get the message body ???)

2002-08-13 06:35:41
From: "Dr. David Kirkby" <davek(_at_)medphys(_dot_)ucl(_dot_)ac(_dot_)uk>

My basic problem seems to be that while Dallman's solution to matching
from a white list (changed slightly in the light of some personal emails
not on the list)

FROM=`formail -x From:`

(Actually, my solution obviated the need for formail in this
particular application at all.  It's not a big footprint, and
you may want it for other things in your .procmailrc, but it's
not part of my proposed answer here.  In any case, glad to
see we're near to full success with your issue.)


USERNAME_CHARACTERS="a-z0-9+._=-"
DOMAINNAME_CHARACTERS="a-z0-9.-"

:0:
* $ ^From:(.*\<)?\/[$USERNAME_CHARACTERS]+(_at_)[$DOMAINNAME_CHARACTERS]+
* $ ? grep -iw $MATCH $HOME/white.list
ok


Btw, If you do decide to keep the formail header extraction thingee, then
you don't even need the variable assignments or the first condition line.
They were merely designed to obviate a shell call to invoke formail and
do it all from within procmail.  If you prefer, however, this would
do the same thing:

        FROM=`formail -x From:`

        :0:
        * $ ? grep -iw $FROM $HOME/white.list
        ok



seems to work fine, without invoking any overflows in fgrep, it failed
to work if the user is local, where the username might be 'davek' and
not be davek(_at_)medphys(_dot_)ucl(_dot_)ac(_dot_)uk

Dallman suggested adding:

:0 fwih
* ^From:(.*\<)?\/[^(_at_)]+$
| formail -I"From: $MATCH(_at_)medphys(_dot_)ucl(_dot_)ac(_dot_)uk"

*before* the above rule, so that a username without a domain would have
my local domain (@medphys.ucl.ac.uk) appended, which would then be
looked up in the white.list as any other email address. The white.list
will contain
davek(_at_)medphys(_dot_)ucl(_dot_)ac(_dot_)uk, rather than just davek.

This however seems to break down if the username is between < and >,
which it frequently is.

In afterthought, I think it was wrong to include the "i" flag here.
Someone will surely correct me if I'm only wrong in afterthought but
not in forethought.  :)

But let's go on: all wee need, I believe, to solve this final problem
of yours is to change this

        * ^From:(.*\<)?\/[^(_at_)]+$

to this:

        * ^From:(.*\<)?\/[^(_at_)]+>?$
 

The change is the addition of ">?" near the end.  Try that and see.

-- 
dman

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