--On Friday, October 10, 2008 8:27 PM +0200 Mark Martinec <mark.martinec+ama...@ijs.si> wrote:
> Quanah, > >> I've directly emailed you the patch, it had an additional set of changes >> to amavisd you may wish to consider. > >> } # endfor per_recip_data >> + if (defined($qar_method) && $qar_method ne '') { # archiving >> quarantine on sender + my($sender) = $msginfo->sender; >> + if ($sender ne '') { >> + my($q) = lookup(0,$sender,@{ca('archive_quarantine_to_maps')}); >> + $q = $sender if $q ne '' && $qar_method =~ /^bsmtp:/i; # >> orig.recip + push(@qar_addr, $q) if $q ne '' && !grep {$_ eq $q} >> @qar_addr; + } >> + } >> if ($ccat == CC_SPAM) { > > This one is not accepted, because it goes against the principle that > *_maps lookup tables are always done on recipients, not on senders. > The proper change would need to introduce a new setting, not overload > the archive_quarantine_to_maps. > > Fortunately such quarantining is achievable by custom hooks, either > by calling do_quarantine() directly, or the way that I prefer, by > flagging a message with an additional minor contents category, and > adding additional quarantine settings. For example: > > Add three new ccat settings: > ccat > major,minor method quarantine_to > ----------- -------------- ----------------- > CC_CLEAN,2 -> local:clean/%m, recip-quarantine > CC_CLEAN,3 -> local:clean/%m, sender-quarantine > CC_CLEAN,4 -> local:clean/%m, clean-quarantine > > like this, in amavisd.conf: > > $quarantine_method_by_ccat{CC_CLEAN.",2"} = 'local:clean/%m'; > $quarantine_method_by_ccat{CC_CLEAN.",3"} = 'local:clean/%m'; > $quarantine_method_by_ccat{CC_CLEAN.",4"} = 'local:clean/%m'; > $quarantine_to_maps_by_ccat{CC_CLEAN.",2"} = ['recip-quarantine']; > $quarantine_to_maps_by_ccat{CC_CLEAN.",3"} = ['sender-quarantine']; > $quarantine_to_maps_by_ccat{CC_CLEAN.",4"} = ['clean-quarantine']; > > (the recip-quarantine, sender-quarantine and clean-quarantine are > predefined in %Amavis::Conf::local_delivery_aliases, but can be > changed or additional aliases added in amavisd.conf). > > > Then in a custom hook just add CC_CLEAN,2 or CC_CLEAN,3 or CC_CLEAN,4 > contents category as appropriate to a message, and quarantining will > happen automatically: > > > custom hook: > ># 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, > qw(send...@example.com send...@example.com .example.net)) { > $ccat_sub = 3; # sender quarantine > } elsif (grep { Amavis::Lookup::lookup(0,$_, > qw(rec...@example.com rec...@example.com)) } @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 > }; Hi Mark, I'm finally implementing this with amavis 2.7.0, and I just wanted to confirm my tweaks to the above module look right to you, based on the initial patch mentioned above: cat amavisd-custom.conf # 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 }; Basically, I modified it to validate against the quarantine maps for both cases. Thanks, Quanah -- Quanah Gibson-Mount Sr. Member of Technical Staff Zimbra, Inc A Division of VMware, Inc. -------------------- Zimbra :: the leader in open source messaging and collaboration ------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ AMaViS-user mailing list AMaViS-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amavis-user Please visit http://www.ijs.si/software/amavisd/ regularly For administrativa requests please send email to rainer at openantivirus dot org