Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Mar 2000 02:06:32 +0000
From:      Paul Richards <paul@originative.co.uk>
To:        Peter Jeremy <peter.jeremy@alcatel.com.au>
Cc:        current@FreeBSD.ORG
Subject:   Re: MAX_UID ?
Message-ID:  <38CC4D28.2268BD00@originative.co.uk>
References:  <38CAD957.3C839375@originative.co.uk> <200003120430.UAA49807@vashon.polstra.com> <38CB322D.D12ED0B0@originative.co.uk> <20000313015009.A5653@hades.hell.gr> <38CC30FB.FC417909@originative.co.uk> <200003130018.TAA32652@khavrinen.lcs.mit.edu> <38CC3D6F.73152D6D@originative.co.uk> <00Mar13.121319est.115208@border.alcanet.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
Peter Jeremy wrote:
> 
> On 2000-Mar-13 12:01:03 +1100, Paul Richards <paul@originative.co.uk> wrote:
> >id = strtoul(p, (char **)NULL, 10);
> >    if ((errno == ERANGE) || (id >= UID_MAX)) {
> >        warnx("%s > max uid value (%lu)", p, UID_MAX);
> >        return (0);
> >}
> 
> You can do this now.  Just add the following:
>         pid_t   UID_MAX = ~0;
> somewhere before the code.

I assume you meant uid_t, but anyway, yes that can be done but I'm
looking for a more generic solution since this is a widespread problem
in the userland code.
 
> >When you see it written out like that the latter is a lot more
> >informative. It also provides the flexibility to limit the parameters
> >max value even if the type allows it to be larger. This is of particular
> >significance to UIDs which are currently limited to a far smaller value
> >than would fit in a uid_t.
> 
> AFAIK, there's no real hard limit.  adduser(8) limits uids to 32000
> to prevent portability problems with systems using a signed 16-bit
> uid_t (whilst allowing for a few `special' uids near the top of the
> range).  Other potential limits are ~65000 (16-bit unsigned) and
> 99999 (5 decimal digits).

The actual limit is 4294967295, which is the largest number that will
fit into the the 32-bit uid_t. This does work, I've been playing around
with it for the last few days. At least, it works from a kernel
perspective, there are many applications that screw things up, most of
them use atol to do conversions which limits the UID to half that. If
you stick within the signed 32 bit limits most things seem to work.

> It would be nice if there was a system-wide constant that could be
> used for this, but it's not obvious where this should be located.
> (And note that adduser(8) is a perl script, so it can't use a C
> header file without some contortions).

Perl can use C include files (after performing some magic) so that
wouldn't be a problem.

Paul.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38CC4D28.2268BD00>