Bug 484259

Summary: Setroubleshoot daemon fails with localized messages
Product: [Fedora] Fedora Reporter: Göran Uddeborg <goeran>
Component: setroubleshootAssignee: Daniel Walsh <dwalsh>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 12CC: dwalsh, jdennis, mgrepl
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-02-01 15:52:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 517000    

Description Göran Uddeborg 2009-02-05 17:53:41 UTC
Description of problem:
I've configured setroubleshootd to send mail to an administrative user.  On a system with sv_SE.utf8 as system locale, no mails are sent.  Instead, a python backtrace winds up in /var/log/messages.

Version-Release number of selected component (if applicable):
setroubleshoot-2.0.12-3.fc10.noarch
setroubleshoot-server-2.0.12-3.fc10.noarch

How reproducible:
Every time.

Steps to Reproduce:
1. Put "LANG=sv_SE.utf8" in /etc/sysconfig/i18n
2. Wait for an AVC message
  
Actual results:
I get a traceback in /var/log/messages.  (I've added a few newlines for readability.  Maybe bugzilla will add a few more.)

Feb  5 18:30:02 mimmi setroubleshoot: [avc.ERROR] Plugin Exception catchall_file
  Traceback (most recent call last):
   File "/usr/lib/python2.5/site-packages/setroubleshoot/analyze.py", line 159, in analyze_avc     report_receiver.report_problem(report)
   File "/usr/lib/python2.5/site-packages/setroubleshoot/server.py", line 150, in report_problem     email_alert(siginfo, to_addrs)
   File "/usr/lib/python2.5/site-packages/setroubleshoot/email_alert.py", line 64, in email_alert     text = siginfo.format_text()
   File "/usr/lib/python2.5/site-packages/setroubleshoot/signature.py", line 465, in format_text     text += html_to_text('<h1>'+_("Detailed Description")+':</h1>'+description) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 21: ordinal not in range(128)


Expected results:
A mail explaining the problem.

Additional info:
With some experimentation, I've figured out that it is the "description" variable that triggers the problem.  If I remove that, the problem doesn't happen on that line.  (A similar traceback happens a few lines further on for the "fix".

But character encodings in Python is a mystery to me, and I don't know how to avoid the problem.  (Short of omitting the description and fix.  But that has unfortunate side effects on the message sent, obviously.)

Comment 1 John Dennis 2009-02-06 19:13:27 UTC
Göran, since you seem capable of editing the python code it would help us if you could get some diagnostic information for us. I need to know the type of the description variable. Could you please add this line in /usr/lib/python*/site-packages/setroubleshoot/signature.py in the format_text() function after the description variable is initialized.

log_sig.error("type(description) = %s", type(description))

This will cause the message to be written to syslog and /var/log/setroubleshoot/setroubleshootd.log

then recreate the problem and let us know what the type is. My guess is it will be <type 'unicode'> based on the traceback, but it should be <type 'str'>.

Thanks!

Also, by any chance did you edit /etc/setroubleshoot/setroubleshoot.cfg and modify the encoding?

Which version of Python are you running?

Comment 2 Göran Uddeborg 2009-02-06 22:27:34 UTC
:-)  I'm not afraid to hack around a little, even if I'm still learning the language when it comes to Python.

But the type of "description" is str as you say it should be:

Feb  6 23:20:01 mimmi setroubleshoot: [sig.ERROR] type(description) = <type 'str'>

Any other test I can do to help?

(In reply to comment #1)
> Also, by any chance did you edit /etc/setroubleshoot/setroubleshoot.cfg and
> modify the encoding?

Not that I can remember.  And an "rpm -Vf" on it agrees with me that it is unchanged.

> Which version of Python are you running?

python-2.5.2-1.fc10.x86_64

Comment 4 Bug Zapper 2009-11-18 09:10:05 UTC
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 5 Göran Uddeborg 2009-11-21 21:32:20 UTC
The current version of setroubleshoot-server uses sedispatch called from auditd.  In this configuration, the alert messages are not translated at all any more.  So this problem doesn't show.  One could probably argue if it is "fixed", or maybe only "hidden".

Comment 6 Daniel Walsh 2009-11-23 15:21:39 UTC
There is another bug filed about the translations in F12.

Comment 7 Göran Uddeborg 2009-11-23 21:14:28 UTC
You refer to bug 539286 I assume?  I tried the command you suggested there, and get a backtrace which looks quite similar to what I reported in comment 0.

22:03 mimmi$ sudo sealert -a /var/log/audit/audit.log
[sudo] password for root: 
100% doneERROR: failed to read complete file, 2405705 bytes read out of total 2405455 bytes (/var/log/audit/audit.log)
found 11 alerts in /var/log/audit/audit.log
--------------------------------------------------------------------------------

Traceback (most recent call last):
  File "/usr/bin/sealert", line 799, in on_analyzer_state_change
    self.output_results()
  File "/usr/bin/sealert", line 818, in output_results
    print siginfo.format_text()
  File "/usr/lib64/python2.6/site-packages/setroubleshoot/signature.py", line 467, in format_text
    description = self.description_adjusted_for_permissive()
  File "/usr/lib64/python2.6/site-packages/setroubleshoot/signature.py", line 368, in description_adjusted_for_permissive
    return _('<font color="0000FF">[%s]</font><p>%s') % (permissive_msg, self.solution.problem_description)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 21: ordinal not in range(128)

This was with setroubleshoot-server-2.2.46-1.fc12.x86_64.

Comment 8 Daniel Walsh 2010-01-19 21:05:15 UTC
Fixed in setroubleshoot-2.2.57-1.fc12

Comment 9 Göran Uddeborg 2010-02-01 15:52:51 UTC
I just verified the sealert command no longer crashes with 2.2.60-1.fc12