Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 107863 - ~/.spamassassin permissions on dev.g.o prevent sa-learn
Summary: ~/.spamassassin permissions on dev.g.o prevent sa-learn
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Infrastructure
Classification: Unclassified
Component: Dev box issues (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Gentoo Infrastructure
URL:
Whiteboard:
Keywords:
: 115768 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-10-02 03:54 UTC by Tom Martin (RETIRED)
Modified: 2006-06-02 06:08 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Martin (RETIRED) gentoo-dev 2005-10-02 03:54:14 UTC
~/.spamassassin on toucan:
-rw-rw----  1 spamd  spamd 2650112 Oct  2 10:45 auto-whitelist
-rw-------  1 spamd  spamd    3408 Oct  2 10:45 bayes_journal
-rw-rw----  1 slarti spamd  663552 Oct  2 10:07 bayes_seen
-rw-------  1 spamd  spamd 5079040 Oct  2 10:07 bayes_toks
-rw-rw----  1 slarti spamd    1173 Sep 26 17:15 user_prefs

My local ~/.spamassassin, similar setup, using spamd:
-rw-------   1 tmartin users  151552 Sep  3 21:05 auto-whitelist
-rw-------   1 tmartin users  663552 Sep 25 18:01 bayes_seen
-rw-------   1 tmartin users 5263360 Sep 25 18:01 bayes_toks
-rw-------   1 tmartin users    1175 May 15 09:29 user_prefs

And, when using sa-learn:
slarti@toucan new % sa-learn --spam 1128247202.8514_0.toucan
Cannot open bayes databases /home/slarti/.spamassassin/bayes_* R/O: tie failed:
Permission denied
Cannot open bayes databases /home/slarti/.spamassassin/bayes_* R/W: tie failed:
Permission denied
Cannot open bayes databases /home/slarti/.spamassassin/bayes_* R/W: tie failed:
Permission denied
Cannot open bayes databases /home/slarti/.spamassassin/bayes_* R/W: tie failed:
Permission denied
Learned from 0 message(s) (1 message(s) examined).
ERROR: the Bayes learn function returned an error, please re-run with -D for
more information

lcars said on IRC that he'd be looking into this.

Thanks,
Tom
Comment 1 Corey Shields 2005-10-11 10:57:09 UTC
Tom,

shot in the dark, but try this:

(make a backup copy of your bayes files first)

db4.2_upgrade bayes_seen
db4.2_upgrade bayes_toks

-C
Comment 2 Tom Martin (RETIRED) gentoo-dev 2005-10-15 01:57:04 UTC
This is the whole problem. I *can't* backup my bayes_toks, bayes_journal or
auto-whitelist because I don't own them or have read to them. I can't
db4.2_upgrade bayes_toks because I don't even have read permission, let alone write.
Comment 3 Roy Marples (RETIRED) gentoo-dev 2005-10-24 05:07:09 UTC
I got bit by this too. Had too rm the contents of .spamassassin just to stop the
mailing list program bouncing my mails every 2 hours :/
Comment 4 Andrea Barisani (RETIRED) gentoo-dev 2005-10-29 04:10:56 UTC
Folks any suggestions? I don't want to manually chown the files and I don't
see any umask/perms setting for spamd -c option. I'm no SA guru so help is 
appreciated.
Comment 5 Lance Albertson (RETIRED) gentoo-dev 2005-10-29 09:21:48 UTC
I'll try and take a look at this today.
Comment 6 Lance Albertson (RETIRED) gentoo-dev 2005-12-16 06:21:25 UTC
*** Bug 115768 has been marked as a duplicate of this bug. ***
Comment 7 Lance Albertson (RETIRED) gentoo-dev 2005-12-16 06:40:54 UTC
I believe the original issue was solar being uneasy about having spamd running
sa setuid, but I'm not sure. Let me try and get him to comment on this bug.
Comment 8 solar (RETIRED) gentoo-dev 2005-12-16 07:53:56 UTC
I dont recall that being the case lance. But now that you bring it up, yeah I'm 
anti having setXid perl scripts. spamd was a bonus feature provided by infra.
If you want better filtering sadly I think you should probably do that in your 
client till a solution exists that does not require us to add new setXid's
Comment 9 Chris White (RETIRED) gentoo-dev 2005-12-16 23:07:08 UTC
If spamassasin is weird, I'd say maybe go with bogofilter:

http://bogofilter.sourceforge.net/

and no, I'm not going to just say, "Hey, let's use bogofilter when some of our devs might not know how to use it", so I made a doc:

http://dev.gentoo.org/~chriswhite/docs/bogofilter.html
http://dev.gentoo.org/~chriswhite/xml_sources/bogofilter.xml

This should cover the basic stuff that most devs will need to control spam using bogofilter.
Comment 10 Tom Martin (RETIRED) gentoo-dev 2005-12-17 07:25:01 UTC
(In reply to comment #9)
> If spamassasin is weird, I'd say maybe go with bogofilter:

It's not that simple. One of the reasons SA was chosen for toucan was that it has a central spam daemon that could really reduce resource usage. In addition, it provides rule-based filtering as well as Bayesian filtering, something which bogofilter doesn't do. Switching to bogofilter would mean there would essentially be no filtering at all until everyone trains up their wordlist. The flood of spam into everyone's inboxes over this initial period would be mammoth, amongst other problems.

I'm not sure exactly what we can do now, to be honest. For people using IMAP, client-side spam filtering is tricky, to say the least. Even with offlineimap, I'm not sure how it could be implemented, besides forcing everyone to use Evolution or Thunderbird. Maybe an email to a spamassassin list or an excursion to their IRC channel will yield some results :)
Comment 11 Chris White (RETIRED) gentoo-dev 2005-12-17 10:09:22 UTC
Well, if someone wants to outline the exact result they'd like as far as permissions/etc, I'm willing to tear spamassasin apart and make a patch to implement these changes.  I have lots of new spammers as of recently, and I'd like to be able to train sa on them.
Comment 12 Tom Martin (RETIRED) gentoo-dev 2005-12-17 11:46:52 UTC
(In reply to comment #11)
> Well, if someone wants to outline the exact result they'd like as far as
> permissions/etc, I'm willing to tear spamassasin apart and make a patch to
> implement these changes.

The target permissions are outlined in the initial bug report.

To summarise:

- lcars can't figure out why they're like that, and doesn't feel comfortable with manual chmoding.

- cshields thinks it's related to a berkdb upgrade, but this is unverifiable.

- Ramereth thinks it's because solar didn't want any setXid perl scripts on toucan.

- solar doesn't recall this being the case, but agrees anyway.
Comment 13 Chris White (RETIRED) gentoo-dev 2005-12-17 13:47:41 UTC
Well, it gets weird.. it's not the normal behaviour of sa to do that apparently.  I think this was a one time only hickup as:

sa-learn --dbpath=~/sa_db --spam 1134737421.29187_0.toucan:2,

learns the file and stuffs it:

-rw-------  1 chriswhite users 12288 Dec 17 21:29 /home/chriswhite/sa_db_seen
-rw-------  1 chriswhite users 49152 Dec 17 21:29 /home/chriswhite/sa_db_toks

however, this much still comes out:

bayes: cannot open bayes databases /home/chriswhite/.spamassassin/bayes_* R/O: tie failed: Permission denied

Though interestingly enough it does that, then goes through with the sa_db_* files just nicely.

It appears to umask the db's as such:

oct($main->{conf}->{bayes_file_mode}) & 0666

so another question is what bayes_file_mode is set for.  This is all I could find, nothing directly seems to chmod anything.
Comment 14 Lance Albertson (RETIRED) gentoo-dev 2005-12-17 16:22:45 UTC
Just an FYI, cfengine sets these permissions, not SA. We did that to get around the orginal issue (which I can't quite remember what it was). But I thought it was a setuid issue. I might look into this more tonight.
Comment 15 Lance Albertson (RETIRED) gentoo-dev 2005-12-18 09:00:42 UTC
Ok, I remember now what the issue was. By default, spamd runs as root which will allow it to set it's uid to the user to write user pref files and such. We didn't want to do that, so we opted to using a non-root user (spamd), but doing that disallowed spamd from writing/reading user pref files.

From the docs [1]:

System-Level Security
---------------------

spamd has the facility to run as a non-root user, this has potential security
payoffs. If a fault is found in spamd or spamassassin code, any third party
linked-libraries or imported perl modules there is the potential for abuse of
both the running uid of spamd, and the uid of the username supplied by spamc
(and this could be any user).

When run as root, spamd will change uid's to the user invoking spamc in order
to read and write to their configurations. This functionality is not possible
if spamd does not run as root and is a disadvantage if you rely on this. If you
use mysql or LDAP for per-user configuration there is no reason in the world
to run as root, and this remains fully functional.

If you do not need to let your users define their own rules, maintain
their own whitelists, or have non-world-readable home and ~/.spamassassin
directories, then just set spamd up to run with the "-u username" option.
Since spamd can use auto-whitelisting, which requires it maintain a
database of email addresses on-disk, you should use a non-"root" but
non-"nobody" user: "mailnull" or "mail" are good choices, or even create a
"spamd" user.

------

I think the best solution right now is either using LDAP to store this information, or use a mysql database. Let me try and get lcars to reply to this to see what he thinks.

[1] http://wiki.apache.org/spamassassin/BetterDocumentation/SpamdReadme
Comment 16 Andrea Barisani (RETIRED) gentoo-dev 2005-12-20 01:07:10 UTC
Ok we can so SA <> LDAP fairly easily and it looks clean enough. My only concern is performance but the only way to find out is testing it.

I'll set this up when I get the chance.
Comment 17 Tom Martin (RETIRED) gentoo-dev 2006-01-27 07:29:17 UTC
Okay, removing bayes_* and auto-whitelist, training, then making them -rw-rw---- slarti:spamd solves the problem, for anyone who needs it now. (Thanks hparker).

Not sure how to make this into a permanent fix though.
Comment 18 Tom Martin (RETIRED) gentoo-dev 2006-01-27 07:31:56 UTC
(In reply to comment #17)
>
> Not sure how to make this into a permanent fix though.
> 

Said without reading the above comments, of course ;)

Never mind.
Comment 19 Lance Albertson (RETIRED) gentoo-dev 2006-05-18 21:49:05 UTC
Closing since we have global bayes working on woodpecker now.
Comment 20 Tom Martin (RETIRED) gentoo-dev 2006-06-02 03:11:48 UTC
(In reply to comment #19)
> Closing since we have global bayes working on woodpecker now.

slarti@woodpecker cur % sa-learn --spam --showdots *

bayes: locker: safe_lock: cannot create tmp lockfile /var/amavis/.spamassassin/bayes.lock.woodpecker.gentoo.org.15402 for /var/amavis/.spamassassin/bayes.lock: Permission denied
config: cannot open "/etc/mail/spamassassin/secrets.cf": Permission denied
bayes: expire_old_tokens: locker: safe_lock: cannot create tmp lockfile /var/amavis/.spamassassin/bayes.lock.woodpecker.gentoo.org.30809 for /var/amavis/.spamassassin/bayes.lock: Permission denied

Learned tokens from 0 message(s) (1 message(s) examined)

There are 219 messages in that directory. Not sure exactly what's going on...
Comment 21 Kurt Lieber (RETIRED) gentoo-dev 2006-06-02 06:08:08 UTC
we don't offer per-user bayesian training.