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
14 * Afs_xsetgroups (syscall)
18 #include <afsconfig.h>
19 #include "afs/param.h"
23 #include "afs/sysincludes.h"
24 #include "afs/afsincludes.h"
25 #include "afs/afs_stats.h" /* statistics */
26 #include "sys/syscallargs.h"
28 #define NOUID ((uid_t) -1)
29 #define NOGID ((gid_t) -1)
47 Afs_xsetgroups(p, args, retval)
55 AFS_STATCNT(afs_xsetgroups);
58 code = afs_InitReq(&treq, osi_curcred());
60 if (code) return code;
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.
66 if (PagInCred(osi_curcred()) == 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, &p->p_rcred);
79 setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue,
80 afs_uint32 *newpag, int change_parent)
82 gid_t gidset[NGROUPS];
87 ngroups = afs_getgroups(*cred, NGROUPS, gidset);
88 if (afs_get_pag_from_groups(gidset[1], gidset[2]) == NOPAG) {
89 /* We will have to shift grouplist to make room for pag */
90 if (ngroups + 2 > NGROUPS) {
93 for (j = ngroups -1; j >= 0; j--) {
94 gidset[j+2] = gidset[j];
98 *newpag = (pagvalue == -1 ? genpag(): pagvalue);
99 afs_get_groups_from_pag(*newpag, &gidset[1], &gidset[2]);
100 code = afs_setgroups(proc, cred, ngroups, gidset, change_parent);
111 int ngrps, savengrps;
114 AFS_STATCNT(afs_getgroups);
115 savengrps = ngrps = MIN(ngroups, cred->cr_ngroups);
116 gp = cred->cr_groups;
133 struct ucred *newcr, *cr;
135 AFS_STATCNT(afs_setgroups);
137 * The real setgroups() call does this, so maybe we should too.
140 if (ngroups > NGROUPS)
143 if (!change_parent) {
148 newcr->cr_ngroups = ngroups;
149 gp = newcr->cr_groups;
152 for ( ; gp < &(*cred)->cr_groups[NGROUPS]; gp++)