procmail
[Top] [All Lists]

Re: rule set problem

2002-10-23 12:49:49
On 22 Oct, Tom Allison wrote:
| 
| :0fw:
| * ! ? (test -f ${WHITELIST} && ( ${FORMAIL} -zxFrom: | $GREP -i -f 
| ${WHITELIST} ))
| * ! ^FROM_DAEMON
| * ! ^FROM_MAILER
|| ${PROCCONFIRM}
| 
| ----------------------------------------------------------------------
| The problem I am having is with the first test.
| I am trying to test for the following conditions:
| NOT (The file $WHITELIST exists AND the FROM matches a name in 
| $WHITELIST)
| 
| But nothing seems to work quite right.  I have attached my LOG 
| output.  I'm sure I'm syntactically close, but I'm just missing 
| something...
| 
| 
| 
| procmail: Executing " test -f ${BLACKLIST} && ( ${FORMAIL} 
| -zxFrom: | $GREP -i -f ${BLACKLIST} )"
| procmail: Non-zero exitcode (1) from " test -f ${BLACKLIST} && ( 
| ${FORMAIL} -zxFrom: | $GREP -i -f
| ${BLACKLIST} )"
| procmail: No match on " test -f ${BLACKLIST} && ( ${FORMAIL} 
| -zxFrom: | $GREP -i -f ${BLACKLIST} )"
| procmail: Executing " (test -f ${WHITELIST} && ( ${FORMAIL} 
| -zxFrom: | $GREP -i -f ${WHITELIST} ))"
| procmail: Non-zero exitcode (1) from " (test -f ${WHITELIST} && ( 
| ${FORMAIL} -zxFrom: | $GREP -i -f
|   ${WHITELIST} ))"
| procmail: Match on ! " (test -f ${WHITELIST} && ( ${FORMAIL} 
| -zxFrom: | $GREP -i -f ${WHITELIST} ))
| "
| procmail: Match on ! 
| "(^(Mailing-List:|Precedence:.*(junk|bulk|list)|To: Multiple 
| recipients of |((
| (Resent-)?(From|Sender)|X-Envelope-From):|>?From 
| )([^>]*[^((_dot_)%(_at_)a-z0-9])?(Post(ma?(st(e?r)?|n)|office
| 
)|(send)?Mail(er)?|daemon|m(mdf|ajordomo)|n?uucp|LIST(SERV|proc)|NETSERV|o(wner|ps)|r(e(quest|spons
| 
e)|oot)|b(ounce|bs\.smtp)|echo|mirror|s(erv(ices?|er)|mtp(error)?|ystem)|A(dmin(istrator)?|MMGR|uto
| answer))(([^).!:a-z0-9][-_a-z0-9]*)?[%@> 
| ][^<)]*(\(.*\).*)?)?$([^>]|$)))"
| procmail: Match on ! 
| "(^(((Resent-)?(From|Sender)|X-Envelope-From):|>?From 
| )([^>]*[^((_dot_)%(_at_)a-z0-9])?(P
| 
ost(ma(st(er)?|n)|office)|(send)?Mail(er)?|daemon|mmdf|n?uucp|ops|r(esponse|oot)|(bbs\.)?smtp(error
| 
)?|s(erv(ices?|er)|ystem)|A(dmin(istrator)?|MMGR))(([^).!:a-z0-9][-_a-z0-9]*)?[%@>
 
|        ][^<)]*(\(
| .*\).*)?)?$([^>]|$))"
| 

First of all, in the log excerpt above I see 2 failed matches on that
conditon and one successful match.  Maybe, your logic isn't exactly
what you think it is.

Anyway, I can't tell you why, but when I do a simple * ? test -f $var
condition it's fine, but then fails if enclosed with parens. I get a
log message that you're not: procmail: Program failure (127) of "(",
but that could be version dependent. (Escaping the "(" doesn't help.)
There's no real need to use a logical &&, and there's no need to
enclose them in parens. If your logic is correct the recipe can be
fixed by removing the 3 pairs of parens in the first condition:

  * ! ? test -f $WHITELIST && formail -zxFrom: |grep -if $WHITELIST

But let's see if this helps...

NOT ( -f $WHITELIST   AND   check From: against $WHITELIST )

matches if

( ! -f $WHITELIST   OR   ! From: matches $WHITELIST )

Try (untested):

  :0fw:
  * 1^0 ! ? test -f $WHITELIST
  * 1^0 ! ? formail -zxFrom: |grep -if $WHITELIST
  *     ! ^FROM_DAEMON
  *     ! ^FROM_MAILER
  | $PROCCONFIRM

The first two conditions are scored (1^0) so the entire recipe requires
that either one or both conditions match. Obviously, the last two are
not scored, so they must both match also.

If one of us has your logic backwards and you want it to NOT execute if
$WHITELIST does not exist and/or From: does not match $WHITELIST:

  :0fw:
  * ? test -f $WHITELIST
  * ! formail -zxFrom: |grep -if $WHITELIST
  * ! ^FROM_DAEMON
  * ! ^FROM_MAILER
  | $PROCCONFIRM

I would also probably put the last two conditions first to preclude
running the external programs where possible.

-- 
Reply to list please, or append "8" to "procmail" in address if you must.
Spammers' unrelenting address harvesting forces me to this...reluctantly.



_______________________________________________
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>