summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spamassassin/sa-bogofilter/Bogofilter.pm46
1 files changed, 13 insertions, 33 deletions
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 <josh@statewidesoftware.com>
-# 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 <directory> 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";