#!/bin/sh # XMSpamPre: XMail filter (pre-data) which checks if a host is blacklisted. # Copyright (C) 2006 Jean-Francois Hovinne - http://www.hovinne.com/dev/xmspam/ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details: http://www.gnu.org/licenses/gpl.txt. # USAGE: edit filters.pre-data.tab: # "/usr/sbin/XMSpamPre" "@@REMOTEADDR" BASEDIR="/var/lib/spamassassin/black" DATE=`date +%Y%m%d` SPAMFILE="$BASEDIR/spam-$DATE" BLACKFILE="$BASEDIR/black-$DATE" BLACKLIST="$BASEDIR/blacklist" MAXCOUNT=1 if [ -r "$BLACKFILE" ]; then COUNT=`grep $1 -c -m 1 < $BLACKFILE` if [ "${COUNT}" -gt 0 ]; then if [ -r "$BLACKLIST" ]; then COUNT=`grep $1 -c -m 1 < $BLACKLIST` if [ "${COUNT}" -eq 0 ]; then echo $1 >> $BLACKLIST fi else echo $1 >> $BLACKLIST fi exit 3 fi fi if [ -r "$SPAMFILE" ]; then COUNT=`grep $1 -c -m $MAXCOUNT < $SPAMFILE` if [ "${COUNT}" -ge "$MAXCOUNT" ]; then echo $1 >> $BLACKFILE exit 3 fi else exit 0 fi