Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 183808 - elog mail module breaks with gmail
Summary: elog mail module breaks with gmail
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - External Interaction (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
: 186590 (view as bug list)
Depends on:
Blocks: 194041
  Show dependency tree
 
Reported: 2007-07-01 09:17 UTC by Russell Harmon
Modified: 2007-10-13 20:16 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
portage-elog-mailer.patch (portage-elog-mailer.patch,986 bytes, patch)
2007-07-01 09:18 UTC, Russell Harmon
Details | Diff
portage-elog-mailer.patch (portage-elog-mailer.patch,1.32 KB, patch)
2007-07-01 23:27 UTC, Russell Harmon
Details | Diff
portage-elog-mailer-prepatched.patch (portage-elog-mailer-prepatched.patch,631 bytes, patch)
2007-07-25 14:57 UTC, Russell Harmon
Details | Diff
portage-elog-mailer.patch (portage-elog-mailer.patch,1.44 KB, patch)
2007-07-25 14:58 UTC, Russell Harmon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Russell Harmon 2007-07-01 09:17:01 UTC
I recently tried setting up the PORTAGE_ELOG_MAILURI to work with gmail. After many headaches, I fixed the following problems with it:

You need to call an initial ehlo() before the starttls() in order for the starttls() to work.
according to the python reference at http://docs.python.org/lib/SMTP-objects.html you need to call another ehlo() after starttls (which is not explicitly done). Without this, logins will not function.
Gmail's ssl servers don't close the connection correctly, this causes a crash with error code 8. I added a conditional to ignore that error (probably not the best way)

Since I can't seem to attach the patch I made, you can get it at http://www.csh.rit.edu/~russ/portage-elog-mailer.patch
Comment 1 Russell Harmon 2007-07-01 09:18:04 UTC
Created attachment 123517 [details, diff]
portage-elog-mailer.patch

Oh, guess I can attach the patch... done
Comment 2 Zac Medico gentoo-dev 2007-07-01 15:31:49 UTC
Thanks for the patch.  Is there any particular reason why the patch chooses to ignore the socket.error with errno == 8 (aka errno.ENOEXEC)?  I'm just curious because silently ignoring errors is often not a good thing.
Comment 3 Russell Harmon 2007-07-01 18:40:19 UTC
When the myconn.close() is called, an error of type 8 is thrown. It seems that gmail's servers don't close the connection correctly, and the only way to fix it is to ignore it.
Comment 4 Russell Harmon 2007-07-01 18:55:10 UTC
One thought however, my direct calls to ehlo() may cause problems with servers that support tls and don't support ehlo (is that possible?)
Comment 5 Russell Harmon 2007-07-01 23:27:08 UTC
Created attachment 123567 [details, diff]
portage-elog-mailer.patch

I fixed the patch up a bit. It now includes the following:
Comments
It throws a warning instead of silently ignoring the error code 8.
It now ONLY ignores the error code 8 if it is thrown by the quit() method.

Here's a bit of code to check if ehlo is supported and use helo if it is not. I didn't put it in the patch, because i'm not sure if it's necessary in the tls-only case where I use ehlo.
#if not (200 <= myconn.ehlo()[0] <= 299):
#  myconn.helo()
Comment 6 Jakub Moc (RETIRED) gentoo-dev 2007-07-25 14:08:08 UTC
*** Bug 186590 has been marked as a duplicate of this bug. ***
Comment 7 Russell Harmon 2007-07-25 14:57:46 UTC
Created attachment 125982 [details, diff]
portage-elog-mailer-prepatched.patch

I've been getting another error recently. I'm not sure if it is caused by gmail, or if it is my system, however I suspect gmail. To get it working again, it was just a matter of ignoring another error. A patch to a portage_mail.py with my old patches is attached, and I will attach another patch which can be applied to a vanilla portage_mail.py. However once we know the cause better the error message should probably be changed a bit. The error is:

====================================
Error in portage_exec.run_exitfuncs

  File "/usr/lib/portage/pym/portage_exec.py", line 84, in run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/portage/pym/elog_modules/mod_mail_summary.py", line 38, in finalize
    portage_mail.send_mail(mysettings, mymessage)
  File "/usr/lib/portage/pym/portage_mail.py", line 100, in send_mail
    raise portage_exception.PortageException("!!! A network error occured while trying to send logmail:\n"+str(e)+"\nSure you configured PORTAGE_ELOG_MAILURI correctly?")
!!! A network error occured while trying to send logmail:
(1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number')
Sure you configured PORTAGE_ELOG_MAILURI correctly?
====================================

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib/python2.4/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/portage/pym/portage_exec.py", line 84, in run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/portage/pym/elog_modules/mod_mail_summary.py", line 38, in finalize
    portage_mail.send_mail(mysettings, mymessage)
  File "/usr/lib/portage/pym/portage_mail.py", line 100, in send_mail
    raise portage_exception.PortageException("!!! A network error occured while trying to send logmail:\n"+str(e)+"\nSure you configured PORTAGE_ELOG_MAILURI correctly?")
PortageException: !!! A network error occured while trying to send logmail:
(1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number')
Sure you configured PORTAGE_ELOG_MAILURI correctly?
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/usr/lib/python2.4/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/portage/pym/portage_exec.py", line 84, in run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/portage/pym/elog_modules/mod_mail_summary.py", line 38, in finalize
    portage_mail.send_mail(mysettings, mymessage)
  File "/usr/lib/portage/pym/portage_mail.py", line 100, in send_mail
    raise portage_exception.PortageException("!!! A network error occured while trying to send logmail:\n"+str(e)+"\nSure you configured PORTAGE_ELOG_MAILURI correctly?")
portage_exception.PortageException: !!! A network error occured while trying to send logmail:
(1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number')
Sure you configured PORTAGE_ELOG_MAILURI correctly?
Comment 8 Russell Harmon 2007-07-25 14:58:26 UTC
Created attachment 125983 [details, diff]
portage-elog-mailer.patch

This one can be applied to the vanilla portage_mailer.py
Comment 9 Sulla Felix 2007-07-26 03:18:14 UTC
It will be nice if in the portage documentation it was documented that we need to add 100000 to the port number to have TLS auth.

New error message:

!!! This is an error that I don't know anything about:
!!! (1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number')
!!! This error can probably be ignored.
Comment 10 Russell Harmon 2007-07-26 03:25:29 UTC
Yes, that error would cause crashes, but the latest patch tells has it tell you that message and continue. It should work fine.
Comment 11 Sulla Felix 2007-07-26 03:41:34 UTC
is it possible to configure ELOG to verify the ssl certificate of the mail server when using TLS?
Comment 12 Russell Harmon 2007-07-26 04:29:44 UTC
(In reply to comment #11)
> is it possible to configure ELOG to verify the ssl certificate of the mail
> server when using TLS?
> 

Um... tls is encrypted. I believe it uses ssl to provide that encryption. Otherwise, i'm not sure what you are asking.
Comment 13 Marius Mauch (RETIRED) gentoo-dev 2007-07-26 04:55:35 UTC
(In reply to comment #11)
> is it possible to configure ELOG to verify the ssl certificate of the mail
> server when using TLS?

No, pythons smtplib module doesn't seem to support that anyway. However if you specify a command (must accept basic sendmail options) instead of a server in the MAILURI variable that command could verify the cerificate.
Comment 14 Marius Mauch (RETIRED) gentoo-dev 2007-10-06 16:32:30 UTC
Handled this in a different way, as the real bug here was that the exception caused a traceback because it was triggered in mod_mail_summary.finalize and not caught by elog_process as it would with mod_mail. So no need to add special cases in the main mail module.
Comment 15 Zac Medico gentoo-dev 2007-10-13 20:16:50 UTC
Thanks, this has been released in 2.1.3.13.