Merge lp:~sakuag333/mailman/lmtp-duplicate-id into lp:mailman

Proposed by Sandesh Kumar Agrawal
Status: Work in progress
Proposed branch: lp:~sakuag333/mailman/lmtp-duplicate-id
Merge into: lp:mailman
Diff against target: 73 lines (+19/-6)
2 files modified
src/mailman/core/switchboard.py (+14/-6)
src/mailman/runners/lmtp.py (+5/-0)
To merge this branch: bzr merge lp:~sakuag333/mailman/lmtp-duplicate-id
Reviewer Review Type Date Requested Status
Barry Warsaw Pending
Review via email: mp+142967@code.launchpad.net

Description of the change

I made changes in lmtp.py
Before lmtp runner enqueues a new message to some queue, it checks if some message with the same id is present in the message store or not using get_message_by_id(), and rejects if the new message has dupliacate id.

To post a comment you must log in.
Revision history for this message
Sumana Harihareswara (sumanah) wrote :

Just for reference, it looks like this branch is actually NOT merged into trunk, despite what Launchpad says (status:merged). Revision 7202 was about something completely different.

Revision history for this message
Barry Warsaw (barry) wrote :

I moved it back to WIP.

Revision history for this message
Aanand (aanand0071) wrote :

I had to ask whether this bug is still open to work on?As i wish to fix it.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/mailman/core/switchboard.py'
2--- src/mailman/core/switchboard.py 2013-01-01 14:05:42 +0000
3+++ src/mailman/core/switchboard.py 2013-01-11 19:03:25 +0000
4@@ -90,9 +90,17 @@
5 'Not a power of 2: {0}'.format(numslices))
6 self.name = name
7 self.queue_directory = queue_directory
8+ self.non_queue_runner={'lmtp','rest'}
9 # If configured to, create the directory if it doesn't yet exist.
10 if config.create_paths:
11- makedirs(self.queue_directory, 0770)
12+ for directory in self.queue_directory.split():
13+ is_non_queue_runner=False
14+ for queue in self.non_queue_runner:
15+ if queue in directory:
16+ is_non_queue_runner=True
17+ break
18+ if not(is_non_queue_runner):
19+ makedirs(directory,0770)
20 # Fast track for no slices
21 self._lower = None
22 self._upper = None
23@@ -143,11 +151,11 @@
24 data['_parsemsg'] = (protocol == 0)
25 # Write to the pickle file the message object and metadata.
26 with open(tmpfile, 'w') as fp:
27- fp.write(msgsave)
28- cPickle.dump(data, fp, protocol)
29- fp.flush()
30- os.fsync(fp.fileno())
31- os.rename(tmpfile, filename)
32+ fp.write(msgsave)
33+ cPickle.dump(data, fp, protocol)
34+ fp.flush()
35+ os.fsync(fp.fileno())
36+ os.rename(tmpfile, filename)
37 return filebase
38
39 def dequeue(self, filebase):
40
41=== modified file 'src/mailman/runners/lmtp.py'
42--- src/mailman/runners/lmtp.py 2013-01-01 14:05:42 +0000
43+++ src/mailman/runners/lmtp.py 2013-01-11 19:03:25 +0000
44@@ -49,6 +49,7 @@
45
46 from email.utils import parseaddr
47 from zope.component import getUtility
48+from mailman.interfaces.messages import IMessageStore
49
50 from mailman.config import config
51 from mailman.core.runner import Runner
52@@ -97,6 +98,7 @@
53 ERR_502 = b'502 Error: command HELO not implemented'
54 ERR_550 = b'550 Requested action not taken: mailbox unavailable'
55 ERR_550_MID = b'550 No Message-ID header provided'
56+ERR_DUP = b'Duplicate Message ID'
57
58 # XXX Blech
59 smtpd.__version__ = b'Python LMTP runner 1.0'
60@@ -181,10 +183,13 @@
61 # Do basic post-processing of the message, checking it for defects or
62 # other missing information.
63 message_id = msg.get('message-id')
64+ message_store = getUtility(IMessageStore)
65 if message_id is None:
66 return ERR_550_MID
67 if msg.defects:
68 return ERR_501
69+ if message_store.get_message_by_id(message_id):
70+ return ERR_DUP
71 msg.original_size = len(data)
72 add_message_hash(msg)
73 msg['X-MailFrom'] = mailfrom