[shibboleth-sp2] 61/89: SSPCPP-682 Wire Shibd into event messages

Ferenc Wágner wferi at moszumanska.debian.org
Thu Sep 1 09:24:10 UTC 2016


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

wferi pushed a commit to branch master
in repository shibboleth-sp2.

commit 9f968a65efa9b65e759d97696a786525bdad2cc4
Author: Rod Widdowson <rdw at steadingsoftware.com>
Date:   Mon Jun 20 11:17:26 2016 +0100

    SSPCPP-682 Wire Shibd into event messages
    
    https://issues.shibboleth.net/jira/browse/SSPCPP-682
    
    Use specific messages for shibd.  No formatting is needed, but as
    a matter of course we leave the original message in place (to help
    debug in the case of broken installs) and also put GetLastError()
    into the binary data area.
    
    We cannot format binary data in the event viewer, so one would
    need to look at tht raw xml and then byte swap. But that is
    advanced debugging anyway.
---
 Projects/vc10/Shibboleth.sln      |  6 ++++++
 Projects/vc10/shibd/shibd.vcxproj | 25 ++++++++++++++++------
 shibd/shibd_win32.cpp             | 16 ++++++++------
 util/message.mc                   | 45 +++++++++++++++++++++++++++++++++++++--
 4 files changed, 77 insertions(+), 15 deletions(-)

diff --git a/Projects/vc10/Shibboleth.sln b/Projects/vc10/Shibboleth.sln
index a86422e..58f621a 100644
--- a/Projects/vc10/Shibboleth.sln
+++ b/Projects/vc10/Shibboleth.sln
@@ -100,6 +100,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Doc", "Doc", "{6ED5E3E7-1B0
 	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "isapi_shib", "isapi_shib\isapi_shib.vcxproj", "{87C25D4E-8D19-4513-B0BA-BC668BC2DEE3}"
+	ProjectSection(ProjectDependencies) = postProject
+		{303291A1-C542-49E4-80B3-9304B7B6F8BC} = {303291A1-C542-49E4-80B3-9304B7B6F8BC}
+	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_shib_13", "apache\mod_shib13.vcxproj", "{D243B43E-728E-4F32-BDFF-B3A897037C6D}"
 EndProject
@@ -114,6 +117,9 @@ EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shibsp", "shibsp\shibsp.vcxproj", "{81F0F7A6-DC36-46EF-957F-F9E81D4403F6}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shibd", "shibd\shibd.vcxproj", "{F13141B5-6C87-40BB-8D4E-5CC56EBB4C59}"
+	ProjectSection(ProjectDependencies) = postProject
+		{303291A1-C542-49E4-80B3-9304B7B6F8BC} = {303291A1-C542-49E4-80B3-9304B7B6F8BC}
+	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shibsp-lite", "shibsp\shibsp-lite.vcxproj", "{81F0F7A6-DC36-46EF-957F-F9E81D4403F7}"
 EndProject
diff --git a/Projects/vc10/shibd/shibd.vcxproj b/Projects/vc10/shibd/shibd.vcxproj
index 9b1b0fe..0c87ef4 100644
--- a/Projects/vc10/shibd/shibd.vcxproj
+++ b/Projects/vc10/shibd/shibd.vcxproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
@@ -93,7 +93,7 @@
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
-      <AdditionalIncludeDirectories>..\..\..\shibd\;..\..\..\;..\..\..\..\cpp-opensaml;..\..\..\..\cpp-xmltooling;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\shibd\;..\..\..\;..\..\..\..\cpp-opensaml;..\..\..\..\cpp-xmltooling;$(OutDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -112,6 +112,9 @@
       </DataExecutionPrevention>
       <GenerateDebugInformation>true</GenerateDebugInformation>
     </Link>
+    <PreBuildEvent>
+      <Command>mc message.mc</Command>
+    </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <Midl>
@@ -122,7 +125,7 @@
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
       <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
-      <AdditionalIncludeDirectories>..\..\..\shibd\;..\..\..\;..\..\..\..\cpp-opensaml;..\..\..\..\cpp-xmltooling;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\shibd\;..\..\..\;..\..\..\..\cpp-opensaml;..\..\..\..\cpp-xmltooling;$(OutDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <StringPooling>true</StringPooling>
       <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -141,6 +144,9 @@
       </DataExecutionPrevention>
       <GenerateDebugInformation>true</GenerateDebugInformation>
     </Link>
+    <PreBuildEvent>
+      <Command>mc message.mc</Command>
+    </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <Midl>
@@ -149,7 +155,7 @@
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\..\shibd\;..\..\..\;..\..\..\..\cpp-opensaml;..\..\..\..\cpp-xmltooling;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\shibd\;..\..\..\;..\..\..\..\cpp-opensaml;..\..\..\..\cpp-xmltooling;$(OutDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CONSOLE;WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <RuntimeTypeInfo>true</RuntimeTypeInfo>
@@ -169,6 +175,10 @@
       <DataExecutionPrevention>
       </DataExecutionPrevention>
     </Link>
+    <PreBuildEvent>
+      <Command>
+      </Command>
+    </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
     <Midl>
@@ -178,7 +188,7 @@
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>..\..\..\shibd\;..\..\..\;..\..\..\..\cpp-opensaml;..\..\..\..\cpp-xmltooling;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\..\..\shibd\;..\..\..\;..\..\..\..\cpp-opensaml;..\..\..\..\cpp-xmltooling;$(OutDir;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>_CONSOLE;WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
       <RuntimeTypeInfo>true</RuntimeTypeInfo>
@@ -198,6 +208,9 @@
       <DataExecutionPrevention>
       </DataExecutionPrevention>
     </Link>
+    <PreBuildEvent>
+      <Command>mc message.mc</Command>
+    </PreBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
     <None Include="..\..\..\shibd\Makefile.am" />
@@ -221,4 +234,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/shibd/shibd_win32.cpp b/shibd/shibd_win32.cpp
index ae8ff46..bb12c59 100644
--- a/shibd/shibd_win32.cpp
+++ b/shibd/shibd_win32.cpp
@@ -27,6 +27,7 @@
 #define _CRT_NONSTDC_NO_DEPRECATE 1
 #define _CRT_SECURE_NO_DEPRECATE 1
 
+#include <message.h>
 #include <shibsp/base.h>
 #include <string>
 #include <windows.h>
@@ -158,7 +159,7 @@ int main(int argc, char *argv[])
         SetConsoleCtrlHandler(&BreakHandler,TRUE);
         if ((i=real_main(1))!=0)
         {
-            LogEvent(nullptr, EVENTLOG_ERROR_TYPE, 2100, nullptr, "shibd startup failed, check shibd.log for further details");
+            LogEvent(nullptr, EVENTLOG_ERROR_TYPE, SHIBD_STARTUP_FAILED, nullptr, "shibd startup failed, check shibd.log for further details");
             return i;
         }
         return real_main(0);
@@ -199,7 +200,7 @@ int main(int argc, char *argv[])
     };
 
     if (!StartServiceCtrlDispatcher(dispatchTable))
-        LogEvent(nullptr, EVENTLOG_ERROR_TYPE, 2100, nullptr, "StartServiceCtrlDispatcher failed.");
+        LogEvent(nullptr, EVENTLOG_ERROR_TYPE, SHIBD_SERVICE_START_FAILED, nullptr, "StartServiceCtrlDispatcher failed.");
     return 0;
 }
 
@@ -214,11 +215,11 @@ VOID ServiceStart (DWORD dwArgc, LPSTR *lpszArgv)
 
     if (real_main(1)!=0)
     {
-        LogEvent(nullptr, EVENTLOG_ERROR_TYPE, 2100, nullptr, "shibd startup failed, check shibd.log for further details");
+        LogEvent(nullptr, EVENTLOG_ERROR_TYPE, SHIBD_STARTUP_FAILED, nullptr, "shibd startup failed, check shibd.log for further details");
         return;
     }
 
-    LogEvent(nullptr, EVENTLOG_INFORMATION_TYPE, 7700, nullptr, "shibd started successfully.");
+    LogEvent(nullptr, EVENTLOG_INFORMATION_TYPE, SHIBD_SERVICE_STARTED, nullptr, "shibd started successfully.");
 
     if (!ReportStatusToSCMgr(SERVICE_RUNNING, NO_ERROR, 0))
         return;
@@ -235,7 +236,7 @@ VOID ServiceStart (DWORD dwArgc, LPSTR *lpszArgv)
 VOID ServiceStop()
 {
     if (!bConsole)
-        LogEvent(nullptr, EVENTLOG_INFORMATION_TYPE, 7701, nullptr, "shibd stopping...");
+        LogEvent(nullptr, EVENTLOG_INFORMATION_TYPE, SHIBD_SERVICE_STOPPING, nullptr, "shibd stopping...");
     shibd_shutdown=true;
 }
 
@@ -362,7 +363,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, 2100, nullptr, "SetServiceStatus failed.");
+            LogEvent(nullptr, EVENTLOG_ERROR_TYPE, SHIBD_SET_SERVICE_STATUS_FAILED, nullptr, "SetServiceStatus failed.");
     }
     return fResult;
 }
@@ -552,8 +553,9 @@ BOOL LogEvent(
     LPCSTR  message)
 {
     LPCSTR  messages[] = {message, nullptr};
+    DWORD gle = {GetLastError()};
     
     HANDLE hElog = RegisterEventSource(lpUNCServerName, "Shibboleth Daemon");
-    BOOL res = ReportEvent(hElog, wType, 0, dwEventID, lpUserSid, 1, 0, messages, nullptr);
+    BOOL res = ReportEvent(hElog, wType, CATEGORY_SHIBD, dwEventID, lpUserSid, 1, sizeof(DWORD), messages, &gle);
     return (DeregisterEventSource(hElog) && res);
 }
diff --git a/util/message.mc b/util/message.mc
index fa28c1e..e7c2612 100644
--- a/util/message.mc
+++ b/util/message.mc
@@ -31,13 +31,54 @@ FacilityNames=(Shibboleth=0x231:FACILITY_SYSTEM
 MessageId=100
 Severity=Error
 Facility=Shibboleth
-SymbolicName=SHIBD_MESSAGE
+SymbolicName=SHIBD_GENERIC_MESSAGE
 Language=English
-Shibboleth Daemon: %1!s!:  %2!s! %3!s! (%1!*x! : %2!x! '%3!ld!')  (%1!4d! : %2!I32d! '%3!3D!')
+Shibboleth Daemon: %1!s!
 .
 
 MessageId=
 Severity=Error
+Facility=Shibboleth
+SymbolicName=SHIBD_STARTUP_FAILED
+Language=English
+Shibboleth Daemon startup failed.
+.
+
+MessageId=
+Severity=Error
+Facility=Shibboleth
+SymbolicName=SHIBD_SERVICE_START_FAILED
+Language=English
+Shibboleth Daemon startup: StartServiceCtrlDispatcher failed.
+.
+
+MessageId=
+Severity=Error
+Facility=Shibboleth
+SymbolicName=SHIBD_SET_SERVICE_STATUS_FAILED
+Language=English
+Shibboleth Daemon startup: SetServiceStatus failed.
+.
+
+MessageId=
+Severity=Informational
+Facility=Shibboleth
+SymbolicName=SHIBD_SERVICE_STARTED
+Language=English
+Shibboleth Daemon started successfully.
+.
+
+MessageId=
+Severity=Informational
+Facility=Shibboleth
+SymbolicName=SHIBD_SERVICE_STOPPING
+Language=English
+Shibboleth Daemon stopping...
+.
+
+
+MessageId=200
+Severity=Error
 Facility=ShibbolethISAPI
 SymbolicName=SHIBISAPI_MESSAGE
 Language=English

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/shibboleth-sp2.git



More information about the Pkg-shibboleth-devel mailing list