]> git.ipfire.org Git - thirdparty/shadow.git/commit
find_new_[gu]id(): Skip over IDs that are reserved for legacy reasons
authorMartin Kletzander <nert.pinx@gmail.com>
Wed, 1 Feb 2023 14:36:41 +0000 (15:36 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 20 Feb 2023 11:10:02 +0000 (12:10 +0100)
commitbaae5b4a06c905d9f52ed1f922a0d7d0625d11cf
treee7103d07b3056389edd105b1fda737dd5edc2760
parent0dfeb9e6747bdbd58d0e262fc22947e4e628eefb
find_new_[gu]id(): Skip over IDs that are reserved for legacy reasons

Some programs don't support `(uint16_t) -1` or `(uint32_t) -1` as user
or group IDs.  This is because `-1` is used as an error code or as an
unspecified ID, e.g. in `chown(2)` parameters, and in the past, `gid_t`
and `uid_t` have changed width.  For legacy reasons, those values have
been kept reserved in programs today (for example systemd does this; see
the documentation in the link below).

This should not be confused with catching overflow in the ID values,
since that is already caught by our ERANGE checks.  This is about not
using reserved values that have been reserved for legacy reasons.

Link: <https://systemd.io/UIDS-GIDS/>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
libmisc/find_new_gid.c
libmisc/find_new_uid.c