From 2ee95fc3fc14029d62db407638d0b6636d621b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Tue, 6 Aug 2002 12:57:59 +0000 Subject: [PATCH] only send messages smaller than 500000 bytes to spamd git-svn-id: https://svn.perl.org/qpsmtpd/branches/v010@42 958fd67b-6ff1-0310-b445-bb7760255be9 --- .cvsignore | 1 + lib/Qpsmtpd/Transaction.pm | 8 ++++++-- log/.cvsignore | 1 + plugins/spamassassin | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.cvsignore b/.cvsignore index 23e60ef..7ab5a7f 100644 --- a/.cvsignore +++ b/.cvsignore @@ -1 +1,2 @@ supervise +tmp diff --git a/lib/Qpsmtpd/Transaction.pm b/lib/Qpsmtpd/Transaction.pm index a05453c..0ce8db9 100644 --- a/lib/Qpsmtpd/Transaction.pm +++ b/lib/Qpsmtpd/Transaction.pm @@ -65,7 +65,6 @@ sub add_header_line { sub body_write { my $self = shift; my $data = shift; - #$self->{_body} .= shift; unless ($self->{_body_file}) { -d "tmp" or mkdir("tmp", 0700) or die "Could not create dir tmp: $!"; $self->{_filename} = "/home/smtpd/qpsmtpd/tmp/" . join(":", time, $$, $transaction_counter++); @@ -76,7 +75,12 @@ sub body_write { seek($self->{_body_file},0,2) unless $self->{_body_file_writing}; $self->{_body_file_writing} = 1; - $self->{_body_file}->print(ref $data eq "SCALAR" ? $$data : $data); + $self->{_body_file}->print(ref $data eq "SCALAR" ? $$data : $data) + and $self->{_body_size} += length (ref $data eq "SCALAR" ? $$data : $data); +} + +sub body_size { + shift->{_body_size} || 0; } sub body_resetpos { diff --git a/log/.cvsignore b/log/.cvsignore index 23e60ef..f27c43f 100644 --- a/log/.cvsignore +++ b/log/.cvsignore @@ -1 +1,2 @@ +main supervise diff --git a/plugins/spamassassin b/plugins/spamassassin index 39329ab..0034f45 100644 --- a/plugins/spamassassin +++ b/plugins/spamassassin @@ -23,6 +23,8 @@ sub register { sub check_spam { my ($self, $transaction) = @_; + return (DECLINED) if $transaction->body_size > 500_000; + my $remote = 'localhost'; my $port = 783; if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }