#4804 Write properly encoded string into stderr, stdout
Closed: fixed 5 years ago Opened 9 years ago by mbasti.

Redirect write stderr or stdout to files can cause encoding errors if unicode characters are used and files doesn't use default encoding.

This problem is at least in optparser:

ipa-server-install --setup-dns --forwarder=192.0.2.1  -r TESTRELM.TEST -p xxxxxxxx -P xxxxxxxx -a xxxxxxxx --zonemgr=Têko@example.com -U > /tmp/ipaserverinstall_invalidzonemgr.out 2>&1
[root@dhcp207-1 install-server-cli]# cat /tmp/ipaserverinstall_invalidzonemgr.out Usage: ipa-server-install [options]

Traceback (most recent call last):
  File "/usr/sbin/ipa-server-install", line 1343, in <module>
    safe_options, options = parse_options()
  File "/usr/sbin/ipa-server-install", line 288, in parse_options
    options, args = parser.parse_args()
  File "/usr/lib64/python2.7/optparse.py", line 1399, in parse_args
    stop = self._process_args(largs, rargs, values)
  File "/usr/lib64/python2.7/optparse.py", line 1439, in _process_args
    self._process_long_opt(rargs, values)
  File "/usr/lib64/python2.7/optparse.py", line 1514, in _process_long_opt
    option.process(opt, value, values, self)
  File "/usr/lib64/python2.7/optparse.py", line 788, in process
    self.action, self.dest, opt, value, values, parser)
  File "/usr/lib64/python2.7/optparse.py", line 808, in take_action
    self.callback(self, opt, value, parser, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/ipaserver/install/bindinstance.py", line 414, in zonemgr_callback
    parser.error("invalid zonemgr: " + unicode(e))
  File "/usr/lib64/python2.7/optparse.py", line 1583, in error
    self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg))
  File "/usr/lib64/python2.7/optparse.py", line 1572, in exit
    sys.stderr.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 58-59:

In this case we can override error() method to encode characters in proper encoding.


The FreeIPA 4.2 was already shaped (see [[milestone:FreeIPA 4.2]] milestone), this does not fit. Pushing out.

If anyone is willing to help and contribute to this one, please let us know!

Metadata Update from @mbasti:
- Issue assigned to someone
- Issue set to the milestone: Future Releases

7 years ago

If is fixed in master (4.7.2+):

ipa-server-install: error: option zonemgr: domain name 'Têko.example.com' should be normalized to: tãako.example.com

Metadata Update from @rcritten:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

5 years ago

Login to comment on this ticket.

Metadata