The patch is for version 1,24 of qmail-scanner and 0,93 of bogofilter.
I hope that it serves to them, and they add it to the official version of qmail-scanner
Pablo Castorino
PS: the data base of bogofilter must have permissions of writing for the group that uses to qmail-scanner
|
Desarrollador de CastorinoP Sistemas Mandrakelinux Community 10.1 |
Index: configure
===================================================================
--- configure (revisión: 1)
+++ configure (copia de trabajo)
@@ -38,7 +38,7 @@
VERSION=`grep '^# Version: ' qmail-scanner-queue.template`
VERSION=`echo $VERSION|awk '{print $NF}'`
-SUPPORTED_SCANNERS="clamscan,clamdscan,sweep,sophie,vscan,trophie,uvscan,csav,antivir,kavscanner,AvpLinux,kavdaemon,AvpDaemonClient,fsav,fprot,inocucmd,vexira,bitdefender,nod32,verbose_spamassassin,fast_spamassassin"
+SUPPORTED_SCANNERS="clamscan,clamdscan,sweep,sophie,vscan,trophie,uvscan,csav,antivir,kavscanner,AvpLinux,kavdaemon,AvpDaemonClient,fsav,fprot,inocucmd,vexira,bitdefender,nod32,verbose_spamassassin,fast_spamassassin,bogofilter"
SILENT_VIRUSES='klez,bugbear,hybris,yaha,braid,nimda,tanatos,sobig,winevar,palyh,fizzer,gibe,cailont,lovelorn,swen,dumaru,sober,hawawi,holar-i,mimail,poffer,bagle,worm.galil,mydoom,worm.sco,tanx,novarg,[EMAIL PROTECTED]'
@@ -129,7 +129,8 @@
--skip-setuid-test) SKIP_SETUID_TEST=1 ; if [ "$2" != "" -a "`echo $2|grep '\-'`" = "" ] ; then shift ; if [ "`echo $1|egrep -i '^1|^yes'`" != "" ]; then SKIP_SETUID_TEST="1" ; fi ; if [ "`echo $1|egrep -i '^[1-9]+$'`" != "" ]; then SKIP_SETUID_TEST="$1" ; fi ; if [ "`echo $1|egrep -i '^0|^no'`" != "" ]; then SKIP_SETUID_TEST="0" ; fi ; fi ;;
--qmail-queue-binary) if [ "$2" != "" ] ; then shift ; fi ; QMAILQUEUE_BIN="$1" ;;
--mime-unpacker) if [ "$2" != "" ] ; then shift ; fi ; MIME_UNPACKER="$1" ;;
- --install) INSTALLIT="1" ; if [ "$2" != "" -a "`echo $2|grep '\-'`" = "" ] ; then shift ; fi ;;
+ --install) INSTALLIT="1" ; if [ "$2" != "" -a "`echo $2|grep '\-'`" = "" ] ; then shift ; fi ;;
+ --bogofilter-dir) if [ "$2" != "" ] ; then shift ; fi ; BOGOFILTER_DIR="$1" ;;
*) cat <<EOF >&2
valid options:
@@ -896,6 +897,16 @@
fi
fi
fi
+ if [ "`echo $FIND_SCANNERS|grep bogofilter`" != "" -a "$BOGOFILTER_BINARY" = "" ]; then
+ if test -x $dir/bogofilter
+ then
+ BOGOFILTER_BINARY="$dir/bogofilter"
+ BOGOFILTER_OPTIONS="-p -u -e"
+ if [ "$BOGOFILTER_DIR" != "" ]; then
+ BOGOFILTER_OPTIONS="$BOGOFILTER_OPTIONS -d $BOGOFILTER_DIR"
+ fi
+ fi
+ fi
if [ "`echo $FIND_SCANNERS|grep spamassassin`" != "" -a "$SPAMASSASSIN_BINARY" = "" ]; then
if test -x $dir/spamassassin
then
@@ -1380,6 +1391,10 @@
SCANNER_ARRAY="$SCANNER_ARRAY,\"verbose_spamassassin\""
fi
fi
+if [ "$BOGOFILTER_BINARY" != "" ]; then
+ echo "bogofilter=$BOGOFILTER_BINARY";
+ SCANNER_ARRAY="$SCANNER_ARRAY,\"bogofilter\""
+fi
USERNAME=${USERNAME:-$LOGNAME}
@@ -1623,6 +1638,9 @@
s?SPAMC_BINARY?$SPAMC_BINARY?g;
s?SPAMC_OPTIONS?$SPAMC_OPTIONS?g;
s?SPAMC_SUBJECT?$SPAMC_SUBJECT?g;
+s?BOGOFILTER_BINARY?$BOGOFILTER_BINARY?g;
+s?BOGOFILTER_OPTIONS?$BOGOFILTER_OPTIONS?g;
+s?BOGOFILTER_SUBJECT?$BOGOFILTER_SUBJECT?g;
s?USERNAME?$USERNAME?g;
s?SKIP_TEXT_MSGS?$SKIP_TEXT_MSGS?g;
s?FQDN?$FQDN?g;
Index: qmail-scanner-queue.template
===================================================================
--- qmail-scanner-queue.template (revisión: 1)
+++ qmail-scanner-queue.template (copia de trabajo)
@@ -220,6 +220,9 @@
my $spamc_options='SPAMC_OPTIONS';
my $spamc_subject='SPAMC_SUBJECT';
my $spamassassin_binary='SPAMASSASSIN_BINARY';
+my $bogofilter_binary="BOGOFILTER_BINARY";
+my $bogofilter_options="BOGOFILTER_OPTIONS";
+my $bogofilter_subject="BOGOFILTER_SUBJECT";
my ($sa_comment,$sa_level);
my $sa_symbol='+';
my ($tag_score)="";
@@ -1224,7 +1227,7 @@
#Just run virus scanners over mail that isn't plain text
if ($plain_text_msg) {
#If it's plain text - just run anti-spam checks
- &{$scanner} if ($scanner =~ /spam/i);
+ &{$scanner} if ($scanner =~ /spam/i || $scanner =~ /bogo/i);
}else {
&{$scanner};
}
@@ -1489,7 +1492,7 @@
sub scan_queue {
my ($scanner,$SCANINFO,$files,$sweep_eng,$sweep_product,$sophie_eng,$dir);
my $start_scan_time =time;
- my ($inocucmd_eng,$inocucmd_product,$spamassassin_eng);
+ my ($inocucmd_eng,$inocucmd_product,$spamassassin_eng,$bogofilter_version);
chdir($scandir);
&debug("s_q: re-create the quarantine version file");
@@ -1713,6 +1716,17 @@
}
close(SPAS);
$SCANINFO .= "spamassassin: $spamassassin_eng. ";
+ } elsif ($scanner eq "bogofilter") {
+ #X-Spam-Checker-Version: SpamAssassin 2.01
+ open(SPAS,"$bogofilter_binary -V 2>&1 |")||die "failed to call $bogofilter_binary -V - $!";
+ while (<SPAS>) {
+ chomp;
+ if (/^bogofilter version (.*)$/i) {
+ $bogofilter_version=$1;
+ }
+ }
+ close(SPAS);
+ $SCANINFO .= "bogofilter: $bogofilter_version. ";
} else {
#Catch-all for other ones
$SCANINFO .= "$scanner: ???. ";
Index: sub-bogofilter.pl
===================================================================
--- sub-bogofilter.pl (revisión: 0)
+++ sub-bogofilter.pl (revisión: 7)
@@ -0,0 +1,51 @@
+sub bogofilter {
+ #Only run BF if mail is from a "remote" SMTP client, or QS_BOGOFILTER
+ #is defined via tcpserver...
+ if (defined($ENV{'RELAYCLIENT'}) && !defined($ENV{'QS_BOGOFILTER'})) {
+ &debug("BF: don't scan as RELAYCLIENT implies this was sent by a local user");
+ return;
+ }
+ #bogofilter
+ my ($bogofilter_found);
+ my ($start_bogofilter_time)=[gettimeofday];
+ my ($DD,$bogofilter_status,$stop_bogofilter_time,$bogofilter_time);
+ my ($bf_status)=0;
+ my ($bf_score)=0; my ($bf_max)=0;
+ my ($bf_version);
+ &debug("BF: run $bogofilter_binary $bogofilter_options < $scandir/$wmaildir/new/$file_id");
+ open(BF,"$bogofilter_binary $bogofilter_options < $scandir/$wmaildir/new/$file_id|")||&tempfail("cannot run $bogofilter_binary < $scandir/$wmaildir/new/$file_id - $!");
+ open(SOUT,">$scandir/$wmaildir/new/$file_id.bogof")||&tempfail("cannot open for write $scandir/$wmaildir/new/$file_id.bogof - $!");
+ while (<BF>) {
+ if (/^X-Bogosity: (Spam|Unsure), tests=bogofilter, spamicity=(.*), version=(.*)/) {
+ $bf_status=1 if ($1 eq "Spam");
+ $bf_score=$2;$bf_version=$3;
+ }
+ print SOUT;
+ }
+ close(SA);
+ $bogofilter_status=($? >> 8);
+ $bf_status = $bogofilter_status if ($bogofilter_options !~ /\-e/);
+ close(SOUT);
+
+ $bf_score="0" if (!$bf_score);
+
+ if ($bogofilter_options =~ /\-e/ && -s "$scandir/$wmaildir/new/$file_id.bogof" && $bogofilter_status == 0) {
+ &debug("BF: overwriting $scandir/$wmaildir/new/$file_id with $scandir/$wmaildir/new/$file_id.bogof");
+ rename ("$scandir/$wmaildir/new/$file_id.bogof","$scandir/$wmaildir/new/$file_id");
+ } else {
+ unlink("$scandir/$wmaildir/new/$file_id.bogof");
+ }
+ &debug("BF: bf_status=$bf_status, options=$bogofilter_options");
+ if ($bf_status == 0) {
+ $tag_score .= "BF:0($bf_score):";
+ $sa_comment = "No, Score:$bf_score" if ($bogofilter_options =~ /\-v/);
+ &debug("BF: no SPAM ($sa_comment)");
+ } else {
+ $tag_score .= "BF:1($bf_score):";
+ $sa_comment = "Yes, Score:$bf_score" if ($bogofilter_options =~ /\-v/);
+ &debug("BF: yup, this smells like SPAM");
+ }
+ $stop_bogofilter_time=[gettimeofday];
+ $bogofilter_time = tv_interval ($start_bogofilter_time, $stop_bogofilter_time);
+ &debug("BF: finished scan of dir \"$scandir/$file_id\" in $bogofilter_time secs");
+}
