On Sat, 28 Aug 2004, Mark Powell wrote:

>   Your technique below is even more efficient (and logical) as we don't
> even bother running spamc when we already know the results we'll get. I
> think that is how 1.24 should handle the spam checking. Currently 1.23 is
> broken.

Attached is a patch to fix this problem. You also need to put the
following two lines near the start of QS.pl, but that meant me patching
configure etc. and I'm bone idle, so I just edited mine directly :)

my $SAlimit = 250 * 1024;               # This is the default that spamc uses in SA 
v2.64 & v3.0.0rc1
my $spamc_options=" -c -s $SAlimit ";

Not heavily tested, but you get the idea. It means that in
verbose_spamassassin mode, the X-Envelope-From: header will only appear in
emails that are less than SAlimit in size, but fast_spamassassin mode
never gets that header anyway and the envelope sender is already in placed
into the QS Received line.
  Making the limit configurable and clear to people might also make it
easier for them to understand why some messages are not being spam
checked.
  I still believe that the old method of having spamc read the file
directly was much more efficient, but I guess you changed it to provide
the X-Envelope-From: functionality, Jason?
  Cheers.

-- 
Mark Powell - UNIX System Administrator - The University of Salford
Information Services Division, Clifford Whitworth Building,
Salford University, Manchester, M5 4WT, UK.
Tel: +44 161 295 4837  Fax: +44 161 295 5888  www.pgp.com for PGP key
--- /root/src/qmail/spam/qmail-scanner-1.23/sub-spamassassin.pl Thu Jul 22 23:06:35 
2004
+++ sub-spamassassin.pl Sat Aug 28 16:30:31 2004
@@ -5,10 +5,20 @@
     &debug("spamassassin: don't scan as RELAYCLIENT implies this was sent by a local 
user");
     return;
   }
+
+  my $env_from_header = "X-Envelope-From: $headers{'MAILFROM'}\n";
+  my $sa_fast=1 if ($spamc_options =~ / \-c /);
+  if ((-s "$scandir/$wmaildir/new/$file_id") + length $env_from_header > $SAlimit) {
+    &debug("SA: $scandir/$wmaildir/new/$file_id would exceed configured 
SAlimit=$SAlimit...skipping SA check.");
+    $tag_score .= "SA:0(?/?):";
+    $sa_comment = "No, hits=? required=?" if ($sa_fast);
+    return;
+  }
+
   #SpamAssassin client scanner
   my ($spamassassin_found,$spamassassin_status);
   my ($start_spamassassin_time)=[gettimeofday];
-  my 
($sa_tag,$DD,$spamassassin_status,$stop_spamassassin_time,$spamassassin_time,$cmdline_recip,$sa_fast);
+  my 
($sa_tag,$DD,$spamassassin_status,$stop_spamassassin_time,$spamassassin_time,$cmdline_recip);
   my ($sa_status)=0;
   my ($sa_score)=0; my ($sa_max)=0;
 
@@ -24,7 +34,7 @@
   open(SIN,"<$scandir/$wmaildir/new/$file_id")||&error_condition("cannot open 
$scandir/$wmaildir/new/$file_id - $!");
   open(SOUT,"|$spamc_binary $spamc_options > 
$scandir/$wmaildir/new/$file_id.spamc")||&error_condition("cannot open for write 
$scandir/$wmaildir/new/$file_id.spamc - $!");
 
-  print SOUT "X-Envelope-From: $headers{'MAILFROM'}\n";
+  print SOUT "$env_from_header";
   while (<SIN>) {
     print SOUT;
   }

Reply via email to