diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-04-07 20:50:11 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-04-19 16:54:56 -0400 |
commit | 7c67db3a8a98045744f06fcd6d8f476d9df0ba5c (patch) | |
tree | 4d0041249b48f9ac66560550e0e96c9c86c37891 /net/sunrpc/auth_generic.c | |
parent | 78ea323be6380a9313e87fe241809e912e8ae401 (diff) |
NFSv4: Reintroduce machine creds
We need to try to ensure that we always use the same credentials whenever
we re-establish the clientid on the server. If not, the server won't
recognise that we're the same client, and so may not allow us to recover
state.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/auth_generic.c')
-rw-r--r-- | net/sunrpc/auth_generic.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/net/sunrpc/auth_generic.c b/net/sunrpc/auth_generic.c index b6f124c85072..d927d9f57412 100644 --- a/net/sunrpc/auth_generic.c +++ b/net/sunrpc/auth_generic.c | |||
@@ -17,6 +17,9 @@ | |||
17 | # define RPCDBG_FACILITY RPCDBG_AUTH | 17 | # define RPCDBG_FACILITY RPCDBG_AUTH |
18 | #endif | 18 | #endif |
19 | 19 | ||
20 | #define RPC_ANONYMOUS_USERID ((uid_t)-2) | ||
21 | #define RPC_ANONYMOUS_GROUPID ((gid_t)-2) | ||
22 | |||
20 | struct generic_cred { | 23 | struct generic_cred { |
21 | struct rpc_cred gc_base; | 24 | struct rpc_cred gc_base; |
22 | struct auth_cred acred; | 25 | struct auth_cred acred; |
@@ -35,6 +38,22 @@ struct rpc_cred *rpc_lookup_cred(void) | |||
35 | } | 38 | } |
36 | EXPORT_SYMBOL_GPL(rpc_lookup_cred); | 39 | EXPORT_SYMBOL_GPL(rpc_lookup_cred); |
37 | 40 | ||
41 | /* | ||
42 | * Public call interface for looking up machine creds. | ||
43 | */ | ||
44 | struct rpc_cred *rpc_lookup_machine_cred(void) | ||
45 | { | ||
46 | struct auth_cred acred = { | ||
47 | .uid = RPC_ANONYMOUS_USERID, | ||
48 | .gid = RPC_ANONYMOUS_GROUPID, | ||
49 | .machine_cred = 1, | ||
50 | }; | ||
51 | |||
52 | dprintk("RPC: looking up machine cred\n"); | ||
53 | return generic_auth.au_ops->lookup_cred(&generic_auth, &acred, 0); | ||
54 | } | ||
55 | EXPORT_SYMBOL_GPL(rpc_lookup_machine_cred); | ||
56 | |||
38 | static void | 57 | static void |
39 | generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred) | 58 | generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred) |
40 | { | 59 | { |
@@ -75,8 +94,10 @@ generic_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) | |||
75 | gcred->acred.group_info = acred->group_info; | 94 | gcred->acred.group_info = acred->group_info; |
76 | if (gcred->acred.group_info != NULL) | 95 | if (gcred->acred.group_info != NULL) |
77 | get_group_info(gcred->acred.group_info); | 96 | get_group_info(gcred->acred.group_info); |
97 | gcred->acred.machine_cred = acred->machine_cred; | ||
78 | 98 | ||
79 | dprintk("RPC: allocated generic cred %p for uid %d gid %d\n", | 99 | dprintk("RPC: allocated %s cred %p for uid %d gid %d\n", |
100 | gcred->acred.machine_cred ? "machine" : "generic", | ||
80 | gcred, acred->uid, acred->gid); | 101 | gcred, acred->uid, acred->gid); |
81 | return &gcred->gc_base; | 102 | return &gcred->gc_base; |
82 | } | 103 | } |
@@ -115,7 +136,8 @@ generic_match(struct auth_cred *acred, struct rpc_cred *cred, int flags) | |||
115 | 136 | ||
116 | if (gcred->acred.uid != acred->uid || | 137 | if (gcred->acred.uid != acred->uid || |
117 | gcred->acred.gid != acred->gid || | 138 | gcred->acred.gid != acred->gid || |
118 | gcred->acred.group_info != acred->group_info) | 139 | gcred->acred.group_info != acred->group_info || |
140 | gcred->acred.machine_cred != acred->machine_cred) | ||
119 | return 0; | 141 | return 0; |
120 | return 1; | 142 | return 1; |
121 | } | 143 | } |