From: cantor Date: Sat, 20 Oct 2007 04:03:34 +0000 (+0000) Subject: Bypass catch all handlers (upport from branch). X-Git-Tag: 2.4~710 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fsp.git;a=commitdiff_plain;h=fa2725961500a483a5932dc4427f4e285def8403 Bypass catch all handlers (upport from branch). git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2543 cb58f699-b61c-0410-a6fe-9272a202ed29 --- diff --git a/apache/mod_apache.cpp b/apache/mod_apache.cpp index 0ab5651..0cfbbf4 100644 --- a/apache/mod_apache.cpp +++ b/apache/mod_apache.cpp @@ -90,6 +90,7 @@ namespace { SPConfig* g_Config = NULL; string g_unsetHeaderValue; bool g_checkSpoofing = true; + bool g_catchAll = false; static const char* g_UserDataKey = "_shib_check_user_"; static const XMLCh path[] = UNICODE_LITERAL_4(p,a,t,h); static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e); @@ -565,12 +566,13 @@ extern "C" int shib_check_user(request_rec* r) ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user threw an exception: %s", e.what()); return SERVER_ERROR; } -#ifndef _DEBUG catch (...) { - ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user threw an uncaught exception!"); - return SERVER_ERROR; + if (g_catchAll) { + ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_check_user threw an uncaught exception!"); + return SERVER_ERROR; + } + throw; } -#endif } extern "C" int shib_handler(request_rec* r) @@ -610,12 +612,13 @@ extern "C" int shib_handler(request_rec* r) ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler threw an exception: %s", e.what()); return SERVER_ERROR; } -#ifndef _DEBUG catch (...) { - ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler threw an uncaught exception!"); - return SERVER_ERROR; + if (g_catchAll) { + ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_handler threw an uncaught exception!"); + return SERVER_ERROR; + } + throw; } -#endif } /* @@ -648,12 +651,13 @@ extern "C" int shib_auth_checker(request_rec* r) ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker threw an exception: %s", e.what()); return SERVER_ERROR; } -#ifndef _DEBUG catch (...) { - ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker threw an uncaught exception!"); - return SERVER_ERROR; + if (g_catchAll) { + ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, SH_AP_R(r), "shib_auth_checker threw an uncaught exception!"); + return SERVER_ERROR; + } + throw; } -#endif } // Access control plugin that enforces htaccess rules @@ -1238,9 +1242,10 @@ extern "C" void shib_child_init(apr_pool_t* p, server_rec* s) pair unsetValue=props->getString("unsetHeaderValue"); if (unsetValue.first) g_unsetHeaderValue = unsetValue.second; - pair checkSpoofing=props->getBool("checkSpoofing"); - if (checkSpoofing.first && !checkSpoofing.second) - g_checkSpoofing = false; + pair flag=props->getBool("checkSpoofing"); + g_checkSpoofing = !flag.first || flag.second; + flag=props->getBool("catchAll"); + g_catchAll = flag.first && flag.second; } // Set the cleanup handler diff --git a/apache/mod_shib13.vcproj b/apache/mod_shib13.vcproj index ef3c30f..9989077 100644 --- a/apache/mod_shib13.vcproj +++ b/apache/mod_shib13.vcproj @@ -54,10 +54,6 @@ RuntimeLibrary="2" EnableFunctionLevelLinking="true" RuntimeTypeInfo="true" - PrecompiledHeaderFile=".\Release/mod_shib13.pch" - AssemblerListingLocation=".\Release/" - ObjectFile=".\Release/" - ProgramDataBaseFileName=".\Release/" WarningLevel="3" SuppressStartupBanner="true" Detect64BitPortabilityProblems="true" @@ -149,10 +145,6 @@ BasicRuntimeChecks="3" RuntimeLibrary="3" RuntimeTypeInfo="true" - PrecompiledHeaderFile=".\Debug/mod_shib13.pch" - AssemblerListingLocation=".\Debug/" - ObjectFile=".\Debug/" - ProgramDataBaseFileName=".\Debug/" BrowseInformation="1" WarningLevel="3" SuppressStartupBanner="true" diff --git a/apache/mod_shib20.vcproj b/apache/mod_shib20.vcproj index 84bb1fe..149615d 100644 --- a/apache/mod_shib20.vcproj +++ b/apache/mod_shib20.vcproj @@ -54,10 +54,6 @@ RuntimeLibrary="2" EnableFunctionLevelLinking="true" RuntimeTypeInfo="true" - PrecompiledHeaderFile=".\mod_shib20___Win32_Release/mod_shib20.pch" - AssemblerListingLocation=".\mod_shib20___Win32_Release/" - ObjectFile=".\mod_shib20___Win32_Release/" - ProgramDataBaseFileName=".\mod_shib20___Win32_Release/" WarningLevel="3" SuppressStartupBanner="true" Detect64BitPortabilityProblems="true" @@ -149,10 +145,6 @@ BasicRuntimeChecks="3" RuntimeLibrary="3" RuntimeTypeInfo="true" - PrecompiledHeaderFile=".\mod_shib20___Win32_Debug/mod_shib20.pch" - AssemblerListingLocation=".\mod_shib20___Win32_Debug/" - ObjectFile=".\mod_shib20___Win32_Debug/" - ProgramDataBaseFileName=".\mod_shib20___Win32_Debug/" BrowseInformation="1" WarningLevel="3" SuppressStartupBanner="true" diff --git a/apache/mod_shib22.vcproj b/apache/mod_shib22.vcproj index ade6366..c08f802 100644 --- a/apache/mod_shib22.vcproj +++ b/apache/mod_shib22.vcproj @@ -54,10 +54,6 @@ RuntimeLibrary="2" EnableFunctionLevelLinking="true" RuntimeTypeInfo="true" - PrecompiledHeaderFile=".\mod_shib22___Win32_Release/mod_shib22.pch" - AssemblerListingLocation=".\mod_shib22___Win32_Release/" - ObjectFile=".\mod_shib22___Win32_Release/" - ProgramDataBaseFileName=".\mod_shib22___Win32_Release/" WarningLevel="3" SuppressStartupBanner="true" Detect64BitPortabilityProblems="true" @@ -151,10 +147,6 @@ BasicRuntimeChecks="3" RuntimeLibrary="3" RuntimeTypeInfo="true" - PrecompiledHeaderFile=".\mod_shib22___Win32_Debug/mod_shib22.pch" - AssemblerListingLocation=".\mod_shib22___Win32_Debug/" - ObjectFile=".\mod_shib22___Win32_Debug/" - ProgramDataBaseFileName=".\mod_shib22___Win32_Debug/" BrowseInformation="1" WarningLevel="3" SuppressStartupBanner="true" diff --git a/isapi_shib/isapi_shib.cpp b/isapi_shib/isapi_shib.cpp index 4465e4f..8099110 100644 --- a/isapi_shib/isapi_shib.cpp +++ b/isapi_shib/isapi_shib.cpp @@ -54,7 +54,7 @@ using namespace std; // globals namespace { static const XMLCh path[] = UNICODE_LITERAL_4(p,a,t,h); - static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e); + static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e); static const XMLCh name[] = UNICODE_LITERAL_4(n,a,m,e); static const XMLCh port[] = UNICODE_LITERAL_4(p,o,r,t); static const XMLCh sslport[] = UNICODE_LITERAL_7(s,s,l,p,o,r,t); @@ -96,6 +96,7 @@ namespace { bool g_bNormalizeRequest = true; string g_unsetHeaderValue; bool g_checkSpoofing = true; + bool g_catchAll = false; vector g_NoCerts; } @@ -201,9 +202,11 @@ extern "C" BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pVer) pair unsetValue=props->getString("unsetHeaderValue"); if (unsetValue.first) g_unsetHeaderValue = unsetValue.second; - pair checkSpoofing=props->getBool("checkSpoofing"); - if (checkSpoofing.first && !checkSpoofing.second) - g_checkSpoofing = false; + pair flag=props->getBool("checkSpoofing"); + g_checkSpoofing = !flag.first || flag.second; + flag=props->getBool("catchAll"); + g_catchAll = flag.first && flag.second; + const DOMElement* impl=XMLHelper::getFirstChildElement(props->getElement(),Implementation); if (impl && (impl=XMLHelper::getFirstChildElement(impl,ISAPI))) { const XMLCh* flag=impl->getAttributeNS(NULL,normalizeRequest); @@ -597,11 +600,11 @@ extern "C" DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificat LogEvent(NULL, EVENTLOG_ERROR_TYPE, 2100, NULL, e.what()); return WriteClientError(pfc,"Shibboleth Filter caught an exception, check Event Log for details."); } -#ifndef _DEBUG catch(...) { - return WriteClientError(pfc,"Shibboleth Filter caught an unknown exception."); + if (g_catchAll) + return WriteClientError(pfc,"Shibboleth Filter caught an unknown exception."); + throw; } -#endif return WriteClientError(pfc,"Shibboleth Filter reached unreachable code, save my walrus!"); } @@ -914,11 +917,11 @@ extern "C" DWORD WINAPI HttpExtensionProc(LPEXTENSION_CONTROL_BLOCK lpECB) LogEvent(NULL, EVENTLOG_ERROR_TYPE, 2100, NULL, e.what()); return WriteClientError(lpECB,"Shibboleth Extension caught an exception, check Event Log for details."); } -#ifndef _DEBUG catch(...) { - return WriteClientError(lpECB,"Shibboleth Extension caught an unknown exception."); + if (g_catchAll) + return WriteClientError(lpECB,"Shibboleth Extension caught an unknown exception."); + throw; } -#endif // If we get here we've got an error. return HSE_STATUS_ERROR; diff --git a/isapi_shib/isapi_shib.vcproj b/isapi_shib/isapi_shib.vcproj index 532cd18..1908d9b 100644 --- a/isapi_shib/isapi_shib.vcproj +++ b/isapi_shib/isapi_shib.vcproj @@ -54,10 +54,6 @@ RuntimeLibrary="2" EnableFunctionLevelLinking="true" RuntimeTypeInfo="true" - PrecompiledHeaderFile=".\Release/isapi_shib.pch" - AssemblerListingLocation=".\Release/" - ObjectFile=".\Release/" - ProgramDataBaseFileName=".\Release/" BrowseInformation="1" WarningLevel="3" SuppressStartupBanner="true" @@ -150,10 +146,6 @@ BasicRuntimeChecks="3" RuntimeLibrary="3" RuntimeTypeInfo="true" - PrecompiledHeaderFile=".\Debug/isapi_shib.pch" - AssemblerListingLocation=".\Debug/" - ObjectFile=".\Debug/" - ProgramDataBaseFileName=".\Debug/" BrowseInformation="1" WarningLevel="3" SuppressStartupBanner="true" diff --git a/nsapi_shib/nsapi_shib.cpp b/nsapi_shib/nsapi_shib.cpp index adf0806..f20ed7d 100644 --- a/nsapi_shib/nsapi_shib.cpp +++ b/nsapi_shib/nsapi_shib.cpp @@ -76,6 +76,7 @@ namespace { string g_ServerScheme; string g_unsetHeaderValue; bool g_checkSpoofing = true; + bool g_catchAll = false; static const XMLCh path[] = UNICODE_LITERAL_4(p,a,t,h); static const XMLCh validate[] = UNICODE_LITERAL_8(v,a,l,i,d,a,t,e); @@ -172,9 +173,10 @@ extern "C" NSAPI_PUBLIC int nsapi_shib_init(pblock* pb, ::Session* sn, Request* pair unsetValue=props->getString("unsetHeaderValue"); if (unsetValue.first) g_unsetHeaderValue = unsetValue.second; - pair checkSpoofing=props->getBool("checkSpoofing"); - if (checkSpoofing.first && !checkSpoofing.second) - g_checkSpoofing = false; + pair flag=props->getBool("checkSpoofing"); + g_checkSpoofing = !flag.first || flag.second; + flag=props->getBool("catchAll"); + g_catchAll = flag.first && flag.second; } return REQ_PROCEED; } @@ -419,11 +421,11 @@ extern "C" NSAPI_PUBLIC int nsapi_shib(pblock* pb, ::Session* sn, Request* rq) log_error(LOG_FAILURE,FUNC,sn,rq,const_cast(e.what())); return WriteClientError(sn, rq, FUNC, "Shibboleth module threw an exception, see web server log for error."); } -#ifndef _DEBUG catch (...) { - return WriteClientError(sn, rq, FUNC, "Shibboleth module threw an uncaught exception."); + if (g_catchAll) + return WriteClientError(sn, rq, FUNC, "Shibboleth module threw an uncaught exception."); + throw; } -#endif } @@ -447,11 +449,11 @@ extern "C" NSAPI_PUBLIC int shib_handler(pblock* pb, ::Session* sn, Request* rq) log_error(LOG_FAILURE,FUNC,sn,rq,const_cast(e.what())); return WriteClientError(sn, rq, FUNC, "Shibboleth handler threw an exception, see web server log for error."); } -#ifndef _DEBUG catch (...) { - return WriteClientError(sn, rq, FUNC, "Shibboleth handler threw an unknown exception."); + if (g_catchAll) + return WriteClientError(sn, rq, FUNC, "Shibboleth handler threw an unknown exception."); + throw; } -#endif } diff --git a/nsapi_shib/nsapi_shib.vcproj b/nsapi_shib/nsapi_shib.vcproj index 180e270..7701483 100644 --- a/nsapi_shib/nsapi_shib.vcproj +++ b/nsapi_shib/nsapi_shib.vcproj @@ -54,10 +54,6 @@ RuntimeLibrary="2" EnableFunctionLevelLinking="true" RuntimeTypeInfo="true" - PrecompiledHeaderFile=".\Release/nsapi_shib.pch" - AssemblerListingLocation=".\Release/" - ObjectFile=".\Release/" - ProgramDataBaseFileName=".\Release/" WarningLevel="3" SuppressStartupBanner="true" Detect64BitPortabilityProblems="true" @@ -148,10 +144,6 @@ BasicRuntimeChecks="3" RuntimeLibrary="3" RuntimeTypeInfo="true" - PrecompiledHeaderFile=".\Debug/nsapi_shib.pch" - AssemblerListingLocation=".\Debug/" - ObjectFile=".\Debug/" - ProgramDataBaseFileName=".\Debug/" BrowseInformation="1" WarningLevel="3" SuppressStartupBanner="true" diff --git a/schemas/shibboleth-2.0-native-sp-config.xsd b/schemas/shibboleth-2.0-native-sp-config.xsd index b8450d4..5352c19 100644 --- a/schemas/shibboleth-2.0-native-sp-config.xsd +++ b/schemas/shibboleth-2.0-native-sp-config.xsd @@ -207,6 +207,7 @@ +