procmail
[Top] [All Lists]

procmail blues: grepping from /etc/passwd for "SEND" users...

2002-12-26 14:47:25
Hi,

I'm new to procmail but I'll make it snappy. I use a freeshell.org so
other users online can "SEND" me messages or "MAIL" me messages so I can
get the following "From:" headers which I can't match:

(well I *can* match them but very uglyly ;)

From: Rex Ruthers <rex>
        (a user using "mail" which doesnt set domain or anything)

From: SEND Daemon <com>
        (a user in "com" mode)

Now I want both of these to goto a folder called "sdf'ers".

I can sort users from a whitelist like:

afriend(_at_)this(_dot_)com
another(_at_)here(_dot_)com

By using:

:0:
* ? formail -x"From:" | egrep -if $HOME/mail/.school-friends
school-friends

where .school-friends is the white list.

First Q - is this an efficient way for handling the "whitelist"?
I can think of setting FROM=`formail -x"From:"` then * ? grep -i "$FROM"
/whitelist

but is that any different?

With that method I can add an address called SEND daemon which works out

Next problem, this user-without-a-domain name...

All the usernames are stored in /etc/passwd so to see if this user is from
there, I do:

USER=`formail -x"From:" | awk -F\< '{print $2}' | awk -F\> '{print $1}'`
:0:
* ? grep -i "$USER" /etc/passwd
"sdf'ers"

Which works ok I suppose. HOWEVER. When I get a mail without the name
<address> it sets USER="" which means it matches and goes into "sdf'ers".
This is bad...

Well I guess it's working ok now, but I'm not happy with it as it seems a
VERY messy way for handling it all.

Can anyone give me some pointers? I wouldn't mind doing:

if [ $USER ne "" ]
        grep "$USER" /etc/passwd
fi

or something but I don't know how in procmail-syntax

Thanks,

poff(_at_)sixbit(_dot_)org
SDF Public Access UNIX System - http://sdf.lonestar.org

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