#include <afsconfig.h>
#include "afs/param.h"
-RCSID("$Header$");
+RCSID
+ ("$Header$");
#include "afs/sysincludes.h"
#include "afs/afsincludes.h"
-#include "afs/afs_stats.h" /* statistics */
+#include "afs/afs_stats.h" /* statistics */
#include "sys/syscallargs.h"
#define NOUID ((uid_t) -1)
static int
-afs_getgroups(
- struct ucred *cred,
- int ngroups,
- gid_t *gidset);
+ afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset);
static int
-afs_setgroups(
- struct proc *proc,
- struct ucred **cred,
- int ngroups,
- gid_t *gidset,
- int change_parent);
+ afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups,
+ gid_t * gidset, int change_parent);
int
Afs_xsetgroups(p, args, retval)
- struct proc *p;
- void *args;
- int *retval;
+ struct proc *p;
+ void *args;
+ int *retval;
{
int code = 0;
struct vrequest treq;
AFS_STATCNT(afs_xsetgroups);
AFS_GLOCK();
- code = afs_InitReq(&treq, osi_curcred());
+ code = afs_InitReq(&treq, p->p_rcred);
AFS_GUNLOCK();
- if (code) return code;
+ if (code)
+ return code;
code = setgroups(p, args, retval);
- /* Note that if there is a pag already in the new groups we don't
+ /*
+ * Note that if there is a pag already in the new groups we don't
* overwrite it with the old pag.
*/
- if (PagInCred(osi_curcred()) == NOPAG) {
+ if (PagInCred(p->p_rcred) == NOPAG) {
if (((treq.uid >> 24) & 0xff) == 'A') {
AFS_GLOCK();
/* we've already done a setpag, so now we redo it */
int
setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue,
- afs_uint32 *newpag, int change_parent)
+ afs_uint32 * newpag, int change_parent)
{
gid_t gidset[NGROUPS];
int ngroups, code;
AFS_STATCNT(setpag);
ngroups = afs_getgroups(*cred, NGROUPS, gidset);
- if (afs_get_pag_from_groups(gidset[0], gidset[1]) == NOPAG) {
+ if (afs_get_pag_from_groups(gidset[1], gidset[2]) == NOPAG) {
/* We will have to shift grouplist to make room for pag */
if (ngroups + 2 > NGROUPS) {
return (E2BIG);
}
- for (j = ngroups -1; j >= 0; j--) {
- gidset[j+2] = gidset[j];
- }
+ for (j = ngroups - 1; j >= 0; j--) {
+ gidset[j + 2] = gidset[j];
+ }
ngroups += 2;
}
- *newpag = (pagvalue == -1 ? genpag(): pagvalue);
- afs_get_groups_from_pag(*newpag, &gidset[0], &gidset[1]);
+ *newpag = (pagvalue == -1 ? genpag() : pagvalue);
+ afs_get_groups_from_pag(*newpag, &gidset[1], &gidset[2]);
code = afs_setgroups(proc, cred, ngroups, gidset, change_parent);
return code;
}
static int
-afs_getgroups(
- struct ucred *cred,
- int ngroups,
- gid_t *gidset)
+afs_getgroups(struct ucred *cred, int ngroups, gid_t * gidset)
{
int ngrps, savengrps;
gid_t *gp;
}
-
static int
-afs_setgroups(
- struct proc *proc,
- struct ucred **cred,
- int ngroups,
- gid_t *gidset,
- int change_parent)
+afs_setgroups(struct proc *proc, struct ucred **cred, int ngroups,
+ gid_t * gidset, int change_parent)
{
- gid_t *gp;
- struct ucred *newcr, *cr;
+ struct ucred *cr = *cred;
+ int i;
AFS_STATCNT(afs_setgroups);
- /*
- * The real setgroups() call does this, so maybe we should too.
- *
- */
+
if (ngroups > NGROUPS)
return EINVAL;
- cr = *cred;
- if (!change_parent) {
- crhold(cr);
- newcr = crcopy(cr);
- } else
- newcr = cr;
- newcr->cr_ngroups = ngroups;
- gp = newcr->cr_groups;
- while (ngroups--)
- *gp++ = *gidset++;
- for ( ; gp < &(*cred)->cr_groups[NGROUPS]; gp++)
- *gp = NOGROUP;
- *cred = newcr;
- return(0);
+
+ if (!change_parent)
+ cr = crcopy(cr);
+
+ for (i = 0; i < ngroups; i++)
+ cr->cr_groups[i] = gidset[i];
+ for (i = ngroups; i < NGROUPS; i++)
+ cr->cr_groups[i] = NOGROUP;
+ cr->cr_ngroups = ngroups;
+
+ *cred = cr;
+ return (0);
}