You may recall I reported a weird `File exists' bug with libdb/DB_File hitting autowhitelists. I've fixed it.
It's not a spamassassin or Perl problem; it's a libdb problem. It seems that libdb internal symbols in libdb2 and libdb3 conflict, even though the names do not and the libdb docs say you can use both simultaneously in the same binary. So libdb2 routines end up calling libdb3 ones, yielding disaster. I've upgraded to libdb4 sitewide now, and everything is peachy. :) Oh, and have a truly hideous hack (no testcases yet) to let you shove razor reports at random external programs instead of at razor. (I use it in conjunction with a couple of scripts and `razor-report -H', to send razor reports up to the server when I'm online, regardless of when I generated them.) Index: spamassassin/lib/Mail/SpamAssassin/Conf.pm =================================================================== RCS file: /cvsroot/spamassassin/spamassassin/lib/Mail/SpamAssassin/Conf.pm,v retrieving revision 1.54 diff -u -r1.54 Conf.pm --- spamassassin/lib/Mail/SpamAssassin/Conf.pm 20 Feb 2002 03:13:20 -0000 1.54 +++ spamassassin/lib/Mail/SpamAssassin/Conf.pm 17 Mar 2002 01:24:37 -0000 @@ -92,6 +92,7 @@ $self->{spamtrap_template} = ''; $self->{razor_config} = $main->sed_path ("~/razor.conf"); + $self->{razor_program} = undef; # this will be sedded by whitelist implementations, so ~ is OK $self->{auto_whitelist_path} = "~/.spamassassin/auto-whitelist"; @@ -642,6 +643,19 @@ if (/^razor[-_]config\s*(.*)\s*$/) { $self->{razor_config} = $1; next; + } + +=item razor_program binary + +Define the name of a binary, if any, that stands in place of Razor's +Perl layer to report spams to Razor. It should accept all C<razor-report>'s +switches, and generally act like C<razor-report>. +By default this is empty, meaning to use Razor's Perl layer. + +=cut + + if (/^razor[-_]program\s*(.*)\s*$/) { + $self->{razor_program} = $1; next; } =item auto_whitelist_path /path/to/file (default: ~/.spamassassin/auto-whitelist) Index: spamassassin/lib/Mail/SpamAssassin/Reporter.pm =================================================================== RCS file: /cvsroot/spamassassin/spamassassin/lib/Mail/SpamAssassin/Reporter.pm,v retrieving revision 1.20 diff -u -r1.20 Reporter.pm --- spamassassin/lib/Mail/SpamAssassin/Reporter.pm 30 Dec 2001 02:45:29 -0000 1.20 +++ spamassassin/lib/Mail/SpamAssassin/Reporter.pm 17 Mar 2002 01:24:37 -0000 @@ -56,7 +56,15 @@ dbg ("local tests only, ignoring Razor"); return 0; } - + + if (($self->{main}->{conf}->{razor_program}) && + (! -x $self->{main}->{conf}->{razor_program})) { + $self->{main}->{conf}->{razor_program} = undef; + } else { + dbg ("Razor is available, program-based"); + return 1; + } + eval { require Razor::Client; }; @@ -73,66 +81,78 @@ sub razor_report { my ($self, $fulltext) = @_; - my @msg = split (/^/m, $fulltext); - my $timeout = 10; # seconds - my $response; my $config = $self->{main}->{conf}->{razor_config}; - my %options = ( - 'debug' => $Mail::SpamAssassin::DEBUG - ); - - # razor also debugs to stdout. argh. fix it to stderr... - if ($Mail::SpamAssassin::DEBUG) { - open (OLDOUT, ">&STDOUT"); - open (STDOUT, ">&STDERR"); - } - my $oldslash = $/; + if ($self->{main}->{conf}->{razor_program}) { + eval { + open RAZOR, "|" . $self->{main}->{conf}->{razor_program} or die . "Argh, " . +$self->{main}->{conf}->{razor_program} . " dead"; + local $SIG{PIPE} = sub { die "Razor pipe broke" }; - eval { - require Razor::Client; - require Razor::Agent; - local ($^W) = 0; # argh, warnings in Razor - local ($/); # argh, bugs in Razor - - local $SIG{ALRM} = sub { die "alarm\n" }; - alarm 10; - - my $rc = Razor::Client->new ($config, %options); - die "undefined Razor::Client\n" if (!$rc); - - my $ver = $Razor::Client::VERSION; - if ($ver >= 1.12) { - my $respary = $rc->report ('spam' => \@msg); - for my $resp (@$respary) { $response .= $resp; } - } else { - $response = $rc->report (\@msg); + print RAZOR $fulltext; + + close RAZOR; + } + } else { + my @msg = split (/^/m, $fulltext); + my $timeout = 10; # seconds + my $response; + my %options = ( + 'debug' => $Mail::SpamAssassin::DEBUG + ); + + # razor also debugs to stdout. argh. fix it to stderr... + if ($Mail::SpamAssassin::DEBUG) { + open (OLDOUT, ">&STDOUT"); + open (STDOUT, ">&STDERR"); } - alarm 0; - dbg ("Razor: spam reported, response is \"$response\"."); - }; + my $oldslash = $/; + + eval { + require Razor::Client; + require Razor::Agent; + local ($^W) = 0; # argh, warnings in Razor + local ($/); # argh, bugs in Razor + + local $SIG{ALRM} = sub { die "alarm\n" }; + alarm 10; + + my $rc = Razor::Client->new ($config, %options); + die "undefined Razor::Client\n" if (!$rc); + + my $ver = $Razor::Client::VERSION; + if ($ver >= 1.12) { + my $respary = $rc->report ('spam' => \@msg); + for my $resp (@$respary) { $response .= $resp; } + } else { + $response = $rc->report (\@msg); + } + + alarm 0; + dbg ("Razor: spam reported, response is \"$response\"."); + }; - if ($@) { - if ($@ =~ /alarm/) { - dbg ("razor report timed out after $timeout secs."); - } else { - warn "razor-report failed: $! $@"; + if ($@) { + if ($@ =~ /alarm/) { + dbg ("razor report timed out after $timeout secs."); + } else { + warn "razor-report failed: $! $@"; + } + undef $response; } - undef $response; - } - $/ = $oldslash; + $/ = $oldslash; - if ($Mail::SpamAssassin::DEBUG) { - open (STDOUT, ">&OLDOUT"); - close OLDOUT; - } + if ($Mail::SpamAssassin::DEBUG) { + open (STDOUT, ">&OLDOUT"); + close OLDOUT; + } - if (defined($response) && $response+0) { - return 1; - } else { - return 0; + if (defined($response) && $response+0) { + return 1; + } else { + return 0; + } } } -- `Frankly I wonder whether you are not writing your posts from underneath a bridge.' --- Jason Clifford, to a particularly dense troll _______________________________________________ Spamassassin-talk mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/spamassassin-talk