On 8/22/2012 9:05 AM, Bowie Bailey wrote:
> On 8/21/2012 5:51 PM, Ben Johnson wrote:
>>
>> On 8/21/2012 5:19 PM, John Hardin wrote:
>>> On Tue, 21 Aug 2012, Ben Johnson wrote:
>>>
>>>> Aug 21 13:08:33.729 [23714] dbg: bayes: tie-ing to DB file R/O
>>>> /var/lib/amavis/.spamassassin/bayes_toks
>>>>
>>>> ---8<----------
>>>> # sa-learn --username=amavis --dump magic
>>> Run that with --debug and verify that the filenames match.
>>>
>> Sure enough, they don't match:
>>
>> ---8<----------
>> [...]
>> dbg: bayes: tie-ing to DB file R/O /root/.spamassassin/bayes_toks
>> dbg: bayes: tie-ing to DB file R/O /root/.spamassassin/bayes_seen
>> Aug 21 14:41:13.112 [32170] dbg: bayes: found bayes db version 3
>> 0.000          0          3          0  non-token data: bayes db version
>> 0.000          0         95          0  non-token data: nspam
>> 0.000          0        307          0  non-token data: nham
>> 0.000          0      62301          0  non-token data: ntokens
>> 0.000          0 1345469997          0  non-token data: oldest atime
>> 0.000          0 1345579297          0  non-token data: newest atime
>> 0.000          0          0          0  non-token data: last journal
>> sync atime
>> 0.000          0          0          0  non-token data: last expiry atime
>> 0.000          0          0          0  non-token data: last expire
>> atime delta
>> 0.000          0          0          0  non-token data: last expire
>> reduction count
>> ---8<----------
>>
>> So, I suppose that I didn't actually resolve the problem from yesterday,
>> which was that I cannot seem to train under the "amavis" user due to the
>> ownership/permissions on the /var/vmail directory.
>>
>> What good is the --username switch, then?
>>
>> Why does this command train the "root" user's database?
>>
>> # sa-learn --username=amavis --spam "/path/to/spam"
>>
>> And why does this command dump the "root" user's database?
>>
>> # sa-learn --username=amavis --dump magic
>>
>> Thanks very much,
> 
> As has already been mentioned, the '--username' option is only useful if
> you're using SQL.  You should set your bayes_path so there is no confusion.

Thank you Axb and Bowie for clarifying this point. Perhaps the sa-learn
documentation should be updated to eliminate the ambiguity around this
switch. In particular, I am referring to this page:
http://spamassassin.apache.org/full/3.0.x/dist/doc/sa-learn.html , which
states only the following:

"If specified this username will override the username taken from the
runtime environment. You can use this option to specify users in a
virtual user configuration."

Maybe adding the "SQL" keyword will make the "virtual user
configuration" distinction more evident.

> Since you have been training the root database, you may want to copy
> that one over.
> 
> $ cp /root/.spamassassin/bayes* /var/lib/amavis/.spamassassin/
> 
> Then fix the permissions and ownership back to what they should be for
> the amavis user.

I did think to do this, but I approached it a bit differently, and used
"sa-learn --backup" (and --restore), under the "amavis" user account,
which mitigated the need to modify the permissions on the database.

> Then set the bayes path in your local.cf:
> 
> bayes_path /var/lib/amavis/.spamassassin/bayes
> 
> (Don't double the 'bayes' at the end as was suggested previously unless
> you want to move the bayes files into a 'bayes' directory)
> 
> Restart amavis and try again...
> 

Again, thanks to Axb and Bowie for making this suggestion. Hard-coding
the bayes_path was the missing link for me; this is what allowed me to
train under the "amavis" user while having "root" (or "vmail")
privileges, which on Debian, are necessary to read mail during training.

I think I'm sorted here; thanks again, guys!

-Ben

Reply via email to