procmail
[Top] [All Lists]

Re: Another Nesting Question :)

2000-02-02 04:28:21
On Tue, 01 Feb 2000 14:42:08 -0500, "W. Mark Herrick, Jr."
<markh(_at_)va(_dot_)rr(_dot_)com> wrote:
Am I doing this correctly? I'm not entirely sure how to
multiple-nest...

A nested block is an action. Every action needs a colon line.

    :0 flags-n-locks, if any
    * conditions, if any
    action

So anything that looks like an opening brace is the start of an
action, and it should have a colon line and probably some conditions
in front of it. Anything else is a syntax error.

# Kansas City
{
:0
# Match on To/Cc Address
* ^(To:|Cc:).*(abuse|security|fraud|spam)@kc\.rr\.com
{

Probably the first brace here is completely gratuitous, and what you
mean to say is

    # Kansas City
    :0
    * ^TO_(abuse|security|fraud|spam)@kc\.rr\.com
    {

The normal warnings about using Procmail as a multiplexer for multiple
accounts applies. If somebody sends to 
kc(_dot_)rr(_dot_)com(_at_)abuse(_dot_)net then that
is probably what is going to be in the To: header, too, and you will
essentially receive a Bcc: to abuse(_at_)kc(_dot_)rr(_dot_)com with no trace in 
the
normal To: or Cc: headers (or any of the others handled by the more
general ^TO_ macro).

     # Check for presence of Black Ice signatures, if yes,
     # then call blackice.rc autoresponder, nuke mail, and
     # stop processing
     :0B
     * ("attack-list.csv"|".enc"|"mac address:")
     INCLUDERC=blackice.rc
     /dev/null

This is also a syntax error. Variable assignments are not valid
actions (other than in the VARIABLE=| special form) and what you mean
is probably

    :0B  # are the literal double quotes really supposed to be there?
    * "(attack-list\.csv|\.enc|mac address:)"
    {
        INCLUDERC=blackice.rc
        :0
        /dev/null
    }

If you want two actions (INCLUDERC= and save to /dev/null) then you
need two recipes, or at least something in braces.

Notice that I factored out the double quotes which were in all the
parts of the condition. The double quotes are not interpreted in any
way, the condition -- in the form you put it, or in mine -- requires
the matching strings to start and end with literal double quotes. If
that's not what you intended, then, uh, say what you intended to say
instead :-)

Usually, anything that ends up delivering to /dev/null can be tidied
up one way or another, but that's just my personal rule of thumb.

If you change blackice.rc so it delivers to /dev/null (or somewhere
more appropriate, so you at least have a trace if you suspect that the
recipe is doing something wrong) you can get away with just

    :0
    * whatever conditions
    { INCLUDERC=blackice.rc }

Notice the braces here again. Like we just said, a variable assignment
alone (or pseudovariable, as in INCLUDERC) is not a valid action, but
an action can be a brace expression, which can contain variable
assignments (and additional recipes, etc). In terms of BNF, you get
something like

  procmailrc := ( assigment | recipe )*

  recipe := colon condition* action

  action := save | "!" address | "|" pipeline | "{" procmailrc "}"

with some minor modifications. (The parser is more sensitive to
whitespace than this implies. I take the liberty to prefer human
readable notation over strictness. This is only for explanatory
purposes. Batteries not included etc. Bozotic American litigation
laws probably can't reach me here in the Civilized World anyway.)

{
     # If no Black Ice signatures, then do regular process

This should probably have a :0E (else) in front of it.

Hope this helps,

/* era */

-- 
 Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
  Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition

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