diff options
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/auth_generic.c | 26 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/auth_gss.c | 12 |
2 files changed, 35 insertions, 3 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 | } |
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 7567eb95823b..46f7ec800af9 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
@@ -371,9 +371,16 @@ gss_alloc_msg(struct gss_auth *gss_auth, uid_t uid) | |||
371 | static struct gss_upcall_msg * | 371 | static struct gss_upcall_msg * |
372 | gss_setup_upcall(struct rpc_clnt *clnt, struct gss_auth *gss_auth, struct rpc_cred *cred) | 372 | gss_setup_upcall(struct rpc_clnt *clnt, struct gss_auth *gss_auth, struct rpc_cred *cred) |
373 | { | 373 | { |
374 | struct gss_cred *gss_cred = container_of(cred, | ||
375 | struct gss_cred, gc_base); | ||
374 | struct gss_upcall_msg *gss_new, *gss_msg; | 376 | struct gss_upcall_msg *gss_new, *gss_msg; |
377 | uid_t uid = cred->cr_uid; | ||
375 | 378 | ||
376 | gss_new = gss_alloc_msg(gss_auth, cred->cr_uid); | 379 | /* Special case: rpc.gssd assumes that uid == 0 implies machine creds */ |
380 | if (gss_cred->gc_machine_cred != 0) | ||
381 | uid = 0; | ||
382 | |||
383 | gss_new = gss_alloc_msg(gss_auth, uid); | ||
377 | if (gss_new == NULL) | 384 | if (gss_new == NULL) |
378 | return ERR_PTR(-ENOMEM); | 385 | return ERR_PTR(-ENOMEM); |
379 | gss_msg = gss_add_msg(gss_auth, gss_new); | 386 | gss_msg = gss_add_msg(gss_auth, gss_new); |
@@ -818,6 +825,7 @@ gss_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) | |||
818 | */ | 825 | */ |
819 | cred->gc_base.cr_flags = 1UL << RPCAUTH_CRED_NEW; | 826 | cred->gc_base.cr_flags = 1UL << RPCAUTH_CRED_NEW; |
820 | cred->gc_service = gss_auth->service; | 827 | cred->gc_service = gss_auth->service; |
828 | cred->gc_machine_cred = acred->machine_cred; | ||
821 | kref_get(&gss_auth->kref); | 829 | kref_get(&gss_auth->kref); |
822 | return &cred->gc_base; | 830 | return &cred->gc_base; |
823 | 831 | ||
@@ -855,6 +863,8 @@ gss_match(struct auth_cred *acred, struct rpc_cred *rc, int flags) | |||
855 | if (gss_cred->gc_ctx && time_after(jiffies, gss_cred->gc_ctx->gc_expiry)) | 863 | if (gss_cred->gc_ctx && time_after(jiffies, gss_cred->gc_ctx->gc_expiry)) |
856 | return 0; | 864 | return 0; |
857 | out: | 865 | out: |
866 | if (acred->machine_cred != gss_cred->gc_machine_cred) | ||
867 | return 0; | ||
858 | return (rc->cr_uid == acred->uid); | 868 | return (rc->cr_uid == acred->uid); |
859 | } | 869 | } |
860 | 870 | ||