- dnsbl, count_unrec_commands, spamassassin:

use symbolic log levels, instead of numeric
- dnsbl:  set some (probably too large) timeouts
- count_unrec_commands: DENYHARD
- spamassassin: upgrade protocol to support switching users


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@349 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Robert Spier 2004-11-27 07:02:23 +00:00
parent 0a2fc866de
commit 012c6db2d3
3 changed files with 18 additions and 11 deletions

View File

@ -41,7 +41,7 @@ sub check_unrec_cmd {
if ($badcmdcount >= $self->{_unrec_cmd_max}) { if ($badcmdcount >= $self->{_unrec_cmd_max}) {
$self->log(LOGINFO, "Closing connection. Too many unrecognized commands."); $self->log(LOGINFO, "Closing connection. Too many unrecognized commands.");
return (DENY, "Closing connection. $badcmdcount unrecognized commands. Perhaps you should read RFC 2821?"); return (DENYHARD, "Closing connection. $badcmdcount unrecognized commands. Perhaps you should read RFC 2821?");
} }
return DECLINED; return DECLINED;

View File

@ -35,6 +35,9 @@ sub connect_handler {
# results in the first rcpt handler ... oh well. # results in the first rcpt handler ... oh well.
my $res = new Net::DNS::Resolver; my $res = new Net::DNS::Resolver;
$res->tcp_timeout(30);
$res->udp_timeout(30);
my $sel = IO::Select->new(); my $sel = IO::Select->new();
for my $dnsbl (keys %dnsbl_zones) { for my $dnsbl (keys %dnsbl_zones) {

View File

@ -94,7 +94,7 @@ sub register {
sub check_spam { sub check_spam {
my ($self, $transaction) = @_; my ($self, $transaction) = @_;
$self->log(6, "check_spam"); $self->log(LOGDEBUG, "check_spam");
return (DECLINED) if $transaction->body_size > 500_000; return (DECLINED) if $transaction->body_size > 500_000;
my $leave_old_headers = lc($self->{_args}->{leave_old_headers}) || 'rename'; my $leave_old_headers = lc($self->{_args}->{leave_old_headers}) || 'rename';
@ -129,8 +129,12 @@ sub check_spam {
SPAMD->autoflush(1); SPAMD->autoflush(1);
$transaction->body_resetpos; $transaction->body_resetpos;
my $username = getpwuid($>);
print SPAMD "SYMBOLS SPAMC/1.0" . CRLF; print SPAMD "SYMBOLS SPAMC/1.3" . CRLF;
print SPAMD "User: $username" . CRLF;
# Content-Length:
print SPAMD CRLF;
# or CHECK or REPORT or SYMBOLS # or CHECK or REPORT or SYMBOLS
print SPAMD "X-Envelope-From: ", $transaction->sender->format, CRLF print SPAMD "X-Envelope-From: ", $transaction->sender->format, CRLF
@ -150,10 +154,10 @@ sub check_spam {
print SPAMD CRLF; print SPAMD CRLF;
shutdown(SPAMD, 1); shutdown(SPAMD, 1);
$self->log(6, "check_spam: finished sending to spamd"); $self->log(LOGDEBUG, "check_spam: finished sending to spamd");
my $line0 = <SPAMD>; # get the first protocol lines out my $line0 = <SPAMD>; # get the first protocol lines out
if ($line0) { if ($line0) {
$self->log(6, "check_spam: spamd: $line0"); $self->log(LOGDEBUG, "check_spam: spamd: $line0");
if ( $leave_old_headers eq 'rename' ) if ( $leave_old_headers eq 'rename' )
{ {
@ -173,7 +177,7 @@ sub check_spam {
my ($flag, $hits, $required); my ($flag, $hits, $required);
while (<SPAMD>) { while (<SPAMD>) {
$self->log(6, "check_spam: spamd: $_"); $self->log(LOGDEBUG, "check_spam: spamd: $_");
#warn "GOT FROM SPAMD1: $_"; #warn "GOT FROM SPAMD1: $_";
last unless m/\S/; last unless m/\S/;
if (m{Spam: (True|False) ; (-?\d+\.\d) / (-?\d+\.\d)}) { if (m{Spam: (True|False) ; (-?\d+\.\d) / (-?\d+\.\d)}) {
@ -184,7 +188,7 @@ sub check_spam {
my $tests = <SPAMD>; my $tests = <SPAMD>;
$tests =~ s/\015//; # hack for outlook $tests =~ s/\015//; # hack for outlook
$flag = $flag eq 'True' ? 'Yes' : 'No'; $flag = $flag eq 'True' ? 'Yes' : 'No';
$self->log(6, "check_spam: finished reading from spamd"); $self->log(LOGDEBUG, "check_spam: finished reading from spamd");
if ( $leave_old_headers eq 'rename' ) if ( $leave_old_headers eq 'rename' )
{ {
@ -218,14 +222,14 @@ sub check_spam {
sub check_spam_reject { sub check_spam_reject {
my ($self, $transaction) = @_; my ($self, $transaction) = @_;
$self->log(6, "check_spam_reject: reject_threshold=" . $self->{_args}->{reject_threshold}); $self->log(LOGDEBUG, "check_spam_reject: reject_threshold=" . $self->{_args}->{reject_threshold});
my $score = $self->get_spam_score($transaction) or return DECLINED; my $score = $self->get_spam_score($transaction) or return DECLINED;
$self->log(6, "check_spam_reject: score=$score"); $self->log(LOGDEBUG, "check_spam_reject: score=$score");
return (DENY, "spam score exceeded threshold") return (DENY, "spam score exceeded threshold")
if $score >= $self->{_args}->{reject_threshold}; if $score >= $self->{_args}->{reject_threshold};
$self->log(6, "check_spam_reject: passed"); $self->log(LOGDEBUG, "check_spam_reject: passed");
return DECLINED; return DECLINED;
} }