Module: check_mk
Branch: master
Commit: 9b99cbd30c17ae1de66a3bf64a75a6089cc95d3c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9b99cbd30c17ae…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Mon Sep 25 09:46:09 2017 +0200
Fix Windows eventlog output with vista_api=yes
The Vista API uses the Win API function EvtFormatMessage that delivers
formatted strings with trailing null characters within the allocated
wstring buffer size. Until the refactoring done in
fc96cd0d661bd51434d252198b574b2dc752a9c6, this did not cause trouble as
the wstring to UTF8 conversion was done using the Win API and 'old' C
strings. The refactoring introduced C++ standard library conversion that
is done on wstring objects instead of C strings. As a consequence, the
trailing null character was taken into the formatted message, later
causing the socket output to be cut at it. The fix is to trim possible
trailing null characters away from the formatted eventlog message.
Change-Id: I2bf5c8093c79e6e7babcc6abb15b91e6d23756d5
---
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 1565696 -> 1565696 bytes
agents/windows/check_mk_agent-64.unstripped.exe | Bin 22787160 -> 22788184 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 1565696 -> 1565696 bytes
agents/windows/check_mk_agent.exe | Bin 1548800 -> 1548800 bytes
agents/windows/check_mk_agent.msi | Bin 3388416 -> 3388416 bytes
agents/windows/check_mk_agent.unstripped.exe | Bin 19627551 -> 19628575 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 1548800 -> 1548800 bytes
agents/windows/crash.exe | Bin 358864 -> 358864 bytes
agents/windows/install_agent-64.exe | Bin 681464 -> 681445 bytes
agents/windows/install_agent.exe | Bin 676446 -> 676321 bytes
agents/windows/nowin.exe | Bin 361000 -> 361000 bytes
agents/windows/plugins/mk_jolokia.exe | Bin 10106814 -> 10106814 bytes
agents/windows/sections/SectionEventlog.cc | 11 +++++++++--
14 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 9b0efd1..ca6b285 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-2928
+2930
diff --git a/agents/windows/check_mk_agent-64.exe b/agents/windows/check_mk_agent-64.exe
index a292297..b25ea52 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 dd1dc1b..2d98db5 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 5cf4442..8ffadee 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 822aae6..95e5761 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 2093c92..98f3486 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 a1f58a0..2fba349 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 c8698a4..f33fcf1 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/crash.exe b/agents/windows/crash.exe
index 6069703..0a372ec 100755
Binary files a/agents/windows/crash.exe and b/agents/windows/crash.exe differ
diff --git a/agents/windows/install_agent-64.exe b/agents/windows/install_agent-64.exe
index f2fa75d..b3fa517 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 835a251..f5cfc01 100755
Binary files a/agents/windows/install_agent.exe and b/agents/windows/install_agent.exe differ
diff --git a/agents/windows/nowin.exe b/agents/windows/nowin.exe
index de789ac..627f396 100755
Binary files a/agents/windows/nowin.exe and b/agents/windows/nowin.exe differ
diff --git a/agents/windows/plugins/mk_jolokia.exe b/agents/windows/plugins/mk_jolokia.exe
index 1245e08..de94659 100755
Binary files a/agents/windows/plugins/mk_jolokia.exe and b/agents/windows/plugins/mk_jolokia.exe differ
diff --git a/agents/windows/sections/SectionEventlog.cc b/agents/windows/sections/SectionEventlog.cc
index f945824..558422c 100644
--- a/agents/windows/sections/SectionEventlog.cc
+++ b/agents/windows/sections/SectionEventlog.cc
@@ -148,10 +148,17 @@ void SectionEventlog::process_eventlog_entry(std::ostream &out,
// source is the application that produced the event
std::string source_name = to_utf8(event.source());
std::replace(source_name.begin(), source_name.end(), ' ', '_');
-
+ auto message = event.message();
+ // Nice surprise: EvtFormatMessage (used by Vista API) delivers wstring
+ // messages with trailing null character within the allocated wstring size!
+ // Later, this causes the socket output to be cut at the 1st null character,
+ // so we need to trim trailing null(s) away here.
+ while (message.back() == L'\0') {
+ message.resize(message.size() - 1);
+ }
out << type_char << " " << timestamp << " " << event.eventQualifiers()
<< "." << event.eventId() << " " << Utf8(event.source()) << " "
- << Utf8(event.message()) << "\n";
+ << Utf8(message) << "\n";
}
void SectionEventlog::outputEventlog(std::ostream &out, const char *logname,
Module: check_mk
Branch: master
Commit: a98c49386e72a121ac81bb9b34364c0ff51a4cb0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a98c49386e72a1…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Sep 20 10:42:00 2017 +0200
5295 FIX Service discovery: Fixed permission handling regarding foreign changes if user just performs a service discovery
If a user is not allowed to activate foreign changes but wants to
perform a service discovery of hosts configured on slave sites,
this action was falsely forbidden by Check_MK showing
<tt>There are some changes made by your colleagues that you can not
activate because you are not permitted to. You can only activate
the changes on the sites that are not affected by these changes.</tt>
Only if the user wants to activate these changes and does not have
the right permissions the above warning message should be displayed.
Change-Id: I22b2c8e4959e4053bedb6507a6ab781d79a5e22d
---
.werks/5295 | 18 ++++++++++++++++++
web/htdocs/watolib.py | 20 +++++++++-----------
2 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/.werks/5295 b/.werks/5295
new file mode 100644
index 0000000..3b00686
--- /dev/null
+++ b/.werks/5295
@@ -0,0 +1,18 @@
+Title: Service discovery: Fixed permission handling regarding foreign changes if user just performs a service discovery
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1505896357
+
+If a user is not allowed to activate foreign changes but wants to
+perform a service discovery of hosts configured on slave sites,
+this action was falsely forbidden by Check_MK showing
+<tt>There are some changes made by your colleagues that you can not
+activate because you are not permitted to. You can only activate
+the changes on the sites that are not affected by these changes.</tt>
+Only if the user wants to activate these changes and does not have
+the right permissions the above warning message should be displayed.
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index f6de125..2027b6f 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -4936,18 +4936,16 @@ class ActivateChangesManager(ActivateChanges):
def _create_site_sync_snapshot(self, site_id):
- has_foreign = self._site_has_foreign_changes(site_id)
+ if self._site_has_foreign_changes(site_id) and not self._activate_foreign:
+ if not config.user.may("wato.activateforeign"):
+ raise MKUserError(None,
+ _("There are some changes made by your colleagues that you can not "
+ "activate because you are not permitted to. You can only activate "
+ "the changes on the sites that are not affected by these changes. "
+ "<br>"
+ "If you need to activate your changes on all sites, please contact "
+ "a permitted user to do it for you."))
- if has_foreign and not config.user.may("wato.activateforeign"):
- raise MKUserError(None,
- _("There are some changes made by your colleagues that you can not "
- "activate because you are not permitted to. You can only activate "
- "the changes on the sites that are not affected by these changes. "
- "<br>"
- "If you need to activate your changes on all sites, please contact "
- "a permitted user to do it for you."))
-
- if has_foreign and not self._activate_foreign:
raise MKUserError(None,
_("There are some changes made by your colleagues and you did not "
"confirm to activate these changes. In order to proceed, you will "