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, p->p_rcred);
63 code = setgroups(p, args, retval);
65 * Note that if there is a pag already in the new groups we don't
66 * overwrite it with the old pag.
68 if (PagInCred(p->p_rcred) == NOPAG) {
69 if (((treq.uid >> 24) & 0xff) == 'A') {
71 /* we've already done a setpag, so now we redo it */
72 AddPag(p, treq.uid, &p->p_rcred);
81 setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue,
82 afs_uint32 *newpag, int change_parent)
84 gid_t gidset[NGROUPS];
89 ngroups = afs_getgroups(*cred, NGROUPS, gidset);
90 if (afs_get_pag_from_groups(gidset[1], gidset[2]) == NOPAG) {
91 /* We will have to shift grouplist to make room for pag */
92 if (ngroups + 2 > NGROUPS) {
95 for (j = ngroups -1; j >= 0; j--) {
96 gidset[j+2] = gidset[j];
100 *newpag = (pagvalue == -1 ? genpag(): pagvalue);
101 afs_get_groups_from_pag(*newpag, &gidset[1], &gidset[2]);
102 code = afs_setgroups(proc, cred, ngroups, gidset, change_parent);
113 int ngrps, savengrps;
116 AFS_STATCNT(afs_getgroups);
117 savengrps = ngrps = MIN(ngroups, cred->cr_ngroups);
118 gp = cred->cr_groups;
133 struct ucred *cr = *cred;
136 AFS_STATCNT(afs_setgroups);
138 if (ngroups > NGROUPS)
144 for (i = 0; i < ngroups; i++)
145 cr->cr_groups[i] = gidset[i];
146 for (i = ngroups; i < NGROUPS; i++)
147 cr->cr_groups[i] = NOGROUP;
148 cr->cr_ngroups = ngroups;