From 4d08a1263be6ae9cbc9800b42b266ec3549a0bb7 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Mon, 3 Mar 2008 12:52:20 +0100 Subject: [PATCH 01/16] do not use addheaders for postpone --- procmail/addheaders | 4 ---- procmail/delay-delivery | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/procmail/addheaders b/procmail/addheaders index 6d739c1..cbfc9ed 100644 --- a/procmail/addheaders +++ b/procmail/addheaders @@ -14,8 +14,4 @@ * EQ_DOMAIN ?? . |$FORMAIL -A"X-EqDomain: $ORIG_DOMAIN" -A"X-EqTo: $EQ_LOCAL@$EQ_DOMAIN" -:0 fw -* POSTPONED ?? . -|$FORMAIL -I"X-Postponed: $POSTPONED" - # vim:ft=procmail diff --git a/procmail/delay-delivery b/procmail/delay-delivery index 6a4717c..65f02e5 100644 --- a/procmail/delay-delivery +++ b/procmail/delay-delivery @@ -33,11 +33,11 @@ { RELEASE_TIME="$MATCH" } LOG="delay: delay delivery of $MSGID until $RELEASE_TIME$NL" - POSTPONED="$RELEASE_TS ($RELEASE_TIME)" - INCLUDERC=$PMDIR/record-delayed-mail - INCLUDERC=$PMDIR/addheaders + :0 fw + |$FORMAIL -I"X-Postponed: $RELEASE_TS ($RELEASE_TIME)" + INCLUDERC=$PMDIR/record-delayed-mail :0 $DELAYED_QUEUE } -- 2.39.5 From 259a4169f1bc8ece69ff289df7a47e0d84f4d418 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Mon, 3 Mar 2008 13:33:42 +0100 Subject: [PATCH 02/16] properly log ignored messages --- procmail/ignore | 2 +- procmail/procmailrc | 8 ++++---- procmail/smsmail | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/procmail/ignore b/procmail/ignore index e49b667..a5ae61f 100644 --- a/procmail/ignore +++ b/procmail/ignore @@ -1,7 +1,7 @@ :0 BH * ? $EGREP -qif $CONF/ignore { - LOG="ignore: discarding ignored message $MSGID from $FROM to $ORIGINAL_TO$NL" + LOG="ignore: discarding ignored message$NL" SWITCHRC=$PMDIR/discard } diff --git a/procmail/procmailrc b/procmail/procmailrc index 6dcd3b4..117f552 100755 --- a/procmail/procmailrc +++ b/procmail/procmailrc @@ -10,15 +10,15 @@ INCLUDERC=$PMDIR/defer INCLUDERC=$PMDIR/defines -INCLUDERC=$PMDIR/ignore - -INCLUDERC=$PMDIR/smsmail - #VERBOSE=yes INCLUDERC=$PMDIR/logging #INCLUDERC=$PMDIR/msgid-index +INCLUDERC=$PMDIR/ignore + +INCLUDERC=$PMDIR/smsmail + INCLUDERC=$PMDIR/flag-test-messages INCLUDERC=$PMDIR/dejavu diff --git a/procmail/smsmail b/procmail/smsmail index 9702f8a..5a6f63c 100644 --- a/procmail/smsmail +++ b/procmail/smsmail @@ -4,6 +4,7 @@ :0 W |$HOME/.bin/proc_smsmail + TRAP EXITCODE=$? HOST } -- 2.39.5 From 122f13badd406cf378fb4f57197d27ddebb4d15b Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Mon, 3 Mar 2008 13:38:09 +0100 Subject: [PATCH 03/16] allow early scripts to properly log --- procmail/defines | 2 +- procmail/get-msgid | 8 ++++---- procmail/logging | 9 +++++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/procmail/defines b/procmail/defines index 55508cb..1c55b63 100644 --- a/procmail/defines +++ b/procmail/defines @@ -150,7 +150,7 @@ INCLUDERC=$PMDIR/get-msgid { ORIGINAL_TO="$MATCH" } :0 E * ^Received: -{ LOG="NO ORIGINAL_TO: $MSGID" } +{ LOGLATER="NO ORIGINAL_TO: $MSGID" } :0 *$ ^X-Trained-As:$RE_EXTRACT_HEADER_VALUE diff --git a/procmail/get-msgid b/procmail/get-msgid index 50fbef4..61eca10 100644 --- a/procmail/get-msgid +++ b/procmail/get-msgid @@ -8,14 +8,14 @@ :0 * ^Resent-Message-Id:[ ]*\/[^ ]+ { - LOG="get-msgid: lacking message-id, using resent-message-id...$NL" + LOGLATER="get-msgid: lacking message-id, using resent-message-id...$NL" :0 fw |$FORMAIL -R Resent-Message-ID Message-ID } :0 E { - LOG="get-msgid: lacking message-id, generating one...$NL" + LOGLATER="get-msgid: lacking message-id, generating one...$NL" :0 fw |$FORMAIL -a Message-ID: } @@ -28,7 +28,7 @@ :0 * ! MSGID ?? ^<[^>]+>$ { - LOG="get-msgid: message-id '$MSGID' not enclosed in <>, fixing it...$NL" + LOGLATER="get-msgid: message-id '$MSGID' not enclosed in <>, fixing it...$NL" MSGID="<$MSGID>" } @@ -38,6 +38,6 @@ *$ !^Received: by $RE_MAILRELAYS \(postfix, from userid * MSGID ?? ^<\/[^>]+ { - LOG="get-msgid: missing message ID added by one of our mail relays$NL" + LOGLATER="get-msgid: missing message ID added by one of our mail relays$NL" MSGID="<${MATCH}.MSGID-ADDED>" } diff --git a/procmail/logging b/procmail/logging index a1e199a..d6fc083 100644 --- a/procmail/logging +++ b/procmail/logging @@ -12,8 +12,13 @@ MSGIDDIR=$PMVAR/msgid MASTERLOGFILE="$LOGFILE" LOGFILE="$THISLOGFILE" -LOG="============================================================================== -msgid: $MSGID +LOG="==============================================================================$NL" + +:0 +* LOGLATER ?? . +{ LOG="$LOGLATER" } + +LOG="msgid: $MSGID logfile: $THISLOGFILE_REL date: $DATE (@$OURDATE) from: $FROM -- 2.39.5 From 90af4d50470f9e9b91720fa42f26673293297312 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Mon, 3 Mar 2008 13:47:43 +0100 Subject: [PATCH 04/16] use RE variables consistently --- procmail/get-msgid | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/procmail/get-msgid b/procmail/get-msgid index 61eca10..4a0d251 100644 --- a/procmail/get-msgid +++ b/procmail/get-msgid @@ -1,12 +1,12 @@ :0 -* ^Message-Id:[ ]*\/[^ ]+ +*$ ^Message-Id:$RE_EXTRACT_HEADER_VALUE { MSGID="$MATCH" } :0 -* MSGID ?? ^[ ]*$|^<>$ +* MSGID ?? ^$RE_SPACE*$|^<>$ { :0 - * ^Resent-Message-Id:[ ]*\/[^ ]+ + * ^Resent-Message-Id:$RE_EXTRACT_HEADER_VALUE { LOGLATER="get-msgid: lacking message-id, using resent-message-id...$NL" :0 fw @@ -21,7 +21,7 @@ } :0 - * ^Message-Id:[ ]*\/[^ ]+ + * ^Message-Id:$RE_EXTRACT_HEADER_VALUE { MSGID="$MATCH" } } -- 2.39.5 From bc7202c2a09ed0fc145ad3aa7a6b7dd52e9025db Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Mon, 3 Mar 2008 16:34:26 +0100 Subject: [PATCH 05/16] fix regexp to avoid extracting sfid with msgid --- procmail/get-msgid | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/procmail/get-msgid b/procmail/get-msgid index 4a0d251..eb5964e 100644 --- a/procmail/get-msgid +++ b/procmail/get-msgid @@ -1,12 +1,12 @@ :0 -*$ ^Message-Id:$RE_EXTRACT_HEADER_VALUE +*$ ^Message-Id:$RE_SPACE*\/$RE_NOT_SPACE+ { MSGID="$MATCH" } :0 * MSGID ?? ^$RE_SPACE*$|^<>$ { :0 - * ^Resent-Message-Id:$RE_EXTRACT_HEADER_VALUE + * ^Resent-Message-Id:$RE_SPACE*\/$RE_NOT_SPACE+ { LOGLATER="get-msgid: lacking message-id, using resent-message-id...$NL" :0 fw -- 2.39.5 From e0d5009c344addede72d90cd677e244f685f8be5 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Mon, 3 Mar 2008 16:34:47 +0100 Subject: [PATCH 06/16] also look for replied messages --- bin/process-delayed-queue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/process-delayed-queue b/bin/process-delayed-queue index 6ab1163..826a346 100755 --- a/bin/process-delayed-queue +++ b/bin/process-delayed-queue @@ -20,9 +20,9 @@ $SQLITE -list -separator ' ' $DELAYED_QUEUE_DB "$QUERY" \ dirname="${file%/*}" case "${dirname##*/}" in cur) - files="$files ${file}:2,S" + files="$files ${file}:2,S ${file}:2,R ${file}:2,RS" file="${dirname%/cur}/new/$basename" - files="$files $file ${file}:2," + files="$files $file ${file}:2, ${file}:2,R ${file}:2,RS" ;; new) file="${dirname%/new}/cur/$basename" -- 2.39.5 From 864bba9e27d4b47043898efaa709281986ba36ff Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Mon, 3 Mar 2008 16:35:04 +0100 Subject: [PATCH 07/16] leave X-Tickle header for tickle messages --- procmail/defines | 9 +++++++++ procmail/delay-delivery | 16 +++++++++++----- procmail/tickle | 14 ++++++++------ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/procmail/defines b/procmail/defines index 1c55b63..514a690 100644 --- a/procmail/defines +++ b/procmail/defines @@ -224,3 +224,12 @@ JUSTME # DISABLE_DELAYS # if set, disables delaying messages DISABLE_DELAYS + +# DELAY +# argument to /bin/date -d to indicate a message delay. This is overridden by +# RELEASE +DELAY + +# RELEASE +# /bin/date time expression indicating the time at which a message is to be +# released. Overrides DELAY. diff --git a/procmail/delay-delivery b/procmail/delay-delivery index 65f02e5..9e8e02a 100644 --- a/procmail/delay-delivery +++ b/procmail/delay-delivery @@ -15,10 +15,13 @@ } :0 E -* DELAY ?? . +* 1^0 DELAY ?? . +* 1^0 RELEASE ?? . { - #TODO: for tickling, use header date - RELEASE="`$BIN_DATE -d \"$DELAY\" +'%s %c'`" + :0 + * ! RELEASE ?? . + { RELEASE="`$BIN_DATE -d \"$DELAY\" +'%s (%c)'`" } + DELAY :0 *$ RELEASE ?? ^\/${RE_NOT_SPACE}+ @@ -29,16 +32,19 @@ *$ -$OURDATE_TS ^0 { :0 - *$ RELEASE ?? ^[0-9]+${RE_SPACE}+\/.+ + *$ RELEASE ?? ^[0-9]+${RE_SPACE}+\(\/[^)]+ { RELEASE_TIME="$MATCH" } LOG="delay: delay delivery of $MSGID until $RELEASE_TIME$NL" + RELEASE_TIME + :0 fw - |$FORMAIL -I"X-Postponed: $RELEASE_TS ($RELEASE_TIME)" + |$FORMAIL -I"X-Postponed: $RELEASE" INCLUDERC=$PMDIR/record-delayed-mail :0 $DELAYED_QUEUE } + RELEASE_TS } diff --git a/procmail/tickle b/procmail/tickle index 1a3388d..0a40a1b 100644 --- a/procmail/tickle +++ b/procmail/tickle @@ -1,11 +1,7 @@ # The X-Tickle header has priority over the Original-To address :0 *$ ^X-Tickle:${RE_SPACE}+\/${RE_NOT_SPACE}+ -{ - TICKLE="$MATCH" - :0 fw - |$FORMAIL -IX-Tickle -} +{ TICKLE="$MATCH" } :0 E * ! POSTPONED ?? . @@ -54,9 +50,15 @@ JUST_DATE DAILY_DELIVERY_TIME - LOG="tickle: delaying message until $DELAY$NL" + :0 + { RELEASE="`$BIN_DATE -d \"$DELAY\" +'%s (%c)'`" } + + LOG="tickle: delaying message until $RELEASE$NL" DELAYED_QUEUE=$TICKLER_QUEUE + :0 fw + |$FORMAIL -I"X-Tickle: $RELEASE" + # unset DISABLE_DELAYS to always enable delaying for tickle messages DISABLE_DELAYS } -- 2.39.5 From c1b84832deb10b1d35aa30c0e77eb61d19ae7cdd Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Mon, 3 Mar 2008 19:57:21 +0100 Subject: [PATCH 08/16] restructure undelaying research-related lists --- procmail/rules/ul | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/procmail/rules/ul b/procmail/rules/ul index 22eb14c..8166fe9 100644 --- a/procmail/rules/ul +++ b/procmail/rules/ul @@ -3,15 +3,10 @@ { DEST=ul } :0 -* ORIGINAL_TO ?? ^academic-debian@lists\.madduck\.net@mass\.madduck\.net$ -{ DELAY } - -:0 -* ORIGINAL_TO ?? ^(community|discuss)=opensource\.mit\.edu@mass\.madduck\.net$ -{ DELAY } - -:0 -* ORIGINAL_TO ?? ^os-renet=insel\.cs\.tu-berlin\.de@mass\.madduck\.net$ +* 1^0 EQ_TO ?? ^academic-debian@lists\.madduck\.net$ +* 1^0 EQ_TO ?? ^(community|discuss)@opensource\.mit\.edu$ +* 1^0 EQ_TO ?? ^os-renet@insel\.cs\.tu-berlin\.de$ +* 1^0 EQ_TO ?? ^iif-discussion@forecasters\.org$ { DELAY } # vim:ft=procmail -- 2.39.5 From 98928363ca2c74c9da7d681d3db938f62d1beacc Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Mon, 3 Mar 2008 23:37:31 +0100 Subject: [PATCH 09/16] skip spamchecks for avaaz.org --- config/skip-spamchecks | 1 + 1 file changed, 1 insertion(+) diff --git a/config/skip-spamchecks b/config/skip-spamchecks index ce5c63b..2340dfa 100644 --- a/config/skip-spamchecks +++ b/config/skip-spamchecks @@ -35,6 +35,7 @@ ^X-Original-To: doodle\.ch@pobox\.madduck\.net$ ^X-Original-To: moveon\.org@pobox\.madduck\.net$ ^X-Original-To: explosionsinthesky\.com@pobox\.madduck\.net$ +^X-Original-To: avaaz\.org@pobox\.madduck\.net$ ^X-Original-To: paypal\.com-(de|us|ie|ch)@pobox\.madduck\.net$ ^X-Original-To: pwc@martin-krafft\.net$ ^X-Original-To: ardex@martin-krafft\.net$ -- 2.39.5 From d31cff0854bc8b4ae11fc482aa623fbd5f8728f1 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Tue, 4 Mar 2008 11:36:02 +0100 Subject: [PATCH 10/16] do not delay ul mail --- procmail/rules/ul | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/procmail/rules/ul b/procmail/rules/ul index 8166fe9..1212308 100644 --- a/procmail/rules/ul +++ b/procmail/rules/ul @@ -1,6 +1,9 @@ :0 * ORIGINAL_TO ?? ^martin\.krafft=ul\.ie@forward\.madduck\.net$ -{ DEST=ul } +{ + DEST=ul + DELAY +} :0 * 1^0 EQ_TO ?? ^academic-debian@lists\.madduck\.net$ -- 2.39.5 From 823c9cb8c52f60f91905745ea6b985ef4660f3d1 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Tue, 4 Mar 2008 12:47:57 +0100 Subject: [PATCH 11/16] add more keywords to justme exceptions --- config/justme-keyword-exceptions | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/justme-keyword-exceptions b/config/justme-keyword-exceptions index ed5d2c5..42b5c83 100644 --- a/config/justme-keyword-exceptions +++ b/config/justme-keyword-exceptions @@ -7,3 +7,7 @@ method diffusion z([üu]|ue)rich logcheck netconf +vcs-pkg +vcs-home +cross-distro +collaboration -- 2.39.5 From 0a76b0032d4004450bee10eded1a8bdb79042c22 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Tue, 4 Mar 2008 16:03:15 +0100 Subject: [PATCH 12/16] fix subject decoding --- procmail/defines | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/procmail/defines b/procmail/defines index 514a690..384f13c 100644 --- a/procmail/defines +++ b/procmail/defines @@ -136,7 +136,7 @@ INCLUDERC=$PMDIR/get-msgid # mimedecode.c: * Disclaimer: We only handle charset of iso-8859-1 :0 - * SUBJECT ?? ^=\?iso-8859-1\?[QB]\?.+\?=$ + * SUBJECT ?? =\?iso-8859-1\?[QBqb]\?.+\?= { DECODED="`echo Subject: $SUBJECT | mimedecode | iconv -f latin1 -t utf-8`" :0 -- 2.39.5 From 5950d5c4e05d47338e97a80dfa0909bf9c870ee5 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Tue, 4 Mar 2008 19:30:57 +0100 Subject: [PATCH 13/16] rewrite processing of postponed messages --- bin/list-postponed-messages | 73 +++++++++++++++++++++++++++++++++ bin/process-delayed-queue | 49 ---------------------- bin/process-tickler | 64 ----------------------------- bin/release-delayed-messages | 11 ++--- bin/resubmit | 59 ++++++++++++++++++++++---- bin/resubmit-postponed-messages | 10 +++++ 6 files changed, 138 insertions(+), 128 deletions(-) create mode 100755 bin/list-postponed-messages delete mode 100755 bin/process-delayed-queue delete mode 100755 bin/process-tickler create mode 100755 bin/resubmit-postponed-messages diff --git a/bin/list-postponed-messages b/bin/list-postponed-messages new file mode 100755 index 0000000..d0ee1af --- /dev/null +++ b/bin/list-postponed-messages @@ -0,0 +1,73 @@ +#!/bin/sh +set -eu + +ME="${0##*/}" + +about() +{ + echo "$ME -- list postponed messages which have expired" + echo "Copyright © martin f. krafft " + echo "Released under the terms of the Artistic Licence 2.0" +} + +usage() +{ + echo "Usage: $ME [options] [ ...]" + echo + echo "Valid options are:" + cat <<-_eof | column -s\& -t + -V|--version & show version information. + -h|--help & show this output. + -a|--all & list all postponed messages, not only expired ones + -s|--stamp & include the time stamp *before* the filename + _eof +} + +SHORTOPTS=Vhas +LONGOPTS=version,help,all,stamp + +maildirs= +listall=0 +timestamp=0 + +for opt in $(getopt -n $ME -o $SHORTOPTS -l $LONGOPTS -u -- "$@"); do + case "$opt" in + -V|--version) about; exit 0;; + -h|--help) about; echo; usage; exit 0;; + -a|--all) listall=1;; + -s|--stamp) timestamp=1;; + --) :;; + *) + if [ -d "$opt/cur" ] && [ -d "$opt/new" ] && [ -d "$opt/tmp" ]; then + maildirs="$maildirs $opt" + else + echo "E: unknown argument: $opt" >&2 + exit 1 + fi + ;; + esac +done + +if [ -z "$maildirs" ]; then + echo "E: no Maildirs specified." >&2 + exit 2 +fi + +NOW=$(date +%s) + +for i in $maildirs; do + d="${i%/}" + echo "$d/new/" + echo "$d/cur/" +done \ + | xargs -I {} find {} -type f \ + | xargs grep '^X-Postponed:' \ + | while read i; do + f="${i%:X-Postponed:*}" + ts="${i#*:X-Postponed: }"; ts="${ts%% *}" + + if [ $listall -eq 1 ] || [ $ts -le $NOW ]; then + [ $timestamp -eq 1 ] && echo -n "$ts " + echo "$f" + fi + done diff --git a/bin/process-delayed-queue b/bin/process-delayed-queue deleted file mode 100755 index 826a346..0000000 --- a/bin/process-delayed-queue +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -set -eu - -MAILDIR=$HOME/.maildir - -SQLITE=/usr/bin/sqlite3 -RESUBMIT=$HOME/.etc/mailfilter/bin/resubmit - -DELAYED_QUEUE_DB=$HOME/.var/procmail/delayed-queue.sqlite - -QUERY='select * from messages where release_ts <= strftime("%s", "now")' - -$SQLITE -list -separator ' ' $DELAYED_QUEUE_DB "$QUERY" \ - | while read msgid basefile ts; do - - file="$MAILDIR/$basefile" - files="$file ${file}:2," - - basename="${file##*/}" - dirname="${file%/*}" - case "${dirname##*/}" in - cur) - files="$files ${file}:2,S ${file}:2,R ${file}:2,RS" - file="${dirname%/cur}/new/$basename" - files="$files $file ${file}:2, ${file}:2,R ${file}:2,RS" - ;; - new) - file="${dirname%/new}/cur/$basename" - files="$files ${file}:2, ${file}:2,S" - ;; - esac - - found=0 - for file in $files; do - if [ -f "$file" ]; then - $RESUBMIT "$file" - echo "I: resubmitted $msgid" - found=1 - break - fi - done - - $SQLITE $DELAYED_QUEUE_DB "delete from messages where msgid = '$msgid'" - - if [ $found -eq 0 ]; then - echo "E: message $msgid not found in $basefile" >&2 - fi - -done diff --git a/bin/process-tickler b/bin/process-tickler deleted file mode 100755 index 28b6c5e..0000000 --- a/bin/process-tickler +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/python2.5 -# -*- coding: utf-8 -*- -# -# process-tickler – process message in tickler maildir -# -# Copyright © martin f. krafft -# Released under the terms of the Artistic Licence 2.0 -# - -import mailbox -import os -import sys -import time - -HOME = os.getenv('HOME') -MAILDIR = os.path.join(HOME, '.maildir') -TICKLER_DIR = os.path.join(MAILDIR, '.tickler') -DEST_DIR = os.path.join(MAILDIR, '.resubmit') - -tmd = mailbox.Maildir(TICKLER_DIR) -dmd = mailbox.Maildir(DEST_DIR) -msgids = dict() - -def resubmit(key): - msg = tmd.get_message(key) - print >>sys.stdout, 'I: resubmit message %s' % key - if msg.has_key('X-Tickle-Delivered'): - msg.replace_header('X-Tickle-Delivered', time.strftime('%c')) - else: - msg.add_header('X-Tickle-Delivered', time.strftime('%c')) - dmd.add(msg) - tmd.discard(key) - -for key, msg in tmd.iteritems(): - msgid = msg.get('Message-Id') - if msgid is None: - print >>sys.stderr, 'W: message without ID: ' + key - resubmit(key) - - tickle = msg.get('X-Tickle') - if tickle is None: - print >>sys.stderr, 'W: message without tickle information: ' + msgid - resubmit(key) - - if msgids.get(msgid, None) is None: - msgids[msgid] = list() - msgids[msgid].append((int(tickle.split(' ', 1)[0]), key, msg)) - -for msgid, msgs in msgids.iteritems(): - msgs.sort() - prev_tickle = None - for tickle, key, msg in msgs: - if tickle == prev_tickle: - print >>sys.stderr, 'I: discarding duplicate %s of message %s' % (key, msgid) - tmd.discard(key) - continue - prev_tickle = tickle - - t = time.time() - if t >= tickle: - resubmit(key) - else: - print >>sys.stdout, 'I: message %s still has %d seconds' % (key, - int(tickle - t)) diff --git a/bin/release-delayed-messages b/bin/release-delayed-messages index fd381d3..61abd85 100755 --- a/bin/release-delayed-messages +++ b/bin/release-delayed-messages @@ -1,12 +1,9 @@ #!/bin/sh set -eu -MAILDIR=$HOME/.maildir +DELAYED_QUEUE=$HOME/.maildir/.delayed -SQLITE=/usr/bin/sqlite3 -DELAYED_QUEUE_DB=$HOME/.var/procmail/delayed-queue.sqlite +DIR="${0%/*}" -QUERY="update messages set release_ts = strftime('%s', 'now') where filename like '.delayed/%'" - -$SQLITE $DELAYED_QUEUE_DB "$QUERY" -exec $HOME/.etc/mailfilter/bin/process-delayed-queue +"$DIR"/list-postponed-messages --all "$DELAYED_QUEUE" \ + | exec xargs "$DIR"/resubmit --list diff --git a/bin/resubmit b/bin/resubmit index 17888f9..6bf8819 100755 --- a/bin/resubmit +++ b/bin/resubmit @@ -1,17 +1,60 @@ #!/bin/sh set -eu +ME="${0##*/}" + +about() +{ + echo "$ME -- resubmit messages to the mail filter" + echo "Copyright © martin f. krafft " + echo "Released under the terms of the Artistic Licence 2.0" +} + +usage() +{ + echo "Usage: $ME [options] [ ...]" + echo + echo "Valid options are:" + cat <<-_eof | column -s\& -t + -V|--version & show version information. + -h|--help & show this output. + -l|--list & process the argument list (even if empty), never stdin + _eof +} + +SHORTOPTS=Vhl +LONGOPTS=version,help,list + +list=0 +files= + +for opt in $(getopt -n $ME -o $SHORTOPTS -l $LONGOPTS -u -- "$@"); do + case "$opt" in + -V|--version) about; exit 0;; + -h|--help) about; echo; usage; exit 0;; + -l|--list) list=1;; + --) :;; + *) + if [ -f "$opt" ] && [ -r "$opt" ]; then + files="$files $opt" + else + echo "E: unknown argument: $opt" >&2 + exit 1 + fi + ;; + esac +done + PROCMAIL=$HOME/.etc/mailfilter/procmail/procmailrc -FORMAIL="/usr/bin/formail -I'X-Resubmitted: $(date -R)'" +# execute the date -R only during the eval, not immediately +FILTER='/usr/bin/formail -I"X-Resubmitted: $(date -R)"' -if [ -z "${1:-}" ]; then - eval $FORMAIL | exec $PROCMAIL +if [ -z "${1:-}" ] && [ $list -eq 0 ]; then + eval $FILTER | exec $PROCMAIL else - if [ ! -f "$1" ]; then - echo "E: no such file: $1" >&2 - exit 1 - fi - eval $FORMAIL < "$1" | $PROCMAIL && rm -f "$1" + for f in $files; do + eval $FILTER < "$f" | $PROCMAIL && rm -f "$f" + done fi exit 0 diff --git a/bin/resubmit-postponed-messages b/bin/resubmit-postponed-messages new file mode 100755 index 0000000..1ea3100 --- /dev/null +++ b/bin/resubmit-postponed-messages @@ -0,0 +1,10 @@ +#!/bin/sh +set -eu + +DELAYED_QUEUE=$HOME/.maildir/.delayed +TICKLER_QUEUE=$HOME/.maildir/.store + +DIR="${0%/*}" + +"$DIR"/list-postponed-messages "$TICKLER_QUEUE" "$DELAYED_QUEUE" \ + | exec xargs "$DIR"/resubmit --list -- 2.39.5 From d855421675244ca1154a6d5668bb2e41940cd7b9 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Tue, 4 Mar 2008 19:32:32 +0100 Subject: [PATCH 14/16] no longer record delays in sqlite database --- procmail/delay-delivery | 1 - procmail/record-delayed-mail | 18 ------------------ 2 files changed, 19 deletions(-) delete mode 100644 procmail/record-delayed-mail diff --git a/procmail/delay-delivery b/procmail/delay-delivery index 9e8e02a..aef22e1 100644 --- a/procmail/delay-delivery +++ b/procmail/delay-delivery @@ -42,7 +42,6 @@ :0 fw |$FORMAIL -I"X-Postponed: $RELEASE" - INCLUDERC=$PMDIR/record-delayed-mail :0 $DELAYED_QUEUE } diff --git a/procmail/record-delayed-mail b/procmail/record-delayed-mail deleted file mode 100644 index c8256e1..0000000 --- a/procmail/record-delayed-mail +++ /dev/null @@ -1,18 +0,0 @@ -# create table messages (msgid text unique not null, filename text -# primary key not null unique, release_ts integer not null); - -DELAYED_QUEUE_DB=$PMVAR/delayed-queue.sqlite - -DO_QUERY="$SQLITE $DELAYED_QUEUE_DB" - -DATA="$MSGID" -INCLUDERC=$PMDIR/sql-escape - -QUERY="insert into messages values ($DATA, '\$DESTFILE', $RELEASE_TS);" -TRAP="$TRAP; OUT=\"$(echo \"$QUERY\" | $DO_QUERY 2>&1)\"; - [ -n \"\$OUT\" ] && echo \"delay: failed register delayed mail in database: \$OUT\"" - -QUERY -DATA -DO_QUERY -DELAYED_QUEUE_DB -- 2.39.5 From 741f9a9bbeb999f22417f0a30696165613684d4d Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Tue, 4 Mar 2008 20:33:05 +0100 Subject: [PATCH 15/16] delete cron mails which will be spooled too --- procmail/rules/all | 1 + procmail/rules/cron | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 procmail/rules/cron diff --git a/procmail/rules/all b/procmail/rules/all index 9795c52..01ac51e 100644 --- a/procmail/rules/all +++ b/procmail/rules/all @@ -13,6 +13,7 @@ INCLUDERC=$PMRULES/ul INCLUDERC=$PMRULES/gpg + INCLUDERC=$PMRULES/cron } # vim:ft=procmail diff --git a/procmail/rules/cron b/procmail/rules/cron new file mode 100644 index 0000000..b723e9b --- /dev/null +++ b/procmail/rules/cron @@ -0,0 +1,6 @@ +# rely on spool to keep cron output around +:0 +* FROM ?? ^root@(.+\.)+madduck.net \(Cron Daemon\)$ +$NULL + +# vim:ft=procmail -- 2.39.5 From ea165ed0a86ce8827c27f61b000797ce01b90a8f Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Tue, 4 Mar 2008 21:39:08 +0100 Subject: [PATCH 16/16] do not fail if there is just a single message --- bin/list-postponed-messages | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/list-postponed-messages b/bin/list-postponed-messages index d0ee1af..3562b2f 100755 --- a/bin/list-postponed-messages +++ b/bin/list-postponed-messages @@ -61,7 +61,7 @@ for i in $maildirs; do echo "$d/cur/" done \ | xargs -I {} find {} -type f \ - | xargs grep '^X-Postponed:' \ + | xargs grep -H '^X-Postponed:' \ | while read i; do f="${i%:X-Postponed:*}" ts="${i#*:X-Postponed: }"; ts="${ts%% *}" -- 2.39.5