Update of /cvsroot/tmda/tmda/bin
In directory sc8-pr-cvs1:/tmp/cvs-serv14871/bin
Modified Files:
tmda-pending tmda-rfilter
Log Message:
Pending queue reorganization. Remove use of DELIVERED_CACHE to store
the status of delivered messages.
I wasn't happy with the fact that only tmda-pending could distinguish
between "still pending" messages and those which were already
delivered (either by confirmation or manual release).
This was also the source of the FAQ about why the message is still in
pending even though it's already been delivered.
Drew Raines suggested adopting the Maildir info flag approach, where a
status indicator is appended to the filename once it's delivered. e.g,
1036836637.29343.msg (indicates a "still pending" message)
1036836637.29343.msg:3,C (indicates delivered by sender confirmation)
1036836637.29343.msg:3,R (indicates delivered by manual release)
We utilize the other numerical prefix ``3'' as ``2'' seems to be
MUA-specific. ``3'' could eventually be reserved for
challenge-response systems.
See http://cr.yp.to/proto/maildir.html for more on this format.
This shouldn't change tmda-pending behavior, but would allow homegrown
tools (as well as users poking through pending) to grok delivery status.
Index: tmda-pending
===================================================================
RCS file: /cvsroot/tmda/tmda/bin/tmda-pending,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- tmda-pending 14 Nov 2002 00:09:52 -0000 1.35
+++ tmda-pending 21 Nov 2002 23:57:40 -0000 1.36
@@ -335,7 +335,7 @@
msgs.remove('-')
if not msgs and not wantedstdin:
- msgs = glob.glob('*.*.msg')
+ msgs = glob.glob('*.*.msg*')
msgs.sort()
if descending:
@@ -348,10 +348,6 @@
else:
dispose_def = dispose
- if os.path.exists(Defaults.DELIVERED_CACHE):
- delcache = Util.unpickle(Defaults.DELIVERED_CACHE)
- else:
- delcache = []
if cache:
if os.path.exists(Defaults.PENDING_CACHE):
msgcache = Util.unpickle(Defaults.PENDING_CACHE)
@@ -363,11 +359,10 @@
if not os.path.exists(msg):
cprint(verbose, msg, 'not found!')
else:
- delivered = None
- for dict in delcache:
- if dict.has_key(msg):
- delivered = 1
- break
+ if msg.endswith(',R') or msg.endswith(',C'):
+ delivered = 1
+ else:
+ delivered = None
if delivered:
if dispose == 'delete' and not interactive:
# continue if we are running in batch/delete mode,
Index: tmda-rfilter
===================================================================
RCS file: /cvsroot/tmda/tmda/bin/tmda-rfilter,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- tmda-rfilter 14 Nov 2002 00:09:53 -0000 1.73
+++ tmda-rfilter 21 Nov 2002 23:57:40 -0000 1.74
@@ -426,21 +426,16 @@
logit("BOUNCE invalid_confirmation_address")
bouncegen('bounce', Defaults.BOUNCE_TEXT_INVALID_CONFIRMATION)
confirmed_filename = '%s.%s.msg' % (confirm_timestamp, confirm_pid)
- confirmed_file = os.path.join(pendingdir, confirmed_filename)
- if os.path.exists(Defaults.DELIVERED_CACHE):
- delcache = Util.unpickle(Defaults.DELIVERED_CACHE)
- else:
- delcache = []
- # Determine whether this message has already been delivered, and
- # if by manual release, or confirmation.
- delivered = None
- for dict in delcache:
- if dict.has_key(confirmed_filename):
- # 'c' for confirmed, 'r' for released
- delivered = dict[confirmed_filename]
- break
- # pre-confirmation
+ confirmed_filepath = os.path.join(pendingdir, confirmed_filename)
if confirm_action == 'accept':
+ # Determine whether this message has already been delivered, and
+ # if by manual release (:3,R), or confirmation (:3,C).
+ if os.path.exists(confirmed_filepath + ':3,R'):
+ delivery_status = 'r'
+ elif os.path.exists(confirmed_filepath + ':3,C'):
+ delivery_status = 'c'
+ else:
+ delivery_status = None
new_confirm_hmac = Cookie.confirmationmac(confirm_timestamp,
confirm_pid, confirm_action)
# Accept the message only if the HMAC can be verified.
@@ -449,15 +444,15 @@
bouncegen('bounce', Defaults.BOUNCE_TEXT_INVALID_CONFIRMATION)
# If the message isn't recorded as delivered and doesn't exist,
# alert sender that their original is missing.
- if not delivered and not (os.path.exists(confirmed_file)):
+ if not delivery_status and not (os.path.exists(confirmed_filepath)):
logit("BOUNCE nonexistent_pending_message")
bouncegen('bounce', Defaults.BOUNCE_TEXT_NONEXISTENT_PENDING)
logit("CONFIRM accept " + confirmed_filename)
# Optionally carbon copy the confirmation to another address.
if Defaults.CONFIRM_ACCEPT_CC:
send_cc(Defaults.CONFIRM_ACCEPT_CC)
- if os.path.exists(confirmed_file):
- msg = email.message_from_file(open(confirmed_file, 'r'))
+ if os.path.exists(confirmed_filepath):
+ msg = email.message_from_file(open(confirmed_filepath, 'r'))
# Optionally append the sender's address to a file.
if Defaults.CONFIRM_APPEND:
confirm_append_addr = Util.confirm_append_address(
@@ -465,32 +460,29 @@
parseaddr(msg.get('return-path'))[1])
if not confirm_append_addr:
raise IOError, \
- confirmed_file + ' has no Return-Path header!'
+ confirmed_filepath + ' has no Return-Path header!'
if Util.append_to_file(confirm_append_addr,
Defaults.CONFIRM_APPEND) != 0:
logit('CONFIRM_APPEND ' + Defaults.CONFIRM_APPEND)
# Optionally generate a confirmation acceptance notice.
if Defaults.CONFIRM_ACCEPT_NOTIFY:
- if (delivered == 'c' and
+ if (delivery_status == 'c' and
Defaults.CONFIRM_ACCEPT_TEXT_ALREADY_CONFIRMED):
bouncegen('accept',
Defaults.CONFIRM_ACCEPT_TEXT_ALREADY_CONFIRMED)
- elif (delivered == 'r' and
+ elif (delivery_status == 'r' and
Defaults.CONFIRM_ACCEPT_TEXT_ALREADY_RELEASED):
bouncegen('accept',
Defaults.CONFIRM_ACCEPT_TEXT_ALREADY_RELEASED)
- elif not delivered:
+ elif not delivery_status:
bouncegen('accept', Defaults.CONFIRM_ACCEPT_TEXT_INITIAL)
# Just stop if the message has already been delivered. Also,
- # change the release mark from 'r' to 'c' to note that this
+ # change the release mark from 'R' to 'C' to note that this
# message has had a confirmation attempt.
- if delivered:
- if delivered == 'r':
- for dict in delcache:
- if dict.has_key(confirmed_filename):
- dict[confirmed_filename] = 'c'
- Util.pickleit(delcache, Defaults.DELIVERED_CACHE)
- break
+ if delivery_status:
+ if delivery_status == 'r':
+ os.rename(confirmed_filepath + ':3,R',
+ confirmed_filepath + ':3,C')
mta.stop()
# Release the message for delivery if we get this far.
release_pending(confirm_timestamp, confirm_pid, msg)
@@ -508,19 +500,13 @@
# redirecting a previously confirmed message.
bouncegen('request')
else:
- # Cache and deliver the message.
+ # Update the delivery status flag and deliver the message.
if msgin.has_key('x-tmda-confirmed'):
- msgval = 'c'
+ status_flag = ':3,C'
elif msgin.has_key('x-tmda-released'):
- msgval = 'r'
- # Record this message in the cache as a dictionary,
- # where the message filename is the key, and how it was
- # delivered is the value. e.g, {'1017186412.798.msg':'c'}
- if not {confirmed_filename:msgval} in delcache:
- delcache.insert(0, {confirmed_filename:msgval})
- # Trim tail entries off if necessary, and then write the cache.
- delcache = delcache[:Defaults.DELIVERED_CACHE_LEN]
- Util.pickleit(delcache, Defaults.DELIVERED_CACHE)
+ status_flag = ':3,R'
+ if os.path.exists(confirmed_filepath):
+ os.rename(confirmed_filepath, confirmed_filepath + status_flag)
logit("OK good_confirm_done_cookie")
# Remove X-TMDA-Confirm-Done: since it's only used
# internally. This won't work when delivering '_qok_',
_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs