Bug 221977 - semanage fails in some locales
semanage fails in some locales
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: policycoreutils (Show other bugs)
6
All Linux
medium Severity high
: ---
: ---
Assigned To: Daniel Walsh
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-01-09 08:59 EST by Tomasz Torcz
Modified: 2008-01-21 10:42 EST (History)
4 users (show)

See Also:
Fixed In Version: Current
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-01-21 10:42:45 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Tomasz Torcz 2007-01-09 08:59:19 EST
Description of problem:
Short story:
# semanage port -a -t openvpn_port_t 1194
/usr/sbin/semanage: Traceback (most recent call last):
  File "/usr/sbin/semanage", line 302, in ?
    errorExit(error.args[0])
  File "/usr/sbin/semanage", line 83, in errorExit
    sys.stderr.write("%s\n" % error)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 20-21:
ordinal not in range(128)
# echo $LANG
pl_PL.UTF-8

It works with "C" locale.


Version-Release number of selected component (if applicable):
policycoreutils-1.33.6-3.fc6

How reproducible:
Always

Additional info:

similar problems exist with setroubleshotd and sealert.
Comment 1 Daniel Walsh 2007-01-09 12:03:40 EST
Fixed in policycoreutils-1_33_8-3
Comment 2 Tomasz Torcz 2007-01-15 05:59:49 EST
Which is still neither in fedora 6 updates nor in proposed updates.
Comment 3 Daniel Walsh 2007-01-15 16:20:04 EST
Sorry about that, Upstream changed the API of libselinux which caused us to pull
back the version of policycoreutils.  So libselinux went into testing today.

libselinux-1.33.4-2.fc6.i386.rpm

I will put that out for a couple of days in testing, and once it moves to final,
I  can put policycoreutils into testing.  

If you want to test the newpackages, they are available for RHEL5 right now on
ftp://people.redhat.com/dwalsh/SELinux/RHEL5
libselinux/policycoreutils for RHEL5 should work fine on FC6.
Comment 4 Tomasz Torcz 2007-06-06 03:04:47 EDT
It still errors on Fedora 7. Locale is pl_PL.UTF-8

Jun  6 09:02:44 s1.crocom.com.pl setroubleshoot: [rpc.ERROR] exception
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0142' in position
3: ordinal not in range(128) Traceback (most recent call last):   File
"/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py", line 780, in
handle_client_io     self.receiver.feed(data)   File
"/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py", line 621, in feed    
self.process()   File "/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py",
line 613, in process     self.dispatchFunc(self.header, self.body)   File
"/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py", line 821, in
default_request_handler     self.emit_rpc(rpc_id, 'method_return',
rpc_callback_def, *return_args)   File
"/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py", line 726, in emit_rpc
    rpc_xml = convert_rpc_to_xml(rpc_id, rpc_def, *args)   File
"/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py", line 199, in
convert_rpc_to_xml     arg_node.addChild(arg_value.get_xml_nodes(doc, arg_name))

Jun  6 09:02:44 s1.crocom.com.pl setroubleshoot: [rpc.ERROR] could send data on
socket ({unix}/var/run/setroubleshoot/setroubleshoot_server): (32, 'Broken pipe')
Jun  6 09:02:48 s1.crocom.com.pl setroubleshoot: [rpc.ERROR] exception
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0142' in position
3: ordinal not in range(128) Traceback (most recent call last):   File
"/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py", line 780, in
handle_client_io     self.receiver.feed(data)   File
"/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py", line 621, in feed    
self.process()   File "/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py",
line 613, in process     self.dispatchFunc(self.header, self.body)   File
"/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py", line 821, in
default_request_handler     self.emit_rpc(rpc_id, 'method_return',
rpc_callback_def, *return_args)   File
"/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py", line 726, in emit_rpc
    rpc_xml = convert_rpc_to_xml(rpc_id, rpc_def, *args)   File
"/usr/lib/python2.5/site-packages/setroubleshoot/rpc.py", line 199, in
convert_rpc_to_xml     arg_node.addChild(arg_value.get_xml_nodes(doc, arg_name))

Jun  6 09:02:48 s1.crocom.com.pl setroubleshoot: [rpc.ERROR] could send data on
socket ({unix}/var/run/setroubleshoot/setroubleshoot_server): (32, 'Broken pipe')

Comment 5 Leszek Matok 2007-11-16 13:41:56 EST
Fedora 8's semanage is still broken with pl_PL(.UTF8). I've come into this when
installing selinux-policy-targeted (its install script is calling the first
command I'm demonstrating)

[root@pensja ~]# setenv LANG pl_PL
[root@pensja ~]# semanage user -a -P unconfined -R "unconfined_r system_r" -r
s0-s0:c0.c1023 unconfined_u
Failed to translate booleans.
[Errno 2] No such file or directory: '/usr/share/selinux/devel/policy.xml'
/usr/sbin/semanage: Traceback (most recent call last):
  File "/usr/sbin/semanage", line 352, in <module>
    errorExit(error.args[0])
  File "/usr/sbin/semanage", line 98, in errorExit
    sys.stderr.write("%s\n" % error)
  File "/usr/lib/python2.5/codecs.py", line 303, in write
    data, consumed = self.encode(object, self.errors)
  File "/usr/lib/python2.5/encodings/iso8859_2.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_table)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 1: ordinal
not in range(128)
[root@pensja ~]# semanage user -l                                              
Failed to translate booleans.
[Errno 2] No such file or directory: '/usr/share/selinux/devel/policy.xml'

                Etykiety   MLS/       MLS/                          
/usr/sbin/semanage: ascii
[root@pensja ~]# unsetenv LANG                                                 
[root@pensja ~]# semanage user -l
Failed to translate booleans.
[Errno 2] No such file or directory: '/usr/share/selinux/devel/policy.xml'

                Labeling   MLS/       MLS/                          
SELinux User    Prefix     MCS Level  MCS Range                      SELinux Roles

guest_u         guest      s0         s0                             guest_r
(now it works)

pl.po doesn't look suspicious and I don't know Python at all.
Comment 6 Leszek Matok 2007-11-16 13:57:42 EST
I forgot to mention: this is policycoreutils-2.0.31-15.fc8 from F8's
updates-testing.

With F8-standard policycoreutils-2.0.31-7.fc8 everything is the same except for
the "Failed to translate booleans." messages (which probably have their own
bugzilla ID).
Comment 7 Daniel Walsh 2007-11-19 13:07:49 EST
If you comment out these two lines in /usr/sbin/semanage 

does it work fine for you?
#sys.stderr = codecs.getwriter(locale.getpreferredencoding())(sys.__stderr__,
'replace')
#sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.__stdout__,
'replace')



Comment 8 Daniel Walsh 2007-11-19 13:21:22 EST
Fixed in policycoreutils-2.0.31-18
Comment 9 Leszek Matok 2007-11-19 15:41:04 EST
I've downloaded policycoreutils-2.0.31-18.fc8 from Koji and can confirm that
this time it's really fixed. Thanks a lot!

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