aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/auth.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2008-03-12 12:12:16 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-03-14 13:42:32 -0400
commitaf093835774931de898a9baf7b4041fa0d100f77 (patch)
treef7617eb4556ead8615f6c26d8b02fcec8f64c6b3 /net/sunrpc/auth.c
parent25337fdc85951dfeac944f16cb565904c619077a (diff)
SUNRPC: Fix RPCAUTH_LOOKUP_ROOTCREDS
The current RPCAUTH_LOOKUP_ROOTCREDS flag only works for AUTH_SYS authentication, and then only as a special case in the code. This patch removes the auth_sys special casing, and replaces it with generic code. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/auth.c')
-rw-r--r--net/sunrpc/auth.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index b38f6ee2f5e2..b0f2b2ee7cc0 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -285,9 +285,6 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred,
285 285
286 nr = hash_long(acred->uid, RPC_CREDCACHE_HASHBITS); 286 nr = hash_long(acred->uid, RPC_CREDCACHE_HASHBITS);
287 287
288 if (!(flags & RPCAUTH_LOOKUP_ROOTCREDS))
289 nr = acred->uid & RPC_CREDCACHE_MASK;
290
291 rcu_read_lock(); 288 rcu_read_lock();
292 hlist_for_each_entry_rcu(entry, pos, &cache->hashtable[nr], cr_hash) { 289 hlist_for_each_entry_rcu(entry, pos, &cache->hashtable[nr], cr_hash) {
293 if (!entry->cr_ops->crmatch(acred, entry, flags)) 290 if (!entry->cr_ops->crmatch(acred, entry, flags))
@@ -378,30 +375,38 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
378} 375}
379EXPORT_SYMBOL_GPL(rpcauth_init_cred); 376EXPORT_SYMBOL_GPL(rpcauth_init_cred);
380 377
381struct rpc_cred * 378void
382rpcauth_bindcred(struct rpc_task *task) 379rpcauth_bind_root_cred(struct rpc_task *task)
383{ 380{
384 struct rpc_auth *auth = task->tk_client->cl_auth; 381 struct rpc_auth *auth = task->tk_client->cl_auth;
385 struct auth_cred acred = { 382 struct auth_cred acred = {
386 .uid = current->fsuid, 383 .uid = 0,
387 .gid = current->fsgid, 384 .gid = 0,
388 .group_info = current->group_info,
389 }; 385 };
390 struct rpc_cred *ret; 386 struct rpc_cred *ret;
391 int flags = 0;
392 387
393 dprintk("RPC: %5u looking up %s cred\n", 388 dprintk("RPC: %5u looking up %s cred\n",
394 task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); 389 task->tk_pid, task->tk_client->cl_auth->au_ops->au_name);
395 get_group_info(acred.group_info); 390 ret = auth->au_ops->lookup_cred(auth, &acred, 0);
396 if (task->tk_flags & RPC_TASK_ROOTCREDS) 391 if (!IS_ERR(ret))
397 flags |= RPCAUTH_LOOKUP_ROOTCREDS; 392 task->tk_msg.rpc_cred = ret;
398 ret = auth->au_ops->lookup_cred(auth, &acred, flags); 393 else
394 task->tk_status = PTR_ERR(ret);
395}
396
397void
398rpcauth_bindcred(struct rpc_task *task)
399{
400 struct rpc_auth *auth = task->tk_client->cl_auth;
401 struct rpc_cred *ret;
402
403 dprintk("RPC: %5u looking up %s cred\n",
404 task->tk_pid, auth->au_ops->au_name);
405 ret = rpcauth_lookupcred(auth, 0);
399 if (!IS_ERR(ret)) 406 if (!IS_ERR(ret))
400 task->tk_msg.rpc_cred = ret; 407 task->tk_msg.rpc_cred = ret;
401 else 408 else
402 task->tk_status = PTR_ERR(ret); 409 task->tk_status = PTR_ERR(ret);
403 put_group_info(acred.group_info);
404 return ret;
405} 410}
406 411
407void 412void