Bug 1796 - read_scoreonly_config doesn't start from a base config
Summary: read_scoreonly_config doesn't start from a base config
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Libraries (show other bugs)
Version: 2.53
Hardware: All All
: P3 normal
Target Milestone: 3.1.0
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-18 00:55 UTC by Daniel M. Zimmerman
Modified: 2004-06-01 16:07 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 Daniel M. Zimmerman 2003-04-18 00:55:21 UTC
If one has an instance of Mail::SpamAssassin, and one calls
"read_scoreonly_config" (a very unintuitively named method, I might add, since
it reads things that aren't scores) on a file, the various settings in that file
replace (or augment, in the case of whitelist entries) the corresponding
settings in the currently active Prefs object. The problem arises when one calls
"read_scoreonly_config", processes an email (presumably using the preferences of
the individual who owns the config in question), and then calls
"read_scoreonly_config" again with a different file to process an email for a
different user. 

For example, assume that I have in my "local.cf" the setting "report_safe 0".
Now I call "read_scoreonly_config" on a file that contains "report_safe 1" and
process an email. Everything works fine. Next, I call "read_scoreonly_config" on
a file that doesn't contain the report_safe setting at all. The user who made
that preference file assumes they will get the system default setting of
"report_safe 0", but they will in fact get "report_safe 1" because it is not
overridden by reading the new config file. 

This is not a problem when "load_scoreonly_config" is used in spamd, because it
uses fork() to create a new child every time it processes a message, and so any
scoreonly config loaded is only loaded in that child's copy of the
Mail::SpamAssassin object. But on a Win32 system, for instance, where fork() in
perl doesn't work too well (at least not in perl 5.6.1), it can cause problems.
This is specifically in the context of a filter I've written for CommuniGate
Pro, called CGPSA (<http://www.tffenterprises.com/cgpsa/>), which uses
Mail::SpamAssassin directly.

While it's possible that some programs depend on this behavior of
"load_scoreonly_config", I think it's unlikely; it would be much more reasonable
for "load_scoreonly_config" to start from a base configuration (the rules files,
plus local.cf) and then modify that configuration with the loaded config file.
If that change is not something reasonable to implement, an alternative way of
getting this functionality without creating a brand new Mail::SpamAssassin
object for each loaded set of preferences would be most helpful.
Comment 1 Justin Mason 2003-07-06 23:30:35 UTC
we would accept a patch ;)

seriously though -- AFAIK we aren't using it in this way.  you're correct, it's
nonintuitive.  I'd suggest apis to swap in and out {conf} objects under caller
control.  e.g. new APIs like  get_conf() to get the current {conf} object,
set_conf() to set it, and basically allow the caller to track the
username->confobject mapping.
Comment 2 Justin Mason 2004-06-02 00:07:38 UTC
btw, this is now fixed in 3.0.0, thx Theo ;)