--- ./include/linux/sunrpc/auth.h.orig 2005-06-12 15:30:23.000000000 +0200 +++ ./include/linux/sunrpc/auth.h 2005-06-12 15:32:03.000000000 +0200 @@ -124,10 +124,7 @@ void rpcauth_destroy(struct rpc_auth *); struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct auth_cred *, int); struct rpc_cred * rpcauth_lookupcred(struct rpc_auth *, int); -struct rpc_cred * rpcauth_bindcred(struct rpc_task *); -void rpcauth_holdcred(struct rpc_task *); void put_rpccred(struct rpc_cred *); -void rpcauth_unbindcred(struct rpc_task *); u32 * rpcauth_marshcred(struct rpc_task *, u32 *); u32 * rpcauth_checkverf(struct rpc_task *, u32 *); int rpcauth_wrap_req(struct rpc_task *task, kxdrproc_t encode, void *rqstp, u32 *data, void *obj); --- ./net/sunrpc/auth.c.orig 2005-06-12 15:30:23.000000000 +0200 +++ ./net/sunrpc/auth.c 2005-06-12 15:32:03.000000000 +0200 @@ -256,38 +256,6 @@ return ret; } -struct rpc_cred * -rpcauth_bindcred(struct rpc_task *task) -{ - struct rpc_auth *auth = task->tk_auth; - struct auth_cred acred = { - .uid = current->fsuid, - .gid = current->fsgid, - .group_info = current->group_info, - }; - struct rpc_cred *ret; - - dprintk("RPC: %4d looking up %s cred\n", - task->tk_pid, task->tk_auth->au_ops->au_name); - get_group_info(acred.group_info); - ret = auth->au_ops->lookup_cred(auth, &acred, task->tk_flags); - if (!IS_ERR(ret)) - task->tk_msg.rpc_cred = ret; - else - task->tk_status = PTR_ERR(ret); - put_group_info(acred.group_info); - return ret; -} - -void -rpcauth_holdcred(struct rpc_task *task) -{ - dprintk("RPC: %4d holding %s cred %p\n", - task->tk_pid, task->tk_auth->au_ops->au_name, task->tk_msg.rpc_cred); - if (task->tk_msg.rpc_cred) - get_rpccred(task->tk_msg.rpc_cred); -} - void put_rpccred(struct rpc_cred *cred) { @@ -297,19 +265,6 @@ cred->cr_ops->crdestroy(cred); } -void -rpcauth_unbindcred(struct rpc_task *task) -{ - struct rpc_auth *auth = task->tk_auth; - struct rpc_cred *cred = task->tk_msg.rpc_cred; - - dprintk("RPC: %4d releasing %s cred %p\n", - task->tk_pid, auth->au_ops->au_name, cred); - - put_rpccred(cred); - task->tk_msg.rpc_cred = NULL; -} - u32 * rpcauth_marshcred(struct rpc_task *task, u32 *p) { --- ./net/sunrpc/clnt.c.orig 2005-06-12 15:30:23.000000000 +0200 +++ ./net/sunrpc/clnt.c 2005-06-12 15:42:16.000000000 +0200 @@ -423,13 +423,21 @@ void rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags) { + struct rpc_cred *cred; + task->tk_msg = *msg; task->tk_flags |= flags; - /* Bind the user cred */ - if (task->tk_msg.rpc_cred != NULL) - rpcauth_holdcred(task); - else - rpcauth_bindcred(task); + + if (task->tk_msg.rpc_cred) { + /* we copied msg->rpc_cred, hold it */ + get_rpccred(task->tk_msg.rpc_cred); + } else { + cred = rpcauth_lookupcred(task->tk_auth, task->tk_flags); + if (!IS_ERR(cred)) + task->tk_msg.rpc_cred = cred; + else + task->tk_status = PTR_ERR(cred); + } if (task->tk_status == 0) task->tk_action = call_start; --- ./net/sunrpc/sched.c.orig 2005-06-12 15:30:23.000000000 +0200 +++ ./net/sunrpc/sched.c 2005-06-12 15:32:04.000000000 +0200 @@ -853,8 +853,10 @@ /* Release resources */ if (task->tk_rqstp) xprt_release(task); - if (task->tk_msg.rpc_cred) - rpcauth_unbindcred(task); + if (task->tk_msg.rpc_cred) { + put_rpccred(task->tk_msg.rpc_cred); + task->tk_msg.rpc_cred = NULL; + } rpc_free(task); if (task->tk_client) { rpc_release_client(task->tk_client);