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
16 #include "../afs/param.h"
17 #include <afsconfig.h>
21 #include "../afs/sysincludes.h"
22 #include "../afs/afsincludes.h"
23 #include "../afs/afs_stats.h" /* statistics */
39 #if defined(AFS_SUN55_ENV)
41 afs_xsetgroups(uap, rvp)
42 u_int uap; /* this is gidsetsize */
43 gid_t *rvp; /* this is gidset */
50 afs_xsetgroups(uap, rvp)
51 struct setgroupsa *uap;
57 struct proc *proc = ttoproc(curthread);
59 AFS_STATCNT(afs_xsetgroups);
61 code = afs_InitReq(&treq, proc->p_cred);
63 if (code) return code;
64 code = setgroups(uap, rvp);
66 /* Note that if there is a pag already in the new groups we don't
67 * overwrite it with the old pag.
69 if (PagInCred(proc->p_cred) == NOPAG) {
70 if (((treq.uid >> 24) & 0xff) == 'A') {
72 /* we've already done a setpag, so now we redo it */
73 AddPag(treq.uid, &proc->p_cred);
81 setpag(cred, pagvalue, newpag, change_parent)
85 afs_uint32 change_parent;
93 gidset = (gid_t *) osi_AllocSmallSpace(AFS_SMALLOCSIZ);
94 ngroups = afs_getgroups(*cred, gidset);
96 if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) {
97 /* We will have to shift grouplist to make room for pag */
98 if ((sizeof gidset[0])*(ngroups + 2) > AFS_SMALLOCSIZ) {
99 osi_FreeSmallSpace((char *)gidset);
102 for (j = ngroups -1; j >= 0; j--) {
103 gidset[j+2] = gidset[j];
107 *newpag = (pagvalue == -1 ? genpag(): pagvalue);
108 afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]);
109 if (code = afs_setgroups(cred, ngroups, gidset, change_parent)) {
110 osi_FreeSmallSpace((char *)gidset);
113 osi_FreeSmallSpace((char *)gidset);
123 int ngrps, savengrps;
126 AFS_STATCNT(afs_getgroups);
128 gidset[0] = gidset[1] = 0;
129 savengrps = ngrps = cred->cr_ngroups;
130 gp = cred->cr_groups;
149 AFS_STATCNT(afs_setgroups);
151 if (ngroups > ngroups_max)
154 *cred = (struct cred *)crcopy(*cred);
155 (*cred)->cr_ngroups = ngroups;
156 gp = (*cred)->cr_groups;
159 if (!change_parent) {
160 struct proc *proc = ttoproc(curthread);
161 crset(proc, *cred); /* broadcast to all threads */