GNOME Bugzilla – Bug 304696
the profile dialog has weird usernames sometimes
Last modified: 2005-05-19 08:44:42 UTC
example for "gnome:x:1001:1001:,,,:/home/gnome:/bin/bash" the username is ",,," usersdialog.py uses this code: if pw.pw_gecos: name = pw.pw_gecos >>> pw = pwd.getpwnam ("gnome") >>> pw.pw_gecos ',,,' one possible fix: --- admin-tool/usersdialog.py 12 May 2005 12:30:20 -0000 1.1 +++ admin-tool/usersdialog.py 18 May 2005 20:02:29 -0000 @@ -38,8 +38,8 @@ for user in db.get_users (): pw = pwd.getpwnam (user) - if pw.pw_gecos: - name = pw.pw_gecos + if pw.pw_gecos and pw.pw_gecos != ",,,": + name = pw.pw_gecos.split(",,,")[0] else: name = user The split handles "UserName,,," cases
splitting on "," is probably better : --- admin-tool/usersdialog.py 12 May 2005 12:30:20 -0000 1.1 +++ admin-tool/usersdialog.py 18 May 2005 20:02:29 -0000 @@ -38,8 +38,8 @@ for user in db.get_users (): pw = pwd.getpwnam (user) - if pw.pw_gecos: - name = pw.pw_gecos + if pw.pw_gecos and pw.pw_gecos != ",,,": + name = pw.pw_gecos.split(",")[0] else: name = user
Is this user a real user or a system one? Why does it have ",,," in its gecos field anyway? How about name = None if pw.pw_gecos: name = pw.pw_gecos.split(",")[0] if not name: name = user
",,," is the field you get when you do "adduser <user>" and validate all the empty fields on a Debian/Ubuntu install your solution seems to be fine
Thanks 2005-05-19 Mark McLoughlin <markmc@redhat.com> Based on a patch from Sebastien Bacher <seb128@debian.org> in bug #304696 * admin-tool/usersdialog.py: pw_gecos is a comma separated list of values - split it an use the first value as the user's name. If that's not set, just use the username as the user's name.