Red Hat Bugzilla – Bug 1295887
Certificate organization with characters outside the ASCII causes a setup failure
Last modified: 2017-05-11 05:23:08 EDT
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.
Please take a look at the https://bugzilla.redhat.com/show_bug.cgi?id=1316908#c5, might be useful for this bug too.
verified in otopi-1.5.0-3.el7ev.noarch ovirt-engine-184.108.40.206-0.1.el7ev.noarch
oVirt 4.0.0 has been released, closing current release.