procmail
[Top] [All Lists]

Re: What am I missing

1999-04-01 06:18:07
On Wed, 31 Mar 1999 16:41:45 -0800, "Ron 'The InSaNe One' Rosson"
<insane(_at_)oneinsane(_dot_)net> wrote:
This is a procmail recipe that I am working on:
TCPREMOTEIP=`cat $1 | origip.pl`

:0
* ! ? if [ -n "$TCPREMOTEIP" ]; then rblcheck -q "$TCPREMOTEIP"; fi{
     EXITCODE=0      # Not Sure what to have here
     LOGABSTRACT=all
     LOG="Filter: RBL-filtered address: \"$TCPREMOTEIP\"
"
     :0 :
     |formail -i "X-RBL-Filtered-Address: $TCPREMOTEIP" >> $FILTER_FOLDER
}

I believe the proper context of this whole thread is that Ron is doing
a cargo cult copy of a construct from the rblcheck INSTALL notes. The
unfortunate thing here is that the INSTALL notes sort of presume you
have control over your sendmail.cf, whereas -- if I have got this
right -- Ron is a mere user who is invoking this over his .forward,
with no way to get any extras from the MTA.

In other words: No, $1 is probably not set, and there's probably no
way to get it, either. (And possibly the rblcheck instructions should
be updated; as others have pointed out, the shell invocation can be
avoided altogether.)

The purpose of the origip.pl script (I don't have the new alpha
version which uses this Perl script; 1.4 had a similarly named C
program) is to glean the IP number from the headers it receives on
standard input, so cat $1 is probably completely wrong here. 

Try this:

    :0h
    TCPREMOTEIP=| origip.pl

    :0
    * TCPREMOTEIP ?? .
    * ? rblcheck -q "$TCPREMOTEIP"
    {
        LOGABSTRACT=all
        LOG="Filter: RBL-filtered address: \"$TPCREMOTEIP\"
"
        :0:
        | formail -i "X-RBL-Filtered-Address: $TCPREMOTEIP" >>$FILTER_FOLDER
    }

You could do better still, because if your MTA stamps the topmost
Received: header with the originating system's IP number, you can
simply grab it from there. Poof, no external process, no need for
origip.pl at all. This has been described by Aaron Schrab in
<http://www.xray.mpe.mpg.de/mailing-lists/procmail/1998-02/msg00034.html>

(You don't really need the scoring stuff if you just construct a
single regex which covers all your local hosts; for current-ish
Sendmail installations, an adaptation of Aaron's recipe would be
something along the lines of

    :0
    * ^Received: from[^])]*\[\/[0-9]+\.[0-9.]+\]\)\<*by\>+${MONSTER_REGEX}
    {
        ...

where MONSTER_REGEX is a properly parenthesized expression covering
all hosts you regard as "local" in some sense (this might include
foreign servers you trust to relay to you, including perhaps selected
forwarding services and/or mailing lists).

Hope this helps,

/* era */

Here's my (grossly outdated) MX equivalent to the MONSTER_REGEX;

# primary MX
MX='helsinki\.fi|iki\.fi'
# secondary
MX="$MX"'|pobox3\.funet\.fi|(hauki|lohi)\.clinet\.fi'
# spam-list
MX="$MX"'|han\.de|hiss\.org|spam-archive\.org'

I have tweaked it a little bit more to regard any local host name in
iki.fi etc as "local" in this sense (even for han.de and hiss.org).

-- 
.obBotBait: It shouldn't even matter whether     <http://www.iki.fi/era/>
I am a resident of the state of Washington. <http://members.xoom.com/procmail/>
 * Sign the European spam petition! <http://www.politik-digital.de/spam/en/> *

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