X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=mech_eap%2Futil_attr.cpp;h=1931efedec1c08875b18e1fc827e96dcc505b601;hb=e741515228135ff735175923eb0ec09a817ee4e4;hp=01c3135f73501092cb0130da792e75ad37ffe140;hpb=5d2cc0917c19bdb6196f060cac3af9f175b295c8;p=mech_eap.git diff --git a/mech_eap/util_attr.cpp b/mech_eap/util_attr.cpp index 01c3135..1931efe 100644 --- a/mech_eap/util_attr.cpp +++ b/mech_eap/util_attr.cpp @@ -46,30 +46,43 @@ static GSSEAP_THREAD_ONCE gssEapAttrProvidersInitOnce = GSSEAP_ONCE_INITIALIZER; static OM_uint32 gssEapAttrProvidersInitStatus = GSS_S_UNAVAILABLE; -static void -gssEapAttrProvidersInitInternal(void) +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; - major = gssEapSamlAttrProvidersInit(&minor); - if (GSS_ERROR(major)) - goto cleanup; +#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; } static OM_uint32 @@ -83,24 +96,38 @@ gssEapAttrProvidersInit(OM_uint32 *minor) return gssEapAttrProvidersInitStatus; } -OM_uint32 -gssEapAttrProvidersFinalize(OM_uint32 *minor) -{ - OM_uint32 major = GSS_S_COMPLETE; - if (gssEapAttrProvidersInitStatus == GSS_S_COMPLETE) { - major = gssEapLocalAttrProviderFinalize(minor); - if (major == GSS_S_COMPLETE) - major = gssEapSamlAttrProvidersFinalize(minor); - if (major == GSS_S_COMPLETE) - major = gssEapRadiusAttrProviderFinalize(minor); +namespace { - gssEapAttrProvidersInitStatus = GSS_S_UNAVAILABLE; - } + class finalize_class { + public: - return major; + 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); +#endif + gssEapRadiusAttrProviderFinalize(&minor); + + gssEapAttrProvidersInitStatus = GSS_S_UNAVAILABLE; + } + } + } finalizer; } + + static gss_eap_attr_create_provider gssEapAttrFactories[ATTR_TYPE_MAX + 1]; /* @@ -110,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; } @@ -123,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; } @@ -411,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]; } @@ -709,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; } @@ -973,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) { @@ -1003,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; @@ -1027,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; @@ -1037,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; @@ -1068,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; @@ -1150,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;