[Mimedefang] Globals
Rich West
Rich.West at wesmo.com
Thu Jul 8 13:32:31 EDT 2004
I've mucked around with the mimedefang-filter.pl pretty heavily in the
past, but I just wanted to ask a quick question before I tried this one out.
The goal is to have it such that our hosted mailing lists do not get
passed through the spamassassin plugin since the lists are subscription
based only. Now, rather inefficiently, I have the code below, but it
litterally populates the array @lists with each and every call.
Ideally, I would like to put the array and its contents in the global
namespace to avoid the generation of the contents of the array (eg:
get_lists) each time an email is processed.
Our mailing lists do not change frequently, but new ones do get added
and older ones do get removed/archived. So, maintaining the dynamic
nature is relatively important. We don't want to restart mimedefang
just because a mailing list was added or removed, but we CAN live with
the fact that it may take some time for mimedefang to 'learn' about the
changes. In other word, I realize that if the array is populated in the
global namespace, it is there, unchanged, for the life of the slave, but
we can live with that, since slaves come and go, and as new ones come,
they will have the new list of lists. :)
-Rich
#***********************************************************************
# %PROCEDURE: get_list
# %ARGUMENTS:
# None
# %RETURNS:
# Array of lists on the system
# %DESCRIPTION:
# This function fills an array with the names of all of the mailing
# lists on the system.
#***********************************************************************
sub get_lists
{
open (LISTS, "/var/mailman/bin/list_lists -b|")
or die "Could not execute '/var/mailman/bin/list_lists -b'.\n";
@lists = <LISTS>;
close(LISTS);
return (@lists);
}
#***********************************************************************
# %PROCEDURE: is_list
# %ARGUMENTS:
# listname -- the name of the mailing list
# %RETURNS:
# boolean - positive if the recipient matches a list name.
# %DESCRIPTION:
# This function matches the incoming mailing address with a list name.
# We do not scan the contents of mailing lists as spam.
#***********************************************************************
sub is_list
{
my($listname) = shift;
my(@lists) = @_;
##
## The email address, as it comes in, is surrounded by
## brackets. We have to massage it a little in order to do
## proper matching. eg: '<test at testdomain.com>' needs to be 'test'.
##
$listname = (split("\@", $listname))[0];
$listname = (split("\<", $listname))[1];
foreach $list (@lists)
{
chop($list);
return 1 if ($list =~ /^$listname/i);
}
return 0;
}
sub filter_end ($) {
my($entity) = @_;
my(@lists);
my($blacklist);
...
if ($RelayAddr eq "127.0.0.1" or $RelayAddr eq
"mailserver.dotted.ip.address")
{
md_graphdefang_log('mail_out',,$RelayAddr);
}
else
{
# Do not scan any messages going to any of the mailing lists.
@lists = &get_lists();
foreach $recipient (@Recipients)
{
if (&is_list($recipient, at lists))
{
md_graphdefang_log('mail_in', , $RelayAddr);
md_graphdefang_log('mailing_list', $hits, $RelayAddr);
return;
}
}
# Spam checks if SpamAssassin is installed
if ($Features{"SpamAssassin"}) {
...
More information about the MIMEDefang
mailing list