user/dev discussion of public-inbox itself
 help / color / Atom feed
* [PATCH 0/2] examples/unsubscribe.milter updates
@ 2020-01-10 22:55 Eric Wong
  2020-01-10 22:55 ` [PATCH 1/2] examples/unsubscribe.milter: skip gmane-mx Eric Wong
  2020-01-10 22:55 ` [PATCH 2/2] examples/unsubscribe.milter: support unique mailto: Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2020-01-10 22:55 UTC (permalink / raw)
  To: meta

It's been a while since I've done anything with this, but
gmane is getting a new domain and I encountered a user
whose MUA favored mailto: in List-Unsubscribe rather than
https://

Eric Wong (2):
  examples/unsubscribe.milter: skip gmane-mx
  examples/unsubscribe.milter: support unique mailto:

 examples/unsubscribe-milter@.service |  6 +++++
 examples/unsubscribe.milter          | 37 +++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 1 deletion(-)

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

* [PATCH 1/2] examples/unsubscribe.milter: skip gmane-mx
  2020-01-10 22:55 [PATCH 0/2] examples/unsubscribe.milter updates Eric Wong
@ 2020-01-10 22:55 ` Eric Wong
  2020-01-10 22:55 ` [PATCH 2/2] examples/unsubscribe.milter: support unique mailto: Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2020-01-10 22:55 UTC (permalink / raw)
  To: meta

Mail to gmane is being delivered to gmane-mx.org, nowadays, and
we don't want ordinary readers to be able to trigger unconfirmed
unsubscription off any mailing lists which go through our
unsubscribe.milter.

https://lars.ingebrigtsen.no/2020/01/06/whatever-happened-to-news-gmane-org/
---
 examples/unsubscribe.milter | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/unsubscribe.milter b/examples/unsubscribe.milter
index d6db766a..f7bf6f1d 100644
--- a/examples/unsubscribe.milter
+++ b/examples/unsubscribe.milter
@@ -75,7 +75,7 @@ $cbs{header} = sub {
 # We don't want people unsubscribing archivers:
 sub archive_addr {
 	my ($addr) = @_;
-	return 1 if ($addr =~ /\@m\.gmane\.org\z/);
+	return 1 if ($addr =~ /\@m\.gmane(?:-mx)?\.org\z/);
 	return 1 if ($addr eq 'archive@mail-archive.com');
 	0
 }

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

* [PATCH 2/2] examples/unsubscribe.milter: support unique mailto:
  2020-01-10 22:55 [PATCH 0/2] examples/unsubscribe.milter updates Eric Wong
  2020-01-10 22:55 ` [PATCH 1/2] examples/unsubscribe.milter: skip gmane-mx Eric Wong
@ 2020-01-10 22:55 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2020-01-10 22:55 UTC (permalink / raw)
  To: meta

Instead of providing a generic "mailto:foo+unsubscribe@example.com"
address in List-Unsubscribe which requires confirmation, replace it
with a mailto: header with a unique subject which contains the same
unique ID we put in the https:// URL.

This makes it easier for some MUAs without https:// support to
unsubscribe with a single action via the List-Unsubscribe header.
---
 examples/unsubscribe-milter@.service |  6 +++++
 examples/unsubscribe.milter          | 35 ++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/examples/unsubscribe-milter@.service b/examples/unsubscribe-milter@.service
index 98e3d478..eb5dcbe4 100644
--- a/examples/unsubscribe-milter@.service
+++ b/examples/unsubscribe-milter@.service
@@ -14,6 +14,12 @@ After = unsubscribe-milter.socket
 # copy+paste errors
 # umask 077 && dd if=/dev/urandom bs=16 count=1 of=.unsubscribe.key
 ExecStart = /usr/local/sbin/unsubscribe.milter /home/mlmmj/.unsubscribe.key
+
+# UNIQUE_MAILTO makes the List-Unsubscribe mailto: header unique
+# so unsubcribing becomes one-step (requires MDA/MTA configuration,
+# see the bottom of examples/unsubscribe.milter
+# Environment = UNIQUE_MAILTO=1
+
 Sockets = unsubscribe-milter.socket
 
 # the corresponding PSGI app needs permissions to modify the
diff --git a/examples/unsubscribe.milter b/examples/unsubscribe.milter
index f7bf6f1d..266596fa 100644
--- a/examples/unsubscribe.milter
+++ b/examples/unsubscribe.milter
@@ -16,6 +16,10 @@ if (read($fh, $key, 8) != 8 || read($fh, $iv, 8) != 8 ||
 	die "KEY_FILE must be 16 bytes\n";
 }
 
+# optionally support unique mailto: subject in List-Unsubscribe,
+# requires a custom rule in front of mlmmj, see __END__
+my $unique_mailto = $ENV{UNIQUE_MAILTO};
+
 # these parameters were chosen to generate shorter parameters
 # to reduce the possibility of copy+paste errors
 my $crypt = Crypt::CBC->new(-key => $key,
@@ -102,6 +106,12 @@ $cbs{eom} = sub {
 			next unless $k && $v && $list && $domain;
 			my $u = $crypt->encrypt($rcpt[0]);
 			$u = encode_base64url($u);
+			if ($unique_mailto) {
+				# $u needs to be in the Subject: header since
+				# +$EXTENSION is case-insensitive
+				my $s = "subject=$u";
+				$v = "<mailto:$list+unique-unsub\@$domain?$s>";
+			}
 			$v .= ",\n <https://$domain/u/$u/$list>";
 
 			$ctx->chgheader($k, $index, $v);
@@ -132,3 +142,28 @@ if ($fds && (($ENV{LISTEN_PID} || 0) == $$)) {
 
 $milter->register('unsubscribe', \%cbs, SMFI_CURR_ACTS);
 $milter->main();
+__END__
+# TMPMSG comes from dc-dlvr, it's populated before the above runs:
+# TMPMSG=$(mktemp -t dc-dlvr.orig.$USER.XXXXXX || exit 1)
+# cat >$TMPMSG
+
+# I use something like this in front of mlmmj for UNIQUE_MAILTO
+# $EXTENSION and $ORIGINAL_RECIPIENT are set by postfix, $list
+# is a local mapping of addresses to mailing list names.
+case $ORIGINAL_RECIPIENT in
+foo+*) list=foo ;;
+# ...
+esac
+
+case $EXTENSION in
+unique-unsub)
+	u="$(formail -z -c -x Subject <$TMPMSG)"
+	d=$(expr "$ORIGINAL_RECIPIENT" : '^.*@\(.*\)')
+
+	# forward this to the unsubscribe.psgi service
+	curl -sSf https://$d/u/$u/$list >/dev/null
+	exit
+	;;
+esac
+/usr/bin/mlmmj-receive -L /path/to/mlmmj-spool/$list <"$TMPMSG"
+exit

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 22:55 [PATCH 0/2] examples/unsubscribe.milter updates Eric Wong
2020-01-10 22:55 ` [PATCH 1/2] examples/unsubscribe.milter: skip gmane-mx Eric Wong
2020-01-10 22:55 ` [PATCH 2/2] examples/unsubscribe.milter: support unique mailto: Eric Wong

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror http://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git