From 7230de2ddc7a69675081c24f3ecd2f1d98856f9e Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 16 Sep 2014 17:55:57 -0700 Subject: [PATCH] SMTP: don't create new Transaction at disconnect the current result of passing a DENY* response is a new transaction. That seems wrong. --- lib/Qpsmtpd/SMTP.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/Qpsmtpd/SMTP.pm b/lib/Qpsmtpd/SMTP.pm index 529927b..f606e99 100644 --- a/lib/Qpsmtpd/SMTP.pm +++ b/lib/Qpsmtpd/SMTP.pm @@ -131,12 +131,14 @@ sub connect_respond { sub transaction { my $self = shift; - return $self->{_transaction} || $self->reset_transaction(); + return $self->{_transaction} || $self->reset_transaction; } sub reset_transaction { my $self = shift; - $self->run_hooks("reset_transaction") if $self->{_transaction}; + if ($self->{_transaction}) { + $self->run_hooks('reset_transaction'); + }; return $self->{_transaction} = Qpsmtpd::Transaction->new(); } @@ -591,7 +593,7 @@ sub vrfy_respond { elsif ($rc == DENY) { $msg->[0] ||= "Access Denied"; $self->respond(554, @$msg); - $self->reset_transaction(); + $self->reset_transaction; return 1; } elsif ($rc == OK) { @@ -631,7 +633,8 @@ sub disconnect { my $self = shift; $self->run_hooks("disconnect"); $self->connection->notes(disconnected => 1); - $self->reset_transaction; + $self->run_hooks('reset_transaction') if $self->{_transaction}; + return; } sub data { @@ -647,13 +650,13 @@ sub data_respond { elsif ($rc == DENY) { $msg->[0] ||= "Message denied"; $self->respond(554, @$msg); - $self->reset_transaction(); + $self->reset_transaction; return 1; } elsif ($rc == DENYSOFT) { $msg->[0] ||= "Message denied temporarily"; $self->respond(451, @$msg); - $self->reset_transaction(); + $self->reset_transaction; return 1; } elsif ($rc == DENY_DISCONNECT) {