[svn:qpsmtpd] r689 - in branches/0.3x: . lib/Qpsmtpd plugins plugins/virus
[email protected] Sat, 16 Dec 2006 03:56:49 -0800 (PST)
| Newsgroups | perl.cvs.qpsmtpd |
|---|---|
| Message-ID | <[email protected]> |
Author: vetinari
Date: Sat Dec 16 03:56:48 2006
New Revision: 689
Modified:
branches/0.3x/Changes
branches/0.3x/lib/Qpsmtpd/Transaction.pm
branches/0.3x/plugins/check_basicheaders
branches/0.3x/plugins/spamassassin
branches/0.3x/plugins/virus/bitdefender
branches/0.3x/plugins/virus/clamav
branches/0.3x/plugins/virus/clamdscan
branches/0.3x/plugins/virus/klez_filter
branches/0.3x/plugins/virus/sophie
branches/0.3x/plugins/virus/uvscan
Log:
Qpsmtpd::Transaction: add body_fh(), body_length() and data_size(),
depreceated body_size()
Modified: branches/0.3x/Changes
==============================================================================
--- branches/0.3x/Changes (original)
+++ branches/0.3x/Changes Sat Dec 16 03:56:48 2006
@@ -1,4 +1,8 @@
0.3x
+ The ill-named $transaction->body_size() is depreceated now, use
+ $transaction->data_size() instead. Check your logs for LOGWARN messages
+ about "body_size" and fix your plugins. (Hanno Hecker)
+
Instead of failing with cryptic message, ignore lines in config/plugins
for uninstalled plugins. (John Peacock)
Modified: branches/0.3x/lib/Qpsmtpd/Transaction.pm
==============================================================================
--- branches/0.3x/lib/Qpsmtpd/Transaction.pm (original)
+++ branches/0.3x/lib/Qpsmtpd/Transaction.pm Sat Dec 16 03:56:48 2006
@@ -141,10 +141,23 @@
}
}
-sub body_size {
+sub body_size { # depreceated, use data_size() instead
+ my $self = shift;
+ $self->log(LOGWARN, "WARNING: body_size() is depreceated, use data_size() instead");
+ $self->{_body_size} || 0;
+}
+
+sub data_size {
shift->{_body_size} || 0;
}
+sub body_length {
+ my $self = shift;
+ $self->{_body_size} or return 0;
+ $self->{_header_size} or return 0;
+ return $self->{_body_size} - $self->{_header_size};
+}
+
sub body_resetpos {
my $self = shift;
@@ -190,6 +203,10 @@
return $str;
}
+sub body_fh {
+ return shift->{_body_file};
+}
+
sub DESTROY {
my $self = shift;
# would we save some disk flushing if we unlinked the file before
@@ -294,6 +311,11 @@
Returns the temporary filename used to store the message contents; useful for
virus scanners so that an additional copy doesn't need to be made.
+Calling C<body_filename()> also forces spooling to disk. A message is not
+spooled to disk if it's size is smaller than
+I<$self-E<gt>config("size_threshold")>, default threshold is 0, the sample
+config file sets this to 10000.
+
=head2 body_write( $data )
Write data to the end of the email.
@@ -302,7 +324,26 @@
=head2 body_size( )
-Get the current size of the email.
+B<Depreceated>, Use I<data_size()> instead.
+
+=head2 data_size( )
+
+Get the current size of the email. Note that this is not the size of the
+message that will be queued, it is the size of what the client sent after
+the C<DATA> command. If you need the size that will be queued, use
+
+ my $msg_len = length($transaction->header->as_string)
+ + $transaction->body_length;
+
+The line above is of course only valid in I<hook_queue( )>, as other plugins
+may add headers and qpsmtpd will add it's I<Received:> header.
+
+=head2 body_length( )
+
+Get the current length of the body of the email. This length includes the
+empty line between the headers and the body. Until the client has sent
+some data of the body of the message (i.e. headers are finished and client
+sent the empty line) this will return 0.
=head2 body_resetpos( )
@@ -316,6 +357,12 @@
Returns a single line of data from the body of the email.
+=head2 body_fh( )
+
+Returns the file handle to the temporary file of the email. This will return
+undef if the file is not opened (yet). In I<hook_data( )> or later you can
+force spooling to disk by calling I<$transaction-E<gt>body_filename>.
+
=head1 SEE ALSO
L<Mail::Header>, L<Qpsmtpd::Address>, L<Qpsmtpd::Connection>
Modified: branches/0.3x/plugins/check_basicheaders
==============================================================================
--- branches/0.3x/plugins/check_basicheaders (original)
+++ branches/0.3x/plugins/check_basicheaders Sat Dec 16 03:56:48 2006
@@ -44,7 +44,7 @@
my ($self, $transaction) = @_;
return (DENY, "You have to send some data first")
- if $transaction->body_size == 0;
+ if $transaction->data_size == 0;
return (DENY, "Mail with no From header not accepted here")
unless $transaction->header->get('From');
Modified: branches/0.3x/plugins/spamassassin
==============================================================================
--- branches/0.3x/plugins/spamassassin (original)
+++ branches/0.3x/plugins/spamassassin Sat Dec 16 03:56:48 2006
@@ -96,7 +96,7 @@
my ($self, $transaction) = @_;
$self->log(LOGDEBUG, "check_spam");
- return (DECLINED) if $transaction->body_size > 500_000;
+ return (DECLINED) if $transaction->data_size > 500_000;
my $leave_old_headers = lc($self->{_args}->{leave_old_headers}) || 'rename';
Modified: branches/0.3x/plugins/virus/bitdefender
==============================================================================
--- branches/0.3x/plugins/virus/bitdefender (original)
+++ branches/0.3x/plugins/virus/bitdefender Sat Dec 16 03:56:48 2006
@@ -80,10 +80,10 @@
sub hook_data_post {
my ( $self, $transaction ) = @_;
- if ( $transaction->body_size > $self->{"_bitd"}->{"max_size"} ) {
+ if ( $transaction->data_size > $self->{"_bitd"}->{"max_size"} ) {
$self->log( LOGWARN,
'Mail too large to scan ('
- . $transaction->body_size . " vs "
+ . $transaction->data_size . " vs "
. $self->{"_bitd"}->{"max_size"}
. ")" );
return (DECLINED);
Modified: branches/0.3x/plugins/virus/clamav
==============================================================================
--- branches/0.3x/plugins/virus/clamav (original)
+++ branches/0.3x/plugins/virus/clamav Sat Dec 16 03:56:48 2006
@@ -164,9 +164,9 @@
sub hook_data_post {
my ($self, $transaction) = @_;
- if ($transaction->body_size > $self->{_max_size}) {
+ if ($transaction->data_size > $self->{_max_size}) {
$self->log(LOGWARN, 'Mail too large to scan ('.
- $transaction->body_size . " vs $self->{_max_size})" );
+ $transaction->data_size . " vs $self->{_max_size})" );
return (DECLINED);
}
Modified: branches/0.3x/plugins/virus/clamdscan
==============================================================================
--- branches/0.3x/plugins/virus/clamdscan (original)
+++ branches/0.3x/plugins/virus/clamdscan Sat Dec 16 03:56:48 2006
@@ -107,8 +107,8 @@
my ( $self, $transaction ) = @_;
$DB::single = 1;
- if ( $transaction->body_size > $self->{"_clamd"}->{"max_size"} * 1024 ) {
- $self->log( LOGNOTICE, "Declining due to body_size" );
+ if ( $transaction->data_size > $self->{"_clamd"}->{"max_size"} * 1024 ) {
+ $self->log( LOGNOTICE, "Declining due to data_size" );
return (DECLINED);
}
Modified: branches/0.3x/plugins/virus/klez_filter
==============================================================================
--- branches/0.3x/plugins/virus/klez_filter (original)
+++ branches/0.3x/plugins/virus/klez_filter Sat Dec 16 03:56:48 2006
@@ -4,9 +4,9 @@
# klez files are always sorta big .. how big? Dunno.
return (DECLINED)
- if $transaction->body_size < 60_000;
+ if $transaction->data_size < 60_000;
# 220k was too little, so let's just disable the "big size check"
- # or $transaction->body_size > 1_000_000;
+ # or $transaction->data_size > 1_000_000;
# maybe it would be worthwhile to add a check for
# Content-Type: multipart/alternative; here?
Modified: branches/0.3x/plugins/virus/sophie
==============================================================================
--- branches/0.3x/plugins/virus/sophie (original)
+++ branches/0.3x/plugins/virus/sophie Sat Dec 16 03:56:48 2006
@@ -16,8 +16,8 @@
my ( $self, $transaction ) = @_;
$DB::single = 1;
- if ( $transaction->body_size > $self->{"_sophie"}->{"max_size"} * 1024 ) {
- $self->log( LOGNOTICE, "Declining due to body_size" );
+ if ( $transaction->data_size > $self->{"_sophie"}->{"max_size"} * 1024 ) {
+ $self->log( LOGNOTICE, "Declining due to data_size" );
return (DECLINED);
}
Modified: branches/0.3x/plugins/virus/uvscan
==============================================================================
--- branches/0.3x/plugins/virus/uvscan (original)
+++ branches/0.3x/plugins/virus/uvscan Sat Dec 16 03:56:48 2006
@@ -55,7 +55,7 @@
my ($self, $transaction) = @_;
return (DECLINED)
- if $transaction->body_size > 250_000;
+ if $transaction->data_size > 250_000;
# Ignore non-multipart emails
my $content_type = $transaction->header->get('Content-Type');