[GLLUG] Perl script question

Bill Bartilson bbartilson at comcast.net
Thu May 22 13:20:01 EDT 2008


Hi All,

I'm configuring a mail server to work with a spam filter called ASSP.   
It's written in Perl, with which I have no experience... so I have a  
question.

The script has a call to a .db file in which folks who are authorized  
via POP are considered authenticated senders.  It's looking for IP  
addresses only.

The mail server maintains a list of active POP connections within a  
specific directory, not a file.  Each file is the dotted decimal of  
the active connection and the extension .dbs.

Now the question:

What's the best way to attack this?  My choice would be to modify the  
script to parse the contents of the directory instead of the looking  
for a .db file.  That is, look at the contents of the directory when  
and only when it needs to - strip the extensions from the list of  
files, and do it's thing.  Doesn't matter to me whether the script  
creates/modifies a .db file and the other code remains intact, or the  
code itself is modified to work by looking at a directory and parsing  
the contents.

The original code:

sub PopB4SMTP {
my $ip=shift;
if($PopB4SMTPMerak) {
return 1 if PopB4Merak($ip);
return 0;
}
return 0 unless $PopB4SMTPFile;
unless ($TriedDBFileUse) {
eval 'use DB_File';
mlog(0,"could not load module DB_File: $@") if $@;
$TriedDBFileUse=1;
}

my %hash;
# tie %hash, 'DB_File', $PopB4SMTPFile, O_READ, 0400, $DB_HASH;
tie %hash, 'DB_File', $PopB4SMTPFile;
if($hash{$ip}) {
mlog(0,"PopB4SMTP OK for $ip");
return 1;
} else {
mlog(0,"PopB4SMTP failed for $ip");
return 0;
}
}


Suggestions?

Thanks in advance for any info.

Regards,
Bill


More information about the linux-user mailing list