commit e5fc552300d589c5ba056c4a07ff0a9d1cd4d5d0
Author: chris <chris@ rudorff com>
Date: Fri Jun 26 19:16:41 2009 +0200
fix Net::Server::Mail::ESMTP::AUTH LOGIN
diff --git a/lib/perl5/Net/Server/Mail/ESMTP/AUTH.pm b/lib/perl5/Net/Server/Mail/ESMTP/AUTH.pm
index f87c106..29d9e4d 100644
--- a/lib/perl5/Net/Server/Mail/ESMTP/AUTH.pm
+++ b/lib/perl5/Net/Server/Mail/ESMTP/AUTH.pm
@@ -6,7 +6,7 @@ use base qw(Net::Server::Mail::ESMTP::Extension);
use MIME::Base64;
use vars qw( $VERSION );
-$VERSION = '0.1';
+$VERSION = '0.1.1';
=pod
@@ -29,6 +29,7 @@ support for SMTP Authentification with Net::Server::Mail::ESMTP module
# adding AUTH handler
$esmtp->set_callback(AUTH => \&validate_auth);
+ $esmtp->set_callback(DATA => \&queue_message);
$esmtp->process;
}
@@ -38,6 +39,7 @@ support for SMTP Authentification with Net::Server::Mail::ESMTP module
if ($username eq 'ROBERT' and $password eq 'TOTO04') {
# AUTH SUCCESFULL
+ $session->{AUTH}->{ok} = 1;
return 1;
} else {
# AUTH FAILED
@@ -45,9 +47,24 @@ support for SMTP Authentification with Net::Server::Mail::ESMTP module
}
}
+sub queue_message {
+ my($session, $data) = @_;
+
+ # providing AUTH doesn't make it mandatory.
+ # A client might not use AUTH at all!
+ # You must deal now with permissions:
+
+ unless ($session->{AUTH}->{ok}) {
+ # warn "no AUTH supplied!";
+ return(0, 530, 'Error: Authentication required');
+ }
+ ... do stuff
+}
+
=head1 FEATURES
-* AUTH LOGIN method support
-* AUTH PLAIN method support
+
+ * AUTH LOGIN method support
+ * AUTH PLAIN method support
=head1 DESCRIPTION
@@ -93,7 +110,7 @@ sub process_authlogin_username
$self->{AUTH}->{password} = '';
$self->reply(334, "UGFzc3dvcmQ6");
$self->next_input_to(\&process_authlogin_password);
- return 1;
+ return ();
}
sub process_authlogin_password
@@ -101,8 +118,7 @@ sub process_authlogin_password
my ($self, $operation) = @_;
$self->{AUTH}->{password} = decode_base64($operation);
- exec_auth_callback($self);
- return 1;
+ return exec_auth_callback($self);
}
sub exec_auth_callback
@@ -120,8 +136,10 @@ sub exec_auth_callback
if ($authok) {
$self->reply(235, "Authentification successful.");
+ return ();
} else {
$self->reply(535, "Authentification failed.");
+ return 1;
}
}
@@ -145,12 +163,11 @@ sub process
} else {
$self->{AUTH}->{username} = $plaindata[@plaindata-2];
$self->{AUTH}->{password} = $plaindata[@plaindata-1];
- exec_auth_callback($self);
- return ();
+ return exec_auth_callback($self);
}
} elsif ($operation eq 'LOGIN') {
$param=decode_base64($param);
- warn " ==> LOGIN ==> $param\n";
+ # warn " ==> LOGIN ==> $param\n";
$self->reply(334, "VXNlcm5hbWU6");
$self->next_input_to(\&process_authlogin_username);
return ();
@@ -176,6 +193,10 @@ Sylvain Cresto E<lt>tost@softhome.netE<gt>
Please send bug-reports to tost@softhome.net.
+=head1 VERSION
+
+0.1.1 06/26/2009 fixed AUTH LOGIN -- chr <chris at u- club.de>
+
=head1 LICENCE
This library is free software; you can redistribute it and/or modify