[Mimedefang] filter & logging issues
B. Tolka
btolka at hsc.wvu.edu
Thu Jul 7 10:08:40 EDT 2005
Hello All,
I have a function call should_check_for_spam that seems to be processed
twice in my filter. I am trying to log the System-Whitelist vs
User-Whitelist.
I am not programmer by trade.
What exactly does this line do in my filter? if
(($Features{"SpamAssassin"}) && should_check_for_spam($Recipients[0]))
Snippets of my filter are below
sub filter_begin () {
if(stream_by_spam_list()) {
return;
}
sub stream_by_spam_list () {
my(@on_list, @off_list, $recip);
foreach $recip (@Recipients) {
if (should_check_for_spam($recip)) {
push(@on_list, $recip);
} else {
push(@off_list, $recip);
}
}
if ($#on_list >= 0 && $#off_list >= 0) {
# Some on, some off -- remail
resend_message(@on_list);
resend_message(@off_list);
$TerminateAndDiscard = 1;
return 1;
}
return 0;
}
sub should_check_for_spam ($)
{
undef $checkspam;
$checkspam = 10;
my($recip) = @_;
$recip = lc($recip);
$recip =~ tr/<>//d;
$Sender = lc($Sender);
$Sender =~ tr/<>//d;
if ($Sender =~ /\.domainname>?$/i or $Sender =~ /\.DOMAINNAME>?$/i ) {
md_graphdefang_log('SYSTEM-WHITELIST',$Sender);
return 0;
}
if ($use_database eq 1)
{
$sth = $dbh->prepare("SELECT checkspam FROM userpref WHERE username
= '$recip' && preference= 'rewrite_subject'");
$sth->execute;
$sth->bind_columns(\$checkspam);
$sth->fetchrow_arrayref;
if ($checkspam eq 0)
{
## md_graphdefang_log('Hit the checkpsam = 0 if statement', $recip);
## md_graphdefang_log('Checkspam is equal to', $checkspam);
md_graphdefang_log('NoSpamCheck');
return 0;
}
$sth1 = $dbh->prepare("SELECT value FROM userpref WHERE username =
'$recip' && preference= 'whitelist_from'");
$sth1->execute;
my (@whitelist);
my $i = 0;
my $count;
my $j = $sth1->rows;
my @rows;
while (@row = $sth1->fetchrow())
{
$whitelist[$i] = lc($row[0]);
if ($Sender =~ m/$whitelist[$i]/)
{
md_graphdefang_log('USER-WHITELIST',
$checkspam);
return 0;
}
$i++;
}
undef $checkspam;
$sth1->finish;
$sth->finish;
$count = $i;
return 1;
}
}
Bryan
More information about the MIMEDefang
mailing list