]> diplodocus.org Git - minc/commitdiff
Factor out the razor-check spam stuff. Instead, read ~/.mincspam if
authorepg <>
Sun, 13 Oct 2002 16:22:00 +0000 (16:22 +0000)
committerepg <>
Sun, 13 Oct 2002 16:22:00 +0000 (16:22 +0000)
it exists, otherwise define a dummy is_spam function.  Document this.

minc

diff --git a/minc b/minc
index 05bdd30d24cfde2d79389661efbc04c419446d83..de70961b0c376f8394006b82677dac689b77b580 100755 (executable)
--- a/minc
+++ b/minc
@@ -133,6 +133,17 @@ if (not $MAILDIR) {
 This file is Perl code (included via the 'require' directive) which is
 expected to define the FILTERS hash.
 
 This file is Perl code (included via the 'require' directive) which is
 expected to define the FILTERS hash.
 
+=item $HOME/.mincspam
+
+If this file exists, minc will include it with the expectation that it
+will define a B<is_spam> function.  This function takes a message
+filename as an argument and returns 1 if the message is spam, else 0.
+If this file does not exist, minc will define a simple function that
+always returns 0.
+
+XXX: need more details about the spam-handling process; for now read
+the code.
+
 =item `mhpath +`/logs/minc.log
 
 Where minc logs what it does, unless in -n mode.
 =item `mhpath +`/logs/minc.log
 
 Where minc logs what it does, unless in -n mode.
@@ -148,6 +159,14 @@ Where minc logs what it would do; used in -n mode.
 our %FILTERS;
 require "$HOME/.mincfilter";
 
 our %FILTERS;
 require "$HOME/.mincfilter";
 
+if (-f "$HOME/.mincspam") {
+    require "$HOME/.mincspam";
+} else {
+    sub is_spam {
+        return 0;
+    }
+}
+
 my $mh;
 my $logfile;
 
 my $mh;
 my $logfile;
 
@@ -453,64 +472,9 @@ sub get_headers {
     return %headers;
 }
 
     return %headers;
 }
 
-\f
 ###############################################################################
 # Spam handling
 
 ###############################################################################
 # Spam handling
 
-sub is_spam {
-    my $msg = shift;
-    my $err;
-    my $sig;
-    my $line;
-    my $message;
-    my $status;
-
-    $err = $sig = $msg;
-    $err =~ s|/new/|/err/|;
-    $sig =~ s|/new/|/sig/|;
-    if (-f $err) {
-        open(ERR, $err);
-        $line = <ERR>;
-        close(ERR);
-
-        chomp($line);
-        ($message, $!) = split(/:/, $line);
-
-        logerr("$err: $message: $!");
-
-        if ($run) {
-            if (unlink($err) != 1) {
-                err(&EX_OSERR, "Failed unlink($err)");
-            }
-        }
-    } elsif (-f $sig) {
-        # This is supposed to be a signature created with razor-check
-        # directly after delivery.  Currently this isn't supported
-        # because it isn't clear to me how to get that signature back
-        # into razor-check.  For now, just unlink any sig files we
-        # find and proceed with full razor-check mode.
-
-        if ($run) {
-            if (unlink($sig) != 1) {
-                err(&EX_OSERR, "Failed unlink($sig)");
-            }
-        }
-    }
-
-    if ($run) {
-        $status = system("razor-check < $msg");
-        if (not WIFEXITED($status)) {
-            err(&EX_OSERR, "Failed to run razor-check < $msg");
-        } elsif (WEXITSTATUS($status) == 0) {
-            return 1;
-        } else {
-            return 0;
-        }
-    } else {
-        return 0;
-    }
-}
-
 sub kill_spam {
     my @msglist = @_;
     my @result;
 sub kill_spam {
     my @msglist = @_;
     my @result;