[Mimedefang] Customer Filter Help
schmaus
schmaus at ties2.net
Sun Mar 30 12:48:01 EST 2003
I am trying to write two customer filters:
1) Allow for the checking of file extensions based on
recipient domain. (i.e. if domain is roaringpenguin.com
load these extensions into bad_exts)
2) A blacklist and whitelist pulled from a database based
on the recieving domain.
Here is the code I have, but it does not appear to be
working:
1)
sub filter_bad_filename ($) {
my($entity) = @_;
my($bad_exts, $re);
my($junk,$tdomain);
my($EXTDB);
open (HDRS,"./HEADERS");
while (<HDRS>) {
if ($_ =~ /^To: /) {
($junk,$tdomain) = split(/\@/);
$tdomain =~ s/\>//g;
$tdomain =~ tr/A-Z/a-z/;
}
}
close (HDRS);
$dbh = DBI->connect($dsn,$dbu,$dbp) or die "Access
Failed";
$sth = $dbh->prepare("select extension from extensions
where customer='$tdomain'");
$sth->execute();
while (($EXTDB)=$sth->fetchrow_array()) {
$bad_exts .= $EXTDB . "|";
}
$sth->finish();
$dbh->disconnect;
$re = '(\{)|(\})|(\.' . $bad_exts .
')\.*([^-A-Za-z0-9_.]|$)';
return re_match($entity, $re);
}
And part 2)
$dbh = DBI->connect($dsn,$dbu,$dbp) or die "Access Failed";
$dbh->do("update counters set emails=emails+1");
($junk,$tdomain)=split(/\@/,$Recipients[0]);
open (HDRS,"./HEADERS");
while (<HDRS>) {
if ($_ =~ /^From: /) {
($before,$after) = split(/\@/);
$after =~ s/\>//g;
$after =~ tr/A-Z/a-z/;
}
}
close (HDRS);
$after =~ tr/A-Z/a-z/;
$sth = $dbh->prepare("select domain,flag from domain where
customer='tdomain'");
$sth->execute();
while (($flag,$domain1)=$sth->fetchrow_array()) {
if ($after eq $domain1) {
if ($flag eq "1") {
$sth->finish();
$dbh->disconnect;
return action_discard();
}
if ($flag eq "0") {
$sth->finish();
$dbh->disconnect;
return action_accept();
}
}
}
$sth->finish();
$dbh->disconnect();
I think my problem is with getting my variable information
from the headers. I get this in my maillogs:
Use of uninitialized value in concatenation (.) or string
Any help would be greatly appreciated.
Benjamin
More information about the MIMEDefang
mailing list