mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 20:54:03 +02:00
NFSD: Relocate nfsd_user_namespace()
Refactor: nfsd_user_namespace() currently lives in nfsd.h, so every caller must pull in nfsd.h -- directly or transitively via state.h -- and with it the NFS protocol definitions from uapi/linux/nfs.h and friends, even when the caller uses nothing else from nfsd.h. Since nfsd_user_namespace() is an auth-related function, move it to fs/nfsd/auth.c in preparation for removing '#include "nfsd.h"' from a few places. Link: https://patch.msgid.link/20260712204554.125308-8-cel@kernel.org Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <cel@kernel.org>
This commit is contained in:
parent
2c0759a6d1
commit
65608a57ae
|
|
@ -88,3 +88,21 @@ int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/**
|
||||
* nfsd_user_namespace - Get user_namespace in effect for an RPC request
|
||||
* @rqstp: RPC execution context
|
||||
*
|
||||
* xpt_cred is set once at transport creation and never modified. The
|
||||
* transport itself is reference-counted during request processing, so
|
||||
* no explicit reference on the namespace is necessary.
|
||||
*
|
||||
* Return: the user_namespace from the transport credential, or
|
||||
* init_user_ns if no credential was set. The returned namespace pointer
|
||||
* is valid for the duration of the RPC request.
|
||||
*/
|
||||
struct user_namespace *nfsd_user_namespace(const struct svc_rqst *rqstp)
|
||||
{
|
||||
const struct cred *cred = rqstp->rq_xprt->xpt_cred;
|
||||
|
||||
return cred ? cred->user_ns : &init_user_ns;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,16 @@
|
|||
#ifndef LINUX_NFSD_AUTH_H
|
||||
#define LINUX_NFSD_AUTH_H
|
||||
|
||||
struct user_namespace;
|
||||
struct svc_export;
|
||||
struct svc_rqst;
|
||||
|
||||
/*
|
||||
* Set the current process's fsuid/fsgid etc to those of the NFS
|
||||
* client user
|
||||
*/
|
||||
int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp);
|
||||
|
||||
struct user_namespace *nfsd_user_namespace(const struct svc_rqst *rqstp);
|
||||
|
||||
#endif /* LINUX_NFSD_AUTH_H */
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include <linux/slab.h>
|
||||
#include <linux/sunrpc/svc_xprt.h>
|
||||
#include <net/net_namespace.h>
|
||||
#include "auth.h"
|
||||
#include "idmap.h"
|
||||
#include "nfsd.h"
|
||||
#include "netns.h"
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#include <uapi/linux/xattr.h>
|
||||
|
||||
#include "auth.h"
|
||||
#include "idmap.h"
|
||||
#include "acl.h"
|
||||
#include "xdr4.h"
|
||||
|
|
|
|||
|
|
@ -153,12 +153,6 @@ static inline int nfsd_v4client(struct svc_rqst *rq)
|
|||
{
|
||||
return rq && rq->rq_prog == NFS_PROGRAM && rq->rq_vers == 4;
|
||||
}
|
||||
static inline struct user_namespace *
|
||||
nfsd_user_namespace(const struct svc_rqst *rqstp)
|
||||
{
|
||||
const struct cred *cred = rqstp->rq_xprt->xpt_cred;
|
||||
return cred ? cred->user_ns : &init_user_ns;
|
||||
}
|
||||
|
||||
/*
|
||||
* NFSv4 State
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user