]> git.ipfire.org Git - thirdparty/shadow.git/commit
src/chfn.c: Do not allow the 'slop' fields to appear before any non-slop gecos fields
authorAlejandro Colomar <alx@kernel.org>
Fri, 18 Jul 2025 21:53:30 +0000 (23:53 +0200)
committerSerge Hallyn <serge@hallyn.com>
Sat, 9 Aug 2025 23:00:36 +0000 (18:00 -0500)
commit51fa767a75930d869b1db6237762c00fac40a22d
treeb76d875899497a4a369eb9466ff5e05b172936b7
parent3d5f1e88d5f0c4ed788c9e36207bfd65768bdee8
src/chfn.c: Do not allow the 'slop' fields to appear before any non-slop gecos fields

According to the Wikipedia page for the 'Gecos field', the "typical"
format for the GECOS field is a comma-delimited list with this order:

1)  User's full name (or application name, if the account is for a program)
2)  Building and room number or contact person
3)  Office telephone number
4)  Home telephone number
5+) Any other contact information (pager number, fax, external e-mail address, etc.)

But our code supported the "other contact information", which we call
slop, and which is composed of an arbitrary number of key=value fields,
to appear before any of the other 4 fields.

This seems to be undocumented, and none of the documentation I've found
for the GECOS field in any systems I checked claims to support this.
By removing support for those, we can significantly simplify the
copy_field() function, which was quite unreadable.

After this patch, the GECOS field is treated as a CSV, blindly copying
the fields as they appear, where the first 4 fields are as specified
above, and anything after them is the slop (5+ fields, any other contact
information).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/chfn.c