You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Michael Monnerie <mi...@it-management.at> on 2006/04/22 10:55:29 UTC

sa-learn not learning with sudo

Hi, I've setup a new server, and made
# sudo -H -u vscan sa-learn --ham --progress --no-sync 
--mbox /tmp/ham.txt
3.59 msgs/sec 31m43s DONE
Learned tokens from 6842 message(s) (6842 message(s) examined)

And the same for SPAM, and then I have this:

# sudo -H -u vscan sa-learn --dump
0.000          0         0          0  non-token data: nspam
0.000          0         0           0  non-token data: nham

But when I do
# su -l vscan
vscan@mailgate:~> sa-learn --ham --progress --no-sync 
--mbox /tmp/ham.txt
6.32 msgs/sec 18m03s DONE
Learned tokens from 6842 message(s) (6842 message(s) examined)

I have:
# sudo -H -u vscan sa-learn --dump
0.000          0       6726          0  non-token data: nspam
0.000          0       7023          0  non-token data: nham

Now why is there a diff between sudo as a user or directly logging in as 
the user? My local.cf has this entries:
loadplugin Mail::SpamAssassin::Plugin::AutoLearnThreshold
bayes_path                          ~/.spamassassin/bayes_db
bayes_expiry_max_db_size            20000000
bayes_file_mode                     0777
bayes_auto_expire                   0
bayes_auto_learn_threshold_spam     8.00
bayes_auto_learn_threshold_nonspam  0.1

mfg zmi
-- 
// Michael Monnerie, Ing.BSc    -----      http://it-management.at
// Tel: 0660/4156531                          .network.your.ideas.
// PGP Key:   "lynx -source http://zmi.at/zmi3.asc | gpg --import"
// Fingerprint: 44A3 C1EC B71E C71A B4C2  9AA6 C818 847C 55CB A4EE
// Keyserver: www.keyserver.net                 Key-ID: 0x55CBA4EE

Re: sa-learn not learning with sudo

Posted by Matt Kettler <mk...@comcast.net>.
Michael Monnerie wrote:
> Hi, I've setup a new server, and made
> # sudo -H -u vscan sa-learn --ham --progress --no-sync 
> --mbox /tmp/ham.txt
> 3.59 msgs/sec 31m43s DONE
> Learned tokens from 6842 message(s) (6842 message(s) examined)
>   

I don't know why it's not working, but the FIRST thing to check is what
files are being updated, if any, when this command runs.

Check both:
    /home/vscan/.spamassassin/bayes_db_toks
   /root/.spamassassin/bayes_db_toks
 
 (Note:, you changed the bayes path to cause this slightly abnormal
naming. Normally the file would be bayes_toks. I'm really not sure why
you over-rode bayes_path with such a subtle change from the default, but
that is the result.)


> And the same for SPAM, and then I have this:
>
> # sudo -H -u vscan sa-learn --dump
> 0.000          0         0          0  non-token data: nspam
> 0.000          0         0           0  non-token data: nham
>
> But when I do
> # su -l vscan
> vscan@mailgate:~> sa-learn --ham --progress --no-sync 
> --mbox /tmp/ham.txt
> 6.32 msgs/sec 18m03s DONE
> Learned tokens from 6842 message(s) (6842 message(s) examined)
>
> I have:
> # sudo -H -u vscan sa-learn --dump
> 0.000          0       6726          0  non-token data: nspam
> 0.000          0       7023          0  non-token data: nham
>
> Now why is there a diff between sudo as a user or directly logging in as 
> the user? My local.cf has this entries:
> loadplugin Mail::SpamAssassin::Plugin::AutoLearnThreshold
>   
Do NOT put loadplugin statements in your local.cf. These belong in init.pre.
> bayes_path                          ~/.spamassassin/bayes_db
> bayes_expiry_max_db_size            20000000
> bayes_file_mode                     0777
>   
Note: you don't need the 0777 normally unless you're forcing bayes path
to a non-home-directory-relative path that multiple users share. ie:
/var/spamassassin/bayes
> bayes_auto_expire                   0
>   
Note: I hope you have a cron job that kicks of sa-learn --force-expire.
With bayes_auto_expire disabled there's nothing else to keep the bayes
DB from growing without bound.
> bayes_auto_learn_threshold_spam     8.00
> bayes_auto_learn_threshold_nonspam  0.1
>
> mfg zmi
>   


Re: sa-learn not learning with sudo

Posted by "Chr. v. Stuckrad" <st...@mi.fu-berlin.de>.
On Sat, Apr 22, 2006 at 10:55:29AM +0200, Michael Monnerie wrote:
...
> # sudo -H -u vscan sa-learn --dump
...
> But when I do
> # su -l vscan
...
> # sudo -H -u vscan sa-learn --dump
...
> Now why is there a diff between sudo as a user or directly logging in as 

One of the differences will be all the commands in the
User's shell-startup-Files!  Those are ignored, if you
run the command directly by sudo.

It also depends on the version of 'sudo', because one
of the latest changes *dropped* the HOME-Variable
from the environment (at least if you run the command
directly from sudo!).

Lots of our automated cron-scripts suddenly failed
by this 'security fix' and we had to replace
OLD:  sudo command
NEW:  sudo env HOME=$HOME command
to 'bridge the gap' and re-use the *current* HOME
'inside of sudo'.

May be the 'sudo -l vscan' also sets the missing HOME!

Yours    Stucki   (postmaster hit by the same? :-)