diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-03-12 16:21:07 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-03-14 13:42:41 -0400 |
commit | 5c691044ecbca04dd558fca4c754121689fe1b34 (patch) | |
tree | 7a56b63c44766fcca0d7ac245ce0e19077b6f118 | |
parent | 9a559efd4199c9812d339e23cc1b6055366b224f (diff) |
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>
-rw-r--r-- | include/linux/sunrpc/auth.h | 2 | ||||
-rw-r--r-- | net/sunrpc/auth.c | 5 | ||||
-rw-r--r-- | net/sunrpc/auth_generic.c | 15 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/auth_gss.c | 2 | ||||
-rw-r--r-- | net/sunrpc/auth_null.c | 1 | ||||
-rw-r--r-- | net/sunrpc/auth_unix.c | 1 |
6 files changed, 24 insertions, 2 deletions
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index 70644ed67996..e93cd8aa3eb6 100644 --- a/include/linux/sunrpc/auth.h +++ b/include/linux/sunrpc/auth.h | |||
@@ -112,6 +112,7 @@ struct rpc_credops { | |||
112 | void (*crdestroy)(struct rpc_cred *); | 112 | void (*crdestroy)(struct rpc_cred *); |
113 | 113 | ||
114 | int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); | 114 | int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); |
115 | void (*crbind)(struct rpc_task *, struct rpc_cred *); | ||
115 | __be32 * (*crmarshal)(struct rpc_task *, __be32 *); | 116 | __be32 * (*crmarshal)(struct rpc_task *, __be32 *); |
116 | int (*crrefresh)(struct rpc_task *); | 117 | int (*crrefresh)(struct rpc_task *); |
117 | __be32 * (*crvalidate)(struct rpc_task *, __be32 *); | 118 | __be32 * (*crvalidate)(struct rpc_task *, __be32 *); |
@@ -139,6 +140,7 @@ struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred * | |||
139 | void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); | 140 | void rpcauth_init_cred(struct rpc_cred *, const struct auth_cred *, struct rpc_auth *, const struct rpc_credops *); |
140 | struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); | 141 | struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); |
141 | void rpcauth_bindcred(struct rpc_task *, struct rpc_cred *, int); | 142 | void rpcauth_bindcred(struct rpc_task *, struct rpc_cred *, int); |
143 | void rpcauth_generic_bind_cred(struct rpc_task *, struct rpc_cred *); | ||
142 | void put_rpccred(struct rpc_cred *); | 144 | void put_rpccred(struct rpc_cred *); |
143 | void rpcauth_unbindcred(struct rpc_task *); | 145 | void rpcauth_unbindcred(struct rpc_task *); |
144 | __be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); | 146 | __be32 * rpcauth_marshcred(struct rpc_task *, __be32 *); |
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 012f2a320638..d65dd7940102 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
@@ -375,13 +375,14 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred, | |||
375 | } | 375 | } |
376 | EXPORT_SYMBOL_GPL(rpcauth_init_cred); | 376 | EXPORT_SYMBOL_GPL(rpcauth_init_cred); |
377 | 377 | ||
378 | static void | 378 | void |
379 | rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred) | 379 | rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred) |
380 | { | 380 | { |
381 | task->tk_msg.rpc_cred = get_rpccred(cred); | 381 | task->tk_msg.rpc_cred = get_rpccred(cred); |
382 | dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid, | 382 | dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid, |
383 | cred->cr_auth->au_ops->au_name, cred); | 383 | cred->cr_auth->au_ops->au_name, cred); |
384 | } | 384 | } |
385 | EXPORT_SYMBOL_GPL(rpcauth_generic_bind_cred); | ||
385 | 386 | ||
386 | static void | 387 | static void |
387 | rpcauth_bind_root_cred(struct rpc_task *task) | 388 | rpcauth_bind_root_cred(struct rpc_task *task) |
@@ -421,7 +422,7 @@ void | |||
421 | rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) | 422 | rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) |
422 | { | 423 | { |
423 | if (cred != NULL) | 424 | if (cred != NULL) |
424 | rpcauth_generic_bind_cred(task, cred); | 425 | cred->cr_ops->crbind(task, cred); |
425 | else if (flags & RPC_TASK_ROOTCREDS) | 426 | else if (flags & RPC_TASK_ROOTCREDS) |
426 | rpcauth_bind_root_cred(task); | 427 | rpcauth_bind_root_cred(task); |
427 | else | 428 | else |
diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c index 6f129b1b20a0..6a3f77c9e4d3 100644 --- a/net/sunrpc/auth_generic.c +++ b/net/sunrpc/auth_generic.c | |||
@@ -35,6 +35,20 @@ struct rpc_cred *rpc_lookup_cred(void) | |||
35 | } | 35 | } |
36 | EXPORT_SYMBOL_GPL(rpc_lookup_cred); | 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 | * Lookup generic creds for current process | 53 | * Lookup generic creds for current process |
40 | */ | 54 | */ |
@@ -138,5 +152,6 @@ static struct rpc_auth generic_auth = { | |||
138 | static const struct rpc_credops generic_credops = { | 152 | static const struct rpc_credops generic_credops = { |
139 | .cr_name = "Generic cred", | 153 | .cr_name = "Generic cred", |
140 | .crdestroy = generic_destroy_cred, | 154 | .crdestroy = generic_destroy_cred, |
155 | .crbind = generic_bind_cred, | ||
141 | .crmatch = generic_match, | 156 | .crmatch = generic_match, |
142 | }; | 157 | }; |
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index ef6384961808..d34f6dfc7516 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
@@ -1300,6 +1300,7 @@ static const struct rpc_credops gss_credops = { | |||
1300 | .cr_name = "AUTH_GSS", | 1300 | .cr_name = "AUTH_GSS", |
1301 | .crdestroy = gss_destroy_cred, | 1301 | .crdestroy = gss_destroy_cred, |
1302 | .cr_init = gss_cred_init, | 1302 | .cr_init = gss_cred_init, |
1303 | .crbind = rpcauth_generic_bind_cred, | ||
1303 | .crmatch = gss_match, | 1304 | .crmatch = gss_match, |
1304 | .crmarshal = gss_marshal, | 1305 | .crmarshal = gss_marshal, |
1305 | .crrefresh = gss_refresh, | 1306 | .crrefresh = gss_refresh, |
@@ -1311,6 +1312,7 @@ static const struct rpc_credops gss_credops = { | |||
1311 | static const struct rpc_credops gss_nullops = { | 1312 | static const struct rpc_credops gss_nullops = { |
1312 | .cr_name = "AUTH_GSS", | 1313 | .cr_name = "AUTH_GSS", |
1313 | .crdestroy = gss_destroy_cred, | 1314 | .crdestroy = gss_destroy_cred, |
1315 | .crbind = rpcauth_generic_bind_cred, | ||
1314 | .crmatch = gss_match, | 1316 | .crmatch = gss_match, |
1315 | .crmarshal = gss_marshal, | 1317 | .crmarshal = gss_marshal, |
1316 | .crrefresh = gss_refresh_null, | 1318 | .crrefresh = gss_refresh_null, |
diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c index 537d0e8589dd..3c26c18df0de 100644 --- a/net/sunrpc/auth_null.c +++ b/net/sunrpc/auth_null.c | |||
@@ -125,6 +125,7 @@ static | |||
125 | const struct rpc_credops null_credops = { | 125 | const struct rpc_credops null_credops = { |
126 | .cr_name = "AUTH_NULL", | 126 | .cr_name = "AUTH_NULL", |
127 | .crdestroy = nul_destroy_cred, | 127 | .crdestroy = nul_destroy_cred, |
128 | .crbind = rpcauth_generic_bind_cred, | ||
128 | .crmatch = nul_match, | 129 | .crmatch = nul_match, |
129 | .crmarshal = nul_marshal, | 130 | .crmarshal = nul_marshal, |
130 | .crrefresh = nul_refresh, | 131 | .crrefresh = nul_refresh, |
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index b763710d3dbd..04e936a56fb2 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c | |||
@@ -237,6 +237,7 @@ static | |||
237 | const struct rpc_credops unix_credops = { | 237 | const struct rpc_credops unix_credops = { |
238 | .cr_name = "AUTH_UNIX", | 238 | .cr_name = "AUTH_UNIX", |
239 | .crdestroy = unx_destroy_cred, | 239 | .crdestroy = unx_destroy_cred, |
240 | .crbind = rpcauth_generic_bind_cred, | ||
240 | .crmatch = unx_match, | 241 | .crmatch = unx_match, |
241 | .crmarshal = unx_marshal, | 242 | .crmarshal = unx_marshal, |
242 | .crrefresh = unx_refresh, | 243 | .crrefresh = unx_refresh, |