From: Simo Sorce Date: Mon, 6 Aug 2012 20:11:17 +0000 (-0400) Subject: Remove gss_mechanism_ext X-Git-Tag: krb5-1.11-alpha1~335 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=997282ac3ecab3f9e56b96ae4cb53ab83bec2dac;p=thirdparty%2Fkrb5.git Remove gss_mechanism_ext This function did not serve any useful purpose. Remove it and the special case it creates; move the only function it contained to the main gss_mechanism structure where it belongs. Note that the function name is preserved so that loadable modules are not affected by this change. --- diff --git a/src/lib/gssapi/krb5/gssapi_krb5.c b/src/lib/gssapi/krb5/gssapi_krb5.c index e94b90c04d..aad24fe2b6 100644 --- a/src/lib/gssapi/krb5/gssapi_krb5.c +++ b/src/lib/gssapi/krb5/gssapi_krb5.c @@ -899,16 +899,9 @@ static struct gss_config krb5_mechanism = { krb5_gss_inquire_attrs_for_mech, krb5_gss_acquire_cred_from, krb5_gss_store_cred_into, -}; - -static struct gss_config_ext krb5_mechanism_ext = { krb5_gss_acquire_cred_with_password, }; -static struct gss_config_ext iakerb_mechanism_ext = { - iakerb_gss_acquire_cred_with_password, -}; - #ifdef _GSS_STATIC_LINK #include "mglueP.h" static int gss_iakerbmechglue_init(void) @@ -921,10 +914,11 @@ static int gss_iakerbmechglue_init(void) iakerb_mechanism.gss_init_sec_context = iakerb_gss_init_sec_context; iakerb_mechanism.gss_delete_sec_context = iakerb_gss_delete_sec_context; iakerb_mechanism.gss_acquire_cred = iakerb_gss_acquire_cred; + iakerb_mechanism.gssspi_acquire_cred_with_password + = iakerb_gss_acquire_cred_with_password; memset(&mech_iakerb, 0, sizeof(mech_iakerb)); mech_iakerb.mech = &iakerb_mechanism; - mech_iakerb.mech_ext = &iakerb_mechanism_ext; mech_iakerb.mechNameStr = "iakerb"; mech_iakerb.mech_type = (gss_OID)gss_mech_iakerb; @@ -939,7 +933,6 @@ static int gss_krb5mechglue_init(void) memset(&mech_krb5, 0, sizeof(mech_krb5)); mech_krb5.mech = &krb5_mechanism; - mech_krb5.mech_ext = &krb5_mechanism_ext; mech_krb5.mechNameStr = "kerberos_v5"; mech_krb5.mech_type = (gss_OID)gss_mech_krb5; diff --git a/src/lib/gssapi/mechglue/g_acquire_cred_with_pw.c b/src/lib/gssapi/mechglue/g_acquire_cred_with_pw.c index 35ec25c849..4d0dbb9563 100644 --- a/src/lib/gssapi/mechglue/g_acquire_cred_with_pw.c +++ b/src/lib/gssapi/mechglue/g_acquire_cred_with_pw.c @@ -335,7 +335,6 @@ gss_add_cred_with_password(minor_status, input_cred_handle, gss_name_t internal_name = GSS_C_NO_NAME; gss_name_t allocated_name = GSS_C_NO_NAME; gss_mechanism mech; - gss_mechanism_ext mech_ext; gss_cred_id_t cred = NULL; gss_OID new_mechs_array = NULL; gss_cred_id_t * new_cred_array = NULL; @@ -359,9 +358,7 @@ gss_add_cred_with_password(minor_status, input_cred_handle, mech = gssint_get_mechanism(desired_mech); if (!mech) return GSS_S_BAD_MECH; - - mech_ext = gssint_get_mechanism_ext(desired_mech); - if (!mech_ext || !mech_ext->gssspi_acquire_cred_with_password) + if (!mech->gssspi_acquire_cred_with_password) return GSS_S_UNAVAILABLE; if (input_cred_handle == GSS_C_NO_CREDENTIAL) { @@ -412,15 +409,15 @@ gss_add_cred_with_password(minor_status, input_cred_handle, if (status != GSS_S_COMPLETE) goto errout; - status = mech_ext->gssspi_acquire_cred_with_password(minor_status, - internal_name, - password, - time_req, - target_mechs, - cred_usage, - &cred, - NULL, - &time_rec); + status = mech->gssspi_acquire_cred_with_password(minor_status, + internal_name, + password, + time_req, + target_mechs, + cred_usage, + &cred, + NULL, + &time_rec); if (status != GSS_S_COMPLETE) { map_error(minor_status, mech); goto errout; diff --git a/src/lib/gssapi/mechglue/g_initialize.c b/src/lib/gssapi/mechglue/g_initialize.c index ea7174fab9..abba914da4 100644 --- a/src/lib/gssapi/mechglue/g_initialize.c +++ b/src/lib/gssapi/mechglue/g_initialize.c @@ -581,10 +581,6 @@ releaseMechInfo(gss_mech_info *pCf) memset(cf->mech, 0, sizeof(*cf->mech)); free(cf->mech); } - if (cf->mech_ext != NULL && cf->freeMech) { - memset(cf->mech_ext, 0, sizeof(*cf->mech_ext)); - free(cf->mech_ext); - } if (cf->dl_handle != NULL) krb5int_close_plugin(cf->dl_handle); @@ -623,16 +619,6 @@ gssint_register_mechinfo(gss_mech_info template) new_cf->freeMech = 1; new_cf->next = NULL; - if (template->mech_ext != NULL) { - new_cf->mech_ext = (gss_mechanism_ext)calloc(1, - sizeof(struct gss_config_ext)); - if (new_cf->mech_ext == NULL) { - releaseMechInfo(&new_cf); - return ENOMEM; - } - *new_cf->mech_ext = *template->mech_ext; - } - if (template->kmodName != NULL) { new_cf->kmodName = strdup(template->kmodName); if (new_cf->kmodName == NULL) { @@ -784,6 +770,7 @@ build_dynamicMech(void *dl, const gss_OID mech_type) GSS_ADD_DYNAMIC_METHOD_NOLOOP(dl, mech, gss_inquire_mech_for_saslname); /* RFC 5587 */ GSS_ADD_DYNAMIC_METHOD_NOLOOP(dl, mech, gss_inquire_attrs_for_mech); + GSS_ADD_DYNAMIC_METHOD(dl, mech, gssspi_acquire_cred_with_password); assert(mech_type != GSS_C_NO_OID); @@ -792,21 +779,6 @@ build_dynamicMech(void *dl, const gss_OID mech_type) return mech; } -static gss_mechanism_ext -build_dynamicMechExt(void *dl, const gss_OID mech_type) -{ - gss_mechanism_ext mech_ext; - - mech_ext = (gss_mechanism_ext)calloc(1, sizeof(*mech_ext)); - if (mech_ext == NULL) { - return NULL; - } - - GSS_ADD_DYNAMIC_METHOD(dl, mech_ext, gssspi_acquire_cred_with_password); - - return mech_ext; -} - static void freeMechList(void) { @@ -905,55 +877,6 @@ gssint_get_mechanism(gss_const_OID oid) return (aMech->mech); } /* gssint_get_mechanism */ -gss_mechanism_ext -gssint_get_mechanism_ext(oid) -const gss_OID oid; -{ - gss_mech_info aMech; - - if (gssint_mechglue_initialize_library() != 0) - return (NULL); - - if (k5_mutex_lock(&g_mechListLock) != 0) - return NULL; - /* check if the mechanism is already loaded */ - if ((aMech = searchMechList(oid)) != NULL && aMech->mech_ext) { - (void) k5_mutex_unlock(&g_mechListLock); - return (aMech->mech_ext); - } - - /* - * might need to re-read the configuration file before loading - * the mechanism to ensure we have the latest info. - */ - updateMechList(); - - aMech = searchMechList(oid); - - /* is the mechanism present in the list ? */ - if (aMech == NULL || aMech->dl_handle == NULL) { - (void) k5_mutex_unlock(&g_mechListLock); - return ((gss_mechanism_ext)NULL); - } - - /* has another thread loaded the mech */ - if (aMech->mech_ext) { - (void) k5_mutex_unlock(&g_mechListLock); - return (aMech->mech_ext); - } - - /* Try dynamic dispatch table */ - aMech->mech_ext = build_dynamicMechExt(aMech->dl_handle, - aMech->mech_type); - if (aMech->mech_ext == NULL) { - (void) k5_mutex_unlock(&g_mechListLock); - return ((gss_mechanism_ext)NULL); - } - - (void) k5_mutex_unlock(&g_mechListLock); - return (aMech->mech_ext); -} /* gssint_get_mechanism_ext */ - /* * this routine is used for searching the list of mechanism data. * diff --git a/src/lib/gssapi/mechglue/mglueP.h b/src/lib/gssapi/mechglue/mglueP.h index 9e87b39bc4..17a9fbbda8 100644 --- a/src/lib/gssapi/mechglue/mglueP.h +++ b/src/lib/gssapi/mechglue/mglueP.h @@ -64,18 +64,6 @@ typedef struct gss_cred_id_struct { gss_cred_id_t *cred_array; } gss_union_cred_desc, *gss_union_cred_t; -typedef OM_uint32 (KRB5_CALLCONV *gss_acquire_cred_with_password_sfct)( - OM_uint32 *, /* minor_status */ - const gss_name_t, /* desired_name */ - const gss_buffer_t, /* password */ - OM_uint32, /* time_req */ - const gss_OID_set, /* desired_mechs */ - int, /* cred_usage */ - gss_cred_id_t *, /* output_cred_handle */ - gss_OID_set *, /* actual_mechs */ - OM_uint32 * /* time_rec */ - /* */); - /* * Rudimentary pointer validation macro to check whether the * "loopback" field of an opaque struct points back to itself. This @@ -633,12 +621,20 @@ typedef struct gss_config { gss_cred_usage_t * /* cred_usage_stored */ /* */); -} *gss_mechanism; + OM_uint32 (KRB5_CALLCONV *gssspi_acquire_cred_with_password) + ( + OM_uint32 *, /* minor_status */ + const gss_name_t, /* desired_name */ + const gss_buffer_t, /* password */ + OM_uint32, /* time_req */ + const gss_OID_set, /* desired_mechs */ + int, /* cred_usage */ + gss_cred_id_t *, /* output_cred_handle */ + gss_OID_set *, /* actual_mechs */ + OM_uint32 * /* time_rec */ + /* */); -/* This structure MUST NOT be used by any code outside libgss */ -typedef struct gss_config_ext { - gss_acquire_cred_with_password_sfct gssspi_acquire_cred_with_password; -} *gss_mechanism_ext; +} *gss_mechanism; /* * In the user space we use a wrapper structure to encompass the @@ -655,7 +651,6 @@ typedef struct gss_mech_config { void *dl_handle; /* RTLD object handle for the mech */ gss_OID mech_type; /* mechanism oid */ gss_mechanism mech; /* mechanism initialization struct */ - gss_mechanism_ext mech_ext; /* extensions */ int priority; /* mechanism preference order */ int freeMech; /* free mech table */ struct gss_mech_config *next; /* next element in the list */ @@ -670,7 +665,6 @@ void gssint_mechglue_fini(void); #endif gss_mechanism gssint_get_mechanism (gss_const_OID); -gss_mechanism_ext gssint_get_mechanism_ext(const gss_OID); OM_uint32 gssint_get_mech_type (gss_OID, gss_buffer_t); char *gssint_get_kmodName(const gss_OID); char *gssint_get_modOptions(const gss_OID); diff --git a/src/lib/gssapi/spnego/spnego_mech.c b/src/lib/gssapi/spnego/spnego_mech.c index 0038043b77..c5c995b999 100644 --- a/src/lib/gssapi/spnego/spnego_mech.c +++ b/src/lib/gssapi/spnego/spnego_mech.c @@ -276,10 +276,6 @@ static struct gss_config spnego_mechanism = spnego_gss_inquire_attrs_for_mech, spnego_gss_acquire_cred_from, NULL, /* gss_store_cred_into */ -}; - -static struct gss_config_ext spnego_mechanism_ext = -{ spnego_gss_acquire_cred_with_password }; @@ -292,7 +288,6 @@ static int gss_spnegomechglue_init(void) memset(&mech_spnego, 0, sizeof(mech_spnego)); mech_spnego.mech = &spnego_mechanism; - mech_spnego.mech_ext = &spnego_mechanism_ext; mech_spnego.mechNameStr = "spnego"; mech_spnego.mech_type = GSS_C_NO_OID;