aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
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
parent58f9612c6ea858f532021a0ce42ec53cb0a493b3 (diff)
SUNRPC: Clean up of rpc_bindcred()
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/auth.c37
-rw-r--r--net/sunrpc/auth_generic.c11
-rw-r--r--net/sunrpc/clnt.c2
3 files changed, 21 insertions, 29 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
diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c
index 8bae33b36cc6..43162bb3b78f 100644
--- a/net/sunrpc/auth_generic.c
+++ b/net/sunrpc/auth_generic.c
@@ -54,18 +54,13 @@ struct rpc_cred *rpc_lookup_machine_cred(void)
54} 54}
55EXPORT_SYMBOL_GPL(rpc_lookup_machine_cred); 55EXPORT_SYMBOL_GPL(rpc_lookup_machine_cred);
56 56
57static void 57static struct rpc_cred *generic_bind_cred(struct rpc_task *task,
58generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred, int lookupflags) 58 struct rpc_cred *cred, int lookupflags)
59{ 59{
60 struct rpc_auth *auth = task->tk_client->cl_auth; 60 struct rpc_auth *auth = task->tk_client->cl_auth;
61 struct auth_cred *acred = &container_of(cred, struct generic_cred, gc_base)->acred; 61 struct auth_cred *acred = &container_of(cred, struct generic_cred, gc_base)->acred;
62 struct rpc_cred *ret;
63 62
64 ret = auth->au_ops->lookup_cred(auth, acred, lookupflags); 63 return auth->au_ops->lookup_cred(auth, acred, lookupflags);
65 if (!IS_ERR(ret))
66 task->tk_msg.rpc_cred = ret;
67 else
68 task->tk_status = PTR_ERR(ret);
69} 64}
70 65
71/* 66/*
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 3647c81fd689..f34b5e3823c0 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -606,7 +606,7 @@ rpc_task_set_rpc_message(struct rpc_task *task, const struct rpc_message *msg)
606 task->tk_msg.rpc_argp = msg->rpc_argp; 606 task->tk_msg.rpc_argp = msg->rpc_argp;
607 task->tk_msg.rpc_resp = msg->rpc_resp; 607 task->tk_msg.rpc_resp = msg->rpc_resp;
608 /* Bind the user cred */ 608 /* Bind the user cred */
609 rpcauth_bindcred(task, msg->rpc_cred, task->tk_flags); 609 task->tk_status = rpcauth_bindcred(task, msg->rpc_cred, task->tk_flags);
610 } 610 }
611} 611}
612 612