Errors with tmda-ofmipd, tlslite, python2.5

"Kevin Goodsell" <[email protected]> Fri, 2 Jan 2009 21:18:40 -0800
Newsgroups gmane.mail.spam.tmda.devel
Message-ID <[email protected]>
Hi folks. I was having a very difficult time getting tmda-ofmipd
working with --ssl, and I've tracked the problem to a bug in tlslite.
I think this has been previously discussed here (I found some archived
messages about it while googling for answers), but it looks like the
problem was never found. I'm going to go check around some more and
see if I can file a bug report with tlslite, or maybe send in a patch.
I thought this list might want to know about it in the meantime.

Anyway, the problem looks like this:

First, I run tmda-ofmipd like this:

sudo ./tmda-ofmipd -f -d --ssl
--ssl-cert=/etc/ssl/certs/selfsigned.pem
--ssl-key=/etc/ssl/certs/selfsigned.pem -R imaps://localhost -p
localhost:8025

Then I try to send a message from Thunderbird. This fails with an
error it Thunderbird, and the terminal where tmda-ofmipd is running
shows this:

Incoming connection from: ('127.0.0.1', 34307)
Incoming connection to: ('127.0.0.1', 8025)
Data: 'EHLO [127.0.0.1]'
error: uncaptured python exception, closing channel
<__main__.SMTPSession connected 127.0.0.1:34307 at 0x86040cc> (<type
'exceptions.ValueError'>: [/usr/lib/python2.5/asyncore.py|read|68]
[/usr/lib/python2.5/asyncore.py|handle_read_event|390]
[./tmda-ofmipd|handle_read|1285]
[/usr/local/tmda-1.1.12/tlslite/integration/AsyncStateMachine.py|inReadEvent|132]
[/usr/local/tmda-1.1.12/tlslite/integration/AsyncStateMachine.py|_doReadOp|177]
[./tmda-ofmipd|outReadEvent|1312]
[/usr/lib/python2.5/asynchat.py|handle_read|137]
[./tmda-ofmipd|found_terminator|222] [./tmda-ofmipd|smtp_EHLO|463]
[./tmda-ofmipd|push|189] [/usr/lib/python2.5/asynchat.py|push|160]
[/usr/lib/python2.5/asynchat.py|initiate_send|219]
[./tmda-ofmipd|send|1331]
[/usr/local/tmda-1.1.12/tlslite/integration/AsyncStateMachine.py|setWriteOp|231]
[/usr/local/tmda-1.1.12/tlslite/integration/AsyncStateMachine.py|_doWriteOp|181]
[/usr/local/tmda-1.1.12/tlslite/TLSRecordLayer.py|writeAsync|254])

The specific problem being reported here is that writeAsync is being
called on a closed TLSRecordLayer. This is checked at the top of the
method, and a ValueError is raised.

The reason the TLSRecordLayer is closed is near the bottom of
readAsync. There is a bare 'except:' that shuts down the
TLSRecordLayer before re-raising the exception. The reason this is
wrong is that there are perfectly valid, non-error exceptions that can
and should be produced in this method -- in particular, GeneratorExit.
GeneratorExit is new in python 2.5, so this problem wouldn't exist in
earlier versions (at least not in exactly the same form). The except:
should probably be except StandardError: or something like that,
though I'm not sure about the compatibility of that with older python
versions.

Like I said, I'm going to continue to investigate this and hope we can
get a fix into tlslite. Maybe this will be useful to someone in the
meantime.

-Kevin

------------------------------------------------------------------------------
_______________________________________________
tmda-workers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmda-workers