Bug 3799 - sa-learn with --dbpath tries to open ~/.spamassassin/bayes* first.
Summary: sa-learn with --dbpath tries to open ~/.spamassassin/bayes* first.
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Learner (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: Other Linux
: P5 normal
Target Milestone: 3.2.0
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-22 10:21 UTC by Matthew Hodgson
Modified: 2006-09-09 19:06 UTC (History)
0 users



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 Matthew Hodgson 2004-09-22 10:21:44 UTC
When spamassassin learns into a bayes database specified using --dbpath, it
first appears to try to open ~/.spamassassin/bayes* for the current user
regardless, which may generate warnings & errors which it then appears to ignore.

e.g.:

% sa-learn --dump=magic --dbpath /etc/mail/virtual/domain/localpart/bayes
bayes: bayes db version 2 is not able to be used, aborting! at
/usr/local/share/perl/5.6.1/Mail/SpamAssassin/BayesStore/DBM.pm line 160.
0.000          0          3          0  non-token data: bayes db version
0.000          0       4593          0  non-token data: nspam
0.000          0       6334          0  non-token data: nham
...

the error is obviously inconsistent - and results from trying to open obsolete a
bayes db in ~/.spamassassin/bayes*.  The workaround is simply to remove the
bayes db from the ~/.spamassassin folder.

If --dbpath is set, presumably SA should not autocreate ~/.spamassassin paths,
either.

The problem can be diagnosed by running sa-learn in -D mode and seeing what db
it complained about trying to open.

The same problem appears to occur when SA autolearns ham or spam in spamd or
presumably normal spamassassin.
Comment 1 Theo Van Dinter 2004-09-22 10:29:25 UTC
I'm not sure if this is really 3.0.1 or 3.1.0, but the scoop is this, in sa-learn, dbpath kluges the 
configured bayes_path via:

$spamtest = new Mail::SpamAssassin(
[...]
$spamtest->init(1);
[...]
  $spamtest->finish_learner();
  $spamtest->{conf}->{bayes_path} = $bayes_override_path;

so the init() tries to read the actual configured bayes db and get the learner bit setup, then we change 
the path and things are good.  However, the init() call throws the "version 2" warning (the person's 
actual bayes db), and then the path overrides and the dump can properly read the other version 3 db.

so I'm not sure how to go about fixing this, but we should look into it.  perhaps either pass in an option 
to init() to not init bayes or figure out something cleaner. :)
Comment 2 Theo Van Dinter 2004-09-28 18:44:10 UTC
the more I think about it, the more I decide there's not an easy solution to this, so it's not really 3.0.1 
material.  pushing to 3.1.0 queue since we can do larger-scale changes there.
Comment 3 Daniel Quinlan 2005-04-30 20:23:18 UTC
punting to 3.2.0, no patch and not a severe problem, unfortunately
Comment 4 Theo Van Dinter 2006-09-10 02:06:38 UTC
Sending        lib/Mail/SpamAssassin.pm
Sending        sa-learn.raw
Transmitting file data ..
Committed revision 441887.

:)