bogus_bounce: added logging and rejection handling

This commit is contained in:
Matt Simerson 2012-06-23 00:32:40 -04:00
parent 6a7598e3bf
commit d74a5bb095

View File

@ -32,13 +32,9 @@ Deny with a soft error code.
=back =back
=cut
=head1 AUTHOR =head1 AUTHOR
Steve Kemp 2010 - Steve Kemp - http://steve.org.uk/Software/qpsmtpd/
--
http://steve.org.uk/Software/qpsmtpd/
=cut =cut
@ -51,23 +47,22 @@ Look for our single expected argument and configure "action" appropriately.
=cut =cut
sub register { sub register {
my ($self, $qp, $arg, @nop) = (@_); my ($self, $qp) = (shift, shift);
# if ( @_ % 2 ) {
# Default behaviour is to merely log. $self->{_args}{action} = shift;
# }
$self->{_action} = "log"; else {
$self->{_args} = { @_ };
};
# if ( ! defined $self->{_args}{reject} ) {
# Unless one was specified $self->{_args}{reject} = 0; # legacy default
# };
if ($arg) {
if ($arg =~ /^(log|deny|denysoft)$/i) { # we only need to check for deferral, default is DENY
$self->{_action} = $arg; if ( $self->{_args}{action} =~ /soft/i ) {
} $self->{_args}{reject_type} = 'temp';
else {
die "Invalid argument '$arg' - use one of : log, deny, denysoft";
}
} }
} }
@ -88,39 +83,27 @@ sub hook_data_post {
# Find the sender, and return unless it wasn't a bounce. # Find the sender, and return unless it wasn't a bounce.
# #
my $sender = $transaction->sender->address || undef; my $sender = $transaction->sender->address || undef;
return DECLINED unless ($sender eq "<>"); if ( $sender && $sender ne '<>') {
$self->log(LOGINFO, "pass, not a null sender");
return DECLINED;
};
# #
# Get the recipients. # Get the recipients.
# #
my @to = $transaction->recipients || (); my @to = $transaction->recipients || ();
return DECLINED unless (scalar @to > 1); if (scalar @to == 1) {
$self->log(LOGINFO, "pass, only 1 recipient");
return DECLINED;
};
# #
# OK at this point we know: # at this point we know:
# #
# 1. It is a bounce, via the null-envelope. # 1. It is a bounce, via the null-envelope.
# 2. It is a bogus bounce, because there are more than one recipients. # 2. It is a bogus bounce, because there are more than one recipients.
# #
if (lc $self->{_action} eq "log") { $self->log(LOGINFO, "fail, bogus bounce for :" . join(',', @to));
$self->log(LOGWARN,
$self->plugin_name() . " bogus bounce for :" . join(",", @to));
}
elsif (lc $self->{_action} eq "deny") {
return (DENY,
$self->plugin_name() . " determined this to be a bogus bounce");
}
elsif (lc $self->{_action} eq "denysoft") {
return (DENYSOFT,
$self->plugin_name() . " determined this to be a bogus bounce");
}
else {
$self->log(LOGWARN,
$self->plugin_name() . " failed to determine action. bug?");
}
# $self->get_reject( "fail, this is a bogus bounce" );
# All done; allow this to proceed
#
return DECLINED;
} }