diff options
author | Eric Wong <e@80x24.org> | 2016-06-24 01:15:13 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-06-24 02:00:26 +0000 |
commit | c515264dd69156fc89c59685f788b1093afb8731 (patch) | |
tree | ada1a21aa82b369dbe1ac8c865474a9318228f7d /script/public-inbox-mda | |
parent | 3c24b7e7e47be9646226d921897cc9ec92e9be8a (diff) | |
download | public-inbox-c515264dd69156fc89c59685f788b1093afb8731.tar.gz |
This should hopefully make it easier to try other anti-spam systems (or none at all) in the future.
Diffstat (limited to 'script/public-inbox-mda')
-rwxr-xr-x | script/public-inbox-mda | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/script/public-inbox-mda b/script/public-inbox-mda index 013642d0..f739ad06 100755 --- a/script/public-inbox-mda +++ b/script/public-inbox-mda @@ -24,7 +24,7 @@ use PublicInbox::Import; use PublicInbox::Git; use PublicInbox::Emergency; use PublicInbox::Filter::Base; -use PublicInbox::Spawn qw(popen_rd); +use PublicInbox::Spamcheck::Spamc; # n.b: hopefully we can setup the emergency path without bailing due to # user error, we really want to setup the emergency destination ASAP @@ -44,9 +44,9 @@ my $main_repo = $dst->{mainrepo} or do_exit(1); # pre-check, MDA has stricter rules than an importer might; do_exit(0) unless PublicInbox::MDA->precheck($simple, $dst->{address}); - +my $spamc = PublicInbox::Spamcheck::Spamc->new; $str = ''; -my $spam_ok = do_spamc($ems->fh, \$str); +my $spam_ok = $spamc->spamcheck($ems->fh, \$str); $simple = undef; $emm = PublicInbox::Emergency->new($emergency); $emm->prepare(\$str); @@ -90,20 +90,5 @@ if (defined $im->add($mime)) { $mime->header_obj->header_raw('Message-ID'), " exists\n"; } -do_exit(0); - -# we depend on "report_safe 0" in /etc/spamassassin/*.cf with --headers -sub do_spamc { - my ($in, $out) = @_; - my $rdr = { 0 => fileno($in) }; - my ($fh, $pid) = popen_rd([qw/spamc -E --headers/], undef, $rdr); - defined $pid or die "failed to popen_rd spamc: $!\n"; - my $r; - do { - $r = sysread($fh, $$out, 65536, length($$out)); - } while (defined($r) && $r != 0); - close $fh or die "close failed: $!\n"; - waitpid($pid, 0); - ($? || $$out eq '') ? 0 : 1; -} +do_exit(0); |