Bug 1121280

Summary: History list with login names fails with non-ascii names
Product: [Fedora] Fedora Reporter: Göran Uddeborg <goeran>
Component: dnfAssignee: Honza Silhan <jsilhan>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: akozumpl, jsilhan, packaging-team-maint, pnemade, rholy, tim.lauridsen
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-0.5.4-2.fc20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-08-01 06:03:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Göran Uddeborg 2014-07-18 20:57:30 UTC
Description of problem:
When trying to do a history list with user names rather than command lines I get a UnicodeDecodeError exception.  Some experimentation led me to the conclusion that is because of non-ascii letters in my login and full names.

Version-Release number of selected component (if applicable):
dnf-0.5.2-1.fc20.noarch

How reproducible:
Every time

Steps to Reproduce:
1. LANG=en_US.utf8 dnf --setopt=history_list_view=users history

Actual results:
ID     | Login user               | Date a | Action | Altere
-------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/bin/dnf", line 36, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 206, in user_main
    errcode = main(args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 82, in main
    return _main(base, args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 132, in _main
    cli.run()
  File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1163, in run
    return self.command.run(self.base.extcmds)
  File "/usr/lib/python2.7/site-packages/dnf/cli/commands/__init__.py", line 1530, in run
    ret = self.output.historyListCmd(extcmds)
  File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 1668, in historyListCmd
    name = self._pwd_ui_username(old.loginuid, 24)
  File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 1513, in _pwd_ui_username
    fullname = _safe_split_0(user.pw_gecos, ';', 2)
  File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 1506, in _safe_split_0
    ret = text.split(*args)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)


Expected results:
A history list with my name in most of the transactions.

Additional info:
Both my login id and my full name contain non-ascii letters.  Having a non-ascii login id might be stretching the the standards a bit.  But having a non ascii full name (gecos) must be considered quite normal.

I made the following patch which seems to work around the problem:

--- output.py.orig	2014-05-28 10:27:24.000000000 +0200
+++ output.py	2014-07-18 22:49:55.000000000 +0200
@@ -1510,8 +1510,8 @@
 
         try:
             user = pwd.getpwuid(uid)
-            fullname = _safe_split_0(user.pw_gecos, ';', 2)
-            name = "%s <%s>" % (fullname, user.pw_name)
+            fullname = _safe_split_0(ucd(user.pw_gecos), ';', 2)
+            name = "%s <%s>" % (fullname, ucd(user.pw_name))
             if limit is not None and len(name) > limit:
                 name = "%s ... <%s>" % (_safe_split_0(fullname), user.pw_name)
                 if len(name) > limit:

If this is the right thing to do, I don't know.  Encodings in Python are a mystery to me!

Bug 1108908, on its way to be fixed, concerns another unicode issue in dnf.

Comment 1 Honza Silhan 2014-07-28 11:40:43 UTC
Fixed in the upstream.

Comment 2 Fedora Update System 2014-07-29 06:45:19 UTC
dnf-0.5.4-2.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/dnf-0.5.4-2.fc20

Comment 3 Fedora Update System 2014-07-30 07:03:21 UTC
Package dnf-0.5.4-2.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-0.5.4-2.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-9009/dnf-0.5.4-2.fc20
then log in and leave karma (feedback).

Comment 4 Fedora Update System 2014-08-01 06:03:34 UTC
dnf-0.5.4-2.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.