From: epg <> Date: Sun, 13 Oct 2002 16:22:00 +0000 (+0000) Subject: Factor out the razor-check spam stuff. Instead, read ~/.mincspam if X-Git-Url: https://diplodocus.org/git/minc/commitdiff_plain/7c1bfa6b8b4bcffad83a556fc90e3011eb311d7d?hp=5e73c433e4a41e0ae6ae0ed1ace34e1efb90841a Factor out the razor-check spam stuff. Instead, read ~/.mincspam if it exists, otherwise define a dummy is_spam function. Document this. --- diff --git a/minc b/minc index 05bdd30..de70961 100755 --- 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. +=item $HOME/.mincspam + +If this file exists, minc will include it with the expectation that it +will define a B 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. @@ -148,6 +159,14 @@ Where minc logs what it would do; used in -n mode. our %FILTERS; require "$HOME/.mincfilter"; +if (-f "$HOME/.mincspam") { + require "$HOME/.mincspam"; +} else { + sub is_spam { + return 0; + } +} + my $mh; my $logfile; @@ -453,64 +472,9 @@ sub get_headers { return %headers; } - ############################################################################### # 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 = ; - 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;