List Info

Thread: X-Spam-Languages header (patch)




X-Spam-Languages header (patch)
country flaguser name
Hungary
2008-01-03 12:31:43
Hello,

I've always been frustrated about amavisd not setting the 
X-Spam-Languages header (while it -by default- loads the
TextCat 
SpamAssassin plugin, so the information is there and it take
some CPU 
time to figure it out), but now I actually need it, so made
the 
following patch to the latest (from FreeBSD ports) amavisd.

By default amavisd now includes the X-Spam-Languages header.
If backward 
compatibility is required, X-Spam-Languages should not be
added in the 
allowed_added_header_fields hash, so this produces the
current output 
with the possibility to include the header if needed.

Mark, do you think it's OK to include it in the mainline?

Thanks,

--- amavisd.orig        2008-01-03 18:22:38.000000000 +0100
+++ amavisd     2008-01-03 19:24:29.000000000 +0100
 -825,7
+825,7 
     Received X-Quarantine-ID X-Amavis-Alert X-Amavis-Hold
X-Amavis-Modified
     X-Amavis-PenPals X-Amavis-OS-Fingerprint
X-Amavis-PolicyBank
     X-Spam-Status X-Spam-Level X-Spam-Flag X-Spam-Score
-    X-Spam-Report X-Spam-Checker-Version X-Spam-Tests
+    X-Spam-Report X-Spam-Checker-Version X-Spam-Tests
X-Spam-Languages
     X-DSPAM-Signature X-DSPAM-Result
     X-DSPAM-Confidence X-DSPAM-Probability X-DSPAM-User
X-DSPAM-Factors
   );
 -9760,7
+9760,7 
   if ($extra_code_antispam) {
     if (c('remove_existing_spam_headers')) {
       my(which_headers) = qw(
-          X-Spam-Status X-Spam-Level X-Spam-Flag
X-Spam-Score
+          X-Spam-Status X-Spam-Level X-Spam-Flag
X-Spam-Score 
X-Spam-Languages
           X-Spam-Report X-Spam-Checker-Version
X-Spam-Tests);
       push(which_headers, qw(
           X-DSPAM-Result X-DSPAM-Confidence
X-DSPAM-Probability
 -18159,6
+18159,7 
   my($which_section); my(lines);
   
my($spam_level,$sa_tests,$spam_report,$spam_summary,$supplem
entary_info_ref);
   my($fh) = $msginfo->mail_text;
+  my($allowed_hdrs) = cr('allowed_added_header_fields');
   my($hdr_edits) = $msginfo->header_edits;
   if (!$hdr_edits) {
     $hdr_edits = Amavis::Out::EditHeader->new;
 -18206,7
+18207,6 
       # keep X-DSPAM-*, ignore other changes e.g.
Content-Transfer-Encoding
       my($all_local) = !grep {!$_->recip_is_local} 
{$msginfo->per_recip_data};
       my($first_line); my($ln);
-      my($allowed_hdrs) =
cr('allowed_added_header_fields');
       # scan mail header from DSPAM
       for ($! = 0; defined($ln=$proc_fh->getline); $! =
0) {
         $dspam_fh->print($ln) or die "Can't write
to $dspam_fname: $!";
 -18296,6
+18296,10 
   #
$hdr_edits->add_header('X-Relay-Countries',$rly_country)
   #   if $rly_country ne '' && $all_local
&&
   #      $allowed_hdrs &&
$allowed_hdrs->{lc('X-Relay-Countries')};
+    
$hdr_edits->add_header('X-Spam-Languages',$supplementary_
info_ref->{'LANGUAGES'})
+      if ($supplementary_info_ref->{'LANGUAGES'} ne ''
&& $allowed_hdrs &&
+        $allowed_hdrs->{lc('X-Spam-Languages')});
+
     if (defined $dspam && $dspam ne '' &&
defined $spam_level) {  # 
auto-learn
       $which_section = 'DSPAM learn';
       my($eat,options);


-- 
Attila Nagy                                   e-mail:
Attila.Nagyfsn.hu
Free Software Network (FSN.HU)                 phone: +3630
306 6758
http://www.fsn.hu/


------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
AMaViS-user mailing list
AMaViS-userlists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user

AMaViS-FAQ:http://www.amav
is.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/ho
wto/

Re: X-Spam-Languages header (patch)
country flaguser name
Slovenia
2008-03-14 09:49:29
Attila,

> I've always been frustrated about amavisd not setting
the
> X-Spam-Languages header (while it -by default- loads
the TextCat
> SpamAssassin plugin, so the information is there and it
take some CPU
> time to figure it out), but now I actually need it, so
made the
> following patch to the latest (from FreeBSD ports)
amavisd.
>
> By default amavisd now includes the X-Spam-Languages
header. If backward
> compatibility is required, X-Spam-Languages should not
be added in the
> allowed_added_header_fields hash, so this produces the
current output
> with the possibility to include the header if needed.
>
> Mark, do you think it's OK to include it in the
mainline?

Well, you need X-Spam-Languages, somebody else needs
X-Relay-Countries,
still others might need X-Spam-ASN, AWL information, etc.
So where should it stop?

I think the custom hooks (i.e. code supplied in
amavisd.conf) provides
a sufficient and not too complicated mechanism to cater for
such needs:

Assuming amavisd-new-2.5.4 (or 2.6.0-*), place the
following
into amavisd.conf:
  include_config_files('/etc/amavisd-custom.conf');


The /etc/amavisd-custom.conf could then look like:


package Amavis::Custom;
use strict;

sub new {
  my($class,$conn,$msginfo) = _;
  bless {}, $class;
}

sub before_send {
  my($self,$conn,$msginfo) = _;
  my($all_local) = !grep { !$_->recip_is_local } {$msginfo->per_recip_data};
  if ($all_local) {
    my($hdr_edits) = $msginfo->header_edits;
    my($rly_country) =
$msginfo->supplementary_info('RELAYCOUNTRY');
    $hdr_edits->add_header('X-Relay-Countries',
$rly_country)
      if defined $rly_country && $rly_country ne
'';
    my($languages) =
$msginfo->supplementary_info('LANGUAGES');
    $hdr_edits->add_header('X-Spam-Languages',
$languages)
      if defined $languages && $languages ne '';
  }
};

1;  # insure a defined return



Sorry for a late  reply.
  Mark

------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
AMaViS-user mailing list
AMaViS-userlists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user

AMaViS-FAQ:http://www.amav
is.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/ho
wto/

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )