[Mimedefang] Greylist cleaner script problem

Todd Aiken taiken at ubishops.ca
Wed May 26 11:32:37 EDT 2004


I am trying to use a slightly modified version of the greylist 
cleaner perl script that is found on Jonas Eckerman's web page to 
clean up my greylist database file.  It runs okay, and gives me valid 
results, but does not change my database file at all.  Here is what 
my script file looks like.  

--------

#!/usr/bin/perl -ws
#

use DB_File;
use Fcntl ':flock';
use Benchmark;

$gdb_white = 36*24*60*60;
$gdb_grey = 36*60*60;

$DBFilename = "/var/spool/MIMEDefang-Greylist-DB/.greylistdb";

sub lock_db () {
    print ("Locking file...");
    open(LOCKFILE, ">>$DBFilename.lock") or return 0;
    flock(LOCKFILE, LOCK_EX);
    print ("OK.\n");
    return 1;
}

sub unlock_db () {
    print ("\nUnlocking file...");
    flock(LOCKFILE, LOCK_UN);
    close(LOCKFILE);
    unlink("$DBFilename.lock");
    print ("OK.\n");
    return 1;
}


my %GDB;
my $now = time();
my $g = 0;
my $w = 0;
my $t = 0;
my $r = 0;


lock_db();
if (tie(%GDB,'DB_File', $DBFilename)) {
        foreach my $key ( keys %GDB) {
                my $data = $GDB{$key};
                $t++;
                if (!$data) {
                        delete $GDB{$key};
                        $r++;
                } else {
                        my 
($created,$modified,$reset,$accepted,$count,$ip,$sender,$recipient,$x)
 = split(/;/,$data,9);
                        if ($accepted == 0 && $count == 0 && $now >
$created + $gdb_grey) {
                                delete $GDB{$key};
                                $g++;
                        }
                        if ($now > $modified + $gdb_white) {
                                delete $GDB{$key};
                                $w++;
                        }
                }
        }
        untie %GDB;
}

unlock_db();

$StartTime = new Benchmark;

my $c = $t - $r - $g - $w;
print("Deleted $g expired grey records.\n");
print("Deleted $w expired white records.\n");
print("Deleted $r records containing no data.\n");
print("Total records remaining: $c\n");
print("Total records processed: $t\n");

$EndTime = new Benchmark;
$extime = Benchmark::timediff($EndTime, $StartTime);
$stats = Benchmark::timestr($extime);
$stats   =~ s/(\(.+?\))//i; $extstats = $1;
$extstats =~ s/(=.+?CPU)//i; $extstats = $1;
$extstats =~ s/=//;
$extstats = lc($extstats);
$stats = $stats . " -" . $extstats . " secs";
print("Execution time is: $stats.\n");

--------

In case anyone is wondering, yes I did remove the # signs in front of 
the delete statements.  It also makes no difference whether or not 
Mimedefang is running at the time.   

Here are the results I get when I try to run the script:

Deleted 0 expired grey records.
Deleted 0 expired white records.
Deleted 34 records containing no data.
Total records remaining: 10881
Total records processed: 10915
Execution time is:  0 wallclock secs  -  0.00 cpu secs.

I had to delete my previous greylist file because it had gotten so
large that I couldn't manage it (> 6 gigs).

I cannot use the method of locking that the original script has, as I 
get the message "Your vendor has not defined Fcntl macro O_EXLOCK".

I also tried to use the script that Edoardo Giannoni posted to the
MIMEDefang list on April 29th, but the same thing occurs.

Does anyone have any idea as to why this isn't working for me?

My system is running on Slackware 8.1, using kernel version 2.4.26.

Thanks.


CU L8R...

Todd A. Aiken 
Systems Analyst - Administrator
Cole Computer Centre
BISHOP'S UNIVERSITY
Lennoxville, Quebec, CANADA

"GUIs on servers... That's like putting an air conditioner on a 
motorcycle..."

-----BEGIN GEEK CODE BLOCK-----
Version 3.12 (http://www.geekcode.com)
GCS$/MU d+(-) s++:+ a C++$ UL++++$ P+ L++ E->+ W+>++ N++ o? K-
w O- M V? PS PE- Y PGP- t+ 5 X R- tv+ b DI(+) D++ G e+ h !r>r+++ y-
------END GEEK CODE BLOCK------





More information about the MIMEDefang mailing list