After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 541945 - [PATCH] Parse gecos field (i.e. don't show username commas)
[PATCH] Parse gecos field (i.e. don't show username commas)
Status: RESOLVED FIXED
Product: policykit-gnome
Classification: Platform
Component: authentication dialog
unspecified
Other Linux
: Normal normal
: ---
Assigned To: policykit-gnome-maint
policykit-gnome-maint
: 557478 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-07-07 19:24 UTC by Michael Terry
Modified: 2009-05-26 19:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (873 bytes, patch)
2008-07-07 19:25 UTC, Michael Terry
none Details | Review
Patch v2 (1.08 KB, patch)
2008-07-07 20:08 UTC, Michael Terry
none Details | Review
Patch against git (1.42 KB, patch)
2009-02-24 16:04 UTC, Michael Terry
none Details | Review

Description Michael Terry 2008-07-07 19:24:50 UTC
The authentication dialog shows user names pulled from a passwd struct returned by getpwnam.

The relevant field is pw_gecos, and currently the code uses the full string.  However, according to the man page (e.g. http://www.daemon-systems.org/man/passwd.5.html), pw_gecos is a comma-delimited field containing first, the user's name, and then data like various phone numbers.

I'd argue that we only want to show the first field of that comma-delimited list.  In the common case, we merely get several unsightly commas.  But if there's actual data there, the combo box would look terrible.

Attached is a patch to parse pw_gecos.  The only issue is whether normal commas can appear in a user's name.  /usr/sbin/adduser didn't let me use one.  Presumably you can't?

Copyright is Canonical, Ltd.'s.
Comment 1 Michael Terry 2008-07-07 19:25:19 UTC
Created attachment 114142 [details] [review]
Proposed patch
Comment 2 Michael Terry 2008-07-07 20:08:15 UTC
Created attachment 114144 [details] [review]
Patch v2

Whoops.  I realized once I hit 'Submit' that I neglected to handle the case of the first delimited field being empty.  Here ya go.
Comment 3 David Zeuthen (not reading bugmail) 2009-02-12 17:21:06 UTC
Patch looks fine to me from a cursory look except for coding standard issues (don't treat pointers as booleans in the if statement, declaration/assignment should be on separate lines).

 However, please note that

 - All this code has basically been rewritten for PolicKit version 0.90 and up
   - GNOME 2.27/2.28 will switch to this new version of PolicyKit-gnome
 - PolicyKit-gnome is in git, see http://git.gnome.org/cgit/PolicyKit-gnome/

I think the PolicyKit in git HEAD still suffers from that so it would be good to fix that.
Comment 4 Matthew Paul Thomas (mpt) 2009-02-19 16:10:19 UTC
*** Bug 557478 has been marked as a duplicate of this bug. ***
Comment 5 Michael Terry 2009-02-24 16:04:17 UTC
Created attachment 129416 [details] [review]
Patch against git

So this patch is against git master.

It changes one thing besides style changes you suggested: I grabbed the g_locale_to_utf8 call from tools/polkit-gnome-authorization.c.  That file had similar code, but was using g_locale_to_utf8.  While I assumed that code was dead (tools isn't a SUBDIR in Makefile.am), I also assumed that that call had been there for a reason.  If that code isn't dead, I can patch it too.

man 5 passwd didn't give any info about the expected encoding.  If I'm wrong and we don't need g_locale_to_utf8 there, just replace it with a g_strdup, please.
Comment 6 David Zeuthen (not reading bugmail) 2009-05-26 19:52:50 UTC
Fixed in commit e758975e8b429f5aa1d80cd9e928236ddcf9380f. Thanks!