Bug 18699

Summary: Incorrect user's full name, doens't parse GECOS
Product: ConsoleKit Reporter: Ross Burton <ross>
Component: DaemonAssignee: william.jon.mccann
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: magic
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Search a comma to truncate the string
The right patch
Looking for 3 commas

Description Ross Burton 2008-11-25 08:14:53 UTC
$ ck-list-sessions 
Session1:
	uid = '1000'
	realname = 'Ross Burton,,,'
	seat = 'Seat1'
	session-type = ''
	active = TRUE
	x11-display = ':0'
	x11-display-device = '/dev/tty7'
	display-device = ''
	remote-host-name = ''
	is-local = TRUE
	on-since = '2008-11-23T09:58:25.055160Z'

I'm pretty certain my passport doesn't say "Ross Burton,,,".  I guess CK should see if the field contains three commas, and if it does then parse it as a GECOS field (http://en.wikipedia.org/wiki/Gecos_field), otherwise use the entire string as the name.
Comment 1 Vincent Ricard 2008-12-04 05:43:56 UTC
Created attachment 20812 [details] [review]
Search a comma to truncate the string

Here is a patch looking for a comma before truncating the string. I'm not sure if the GECOS delimiter is the same accross the unices (Linux, *BSD, AIX, etc). It remains a question: what about the real name containing a comma?
Comment 2 Vincent Ricard 2008-12-04 05:45:48 UTC
Created attachment 20813 [details] [review]
The right patch

Sorry, here is the right patch (the former does not compile).
Comment 3 Ross Burton 2008-12-04 06:20:22 UTC
Checking that there are three commas would handle false-positives in the case where the field contains "Bar, Foo".
Comment 4 Vincent Ricard 2008-12-05 03:52:29 UTC
I discover the GECOS handling... this is the hell ;-)

> Checking that there are three commas would handle false-positives in the case
> where the field contains "Bar, Foo".

What do you mean i should do?
1- look for the string ",,," to detect a GECOS format then truncating the string (this solution fixes the entry "Burton, Ross,,," but not "Burton, Ross,Room R123,,")
2- look for the 3 times string "," ? (by starting from the end, we could handle more cases)

Definitively, the real name should be stored elsewhere :-)
Comment 5 Ross Burton 2008-12-05 05:41:23 UTC
I'd search the string for at least three commas.  If there are three or more, the username is up to the first comma.  If less, then the username is the entire field.

If GECOS is being used then the user's real name can't contain any commas (see chfn(1)).
Comment 6 Vincent Ricard 2008-12-08 05:05:56 UTC
Created attachment 20891 [details] [review]
Looking for 3 commas

Here is a new patch following the advices of Ross (thx, btw :-); it should handle the common cases.
Comment 7 william.jon.mccann 2009-02-11 18:53:24 UTC
Sorry for the long delay.  I've fixed this to use the same method that glib uses.  Should be fixed in master.  Please reopen if you still have problems.  Thanks.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.