diff --git a/config.sample/badrcptto_patterns b/config.sample/badrcptto_patterns new file mode 100644 index 0000000..e3bdca9 --- /dev/null +++ b/config.sample/badrcptto_patterns @@ -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 diff --git a/lib/Qpsmtpd/Plugin.pm b/lib/Qpsmtpd/Plugin.pm index d3200ff..48f3a43 100644 --- a/lib/Qpsmtpd/Plugin.pm +++ b/lib/Qpsmtpd/Plugin.pm @@ -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 ) diff --git a/plugins/check_spamhelo b/plugins/check_spamhelo index 2461460..fb90b72 100644 --- a/plugins/check_spamhelo +++ b/plugins/check_spamhelo @@ -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; diff --git a/plugins/logging/adaptive b/plugins/logging/adaptive index 4e57801..27d0eba 100644 --- a/plugins/logging/adaptive +++ b/plugins/logging/adaptive @@ -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;