From owner-freebsd-current Sun Mar 12 18: 6:38 2000 Delivered-To: freebsd-current@freebsd.org Received: from mail.originative.co.uk (mailgate.originative.co.uk [194.217.50.228]) by hub.freebsd.org (Postfix) with ESMTP id 571A237B541 for ; Sun, 12 Mar 2000 18:06:34 -0800 (PST) (envelope-from paul@originative.co.uk) Received: from originative.co.uk (lobster.originative.co.uk [194.217.50.241]) by mail.originative.co.uk (Postfix) with ESMTP id A513D1D132; Mon, 13 Mar 2000 02:06:32 +0000 (GMT) Message-ID: <38CC4D28.2268BD00@originative.co.uk> Date: Mon, 13 Mar 2000 02:06:32 +0000 From: Paul Richards Organization: Originative Solutions Ltd X-Mailer: Mozilla 4.7 [en] (X11; I; FreeBSD 4.0-CURRENT i386) X-Accept-Language: en-GB, en MIME-Version: 1.0 To: Peter Jeremy Cc: current@FreeBSD.ORG Subject: Re: MAX_UID ? 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> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Peter Jeremy wrote: > > On 2000-Mar-13 12:01:03 +1100, Paul Richards 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