From f82dffe5ce638930a29ed5b36a717740a8ab686a Mon Sep 17 00:00:00 2001 From: John Peacock Date: Tue, 1 Mar 2005 14:31:25 +0000 Subject: [PATCH] * lib/Qpsmtpd/SMTP.pm Copy all lines of incoming message to spool file and keep track of where the body lines started (ease use of inplace scanning for viruses). * lib/Qpsmtpd/Transaction.pm New function body_start() to get/set the body in spool file Tweak body_resetpos() and body_getline() to use body_start instead of 0 git-svn-id: https://svn.perl.org/qpsmtpd/trunk@375 958fd67b-6ff1-0310-b445-bb7760255be9 --- lib/Qpsmtpd/SMTP.pm | 10 +++++++--- lib/Qpsmtpd/Transaction.pm | 12 ++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/Qpsmtpd/SMTP.pm b/lib/Qpsmtpd/SMTP.pm index d7f1b95..b52564f 100644 --- a/lib/Qpsmtpd/SMTP.pm +++ b/lib/Qpsmtpd/SMTP.pm @@ -471,15 +471,19 @@ sub data { # FIXME - call plugins to work on just the header here; can # save us buffering the mail content. + # Save the start of just the body itself + $self->transaction->body_start($size); + } + # grab a copy of all of the header lines if ($in_header) { $buffer .= $_; } - else { - $self->transaction->body_write($_); - } + # copy all lines into the spool file, including the headers + # we will create a new header later before sending onwards + $self->transaction->body_write($_); $size += length $_; } #$self->log(LOGDEBUG, "size is at $size\n") unless ($i % 300); diff --git a/lib/Qpsmtpd/Transaction.pm b/lib/Qpsmtpd/Transaction.pm index 4663e54..74afeba 100644 --- a/lib/Qpsmtpd/Transaction.pm +++ b/lib/Qpsmtpd/Transaction.pm @@ -57,6 +57,12 @@ sub notes { $self->{_notes}->{$key}; } +sub body_start { + my $self = shift; + @_ and $self->{_body_start} = shift; + $self->{_body_start}; +} + sub body_filename { my $self = shift; return unless $self->{_body_file}; @@ -86,7 +92,8 @@ sub body_size { sub body_resetpos { my $self = shift; return unless $self->{_body_file}; - seek($self->{_body_file}, 0,0); + my $start = $self->{_body_start} || 0; + seek($self->{_body_file}, $start, 0); $self->{_body_file_writing} = 0; 1; } @@ -94,7 +101,8 @@ sub body_resetpos { sub body_getline { my $self = shift; return unless $self->{_body_file}; - seek($self->{_body_file}, 0,0) + my $start = $self->{_body_start} || 0; + seek($self->{_body_file}, $start,0) if $self->{_body_file_writing}; $self->{_body_file_writing} = 0; my $line = $self->{_body_file}->getline;