Aaron Axelsen wrote:
> Hello,
>
> I am trying to run a cronjob as root which will learn a different
> accounts spam into my spam db.  Example command:
>
> sa-learn -u user1 --spam /home/user2/Maildir/.Spam/cur/
>
> When the command runs, it learns the spam into /root/.spamassassin
> instead of /home/user1/.spamassassin
>
> Does anyone have any idea why its doing this? 

The -u option to sa-learn only works if you're using SQL for bayes
storage, or if you're using virtual users.

The caveat is revealed in the docs for sa-learn:
--------------
NOTE: This option will not change to the given /username/, it will only
attempt to act on behalf of that user. Because of this you will need to
have proper permissions to be able to change files owned by /username/.
In the case of SQL this generally is not a problem.
--------------

In particular, that first sentence is important here. It will not change
(setuid) to the given username, therefore the home directory does not
change.

If you want to exec sa-learn as a particular user, just use su in the
straightforward unix fashion:

su  user1  sa-learn --spam /home/user2/Maildir/.Spam/cur/

Note that user1 will need read-privileges to
/home/user2/Maildir/.Spam/cur/  for this to work.


Reply via email to