uid_t
is (after some typedefs/defines) defined as __U32_TYPE
which is defined as unsigned int
(that is on my Gentoo Linux system).
However, just because -1
has a special meaning it does not mean that UIDs are restricted to the numbers that fit in a signed int
. It just means that the highest value (i.e. (unsigned int)-1
) is not a valid UID. The code in setreuid
probably uses the reverse form of that cast ((signed int)ruid
) to compare against -1
cleanly although it accepts an uid_t
.