From d5ccedd37ed3a8bfe418ba49720505b52e7de8e6 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Fri, 22 Jun 2012 18:14:44 -0400 Subject: [PATCH] Plugin.pm: more descriptive variable names append optional log_mess to log entry (more description) subsequent attempts to set naughty don't overwrite the first set the naughty rejection type to be the reject type of the plugin that marked the connection naughty get_reject_type can be passed an explicit default --- lib/Qpsmtpd/Plugin.pm | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/Qpsmtpd/Plugin.pm b/lib/Qpsmtpd/Plugin.pm index 57a8614..6b063b4 100644 --- a/lib/Qpsmtpd/Plugin.pm +++ b/lib/Qpsmtpd/Plugin.pm @@ -212,32 +212,37 @@ sub compile { sub get_reject { my $self = shift; - my $message = shift || "why didn't you pass an error message?"; - my $log_info = shift || ''; - $log_info = ", $log_info" if $log_info; + my $smtp_mess = shift || "why didn't you pass an error message?"; + my $log_mess = shift || ''; + $log_mess = ", $log_mess" if $log_mess; my $reject = $self->{_args}{reject}; if ( defined $reject && ! $reject ) { - $self->log(LOGINFO, 'fail, reject disabled'); + $self->log(LOGINFO, "fail, reject disabled" . $log_mess); return DECLINED; }; # the naughty plugin will reject later if ( $reject eq 'naughty' ) { - $self->log(LOGINFO, 'fail, NAUGHTY'); - $self->connection->notes('naughty', $message); + $self->log(LOGINFO, "fail, NAUGHTY" . $log_mess); + if ( ! $self->connection->notes('naughty') ) { + $self->connection->notes('naughty', $smtp_mess); + }; + if ( ! $self->connection->notes('naughty_reject_type') ) { + $self->connection->notes('naughty_reject_type', $self->{_args}{reject_type} ); + } return (DECLINED); }; # they asked for reject, we give them reject - $self->log(LOGINFO, 'fail'.$log_info); - return ( $self->get_reject_type(), $message); + $self->log(LOGINFO, "fail" . $log_mess); + return ( $self->get_reject_type(), $smtp_mess); }; sub get_reject_type { my $self = shift; my $default = shift || DENY; - my $deny = $self->{_args}{reject_type} or return $default; + my $deny = shift || $self->{_args}{reject_type} or return $default; return $deny =~ /^(temp|soft)$/i ? DENYSOFT : $deny =~ /^(perm|hard)$/i ? DENY