Bug 1295887 - Certificate organization with characters outside the ASCII causes a setup failure
Certificate organization with characters outside the ASCII causes a setup fai...
Product: otopi
Classification: oVirt
Component: General (Show other bugs)
Unspecified Unspecified
unspecified Severity high (vote)
: ovirt-4.0.0-alpha
: 1.5.0
Assigned To: Yedidyah Bar David
Lukas Svaty
Depends On:
  Show dependency treegraph
Reported: 2016-01-05 12:16 EST by Juan Hernández
Modified: 2017-05-11 05:23 EDT (History)
10 users (show)

See Also:
Fixed In Version: ovirt 4.0.0 alpha1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-07-05 03:38:31 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: Integration
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
rule-engine: ovirt‑4.0.0+
rule-engine: planning_ack+
sbonazzo: devel_ack+
pstehlik: testing_ack+

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
oVirt gerrit 54731 master MERGED filetransaction: Convert sequences toStr 2016-03-15 05:06 EDT

  None (edit)
Description Juan Hernández 2016-01-05 12:16:54 EST
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:

[ 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)

The log says the following:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/otopi/context.py", line 146, in _executeMethod
  File "/usr/share/ovirt-engine/setup/bin/../plugins/ovirt-engine-common/base/core/postinstall.py", line 86, in _misc
  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)

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 10:04:10 EDT
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 07:11:12 EDT
verified in otopi-1.5.0-3.el7ev.noarch ovirt-engine-
Comment 3 Sandro Bonazzola 2016-07-05 03:38:31 EDT
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.