Author: vetinari
Date: Thu May 8 06:58:16 2008
New Revision: 891
Modified:
contrib/vetinari/hook_skip/README.pod
contrib/vetinari/pipeline_sync
Log:
- pipeline_sync: per hook actions
Modified: contrib/vetinari/hook_skip/README.pod
==============================================================================
--- contrib/vetinari/hook_skip/README.pod (original)
+++ contrib/vetinari/hook_skip/README.pod Thu May 8 06:58:16 2008
@@ -3,11 +3,13 @@
This hook is run before a hooked subroutine for a plugin is called. If this
hook returns B<DENY>, the hook for a plugin is not executed and the next
-plugin (if any left) for the same hook is called. The C<logging> and
-the C<skip> hooks cannot be skipped.
+plugin (if any left) for the same hook is called. The C<logging>, C<config>
+and the C<skip> hooks cannot be skipped.
Arguments:
+
my ($self, $transaction, $plugin, $hook) = @_;
+
The I<$plugin> is the encoded plugin name, i.e. the string which
C<$self-E<gt>plugin_name> returns.
@@ -23,7 +25,7 @@
Any other return value continues as usual.
-Example plugin is F<skip_plugins>:
+Example plugins are F<skip_plugins> (see code below) and F<dnswl_skip>:
sub hook_skip {
my ($self, $txn, $plugin, $hook) = @_;
Modified: contrib/vetinari/pipeline_sync
==============================================================================
--- contrib/vetinari/pipeline_sync (original)
+++ contrib/vetinari/pipeline_sync Thu May 8 06:58:16 2008
@@ -22,36 +22,37 @@
=head1 CONFIGURATION
Arguments are key/value pairs. Setting the TIMEOUT values below to C<0>
-disables the checks for the given hook. Known arguments are:
+disables the checks for the given hook. You may specify also an action,
+separated by a C<,>. Known arguments are:
=over 4
-=item connect TIMEOUT
+=item connect TIMEOUT[,ACTION]
Wait TIMEOUT seconds at connect before sending out the greeting banner, default
timeout is C<1>.
-=item data TIMEOUT
+=item data TIMEOUT[,ACTION]
Wait TIMEOUT seconds before sending the C<354> message to the client, default
timeout is C<1>.
-
-=item noop TIMEOUT
+=item noop TIMEOUT[,ACTION]
Wait TIMEOUT seconds before returning C<250 OK> to the client, this check is
disabled by default.
-=item vrfy TIMEOUT
+=item vrfy TIMEOUT[,ACTION]
Wait TIMEOUT seconds before the other hook_vrfy() do something, this check is
disabled by default.
=item action DENY(SOFT)?(_DISCONNECT)?
-Sent (a temporary) error to the client and optionally disconnect, see
-F<docs/plugins.pod> and F<Qpsmtpd::Constants> for more info about the
-DENY, DENYSOFT, DENY_DISCONNECT and DENYSOFT_DISCONNECT constants.
+This sets the default action: Sent (a temporary) error to the client and
+optionally disconnect, see F<docs/plugins.pod> and F<Qpsmtpd::Constants> for
+more info about the DENY, DENYSOFT, DENY_DISCONNECT and DENYSOFT_DISCONNECT
+constants.
Default action is C<DENY>.
@@ -90,30 +91,41 @@
sub register {
my ($self, $qp, %args) = @_;
- $self->{_is_apache} = 0;
- $self->{_action} = "DENY";
- $self->{_defer} = 0;
+ $self->{_is_apache} = 0;
+ $self->{_def_action} = "DENY";
+ $self->{_defer} = 0;
my %checks = ( # default values... timeout in seconds
'connect' => 1,
'data' => 1,
'vrfy' => 0,
'noop' => 0,
);
+ my %actions = (
+ 'connect' => 0,
+ 'data' => 0,
+ 'vrfy' => 0,
+ 'noop' => 0,
+ );
foreach my $key (keys %args) {
if (exists $checks{$key}) {
- next unless $args{$key} =~ /^\d+$/;
- $checks{$key} = $args{$key};
+ next unless $args{$key} =~
/^(\d+)(,(DENY(SOFT)?(_DISCONNECT)?))?$/i;
+ $checks{$key} = $1;
+ $actions{$key} = Qpsmtpd::Constants::return_code(uc $3)
+ if $3;
+ ## $self->log(LOGDEBUG, "ACTION=$actions{$key} => $3") if $3;
}
elsif ($key eq "action") {
next unless $args{"action"} =~ /^DENY(SOFT)?(_DISCONNECT)?$/i;
- $self->{_action} = Qpsmtpd::Constants::return_code(uc
$args{"action"});
+ $self->{_def_action} =
+ Qpsmtpd::Constants::return_code(uc $args{"action"});
}
elsif ($key eq "defer-reject") {
$self->{_defer} = $args{"defer-reject"} ? 1 : 0;
}
}
- $self->{_checks} = \%checks;
+ $self->{_checks} = \%checks;
+ $self->{_actions} = \%actions;
if ($qp->{conn} && $qp->{conn}->isa('Apache2::Connection')) {
require APR::Const;
@@ -144,8 +156,8 @@
return (DECLINED, "remote host said nothing spontaneous at hook_$hook(),
proceeding")
unless ($rc);
- my $ip = $self->qp->connection->remote_ip;
-
+ my $ip = $self->qp->connection->remote_ip;
+ my $action = $self->{_actions}->{$hook} || $self->{_def_action};
$_ = $hook;
/^connect$/
and do {
@@ -154,20 +166,20 @@
$self->qp->connection->notes('earlytalker', 1);
return (DECLINED);
}
- return($self->{_action}, "Connecting host started transmitting before
SMTP greeting");
+ return($action, "Connecting host started transmitting before SMTP
greeting");
};
/^data$/
and $self->log(LOGNOTICE, "remote host [$ip] started with message before
we allowed to"),
- return($self->{_action}, "I wasn't ready to receive your message");
+ return($action, "I wasn't ready to receive your message");
/^noop$/
and $self->log(LOGNOTICE, "remote host [$ip] didn't wait after NOOP"),
- return($self->{_action}, "NOOP took longer than you expected?");
+ return($action, "NOOP took longer than you expected?");
/^vrfy$/
and $self->log(LOGNOTICE, "remote host [$ip] didn't wait for address
verification"),
- return($self->{_action}, "Not enough time to wait for verification of
recipient?");
+ return($action, "Not enough time to wait for verification of
recipient?");
return (DECLINED); # how did we get here?
}
@@ -182,9 +194,8 @@
my $self = shift;
return (DECLINED)
unless ($self->{_defer} and $self->qp->connection->notes('earlytalker'));
-
- return($self->{_action},
- "Connecting host started transmitting before SMTP greeting");
+ my $action = $self->{_actions}->{connect} || $self->{_def_action};
+ return($action, "Connecting host started transmitting before SMTP
greeting");
}
sub wait_apache {