Date: Fri, 28 Feb 1997 07:42:12 -0800 (PST) From: "Jordan K. Hubbard" <jkh@time.cdrom.com> To: bde@freebsd.org Cc: hackers@freebsd.org Subject: Will the real uid_t please stand up? Message-ID: <199702281542.HAA29897@time.cdrom.com>
next in thread | raw e-mail | index | archive | help
Following some of the discussion in port-i386@NetBSD.org about this, I decided to look into FreeBSD's own uid_t situation and noticed the following "interesting things" in 2.2 and -current: /usr/include/g++/_G_config.h:typedef unsigned int _G_uid_t; OK, one vote for unsigned int. /usr/include/kerberosIV/krb.h:typedef unsigned short uid_t; Ooh, and one for unsigned short! Fortunately, this one is disabled by an ifdef but it probably should still be changed. /usr/include/sys/types.h:typedef u_int32_t uid_t; /* user And that looks reasonable. But here's the clincher: Adding this user to the password file: test:*:1048576:32766::0:0:Just Testing:/tmp:/sbin/nologin Results in this: vipw: rebuilding the database... pwd_mkdb: 1048576 > max uid value (65535) vipw: done And the check in /usr/src/usr.sbin/pwd_mkdb/pw_scan.c does indeed say: if (id > USHRT_MAX) { warnx("%s > max uid value (%d)", p, USHRT_MAX); /*return (0);*/ /* THIS SHOULD NOT BE FATAL! */ } (same mistake made for gid_t). It's not fatal, but it certainly doesn't seem right. Does the following patch seem appropriate or are there reasons for artificially limiting uid_t to a ushort which I still don't know about? Jordan --- /usr/src/usr.sbin/pwd_mkdb/pw_scan.c.orig Fri Feb 28 07:37:48 1997 +++ /usr/src/usr.sbin/pwd_mkdb/pw_scan.c Fri Feb 28 07:37:49 1997 @@ -81,8 +81,8 @@ warnx("root uid should be 0"); return (0); } - if (id > USHRT_MAX) { - warnx("%s > max uid value (%d)", p, USHRT_MAX); + if (id > UINT_MAX) { + warnx("%s > max uid value (%d)", p, UINT_MAX); /*return (0);*/ /* THIS SHOULD NOT BE FATAL! */ } pw->pw_uid = id; @@ -91,8 +91,8 @@ goto fmt; if(p[0]) pw->pw_fields |= _PWF_GID; id = atol(p); - if (id > USHRT_MAX) { - warnx("%s > max gid value (%d)", p, USHRT_MAX); + if (id > UINT_MAX) { + warnx("%s > max gid value (%d)", p, UINT_MAX); /* return (0); This should not be fatal! */ } pw->pw_gid = id;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702281542.HAA29897>