Contributors: 15
Author |
Tokens |
Token Proportion |
Commits |
Commit Proportion |
David Howells |
129 |
27.98% |
4 |
12.90% |
Linus Torvalds (pre-git) |
126 |
27.33% |
6 |
19.35% |
J. Bruce Fields |
75 |
16.27% |
5 |
16.13% |
Andrew Morton |
38 |
8.24% |
3 |
9.68% |
Eric W. Biedermann |
33 |
7.16% |
2 |
6.45% |
Neil Brown |
18 |
3.90% |
2 |
6.45% |
Alexey Dobriyan |
16 |
3.47% |
1 |
3.23% |
Andrew G. Morgan |
10 |
2.17% |
1 |
3.23% |
Thiago Rafael Becker |
6 |
1.30% |
1 |
3.23% |
Harvey Harrison |
3 |
0.65% |
1 |
3.23% |
Jeff Layton |
2 |
0.43% |
1 |
3.23% |
Kinglong Mee |
2 |
0.43% |
1 |
3.23% |
Boaz Harrosh |
1 |
0.22% |
1 |
3.23% |
Greg Kroah-Hartman |
1 |
0.22% |
1 |
3.23% |
Ben Hutchings |
1 |
0.22% |
1 |
3.23% |
Total |
461 |
|
31 |
|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
// SPDX-License-Identifier: GPL-2.0
/* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
#include <linux/sched.h>
#include "nfsd.h"
#include "auth.h"
int nfsexp_flags(struct svc_cred *cred, struct svc_export *exp)
{
struct exp_flavor_info *f;
struct exp_flavor_info *end = exp->ex_flavors + exp->ex_nflavors;
for (f = exp->ex_flavors; f < end; f++) {
if (f->pseudoflavor == cred->cr_flavor)
return f->flags;
}
return exp->ex_flags;
}
int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp)
{
struct group_info *rqgi;
struct group_info *gi;
struct cred *new;
int i;
int flags = nfsexp_flags(cred, exp);
/* discard any old override before preparing the new set */
revert_creds(get_cred(current_real_cred()));
new = prepare_creds();
if (!new)
return -ENOMEM;
new->fsuid = cred->cr_uid;
new->fsgid = cred->cr_gid;
rqgi = cred->cr_group_info;
if (flags & NFSEXP_ALLSQUASH) {
new->fsuid = exp->ex_anon_uid;
new->fsgid = exp->ex_anon_gid;
gi = groups_alloc(0);
if (!gi)
goto oom;
} else if (flags & NFSEXP_ROOTSQUASH) {
if (uid_eq(new->fsuid, GLOBAL_ROOT_UID))
new->fsuid = exp->ex_anon_uid;
if (gid_eq(new->fsgid, GLOBAL_ROOT_GID))
new->fsgid = exp->ex_anon_gid;
gi = groups_alloc(rqgi->ngroups);
if (!gi)
goto oom;
for (i = 0; i < rqgi->ngroups; i++) {
if (gid_eq(GLOBAL_ROOT_GID, rqgi->gid[i]))
gi->gid[i] = exp->ex_anon_gid;
else
gi->gid[i] = rqgi->gid[i];
}
/* Each thread allocates its own gi, no race */
groups_sort(gi);
} else {
gi = get_group_info(rqgi);
}
if (uid_eq(new->fsuid, INVALID_UID))
new->fsuid = exp->ex_anon_uid;
if (gid_eq(new->fsgid, INVALID_GID))
new->fsgid = exp->ex_anon_gid;
set_groups(new, gi);
put_group_info(gi);
if (!uid_eq(new->fsuid, GLOBAL_ROOT_UID))
new->cap_effective = cap_drop_nfsd_set(new->cap_effective);
else
new->cap_effective = cap_raise_nfsd_set(new->cap_effective,
new->cap_permitted);
put_cred(override_creds(new));
put_cred(new);
return 0;
oom:
abort_creds(new);
return -ENOMEM;
}