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"
19 #include <sys/param.h>
21 #include <sys/sysproto.h>
26 #include "afs/sysincludes.h"
27 #include "afsincludes.h"
28 #include "afs/afs_stats.h" /* statistics */
46 * This does nothing useful yet.
47 * In 5.0, creds are associated not with a process, but with a thread.
48 * Probably the right thing to do is replace struct proc with struct thread
49 * everywhere, including setpag.
50 * That will be a tedious undertaking.
51 * For now, I'm just passing curproc to AddPag.
52 * This is probably wrong and I don't know what the consequences might be.
56 Afs_xsetgroups(struct thread *td, struct setgroups_args *uap)
62 cr = crdup(td->td_ucred);
64 AFS_STATCNT(afs_xsetgroups);
67 code = afs_InitReq(&treq, cr);
70 if (code) return setgroups(td, uap); /* afs has shut down */
72 code = setgroups(td, uap);
73 /* Note that if there is a pag already in the new groups we don't
74 * overwrite it with the old pag.
76 cr = crdup(td->td_ucred);
78 if (PagInCred(cr) == NOPAG) {
79 if (((treq.uid >> 24) & 0xff) == 'A') {
81 /* we've already done a setpag, so now we redo it */
82 AddPag(curproc, treq.uid, &cr);
91 Afs_xsetgroups(p, args, retval)
100 cr=crdup(p->p_cred->pc_ucred);
102 AFS_STATCNT(afs_xsetgroups);
105 code = afs_InitReq(&treq, cr);
108 if (code) return setgroups(p, args, retval); /* afs has shut down */
110 code = setgroups(p, args, retval);
111 /* Note that if there is a pag already in the new groups we don't
112 * overwrite it with the old pag.
114 cr=crdup(p->p_cred->pc_ucred);
116 if (PagInCred(cr) == NOPAG) {
117 if (((treq.uid >> 24) & 0xff) == 'A') {
119 /* we've already done a setpag, so now we redo it */
120 AddPag(p, treq.uid, &cr );
131 setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue,
132 afs_uint32 *newpag, int change_parent)
134 gid_t gidset[NGROUPS];
139 ngroups = afs_getgroups(*cred, NGROUPS, gidset);
140 if (afs_get_pag_from_groups(gidset[1], gidset[2]) == NOPAG) {
141 /* We will have to shift grouplist to make room for pag */
142 if (ngroups + 2 > NGROUPS) {
145 for (j = ngroups -1; j >= 1; j--) {
146 gidset[j+2] = gidset[j];
150 *newpag = (pagvalue == -1 ? genpag(): pagvalue);
151 afs_get_groups_from_pag(*newpag, &gidset[1], &gidset[2]);
152 code = afs_setgroups(proc, cred, ngroups, gidset, change_parent);
163 int ngrps, savengrps;
166 AFS_STATCNT(afs_getgroups);
167 savengrps = ngrps = MIN(ngroups, cred->cr_ngroups);
168 gp = cred->cr_groups;
183 #ifndef AFS_FBSD50_ENV
187 struct ucred *oldcr, *cr;
189 AFS_STATCNT(afs_setgroups);
191 * The real setgroups() call does this, so maybe we should too.
194 if (ngroups > NGROUPS)
197 cr->cr_ngroups = ngroups;
203 oldcr=proc->p_pptr->p_cred->pc_ucred;
204 proc->p_pptr->p_cred->pc_ucred=cr;
208 oldcr=proc->p_cred->pc_ucred;
209 proc->p_cred->pc_ucred=cr;