You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Aaron Axelsen <li...@frozenpc.net> on 2006/06/07 05:19:43 UTC

sa-learn --username option

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 user1 .spamassassin
folder is chown user1.user and has permissions 700.  Are the permissions
a problem?

I see there is a --spam-db option.  Do I need to use this?

-- 
Aaron Axelsen
lists@frozenpc.net

Great hosting, low prices.  Modevia Web Services LLC -- http://www.modevia.com


Re: sa-learn --username option

Posted by Jonathan Armitage <jo...@hepworthband.co.uk>.
In Solaris, that would be something like:

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

Jon

> Aaron Axelsen wrote:
>> 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


Re: sa-learn --username option

Posted by Aaron Axelsen <li...@frozenpc.net>.
Matt,

Thanks for the reply.  I ended up writing a perl script to copy all the
spam to learn into a neutral location group owned.  In that same script
I then change the effective user id, and try to learn.  However, it
still is not learning as the effective user.  The script runs as root,
and still tries to learn as root

Is there some reason for this? Any suggestions?

-- Aaron

Matt Kettler wrote:
> 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.
>
>
>   

-- 
Aaron Axelsen
lists@frozenpc.net

Great hosting, low prices.  Modevia Web Services LLC -- http://www.modevia.com


Re: sa-learn --username option

Posted by Matt Kettler <mk...@comcast.net>.
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.