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 "../afs/param.h"
17 #include "../afs/sysincludes.h"
18 #include "../afs/afsincludes.h"
19 #include "../afs/afs_stats.h" /* statistics */
36 Afs_xsetgroups(p, args, retval)
44 AFS_STATCNT(afs_xsetgroups);
47 code = afs_InitReq(&treq, u.u_cred);
49 if (code) return code;
51 code = setgroups(p, args, retval);
52 /* Note that if there is a pag already in the new groups we don't
53 * overwrite it with the old pag.
55 if (PagInCred(u.u_cred) == NOPAG) {
56 if (((treq.uid >> 24) & 0xff) == 'A') {
58 /* we've already done a setpag, so now we redo it */
59 AddPag(p, treq.uid, &p->p_rcred);
68 setpag(proc, cred, pagvalue, newpag, change_parent)
73 afs_uint32 change_parent;
75 gid_t gidset[NGROUPS];
80 ngroups = afs_getgroups(*cred, NGROUPS, gidset);
81 if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) {
82 /* We will have to shift grouplist to make room for pag */
83 if (ngroups + 2 > NGROUPS) {
86 for (j = ngroups -1; j >= 0; j--) {
87 gidset[j+2] = gidset[j];
91 *newpag = (pagvalue == -1 ? genpag(): pagvalue);
92 afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]);
93 code = afs_setgroups(proc, cred, ngroups, gidset, change_parent);
104 int ngrps, savengrps;
107 AFS_STATCNT(afs_getgroups);
108 savengrps = ngrps = MIN(ngroups, cred->cr_ngroups);
109 gp = cred->cr_groups;
128 struct ucred *newcr, *cr;
130 AFS_STATCNT(afs_setgroups);
132 * The real setgroups() call does this, so maybe we should too.
135 if (ngroups > NGROUPS)
138 if (!change_parent) {
143 newcr->cr_ngroups = ngroups;
144 gp = newcr->cr_groups;
147 if (!change_parent) {
148 substitute_real_creds(proc, NOUID, NOUID, NOGID, NOGID, newcr);