On Tue May 04, 2010 at 14:27:16 -0700, Robert Spier wrote: > Oddly, this doesn't apply cleanly to the STATUS file.
Oddness. A single line removal should be a sane patch! > Can you generate a new patch, and run perltidy on it as well? At > the very least, the qpsmtpd style is to put the braces { } on the > same line as the operation, not the line itself. Done. Using the .perltidyrc file found in the repository. Two patches attached, in case of failure to apply. (Fresh checkout of the repository from git://git.develooper.com/qpsmtpd.git ) Steve --
diff --git a/plugins/check_bogus_bounce b/plugins/check_bogus_bounce new file mode 100644 index 0000000..045889c --- /dev/null +++ b/plugins/check_bogus_bounce @@ -0,0 +1,126 @@ +#!/usr/bin/perl -w + +=head1 NAME + +check_bogus_bounce - Check that a bounce message isn't bogus + +=head1 DESCRIPTION + +This plugin is designed to reject bogus bounce messages. + +In our case a bogus bounce message is defined as a bounce message +which has more than a single recipient. + +=head1 CONFIGURATION + +Only a single argument is recognized and is assumed to be the default +action. Valid settings are: + +=over 8 + +=item log + +Merely log the receipt of the bogus bounce (the default behaviour). + +=item deny + +Deny with a hard error code. + +=item denysoft + +Deny with a soft error code. + +=back + +=cut + +=head1 AUTHOR + +Steve Kemp +-- +http://steve.org.uk/Software/qpsmtpd/ + +=cut + +=begin doc + +Look for our single expected argument and configure "action" appropriately. + +=end doc + +=cut + +sub register { + my ($self, $qp, $arg, @nop) = (@_); + + # + # Default behaviour is to merely log. + # + $self->{_action} = "log"; + + # + # Unless one was specified + # + if ($arg) { + if ($arg =~ /^(log|deny|denysoft)$/i) { + $self->{_action} = $arg; + } + else { + die "Invalid argument '$arg' - use one of : log, deny, denysoft"; + } + } +} + +=begin doc + +Handle the detection of bounces here. + +If we find a match then we'll react with our expected action. + +=end doc + +=cut + +sub hook_data_post { + my ($self, $transaction) = (@_); + + # + # Find the sender, and return unless it wasn't a bounce. + # + my $sender = $transaction->sender->address || undef; + return DECLINED unless ($sender =~ /^<>$/); + + # + # Get the recipients. + # + my @to = $transaction->recipients || (); + return DECLINED unless (scalar @to > 1); + + # + # OK at this point we know: + # + # 1. It is a bounce, via the null-envelope. + # 2. It is a bogus bounce, because there are more than one recipients. + # + if ($self->{_action} =~ /^log$/i) { + $self->log(LOGWARN, + $self->plugin_name() . " bogus bounce for :" . join(",", @to)); + } + elsif ($self->{_action} =~ /^deny$/i) { + return (DENY, + $self->plugin_name() . " determined this to be a bogus bounce"); + } + elsif ($self->{_action} =~ /^denysoft$/i) { + return (DENYSOFT, + $self->plugin_name() . " determined this to be a bogus bounce"); + } + else { + $self->log(LOGWARN, + $self->plugin_name() . " failed to determine action. bug?"); + } + + # + # All done; allow this to proceed + # + return DECLINED; +}
diff --git a/STATUS b/STATUS index 4a00dc6..81cf0df 100644 --- a/STATUS +++ b/STATUS @@ -59,8 +59,6 @@ Make a system for configuring the plugins per user/domain/... support databytes per user / domain -plugin to reject mails from <> if it has multiple recipients. - localiphost - support f...@[a.b.c.d] addresses Move dispatch() etc from SMTP.pm to Qpsmtpd.pm to allow other similar