[cpp-sp] branch master updated: SSPCPP-794 - Change default logging for inproc half of SP

Scott Cantor cantor.2 at osu.edu
Wed Apr 18 15:52:16 EDT 2018


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=7c6b1ea2d7c89ebc6b6b5799f2850872d51f657e

The following commit(s) were added to refs/heads/master by this push:
       new  7c6b1ea   SSPCPP-794 - Change default logging for inproc half of SP
7c6b1ea is described below

commit 7c6b1ea2d7c89ebc6b6b5799f2850872d51f657e
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Apr 18 15:51:03 2018 -0400

    SSPCPP-794 - Change default logging for inproc half of SP
    
    https://issues.shibboleth.net/jira/browse/SSPCPP-794
    
    Retrofit shibd EventLog behavior on Windows.
    Untested installer changes to message DLL installation.
---
 Projects/vc15/Shibboleth.sln        |  1 +
 Projects/vc15/util/messages.vcxproj |  2 +-
 msi/WiX/ShibbolethSP-main-x64.wxs   | 28 +++-----------------------
 msi/WiX/ShibbolethSP-main-x86.wxs   | 28 +++-----------------------
 shibd/shibd_win32.cpp               | 40 +++++++++++++++++++------------------
 shibsp/base.h                       |  3 +++
 6 files changed, 32 insertions(+), 70 deletions(-)

diff --git a/Projects/vc15/Shibboleth.sln b/Projects/vc15/Shibboleth.sln
index 3ce86ed..dc15f61 100644
--- a/Projects/vc15/Shibboleth.sln
+++ b/Projects/vc15/Shibboleth.sln
@@ -75,6 +75,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{2543BC
 		..\..\configs\shibd.logger.in = ..\..\configs\shibd.logger.in
 		..\..\configs\sslError.html = ..\..\configs\sslError.html
 		..\..\configs\syslog.logger = ..\..\configs\syslog.logger
+		..\..\configs\win-native.logger = ..\..\configs\win-native.logger
 		..\..\configs\win-shibboleth3.xml = ..\..\configs\win-shibboleth3.xml
 	EndProjectSection
 EndProject
diff --git a/Projects/vc15/util/messages.vcxproj b/Projects/vc15/util/messages.vcxproj
index ba3cfb7..99fc724 100644
--- a/Projects/vc15/util/messages.vcxproj
+++ b/Projects/vc15/util/messages.vcxproj
@@ -201,4 +201,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/msi/WiX/ShibbolethSP-main-x64.wxs b/msi/WiX/ShibbolethSP-main-x64.wxs
index b00484a..4078412 100644
--- a/msi/WiX/ShibbolethSP-main-x64.wxs
+++ b/msi/WiX/ShibbolethSP-main-x64.wxs
@@ -186,35 +186,13 @@
       <!-- 
          We put the messages for IIS7 and Shibd in this module since all others are shared with x86
         -->
-      <Component Id="messageFile" Guid="{3FF89632-9F39-4B1B-AA3E-3AF6C8155B92}" Win64="yes" Directory="bin64">
-        <File Id="Messages" KeyPath="yes" Source="$(var.SPBuildDirectory)\cpp-sp\Build\$(var.MsVCVersion)\x64\Release\Messages.dll" />
+      <Component Id="messageFile" Guid="{3FF89632-9F39-4B1B-AA3E-3AF6C8155B92}" Win64="yes" Directory="lib64">
+        <File Id="Messages" KeyPath="yes" Source="$(var.SPBuildDirectory)\cpp-sp\Build\$(var.MsVCVersion)\x64\Release\messages.dll" />
         <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\EventLog\Shibboleth\Shibboleth Service Provider">
           <RegistryValue Name="CategoryCount" Type="integer" Value="8" />
           <RegistryValue Name="TypesSupported" Type="integer" Value="7" />
           <RegistryValue Name="CategoryMessageFile" Type="string" Value="[ProgramFilesFolder]Shibboleth\SP\lib\NTEventLogAppender.dll" />
-          <RegistryValue Name="EventMessageFile" Type="string" Value="[ProgramFilesFolder]Shibboleth\SP\lib\NTEventLogAppender.dll" />
-        </RegistryKey>
-        <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\services\eventlog\Application\Shibboleth Daemon">
-          <RegistryValue Name="CategoryCount" Type="integer" Value="2" />
-          <RegistryValue Name="TypesSupported" Type="integer" Value="15" />
-          <RegistryValue Name="CategoryMessageFile" Type="string" Value="[#Messages]" />
-          <RegistryValue Name="EventMessageFile" Type="string" Value="[#Messages]" />
-          <RegistryValue Name="ParameterMessageFile" Type="string" Value="[#Messages]" />
-        </RegistryKey>
-        <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\services\eventlog\Application\Shibboleth ISAPI Filter">
-          <RegistryValue Name="CategoryCount" Type="integer" Value="2" />
-          <RegistryValue Name="TypesSupported" Type="integer" Value="15" />
-          <RegistryValue Name="CategoryMessageFile" Type="string" Value="[#Messages]" />
-          <RegistryValue Name="EventMessageFile" Type="string" Value="[#Messages]" />
-          <RegistryValue Name="ParameterMessageFile" Type="string" Value="[#Messages]" />
-        </RegistryKey>
-      </Component>
-      <Component Id="messageIIS7" Guid="{1CC5CF4A-6203-4ab8-9743-4A79C95D30CE}" Win64="yes" Directory="bin64">
-        <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\services\eventlog\Application\Shibboleth NATIVE Filter">
-          <RegistryValue Name="CategoryCount" Type="integer" Value="2" />
-          <RegistryValue Name="TypesSupported" Type="integer" Value="15" />
-          <RegistryValue Name="CategoryMessageFile" Type="string" Value="[#Messages]" />
-          <RegistryValue Name="EventMessageFile" Type="string" Value="[#Messages]" />
+          <RegistryValue Name="EventMessageFile" Type="string" Value="[ProgramFilesFolder]Shibboleth\SP\lib\NTEventLogAppender.dll;[#Messages]" />
           <RegistryValue Name="ParameterMessageFile" Type="string" Value="[#Messages]" />
         </RegistryKey>
       </Component>
diff --git a/msi/WiX/ShibbolethSP-main-x86.wxs b/msi/WiX/ShibbolethSP-main-x86.wxs
index 3fbcefd..b2270e9 100644
--- a/msi/WiX/ShibbolethSP-main-x86.wxs
+++ b/msi/WiX/ShibbolethSP-main-x86.wxs
@@ -100,38 +100,16 @@
       <!--
          We put in the messages for Isapi and Shibd in this module since all others are shared with x64
         -->
-      <Component Id="messageFile" Guid="{7B81ACC5-B79C-426B-ACB8-346A52E5FF60}" Win64="no" Directory="bin">
-        <File Id="Messages" KeyPath="yes" Source="$(var.SPBuildDirectory)\cpp-sp\Build\$(var.MsVCVersion)\Release\Messages.dll" />
+      <Component Id="messageFile" Guid="{7B81ACC5-B79C-426B-ACB8-346A52E5FF60}" Win64="no" Directory="lib">
+        <File Id="Messages" KeyPath="yes" Source="$(var.SPBuildDirectory)\cpp-sp\Build\$(var.MsVCVersion)\Release\messages.dll" />
         <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\EventLog\Shibboleth\Shibboleth Service Provider">
           <RegistryValue Name="CategoryCount" Type="integer" Value="8" />
           <RegistryValue Name="TypesSupported" Type="integer" Value="7" />
           <RegistryValue Name="CategoryMessageFile" Type="string" Value="[ProgramFilesFolder]Shibboleth\SP\lib\NTEventLogAppender.dll" />
-          <RegistryValue Name="EventMessageFile" Type="string" Value="[ProgramFilesFolder]Shibboleth\SP\lib\NTEventLogAppender.dll" />
-        </RegistryKey>
-        <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\services\eventlog\Application\Shibboleth Daemon">
-          <RegistryValue Name="CategoryCount" Type="integer" Value="2" />
-          <RegistryValue Name="TypesSupported" Type="integer" Value="15" />
-          <RegistryValue Name="CategoryMessageFile" Type="string" Value="[#Messages]" />
-          <RegistryValue Name="EventMessageFile" Type="string" Value="[#Messages]" />
-          <RegistryValue Name="ParameterMessageFile" Type="string" Value="[#Messages]" />
-        </RegistryKey>
-        <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\services\eventlog\Application\Shibboleth ISAPI Filter">
-          <RegistryValue Name="CategoryCount" Type="integer" Value="2" />
-          <RegistryValue Name="TypesSupported" Type="integer" Value="15" />
-          <RegistryValue Name="CategoryMessageFile" Type="string" Value="[#Messages]" />
-          <RegistryValue Name="EventMessageFile" Type="string" Value="[#Messages]" />
+          <RegistryValue Name="EventMessageFile" Type="string" Value="[ProgramFilesFolder]Shibboleth\SP\lib\NTEventLogAppender.dll;[#Messages]" />
           <RegistryValue Name="ParameterMessageFile" Type="string" Value="[#Messages]" />
         </RegistryKey>
       </Component>
-      <Component Id="messageIIS7" Guid="{FDEB81BA-4935-49c2-84FE-E58F674F5FF3}" Win64="no" Directory="bin">
-        <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\services\eventlog\Application\Shibboleth NATIVE Filter">
-          <RegistryValue Name="CategoryCount" Type="integer" Value="2" />
-          <RegistryValue Name="TypesSupported" Type="integer" Value="15" />
-          <RegistryValue Name="CategoryMessageFile" Type="string" Value="[#Messages]" />
-          <RegistryValue Name="EventMessageFile" Type="string" Value="[#Messages]" />
-          <RegistryValue Name="ParameterMessageFile" Type="string" Value="[#Messages]" />
-        </RegistryKey>
-      </Component>      
 
       <Component Id="shibd.exe" Guid="{2476BB80-9384-4026-86F5-E1569A685187}" Directory="sbin">
         <File KeyPath="yes" Checksum="yes" Source="$(var.SPBuildDirectory)\cpp-sp\Build\$(var.MsVCVersion)\Release\shibd.exe" />
diff --git a/shibd/shibd_win32.cpp b/shibd/shibd_win32.cpp
index bb12c59..26fac6e 100644
--- a/shibd/shibd_win32.cpp
+++ b/shibd/shibd_win32.cpp
@@ -27,11 +27,15 @@
 #define _CRT_NONSTDC_NO_DEPRECATE 1
 #define _CRT_SECURE_NO_DEPRECATE 1
 
-#include <message.h>
 #include <shibsp/base.h>
+#include <xmltooling/logging.h>
+
+#include <message.h>
+
 #include <string>
 #include <windows.h>
 
+using namespace xmltooling::logging;
 using namespace std;
 
 extern bool shibd_shutdown;                    // signals shutdown to Unix side
@@ -60,16 +64,14 @@ VOID CmdRemoveService(LPCSTR);
 LPTSTR GetLastErrorText( LPSTR lpszBuf, DWORD dwSize );
 
 BOOL LogEvent(
-    LPCTSTR  lpUNCServerName,
-    WORD  wType,
-    DWORD  dwEventID,
-    PSID  lpUserSid,
-    LPCTSTR  message);
+    WORD wType,
+    Priority::PriorityLevel priority,
+    DWORD dwEventID,
+    LPCTSTR message);
 
 VOID ServiceStart(DWORD dwArgc, LPSTR *lpszArgv);
 VOID ServiceStop();
 BOOL ReportStatusToSCMgr(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint);
-void AddToMessageLog(LPSTR lpszMsg);
 
 BOOL WINAPI BreakHandler(DWORD dwCtrlType)
 {
@@ -159,7 +161,8 @@ int main(int argc, char *argv[])
         SetConsoleCtrlHandler(&BreakHandler,TRUE);
         if ((i=real_main(1))!=0)
         {
-            LogEvent(nullptr, EVENTLOG_ERROR_TYPE, SHIBD_STARTUP_FAILED, nullptr, "shibd startup failed, check shibd.log for further details");
+            LogEvent(EVENTLOG_ERROR_TYPE, Priority::FATAL, SHIBD_STARTUP_FAILED,
+                "shibd startup failed, check shibd.log for further details");
             return i;
         }
         return real_main(0);
@@ -200,7 +203,7 @@ int main(int argc, char *argv[])
     };
 
     if (!StartServiceCtrlDispatcher(dispatchTable))
-        LogEvent(nullptr, EVENTLOG_ERROR_TYPE, SHIBD_SERVICE_START_FAILED, nullptr, "StartServiceCtrlDispatcher failed.");
+        LogEvent(EVENTLOG_ERROR_TYPE, Priority::FATAL, SHIBD_SERVICE_START_FAILED, "SHIBD_SERVICE_START_FAILED");
     return 0;
 }
 
@@ -215,11 +218,11 @@ VOID ServiceStart (DWORD dwArgc, LPSTR *lpszArgv)
 
     if (real_main(1)!=0)
     {
-        LogEvent(nullptr, EVENTLOG_ERROR_TYPE, SHIBD_STARTUP_FAILED, nullptr, "shibd startup failed, check shibd.log for further details");
+        LogEvent(EVENTLOG_ERROR_TYPE, Priority::FATAL, SHIBD_STARTUP_FAILED, "SHIBD_STARTUP_FAILED");
         return;
     }
 
-    LogEvent(nullptr, EVENTLOG_INFORMATION_TYPE, SHIBD_SERVICE_STARTED, nullptr, "shibd started successfully.");
+    LogEvent(EVENTLOG_INFORMATION_TYPE, Priority::INFO, SHIBD_SERVICE_STARTED, "SHIBD_SERVICE_STARTED");
 
     if (!ReportStatusToSCMgr(SERVICE_RUNNING, NO_ERROR, 0))
         return;
@@ -236,7 +239,7 @@ VOID ServiceStart (DWORD dwArgc, LPSTR *lpszArgv)
 VOID ServiceStop()
 {
     if (!bConsole)
-        LogEvent(nullptr, EVENTLOG_INFORMATION_TYPE, SHIBD_SERVICE_STOPPING, nullptr, "shibd stopping...");
+        LogEvent(EVENTLOG_INFORMATION_TYPE, Priority::INFO, SHIBD_SERVICE_STOPPING, "SHIBD_SERVICE_STOPPING");
     shibd_shutdown=true;
 }
 
@@ -363,7 +366,7 @@ BOOL ReportStatusToSCMgr(DWORD dwCurrentState,
         // Report the status of the service to the service control manager.
         //
         if (!(fResult = SetServiceStatus(sshStatusHandle, &ssStatus)))
-            LogEvent(nullptr, EVENTLOG_ERROR_TYPE, SHIBD_SET_SERVICE_STATUS_FAILED, nullptr, "SetServiceStatus failed.");
+            LogEvent(EVENTLOG_ERROR_TYPE, Priority::ERROR, SHIBD_SET_SERVICE_STATUS_FAILED, "SHIBD_SET_SERVICE_STATUS_FAILED");
     }
     return fResult;
 }
@@ -546,16 +549,15 @@ LPTSTR GetLastErrorText( LPSTR lpszBuf, DWORD dwSize )
 }
 
 BOOL LogEvent(
-    LPCSTR  lpUNCServerName,
     WORD  wType,
+    Priority::PriorityLevel priority,
     DWORD  dwEventID,
-    PSID  lpUserSid,
     LPCSTR  message)
 {
     LPCSTR  messages[] = {message, nullptr};
-    DWORD gle = {GetLastError()};
+    DWORD gle = ::GetLastError();
     
-    HANDLE hElog = RegisterEventSource(lpUNCServerName, "Shibboleth Daemon");
-    BOOL res = ReportEvent(hElog, wType, CATEGORY_SHIBD, dwEventID, lpUserSid, 1, sizeof(DWORD), messages, &gle);
-    return (DeregisterEventSource(hElog) && res);
+    HANDLE hElog = ::RegisterEventSource(nullptr, SHIBSP_EVENTLOGSOURCE);
+    BOOL res = ::ReportEvent(hElog, wType, (priority / 100) + 1, dwEventID, nullptr, 1, sizeof(DWORD), messages, &gle);
+    return (::DeregisterEventSource(hElog) && res);
 }
diff --git a/shibsp/base.h b/shibsp/base.h
index cea76bd..c228678 100644
--- a/shibsp/base.h
+++ b/shibsp/base.h
@@ -102,6 +102,9 @@
 
 #ifdef WIN32
 
+/** Name of source to register with Windows Event Log. */
+#define SHIBSP_EVENTLOGSOURCE "Shibboleth Service Provider"
+
 /** Default catalog path on Windows. */
 # define SHIBSP_SCHEMAS "%PROGRAMDATA%/Shibboleth/SP/xml/xmltooling/catalog.xml;%PROGRAMDATA%/Shibboleth/SP/xml/opensaml/saml20-catalog.xml;%PROGRAMDATA%/Shibboleth/SP/xml/opensaml/saml11-catalog.xml;%PROGRAMDATA%/Shibboleth/SP/xml/shibboleth/catalog.xml"
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list