[ale] Spam Assasin + Bayesian Filters
Jason Day
jasonday at worldnet.att.net
Thu Jun 5 09:34:58 EDT 2003
On Wed, Jun 04, 2003 at 10:28:34PM -0400, attriel wrote:
> Does this work for a daemon non-root install? I never got it to do config
> files with that setup, but since I have multiple accounts and lots of
> mail, I'd really rather do the spamd centralized, and I always prefer
> non-root :(
Yes, it does work, but it's not easy or intuitive. Here's how I did it:
I have spamd run as user spamd, which I created specifically for this
purpose. I start spamd with these options:
-x --virtual-config=/home/spamd
That tells spamd to use /home/spamd for per-user configurations.
Whenever spamd processes mail for a user, it will look in /home/spamd
for a file called username.prefs to use as a user prefs file (normally
this file is called user_prefs and is in your ~/.spamassassin
directory), and if Bayes is enabled, it will store the Bayes files in
/home/spamd/username.
So, in the /home/spamd directory, I created a directory called jday.
The directory is owned by me, but its group owner is spamd. It has rwx
permissions for user and group:
jday:spiderman$ ls -la /home/spamd/
total 20
drwxr-xr-x 3 spamd root 4096 May 28 21:48 ./
drwxr-xr-x 3 spamd spamd 4096 May 7 11:47 ../
-rwx------ 1 root root 163 May 28 21:48 fixperms*
drwxrwx--- 3 jday spamd 4096 May 16 14:30 jday/
-rw-rw-r-- 1 jday spamd 1395 May 16 14:23 jday.prefs
Next, I copied my ~/.spamassassin directory to the /home/spamd/jday
directory:
# cp -a /home/jday/.spamassassin /home/spamd/jday
And fix the permissions:
# chown -R jday.spamd /home/spamd/jday
# chmod 770 /home/spamd/jday/.spamassassin
# chmod -R g+rw /home/spamd/jday/.spamassassin
spamassassin insists on using a .spamassassin directory inside of the
user directory, so make sure you put it there.
jday:spiderman$ ls -la /home/spamd/jday
total 16
drwxrwx--- 3 jday spamd 4096 May 16 14:30 ./
drwxr-xr-x 3 spamd root 4096 May 28 21:48 ../
drwxrwx--- 2 jday spamd 4096 Jun 5 09:03 .spamassassin/
jday:spiderman$ ls -la /home/spamd/jday/.spamassassin/
total 2600
drwxrwx--- 2 jday spamd 4096 Jun 5 09:03 ./
drwxrwx--- 3 jday spamd 4096 May 16 14:30 ../
-rw-rw---- 1 jday spamd 225741 Jun 5 09:03 bayes_journal
-rw-rw---- 1 jday spamd 1932 Jun 5 09:03 bayes_msgcount
-rw-rw---- 1 jday spamd 339968 Jun 5 09:03 bayes_seen
-rw-rw---- 1 jday spamd 2650112 Jun 5 09:03 bayes_toks
-rw-rw---- 1 jday spamd 1321 May 7 11:02 user_prefs
Once you have this directory structure, test that spamd is working
properly by running it in debug mode:
spamd -x --virtual-config=/home/spamd -D -p 7783
Replace the port 7783 with one of your liking. It takes it a minute to
startup, so wait until you see the line like:
logmsg: server started on port 7783 (running version 2.53)
Then send it a spam message:
cat spam.txt | spamc -p 7783
Look at the output on the console where you started spamd. You should
see something like this:
logmsg: connection from localhost [127.0.0.1] at port 1525
debug: user has changed
debug: bayes: 9449 untie-ing
debug: bayes: 9449 tie-ing to DB file R/O /home/spamd/jday/.spamassassin/bayes_toks
debug: bayes: 9449 tie-ing to DB file R/O /home/spamd/jday/.spamassassin/bayes_seen
This all works wonderfully, until you want to report a spam to razor, or
you get a message that has been mis-classified and you want to (re)learn
it with sa-learn. Unfortunately, there is no way to use spamassassin -r
or sa-learn with spamd; they still use ~/.spamassassin for user prefs
and bayes files. My fix for this was simple: I created two wrapper
scripts (attached) that change the HOME environment variable, then call
the real program.
Sorry for the long reply. I hope at least someone finds this useful :)
Jason
--
Jason Day jasonday at
http://jasonday.home.att.net worldnet dot att dot net
"Of course I'm paranoid, everyone is trying to kill me."
-- Weyoun-6, Star Trek: Deep Space 9
#! /bin/sh
# Home directory of the user spamd runs as. Per-user config files will
# be stored in a subdirectory called .spamassassin/$LOGNAME under this
# directory, where LOGNAME is the current user.
SPAMD_HOME=/home/spamd
# Fool sa-learn by changing our home directory location.
export HOME=${SPAMD_HOME}/${LOGNAME}
spamassassin $*
#! /bin/sh
# Home directory of the user spamd runs as. Per-user config files will
# be stored in a subdirectory called .spamassassin/$LOGNAME under this
# directory, where LOGNAME is the current user.
SPAMD_HOME=/home/spamd
# Fool sa-learn by changing our home directory location.
export HOME=${SPAMD_HOME}/${LOGNAME}
sa-learn $*
More information about the Ale
mailing list