[Mimedefang] spamd (was: Spammers who won't take no for an answer)

Jonas Eckerman jonas_lists at frukt.org
Tue Oct 28 06:51:12 EST 2003


> OpenBSD's spamd is very efficient (spends most of time sleeping),

I took a short look at spamd, and saw that it's commonly used 
together with relaydb (for creating the pf rules that routes bad 
relays to spamd instead of sendmail).

I'm currenlty testing the following code in filter_end for reporting 
to relaydb (watch out for word wrapping):

--8<--
sub_filter_end ($) {
    # $black_list and $white_list controls how messages will be
    # reported to relaydb

    # reladb can be used in filter_relay to reject mails from 
    # spamming servers.

    # It can also be used in cinjunction with spamd and other spam
    # tarpits, for example by having spamd-setup telling pf to 
    # reroute connections.

    # mail with ($hits > $black_list) will be reported as spam
    # mail with ($hits < $white_list) will be reported as non-spam
    my $black_list = 12;
    my $white_list = 3;

[Some code snipped...

        my($hits, $req, $names, $report) = spam_assassin_check();

        if (($hits > $black_list || $hits < $white_list) &&  open 
IMSGF, "< ./INPUTMSG" ) {
            my @rdbmsg = <IMSGF>;
            close IMSGF;
            unshift (@rdbmsg, split(/^/m, 
synthesize_received_header()));
            my $rdbcmd = "";
            if ($hits > $black_list) {
                $rdbcmd = "/usr/local/bin/relaydb -b -f 
/var/spool/MIMEDefang/.relaydb";
            } elsif ($hits < $white_list) {
                $rdbcmd = "/usr/local/bin/relaydb -w -f 
/var/spool/MIMEDefang/.relaydb";
            }
            $rdbpid = open(RELAYDB, "|$rdbcmd");
            if ($rdbpid) {
                print RELAYDB @rdbmsg;
                close RELAYDB;
            } else {
                md_syslog('err',"$MsgID: could not run relaydb");
            }
        }

[More code snipped...]
--8<--

This seems to work.

As I've said before I don't really know perl, so before you use my 
code you should check it yourself as I might well have done something 
stupid. If my code isn'ät really what it should be, it should still 
be useable as an idea for an easy way to use relaydb with MIMEDefang.

A note: Presonally I know I won't be using spamd-setup, but I might 
use spamd with something more flexible replacing spamd-setup.

Regards
/Jonas
-- 
Jonas Eckerman, jonas_lists at frukt.org
http://www.fsdb.org/





More information about the MIMEDefang mailing list