[svn:qpsmtpd] rev 503 - in branches/0.31: config.sample lib/Qpsmtpd plugins plugins/logging
[email protected] 14 Jul 2005 02:31:01 -0000
| Newsgroups | perl.cvs.qpsmtpd |
|---|---|
| Message-ID | <[email protected]> |
Author: jpeacock Date: Wed Jul 13 19:31:01 2005 New Revision: 503 Added: branches/0.31/config.sample/badrcptto_patterns Modified: branches/0.31/lib/Qpsmtpd/Plugin.pm branches/0.31/plugins/check_spamhelo branches/0.31/plugins/logging/adaptive Log: 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 <[email protected]> r548@jpeacock: jpeacock | 2005-07-02 07:24:21 -0400 Example patterns for badrcptto plugin - Gordon Rowell <[email protected]> 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. Added: branches/0.31/config.sample/badrcptto_patterns ============================================================================== --- (empty file) +++ branches/0.31/config.sample/badrcptto_patterns Wed Jul 13 19:31:01 2005 @@ -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 Modified: branches/0.31/lib/Qpsmtpd/Plugin.pm ============================================================================== --- branches/0.31/lib/Qpsmtpd/Plugin.pm (original) +++ branches/0.31/lib/Qpsmtpd/Plugin.pm Wed Jul 13 19:31:01 2005 @@ -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 ) Modified: branches/0.31/plugins/check_spamhelo ============================================================================== --- branches/0.31/plugins/check_spamhelo (original) +++ branches/0.31/plugins/check_spamhelo Wed Jul 13 19:31:01 2005 @@ -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; Modified: branches/0.31/plugins/logging/adaptive ============================================================================== --- branches/0.31/plugins/logging/adaptive (original) +++ branches/0.31/plugins/logging/adaptive Wed Jul 13 19:31:01 2005 @@ -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;