2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
12 * Afs_xsetgroups (syscall)
16 #include <afsconfig.h>
17 #include "afs/param.h"
21 #include "afs/sysincludes.h"
22 #include "afsincludes.h"
23 #include "afs/afs_stats.h" /* statistics */
40 Afs_xsetgroups(p, args, retval)
48 AFS_STATCNT(afs_xsetgroups);
51 code = afs_InitReq(&treq, u.u_cred);
53 if (code) return code;
55 code = setgroups(p, args, retval);
56 /* Note that if there is a pag already in the new groups we don't
57 * overwrite it with the old pag.
59 if (PagInCred(u.u_cred) == NOPAG) {
60 if (((treq.uid >> 24) & 0xff) == 'A') {
62 /* we've already done a setpag, so now we redo it */
63 AddPag(p, treq.uid, &p->p_rcred);
72 setpag(proc, cred, pagvalue, newpag, change_parent)
77 afs_uint32 change_parent;
79 gid_t gidset[NGROUPS];
84 ngroups = afs_getgroups(*cred, NGROUPS, gidset);
85 if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) {
86 /* We will have to shift grouplist to make room for pag */
87 if (ngroups + 2 > NGROUPS) {
90 for (j = ngroups -1; j >= 0; j--) {
91 gidset[j+2] = gidset[j];
95 *newpag = (pagvalue == -1 ? genpag(): pagvalue);
96 afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]);
97 code = afs_setgroups(proc, cred, ngroups, gidset, change_parent);
108 int ngrps, savengrps;
111 AFS_STATCNT(afs_getgroups);
112 savengrps = ngrps = MIN(ngroups, cred->cr_ngroups);
113 gp = cred->cr_groups;
132 struct ucred *newcr, *cr;
134 AFS_STATCNT(afs_setgroups);
136 * The real setgroups() call does this, so maybe we should too.
139 if (ngroups > NGROUPS)
142 if (!change_parent) {
147 newcr->cr_ngroups = ngroups;
148 gp = newcr->cr_groups;
151 if (!change_parent) {
152 substitute_real_creds(proc, NOUID, NOUID, NOGID, NOGID, newcr);