36 #include <linux/types.h>
37 #include <linux/slab.h>
38 #include <linux/module.h>
49 # define RPCDBG_FACILITY RPCDBG_AUTH
56 gss_mech_free(
struct gss_api_mech *gm)
61 for (i = 0; i < gm->gm_pf_num; i++) {
63 kfree(pf->auth_domain_name);
64 pf->auth_domain_name =
NULL;
69 make_auth_domain_name(
char *
name)
71 static char *
prefix =
"gss/";
83 gss_mech_svc_setup(
struct gss_api_mech *gm)
88 for (i = 0; i < gm->gm_pf_num; i++) {
90 pf->auth_domain_name = make_auth_domain_name(pf->name);
92 if (pf->auth_domain_name ==
NULL)
95 pf->auth_domain_name);
110 status = gss_mech_svc_setup(gm);
113 spin_lock(®istered_mechs_lock);
114 list_add(&gm->gm_list, ®istered_mechs);
115 spin_unlock(®istered_mechs_lock);
116 dprintk(
"RPC: registered gss mechanism %s\n", gm->gm_name);
125 spin_lock(®istered_mechs_lock);
127 spin_unlock(®istered_mechs_lock);
128 dprintk(
"RPC: unregistered gss mechanism %s\n", gm->gm_name);
134 struct gss_api_mech *
137 __module_get(gm->gm_owner);
143 struct gss_api_mech *
146 struct gss_api_mech *
pos, *gm =
NULL;
148 spin_lock(®istered_mechs_lock);
150 if (0 ==
strcmp(name, pos->gm_name)) {
151 if (try_module_get(pos->gm_owner))
156 spin_unlock(®istered_mechs_lock);
163 struct gss_api_mech *gm =
NULL;
167 request_module(
"rpc-auth-gss-%s", name);
174 struct gss_api_mech *
177 struct gss_api_mech *
pos, *gm =
NULL;
179 spin_lock(®istered_mechs_lock);
181 if (obj->len == pos->gm_oid.len) {
182 if (0 ==
memcmp(obj->data, pos->gm_oid.data, obj->len)) {
183 if (try_module_get(pos->gm_owner))
189 spin_unlock(®istered_mechs_lock);
197 mech_supports_pseudoflavor(
struct gss_api_mech *gm,
u32 pseudoflavor)
201 for (i = 0; i < gm->gm_pf_num; i++) {
202 if (gm->gm_pfs[i].pseudoflavor == pseudoflavor)
210 struct gss_api_mech *gm =
NULL, *
pos;
212 spin_lock(®istered_mechs_lock);
214 if (!mech_supports_pseudoflavor(pos, pseudoflavor)) {
215 module_put(pos->gm_owner);
218 if (try_module_get(pos->gm_owner))
222 spin_unlock(®istered_mechs_lock);
226 struct gss_api_mech *
229 struct gss_api_mech *gm;
234 request_module(
"rpc-auth-gss-%u", pseudoflavor);
254 struct gss_api_mech *
pos =
NULL;
257 spin_lock(®istered_mechs_lock);
259 for (j = 0; j < pos->gm_pf_num; j++) {
261 spin_unlock(®istered_mechs_lock);
264 array_ptr[i++] = pos->gm_pfs[
j].pseudoflavor;
267 spin_unlock(®istered_mechs_lock);
276 for (i = 0; i < gm->gm_pf_num; i++) {
277 if (gm->gm_pfs[i].service == service) {
278 return gm->gm_pfs[
i].pseudoflavor;
281 return RPC_AUTH_MAXFLAVOR;
290 for (i = 0; i < gm->gm_pf_num; i++) {
291 if (gm->gm_pfs[i].pseudoflavor == pseudoflavor)
292 return gm->gm_pfs[
i].service;
304 for (i = 0; i < gm->gm_pf_num; i++) {
305 if (gm->gm_pfs[i].service == service)
306 return gm->gm_pfs[
i].auth_domain_name;
317 module_put(gm->gm_owner);
326 struct gss_api_mech *mech,
330 if (!(*ctx_id = kzalloc(
sizeof(**ctx_id), gfp_mask)))
335 ->gss_import_sec_context(input_token, bufsize, *ctx_id, gfp_mask);
343 struct xdr_netobj *mic_token)
345 return context_handle->mech_type->gm_ops
346 ->gss_get_mic(context_handle,
356 struct xdr_netobj *mic_token)
358 return context_handle->mech_type->gm_ops
359 ->gss_verify_mic(context_handle,
382 struct page **inpages)
384 return ctx_id->mech_type->gm_ops
385 ->gss_wrap(ctx_id, offset, buf, inpages);
393 return ctx_id->mech_type->gm_ops
394 ->gss_unwrap(ctx_id, offset, buf);
405 dprintk(
"RPC: gss_delete_sec_context deleting %p\n",
408 if (!*context_handle)
409 return GSS_S_NO_CONTEXT;
410 if ((*context_handle)->internal_ctx_id)
411 (*context_handle)->mech_type->gm_ops
412 ->gss_delete_sec_context((*context_handle)
415 kfree(*context_handle);
416 *context_handle=
NULL;
417 return GSS_S_COMPLETE;