Bypass catch all handlers (upport from branch).
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Sat, 20 Oct 2007 04:03:34 +0000 (04:03 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Sat, 20 Oct 2007 04:03:34 +0000 (04:03 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2543 cb58f699-b61c-0410-a6fe-9272a202ed29

apache/mod_apache.cpp
apache/mod_shib13.vcproj
apache/mod_shib20.vcproj
apache/mod_shib22.vcproj
isapi_shib/isapi_shib.cpp
isapi_shib/isapi_shib.vcproj
nsapi_shib/nsapi_shib.cpp
nsapi_shib/nsapi_shib.vcproj
schemas/shibboleth-2.0-native-sp-config.xsd

index 0ab5651..0cfbbf4 100644 (file)
@@ -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<bool,const char*> unsetValue=props->getString("unsetHeaderValue");
         if (unsetValue.first)
             g_unsetHeaderValue = unsetValue.second;
-        pair<bool,bool> checkSpoofing=props->getBool("checkSpoofing");
-        if (checkSpoofing.first && !checkSpoofing.second)
-            g_checkSpoofing = false;
+        pair<bool,bool> flag=props->getBool("checkSpoofing");
+        g_checkSpoofing = !flag.first || flag.second;
+        flag=props->getBool("catchAll");
+        g_catchAll = flag.first && flag.second;
     }
 
     // Set the cleanup handler
index ef3c30f..9989077 100644 (file)
                                RuntimeLibrary="2"
                                EnableFunctionLevelLinking="true"
                                RuntimeTypeInfo="true"
-                               PrecompiledHeaderFile=".\Release/mod_shib13.pch"
-                               AssemblerListingLocation=".\Release/"
-                               ObjectFile=".\Release/"
-                               ProgramDataBaseFileName=".\Release/"
                                WarningLevel="3"
                                SuppressStartupBanner="true"
                                Detect64BitPortabilityProblems="true"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="3"
                                RuntimeTypeInfo="true"
-                               PrecompiledHeaderFile=".\Debug/mod_shib13.pch"
-                               AssemblerListingLocation=".\Debug/"
-                               ObjectFile=".\Debug/"
-                               ProgramDataBaseFileName=".\Debug/"
                                BrowseInformation="1"
                                WarningLevel="3"
                                SuppressStartupBanner="true"
index 84bb1fe..149615d 100644 (file)
                                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"
                                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"
index ade6366..c08f802 100644 (file)
                                RuntimeLibrary="2"\r
                                EnableFunctionLevelLinking="true"\r
                                RuntimeTypeInfo="true"\r
-                               PrecompiledHeaderFile=".\mod_shib22___Win32_Release/mod_shib22.pch"\r
-                               AssemblerListingLocation=".\mod_shib22___Win32_Release/"\r
-                               ObjectFile=".\mod_shib22___Win32_Release/"\r
-                               ProgramDataBaseFileName=".\mod_shib22___Win32_Release/"\r
                                WarningLevel="3"\r
                                SuppressStartupBanner="true"\r
                                Detect64BitPortabilityProblems="true"\r
                                BasicRuntimeChecks="3"\r
                                RuntimeLibrary="3"\r
                                RuntimeTypeInfo="true"\r
-                               PrecompiledHeaderFile=".\mod_shib22___Win32_Debug/mod_shib22.pch"\r
-                               AssemblerListingLocation=".\mod_shib22___Win32_Debug/"\r
-                               ObjectFile=".\mod_shib22___Win32_Debug/"\r
-                               ProgramDataBaseFileName=".\mod_shib22___Win32_Debug/"\r
                                BrowseInformation="1"\r
                                WarningLevel="3"\r
                                SuppressStartupBanner="true"\r
index 4465e4f..8099110 100644 (file)
@@ -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<string> g_NoCerts;
 }
 
@@ -201,9 +202,11 @@ extern "C" BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pVer)
         pair<bool,const char*> unsetValue=props->getString("unsetHeaderValue");
         if (unsetValue.first)
             g_unsetHeaderValue = unsetValue.second;
-        pair<bool,bool> checkSpoofing=props->getBool("checkSpoofing");
-        if (checkSpoofing.first && !checkSpoofing.second)
-            g_checkSpoofing = false;
+        pair<bool,bool> 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;
index 532cd18..1908d9b 100644 (file)
                                RuntimeLibrary="2"
                                EnableFunctionLevelLinking="true"
                                RuntimeTypeInfo="true"
-                               PrecompiledHeaderFile=".\Release/isapi_shib.pch"
-                               AssemblerListingLocation=".\Release/"
-                               ObjectFile=".\Release/"
-                               ProgramDataBaseFileName=".\Release/"
                                BrowseInformation="1"
                                WarningLevel="3"
                                SuppressStartupBanner="true"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="3"
                                RuntimeTypeInfo="true"
-                               PrecompiledHeaderFile=".\Debug/isapi_shib.pch"
-                               AssemblerListingLocation=".\Debug/"
-                               ObjectFile=".\Debug/"
-                               ProgramDataBaseFileName=".\Debug/"
                                BrowseInformation="1"
                                WarningLevel="3"
                                SuppressStartupBanner="true"
index adf0806..f20ed7d 100644 (file)
@@ -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<bool,const char*> unsetValue=props->getString("unsetHeaderValue");
         if (unsetValue.first)
             g_unsetHeaderValue = unsetValue.second;
-        pair<bool,bool> checkSpoofing=props->getBool("checkSpoofing");
-        if (checkSpoofing.first && !checkSpoofing.second)
-            g_checkSpoofing = false;
+        pair<bool,bool> 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<char*>(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<char*>(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
 }
 
 
index 180e270..7701483 100644 (file)
                                RuntimeLibrary="2"
                                EnableFunctionLevelLinking="true"
                                RuntimeTypeInfo="true"
-                               PrecompiledHeaderFile=".\Release/nsapi_shib.pch"
-                               AssemblerListingLocation=".\Release/"
-                               ObjectFile=".\Release/"
-                               ProgramDataBaseFileName=".\Release/"
                                WarningLevel="3"
                                SuppressStartupBanner="true"
                                Detect64BitPortabilityProblems="true"
                                BasicRuntimeChecks="3"
                                RuntimeLibrary="3"
                                RuntimeTypeInfo="true"
-                               PrecompiledHeaderFile=".\Debug/nsapi_shib.pch"
-                               AssemblerListingLocation=".\Debug/"
-                               ObjectFile=".\Debug/"
-                               ProgramDataBaseFileName=".\Debug/"
                                BrowseInformation="1"
                                WarningLevel="3"
                                SuppressStartupBanner="true"
index b8450d4..5352c19 100644 (file)
                        <attribute name="logger" type="anyURI"/>\r
                        <attribute name="unsetHeaderValue" type="string"/>\r
                        <attribute name="checkSpoofing" type="boolean"/>\r
+                   <attribute name="catchAll" type="boolean"/>\r
                        <anyAttribute namespace="##other" processContents="lax"/>\r
                </complexType>\r
        </element>\r