mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 15:54:15 +08:00
a254b246ee
Add extern to nfsd/nfsd.h fs/nfsd/nfssvc.c:146:5: warning: symbol 'nfsd_nrthreads' was not declared. Should it be static? fs/nfsd/nfssvc.c:261:5: warning: symbol 'nfsd_nrpools' was not declared. Should it be static? fs/nfsd/nfssvc.c:269:5: warning: symbol 'nfsd_get_nrthreads' was not declared. Should it be static? fs/nfsd/nfssvc.c:281:5: warning: symbol 'nfsd_set_nrthreads' was not declared. Should it be static? fs/nfsd/export.c:1534:23: warning: symbol 'nfs_exports_op' was not declared. Should it be static? Add include of auth.h fs/nfsd/auth.c:27:5: warning: symbol 'nfsd_setuser' was not declared. Should it be static? Make static, move forward declaration closer to where it's needed. fs/nfsd/nfs4state.c:1877:1: warning: symbol 'laundromat_main' was not declared. Should it be static? Make static, forward declaration was already marked static. fs/nfsd/nfs4idmap.c:206:1: warning: symbol 'idtoname_parse' was not declared. Should it be static? fs/nfsd/vfs.c:1156:1: warning: symbol 'nfsd_create_setattr' was not declared. Should it be static? Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
80 lines
1.9 KiB
C
80 lines
1.9 KiB
C
/*
|
|
* 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>
|
|
#include <linux/nfsd/export.h>
|
|
#include "auth.h"
|
|
|
|
int nfsexp_flags(struct svc_rqst *rqstp, 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 == rqstp->rq_flavor)
|
|
return f->flags;
|
|
}
|
|
return exp->ex_flags;
|
|
|
|
}
|
|
|
|
int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
|
|
{
|
|
struct svc_cred cred = rqstp->rq_cred;
|
|
int i;
|
|
int flags = nfsexp_flags(rqstp, exp);
|
|
int ret;
|
|
|
|
if (flags & NFSEXP_ALLSQUASH) {
|
|
cred.cr_uid = exp->ex_anon_uid;
|
|
cred.cr_gid = exp->ex_anon_gid;
|
|
cred.cr_group_info = groups_alloc(0);
|
|
} else if (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);
|
|
}
|
|
cred.cr_group_info = gi;
|
|
} else
|
|
get_group_info(cred.cr_group_info);
|
|
|
|
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);
|
|
put_group_info(cred.cr_group_info);
|
|
if ((cred.cr_uid)) {
|
|
current->cap_effective =
|
|
cap_drop_nfsd_set(current->cap_effective);
|
|
} else {
|
|
current->cap_effective =
|
|
cap_raise_nfsd_set(current->cap_effective,
|
|
current->cap_permitted);
|
|
}
|
|
return ret;
|
|
}
|