From 8dbc021592be6992b33afbee6b9d91d1990766bf Mon Sep 17 00:00:00 2001 From: short <> Date: Tue, 27 Jul 2004 06:59:09 +0000 Subject: [PATCH] razor2 -> spamassassin --- PerlMail/Config.pm | 4 ++-- perlmail-accept | 24 +++++++----------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/PerlMail/Config.pm b/PerlMail/Config.pm index dc9f756..9735762 100644 --- a/PerlMail/Config.pm +++ b/PerlMail/Config.pm @@ -43,7 +43,7 @@ require Mail::Alias; BEGIN { for (qw(headerhas store headeris did dnsbl store_muttrc_alternates Received_for parts_linear mime_type - body_first mimehead razor2 header_remap)) { + body_first mimehead spamassassin header_remap)) { eval 'sub '.$_.' { return ::'.$_.'(@_); }'; } } @@ -206,7 +206,7 @@ sub audit # Do not local $store_file as it is our-imported $store_profile="silent"; local $_; - store "=spam".($_ eq 1 ? "" : ";$_") if $_=razor2(); + store "=spam".($_ eq 1 ? "" : ";$_") if $_=spamassassin(); }; $store_profile=undef(); return if did sub { diff --git a/perlmail-accept b/perlmail-accept index dad2bd3..c4fa61e 100755 --- a/perlmail-accept +++ b/perlmail-accept @@ -487,32 +487,22 @@ my($message)=@_; # utility functions: # return: true (error-message or "1") if is spam -sub razor2 +sub spamassassin { - # razor-check has exit code 1 if NOT spam, code 0 if IS spam + # spamassassin has exit code 1 if IS spam, code 0 if NOT spam local *CHILD; - local $SIG{"PIPE"}=sub { warn "razor2 gave me SIGPIPE: broken pipe"; }; + local $SIG{"PIPE"}=sub { warn "spamassassin gave me SIGPIPE: broken pipe"; }; # prevent Razor2's: Can't call method "log" on unblessed reference at Razor2/Client/Agent.pm line 212. local $ENV{"HOME"}=$HOME; - open CHILD,'|' - .'('.'(razor-check 2>&1;echo >&3 $?)' - .'|sed "s/^/razor-check: /"' - .'|logger -t "perlmail['.$$.']" -p mail.crit' - .') 3>&1' - .'|exit `cat`' + open CHILD,'|spamassassin --exit-code --mbox >/dev/null' or return 0; print CHILD $Message; - my $return; - { - local $/=undef(); - $return= || 1; - } - close CHILD; + my $return=close CHILD; return undef() if !WIFEXITED($?); return undef() if WIFSIGNALED($?); return undef() if WIFSTOPPED($?); - return undef() if WEXITSTATUS($?); - return $return; # is-spam + return 1 if WEXITSTATUS($?); # is-spam + return 0; # not-spam } # NOTE: returns undef() if !wantarray and the first header is unrecognized -- 1.8.3.1