diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2012-07-11 16:31:08 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-07-16 15:12:15 -0400 |
commit | 6a1a1e34dc55f17e7bd260809207442dbb7a0296 (patch) | |
tree | 3a2ce5b9d3c8edc80f6486efc1f9b34cee559f8f /net/sunrpc/auth_gss/gss_mech_switch.c | |
parent | 56d08fef2369d5ca9ad2e1fc697f5379fd8af751 (diff) |
SUNRPC: Add rpcauth_list_flavors()
The gss_mech_list_pseudoflavors() function provides a list of
currently registered GSS pseudoflavors. This list does not include
any non-GSS flavors that have been registered with the RPC client.
nfs4_find_root_sec() currently adds these extra flavors by hand.
Instead, nfs4_find_root_sec() should be looking at the set of flavors
that have been explicitly registered via rpcauth_register(). And,
other areas of code will soon need the same kind of list that
contains all flavors the kernel currently knows about (see below).
Rather than cloning the open-coded logic in nfs4_find_root_sec() to
those new places, introduce a generic RPC function that generates a
full list of registered auth flavors and pseudoflavors.
A new rpc_authops method is added that lists a flavor's
pseudoflavors, if it has any. I encountered an interesting module
loader loop when I tried to get the RPC client to invoke
gss_mech_list_pseudoflavors() by name.
This patch is a pre-requisite for server trunking discovery, and a
pre-requisite for fixing up the in-kernel mount client to do better
automatic security flavor selection.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/auth_gss/gss_mech_switch.c')
-rw-r--r-- | net/sunrpc/auth_gss/gss_mech_switch.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c b/net/sunrpc/auth_gss/gss_mech_switch.c index 782bfe1b6465..6ac5dfcd2928 100644 --- a/net/sunrpc/auth_gss/gss_mech_switch.c +++ b/net/sunrpc/auth_gss/gss_mech_switch.c | |||
@@ -239,14 +239,26 @@ gss_mech_get_by_pseudoflavor(u32 pseudoflavor) | |||
239 | 239 | ||
240 | EXPORT_SYMBOL_GPL(gss_mech_get_by_pseudoflavor); | 240 | EXPORT_SYMBOL_GPL(gss_mech_get_by_pseudoflavor); |
241 | 241 | ||
242 | int gss_mech_list_pseudoflavors(rpc_authflavor_t *array_ptr) | 242 | /** |
243 | * gss_mech_list_pseudoflavors - Discover registered GSS pseudoflavors | ||
244 | * @array: array to fill in | ||
245 | * @size: size of "array" | ||
246 | * | ||
247 | * Returns the number of array items filled in, or a negative errno. | ||
248 | * | ||
249 | * The returned array is not sorted by any policy. Callers should not | ||
250 | * rely on the order of the items in the returned array. | ||
251 | */ | ||
252 | int gss_mech_list_pseudoflavors(rpc_authflavor_t *array_ptr, int size) | ||
243 | { | 253 | { |
244 | struct gss_api_mech *pos = NULL; | 254 | struct gss_api_mech *pos = NULL; |
245 | int j, i = 0; | 255 | int j, i = 0; |
246 | 256 | ||
247 | spin_lock(®istered_mechs_lock); | 257 | spin_lock(®istered_mechs_lock); |
248 | list_for_each_entry(pos, ®istered_mechs, gm_list) { | 258 | list_for_each_entry(pos, ®istered_mechs, gm_list) { |
249 | for (j=0; j < pos->gm_pf_num; j++) { | 259 | for (j = 0; j < pos->gm_pf_num; j++) { |
260 | if (i >= size) | ||
261 | return -ENOMEM; | ||
250 | array_ptr[i++] = pos->gm_pfs[j].pseudoflavor; | 262 | array_ptr[i++] = pos->gm_pfs[j].pseudoflavor; |
251 | } | 263 | } |
252 | } | 264 | } |
@@ -254,8 +266,6 @@ int gss_mech_list_pseudoflavors(rpc_authflavor_t *array_ptr) | |||
254 | return i; | 266 | return i; |
255 | } | 267 | } |
256 | 268 | ||
257 | EXPORT_SYMBOL_GPL(gss_mech_list_pseudoflavors); | ||
258 | |||
259 | u32 | 269 | u32 |
260 | gss_svc_to_pseudoflavor(struct gss_api_mech *gm, u32 service) | 270 | gss_svc_to_pseudoflavor(struct gss_api_mech *gm, u32 service) |
261 | { | 271 | { |