summaryrefslogtreecommitdiffstats
path: root/usr.sbin/jexec
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/jexec')
-rw-r--r--usr.sbin/jexec/jexec.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.sbin/jexec/jexec.c b/usr.sbin/jexec/jexec.c
index e86657bf..143bbd5 100644
--- a/usr.sbin/jexec/jexec.c
+++ b/usr.sbin/jexec/jexec.c
@@ -59,7 +59,7 @@ static void usage(void);
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)
@@ -71,12 +71,17 @@ main(int argc, char *argv[])
int jid;
login_cap_t *lcap = NULL;
struct passwd *pwd = NULL;
- gid_t groups[NGROUPS];
+ gid_t *groups = NULL;
int ch, ngroups, uflag, Uflag;
+ long ngroups_max;
char *ep, *username;
ch = uflag = Uflag = 0;
username = 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, "nu:U:")) != -1) {
switch (ch) {
case 'n':
OpenPOWER on IntegriCloud