[Mimedefang] Greylist

Andrea Gabellini agabellini at intelcom.sm
Thu Feb 26 12:07:20 EST 2004


Hi,

I found the greylist implementation at 
http://lists.roaringpenguin.com/pipermail/mimedefang/2004-February/020126.html 
very useful, and I made a little change to support a greylist 'whitelist'. 
My intention is to not apply the greylist rules to local or trusted ip.

The white list is a BDB file with the same basic rules of the sendmail 
access file (compiled with makemap):

127.0.0.1               Localhost
xx.xx.xx                My network



I added the function greylist_whitelist:

$DBFilenameWL = "/etc/mail/greylistdb-whitelist.db";
sub greylist_whitelist($) {
         my ($ip) = @_;
         my $strip_ip = $ip;
         my $result = 0;

         my %GDB;
         if (tie(%GDB,'DB_File', $DBFilenameWL, O_RDONLY)) {
                 $strip_ip =~ s/(.*)\.[0-9]+$/$1/;
                 if ($GDB{$ip} || $GDB{$strip_ip}) {
                         $result = 1;
                         md_syslog('info', "greylist: $ip found in 
whitelist") if (defined($gdb_log) && $gdb_log);
                 } else {
                         md_syslog('info', "greylist: $ip not found in 
whitelist") if (defined($gdb_log) && $gdb_log);
                 }
                 untie %GDB;
         }
         return $result;
}



and in the filter_recipient function the first test become:

if ($greylist && !greylist_whitelist($ip)) {
         .....
}



---------------------------------------
Crashing is the only thing windows does quickly.
---------------------------------------
Ing. Andrea Gabellini
Email: agabellini at intelcom.sm
Tel: 0549 886111 (Italy)
Tel. +378 0549 886111 (International)

Intelcom San Marino S.p.A.
Strada degli Angariari, 3
47891 Rovereta
Repubblic of San Marino

http://www.omniway.sm  http://www.intelcom.sm



More information about the MIMEDefang mailing list