[Mimedefang] disable antivirus for one user

Steffen Kaiser skmimedefang at smail.inf.fh-bonn-rhein-sieg.de
Thu Jan 29 07:58:40 EST 2004


On Wed, 28 Jan 2004, Fox, Randy wrote:

> > does anyone have a quick way to say
> > if the recipient is myhoneypot at domain.com exit from the
> > filter completely and deliver as-is?
>
> How about adding and activating filter_recipient?  Then put something
> like this in the sub-routine:
>
> sub filter_recipient {
>         my($recip, $sender, $ip, $host, $first, $helo) = @_;
>         $recip =~ tr/A-Z/a-z/;
>         if ($recip =~ /myhoneypot\@domain.com/) {
>             return ('ACCEPT_AND_NO_MORE_FILTERING','ok');
>         }
> }

Hmm, this snippet is from stream_by_recipient:

    foreach $recip (@Recipients) {
        resend_message_one_recipient($recip);
    }

You have _one_ recipient that should go unfiltered, but the mail has
probably more than one recipient.

The idea I have now is that the mail is dealt with normally, if there is
just one recipient or at least one non-exempted recipient is specified,
and the message is resend to all exempted recipients individually.

How about in filter_begin:

if(scalar(@Recipients) > 1) { # May be honeypot and regular users are
			# intermixed

	# Filter for exempted recipients
	foreach my $r (@Recipients) {
		if($r =~ /(^|\<)myhoneypot\@domain\.com($|\>)/i) {
			# honeypot found

			# Resend -> Next time the filter gets this mail
			# there is just one recipient, hence, this
			# check is bypassed, and the mail is processed
			resend_message_one_recipient($r);

			delete_recipient($r);
		}
	}

## Warning:
# If you have more than one recipients to exempt, you have to deal with
# the probability that all recipients are deleted from the current (the
# original, actually) message, because all of them are exempted.

## Warning #2:
# @Recipients does still include all exempted recipients, because
# delete_recipient() does not update the array!

	$exemptedUser = 0;
} elsif($Recipient[0]  =~ /(^|\<)myhoneypot\@domain\.com($|\>)/i) {
	# the single recipient is the special user to be exempted from
	# scanning

	# Set a global variable so all filter_*() functions bypass filtering
	# by immediately calling action_accept();
	$exemptedUser = 1;
	return action_accept();
} else {
	$exemptedUser = 0;
}

Then in all other filter_* functions there is a:


	return action_accept() if $exemptedUser;

right behind the usual

	return if message_rejected();

Or do evaluate $exemptedUser whereever you need.

Bye,

-- 
Steffen Kaiser



More information about the MIMEDefang mailing list