Bug 5740 - It is impossible to report (to remote service) a message via spamc if bayes is disabled
Summary: It is impossible to report (to remote service) a message via spamc if bayes i...
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamc/spamd (show other bugs)
Version: 3.2.1
Hardware: All Linux
: P3 major
Target Milestone: 4.0.0
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-05 10:38 UTC by Andrey Lelikov
Modified: 2022-04-15 12:31 UTC (History)
2 users (show)



Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Lelikov 2007-12-05 10:38:30 UTC
spamassasin has a -r option to report message as spam (or ham). By default it
also calls learn method which fails if bayes is disabled. This may be disabled
by setting bayes_learn_during_report to 0. 
spamc has -C option for the same purpose, but it will never work if bayes is
disabled. spamc always sets set_remote and set_local flags, and spamd always
calls learn() if set_local flag is set - so bayes_learn_during_report option is
not checked and spamd fails with 'Can't call method "learn" on an undefined
value'. workaround is to comment following code in spamd, but this is ugly.

#  if ($hdrs->{set_local}) {
#    my $status = $spamtest->learn($mail, undef, ($hdrs->{message_class} eq
'spam' ? 1 : 0), 0);

#    push(@did_set, 'local') if ($status->did_learn());
#    $status->finish();
#  }
Comment 1 Sidney Markowitz 2022-04-15 12:31:43 UTC
For some reason the use_bayes config option always shows up as 1 in spamd, so it didn't work to check that. It does work to check if there is a bayes_scanner defined, and also to have spamd check th4 bayes_learn_during_report option. Note that if the site local.cf enables bayes, this fix allows a user to disable the learning in their userprefs by setting bayes_learn_during_report 0

The fix is to wrap the code in spamd inside a

if (defined $spamtest->{bayes_scanner} &&
    $spamtest->{conf}->{bayes_learn_during_report})

Committed revision 1899889.