Migrate transaction(), reset_transaction() and connection() up to Qpsmtpd.pm
Minor bug fix for auth capability git-svn-id: https://svn.perl.org/qpsmtpd/trunk@533 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
72a3056e66
commit
9d6faa39cb
@ -4,6 +4,8 @@ use vars qw($VERSION $Logger $TraceLevel $Spool_dir);
|
|||||||
|
|
||||||
use Sys::Hostname;
|
use Sys::Hostname;
|
||||||
use Qpsmtpd::Constants;
|
use Qpsmtpd::Constants;
|
||||||
|
use Qpsmtpd::Transaction;
|
||||||
|
use Qpsmtpd::Connection;
|
||||||
|
|
||||||
$VERSION = "0.31-dev";
|
$VERSION = "0.31-dev";
|
||||||
|
|
||||||
@ -255,7 +257,21 @@ sub _load_plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub transaction {
|
sub transaction {
|
||||||
return {}; # base class implements empty transaction
|
my $self = shift;
|
||||||
|
return $self->{_transaction} || $self->reset_transaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub reset_transaction {
|
||||||
|
my $self = shift;
|
||||||
|
$self->run_hooks("reset_transaction") if $self->{_transaction};
|
||||||
|
return $self->{_transaction} = Qpsmtpd::Transaction->new();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub connection {
|
||||||
|
my $self = shift;
|
||||||
|
@_ and $self->{_connection} = shift;
|
||||||
|
return $self->{_connection} || ($self->{_connection} = Qpsmtpd::Connection->new());
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run_hooks {
|
sub run_hooks {
|
||||||
|
@ -6,8 +6,6 @@ package Qpsmtpd::SMTP;
|
|||||||
use strict;
|
use strict;
|
||||||
use Carp;
|
use Carp;
|
||||||
|
|
||||||
use Qpsmtpd::Connection;
|
|
||||||
use Qpsmtpd::Transaction;
|
|
||||||
use Qpsmtpd::Plugin;
|
use Qpsmtpd::Plugin;
|
||||||
use Qpsmtpd::Constants;
|
use Qpsmtpd::Constants;
|
||||||
use Qpsmtpd::Auth;
|
use Qpsmtpd::Auth;
|
||||||
@ -32,7 +30,7 @@ sub new {
|
|||||||
my $self = bless ({ args => \%args }, $class);
|
my $self = bless ({ args => \%args }, $class);
|
||||||
|
|
||||||
my (@commands) = qw(ehlo helo rset mail rcpt data help vrfy noop quit);
|
my (@commands) = qw(ehlo helo rset mail rcpt data help vrfy noop quit);
|
||||||
my (%commands); @commands{@commands} = ('') x @commands;
|
my (%commands); @commands{@commands} = (1) x @commands;
|
||||||
# this list of valid commands should probably be a method or a set of methods
|
# this list of valid commands should probably be a method or a set of methods
|
||||||
$self->{_commands} = \%commands;
|
$self->{_commands} = \%commands;
|
||||||
|
|
||||||
@ -130,25 +128,6 @@ sub connect_respond {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub transaction {
|
|
||||||
my $self = shift;
|
|
||||||
return $self->{_transaction} || $self->reset_transaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
sub reset_transaction {
|
|
||||||
my $self = shift;
|
|
||||||
$self->run_hooks("reset_transaction") if $self->{_transaction};
|
|
||||||
return $self->{_transaction} = Qpsmtpd::Transaction->new();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sub connection {
|
|
||||||
my $self = shift;
|
|
||||||
@_ and $self->{_connection} = shift;
|
|
||||||
return $self->{_connection} || ($self->{_connection} = Qpsmtpd::Connection->new());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sub helo {
|
sub helo {
|
||||||
my ($self, $hello_host, @stuff) = @_;
|
my ($self, $hello_host, @stuff) = @_;
|
||||||
return $self->respond (501,
|
return $self->respond (501,
|
||||||
@ -217,9 +196,7 @@ sub ehlo_respond {
|
|||||||
$conn->hello_host($hello_host);
|
$conn->hello_host($hello_host);
|
||||||
$self->transaction;
|
$self->transaction;
|
||||||
|
|
||||||
my @capabilities = $self->transaction->notes('capabilities')
|
my @capabilities = @{ $self->transaction->notes('capabilities') };
|
||||||
? @{ $self->transaction->notes('capabilities') }
|
|
||||||
: ();
|
|
||||||
|
|
||||||
# Check for possible AUTH mechanisms
|
# Check for possible AUTH mechanisms
|
||||||
my %auth_mechanisms;
|
my %auth_mechanisms;
|
||||||
@ -237,7 +214,7 @@ HOOK: foreach my $hook ( keys %{$self->{hooks}} ) {
|
|||||||
|
|
||||||
if ( %auth_mechanisms ) {
|
if ( %auth_mechanisms ) {
|
||||||
push @capabilities, 'AUTH '.join(" ",keys(%auth_mechanisms));
|
push @capabilities, 'AUTH '.join(" ",keys(%auth_mechanisms));
|
||||||
$self->{_commands}->{'auth'} = "";
|
$self->{_commands}->{'auth'} = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->respond(250,
|
$self->respond(250,
|
||||||
|
Loading…
Reference in New Issue
Block a user