diff options
-rw-r--r-- | include/linux/sunrpc/auth.h | 6 | ||||
-rw-r--r-- | net/sunrpc/auth.c | 37 | ||||
-rw-r--r-- | net/sunrpc/auth_generic.c | 11 | ||||
-rw-r--r-- | net/sunrpc/clnt.c | 2 |
4 files changed, 24 insertions, 32 deletions
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index d2737625a247..90e4c3827ac0 100644 --- a/include/linux/sunrpc/auth.h +++ b/include/linux/sunrpc/auth.h | |||
@@ -106,7 +106,7 @@ struct rpc_credops { | |||
106 | void (*crdestroy)(struct rpc_cred *); | 106 | void (*crdestroy)(struct rpc_cred *); |
107 | 107 | ||
108 | int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); | 108 | int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); |
109 | void (*crbind)(struct rpc_task *, struct rpc_cred *, int); | 109 | struct rpc_cred * (*crbind)(struct rpc_task *, struct rpc_cred *, int); |
110 | __be32 * (*crmarshal)(struct rpc_task *, __be32 *); | 110 | __be32 * (*crmarshal)(struct rpc_task *, __be32 *); |
111 | int (*crrefresh)(struct rpc_task *); | 111 | int (*crrefresh)(struct rpc_task *); |
112 | __be32 * (*crvalidate)(struct rpc_task *, __be32 *); | 112 | __be32 * (*crvalidate)(struct rpc_task *, __be32 *); |
@@ -135,8 +135,8 @@ void rpcauth_release(struct rpc_auth *); | |||
135 | struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int); | 135 | struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int); |
136 | void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); | 136 | void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); |
137 | struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); | 137 | struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); |
138 | void rpcauth_bindcred(struct rpc_task *, struct rpc_cred *, int); | 138 | int rpcauth_bindcred(struct rpc_task *, struct rpc_cred *, int); |
139 | void rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *, int); | 139 | struct rpc_cred * rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *, int); |
140 | void put_rpccred(struct rpc_cred *); | 140 | void put_rpccred(struct rpc_cred *); |
141 | void rpcauth_unbindcred(struct rpc_task *); | 141 | void rpcauth_unbindcred(struct rpc_task *); |
142 | __be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); | 142 | __be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); |
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 | } |
445 | EXPORT_SYMBOL_GPL(rpcauth_init_cred); | 445 | EXPORT_SYMBOL_GPL(rpcauth_init_cred); |
446 | 446 | ||
447 | void | 447 | struct rpc_cred * |
448 | rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred, int lookupflags) | 448 | rpcauth_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 | } |
454 | EXPORT_SYMBOL_GPL(rpcauth_generic_bind_cred); | 454 | EXPORT_SYMBOL_GPL(rpcauth_generic_bind_cred); |
455 | 455 | ||
456 | static void | 456 | static struct rpc_cred * |
457 | rpcauth_bind_root_cred(struct rpc_task *task, int lookupflags) | 457 | rpcauth_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 | ||
475 | static void | 470 | static struct rpc_cred * |
476 | rpcauth_bind_new_cred(struct rpc_task *task, int lookupflags) | 471 | rpcauth_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 | ||
490 | void | 480 | int |
491 | rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) | 481 | rpcauth_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 | ||
505 | void | 502 | void |
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 | } |
55 | EXPORT_SYMBOL_GPL(rpc_lookup_machine_cred); | 55 | EXPORT_SYMBOL_GPL(rpc_lookup_machine_cred); |
56 | 56 | ||
57 | static void | 57 | static struct rpc_cred *generic_bind_cred(struct rpc_task *task, |
58 | generic_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 | ||