From e1c9e10cd7dc8ed1e09c5c0b09154c3b2eec22c3 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 6 Oct 2002 03:45:40 +0000 Subject: Backport 1.12 and 1.13 and normalize whitespace (remove formfeeds): SF #515021, print the refused list to the DEBUGSTREAM, so the parameter is used Note: There is a TBD (aka FIXME) for how best to handle the refused addresses. smtp_RCPT(): Removed a somewhat embarrassing debugging line, found by Scot Stevenson. Could be a bug fix candidate, but probably doesn't matter much unless a certain blue-nosed cat suddenly becomes corporeal and starts emailing some stmp.py (sic) fronted mailer. --- Lib/smtpd.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Lib/smtpd.py b/Lib/smtpd.py index eb0a9b9..7b614f3 100755 --- a/Lib/smtpd.py +++ b/Lib/smtpd.py @@ -35,7 +35,7 @@ given then 8025 is used. If remotehost is not given then `localhost' is used, and if remoteport is not given, then 25 is used. """ - + # Overview: # # This file implements the minimal SMTP protocol as defined in RFC 821. It @@ -96,7 +96,7 @@ EMPTYSTRING = '' COMMASPACE = ', ' - + def usage(code, msg=''): print >> sys.stderr, __doc__ % globals() if msg: @@ -104,7 +104,7 @@ def usage(code, msg=''): sys.exit(code) - + class SMTPChannel(asynchat.async_chat): COMMAND = 0 DATA = 1 @@ -241,9 +241,6 @@ class SMTPChannel(asynchat.async_chat): if not address: self.push('501 Syntax: RCPT TO:
') return - if address.lower().startswith('stimpy'): - self.push('503 You suck %s' % address) - return self.__rcpttos.append(address) print >> DEBUGSTREAM, 'recips:', self.__rcpttos self.push('250 Ok') @@ -271,7 +268,7 @@ class SMTPChannel(asynchat.async_chat): self.push('354 End data with .') - + class SMTPServer(asyncore.dispatcher): def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr @@ -318,7 +315,7 @@ class SMTPServer(asyncore.dispatcher): raise NotImplementedError - + class DebuggingServer(SMTPServer): # Do something with the gathered message def process_message(self, peer, mailfrom, rcpttos, data): @@ -334,7 +331,7 @@ class DebuggingServer(SMTPServer): print '------------ END MESSAGE ------------' - + class PureProxy(SMTPServer): def process_message(self, peer, mailfrom, rcpttos, data): lines = data.split('\n') @@ -348,7 +345,7 @@ class PureProxy(SMTPServer): data = NEWLINE.join(lines) refused = self._deliver(mailfrom, rcpttos, data) # TBD: what to do with refused addresses? - print >> DEBUGSTREAM, 'we got some refusals' + print >> DEBUGSTREAM, 'we got some refusals:', refused def _deliver(self, mailfrom, rcpttos, data): import smtplib @@ -375,7 +372,7 @@ class PureProxy(SMTPServer): return refused - + class MailmanProxy(PureProxy): def process_message(self, peer, mailfrom, rcpttos, data): from cStringIO import StringIO @@ -417,7 +414,7 @@ class MailmanProxy(PureProxy): if rcpttos: refused = self._deliver(mailfrom, rcpttos, data) # TBD: what to do with refused addresses? - print >> DEBUGSTREAM, 'we got refusals' + print >> DEBUGSTREAM, 'we got refusals:', refused # Now deliver directly to the list commands mlists = {} s = StringIO(data) @@ -454,13 +451,13 @@ class MailmanProxy(PureProxy): msg.Enqueue(mlist, torequest=1) - + class Options: setuid = 1 classname = 'PureProxy' - + def parseargs(): global DEBUGSTREAM try: @@ -517,7 +514,7 @@ def parseargs(): return options - + if __name__ == '__main__': options = parseargs() # Become nobody -- cgit v0.12