NFS/SUNRPC: don't lookup machine credential until rpcauth_bindcred().

When NFS creates a machine credential, it is a "generic" credential,
not tied to any auth protocol, and is really just a container for
the princpal name.
This doesn't get linked to a genuine credential until rpcauth_bindcred()
is called.
The lookup always succeeds, so various places that test if the machine
credential is NULL, are pointless.

As a step towards getting rid of generic credentials, this patch gets
rid of generic machine credentials.  The nfs_client and rpc_client
just hold a pointer to a constant principal name.
When a machine credential is wanted, a special static 'struct rpc_cred'
pointer is used. rpcauth_bindcred() recognizes this, finds the
principal from the client, and binds the correct credential.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
NeilBrown
2018-12-03 11:30:30 +11:00
committed by Anna Schumaker
parent ecd5f97e1c
commit 5e16923b43
10 changed files with 54 additions and 68 deletions

View File

@@ -166,28 +166,15 @@ out:
struct rpc_cred *nfs4_get_machine_cred(struct nfs_client *clp)
{
struct rpc_cred *cred = clp->cl_root_cred;
if (!cred)
cred = clp->cl_machine_cred;
if (cred)
return get_rpccred(cred);
return cred;
return get_rpccred(rpc_machine_cred());
}
static void nfs4_root_machine_cred(struct nfs_client *clp)
{
struct rpc_cred *new;
new = rpc_lookup_machine_cred(NULL);
spin_lock(&clp->cl_lock);
if (clp->cl_root_cred == NULL) {
clp->cl_root_cred = new;
new = NULL;
}
spin_unlock(&clp->cl_lock);
if (new != NULL)
put_rpccred(new);
/* Force root creds instead of machine */
clp->cl_principal = NULL;
clp->cl_rpcclient->cl_principal = NULL;
}
static struct rpc_cred *