cvs commit: qpsmtpd/plugins rcpt_ok check_relay
[email protected] (John Peacock)
| Newsgroups | perl.cvs.qpsmtpd |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 04/09/22 09:01:16
Modified: . Changes
config plugins
lib/Qpsmtpd Auth.pm Connection.pm SMTP.pm
plugins check_relay
Added: plugins rcpt_ok
Log:
* plugins/check_relay
* plugins/rcpt_ok
Split check_relay into two plugins
* config/plugins
Reorder plugins to take advantage of the new check_relay
* lib/Qpsmtpd/Connection.pm
Add support for relay_client() method
* lib/Qpsmtpd/SMTP.pm
Copy connection relay settings to transaction object when created
* lib/Qpsmtpd/Auth.pm
Use the connection->relay_client() instead of setting an env var
Revision Changes Path
1.75 +11 -0 qpsmtpd/Changes
Index: Changes
===================================================================
RCS file: /cvs/public/qpsmtpd/Changes,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -w -r1.74 -r1.75
--- Changes 1 Aug 2004 22:35:49 -0000 1.74
+++ Changes 22 Sep 2004 16:01:16 -0000 1.75
@@ -25,6 +25,17 @@
+ initial "awkward silence" period now configurable (Mark Powell)
+ DENY/DENYSOFT now configurable
+ Move relay flag to connection object (John Peacock):
+ + add relay_client() method to Connection.pm
+ + change SMTP.pm to copy relay_client() flag to transaction relaying
+ flag (for compatibility purposes) - should deprecate instead
+ + Update Auth.pm module to set $connection->relay_client()
+
+ Split check_relay plugin into two plugins (John Peacock):
+ + check_relay now fires on connect and sets relay_client() flag
+ + rcpt_ok runs last of rcpt plugins and performs final OK/DENY
+ + change default config/plugins to reflect new order
+
0.28 - 2004/06/05
Don't keep adding ip addresses to the process status line ($0) when running under PPerl.
1.14 +2 -1 qpsmtpd/config/plugins
Index: plugins
===================================================================
RCS file: /cvs/public/qpsmtpd/config/plugins,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -r1.13 -r1.14
--- plugins 7 Sep 2004 05:36:41 -0000 1.13
+++ plugins 22 Sep 2004 16:01:16 -0000 1.14
@@ -10,6 +10,7 @@
check_earlytalker
count_unrecognized_commands 4
+check_relay
require_resolvable_fromhost
@@ -22,7 +23,7 @@
# sender_permitted_from
# this plugin needs to run after all other "rcpt" plugins
-check_relay
+rcpt_ok
# content filters
virus/klez_filter
1.4 +1 -1 qpsmtpd/lib/Qpsmtpd/Auth.pm
Index: Auth.pm
===================================================================
RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/Auth.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- Auth.pm 29 Jul 2004 14:40:32 -0000 1.3
+++ Auth.pm 22 Sep 2004 16:01:16 -0000 1.4
@@ -319,7 +319,7 @@
$msg = "Authentication successful" .
( defined $msg ? " - " . $msg : "" );
$session->respond( 235, $msg );
- $ENV{RELAYCLIENT} = 1;
+ $session->connection->relay_client(1);
$session->log( LOGINFO, $msg );
return OK;
}
1.6 +6 -0 qpsmtpd/lib/Qpsmtpd/Connection.pm
Index: Connection.pm
===================================================================
RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/Connection.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -r1.5 -r1.6
--- Connection.pm 29 Aug 2004 07:53:15 -0000 1.5
+++ Connection.pm 22 Sep 2004 16:01:16 -0000 1.6
@@ -59,6 +59,12 @@
$self->{_remote_info};
}
+sub relay_client {
+ my $self = shift;
+ @_ and $self->{_relay_client} = shift;
+ $self->{_relay_client};
+}
+
sub hello {
my $self = shift;
@_ and $self->{_hello} = shift;
1.43 +3 -1 qpsmtpd/lib/Qpsmtpd/SMTP.pm
Index: SMTP.pm
===================================================================
RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/SMTP.pm,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -w -r1.42 -r1.43
--- SMTP.pm 14 Sep 2004 05:48:39 -0000 1.42
+++ SMTP.pm 22 Sep 2004 16:01:16 -0000 1.43
@@ -116,7 +116,9 @@
sub reset_transaction {
my $self = shift;
$self->run_hooks("reset_transaction") if $self->{_transaction};
- return $self->{_transaction} = Qpsmtpd::Transaction->new();
+ $self->{_transaction} = Qpsmtpd::Transaction->new();
+ $self->{_transaction}->relaying($self->{_connection}->{_relay_client});
+ return $self->{_transaction};
}
1.7 +7 -28 qpsmtpd/plugins/check_relay
Index: check_relay
===================================================================
RCS file: /cvs/public/qpsmtpd/plugins/check_relay,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -r1.6 -r1.7
--- check_relay 16 Jun 2004 20:28:57 -0000 1.6
+++ check_relay 22 Sep 2004 16:01:16 -0000 1.7
@@ -1,26 +1,15 @@
-# this plugin checks the standard rcpthosts config and
+# this plugin checks the relayclients config file and
# $ENV{RELAYCLIENT} to see if relaying is allowed.
#
-# It should be configured to be run _LAST_!
-#
sub register {
my ($self, $qp) = @_;
- $self->register_hook("rcpt", "check_relay");
+ $self->register_hook("connect", "check_relay");
}
sub check_relay {
- my ($self, $transaction, $recipient) = @_;
- my $host = lc $recipient->host;
-
- my @rcpt_hosts = ($self->qp->config("me"), $self->qp->config("rcpthosts"));
-
- # Allow 'no @' addresses for 'postmaster' and 'abuse'
- # qmail-smtpd will do this for all users without a domain, but we'll
- # be a bit more picky. Maybe that's a bad idea.
- my $user = $recipient->user;
- $host = $self->qp->config("me")
- if ($host eq "" && (lc $user eq "postmaster" || lc $user eq "abuse"));
+ my ($self, $transaction) = @_;
+ my $connection = $self->qp->connection;
# Check if this IP is allowed to relay
my @relay_clients = $self->qp->config("relayclients");
@@ -32,21 +21,11 @@
exists($relay_clients{$client_ip}) or
exists($more_relay_clients->{$client_ip}))
{
- $transaction->relaying(1);
- return (OK);
+ $connection->relay_client(1);
+ last;
}
$client_ip =~ s/\d+\.?$//; # strip off another 8 bits
}
- # Check if this recipient host is allowed
- for my $allowed (@rcpt_hosts) {
- $allowed =~ s/^\s*(\S+)/$1/;
- return (OK) if $host eq lc $allowed;
- return (OK) if substr($allowed,0,1) eq "." and $host =~ m/\Q$allowed\E$/i;
- }
-
- my $more_rcpt_hosts = $self->qp->config('morercpthosts', 'map');
- return (OK) if exists $more_rcpt_hosts->{$host};
-
- return (DENY);
+ return (DECLINED);
}
1.1 qpsmtpd/plugins/rcpt_ok
Index: rcpt_ok
===================================================================
# this plugin checks the standard rcpthosts config
#
# It should be configured to be run _LAST_!
#
sub register {
my ($self, $qp) = @_;
$self->register_hook("rcpt", "rcpt_ok");
}
sub rcpt_ok {
my ($self, $transaction, $recipient) = @_;
my $host = lc $recipient->host;
my @rcpt_hosts = ($self->qp->config("me"), $self->qp->config("rcpthosts"));
# Allow 'no @' addresses for 'postmaster' and 'abuse'
# qmail-smtpd will do this for all users without a domain, but we'll
# be a bit more picky. Maybe that's a bad idea.
my $user = $recipient->user;
$host = $self->qp->config("me")
if ($host eq "" && (lc $user eq "postmaster" || lc $user eq "abuse"));
# Check if this recipient host is allowed
for my $allowed (@rcpt_hosts) {
$allowed =~ s/^\s*(\S+)/$1/;
return (OK) if $host eq lc $allowed;
return (OK) if substr($allowed,0,1) eq "." and $host =~ m/\Q$allowed\E$/i;
}
my $more_rcpt_hosts = $self->qp->config('morercpthosts', 'map');
return (OK) if exists $more_rcpt_hosts->{$host};
if ( $self->qp->connection->relay_client ) { # failsafe
return (OK);
}
else {
return (DENY);
}
}