X-Git-Url: http://www.project-moonshot.org/gitweb/?p=mech_eap.git;a=blobdiff_plain;f=mech_eap%2Futil_attr.cpp;h=1931efedec1c08875b18e1fc827e96dcc505b601;hp=d24615d3e65f7076c4b2d7499ad5129fa5354b4a;hb=HEAD;hpb=8e3e9cccdc3251abeb806110530564c9f576be5b diff --git a/mech_eap/util_attr.cpp b/mech_eap/util_attr.cpp index d24615d..1931efe 100644 --- a/mech_eap/util_attr.cpp +++ b/mech_eap/util_attr.cpp @@ -50,28 +50,36 @@ GSSEAP_ONCE_CALLBACK(gssEapAttrProvidersInitInternal) { OM_uint32 major, minor; - assert(gssEapAttrProvidersInitStatus == GSS_S_UNAVAILABLE); + GSSEAP_ASSERT(gssEapAttrProvidersInitStatus == GSS_S_UNAVAILABLE); + + json_set_alloc_funcs(GSSEAP_MALLOC, GSSEAP_FREE); major = gssEapRadiusAttrProviderInit(&minor); if (GSS_ERROR(major)) goto cleanup; -#ifdef HAVE_OPENSAML - major = gssEapSamlAttrProvidersInit(&minor); - if (GSS_ERROR(major)) - goto cleanup; -#endif #ifdef HAVE_SHIBRESOLVER /* Allow Shibboleth initialization failure to be non-fatal */ gssEapLocalAttrProviderInit(&minor); #endif +#ifdef HAVE_OPENSAML + wpa_printf(MSG_INFO, "### gssEapAttrProvidersInitInternal(): Calling gssEapSamlAttrProvidersInit()"); + major = gssEapSamlAttrProvidersInit(&minor); + if (GSS_ERROR(major)) { + wpa_printf(MSG_ERROR, "### gssEapAttrProvidersInitInternal(): Error returned from gssEapSamlAttrProvidersInit; major code is %08X; minor is %08X", major, minor); + goto cleanup; + } +#else + wpa_printf(MSG_INFO, "### gssEapAttrProvidersInitInternal(): Don't have OpenSAML; not calling gssEapSamlAttrProvidersInit()"); +#endif cleanup: #ifdef GSSEAP_DEBUG - assert(major == GSS_S_COMPLETE); + GSSEAP_ASSERT(major == GSS_S_COMPLETE); #endif + wpa_printf(MSG_INFO, "### gssEapAttrProvidersInitInternal(): Setting gssEapAttrProvidersInitStatus to %08X", major); gssEapAttrProvidersInitStatus = major; GSSEAP_ONCE_LEAVE; @@ -88,24 +96,38 @@ gssEapAttrProvidersInit(OM_uint32 *minor) return gssEapAttrProvidersInitStatus; } -OM_uint32 -gssEapAttrProvidersFinalize(OM_uint32 *minor) -{ - if (gssEapAttrProvidersInitStatus == GSS_S_COMPLETE) { -#ifdef HAVE_SHIBRESOLVER - gssEapLocalAttrProviderFinalize(minor); -#endif + +namespace { + + class finalize_class { + public: + + finalize_class() { + wpa_printf(MSG_INFO, "### finalize_class::finalize_class(): Constructing"); + } + + ~finalize_class() + { + OM_uint32 minor = 0; + + wpa_printf(MSG_INFO, "### ~finalize_class::~finalize_class() : initStatus=%08x", gssEapAttrProvidersInitStatus); + + if (gssEapAttrProvidersInitStatus == GSS_S_COMPLETE) { + wpa_printf(MSG_INFO, "### ~finalize_class::~finalize_class() : really finalizing"); + #ifdef HAVE_OPENSAML - gssEapSamlAttrProvidersFinalize(minor); + gssEapSamlAttrProvidersFinalize(&minor); #endif - gssEapRadiusAttrProviderFinalize(minor); + gssEapRadiusAttrProviderFinalize(&minor); - gssEapAttrProvidersInitStatus = GSS_S_UNAVAILABLE; - } - - return GSS_S_COMPLETE; + gssEapAttrProvidersInitStatus = GSS_S_UNAVAILABLE; + } + } + } finalizer; } + + static gss_eap_attr_create_provider gssEapAttrFactories[ATTR_TYPE_MAX + 1]; /* @@ -115,9 +137,9 @@ void gss_eap_attr_ctx::registerProvider(unsigned int type, gss_eap_attr_create_provider factory) { - assert(type <= ATTR_TYPE_MAX); + GSSEAP_ASSERT(type <= ATTR_TYPE_MAX); - assert(gssEapAttrFactories[type] == NULL); + GSSEAP_ASSERT(gssEapAttrFactories[type] == NULL); gssEapAttrFactories[type] = factory; } @@ -128,7 +150,7 @@ gss_eap_attr_ctx::registerProvider(unsigned int type, void gss_eap_attr_ctx::unregisterProvider(unsigned int type) { - assert(type <= ATTR_TYPE_MAX); + GSSEAP_ASSERT(type <= ATTR_TYPE_MAX); gssEapAttrFactories[type] = NULL; } @@ -416,7 +438,7 @@ gss_eap_attr_ctx::~gss_eap_attr_ctx(void) gss_eap_attr_provider * gss_eap_attr_ctx::getProvider(unsigned int type) const { - assert(type >= ATTR_TYPE_MIN && type <= ATTR_TYPE_MAX); + GSSEAP_ASSERT(type >= ATTR_TYPE_MIN && type <= ATTR_TYPE_MAX); return m_providers[type]; } @@ -714,7 +736,7 @@ gss_eap_attr_ctx::mapException(OM_uint32 *minor, std::exception &e) const } cleanup: - assert(GSS_ERROR(major)); + GSSEAP_ASSERT(GSS_ERROR(major)); return major; } @@ -978,7 +1000,7 @@ gssEapSetNameAttribute(OM_uint32 *minor, OM_uint32 gssEapExportAttrContext(OM_uint32 *minor, - gss_name_t name, + gss_const_name_t name, gss_buffer_t buffer) { if (name->attrCtx == NULL) { @@ -1008,7 +1030,7 @@ gssEapImportAttrContext(OM_uint32 *minor, gss_eap_attr_ctx *ctx = NULL; OM_uint32 major = GSS_S_FAILURE; - assert(name->attrCtx == NULL); + GSSEAP_ASSERT(name->attrCtx == NULL); if (GSS_ERROR(gssEapAttrProvidersInit(minor))) return GSS_S_UNAVAILABLE; @@ -1032,7 +1054,7 @@ gssEapImportAttrContext(OM_uint32 *minor, major = ctx->mapException(minor, e); } - assert(major == GSS_S_COMPLETE || name->attrCtx == NULL); + GSSEAP_ASSERT(major == GSS_S_COMPLETE || name->attrCtx == NULL); if (GSS_ERROR(major)) delete ctx; @@ -1042,13 +1064,13 @@ gssEapImportAttrContext(OM_uint32 *minor, OM_uint32 gssEapDuplicateAttrContext(OM_uint32 *minor, - gss_name_t in, + gss_const_name_t in, gss_name_t out) { gss_eap_attr_ctx *ctx = NULL; OM_uint32 major = GSS_S_FAILURE; - assert(out->attrCtx == NULL); + GSSEAP_ASSERT(out->attrCtx == NULL); if (in->attrCtx == NULL) { *minor = 0; @@ -1073,7 +1095,7 @@ gssEapDuplicateAttrContext(OM_uint32 *minor, major = in->attrCtx->mapException(minor, e); } - assert(major == GSS_S_COMPLETE || out->attrCtx == NULL); + GSSEAP_ASSERT(major == GSS_S_COMPLETE || out->attrCtx == NULL); if (GSS_ERROR(major)) delete ctx; @@ -1155,7 +1177,7 @@ gssEapCreateAttrContext(OM_uint32 *minor, gss_eap_attr_ctx *ctx = NULL; OM_uint32 major; - assert(gssCtx != GSS_C_NO_CONTEXT); + GSSEAP_ASSERT(gssCtx != GSS_C_NO_CONTEXT); *pAttrContext = NULL;