I took rblcheck and added some extra code to read a message from stdin,
find the IP of the last relay. It then compares a rating, based on
running lookups against various RBL-style lists, against the value
supplied on the command line. These mods make it suitable to be used in
a .qmail file.

In other words, it looks for the first instance of this type of line:

   Received: from mail.domain.com (HELO domain.com) (12.34.56.78)

It will grab the IP in ()'s and feed it into the rblcheck routine
written by Edward Marshall. The rblcheck routine(s) has been modified to
return a value based on which list(s) matched. Namely:

           rbl.maps.vix.com  = 16
           dul.maps.vix.com  = 8
      relays.mail-abuse.org  = 4
           outputs.orbs.org  = 2
            relays.orbs.org  = 1

Add all values of lists that matched together, and compare it to the
value supplied on the command line. If the returned value is less than
or equal to the command line value, qrblcheck returns code 0, which
tells qmail to continue delivery. If the value is greater than that
supplied on the command line, qrblcheck returns 100 which tells qmail to
stop all deliveries and return the message.

If, for whatever reason, no IP was found, qrblcheck returns 0 (mail is
accepted).

EXAMPLE:

Putting "|qrblcheck 15" on the first line of your .qmail file will block
any mail that matches rbl.maps.vix.com. Instead, using "|qrblcheck 1"
will reject mail that matches all the lists except for relays.orbs.org.

Download the source at 

   http://jon.rusts.net/qrblcheck.c

I'm not an experienced C programmer, so feedback is welcome and
encouraged. The biggest problem I see right now is that it will match
bogus IP's... like 999.999.999.999, but I don't see how that would work
it's way into headers written by qmail. Regardless, I do plan on
implementing some sort of trap for this.

It successfully compiles on FreeBSD 4.x, but can't be sure it will on
any other system.

Hopefully this will be useful to someone.

jon


Reply via email to