aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/auth.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-07-31 14:29:08 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-08-04 08:54:08 -0400
commit8572b8e2e3c5f3d990122348c4d2c64dad338611 (patch)
tree5de87a7f2cb1c1105313c0fb1d1f26a969961c83 /net/sunrpc/auth.c
parent58f9612c6ea858f532021a0ce42ec53cb0a493b3 (diff)
SUNRPC: Clean up of rpc_bindcred()
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/auth.c')
-rw-r--r--net/sunrpc/auth.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index d80f01725fc2..d8968faf5ccf 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -444,16 +444,16 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
444} 444}
445EXPORT_SYMBOL_GPL(rpcauth_init_cred); 445EXPORT_SYMBOL_GPL(rpcauth_init_cred);
446 446
447void 447struct rpc_cred *
448rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred, int lookupflags) 448rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred, int lookupflags)
449{ 449{
450 task->tk_msg.rpc_cred = get_rpccred(cred);
451 dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid, 450 dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid,
452 cred->cr_auth->au_ops->au_name, cred); 451 cred->cr_auth->au_ops->au_name, cred);
452 return get_rpccred(cred);
453} 453}
454EXPORT_SYMBOL_GPL(rpcauth_generic_bind_cred); 454EXPORT_SYMBOL_GPL(rpcauth_generic_bind_cred);
455 455
456static void 456static struct rpc_cred *
457rpcauth_bind_root_cred(struct rpc_task *task, int lookupflags) 457rpcauth_bind_root_cred(struct rpc_task *task, int lookupflags)
458{ 458{
459 struct rpc_auth *auth = task->tk_client->cl_auth; 459 struct rpc_auth *auth = task->tk_client->cl_auth;
@@ -461,45 +461,42 @@ rpcauth_bind_root_cred(struct rpc_task *task, int lookupflags)
461 .uid = 0, 461 .uid = 0,
462 .gid = 0, 462 .gid = 0,
463 }; 463 };
464 struct rpc_cred *ret;
465 464
466 dprintk("RPC: %5u looking up %s cred\n", 465 dprintk("RPC: %5u looking up %s cred\n",
467 task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); 466 task->tk_pid, task->tk_client->cl_auth->au_ops->au_name);
468 ret = auth->au_ops->lookup_cred(auth, &acred, lookupflags); 467 return auth->au_ops->lookup_cred(auth, &acred, lookupflags);
469 if (!IS_ERR(ret))
470 task->tk_msg.rpc_cred = ret;
471 else
472 task->tk_status = PTR_ERR(ret);
473} 468}
474 469
475static void 470static struct rpc_cred *
476rpcauth_bind_new_cred(struct rpc_task *task, int lookupflags) 471rpcauth_bind_new_cred(struct rpc_task *task, int lookupflags)
477{ 472{
478 struct rpc_auth *auth = task->tk_client->cl_auth; 473 struct rpc_auth *auth = task->tk_client->cl_auth;
479 struct rpc_cred *ret;
480 474
481 dprintk("RPC: %5u looking up %s cred\n", 475 dprintk("RPC: %5u looking up %s cred\n",
482 task->tk_pid, auth->au_ops->au_name); 476 task->tk_pid, auth->au_ops->au_name);
483 ret = rpcauth_lookupcred(auth, lookupflags); 477 return rpcauth_lookupcred(auth, lookupflags);
484 if (!IS_ERR(ret))
485 task->tk_msg.rpc_cred = ret;
486 else
487 task->tk_status = PTR_ERR(ret);
488} 478}
489 479
490void 480int
491rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) 481rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags)
492{ 482{
483 struct rpc_cred *new;
493 int lookupflags = 0; 484 int lookupflags = 0;
494 485
495 if (flags & RPC_TASK_ASYNC) 486 if (flags & RPC_TASK_ASYNC)
496 lookupflags |= RPCAUTH_LOOKUP_NEW; 487 lookupflags |= RPCAUTH_LOOKUP_NEW;
497 if (cred != NULL) 488 if (cred != NULL)
498 cred->cr_ops->crbind(task, cred, lookupflags); 489 new = cred->cr_ops->crbind(task, cred, lookupflags);
499 else if (flags & RPC_TASK_ROOTCREDS) 490 else if (flags & RPC_TASK_ROOTCREDS)
500 rpcauth_bind_root_cred(task, lookupflags); 491 new = rpcauth_bind_root_cred(task, lookupflags);
501 else 492 else
502 rpcauth_bind_new_cred(task, lookupflags); 493 new = rpcauth_bind_new_cred(task, lookupflags);
494 if (IS_ERR(new))
495 return PTR_ERR(new);
496 if (task->tk_msg.rpc_cred != NULL)
497 put_rpccred(task->tk_msg.rpc_cred);
498 task->tk_msg.rpc_cred = new;
499 return 0;
503} 500}
504 501
505void 502void