cvs commit: qpsmtpd/lib/Qpsmtpd SMTP.pm
[email protected] (Ask Bjoern Hansen)
| Newsgroups | perl.cvs.qpsmtpd |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 03/04/21 02:42:01
Modified: . Changes
lib/Qpsmtpd SMTP.pm
Added: plugins saslauth
Log:
Add not even halfbaked saslauth plugin. Hopefully it'll give us
SMTP AUTH some day. :-)
If a plugin running the ehlo hook add something to the ARRAY
reference $self->transaction->notes('capabilities') then it will be
added to the EHLO response.
Add command_counter method to the SMTP object. Plugins can use this
to catch (or not) consecutive commands. In particular useful with
the unrecognized_command hook.
Revision Changes Path
1.44 +8 -0 qpsmtpd/Changes
Index: Changes
===================================================================
RCS file: /cvs/public/qpsmtpd/Changes,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -w -r1.43 -r1.44
--- Changes 21 Apr 2003 08:28:12 -0000 1.43
+++ Changes 21 Apr 2003 09:42:00 -0000 1.44
@@ -1,5 +1,13 @@
0.26-dev
+ If a plugin running the ehlo hook add something to the ARRAY
+ reference $self->transaction->notes('capabilities') then it will be
+ added to the EHLO response.
+
+ Add command_counter method to the SMTP object. Plugins can use this
+ to catch (or not) consecutive commands. In particular useful with
+ the unrecognized_command hook.
+
Filter out all uncommon characters from the remote_host
setting. (thanks to Frank Denis / Jedi/Sector One for the hint).
1.1 qpsmtpd/plugins/saslauth
Index: saslauth
===================================================================
#
# This plugin doesn't work at all yet! Really; it's not even a
# prototype. More like a skeleton with no bones. Patches welcome.
#
=pod
TODO:
After an AUTH command has successfully completed, no more AUTH
commands may be issued in the same session. After a successful
AUTH command completes, a server MUST reject any further AUTH
commands with a 503 reply.
The AUTH command is not permitted during a mail transaction.
If the client wishes to cancel an authentication exchange, it issues a line
with a single "*". If the server receives such an answer, it
MUST reject the AUTH command by sending a 501 reply.
=cut
sub register {
my ($self, $qp) = @_;
$self->register_hook("ehlo", "ehlo");
$self->register_hook("unrecognized_command", "auth");
}
sub ehlo {
my ($self, $transaction, $host) = @_;
$transaction->notes('capabilities'); # or
$transaction->notes('capabilities', []);
my $capabilities = $transaction->notes('capabilities');
push @{$capabilities}, 'AUTH PLAIN LOGIN DIGEST-MD5 PLAIN';
}
sub auth {
my ($self, $transaction, $command) = @_;
return DECLINED unless $self->{expecting_response} or $command eq "auth";
if ($command eq "auth") {
warn "COMMAND: $command";
$self->qp->respond(334, "VXNlcm5hbWU6");
$self->{expecting_response} = $self->qp->command_counter;
return DONE;
}
else {
$self->{expecting_response}+1 == $self->qp->command_counter
or return DECLINED;
# check the response
$self->qp->respond(123, "Something should go here...");
return DONE;
}
}
1.13 +11 -1 qpsmtpd/lib/Qpsmtpd/SMTP.pm
Index: SMTP.pm
===================================================================
RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/SMTP.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -r1.12 -r1.13
--- SMTP.pm 15 Apr 2003 18:10:44 -0000 1.12
+++ SMTP.pm 21 Apr 2003 09:42:01 -0000 1.13
@@ -37,12 +37,17 @@
$self;
}
-
+sub command_counter {
+ my $self = shift;
+ $self->{_counter} || 0;
+}
sub dispatch {
my $self = shift;
my ($cmd) = lc shift;
+ $self->{_counter}++;
+
#$self->respond(553, $state{dnsbl_blocked}), return 1
# if $state{dnsbl_blocked} and ($cmd eq "rcpt");
@@ -157,11 +162,16 @@
$conn->hello_host($hello_host);
$self->transaction;
+ my @capabilities = $self->transaction->notes('capabilities')
+ ? @{ $self->transaction->notes('capabilities') }
+ : ();
+
$self->respond(250,
$self->config("me") . " Hi " . $conn->remote_info . " [" . $conn->remote_ip ."]",
"PIPELINING",
"8BITMIME",
($self->config('databytes') ? "SIZE ". ($self->config('databytes'))[0] : ()),
+ @capabilities,
);
}
}