Commit 5c691044ecbca04dd558fca4c754121689fe1b34
1 parent
9a559efd41
Exists in
master
and in
7 other branches
SUNRPC: Add an rpc_credop callback for binding a credential to an rpc_task
We need the ability to treat 'generic' creds specially, since they want to bind instances of the auth cred instead of binding themselves. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Showing 6 changed files with 24 additions and 2 deletions Side-by-side Diff
include/linux/sunrpc/auth.h
... | ... | @@ -112,6 +112,7 @@ |
112 | 112 | void (*crdestroy)(struct rpc_cred *); |
113 | 113 | |
114 | 114 | int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); |
115 | + void (*crbind)(struct rpc_task *, struct rpc_cred *); | |
115 | 116 | __be32 * (*crmarshal)(struct rpc_task *, __be32 *); |
116 | 117 | int (*crrefresh)(struct rpc_task *); |
117 | 118 | __be32 * (*crvalidate)(struct rpc_task *, __be32 *); |
... | ... | @@ -139,6 +140,7 @@ |
139 | 140 | void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); |
140 | 141 | struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); |
141 | 142 | void rpcauth_bindcred(struct rpc_task *, struct rpc_cred *, int); |
143 | +void rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *); | |
142 | 144 | void put_rpccred(struct rpc_cred *); |
143 | 145 | void rpcauth_unbindcred(struct rpc_task *); |
144 | 146 | __be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); |
net/sunrpc/auth.c
... | ... | @@ -375,13 +375,14 @@ |
375 | 375 | } |
376 | 376 | EXPORT_SYMBOL_GPL(rpcauth_init_cred); |
377 | 377 | |
378 | -static void | |
378 | +void | |
379 | 379 | rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred) |
380 | 380 | { |
381 | 381 | task->tk_msg.rpc_cred = get_rpccred(cred); |
382 | 382 | dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid, |
383 | 383 | cred->cr_auth->au_ops->au_name, cred); |
384 | 384 | } |
385 | +EXPORT_SYMBOL_GPL(rpcauth_generic_bind_cred); | |
385 | 386 | |
386 | 387 | static void |
387 | 388 | rpcauth_bind_root_cred(struct rpc_task *task) |
... | ... | @@ -421,7 +422,7 @@ |
421 | 422 | rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) |
422 | 423 | { |
423 | 424 | if (cred != NULL) |
424 | - rpcauth_generic_bind_cred(task, cred); | |
425 | + cred->cr_ops->crbind(task, cred); | |
425 | 426 | else if (flags & RPC_TASK_ROOTCREDS) |
426 | 427 | rpcauth_bind_root_cred(task); |
427 | 428 | else |
net/sunrpc/auth_generic.c
... | ... | @@ -35,6 +35,20 @@ |
35 | 35 | } |
36 | 36 | EXPORT_SYMBOL_GPL(rpc_lookup_cred); |
37 | 37 | |
38 | +static void | |
39 | +generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred) | |
40 | +{ | |
41 | + struct rpc_auth *auth = task->tk_client->cl_auth; | |
42 | + struct auth_cred *acred = &container_of(cred, struct generic_cred, gc_base)->acred; | |
43 | + struct rpc_cred *ret; | |
44 | + | |
45 | + ret = auth->au_ops->lookup_cred(auth, acred, 0); | |
46 | + if (!IS_ERR(ret)) | |
47 | + task->tk_msg.rpc_cred = ret; | |
48 | + else | |
49 | + task->tk_status = PTR_ERR(ret); | |
50 | +} | |
51 | + | |
38 | 52 | /* |
39 | 53 | * Lookup generic creds for current process |
40 | 54 | */ |
... | ... | @@ -138,6 +152,7 @@ |
138 | 152 | static const struct rpc_credops generic_credops = { |
139 | 153 | .cr_name = "Generic cred", |
140 | 154 | .crdestroy = generic_destroy_cred, |
155 | + .crbind = generic_bind_cred, | |
141 | 156 | .crmatch = generic_match, |
142 | 157 | }; |
net/sunrpc/auth_gss/auth_gss.c
... | ... | @@ -1300,6 +1300,7 @@ |
1300 | 1300 | .cr_name = "AUTH_GSS", |
1301 | 1301 | .crdestroy = gss_destroy_cred, |
1302 | 1302 | .cr_init = gss_cred_init, |
1303 | + .crbind = rpcauth_generic_bind_cred, | |
1303 | 1304 | .crmatch = gss_match, |
1304 | 1305 | .crmarshal = gss_marshal, |
1305 | 1306 | .crrefresh = gss_refresh, |
... | ... | @@ -1311,6 +1312,7 @@ |
1311 | 1312 | static const struct rpc_credops gss_nullops = { |
1312 | 1313 | .cr_name = "AUTH_GSS", |
1313 | 1314 | .crdestroy = gss_destroy_cred, |
1315 | + .crbind = rpcauth_generic_bind_cred, | |
1314 | 1316 | .crmatch = gss_match, |
1315 | 1317 | .crmarshal = gss_marshal, |
1316 | 1318 | .crrefresh = gss_refresh_null, |
net/sunrpc/auth_null.c
net/sunrpc/auth_unix.c