that would only do it for the user you're running sa-learn as, in this case root. I kind of hacked something together to do sa-learn on a per-user basis. In my case, I store all my spamassassin settings in mysql, so the following probably wont help anyone that isnt using mysql, and spamassassin 3.0
step 1) make a directory, call it users/ this directory will contain subdirectories for each user you want to enable this for. Use username@domainname for the format
step 2) create a local.cf in the username@domainname dir
step 3) copy your /etc/mail/spamassassin/local.cf to that dir
step 4) add this line to it:
bayes_sql_override_username username@domainname
step 5) I use this script to automate spam learning, the last line is what youd use. The template stuff is how I automate building the local.cf files.
#!/bin/sh
SALEARN="/usr/bin/sa-learn"
CONFDIR="/usr/share/atomic-mail-scanner/users"
USER=$1
echo "Updating: $1"
if [ ! -d $CONFDIR/$USER ]; then
mkdir $CONFDIR/$USER
fi
if [ ! -f $USER/local.cf ]; then
sed s/CHANGEME/$USER/ $CONFDIR/template.cf > $CONFDIR/$USER/local.cf
fi
$SALEARN --siteconfigpath=$CONFDIR/$USER/ --showdots --spam "$2"
step 6) Same thing, but for ham
#!/bin/sh
SALEARN="/usr/bin/sa-learn"
CONFDIR="/usr/share/atomic-mail-scanner/users"
USER=$1
echo "learning ham for: $1"
if [ ! -d $CONFDIR/$USER ]; then
mkdir $CONFDIR/$USER
fi
if [ ! -f $USER/local.cf ]; then
sed s/CHANGEME/$USER/ $CONFDIR/template.cf > $CONFDIR/$USER/local.cf
fi
$SALEARN --siteconfigpath=$CONFDIR/$USER/ --showdots --ham "$2"
step 7) write a wrapper to run this for all your users. Heres mine, YMMV, since I use spamtraps, and archive spam for research purposes.
#!/bin/sh
# bulk ham importer
# v 0.1
SALEARN="/usr/share/atomic-mail-scanner/users/ham-learner.sh"
SPAMTRAP1="/var/qmail/mailnames/atomicrocketturtle.com/spamtrap/Maildir/cur"
SPAMTRAP2="/var/qmail/mailnames/atomicrocketturtle.com/spamtrap/Maildir/new"
ARCHIVE="/root/spam/archive/"
if [ -f /tmp/atomic-bulk ]; then
echo "scan is running"
exit 0
fi
# create lock file
touch /tmp/atomic-bulk
for i in `find /var/qmail/mailnames/ -name .Learn\ FP -type d |sed s/Learn\ FP/Learn_FP/ `; do
USER=`echo "$i"| awk -F\/ '{print $6"@"$5}' |grep -v ^@`
DIR=`echo $i | sed s/Learn_FP/Learn\ FP/`
echo "Processing HAM for $USER"
#echo "$DIR/cur"
#ls -la "$DIR/cur"
echo "Deleting mail from $DIR/cur/"
$SALEARN $USER "$DIR/cur"
rm -f $DIR/cur/*
done
SALEARN="/usr/share/atomic-mail-scanner/users/spam-learner.sh"
for i in `find /var/qmail/mailnames/ -name .Learn\ Spam -type d |sed s/Learn\ Spam/Learn_Spam/ `; do
USER=`echo "$i"| awk -F\/ '{print $6"@"$5}' |grep -v ^@`
DIR=`echo $i | sed s/Learn_Spam/Learn\ Spam/`
echo "Processing SPAM for $USER"
#echo "$DIR/cur"
#ls -la "$DIR/cur"
$SALEARN $USER "$DIR/cur"
echo "Deleting mail from $DIR/cur/"
rm -f $DIR/cur/*
#exit
done
if [ ! -d $ARCHIVE ]; then
mkdir -p $ARCHIVE
fi
Note: sa-learn can just kill a box in terms of resource usage. My next kooky idea is to modify this so it does it over imap, that way it can run on remote folders and offload some of the processessing to another box.