From 01d7c7e228948b8e67716cc907738bcd1a5e27af Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Sat, 30 Jun 2012 15:37:25 -0400 Subject: [PATCH] karma: added adjust_karma method makes it easier to set karma in plugins --- lib/Qpsmtpd/Plugin.pm | 2 +- plugins/qmail_deliverable | 10 +++++----- plugins/spamassassin | 2 +- plugins/whitelist | 7 ------- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/Qpsmtpd/Plugin.pm b/lib/Qpsmtpd/Plugin.pm index 3bb4b73..3086c20 100644 --- a/lib/Qpsmtpd/Plugin.pm +++ b/lib/Qpsmtpd/Plugin.pm @@ -285,7 +285,7 @@ sub is_immune { sub adjust_karma { my ( $self, $value ) = @_; - my $karma = $self->connection->notes('karma') || 0; + my $karma = $self->connection->notes('karma') || 0 $karma += $value; $self->connection->notes('karma', $value); return $value; diff --git a/plugins/qmail_deliverable b/plugins/qmail_deliverable index e4e0263..7543a4b 100755 --- a/plugins/qmail_deliverable +++ b/plugins/qmail_deliverable @@ -195,12 +195,12 @@ sub rcpt_handler { $self->log(LOGINFO, "error, SHOULD NOT HAPPEN"), $k++ if $rv == 0xfe; $self->log(LOGINFO, "fail, address not local"), $k++ if $rv == 0xff; - if ( $rv ) { - $self->log(LOGINFO, sprintf("error, unknown: 0x%02x", $rv)) if not $k; - return DECLINED; - }; + $self->log(LOGINFO, sprintf("Unknown: 0x%02x", $rv)) if $rv and not $k; - return (DENY, "Sorry, no mailbox by that name. qd (#5.1.1)" ); + return DECLINED if $rv; + + $self->adjust_karma( -1 ); + return (DENY, "fail, no mailbox by that name. qd (#5.1.1)" ); } sub _smtproute { diff --git a/plugins/spamassassin b/plugins/spamassassin index 23681b0..d3b9710 100644 --- a/plugins/spamassassin +++ b/plugins/spamassassin @@ -413,7 +413,7 @@ sub reject { } } - $self->connection->notes('karma', ($self->connection->notes('karma') - 1)); + $self->adjust_karma( -1 ); # default of media_unsupported is DENY, so just change the message $self->log(LOGINFO, "fail, $status, > $reject, $learn"); return ($self->get_reject_type(), "spam score exceeded threshold"); diff --git a/plugins/whitelist b/plugins/whitelist index 43aace4..2e0ccb7 100644 --- a/plugins/whitelist +++ b/plugins/whitelist @@ -94,12 +94,6 @@ automatically allow relaying from that IP. =cut -use strict; -use warnings; - -use lib 'lib'; -use Qpsmtpd::Constants; - my $VERSION = 0.02; # Default is to merge whitelists in per_recipient mode @@ -150,7 +144,6 @@ sub check_host { return OK; } } - $self->log(LOGDEBUG, "skip: $ip is not whitelisted"); return DECLINED; }