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 "../afs/sysincludes.h"
18 #include "../afs/afsincludes.h"
19 #include "../afs/afs_stats.h" /* statistics */
35 #if defined(AFS_SUN55_ENV)
37 afs_xsetgroups(uap, rvp)
38 u_int uap; /* this is gidsetsize */
39 gid_t *rvp; /* this is gidset */
46 afs_xsetgroups(uap, rvp)
47 struct setgroupsa *uap;
53 struct proc *proc = ttoproc(curthread);
55 AFS_STATCNT(afs_xsetgroups);
57 code = afs_InitReq(&treq, proc->p_cred);
59 if (code) return code;
60 code = setgroups(uap, rvp);
62 /* Note that if there is a pag already in the new groups we don't
63 * overwrite it with the old pag.
65 if (PagInCred(proc->p_cred) == NOPAG) {
66 if (((treq.uid >> 24) & 0xff) == 'A') {
68 /* we've already done a setpag, so now we redo it */
69 AddPag(treq.uid, &proc->p_cred);
77 setpag(cred, pagvalue, newpag, change_parent)
81 afs_uint32 change_parent;
89 gidset = (gid_t *) osi_AllocSmallSpace(AFS_SMALLOCSIZ);
90 ngroups = afs_getgroups(*cred, gidset);
92 if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) {
93 /* We will have to shift grouplist to make room for pag */
94 if ((sizeof gidset[0])*(ngroups + 2) > AFS_SMALLOCSIZ) {
95 osi_FreeSmallSpace((char *)gidset);
98 for (j = ngroups -1; j >= 0; j--) {
99 gidset[j+2] = gidset[j];
103 *newpag = (pagvalue == -1 ? genpag(): pagvalue);
104 afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]);
105 if (code = afs_setgroups(cred, ngroups, gidset, change_parent)) {
106 osi_FreeSmallSpace((char *)gidset);
109 osi_FreeSmallSpace((char *)gidset);
119 int ngrps, savengrps;
122 AFS_STATCNT(afs_getgroups);
124 gidset[0] = gidset[1] = 0;
125 savengrps = ngrps = cred->cr_ngroups;
126 gp = cred->cr_groups;
145 AFS_STATCNT(afs_setgroups);
147 if (ngroups > ngroups_max)
150 *cred = (struct cred *)crcopy(*cred);
151 (*cred)->cr_ngroups = ngroups;
152 gp = (*cred)->cr_groups;
155 if (!change_parent) {
156 struct proc *proc = ttoproc(curthread);
157 crset(proc, *cred); /* broadcast to all threads */