Module: check_mk
Branch: master
Commit: 372c6adeab9d67ba3e17ca67a481f6f7bafe41f0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=372c6adeab9d67…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Jun 19 14:52:54 2017 +0200
picked WK4708 from 1.4.0
Change-Id: Id56a6f3d41503266983d67539e8ce1120270366f
---
.werks/4708 | 16 ++++++++++++++
agents/windows/ExternalCmd.cc | 27 +++++++++++++++++++----
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 1339392 -> 1339904 bytes
agents/windows/check_mk_agent-64.unstripped.exe | Bin 15811521 -> 15823277 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 1339392 -> 1339904 bytes
agents/windows/check_mk_agent.exe | Bin 1316864 -> 1317888 bytes
agents/windows/check_mk_agent.msi | Bin 2926080 -> 2927616 bytes
agents/windows/check_mk_agent.unstripped.exe | Bin 13670888 -> 13681693 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 1316864 -> 1317888 bytes
agents/windows/install_agent-64.exe | Bin 591635 -> 591860 bytes
agents/windows/install_agent.exe | Bin 589053 -> 589484 bytes
12 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/.werks/4708 b/.werks/4708
new file mode 100644
index 0000000..fb0e153
--- /dev/null
+++ b/.werks/4708
@@ -0,0 +1,16 @@
+Title: Windows Agent/Agent Updater: Fixed race condition which removed the windows
service
+Level: 2
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1496847511
+
+The agent updater could kill itself during an update, because the MSI installation
process
+sent a shutdown signal to the windows service. This shutdown also killed any plugins,
+including the agent updater... This has been fixed by detaching the cmk-update-agent.exe
+file from the process group of the windows agent.
+
+
diff --git a/agents/windows/ExternalCmd.cc b/agents/windows/ExternalCmd.cc
index cbc4663..3d12242 100644
--- a/agents/windows/ExternalCmd.cc
+++ b/agents/windows/ExternalCmd.cc
@@ -31,6 +31,14 @@
extern bool with_stderr;
extern HANDLE g_workers_job_object;
+
+bool ends_with(std::string const & value, std::string const & ending)
+{
+ if (ending.size() > value.size()) return false;
+ return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
+}
+
+
ExternalCmd::ExternalCmd(const char *cmdline) {
SECURITY_DESCRIPTOR security_descriptor;
SECURITY_ATTRIBUTES security_attributes;
@@ -73,9 +81,18 @@ ExternalCmd::ExternalCmd(const char *cmdline) {
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
std::unique_ptr<char[], decltype(free) *> cmdline_buf(strdup(cmdline),
free);
+
+ bool detach_process = ends_with(std::string(cmdline),
std::string("cmk-update-agent.exe\""));
+
+ DWORD dwCreationFlags = CREATE_NEW_CONSOLE;
+ if (detach_process) {
+ crash_log("Detaching process: %s, %d", cmdline, detach_process);
+ dwCreationFlags = CREATE_NEW_PROCESS_GROUP | DETACHED_PROCESS;
+ }
+
if (!CreateProcess(nullptr, cmdline_buf.get(), nullptr, nullptr, TRUE,
- CREATE_NEW_CONSOLE, nullptr, nullptr, &si, &pi)) {
- throw win_exception(std::string("failed to spawn process ") + cmdline);
+ dwCreationFlags, nullptr, nullptr, &si, &pi)) {
+ throw win_exception(std::string("failed to spawn process ") +
cmdline);
}
_process = pi.hProcess;
@@ -84,8 +101,10 @@ ExternalCmd::ExternalCmd(const char *cmdline) {
// Create a job object for this process
// Whenever the process ends all of its childs will terminate, too
_job_object = CreateJobObject(nullptr, nullptr);
- AssignProcessToJobObject(_job_object, pi.hProcess);
- AssignProcessToJobObject(g_workers_job_object, pi.hProcess);
+ if (!detach_process) {
+ AssignProcessToJobObject(_job_object, pi.hProcess);
+ AssignProcessToJobObject(g_workers_job_object, pi.hProcess);
+ }
}
ExternalCmd::~ExternalCmd() {
diff --git a/agents/windows/build_version b/agents/windows/build_version
index dc1d7d0..c98e88a 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-2711
+2713
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index fcff221..a1750d6 100755
Binary files a/agents/windows/check_mk_agent-64.exe and
b/agents/windows/check_mk_agent-64.exe differ
diff --git a/agents/windows/check_mk_agent-64.unstripped.exe
b/agents/windows/check_mk_agent-64.unstripped.exe
index 95096dd..d0c42ee 100755
Binary files a/agents/windows/check_mk_agent-64.unstripped.exe and
b/agents/windows/check_mk_agent-64.unstripped.exe differ
diff --git a/agents/windows/check_mk_agent-64.unversioned.exe
b/agents/windows/check_mk_agent-64.unversioned.exe
index 86953d6..32229f9 100755
Binary files a/agents/windows/check_mk_agent-64.unversioned.exe and
b/agents/windows/check_mk_agent-64.unversioned.exe differ
diff --git a/agents/windows/check_mk_agent.exe b/agents/windows/check_mk_agent.exe
index 2b15763..5b0c4de 100755
Binary files a/agents/windows/check_mk_agent.exe and b/agents/windows/check_mk_agent.exe
differ
diff --git a/agents/windows/check_mk_agent.msi b/agents/windows/check_mk_agent.msi
index 398eabf..b4de316 100755
Binary files a/agents/windows/check_mk_agent.msi and b/agents/windows/check_mk_agent.msi
differ
diff --git a/agents/windows/check_mk_agent.unstripped.exe
b/agents/windows/check_mk_agent.unstripped.exe
index 69c4e60..0b43306 100755
Binary files a/agents/windows/check_mk_agent.unstripped.exe and
b/agents/windows/check_mk_agent.unstripped.exe differ
diff --git a/agents/windows/check_mk_agent.unversioned.exe
b/agents/windows/check_mk_agent.unversioned.exe
index 235143b..e77dcc3 100755
Binary files a/agents/windows/check_mk_agent.unversioned.exe and
b/agents/windows/check_mk_agent.unversioned.exe differ
diff --git a/agents/windows/install_agent-64.exe b/agents/windows/install_agent-64.exe
index 8f55da0..4210301 100755
Binary files a/agents/windows/install_agent-64.exe and
b/agents/windows/install_agent-64.exe differ
diff --git a/agents/windows/install_agent.exe b/agents/windows/install_agent.exe
index 1be05ce..867cf5d 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe
differ