From 5d2ed652359466822f429a71dcf0f4feb09354f4 Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Wed, 14 Feb 2018 11:32:48 -0600 Subject: [PATCH 01/10] Interim commit. Need to diagnose failure parsing the plist. --- Support/bin/reject | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Support/bin/reject b/Support/bin/reject index 4b257c8..9a529eb 100755 --- a/Support/bin/reject +++ b/Support/bin/reject @@ -4,6 +4,17 @@ ACTION=`defaults read com.freron.MailMate MmMailManCommandAction 2>/dev/null` if [ -z "${ACTION}" ]; then ACTION="openMessage" fi +if [ ! -z ${MM_DEBUG+x} ] && [ $MM_DEBUG ] +then + echo "MM_TO is ${MM_TO}" >> /tmp/MailMan.log +fi +export MM_ADDRESS=`${MM_BUNDLE_SUPPORT}/bin/table_lookup ${MM_TO}` +if [ ! -z ${MM_DEBUG+x} ] && [ $MM_DEBUG ] +then + echo "MM_ADDRESS is ${MM_ADDRESS}" >> /tmp/MailMan.log + echo "ACTION = ${ACTION}." >> /tmp/MailMan.log +fi + cat << END { actions = ( @@ -13,14 +24,16 @@ cat << END headers = { "#posting-style" = "top"; "#signature" = ""; - "from" = "${MM_TO}"; + "from" = "${MM_ADDRESS}"; + "tags" = "Don'tSave"; }; resultActions = ( { type = "${ACTION}"; - } + }; ); - }, + }; ); } END + From 39fea2839bf107f6fb0e10c3d4e5991c210d87c1 Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Wed, 14 Feb 2018 13:27:19 -0600 Subject: [PATCH 02/10] Fix the plist syntax. --- Support/bin/reject | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Support/bin/reject b/Support/bin/reject index 9a529eb..a75d232 100755 --- a/Support/bin/reject +++ b/Support/bin/reject @@ -30,9 +30,9 @@ cat << END resultActions = ( { type = "${ACTION}"; - }; + } ); - }; + }, ); } END From 2b094ae14f44ae4f2f18eed86d04e39aa3d493a2 Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Fri, 16 Feb 2018 10:17:21 -0600 Subject: [PATCH 03/10] Document the enhancements. --- README.mdown | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/README.mdown b/README.mdown index 35cd067..bc71a7b 100644 --- a/README.mdown +++ b/README.mdown @@ -1,4 +1,26 @@ -# Features +# Enhancements + +This "Enhanced MailMan Bundle" is a fork of the MailMan bundle +included with MailMate. It is as the original, however, in order to +handle lists whose delivery includes address rewriting, it allows the +user to save a `.mailman-addresses` file in their home directory, +which is (for now) a perl hash mapping delivery addresses to sender +addresses. That way, when one receives email addressed to +`foobar-list-owner@hosting.com` one can rewrite the address to an +address the mailman instance will accept. + +Currently this is only implemented for the "Reject" messages, since as +a moderator, I have found my task is almost solely rejection. + +## To do: + +* Replace the use of a perl literal with a config file, which will be + safer, but needs to be handled without forcing dependencies on the + user. + +* Extend the address rewriting to acceptance emails. + +# Original Features This bundle groks the `List-*` headers used by MailMan based systems. From b00fe7c7e16f118f90dfb6623361d1da4c30d9f4 Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Fri, 16 Feb 2018 10:18:25 -0600 Subject: [PATCH 04/10] Table lookup script. Perl script allowing translation of original header to address into acceptable replying address. --- Support/bin/table_lookup | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 Support/bin/table_lookup diff --git a/Support/bin/table_lookup b/Support/bin/table_lookup new file mode 100755 index 0000000..bb66b20 --- /dev/null +++ b/Support/bin/table_lookup @@ -0,0 +1,47 @@ +#! /usr/bin/env perl + +my $tableFilename = "$ENV{HOME}/.mailman-addresses"; +my $logfile; +if ( $ENV{"DEBUG_MM"} ) { + $logfile = "/tmp/MailMan.log"; +} else { + $logfile = "/dev/null"; +} +open(LOG, ">>$logfile"); +local $SIG{__DIE__} = sub { + my ($message) = @_; + print LOG "$message\n"; +}; +my %table; +{ + local $/; # enable "slurp" mode + open(FH, "< $tableFilename") or die "Unable to open table file $tableFilename $!"; + local $raw = ; + close FH; +# print "$raw\n"; + %table = %{eval $raw}; +} + +{ + my @keys = sort(keys(%table)); + print LOG "@keys\n"; + + if ( $ARGV[0] eq $keys[0] ) { + print LOG "$ARGV[0] matches a key." + } elsif ( $ARGV[0] ne $keys[0] ) { + print LOG "Surprisingly $ARGV[0] is not equal to $keys[0]\n"; + } + + foreach my $key (@keys) { + print LOG "$key\t$table{$key}\n"; + } +} + +my $INPUT_ADDRESS = $ARGV[0]; +chomp $INPUT_ADDRESS; +#print "$INPUT_ADDRESS\n"; +my $entry = $table{"$INPUT_ADDRESS"}; +die "Unable to find entry for $INPUT_ADDRESS in $tableFilename" unless $entry; +print LOG "Translating to $entry\n"; +close FH; +print "$entry\n"; \ No newline at end of file From c9067e0d419d26107b787a82407b953b999bdbff Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Fri, 16 Feb 2018 10:18:37 -0600 Subject: [PATCH 05/10] Rename and add new UUID. --- info.plist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/info.plist b/info.plist index a4499ef..a6ef9c8 100644 --- a/info.plist +++ b/info.plist @@ -9,8 +9,8 @@ description Commands for the MailMan mailing list software. name - MailMan + Enhanced MailMan uuid - 5ED82AEE-926C-476F-A4D6-FA6E1E89F246 + EC81B9E9-4AAF-4342-8A15-761027EA5E57 From dca6e71dc1abee0dcd73bcf3d36119c0cca23255 Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Tue, 27 Feb 2018 17:27:19 -0600 Subject: [PATCH 06/10] Add debugging output. --- Support/bin/approve | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Support/bin/approve b/Support/bin/approve index 528f497..0de208b 100755 --- a/Support/bin/approve +++ b/Support/bin/approve @@ -5,12 +5,26 @@ ACTION=`defaults read com.freron.MailMate MmMailManCommandAction 2>/dev/null` if [ -z "${ACTION}" ]; then ACTION="openMessage" fi +if [ ! -z ${MM_DEBUG+x} ] && [ $MM_DEBUG ] +then + echo "MailMan accept command"; + echo "MM_TO is ${MM_TO}, PASSWORD before request is ${PASSWORD}, MM_IDENTIFIER is ${MM_IDENTIFIER}" >> /tmp/MailMan.log +fi + # If no password then ask for one if [ -z "${PASSWORD}" ]; then PASSWORD=`"${MM_BUNDLE_SUPPORT}/bin/set_password"` fi +export MM_ADDRESS=`${MM_BUNDLE_SUPPORT}/bin/table_lookup ${MM_TO}` +if [ ! -z ${MM_DEBUG+x} ] && [ $MM_DEBUG ] +then + echo "MM_ADDRESS is ${MM_ADDRESS}" >> /tmp/MailMan.log + echo "After request, PASSWORD = ${PASSWORD}." >> /tmp/MailMan.log +fi + + # If password has been found then create the reply if [ -n "${PASSWORD}" ]; then From 6d6bf765be539a70913479b5ee80af14587ed945 Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Tue, 27 Feb 2018 17:27:52 -0600 Subject: [PATCH 07/10] Revert to openMessage from sendMessage. Was unable to get sendMessage to work. --- Support/bin/reject | 1 + 1 file changed, 1 insertion(+) diff --git a/Support/bin/reject b/Support/bin/reject index a75d232..d268923 100755 --- a/Support/bin/reject +++ b/Support/bin/reject @@ -3,6 +3,7 @@ ACTION=`defaults read com.freron.MailMate MmMailManCommandAction 2>/dev/null` if [ -z "${ACTION}" ]; then ACTION="openMessage" + # ACTION="sendMessage" # we don't need to do anything to the message fi if [ ! -z ${MM_DEBUG+x} ] && [ $MM_DEBUG ] then From 25a103e583d7b75f7ea341551af9d3872c3c055b Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Wed, 1 Dec 2021 22:24:07 -0600 Subject: [PATCH 08/10] Make table_lookup use JSON file format. Couldn't figure out how to use a perl literal for a hash table, so replaced with JSON. This is not ideal because it requires the use of a library. --- Support/bin/table_lookup | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Support/bin/table_lookup b/Support/bin/table_lookup index bb66b20..bd31199 100755 --- a/Support/bin/table_lookup +++ b/Support/bin/table_lookup @@ -1,8 +1,10 @@ #! /usr/bin/env perl +use JSON; + my $tableFilename = "$ENV{HOME}/.mailman-addresses"; my $logfile; -if ( $ENV{"DEBUG_MM"} ) { +if ( $ENV{"DEBUG_MM"} || $ENV{"MM_DEBUG"}) { $logfile = "/tmp/MailMan.log"; } else { $logfile = "/dev/null"; @@ -18,19 +20,19 @@ my %table; open(FH, "< $tableFilename") or die "Unable to open table file $tableFilename $!"; local $raw = ; close FH; -# print "$raw\n"; - %table = %{eval $raw}; + print LOG "Have read:\n$raw\n"; + %table = %{decode_json($raw)}; } { - my @keys = sort(keys(%table)); - print LOG "@keys\n"; + my @keys = keys(%table); + print LOG "Keys are: @keys\n"; - if ( $ARGV[0] eq $keys[0] ) { - print LOG "$ARGV[0] matches a key." - } elsif ( $ARGV[0] ne $keys[0] ) { - print LOG "Surprisingly $ARGV[0] is not equal to $keys[0]\n"; - } + # if ( $ARGV[0] eq $keys[0] ) { + # print LOG "$ARGV[0] matches a key." + # } elsif ( $ARGV[0] ne $keys[0] ) { + # print LOG "Surprisingly $ARGV[0] is not equal to $keys[0]\n"; + # } foreach my $key (@keys) { print LOG "$key\t$table{$key}\n"; @@ -44,4 +46,4 @@ my $entry = $table{"$INPUT_ADDRESS"}; die "Unable to find entry for $INPUT_ADDRESS in $tableFilename" unless $entry; print LOG "Translating to $entry\n"; close FH; -print "$entry\n"; \ No newline at end of file +print "$entry\n"; From cd262a39ea1db44a26d28901734bcc713cc9befa Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Tue, 28 Dec 2021 10:15:51 -0600 Subject: [PATCH 09/10] Add JSON address lookup table. Could not figure out how the original bundle looked up sending addresses, and there were no examples or descriptions. So I added a new table lookup utility using JSON format, which I understand better. --- Support/bin/reject | 9 +++++---- Support/bin/table_lookup | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Support/bin/reject b/Support/bin/reject index d268923..64213a6 100755 --- a/Support/bin/reject +++ b/Support/bin/reject @@ -1,9 +1,11 @@ #!/bin/bash +echo "Attempting to run reject command" >> /tmp/MailMan.log + ACTION=`defaults read com.freron.MailMate MmMailManCommandAction 2>/dev/null` if [ -z "${ACTION}" ]; then - ACTION="openMessage" - # ACTION="sendMessage" # we don't need to do anything to the message + #ACTION="openMessage" + ACTION="sendMessage" # we don't need to do anything to the message fi if [ ! -z ${MM_DEBUG+x} ] && [ $MM_DEBUG ] then @@ -13,7 +15,7 @@ export MM_ADDRESS=`${MM_BUNDLE_SUPPORT}/bin/table_lookup ${MM_TO}` if [ ! -z ${MM_DEBUG+x} ] && [ $MM_DEBUG ] then echo "MM_ADDRESS is ${MM_ADDRESS}" >> /tmp/MailMan.log - echo "ACTION = ${ACTION}." >> /tmp/MailMan.log + echo "ACTION = ${ACTION}" >> /tmp/MailMan.log fi @@ -26,7 +28,6 @@ cat << END "#posting-style" = "top"; "#signature" = ""; "from" = "${MM_ADDRESS}"; - "tags" = "Don'tSave"; }; resultActions = ( { diff --git a/Support/bin/table_lookup b/Support/bin/table_lookup index bd31199..457d117 100755 --- a/Support/bin/table_lookup +++ b/Support/bin/table_lookup @@ -1,4 +1,4 @@ -#! /usr/bin/env perl +#! /usr/local/bin/perl use JSON; From fa5a4392d762a1b2ad603cc40bae027d6f8b20cf Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Tue, 28 Dec 2021 10:17:36 -0600 Subject: [PATCH 10/10] Enable debugging log. --- Commands/Reject.mmCommand | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Commands/Reject.mmCommand b/Commands/Reject.mmCommand index cbf1dac..1191bf3 100644 --- a/Commands/Reject.mmCommand +++ b/Commands/Reject.mmCommand @@ -2,7 +2,7 @@ name = 'Reject'; uuid = 'BF23BD82-6EE9-4298-9B52-03A6B9CE6E80'; conditions = 'list-id exists'; - environment = 'MM_TO=${to}\n'; + environment = 'MM_DEBUG=yes\nMM_TO=${to}\n'; output = 'actions'; command = '#!/bin/bash\n"${MM_BUNDLE_SUPPORT}/bin/reject"\n'; keyEquivalent = '^m';