diff options
author | Casper H.S. Dik <Casper.Dik@Sun.COM> | 2009-11-20 20:58:43 +0100 |
---|---|---|
committer | Casper H.S. Dik <Casper.Dik@Sun.COM> | 2009-11-20 20:58:43 +0100 |
commit | 67dbe2be0c0f1e2eb428b89088bb5667e8f0b9f6 (patch) | |
tree | ae276da3565da2f00f984253f7b5da205d4384c5 /usr/src/cmd/print | |
parent | f73ae3db72a91f9f8759931a1c643c7dad785881 (diff) | |
download | illumos-gate-67dbe2be0c0f1e2eb428b89088bb5667e8f0b9f6.tar.gz |
PSARC 2009/542 Increase the maximum value of NGROUPS_MAX to 1024
4088757 Customer would like to increase ngroups_max more than 32
6853435 Many files incorrectly include the private <sys/cred_impl.h>
Diffstat (limited to 'usr/src/cmd/print')
-rw-r--r-- | usr/src/cmd/print/lpset/lpset.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/usr/src/cmd/print/lpset/lpset.c b/usr/src/cmd/print/lpset/lpset.c index d0a765caea..04b0cc7677 100644 --- a/usr/src/cmd/print/lpset/lpset.c +++ b/usr/src/cmd/print/lpset/lpset.c @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <stdlib.h> #include <sys/types.h> @@ -39,6 +37,7 @@ #include <libintl.h> #endif #include <pwd.h> +#include <alloca.h> #include <ns.h> #include <list.h> @@ -54,8 +53,9 @@ authorized() { struct passwd *pw; uid_t uid; - gid_t list[NGROUPS_MAX]; + gid_t *list; int len; + int maxgrp; if ((uid = getuid()) == 0) return (1); /* "root" is authorized */ @@ -69,8 +69,12 @@ authorized() if (chkauthattr("solaris.print.admin", pw->pw_name) == 1) return (1); /* "solaris.print.admin" is authorized */ - if ((len = getgroups(sizeof (list), list)) != -1) - for (; len >= 0; len--) + /* How many supplemental groups do we have? */ + maxgrp = getgroups(0, NULL); + list = alloca(maxgrp * sizeof (gid_t)); + + if ((len = getgroups(maxgrp, list)) != -1) + while (len-- > 0) if (list[len] == 14) return (1); /* group 14 is authorized */ |