From 5959cc1c32491267125a9b68d0feda78f0d76a1a Mon Sep 17 00:00:00 2001 From: John Peacock Date: Mon, 31 Oct 2005 17:12:37 +0000 Subject: [PATCH] * lib/Qpsmtpd/Auth.pm lib/Qpsmtpd/SMTP.pm Take the AUTH method and put it in SMTP.pm where it belongs. * lib/Qpsmtpd.pm lib/Qpsmtpd/Plugin.pm Expose the auth_user/auth_mechanism property to plugin writers. git-svn-id: https://svn.perl.org/qpsmtpd/branches/0.31@556 958fd67b-6ff1-0310-b445-bb7760255be9 --- lib/Qpsmtpd.pm | 10 ++++++++++ lib/Qpsmtpd/Auth.pm | 13 ------------- lib/Qpsmtpd/Plugin.pm | 8 ++++++++ lib/Qpsmtpd/SMTP.pm | 13 +++++++++++++ 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/lib/Qpsmtpd.pm b/lib/Qpsmtpd.pm index 9572df7..9ee6514 100644 --- a/lib/Qpsmtpd.pm +++ b/lib/Qpsmtpd.pm @@ -423,6 +423,16 @@ sub size_threshold { } return $Size_threshold; } + +sub auth_user { + my $self = shift; + return (defined $self->{_auth_user} ? $self->{_auth_user} : "" ); +} + +sub auth_mechanism { + my $self = shift; + return (defined $self->{_auth_mechanism} ? $self->{_auth_mechanism} : "" ); +} 1; diff --git a/lib/Qpsmtpd/Auth.pm b/lib/Qpsmtpd/Auth.pm index ea28b92..3bb2c86 100644 --- a/lib/Qpsmtpd/Auth.pm +++ b/lib/Qpsmtpd/Auth.pm @@ -226,19 +226,6 @@ sub e64 return($res); } -sub Qpsmtpd::SMTP::auth { - my ( $self, $arg, @stuff ) = @_; - - #they AUTH'd once already - return $self->respond( 503, "but you already said AUTH ..." ) - if ( defined $self->{_auth} - and $self->{_auth} == OK ); - return $self->respond( 503, "AUTH not defined for HELO" ) - if ( $self->connection->hello eq "helo" ); - - return $self->{_auth} = Qpsmtpd::Auth::SASL( $self, $arg, @stuff ); -} - sub SASL { # $DB::single = 1; diff --git a/lib/Qpsmtpd/Plugin.pm b/lib/Qpsmtpd/Plugin.pm index 6f8b124..f7250f7 100644 --- a/lib/Qpsmtpd/Plugin.pm +++ b/lib/Qpsmtpd/Plugin.pm @@ -65,6 +65,14 @@ sub spool_dir { shift->qp->spool_dir; } +sub auth_user { + shift->qp->auth_user; +} + +sub auth_mechanism { + shift->qp->auth_mechanism; +} + sub temp_file { my $self = shift; my $tempfile = $self->qp->temp_file; diff --git a/lib/Qpsmtpd/SMTP.pm b/lib/Qpsmtpd/SMTP.pm index 7400b66..b24eed7 100644 --- a/lib/Qpsmtpd/SMTP.pm +++ b/lib/Qpsmtpd/SMTP.pm @@ -225,6 +225,19 @@ HOOK: foreach my $hook ( keys %{$self->{hooks}} ) { } } +sub auth { + my ( $self, $arg, @stuff ) = @_; + + #they AUTH'd once already + return $self->respond( 503, "but you already said AUTH ..." ) + if ( defined $self->{_auth} + and $self->{_auth} == OK ); + return $self->respond( 503, "AUTH not defined for HELO" ) + if ( $self->connection->hello eq "helo" ); + + return $self->{_auth} = Qpsmtpd::Auth::SASL( $self, $arg, @stuff ); +} + sub mail { my $self = shift; return $self->respond(501, "syntax error in parameters") if !$_[0] or $_[0] !~ m/^from:/i;