Bug 1295887 - Certificate organization with characters outside the ASCII causes a setup failure
Summary: Certificate organization with characters outside the ASCII causes a setup fai...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: otopi
Classification: oVirt
Component: General
Version: 1.4.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ovirt-4.0.0-alpha
: 1.5.0
Assignee: Yedidyah Bar David
QA Contact: Lukas Svaty
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-01-05 17:16 UTC by Juan Hernández
Modified: 2017-05-11 09:23 UTC (History)
10 users (show)

Fixed In Version: ovirt 4.0.0 alpha1
Clone Of:
Environment:
Last Closed: 2016-07-05 07:38:31 UTC
oVirt Team: Integration
Embargoed:
rule-engine: ovirt-4.0.0+
rule-engine: planning_ack+
sbonazzo: devel_ack+
pstehlik: testing_ack+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 54731 0 master MERGED filetransaction: Convert sequences toStr 2016-03-15 09:06:03 UTC

Description Juan Hernández 2016-01-05 17:16:54 UTC
When a string containing characters outside the ASCII character set is provided as the name of the organization of the certificate it produces a failure of the 
setup, with the following error message:

---8<---
[ INFO  ] Generating post install configuration file '/etc/ovirt-engine-setup.conf.d/20-setup-ovirt-post.conf'
[ ERROR ] Failed to execute stage 'Misc configuration': 'ascii' codec can't decode byte 0xc3 in position 38: ordinal not in range(128)
--->8---

The log says the following:

---8<---
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/otopi/context.py", line 146, in _executeMethod
    method['method']()
  File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/core/postinstall.py", line 86, in _misc
    otopicons.CoreEnv.MODIFIED_FILES
  File "/usr/lib/python2.7/site-packages/otopi/filetransaction.py", line 161, in __init__
    self._content = '\n'.join(content)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 38: ordinal not in range(128)
--->8---

I believe that the root cause of the problem is in otopi, when it reads the string from the input. The text given by the user is converted into a Python str object, but encoded using UTF-8. For example, if the text "á" is given then it will be translated into the byte string [195, 173] (an instance of "str", not "unicode"). This works well with most Python string functions, as they don't care about the fact that 195 and 173 aren't valid ASCII characters. But functions that try to convert this byte string to Unicode will fail, with an exception similar to this:

  File "./test.py", line 6, in <module>
    name = name.decode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)

One notable case is the string "join" method. This methods joins a list of strings with a separator, and it supports both "str" and "unicode", even mixed:

  list = [ byte_string, unicode_string ]
  joined = '\n'.join(list)

In the above example, if "byte_string" is the result of reading "á" then the UnicodeDecodeError exception will be raised.

The "join" method is used like this in multiple places inside otopi, in particular inside the FileTransaction.__init__ method, to convert a list of strings to the content of a file, and this method is used by engine-setup in order to generate the /etc/ovirt-engine-setup.conf.d/20-setup-ovirt-post.conf file.

Comment 1 Nikolai Sednev 2016-04-11 14:04:10 UTC
Please take a look at the https://bugzilla.redhat.com/show_bug.cgi?id=1316908#c5, might be useful for this bug too.

Comment 2 Lukas Svaty 2016-07-01 11:11:12 UTC
verified in otopi-1.5.0-3.el7ev.noarch ovirt-engine-4.0.0.6-0.1.el7ev.noarch

Comment 3 Sandro Bonazzola 2016-07-05 07:38:31 UTC
oVirt 4.0.0 has been released, closing current release.


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