Re: PATCH: report NGROUPS_MAX via a sysctl (read-only)

Tim Hockin
2004-02-25T01:15:05Z

On Wed, Feb 25, 2004 at 11:29:27AM +1030, Glen Turner wrote:
> The mere existence of the value means it can be used correctly
> in application code for sanity checking.

Andrew seems to have picked it up for -mm. I sent a patch to glibc-bugs (is
that the right place? any libc folk?) to use the new sysctl in
sysconf(_SC_NGROUPS_MAX). So if/when all those releases converge, you
should be able to get the kernel's idea of NGROUPS_MAX from
sysconf(_SC_NGROUPS_MAX);

> Returning INT_MAX for NGROUPS_MAX isn't wrong, but you
> then can't blame user space for making inefficient choices
> if the kernel limit is actually smaller.

Well, if the kernel HAS no limit, then NGROUPS_MAX really is INT_MAX. There
are not many legit uses I can think of for userspace to actually care about
NGROUPS_MAX. Just the current number of groups, which is easily gotten via
setgroups().

Now that the sysctl is in, it's a very tiny patch to make ngroups_max
actually raisable/ by sysctl, though it is debatable whether it is useful AT
ALL, and dubious whether it is safe to lower that value after any apps are
running.

--
Tim Hockin
thockin@hockin.org
Soon anyone who's not on the World Wide Web will qualify for a government
subsidy for the home-pageless.