Subject: Re: Defining a maximum value for uid's.
To: None <>
From: J.T. Conklin <jtc@NetBSD.ORG>
List: tech-userlevel
Date: 05/19/1997 10:37:23
> To do this, I've been converting the use of atoi() to strtoul(), and
> checking appropriate values to ensure that the parsed field was just a
> number.
> However, on the alpha, the return value of strtoul() is a unsigned 64
> bit long, which may exceed the size of uid_t (unsigned 32 bit int).
> So, I would like to create the following defines in <limits.h> or
> <machine/limits.h>, and check against them in the relevant areas:
> 	#define		UID_MAX		4294967294	/* 2^32 - 2 */
> 	#define		GID_MAX		4294967294

Hmm, if my rusty memory cells aren't failing me, I think that XPG4.2
may have specified macros for this purpose.  Unfortunately, I don't
have the documents with me; and the MAXUID I found by grep'ing thru
Solaris 2.5 headers doesn't ring a bell.

If there is an established standard (or even de facto convention) for
uid/gid maximum manifest constants, we should use those names.
Otherwise, UID_MAX and GID_MAX are fine with me.

> It's 2^32-2 because setreuid treats -1 as a special value.
> I had thought about using 2147483647 (2^31-1), because of setreuid()
> That halves the size of the uid space, however.

It's not like that will be a significant limitation.  FWIW, Solaris'
MAXUID is set to 2^31-1.