1 /* Copyright (C) 1995, 1989, 1998 Transarc Corporation - All rights reserved */
3 * (C) COPYRIGHT IBM CORPORATION 1987, 1988
4 * LICENSED MATERIALS - PROPERTY OF IBM
10 * Afs_xsetgroups (syscall)
14 #include "../afs/param.h"
15 #include "../afs/sysincludes.h"
16 #include "../afs/afsincludes.h"
17 #include "../afs/afs_stats.h" /* statistics */
34 Afs_xsetgroups(p, args, retval)
42 AFS_STATCNT(afs_xsetgroups);
45 code = afs_InitReq(&treq, u.u_cred);
47 if (code) return code;
49 code = setgroups(p, args, retval);
50 /* Note that if there is a pag already in the new groups we don't
51 * overwrite it with the old pag.
53 if (PagInCred(u.u_cred) == NOPAG) {
54 if (((treq.uid >> 24) & 0xff) == 'A') {
56 /* we've already done a setpag, so now we redo it */
57 AddPag(p, treq.uid, &p->p_rcred);
66 setpag(proc, cred, pagvalue, newpag, change_parent)
71 afs_uint32 change_parent;
73 gid_t gidset[NGROUPS];
78 ngroups = afs_getgroups(*cred, NGROUPS, gidset);
79 if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) {
80 /* We will have to shift grouplist to make room for pag */
81 if (ngroups + 2 > NGROUPS) {
84 for (j = ngroups -1; j >= 0; j--) {
85 gidset[j+2] = gidset[j];
89 *newpag = (pagvalue == -1 ? genpag(): pagvalue);
90 afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]);
91 code = afs_setgroups(proc, cred, ngroups, gidset, change_parent);
102 int ngrps, savengrps;
105 AFS_STATCNT(afs_getgroups);
106 savengrps = ngrps = MIN(ngroups, cred->cr_ngroups);
107 gp = cred->cr_groups;
126 struct ucred *newcr, *cr;
128 AFS_STATCNT(afs_setgroups);
130 * The real setgroups() call does this, so maybe we should too.
133 if (ngroups > NGROUPS)
136 if (!change_parent) {
141 newcr->cr_ngroups = ngroups;
142 gp = newcr->cr_groups;
145 if (!change_parent) {
146 substitute_real_creds(proc, NOUID, NOUID, NOGID, NOGID, newcr);