diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 15:20:36 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 15:20:36 -0700 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /fs/nfsd/auth.c | |
download | op-kernel-dev-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.zip op-kernel-dev-1da177e4c3f41524e886b7f1b8a0c1fc7321cac2.tar.gz |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'fs/nfsd/auth.c')
-rw-r--r-- | fs/nfsd/auth.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c new file mode 100644 index 0000000..cfe9ce8 --- /dev/null +++ b/fs/nfsd/auth.c @@ -0,0 +1,63 @@ +/* + * linux/fs/nfsd/auth.c + * + * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> + */ + +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/sunrpc/svc.h> +#include <linux/sunrpc/svcauth.h> +#include <linux/nfsd/nfsd.h> + +#define CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE)) + +int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp) +{ + struct svc_cred *cred = &rqstp->rq_cred; + int i; + int ret; + + if (exp->ex_flags & NFSEXP_ALLSQUASH) { + cred->cr_uid = exp->ex_anon_uid; + cred->cr_gid = exp->ex_anon_gid; + put_group_info(cred->cr_group_info); + cred->cr_group_info = groups_alloc(0); + } else if (exp->ex_flags & NFSEXP_ROOTSQUASH) { + struct group_info *gi; + if (!cred->cr_uid) + cred->cr_uid = exp->ex_anon_uid; + if (!cred->cr_gid) + cred->cr_gid = exp->ex_anon_gid; + gi = groups_alloc(cred->cr_group_info->ngroups); + if (gi) + for (i = 0; i < cred->cr_group_info->ngroups; i++) { + if (!GROUP_AT(cred->cr_group_info, i)) + GROUP_AT(gi, i) = exp->ex_anon_gid; + else + GROUP_AT(gi, i) = GROUP_AT(cred->cr_group_info, i); + } + put_group_info(cred->cr_group_info); + cred->cr_group_info = gi; + } + + if (cred->cr_uid != (uid_t) -1) + current->fsuid = cred->cr_uid; + else + current->fsuid = exp->ex_anon_uid; + if (cred->cr_gid != (gid_t) -1) + current->fsgid = cred->cr_gid; + else + current->fsgid = exp->ex_anon_gid; + + if (!cred->cr_group_info) + return -ENOMEM; + ret = set_current_groups(cred->cr_group_info); + if ((cred->cr_uid)) { + cap_t(current->cap_effective) &= ~CAP_NFSD_MASK; + } else { + cap_t(current->cap_effective) |= (CAP_NFSD_MASK & + current->cap_permitted); + } + return ret; +} |