Bug 4644

Summary: remove_header and SQL prefs serialization issue
Product: Spamassassin Reporter: Dallas Engelken <dallas>
Component: spamassassinAssignee: SpamAssassin Developer Mailing List <dev>
Status: NEW ---    
Severity: minor    
Priority: P3    
Version: 3.1.0   
Target Milestone: Undefined   
Hardware: All   
OS: All   
Whiteboard:

Description Dallas Engelken 2005-10-21 18:32:33 UTC
ok here we go...  report_safe 0 forces X-Spam-Report: to be added to the spam
headers via this code here in Conf.pm

      if (! $self->{report_safe}) {
        $self->{headers_spam}->{"Report"} = "_REPORT_";
      }

Now, if I want to run report_safe 0 and remove the 'Report' header, the man says
to use 

remove_header all Report

So.. if I do this via local.cf, I use 

clear_headers
add_header all Level _STARS(*)_
add_header all Score _HITS_
add_header all Flag _YESNO_
remove_header all Report

That should do the trick!  Problem is, spamd is also using -q to pull SQL
prefs... and 'report_safe' is one of the sql prefs it reads.  As soon as
report_safe gets read via SQL and its set to 0,     
$self->{headers_spam}->{"Report"} gets re-added.

So, you'd think the fix would be to have a 'remove_header all Report' loaded via
SQL...  but, if your prefs are pulled alphabetically, remove_header <
report_safe, so report_safe gets applied after the sql pref remove_header.... 
catch 22.  

Since there is no way to prioritize SQL prefs currently, my suggestion is a
different way of handling remove_header prefs.  I think they should be stored in
an array in M::SA so they can then all be applied in one fell swoop in
M::SA::PMS.  The only other way around this would be prioritization of rules via
SQL, which i think would be alot more work.

here is a quick debug of the situation as M::SA::PMS reads a new message through
and the SQL prefs are pulled...

[5834] dbg: config: Conf::SQL: executing SQL: SELECT preference, value FROM
sa_rules WHERE username = 'user@domain.tld' OR username = '$GLOBAL' OR username
= CONCAT('%','domain.tld') ORDER BY username ASC
[5834] dbg: config: retrieving prefs for user@domain.tld from SQL server
[5834] dbg: Conf: remove_header delete ham header Report
[5834] dbg: Conf: remove_header delete spam header Report
[5834] dbg: Conf: report_safe is 0, adding X-Spam-Report header to headers_spam