Module: check_mk
Branch: master
Commit: 6a209f7ae7418f6563e02f24694067355c502d7d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6a209f7ae7418f…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Jun 12 11:16:16 2017 +0200
logwatch.py minor code cleanup in may_see function
Change-Id: I058ba0bab13a8a6f78c3a176832486329369c915
---
web/htdocs/logwatch.py | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/web/htdocs/logwatch.py b/web/htdocs/logwatch.py
index 3b301d3..e2feb0b 100644
--- a/web/htdocs/logwatch.py
+++ b/web/htdocs/logwatch.py
@@ -566,12 +566,17 @@ def may_see(site, host_name):
if config.user.may("general.see_all"):
return True
- if site:
- sites.live().set_only_sites([site])
+ host_found = False
+ try:
+ if site:
+ sites.live().set_only_sites([site])
+ # Note: This query won't work in a distributed setup and no site given as
argument
+ # livestatus connection is setup with AuthUser
+ host_found = sites.live().query_value("GET hosts\nStats: state >=
0\nFilter: name = %s\n" % lqencode(host_name)) > 0
+ finally:
+ sites.live().set_only_sites(None)
- # Note: This query won't work in a distributed setup and no site given as
argument
- # livestatus connection is setup with AuthUser
- return sites.live().query_value("GET hosts\nStats: state >= 0\nFilter: name =
%s\n" % lqencode(host_name)) > 0
+ return host_found
# Tackle problem, where some characters are missing in the service