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)
51 cr=crdup(p->p_cred->pc_ucred);
54 AFS_STATCNT(afs_xsetgroups);
57 code = afs_InitReq(&treq, cr);
60 if (code) return setgroups(p, args, retval); /* afs has shut down */
62 code = setgroups(p, args, retval);
63 /* Note that if there is a pag already in the new groups we don't
64 * overwrite it with the old pag.
67 cr=crdup(p->p_cred->pc_ucred);
70 if (PagInCred(cr) == NOPAG) {
71 if (((treq.uid >> 24) & 0xff) == 'A') {
73 /* we've already done a setpag, so now we redo it */
74 AddPag(p, treq.uid, &cr );
84 setpag(proc, cred, pagvalue, newpag, change_parent)
89 afs_uint32 change_parent;
91 gid_t gidset[NGROUPS];
96 ngroups = afs_getgroups(*cred, NGROUPS, gidset);
97 if (afs_get_pag_from_groups(gidset[1], gidset[2]) == NOPAG) {
98 /* We will have to shift grouplist to make room for pag */
99 if (ngroups + 2 > NGROUPS) {
102 for (j = ngroups -1; j >= 1; j--) {
103 gidset[j+2] = gidset[j];
107 *newpag = (pagvalue == -1 ? genpag(): pagvalue);
108 afs_get_groups_from_pag(*newpag, &gidset[1], &gidset[2]);
109 code = afs_setgroups(proc, cred, ngroups, gidset, change_parent);
120 int ngrps, savengrps;
123 AFS_STATCNT(afs_getgroups);
124 savengrps = ngrps = MIN(ngroups, cred->cr_ngroups);
125 gp = cred->cr_groups;
144 struct ucred *oldcr, *cr;
146 AFS_STATCNT(afs_setgroups);
148 * The real setgroups() call does this, so maybe we should too.
151 if (ngroups > NGROUPS)
154 cr->cr_ngroups = ngroups;
160 pcred_writelock(proc->p_pptr);
161 oldcr=proc->p_pptr->p_cred->pc_ucred;
162 proc->p_pptr->p_cred->pc_ucred=cr;
163 pcred_unlock(proc->p_pptr);
167 pcred_writelock(proc);
168 oldcr=proc->p_cred->pc_ucred;
169 proc->p_cred->pc_ucred=cr;