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'; 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. 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 diff --git a/Support/bin/reject b/Support/bin/reject index 4b257c8..64213a6 100755 --- a/Support/bin/reject +++ b/Support/bin/reject @@ -1,10 +1,24 @@ #!/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="openMessage" + ACTION="sendMessage" # we don't need to do anything to the message +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,7 +27,7 @@ cat << END headers = { "#posting-style" = "top"; "#signature" = ""; - "from" = "${MM_TO}"; + "from" = "${MM_ADDRESS}"; }; resultActions = ( { @@ -24,3 +38,4 @@ cat << END ); } END + diff --git a/Support/bin/table_lookup b/Support/bin/table_lookup new file mode 100755 index 0000000..457d117 --- /dev/null +++ b/Support/bin/table_lookup @@ -0,0 +1,49 @@ +#! /usr/local/bin/perl + +use JSON; + +my $tableFilename = "$ENV{HOME}/.mailman-addresses"; +my $logfile; +if ( $ENV{"DEBUG_MM"} || $ENV{"MM_DEBUG"}) { + $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 LOG "Have read:\n$raw\n"; + %table = %{decode_json($raw)}; +} + +{ + 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"; + # } + + 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"; 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