Module: check_mk
Branch: master
Commit: 84cbab1c0ce0bde95c9010ed5577393696861067
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=84cbab1c0ce0bd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 27 16:33:51 2018 +0200
Fixed unstable integration tests because of port conflicts
The previous "free port" detection was not sufficient because the
site is not always running and listenting on that port during tests.
This could lead to conflicts when different branch test jobs run.
Change-Id: Ic689330d17d18c2363774551d83bc0212ebc4ec6
---
tests/testlib/__init__.py | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index 8e54bc7..96cfca3 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -2,6 +2,7 @@
# encoding: utf-8
import os
+import glob
import pwd
import time
import pytest
@@ -916,6 +917,8 @@ class Site(object):
if start_again:
self.start()
+ sys.stdout.write("After livestatus port lock\n")
+
def _gather_livestatus_port(self):
if self.reuse and self.exists():
@@ -927,21 +930,17 @@ class Site(object):
def get_free_port_from(self, port):
- while True:
- try:
- print "Trying port %d" % port
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- sock.bind(("127.0.0.1", port))
- sock.listen(1)
- sock.close()
-
- break # found a bindable port
- except socket.error, e:
- print "Failed to bind 127.0.0.1:%d: %s" % (port, e)
- port += 1
-
- print "Using port %d" % port
+ used_ports = set([])
+ for cfg_path in glob.glob("/omd/sites/*/etc/omd/site.conf"):
+ for line in cfg_path:
+ if line.startswith("CONFIG_LIVESTATUS_TCP_PORT="):
+ port = int(line.strip().split("=", 1)[1].strip("'"))
+ used_ports.add(port)
+
+ while port in used_ports:
+ port += 1
+
+ print "Livestatus ports already in use: %r, using port: %d" % (used_ports, port)
return port
# Problem: The group change only affects new sessions of the test_user
Module: check_mk
Branch: master
Commit: d18d9419281d28d8e935573f78d26559b4fe1a3b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d18d9419281d28…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Sep 27 14:21:14 2018 +0200
6728 FIX Hide links to not permitted views from host context menu
The entries for linking to BI aggregations of a host and HW/SW inventory of
a host are now hidden from the host context menu when a user is not permitted
to see the target views.
Change-Id: I483d1ba885b1ac7a44f6f363fd58765d42a2d806
---
.werks/6728 | 13 +++++++++++++
cmk/gui/plugins/views/icons/builtin.py | 7 ++++++-
cmk/gui/plugins/views/icons/inventory.py | 4 ++++
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/.werks/6728 b/.werks/6728
new file mode 100644
index 0000000..12e7268
--- /dev/null
+++ b/.werks/6728
@@ -0,0 +1,13 @@
+Title: Hide links to not permitted views from host context menu
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1538050817
+
+The entries for linking to BI aggregations of a host and HW/SW inventory of
+a host are now hidden from the host context menu when a user is not permitted
+to see the target views.
diff --git a/cmk/gui/plugins/views/icons/builtin.py b/cmk/gui/plugins/views/icons/builtin.py
index bd6032b..433adf4 100644
--- a/cmk/gui/plugins/views/icons/builtin.py
+++ b/cmk/gui/plugins/views/icons/builtin.py
@@ -740,8 +740,13 @@ def paint_aggregations(what, row, tags, host_custom_vars):
if config.bi_precompile_on_demand \
or bi.is_part_of_aggregation(what, row["site"], row["host_name"],
row.get("service_description")):
+ view_name = "aggr_%s" % what
+
+ if not config.user.may("view.%s" % view_name):
+ return
+
urivars = [
- ("view_name", "aggr_" + what),
+ ("view_name", view_name),
("aggr_%s_site" % what, row["site"]),
("aggr_%s_host" % what, row["host_name"]),
]
diff --git a/cmk/gui/plugins/views/icons/inventory.py b/cmk/gui/plugins/views/icons/inventory.py
index 580ba78..96669be 100644
--- a/cmk/gui/plugins/views/icons/inventory.py
+++ b/cmk/gui/plugins/views/icons/inventory.py
@@ -34,6 +34,10 @@ def paint_icon_inventory(what, row, tags, customer_vars):
from cmk.gui.plugins.views import url_to_view
if (what == "host" or row.get("service_check_command","").startswith("check_mk_active-cmk_inv!")) \
and inventory.has_inventory(row["host_name"]):
+
+ if not config.user.may("view.inv_host"):
+ return
+
return 'inv', _("Show Hardware/Software Inventory of this host"), url_to_view(row, 'inv_host')
multisite_icons_and_actions['inventory'] = {