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
13 * Afs_xsetgroups (syscall)
17 #include <afsconfig.h>
18 #include "../afs/param.h"
22 #include "../afs/sysincludes.h"
23 #include "../afs/afsincludes.h"
24 #include "../afs/afs_stats.h" /* statistics */
41 Afs_xsetgroups(p, args, retval)
50 cr=crdup(p->p_cred->pc_ucred);
52 AFS_STATCNT(afs_xsetgroups);
55 code = afs_InitReq(&treq, cr);
58 if (code) return setgroups(p, args, retval); /* afs has shut down */
60 code = setgroups(p, args, retval);
61 /* Note that if there is a pag already in the new groups we don't
62 * overwrite it with the old pag.
64 cr=crdup(p->p_cred->pc_ucred);
66 if (PagInCred(cr) == NOPAG) {
67 if (((treq.uid >> 24) & 0xff) == 'A') {
69 /* we've already done a setpag, so now we redo it */
70 AddPag(p, treq.uid, &cr );
80 setpag(proc, cred, pagvalue, newpag, change_parent)
85 afs_uint32 change_parent;
87 gid_t gidset[NGROUPS];
92 ngroups = afs_getgroups(*cred, NGROUPS, gidset);
93 if (afs_get_pag_from_groups(gidset[1], gidset[2]) == NOPAG) {
94 /* We will have to shift grouplist to make room for pag */
95 if (ngroups + 2 > NGROUPS) {
98 for (j = ngroups -1; j >= 1; j--) {
99 gidset[j+2] = gidset[j];
103 *newpag = (pagvalue == -1 ? genpag(): pagvalue);
104 afs_get_groups_from_pag(*newpag, &gidset[1], &gidset[2]);
105 code = afs_setgroups(proc, cred, ngroups, gidset, change_parent);
116 int ngrps, savengrps;
119 AFS_STATCNT(afs_getgroups);
120 savengrps = ngrps = MIN(ngroups, cred->cr_ngroups);
121 gp = cred->cr_groups;
140 struct ucred *oldcr, *cr;
142 AFS_STATCNT(afs_setgroups);
144 * The real setgroups() call does this, so maybe we should too.
147 if (ngroups > NGROUPS)
150 cr->cr_ngroups = ngroups;
156 oldcr=proc->p_pptr->p_cred->pc_ucred;
157 proc->p_pptr->p_cred->pc_ucred=cr;
161 oldcr=proc->p_cred->pc_ucred;
162 proc->p_cred->pc_ucred=cr;