unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] mda: support --no-precheck option
@ 2019-10-16  0:39 Eric Wong
  2019-10-16  4:42 ` Kyle Meyer
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2019-10-16  0:39 UTC (permalink / raw)
  To: meta

Since -mda now supports List-ID to better support mirroring of
existing mailing lists, it probably makes sense to support
disabling the precheck function to provide more accurate (though
potentially spammier) mirrors of lists
---
 Documentation/public-inbox-mda.pod | 25 +++++++++++++++++++++++++
 script/public-inbox-mda            |  7 +++++--
 t/mda.t                            | 15 +++++++++++++++
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/Documentation/public-inbox-mda.pod b/Documentation/public-inbox-mda.pod
index 921b7a15..15bf4d84 100644
--- a/Documentation/public-inbox-mda.pod
+++ b/Documentation/public-inbox-mda.pod
@@ -16,6 +16,31 @@ By default, it relies on L<spamc(1)> for filtering mail,
 but may be disabled via
 L<public-inbox-config(5)/publicinboxmda.spamcheck>
 
+=head1 OPTIONS
+
+=over 8
+
+=item --no-precheck
+
+By default, public-inbox-mda does some simple checks before
+invoking L<spamc(1)> since it is intended to receive mail before
+it goes to a mailing list.
+
+Howeever, some users prefer to use public-inbox-mda to mirror
+mailing lists.  This option exists to support those users.
+
+Using this option, the following prechecks are disabled:
+
+  * multiple Message-IDs
+  * non-existent Message-IDs
+  * Message-IDs longer than 244 characters long
+  * From: header shorter than 3 characters
+  * Subject: header shorter than 2 characters
+  * unusable Date: headers
+  * inbox address specified in To: or Cc: header
+
+=back
+
 =head1 ENVIRONMENT
 
 =over 8
diff --git a/script/public-inbox-mda b/script/public-inbox-mda
index 2655a6c5..9b8753da 100755
--- a/script/public-inbox-mda
+++ b/script/public-inbox-mda
@@ -5,7 +5,8 @@
 # Mail delivery agent for public-inbox, run from your MTA upon mail delivery
 use strict;
 use warnings;
-my $usage = 'public-inbox-mda < rfc2822_message';
+my $usage = 'public-inbox-mda [OPTIONS] < rfc2822_message';
+my $precheck = grep(/\A--no-precheck\z/, @ARGV) ? 0 : 1;
 my ($ems, $emm);
 
 sub do_exit {
@@ -55,7 +56,9 @@ $dst->{mainrepo} or do_exit(67);
 $dst = PublicInbox::InboxWritable->new($dst);
 
 # pre-check, MDA has stricter rules than an importer might;
-do_exit(0) unless PublicInbox::MDA->precheck($simple, $dst->{address});
+if ($precheck && !PublicInbox::MDA->precheck($simple, $dst->{address})) {
+	do_exit(0);
+}
 $simple = undef;
 my $spam_ok;
 if ($spamc) {
diff --git a/t/mda.t b/t/mda.t
index 3cab590b..92e8ad0d 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -293,6 +293,21 @@ EOF
 	my $path = mid2path($mid);
 	my $msg = `git --git-dir=$maindir cat-file blob HEAD:$path`;
 	like($msg, qr/\Q$list_id\E/, 'delivered message w/ List-ID matches');
+
+	# try a message w/o precheck
+	$simple = Email::Simple->new(<<EOF);
+To: You <you\@example.com>
+List-Id: <$list_id>
+
+this message would not be accepted without --no-precheck
+EOF
+	$in = $simple->as_string;
+	my ($out, $err) = ('', '');
+	IPC::Run::run([$mda, '--no-precheck'], \$in, \$out, \$err);
+	is($?, 0, 'mda OK with List-Id match and --no-precheck');
+	my $cur = `git --git-dir=$maindir diff HEAD~1..HEAD`;
+	like($cur, qr/this message would not be accepted without --no-precheck/,
+		'--no-precheck delivered message anyways');
 }
 
 done_testing();

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mda: support --no-precheck option
  2019-10-16  0:39 [PATCH] mda: support --no-precheck option Eric Wong
@ 2019-10-16  4:42 ` Kyle Meyer
  2019-10-16  8:13   ` Eric Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle Meyer @ 2019-10-16  4:42 UTC (permalink / raw)
  To: Eric Wong, meta

Hello,

Just a drive-by typo comment.

Eric Wong <e@80x24.org> writes:

> +=item --no-precheck
> +
> +By default, public-inbox-mda does some simple checks before
> +invoking L<spamc(1)> since it is intended to receive mail before
> +it goes to a mailing list.
> +
> +Howeever, some users prefer to use public-inbox-mda to mirror

s/Howeever/However/

-- 
Kyle

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mda: support --no-precheck option
  2019-10-16  4:42 ` Kyle Meyer
@ 2019-10-16  8:13   ` Eric Wong
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Wong @ 2019-10-16  8:13 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: meta

Kyle Meyer <kyle@kyleam.com> wrote:
> Hello,
> 
> Just a drive-by typo comment.
> 
> Eric Wong <e@80x24.org> writes:
> > +Howeever, some users prefer to use public-inbox-mda to mirror
> 
> s/Howeever/However/

Thanks!  Fixed and pushed :>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-16  8:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-16  0:39 [PATCH] mda: support --no-precheck option Eric Wong
2019-10-16  4:42 ` Kyle Meyer
2019-10-16  8:13   ` Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).