aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2008-03-12 16:21:07 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-03-14 13:42:41 -0400
commit5c691044ecbca04dd558fca4c754121689fe1b34 (patch)
tree7a56b63c44766fcca0d7ac245ce0e19077b6f118 /net
parent9a559efd4199c9812d339e23cc1b6055366b224f (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>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/auth.c5
-rw-r--r--net/sunrpc/auth_generic.c15
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c2
-rw-r--r--net/sunrpc/auth_null.c1
-rw-r--r--net/sunrpc/auth_unix.c1
5 files changed, 22 insertions, 2 deletions
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}
376EXPORT_SYMBOL_GPL(rpcauth_init_cred); 376EXPORT_SYMBOL_GPL(rpcauth_init_cred);
377 377
378static void 378void
379rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred) 379rpcauth_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}
385EXPORT_SYMBOL_GPL(rpcauth_generic_bind_cred);
385 386
386static void 387static void
387rpcauth_bind_root_cred(struct rpc_task *task) 388rpcauth_bind_root_cred(struct rpc_task *task)
@@ -421,7 +422,7 @@ void
421rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags) 422rpcauth_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}
36EXPORT_SYMBOL_GPL(rpc_lookup_cred); 36EXPORT_SYMBOL_GPL(rpc_lookup_cred);
37 37
38static void
39generic_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 = {
138static const struct rpc_credops generic_credops = { 152static 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 = {
1311static const struct rpc_credops gss_nullops = { 1312static 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
125const struct rpc_credops null_credops = { 125const 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
237const struct rpc_credops unix_credops = { 237const 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,