cvs commit: qpsmtpd/plugins spamassassin

[email protected] (John Peacock)
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
cvsuser     04/10/12 18:52:35

  Modified:    plugins  spamassassin
  Log:
  plugins/spamassassin
      New option to strip/rename/keep old X-Spam headers (Michael Holzt)
  
  Revision  Changes    Path
  1.14      +43 -0     qpsmtpd/plugins/spamassassin
  
  Index: spamassassin
  ===================================================================
  RCS file: /cvs/public/qpsmtpd/plugins/spamassassin,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -w -r1.13 -r1.14
  --- spamassassin	24 Sep 2004 17:29:56 -0000	1.13
  +++ spamassassin	13 Oct 2004 01:52:35 -0000	1.14
  @@ -50,6 +50,14 @@
   domain sockets for spamd.  This is faster and more secure than using
   a TCP connection.
   
  +=item leave_old_headers [drop|rename|keep]
  +
  +Another mail server before might have checked this mail already and may have
  +added X-Spam-Status, X-Spam-Flag and X-Spam-Check-By lines. Normally you can
  +not trust such headers and should either rename them to X-Old-... (default,
  +parameter 'rename') or have them removed (parameter 'drop'). If you know
  +what you are doing, you can also leave them intact (parameter 'keep').
  +
   =back
   
   With both of the first options the configuration line will look like the following
  @@ -89,6 +97,8 @@
     $self->log(6, "check_spam");
     return (DECLINED) if $transaction->body_size > 500_000;
   
  +  my $leave_old_headers = lc($self->{_args}->{leave_old_headers}) || 'rename';
  +
     my $remote  = 'localhost';
     my $port    = 783;
     if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
  @@ -144,6 +154,20 @@
     my $line0 = <SPAMD>; # get the first protocol lines out
     if ($line0) {
       $self->log(6, "check_spam: spamd: $line0");
  +
  +    if ( $leave_old_headers eq 'rename' )
  +    {
  +      foreach my $header ( $transaction->header->get('X-Spam-Check-By') )
  +      {
  +        $transaction->header->add('X-Old-Spam-Check-By', $header);
  +      }
  +    }
  +    
  +    if ( $leave_old_headers eq 'drop' || $leave_old_headers eq 'rename' )
  +    {
  +      $transaction->header->delete('X-Spam-Check-By');
  +    }
  +
       $transaction->header->add("X-Spam-Check-By", $self->qp->config('me'), 0);
     }
   
  @@ -162,6 +186,25 @@
     $flag = $flag eq 'True' ? 'Yes' : 'No';
     $self->log(6, "check_spam: finished reading from spamd");
   
  +  if ( $leave_old_headers eq 'rename' )
  +  {
  +    foreach my $header ( $transaction->header->get('X-Spam-Flag') )
  +    {
  +      $transaction->header->add('X-Old-Spam-Flag', $header);
  +    }
  +
  +    foreach my $header ( $transaction->header->get('X-Spam-Status') )
  +    {
  +      $transaction->header->add('X-Old-Spam-Status', $header);
  +    }
  +  }
  +    
  +  if ( $leave_old_headers eq 'drop' || $leave_old_headers eq 'rename' )
  +  {
  +    $transaction->header->delete('X-Spam-Flag');
  +    $transaction->header->delete('X-Spam-Status');
  +  }
  +
     $transaction->header->add('X-Spam-Flag', 'YES', 0) if ($flag eq 'Yes');
     $transaction->header->add('X-Spam-Status',
   			    "$flag, hits=$hits required=$required\n" .
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.