From a04e88267c59ff3e5b9202a272ba9c81ed8e8133 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sun, 21 May 2006 00:08:57 +0000 Subject: Remove the -d mess git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@97 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- spamassassin/sa-bogofilter/Bogofilter.pm | 46 +++++++++----------------------- 1 file changed, 13 insertions(+), 33 deletions(-) (limited to 'spamassassin') diff --git a/spamassassin/sa-bogofilter/Bogofilter.pm b/spamassassin/sa-bogofilter/Bogofilter.pm index b448430..b6350ad 100644 --- a/spamassassin/sa-bogofilter/Bogofilter.pm +++ b/spamassassin/sa-bogofilter/Bogofilter.pm @@ -1,7 +1,7 @@ package Bogofilter; # # Copyright (c) 2004, 2005 Josh Harding -# http://www.statewidesoftware.com/projects.shtml +# http://www.statewidesoftware.com/projects.shtml # # 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 @@ -17,6 +17,15 @@ package Bogofilter; # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # +# Copyright (c) 2006 Peter Palfrader +# Changes: +# 2006-05-21: remove all of the code that creates per user +# files for bogofilter based on Received header +# lines. No longer pass -d to bogofilter. +# It will therefore use $HOME/.bogofilter or something +# equally sensible. + + use strict; use Mail::SpamAssassin; use Mail::SpamAssassin::Plugin; @@ -42,14 +51,9 @@ sub check_bogofilter { if ( ! exists $permsgstatus->{bogoscore} ) { my $tmpfile = $permsgstatus->create_fulltext_tmpfile($fulltext); Mail::SpamAssassin::dbg("BOGOFILTER: permsgstatus $permsgstatus"); - my $to = $permsgstatus->get('Received'); - $to =~ /for (\S+\@\S+);/; - my $received = $1; - $received = lc($received); - $received = $self->stripUser($received); - my $cmd = "bogofilter -d /var/lib/bogofilter/$received -v < $tmpfile"; + my $cmd = "bogofilter -v < $tmpfile"; $return = `$cmd`; - Mail::SpamAssassin::dbg("BOGOFILTER: ran $cmd for $received"); + Mail::SpamAssassin::dbg("BOGOFILTER: ran $cmd"); Mail::SpamAssassin::dbg("BOGOFILTER: returned $return"); $permsgstatus->delete_fulltext_tmpfile(); $return =~ /spamicity\=([0-9\.]+)/; @@ -77,23 +81,6 @@ sub check_bogofilter { return $isspam; } -sub createUserDir { - my $self = shift; - my $user = shift; - my $dir = '/var/lib/bogofilter/' . $user; - if ( !-e $dir ) { - Mail::SpamAssassin::dbg("BOGOFILTER: gotta create directory! $dir"); - mkdir $dir; - } -} - -sub stripUser { - my $self = shift; - my $email = shift; - $email =~ /([A-Za-z\-\_]+?)\@/; - return $1; -} - sub autolearn { my ( $self, $opts ) = @_; my $isspam = $opts->{isspam}; @@ -101,18 +88,11 @@ sub autolearn { "BOGOFILTER: message being learned as $isspam"); my $to = $opts->{permsgstatus}->get('Received'); Mail::SpamAssassin::Plugin::dbg("BOGOFILTER: Received $to"); - $to =~ /for (\S+\@\S+);/; - my $received = $1; - $received = lc($received); - Mail::SpamAssassin::Plugin::dbg("BOGOFILTER: delivery to: $received"); - $to = $self->stripUser($received); - Mail::SpamAssassin::Plugin::dbg("BOGOFILTER: message was sent to: $to"); - $self->createUserDir($to); my $msg = $opts->{permsgstatus}->get_message(); my $fulltext = $msg->get_pristine(); my $tmpfile = $opts->{permsgstatus}->create_fulltext_tmpfile($fulltext); Mail::SpamAssassin::Plugin::dbg("BOGOFILTER: outut to $tmpfile"); - my $bogofilterargs = "-d /var/lib/bogofilter/$to "; + my $bogofilterargs = ""; if ($isspam) { $bogofilterargs .= "-s"; -- cgit v1.2.3