summaryrefslogtreecommitdiffstats
path: root/usr.sbin/jail/jail.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/jail/jail.c')
-rw-r--r--usr.sbin/jail/jail.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.sbin/jail/jail.c b/usr.sbin/jail/jail.c
index 3963de5..e00610b 100644
--- a/usr.sbin/jail/jail.c
+++ b/usr.sbin/jail/jail.c
@@ -104,7 +104,7 @@ extern char **environ;
lcap = login_getpwclass(pwd); \
if (lcap == NULL) \
err(1, "getpwclass: %s", username); \
- ngroups = NGROUPS; \
+ ngroups = ngroups_max; \
if (getgrouplist(username, pwd->pw_gid, groups, &ngroups) != 0) \
err(1, "getgrouplist: %s", username); \
} while (0)
@@ -115,10 +115,11 @@ main(int argc, char **argv)
login_cap_t *lcap = NULL;
struct iovec rparams[2];
struct passwd *pwd = NULL;
- gid_t groups[NGROUPS];
+ gid_t *groups;
size_t sysvallen;
int ch, cmdarg, i, jail_set_flags, jid, ngroups, sysval;
int hflag, iflag, Jflag, lflag, rflag, uflag, Uflag;
+ long ngroups_max;
unsigned pi;
char *ep, *jailname, *securelevel, *username, *JidFile;
char errmsg[ERRMSG_SIZE], enforce_statfs[4];
@@ -132,6 +133,10 @@ main(int argc, char **argv)
jailname = securelevel = username = JidFile = cleanenv = NULL;
fp = NULL;
+ ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1;
+ if ((groups = malloc(sizeof(gid_t) * ngroups_max)) == NULL)
+ err(1, "malloc");
+
while ((ch = getopt(argc, argv, "cdhilmn:r:s:u:U:J:")) != -1) {
switch (ch) {
case 'd':
OpenPOWER on IntegriCloud