Commit 98a8e323 authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Add a helper rpcauth_lookup_generic_cred()

The NFSv4 protocol allows clients to negotiate security protocols on the
fly in the case where an administrator on the server changes the export
settings and/or in the case where we may have a filesystem migration event.

Instead of having the NFS client code cache credentials that are tied to a
particular AUTH method it is therefore preferable to have a generic credential
that can be converted into whatever AUTH is in use by the RPC client when
the read/write/sillyrename/... is put on the wire.

We do this by means of the new "generic" credential, which basically just
caches the minimal information that is needed to look up an RPCSEC_GSS,
AUTH_SYS, or AUTH_NULL credential.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 5c691044
...@@ -1966,7 +1966,7 @@ int nfs_permission(struct inode *inode, int mask, struct nameidata *nd) ...@@ -1966,7 +1966,7 @@ int nfs_permission(struct inode *inode, int mask, struct nameidata *nd)
if (!NFS_PROTO(inode)->access) if (!NFS_PROTO(inode)->access)
goto out_notsup; goto out_notsup;
cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0); cred = rpc_lookup_cred();
if (!IS_ERR(cred)) { if (!IS_ERR(cred)) {
res = nfs_do_access(inode, cred, mask); res = nfs_do_access(inode, cred, mask);
put_rpccred(cred); put_rpccred(cred);
......
...@@ -613,7 +613,7 @@ int nfs_open(struct inode *inode, struct file *filp) ...@@ -613,7 +613,7 @@ int nfs_open(struct inode *inode, struct file *filp)
struct nfs_open_context *ctx; struct nfs_open_context *ctx;
struct rpc_cred *cred; struct rpc_cred *cred;
cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0); cred = rpc_lookup_cred();
if (IS_ERR(cred)) if (IS_ERR(cred))
return PTR_ERR(cred); return PTR_ERR(cred);
ctx = alloc_nfs_open_context(filp->f_path.mnt, filp->f_path.dentry, cred); ctx = alloc_nfs_open_context(filp->f_path.mnt, filp->f_path.dentry, cred);
......
...@@ -1408,7 +1408,7 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd) ...@@ -1408,7 +1408,7 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
BUG_ON(nd->intent.open.flags & O_CREAT); BUG_ON(nd->intent.open.flags & O_CREAT);
} }
cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0); cred = rpc_lookup_cred();
if (IS_ERR(cred)) if (IS_ERR(cred))
return (struct dentry *)cred; return (struct dentry *)cred;
parent = dentry->d_parent; parent = dentry->d_parent;
...@@ -1443,7 +1443,7 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st ...@@ -1443,7 +1443,7 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st
struct rpc_cred *cred; struct rpc_cred *cred;
struct nfs4_state *state; struct nfs4_state *state;
cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0); cred = rpc_lookup_cred();
if (IS_ERR(cred)) if (IS_ERR(cred))
return PTR_ERR(cred); return PTR_ERR(cred);
state = nfs4_do_open(dir, &path, openflags, NULL, cred); state = nfs4_do_open(dir, &path, openflags, NULL, cred);
...@@ -1660,7 +1660,7 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, ...@@ -1660,7 +1660,7 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
nfs_fattr_init(fattr); nfs_fattr_init(fattr);
cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0); cred = rpc_lookup_cred();
if (IS_ERR(cred)) if (IS_ERR(cred))
return PTR_ERR(cred); return PTR_ERR(cred);
...@@ -1896,7 +1896,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, ...@@ -1896,7 +1896,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
struct rpc_cred *cred; struct rpc_cred *cred;
int status = 0; int status = 0;
cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0); cred = rpc_lookup_cred();
if (IS_ERR(cred)) { if (IS_ERR(cred)) {
status = PTR_ERR(cred); status = PTR_ERR(cred);
goto out; goto out;
......
...@@ -234,7 +234,7 @@ nfs_async_unlink(struct inode *dir, struct dentry *dentry) ...@@ -234,7 +234,7 @@ nfs_async_unlink(struct inode *dir, struct dentry *dentry)
if (data == NULL) if (data == NULL)
goto out; goto out;
data->cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0); data->cred = rpc_lookup_cred();
if (IS_ERR(data->cred)) { if (IS_ERR(data->cred)) {
status = PTR_ERR(data->cred); status = PTR_ERR(data->cred);
goto out_free; goto out_free;
......
...@@ -356,7 +356,6 @@ rpcauth_lookupcred(struct rpc_auth *auth, int flags) ...@@ -356,7 +356,6 @@ rpcauth_lookupcred(struct rpc_auth *auth, int flags)
put_group_info(acred.group_info); put_group_info(acred.group_info);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(rpcauth_lookupcred);
void void
rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred, rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment