[Mimedefang] Bug at SA website: SA 3.3.1 - Is "local.cf" read in TWICE when loading configuration files?

- kd6lvw at yahoo.com
Tue Aug 10 14:48:39 EDT 2010

--- On Tue, 8/10/10, Kevin A. McGrail <KMcGrail at PCCC.com> wrote:
> > URL:  https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6481
> > 
> > Could we make certain that MIMEDefang isn't the cause of this?  Thanks.
> >    
> I'd be shocked if this isn't a mimedefang-filter or
> duplicated information in a cf file on your
> installation.  I've used SA and MD in a number of ways
> and never seen this issue.
> I'm not ruling things out but I would check what cf files
> you have in /etc/mail and /etc/mail/spamasssassin and I'd
> post your mimedefang-filter for review.

I'm not going to post the entire filter, but there is only one reference to SA from my MD code:

sub filter_end {
    my($entity) = @_;
    return if message_rejected();
    if ($Features{'SpamAssassin'} && (-s './INPUTMSG' < (128 * 1024))) {
        my($hits, $req, $names, $report) = spam_assassin_check();
        md_syslog('info',"$QueueID: Spam-Score=$hits Relay=$RelayAddr To=".
            join(',', at Recipients) . ($names ? " Rules=$names" : ''));
        action_insert_header('Authentication-Results', ...[DELETED]..., 0);
        if ($hits >= ($req / 3.6)) {
            action_add_part($entity, 'text/plain', '-suggest', $report,
                'SpamReport.text', 'attachment');
            if ($hits >= $req) {

As noted, spam_assassin_check() is the ONLY call I make to SA, and only in filter_end().

I've taken a look at the subroutines in mimedefang.pl, and I note that in spam_assassin_init() a reference to "config" which selects a configuration file.  Although I don't select one explicitly, the routine may suggest that it picks one to load -- one that may already be loaded by SA itself, so the "user_prefs" parameter may not be needed.

I experimented with setting an empty configuration, spam_assassin_check(""), and that worked.  Apparently, leaving the default allowed mimedefang.pl to pick a file that SA was already loading.  ARGH!

The lines 6749-6759 in spam_assassin_init(), where it picks a configuration file if none was passed, are the problem.  The choices in the "/etc/mail/spamassassin/" directory are ALREADY LOADED by SA.  Perhaps they should be deleted?

I conclude that MD is at fault in causing a file to be loaded twice.
I also have my fix:  Explicitly pass "" as the configuration parameter to spam_assassin_check(), such that "user_prefs" => "" to the ..._init() call.

More information about the MIMEDefang mailing list