diff options
author | brooks <brooks@FreeBSD.org> | 2010-01-12 07:49:34 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2010-01-12 07:49:34 +0000 |
commit | a093b41dafbd7defb7612a20d5672d938b8a54ed (patch) | |
tree | de91cf4c019f8024f0f1e02debf82cece77d60f2 /sys/kern/subr_param.c | |
parent | 5d104fe3d7b80ec6fa42b6b91bdfb5c7b24c7775 (diff) | |
download | FreeBSD-src-a093b41dafbd7defb7612a20d5672d938b8a54ed.zip FreeBSD-src-a093b41dafbd7defb7612a20d5672d938b8a54ed.tar.gz |
Replace the static NGROUPS=NGROUPS_MAX+1=1024 with a dynamic
kern.ngroups+1. kern.ngroups can range from NGROUPS_MAX=1023 to
INT_MAX-1. Given that the Windows group limit is 1024, this range
should be sufficient for most applications.
MFC after: 1 month
Diffstat (limited to 'sys/kern/subr_param.c')
-rw-r--r-- | sys/kern/subr_param.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index 6113b63..fcd8131 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include "opt_param.h" #include "opt_maxusers.h" +#include <sys/limits.h> #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> @@ -88,6 +89,7 @@ int maxfiles; /* sys. wide open files limit */ int maxfilesperproc; /* per-proc open files limit */ int ncallout; /* maximum # of timer events */ int nbuf; +int ngroups_max; /* max # groups per process */ int nswbuf; long maxswzone; /* max swmeta KVA storage */ long maxbcache; /* max buffer cache KVA storage */ @@ -228,6 +230,18 @@ init_param1(void) TUNABLE_ULONG_FETCH("kern.maxssiz", &maxssiz); sgrowsiz = SGROWSIZ; TUNABLE_ULONG_FETCH("kern.sgrowsiz", &sgrowsiz); + + /* + * Let the administrator set {NGROUPS_MAX}, but disallow values + * less than NGROUPS_MAX which would violate POSIX.1-2008 or + * greater than INT_MAX-1 which would result in overflow. + */ + ngroups_max = NGROUPS_MAX; + TUNABLE_INT_FETCH("kern.ngroups", &ngroups_max); + if (ngroups_max < NGROUPS_MAX) + ngroups_max = NGROUPS_MAX; + if (ngroups_max > INT_MAX - 1) + ngroups_max = INT_MAX - 1; } /* |