Bug 1297111 - setroubleshoot-server cannot send email because of error: Exception during AVC analysis: No module named 'email.MIMEText'
Summary: setroubleshoot-server cannot send email because of error: Exception during AV...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: setroubleshoot
Version: 23
Hardware: i686
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Petr Lautrbach
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-01-09 11:21 UTC by Matt Kinni
Modified: 2016-01-28 18:23 UTC (History)
3 users (show)

Fixed In Version: setroubleshoot-3.3.3-1.fc23
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-01-28 18:23:37 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Matt Kinni 2016-01-09 11:21:49 UTC
Description of problem:
setroubleshoot-server cannot send email alerts because of an exception in /usr/lib/python3.4/site-packages/setroubleshoot/email_alert.py.

The error shown in the logs: 
Jan 09 11:18:32 example.com setroubleshoot[1230]: Exception during AVC analysis: No module named 'email.MIMEText'.

I have actually figured out what the issue is.

In email_alert.py Line 26 it says:
"from email.MIMEText import MIMEText"
This works in python2.7 (which I suspect this package was using at some point), but does NOT work in python3.4 as the library names have changed.

According to the Package History section on this page https://docs.python.org/2/library/email.html (quoting a bullet point):
"- A new subpackage email.mime was added and all the version 3 email.MIME* modules were renamed and situated into the email.mime subpackage. For example, the version 3 module email.MIMEText was renamed to email.mime.text."

I have confirmed this new naming.
Old way that doesn't work:

python3.4
Python 3.4.3 (default, Jun 29 2015, 12:15:26) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from email.MIMEText import MIMEText
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'email.MIMEText'
>>> 

New way that does work:

python3.4
Python 3.4.3 (default, Jun 29 2015, 12:15:26) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from email.mime.text import MIMEText
>>>

So basically, I think all of the import lines in email_alert.py need to be updated to reference the new library names.  I suspect the file was written and works in an earlier python, but now it is installed for python3.4 and doesn't work anymore. I am not a python developer so I hope this analysis was helpful or points you in the right direction.
Thanks!



Version-Release number of selected component (if applicable):
setroubleshoot-server-3.3.1-0.2.fc23.i686

How reproducible:
Always

Steps to Reproduce:
1. Put an email address in /var/lib/setroubleshoot/email_alert_recipients 
2. cause avc denial
3. journalctl -f SYSLOG_IDENTIFIER=setroubleshoot

Actual results:
No email is sent, error message printed to log

Expected results:
Email is sent


Additional info:

Comment 1 Petr Lautrbach 2016-01-10 19:48:09 UTC
Thanks for the report and deep investigation! Indeed it's python 3 rewrite problem. I'll provide an update soon.

Comment 3 Fedora Update System 2016-01-21 14:58:56 UTC
setroubleshoot-3.3.3-1.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-8f471924e8

Comment 4 Fedora Update System 2016-01-22 04:56:20 UTC
setroubleshoot-3.3.3-1.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-8f471924e8

Comment 5 Fedora Update System 2016-01-28 18:23:35 UTC
setroubleshoot-3.3.3-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.