Whitelist ??

Michael Gale michael.gale at utilitran.com
Mon Dec 6 23:35:32 CET 2004


Hello,

	At the moment I am using bogofilter to identify spam on our mail 
server. I wanted to add in a whitelist option so people who receive news 
letters, for example PS2 or Xbox reviews can have that e-mail be handed 
differently. I don't want to train bogofilter with these messages.

At the moment I have a header check look for "X-Bogosity: Spam" and if 
found redirect the message to the users virtual account. This is where 
all spam for that user would get sent ... to be later reviewed.

I made the following changes to the script provided in my bogofilter tgz 
file. It checks the "From" address of the message, this is not the 
evelop from address. And if a match is found it switch the SPAM header 
tag to "Whitelisted" instead. So it bypasses the filter.

I tested it with a few messages ... but before we go live can anybody 
see anything wrong with it.

Also is there away to read standard in twice ... once to check the 
whitelisting option and again for the remained of the script ?


Thanks.

With whitelist ...

--snip--
#!/bin/sh

FILTER=/usr/local/bin/bogofilter
FILTER_DIR=/home/clamav/bogofilter/filter
POSTFIX=/usr/sbin/sendmail
export BOGOFILTER_DIR=/home/clamav/bogofilter

# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

cd $FILTER_DIR || \
     { echo $FILTER_DIR does not exist; exit $EX_TEMPFAIL; }

# Clean up when done or when aborting.
trap "rm -f msg.$$ ; exit $EX_TEMPFAIL" 0 1 2 3 15

# bogofilter -e returns: 0 for OK, nonzero for error
rm -f msg.$$ || exit $EX_TEMPFAIL

whitelistdir=`grep -i ${2} /etc/postfixvirtual/vmailbox | gawk '{print $2}'`

if [ `grep -c -i -f $BOGOFILTER_DIR/whitelist/$whitelistdir/whitelist > 
/dev/null` ]; then
         $FILTER -l -p -e --spamicity_tags="Whitelisted,Ham,Unsure" > 
msg.$$ || exit $EX_TEMPFAIL
else
         $FILTER -l -p -e > msg.$$ || exit $EX_TEMPFAIL
fi

exec <msg.$$ || exit $EX_TEMPFAIL
#cp msg.$$ /home/clamav/bogofilter/mail_archive/msg.$$
rm -f msg.$$ # safe, we hold the file descriptor
exec $POSTFIX "$@"
exit $EX_TEMPFAIL
--snip--





-- 
Michael Gale
Lan Administrator
Utilitran Corp.

Linux: because a PC is a terrible thing to waste !!!



More information about the Bogofilter mailing list