custom quarantine help
Quanah Gibson-Mount
quanah at zimbra.com
Sat May 21 02:34:07 CEST 2011
I have the following custom module that does not do quite what I want it to
do yet. I know I need to tweak the "sender" and "recipient" sections, but
I'm not quite sure what they need to be tweaked to. Previously, when we
patched amavis directly, we could trigger a quarantine of any mail a user
sent or received by setting amavisQuarantineTo on their user object in
LDAP. We are now trying to do this the correct way via a custom module.
However, when I put the module in place, it quarantines all email
regardless of sender/recipient, rather than only the targeted user(s), and
it puts the quarantine on disk rather than sending them to the specified
quarantine account. Module is as follows, pointers appreciated:
package Amavis::Custom;
use strict;
use warnings;
no warnings qw(uninitialized redefine);
BEGIN {
import Amavis::Conf qw(:platform ca);
}
# invoked at child process creation time;
# return an object, or just undef when custom checks are not needed
sub new {
my($class,$conn,$msginfo) = @_;
my($self) = bless {}, $class;
my($ccat_sub) = 0;
my(@recips) = map { $_->recip_addr } @{$msginfo->per_recip_data};
if (Amavis::Lookup::lookup(0,$msginfo->sender,
@{ca('archive_quarantine_to_maps')})) {
$ccat_sub = 3; # sender quarantine
} elsif (grep { Amavis::Lookup::lookup(0,$_,
@{ca('archive_quarantine_to_maps')}) } @recips) {
$ccat_sub = 2; # recipient quarantine
}
if ($ccat_sub > 0) {
$msginfo->add_contents_category(CC_CLEAN,$ccat_sub);
for my $r (@{$msginfo->per_recip_data}) {
$r->add_contents_category(CC_CLEAN,$ccat_sub);
}
}
$self; # returning an object activates further callbacks,
# returning undef disables them
};
Thanks,
Quanah
--
Quanah Gibson-Mount
Principal Software Engineer
Zimbra, Inc
--------------------
Zimbra :: the leader in open source messaging and collaboration
More information about the amavis-users
mailing list