welcome: please sign in

Diff for "SpamAssassinAdmin"

Differences between revisions 10 and 18 (spanning 8 versions)
Revision 10 as of 2007-09-17 17:48:52
Size: 4481
Editor: MichaelOlson
Comment: Put spam-learning logic into a script
Revision 18 as of 2021-11-06 18:42:33
Size: 710
Editor: ClintonEbadi
Comment: ... but the puppet parts for installing spamd aren't public yet
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Here's how we set up our site-wide Spam``Assassin bayes database, including the ability for users to train it. {{{#!wiki note
'''Additional information is available at a [[https://wiki.hcoop.net/SpamAssassinAdmin?rev=14|previous version of this page]]'''
Line 3: Line 4:
 1. Create a new user `spamd` with home `/var/local/lib/spamd`.
 1. Add "spamd" to `/etc/cron.allow`.
 1. Perform the following as `spamd`:
   1. `cd ~spamd`
   1. `maildirmake -S Maildir`, to create the shared Spam``Assassin mailbox.
   1. `maildirmake -f SiteSpam -s write Maildir`, to create a writable folder for misclassified spam (or if extracting from a tarball, make sure it has the sticky bit set by doing the following).
      {{{
find ~spamd/Maildir/.SiteSpam -type d -exec chmod o+t {} \;
It is quite outdated. However, it may have some information which has not yet been incorporated into the current version.
Line 12: Line 6:
   1. `maildirmake -f SiteHam -s write Maildir`, to create a writable folder for misclassified ham (or if extracting from a tarball, make sure it has the sticky bit set by doing the following).
      {{{
find ~spamd/Maildir/.SiteHam -type d -exec chmod o+t {} \;
}}}
 1. Add the following to `~spamd/.crontab` to learn from and delete messages in those shared folders every five minutes (changing MACHINENAME to be the name of the local machine):
    {{{
MAILTO=logs@MACHINENAME.hcoop.net
Line 20: Line 7:
# Learn from submitted spam
0,10,20,30,40,50 * * * * ~spamd/scripts/learn-spam --spam
# Learn from submitted ham
0,10,20,30,40,50 * * * * ~spamd/scripts/learn-spam --ham
# Remove any tmp cruft
3 3 * * * find ~spamd/Maildir/.SiteHam/tmp -type f -delete ; find ~spamd/Maildir/.SiteSpam/tmp -type f -delete
}}}
    '''Be sure there's a newline after the last line, or it won't be processed.'''
 1. Copy the `learn-spam` script from the `spam` directory of the hcoop "misc" repository into the directory `~spamd/scripts`.
 1. Modify `/etc/spamassassin/local.cf` with the directive:
    {{{
# Location of bayes data
bayes_path /var/local/lib/spamd/bayes/.spamassassin/bayes
Line 34: Line 8:
# Fix bayes permissions
bayes_file_mode 0770
== FAQ ==
Line 37: Line 10:
# Directives from old setup
# [any custom stuff from the old /etc/spamassassin/local.cf that you want to keep]
}}}
 1. Modify `/etc/default/spamassassin` by setting `OPTIONS` and `ENABLED`as follows. The `-x` prevents `spamd` from trying to look for per-user configuration, which would be silly because it always runs as the same user here. Without this flag, the cron job triggered every 5 minutes would log an error message, which would lead to an e-mail being sent to the `spamd` user.
    {{{
# Change to one to enable spamd
ENABLED=1
=== Where can I find the config files? ===
Line 45: Line 12:
OPTIONS="--create-prefs --max-children 5 --helper-home-dir=/var/local/lib/spamd -u spamd -x -s /var/log/spamd.log" A: https://git.hcoop.net/hcoop/config/spamassassin.git contains the current spamd configuration, which is pulled into puppet using a git submodule.
Line 47: Line 14:
PIDFILE="/var/local/lib/spamd/pid"
}}}
 1. Make a file called `/etc/logrotate.d/spamd` with the following contents.
    {{{
/var/log/spamd.log {
        weekly
                missingok
                create 0640 root adm
                rotate 4
                compress
                delaycompress
                sharedscripts
                postrotate
                [ -f '/var/local/lib/spamd/pid' ] && (kill -HUP `cat /var/local/lib/spamd/pid`) || exit 0
                endscript
}
}}}
 1. Start the daemon by doing {{{/etc/init.d/spamassassin start}}}. Check `/var/log/spamd.log` to be sure that it started OK.
 1. Install the `.crontab` entries that you wrote earlier by doing {{{crontab -u spamd ~spamd/.crontab}}} as root. Do this every time that you make changes to `~spamd/.crontab`.
 1. Edit {{{/etc/courier/shared/index}}} as follows, being sure to separate each column with a single TAB character. The second column is UID, and third column is GID -- consult `/etc/passwd` and `/etc/group` to make these match the `spamd` user and group.
    {{{
spamd 116 119 /var/local/lib/spamd
}}}
 1. Restart courier's IMAP process: {{{runsv restart courier-imap}}}
 1. Test by checking to see if you can access {{{shared.SpamAssassin.SiteHam}}} and {{{shared.SpamAssassin.SiteSpam}}} from IMAP. If not, do {{{maildirmake --add SpamAssassin=~spamd/Maildir ~/Maildir}}} as your normal user from the machine that does courier (and presumably spamassassin as well). You might need to replace `~` with `~USERNAME` if you are using sudo to do this, where USERNAME is your normal username.
 1. Now copy some spammy mail into the {{{SiteSpam}}} directory, wait 5 minutes, and check to see if the mail got learned and deleted.
 1. If so, edit {{{~spamd/.crontab}}} to pipe the output of sa-learn to /dev/null, and run crontab as specified earlier to propogate this change.
Installation is handled using Puppet classes `hcoop::service::mail::spamassassin::{client,server}`, which is unfortunately only accessible to members with admin accounts currently.

Additional information is available at a previous version of this page

It is quite outdated. However, it may have some information which has not yet been incorporated into the current version.

1. FAQ

1.1. Where can I find the config files?

A: https://git.hcoop.net/hcoop/config/spamassassin.git contains the current spamd configuration, which is pulled into puppet using a git submodule.

Installation is handled using Puppet classes hcoop::service::mail::spamassassin::{client,server}, which is unfortunately only accessible to members with admin accounts currently.


CategorySystemAdministration

SpamAssassinAdmin (last edited 2021-11-06 18:42:33 by ClintonEbadi)