[issue8739] Update to smtpd.py to RFC 5321

2010-08-14 Thread Alberto Trevino

Alberto Trevino  added the comment:

Any more work I need to do on this patch?

--

___
Python tracker 
<http://bugs.python.org/issue8739>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9168] setuid in smtp.py sheds privileges before binding port

2010-08-14 Thread Alberto Trevino

Alberto Trevino  added the comment:

I haven't heard anything on this problem or my patch.  What's the status?

--

___
Python tracker 
<http://bugs.python.org/issue9168>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8739] Update to smtpd.py to RFC 5321

2010-08-16 Thread Alberto Trevino

Alberto Trevino  added the comment:

On Sunday, August 15, 2010 09:19:27 am Giampaolo Rodola' wrote:
> Patch no longer applies cleanly because smtpd.py changed in the meantime.

Is someone going to fix that or I am expected to play daily catch-up until 
this gets merged?

> A further comment:
> 
> -def __init__(self, server, conn, addr):
> +def __init__(self, server, conn, addr, size = 0):
> -def __init__(self, localaddr, remoteaddr):
> +def __init__(self, localaddr, remoteaddr, size = 0):
> 
> This change breaks backward compatibility. I think it would be better to
> provide this as a SMTPChannel.size_limit class attribute.

Unfortunately, I don't have the time in the next few weeks to make that 
change.  Can someone else make it?

--

___
Python tracker 
<http://bugs.python.org/issue8739>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8739] Update to smtpd.py to RFC 5321

2010-08-16 Thread Alberto Trevino

Alberto Trevino  added the comment:

On Monday, August 16, 2010 11:42:51 am you wrote:
> Re-adapted patch including size_limit change as described in my previous
> message is in attachment. Barry and Alberto, could you take a final look
> at it before committing?

Looks good to me.  If the tests pass, then I'm good to go.

--

___
Python tracker 
<http://bugs.python.org/issue8739>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8739] Update to smtpd.py to RFC 5321

2010-08-16 Thread Alberto Trevino

Alberto Trevino  added the comment:

On Monday, August 16, 2010 12:58:07 pm Barry A. Warsaw wrote:
> The one thing that looks weird to me is VRFY.  Since it never actually
> does verify the user, should we even claim to support the command?  Why
> not let subclasses claim support if they want to add it?

RFC 5321 section 4.5.1 states VRFY should be implemented in order to be 
considered an RFC 5321-compliant implementation.  But, in section 3.5.3 
paragraph 2 it states that if the actual verification was not performed but 
syntax was checked similar to RCPT, then the response code should be 252.

So my purposes for providing the plumbing for VRFY are:

1. Provide a basic, valid implementation to be as RFC 5321-compliant as 
possible.

2. Let users know the command is there so that it can be reimplemented as 
they build their solutions.

--

___
Python tracker 
<http://bugs.python.org/issue8739>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8739] Update to smtpd.py to RFC 5321

2012-02-13 Thread Alberto Trevino

Alberto Trevino  added the comment:

David, I'd be happy to help, but I'm pretty busy for the next month. I read the 
description of your patch, and it sounds good to me. Anything that moves the 
project forward is always welcomed. Thanks for your work on this.

--

___
Python tracker 
<http://bugs.python.org/issue8739>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8739] Update to smtpd.py to RFC 5321

2010-05-17 Thread Alberto Trevino

New submission from Alberto Trevino :

This patch updates smtpd.py to be more RFC 5321 compliant.  It contains:

 - EHLO support
 - Implement DATA size limit (32 MiB by default)
 - 8-bit mime extension plumbing (doesn't do anything, but accepts and
   records command)
 - Basic VRFY support
 - Basic HELP support
 - A few improvements to messages (more in line with RFC 5321 examples)
 - Misc. documentation updates

The patch is specific to Python 3.1.  I have not tried to backport the changes 
to 2.x.  If possible, I would like the patch to be considered for inclusion to 
3.2.

--
components: Library (Lib)
files: smtpd.py-0.2-rfc5321-enhancements.diff
keywords: patch
messages: 105902
nosy: alfmel, barry
priority: normal
severity: normal
status: open
title: Update to smtpd.py to RFC 5321
type: feature request
versions: Python 3.1, Python 3.2
Added file: 
http://bugs.python.org/file17380/smtpd.py-0.2-rfc5321-enhancements.diff

___
Python tracker 
<http://bugs.python.org/issue8739>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8739] Update to smtpd.py to RFC 5321

2010-05-17 Thread Alberto Trevino

Alberto Trevino  added the comment:

> Giampaolo Rodola'  added the comment:
> 
> Some comments:
> 
> Is RFC 5321 completely implemented? Otherwise I would turn this in "as
> defined in RFC 821 and part of RFC 5321".

RFC 5321 obsoletes RFCs 821, 974, 1869 and 2821.  I don't think we should 
make reference to them anymore.  Perhaps say something like "implements RFC 
5321 which supersedes RFC 821."

As to how complete the implementation is, section 4.5.1 of RFC 5321 
specifies the following as the minimum set of commands that should be 
supported in a conforming specification: EHLO, HELO, MAIL, RCPT, DATA, RSET, 
NOOP, QUIT, VRFY.  The only gray area is VRFY which is supposed to see if a 
mailbox exists for a particular user.  Since that function cannot be easily 
performed in this proxy smtpd server, section 3.5.3 states a 252 reply code 
should be returned.  My patch returns code 252 if self.__getaddr returns 
true, or 502 if it returns false.

> > - Implement DATA size limit (32 MiB by default)
> I couldn't find any reference to this in RFC 5321. Is it recommended
> somewhere else maybe? Also, issue 2518 and issue 1745035 are somewhat
> related with this specific problem.

It is not, but just seemed like good practice to advertise the limit in EHLO 
and enforce it.  My patch doesn't do a good job of enforcing it since it 
enforces it before doing process_message.  The problems with 2518 and 
1745035 are still there.

> Since you implemented HELP command in the first place it would be good to
> do it completely.

RFC 5321 doesn't specify it must accept arguments, but I agree it is a good 
idea.  I'll work on that and submit a new patch.

> Too bad smtpd currently lacks a test suite.
> Before going any further with this issue I would recommend to write tests
> first. I have a patch for adding a basic test suite for smtpd module I
> hope I'll be able to submit within this week.

It would be great if you could implement a test suite.

--

___
Python tracker 
<http://bugs.python.org/issue8739>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8739] Update to smtpd.py to RFC 5321

2010-05-20 Thread Alberto Trevino

Alberto Trevino  added the comment:

I have attached a version 2 of the patch.  This patch includes everything in 
the first version, and adds the following:

 - Support for help arguments (HELP MAIL, for example)
 - Support for setting the maximum message size from the command line

This last feature adds the -s or --size option to the command line.  It allows 
the user to specify the maximum size for the message.  It is set to 0 for the 
default, meaning no limit.  This mimics the original behavior of module.  If 
you specify a size (like --size 32768), it will reject messages larger than the 
specified number of bytes (32KiB in this case).  If you don't specify the size, 
the response of EHLP won't list SIZE as one of the extensions.  But, if a size 
is specified, then it will show it on EHLP.

Hopefully these two changes will address some of the concerns that have been 
brought up.

--
Added file: 
http://bugs.python.org/file17415/smtpd.py-0.2-rfc5321-enhancements-2.diff

___
Python tracker 
<http://bugs.python.org/issue8739>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8739] Update to smtpd.py to RFC 5321

2010-05-21 Thread Alberto Trevino

Alberto Trevino  added the comment:

On Thursday 20 May 2010 07:46:43 am you wrote:
> If you don't specify the size, the response of EHLP won't list
> SIZE as one of the extensions.  But, if a size is specified, then it
> will show it on EHLP.

Sorry, the EHLP above should be EHLO.  Fat fingers, little sleep, talk about 
help... you get the idea.

--

___
Python tracker 
<http://bugs.python.org/issue8739>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9168] setuid in smtp.py sheds privileges before binding port

2010-07-05 Thread Alberto Trevino

New submission from Alberto Trevino :

The SMTP proxy server in Python (smtpd.py) allows you to shed privileges and 
run as user nobody. However, if you are trying to use port 25, the server will 
shed privileges before binding the port, causing a bind failure. By moving the 
setuid code between the creation of the proxy server and the aysncore loop, we 
can bind a port below 1024 and run as nobody.

--
components: Library (Lib)
files: smtpd.py-0.2-setuid-fix.diff
keywords: patch
messages: 109336
nosy: alfmel, barry
priority: normal
severity: normal
status: open
title: setuid in smtp.py sheds privileges before binding port
versions: Python 3.2
Added file: http://bugs.python.org/file17871/smtpd.py-0.2-setuid-fix.diff

___
Python tracker 
<http://bugs.python.org/issue9168>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8739] Update to smtpd.py to RFC 5321

2010-07-05 Thread Alberto Trevino

Alberto Trevino  added the comment:

What is the status of this patch? Is there anything else I need to do? Any 
remaining concerns that would stop this patch from being merged?

--

___
Python tracker 
<http://bugs.python.org/issue8739>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8739] Update to smtpd.py to RFC 5321

2010-08-02 Thread Alberto Trevino

Alberto Trevino  added the comment:

On Monday, July 05, 2010 10:41:28 am you wrote:
> Yes, the fact that there are no unit tests for the new functionality.

Sorry to take so long to reply.  I have attached the latest version of the 
patch which does everything in rev. 2 of the patch, patches the setuid 
problem discussed in issue 9168, updates to the unit test to account for the 
changes and to test the new functionality, plus some little changes here and 
there.

Please review and advise.

--
Added file: 
http://bugs.python.org/file18332/smtpd.py-0.2-rfc5321-enhancements-4.diff

___
Python tracker 
<http://bugs.python.org/issue8739>
___diff -aur Python-3.1.2.orig/Lib/smtpd.py Python-3.1.2/Lib/smtpd.py
--- Python-3.1.2.orig/Lib/smtpd.py  2009-02-21 13:59:32.0 -0700
+++ Python-3.1.2/Lib/smtpd.py   2010-08-02 08:23:04.424066197 -0600
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-"""An RFC 2821 smtp proxy.
+"""An RFC 5321 smtp proxy.
 
 Usage: %(program)s [options] [localhost:localport [remotehost:remoteport]]
 
@@ -20,6 +20,11 @@
 Use `classname' as the concrete SMTP proxy class.  Uses `PureProxy' by
 default.
 
+--size limit
+-s limit
+Restrict the total size of the incoming message to "limit" number of
+bytes.  Defaults to 0 (no limit).
+
 --debug
 -d
 Turn on debugging prints.
@@ -35,10 +40,9 @@
 and if remoteport is not given, then 25 is used.
 """
 
-
 # Overview:
 #
-# This file implements the minimal SMTP protocol as defined in RFC 821.  It
+# This file implements the minimal SMTP protocol as defined in RFC 5321.  It
 # has a hierarchy of classes which implement the backend functionality for the
 # smtpd.  A number of classes are provided:
 #
@@ -59,15 +63,18 @@
 #   gets forwarded to a real backend smtpd, as with PureProxy.  Again, errors
 #   are not handled correctly yet.
 #
-# Please note that this script requires Python 2.0
+# Please note that this script requires Python 3.0
 #
 # Author: Barry Warsaw 
 #
+# Contributors:
+#   Alberto Trevino 
+#
 # TODO:
 #
 # - support mailbox delivery
 # - alias files
-# - ESMTP
+# - Handle more ESMTP extensions
 # - handle error codes from the backend smtpd
 
 import sys
@@ -82,7 +89,7 @@
 __all__ = ["SMTPServer","DebuggingServer","PureProxy","MailmanProxy"]
 
 program = sys.argv[0]
-__version__ = 'Python SMTP proxy version 0.2'
+__version__ = 'Python SMTP proxy version 0.21'
 
 
 class Devnull:
@@ -96,7 +103,6 @@
 COMMASPACE = ', '
 
 
-
 def usage(code, msg=''):
 print(__doc__ % globals(), file=sys.stderr)
 if msg:
@@ -104,16 +110,16 @@
 sys.exit(code)
 
 
-
 class SMTPChannel(asynchat.async_chat):
 COMMAND = 0
 DATA = 1
 
-def __init__(self, server, conn, addr):
+def __init__(self, server, conn, addr, size):
 asynchat.async_chat.__init__(self, conn)
 self.__server = server
 self.__conn = conn
 self.__addr = addr
+self.__size = size
 self.__line = []
 self.__state = self.COMMAND
 self.__greeting = 0
@@ -122,6 +128,7 @@
 self.__data = ''
 self.__fqdn = socket.getfqdn()
 self.__peer = conn.getpeername()
+self.__8bitmime = False
 print('Peer:', repr(self.__peer), file=DEBUGSTREAM)
 self.push('220 %s %s' % (self.__fqdn, __version__))
 self.set_terminator(b'\r\n')
@@ -153,7 +160,7 @@
 arg = line[i+1:].strip()
 method = getattr(self, 'smtp_' + command, None)
 if not method:
-self.push('502 Error: command "%s" not implemented' % command)
+self.push('500 Error: command "%s" not recognized' % command)
 return
 method(arg)
 return
@@ -162,7 +169,7 @@
 self.push('451 Internal confusion')
 return
 # Remove extraneous carriage returns and de-transparency according
-# to RFC 821, Section 4.5.2.
+# to RFC 5321, Section 4.5.2.
 data = []
 for text in line.split('\r\n'):
 if text and text[0] == '.':
@@ -170,18 +177,39 @@
 else:
 data.append(text)
 self.__data = NEWLINE.join(data)
-status = self.__server.process_message(self.__peer,
-   self.__mailfrom,
-   self.__rcpttos,
-   self.__data)
-self.__rcpttos = []
-self.__mailfrom = None
-self.__state = self.COMMAN

[issue8739] Update to smtpd.py to RFC 5321

2010-08-04 Thread Alberto Trevino

Alberto Trevino  added the comment:

Sorry.  This is my first submission to Python, so I'm learning the process as I 
go.

This latest patch is done against today's SVN snapshot.  Just to summarize, it 
does the following:

  * Updates the main smtpd.py module to make it RFC 5321 compliant:
- Adds EHLO support
- Provides basic VRFY support
- Updated messages (more in line with RFC 5321 examples)

  * Adds additional functionality to smtpd.py:
- Adds HELP support
- Implements DATA size limits (optional feature -- backward compatible)
- 8BITMIME extension plubming

  * Fixes setuid bug in smtpd.py as explained in issue 9168

  * Updates test-smtpd.py to test new functionality

  * Updates test-smtpdlib.py to work with updates to smtpd.py

Again, please review and comment as necessary.

--
Added file: 
http://bugs.python.org/file18397/smtpd.py-0.2-rfc5321-enhancements-5.diff

___
Python tracker 
<http://bugs.python.org/issue8739>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9168] setuid in smtp.py sheds privileges before binding port

2010-08-05 Thread Alberto Trevino

Changes by Alberto Trevino :


--
type:  -> crash
versions: +Python 3.1 -Python 3.2

___
Python tracker 
<http://bugs.python.org/issue9168>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com