procmail
[Top] [All Lists]

Re: scored weighting, and aborting questions.

1997-01-12 16:40:16
Ken Marsh <kmarsh(_at_)charm(_dot_)net> writes:
I have some (probably basic) questions.

1.) I read the entire procmailsc man page. While there is a lot
about  putting together rules, the actual acceptance criteria
is NOT listed! Is it a score that is positive, or negative,
or over a certain value? Can I set that value?

Um, to quote the end of the first paragraph of the procmailsc(5) manpage:

     When  weighted  scoring  is used in a recipe, then the final
     score for that recipe must be positive for it to match.

Note that zero is *not* positive.  If you want to offset the acceptance
from zero, just subtract that value as the first condition:

# Require the 'real' conditions to add up to more than 100.  Exactly 100
# will not be accepted.
:0
* -100^0
...etc

Remember that the null regexp matches anything, but only once.


How would I use the $= withing procmail (or would I have  to
pass it to another program) to use it's value?

You can use its value anytime that variables are expanded in procmail,
including inside conditions that are prefixed with '$'.  It's just a
variable after all.

:0 c
* some scoring conditions that test something
some action here

# Start this recipe with final score of the previous condition, say,
# so that it can be 'refined'.
:0
* $ $=^0
* some more conditions
...etc


2.) I tried LOG="I received a letter" placed in part of
a rule, to update the logs when a certain non-delivery rule
is invocked. It then places the letter in a file named, joy
of joys, 'LOG=I received a letter'. How can I make it
USE the LOG command instead of file into it?

LOG=... is _not_ a command.  Procmail has no "commands", only
recipes and assignments.  If you want the action of a recipe to
be an assignment, you need to make it a nested block action, and
do the assignment inside the nested block:

:0
* some tests
{ LOG="I received a letter
"
}

Note how I put the close quote on the next line.  That's so procmail
includes a newline at the end of what is logged.


3.) In the same fashion, how to I get it to ABORT or 
INTERRUPT in a rule, rather than put it in a file
name "INTERRUPT"? If the letter is forged, will sendmail
(not using procmail as the default delivery agent in this case)
bounce it correctly to the originator? If procmail is the
default senmail delivery agent, will it bounce it correctly
then on an ABORT?

I'm not sure where "ABORT" and "INTERRUPT" are coming from.  If some
document said that procmail treated them specially, it was wrong and
should be corrected or deleted.  You need to set EXITCODE to some value
from sysexits.h, then convince procmail to stop attempting delivery,
typically by unsetting the HOST (magic) variable:

:0
* some tests that are true it's spam.
{
    # EX_NOUSER 67
EX_NOPERM 77

    # From sysexits.h:
    #       EX_NOPERM -- You did not have sufficient permission to
    #               perform the operation.  This is not intended for
    #               file system problems, which should use NOINPUT or
    #               CANTCREAT, but rather for higher level permissions.
    # EX_NOPERM=77  Alternatively, you could use EX_NOUSER=67:
    #       EX_NOUSER -- The user specified did not exist.  This might
    #               be used for mail addresses or remote logins.
    # sendmail should catch this and use it to form a bounce message,
    # unless you're using a .forward file that ends in "|| exit 75".
    # which'll stop this from working, sigh.
    EXITCODE = 77

    # Unseting the HOST variable forces procmail to immeadiately
    # act as though delivery had succeeded.
    HOST
}


4.) How would I put together a rule to bounce email sent to
20 or more addresses? So far I have:
:0h
* 1^1 @
(and then something like) if $= > 20
ABORT (or whatever)

First I'll note that counting at-signs in the header is a *bad* way to
count addresses, as many at's occur in the header in non-address
positions, include the Received: header and the Message-Id: header.
A better way is to count commas in the To: and Cc: headers, adding
one to each (a 3 address To: field will have 2 commas).  Combine that
with the idea of starting "behind in the count" to put a minimum value
requirement in, and the EXITCODE/HOST method of bounce, and you get:

:0
* -19^0
* 1^0 ^(Resent-)?To:
* 1^1 ^(Resent-)?To:.*,
* 1^0 ^(Resent-)?Cc:
* 1^1 ^(Resent-)?Cc:.*,
{
    EXITCODE=77
    HOST
}


I don't particularly like the above idea (I sometime get mail addressed
to a string of 30+ admin types when a string of sites are involved in a
security incident and the detecting site notifies the others all at
once), but it's your email, and you'll be the one to suffer the
consequences of your own .procmailrc, so...

Philip Guenther