These changes to trunk were missed when 0.31 was branched.
r588@jpeacock (orig r490): jpeacock | 2005-07-09 07:03:53 -0400 r547@jpeacock: jpeacock | 2005-07-02 07:20:17 -0400 Replace pithy comment with something more neutral. Thanks Gordon Rowell <gordonr@gormand.com.au> r548@jpeacock: jpeacock | 2005-07-02 07:24:21 -0400 Example patterns for badrcptto plugin - Gordon Rowell <gordonr@gormand.com.au> r586@jpeacock: jpeacock | 2005-07-09 06:54:47 -0400 Don't use varlog() directly unless you are passing all parameters. Don't try to log() anything during loading of logging plugins. r587@jpeacock: jpeacock | 2005-07-09 06:59:57 -0400 Cannot use new-style hooking with logging plugins (yet). r590@jpeacock (orig r491): jpeacock | 2005-07-10 06:56:55 -0400 r589@jpeacock: jpeacock | 2005-07-10 06:54:32 -0400 Track hooks as array and hash. Re-revert changes to logging plugins to use new-style hooking. logging/adaptive assumed that register() has been called before hook_logging. git-svn-id: https://svn.perl.org/qpsmtpd/branches/0.31@503 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
f0b31cbb9b
commit
35f45f208b
5
config.sample/badrcptto_patterns
Normal file
5
config.sample/badrcptto_patterns
Normal file
@ -0,0 +1,5 @@
|
||||
# Format is pattern\s+Response
|
||||
# Don't forget to anchor the pattern if required
|
||||
! Sorry, bang paths not accepted here
|
||||
@.*@ Sorry, multiple at signs not accepted here
|
||||
% Sorry, percent hack not accepted here
|
@ -2,12 +2,13 @@ package Qpsmtpd::Plugin;
|
||||
use Qpsmtpd::Constants;
|
||||
use strict;
|
||||
|
||||
our %hooks = map { $_ => 1 } qw(
|
||||
config queue data data_post quit rcpt mail ehlo helo
|
||||
our @hooks = qw(
|
||||
logging config queue data data_post quit rcpt mail ehlo helo
|
||||
auth auth-plain auth-login auth-cram-md5
|
||||
connect reset_transaction unrecognized_command disconnect
|
||||
deny logging ok pre-connection post-connection
|
||||
deny ok pre-connection post-connection
|
||||
);
|
||||
our %hooks = map { $_ => 1 } @hooks;
|
||||
|
||||
sub new {
|
||||
my $proto = shift;
|
||||
@ -20,7 +21,8 @@ sub register_hook {
|
||||
|
||||
die $plugin->plugin_name . " : Invalid hook: $hook" unless $hooks{$hook};
|
||||
|
||||
$plugin->{_qp}->varlog(LOGDEBUG, $plugin->plugin_name, " hooking ", $hook);
|
||||
$plugin->{_qp}->log(LOGDEBUG, $plugin->plugin_name, "hooking", $hook)
|
||||
unless $hook =~ /logging/; # can't log during load_logging()
|
||||
|
||||
# I can't quite decide if it's better to parse this code ref or if
|
||||
# we should pass the plugin object and method name ... hmn.
|
||||
@ -154,7 +156,7 @@ sub compile {
|
||||
sub _register_standard_hooks {
|
||||
my ($plugin, $qp) = @_;
|
||||
|
||||
for my $hook (keys %hooks) {
|
||||
for my $hook (@hooks) {
|
||||
my $hooksub = "hook_$hook";
|
||||
$hooksub =~ s/\W/_/g;
|
||||
$plugin->register_hook( $hook, $hooksub )
|
||||
|
@ -23,7 +23,7 @@ sub hook_helo {
|
||||
for my $bad ($self->qp->config('badhelo')) {
|
||||
if ($host eq lc $bad) {
|
||||
$self->log(LOGDEBUG, "Denying HELO from host claiming to be $bad");
|
||||
return (DENY, "Uh-huh. You're $host, and I'm a boil on the bottom of the Marquess of Queensbury's great-aunt.");
|
||||
return (DENY, "Sorry, I don't believe that you are $host.");
|
||||
}
|
||||
}
|
||||
return DECLINED;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/perl
|
||||
#!perl
|
||||
# Adaptive logging plugin - logs at one level for successful messages and
|
||||
# one level for DENY'd messages
|
||||
|
||||
@ -43,7 +43,7 @@ sub hook_logging { # wlog
|
||||
# out this line and it will not cause an infinite loop.
|
||||
return DECLINED if defined $plugin and $plugin eq $self->plugin_name;
|
||||
|
||||
if ( $trace <= $self->{_maxlevel} ) {
|
||||
if ( defined $self->{_maxlevel} && $trace <= $self->{_maxlevel} ) {
|
||||
warn join(
|
||||
" ", $$.
|
||||
(
|
||||
@ -56,7 +56,7 @@ sub hook_logging { # wlog
|
||||
"\n"
|
||||
unless $log[0] =~ /logging::adaptive/;
|
||||
push @{ $transaction->{_log} }, [ $trace, $hook, $plugin, @log ]
|
||||
if ( $trace <= $self->{_minlevel} );
|
||||
if ( defined $self->{_minlevel} && $trace <= $self->{_minlevel} );
|
||||
}
|
||||
|
||||
return DECLINED;
|
||||
|
Loading…
Reference in New Issue
Block a user