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
=== modified file 'src/mailman/core/switchboard.py'
--- src/mailman/core/switchboard.py 2013-01-01 14:05:42 +0000
+++ src/mailman/core/switchboard.py 2013-01-11 19:03:25 +0000
@@ -90,9 +90,17 @@
90 'Not a power of 2: {0}'.format(numslices))90 'Not a power of 2: {0}'.format(numslices))
91 self.name = name91 self.name = name
92 self.queue_directory = queue_directory92 self.queue_directory = queue_directory
93 self.non_queue_runner={'lmtp','rest'}
93 # If configured to, create the directory if it doesn't yet exist.94 # If configured to, create the directory if it doesn't yet exist.
94 if config.create_paths:95 if config.create_paths:
95 makedirs(self.queue_directory, 0770)96 for directory in self.queue_directory.split():
97 is_non_queue_runner=False
98 for queue in self.non_queue_runner:
99 if queue in directory:
100 is_non_queue_runner=True
101 break
102 if not(is_non_queue_runner):
103 makedirs(directory,0770)
96 # Fast track for no slices104 # Fast track for no slices
97 self._lower = None105 self._lower = None
98 self._upper = None106 self._upper = None
@@ -143,11 +151,11 @@
143 data['_parsemsg'] = (protocol == 0)151 data['_parsemsg'] = (protocol == 0)
144 # Write to the pickle file the message object and metadata.152 # Write to the pickle file the message object and metadata.
145 with open(tmpfile, 'w') as fp:153 with open(tmpfile, 'w') as fp:
146 fp.write(msgsave)154 fp.write(msgsave)
147 cPickle.dump(data, fp, protocol)155 cPickle.dump(data, fp, protocol)
148 fp.flush()156 fp.flush()
149 os.fsync(fp.fileno())157 os.fsync(fp.fileno())
150 os.rename(tmpfile, filename)158 os.rename(tmpfile, filename)
151 return filebase159 return filebase
152160
153 def dequeue(self, filebase):161 def dequeue(self, filebase):
154162
=== modified file 'src/mailman/runners/lmtp.py'
--- src/mailman/runners/lmtp.py 2013-01-01 14:05:42 +0000
+++ src/mailman/runners/lmtp.py 2013-01-11 19:03:25 +0000
@@ -49,6 +49,7 @@
4949
50from email.utils import parseaddr50from email.utils import parseaddr
51from zope.component import getUtility51from zope.component import getUtility
52from mailman.interfaces.messages import IMessageStore
5253
53from mailman.config import config54from mailman.config import config
54from mailman.core.runner import Runner55from mailman.core.runner import Runner
@@ -97,6 +98,7 @@
97ERR_502 = b'502 Error: command HELO not implemented'98ERR_502 = b'502 Error: command HELO not implemented'
98ERR_550 = b'550 Requested action not taken: mailbox unavailable'99ERR_550 = b'550 Requested action not taken: mailbox unavailable'
99ERR_550_MID = b'550 No Message-ID header provided'100ERR_550_MID = b'550 No Message-ID header provided'
101ERR_DUP = b'Duplicate Message ID'
100102
101# XXX Blech103# XXX Blech
102smtpd.__version__ = b'Python LMTP runner 1.0'104smtpd.__version__ = b'Python LMTP runner 1.0'
@@ -181,10 +183,13 @@
181 # Do basic post-processing of the message, checking it for defects or183 # Do basic post-processing of the message, checking it for defects or
182 # other missing information.184 # other missing information.
183 message_id = msg.get('message-id')185 message_id = msg.get('message-id')
186 message_store = getUtility(IMessageStore)
184 if message_id is None:187 if message_id is None:
185 return ERR_550_MID188 return ERR_550_MID
186 if msg.defects:189 if msg.defects:
187 return ERR_501190 return ERR_501
191 if message_store.get_message_by_id(message_id):
192 return ERR_DUP
188 msg.original_size = len(data)193 msg.original_size = len(data)
189 add_message_hash(msg)194 add_message_hash(msg)
190 msg['X-MailFrom'] = mailfrom195 msg['X-MailFrom'] = mailfrom