Module: check_mk
Branch: master
Commit: 44abc7447a849d1064f8945887348a1f6385ccb0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=44abc7447a849d…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue May 29 12:59:37 2018 +0200
Work around pipenv timestamp oddity. Cleaned up a bit.
Change-Id: I7405f91c1d959c5528b4ddc1e2217144d6d01229
---
Makefile | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 6b2958c..10c47ea 100644
--- a/Makefile
+++ b/Makefile
@@ -68,6 +68,7 @@ SCAN_BUILD := scan-build-$(CLANG_VERSION)
export CPPCHECK := cppcheck
export DOXYGEN := doxygen
export IWYU_TOOL := iwyu_tool
+PIPENV := PIPENV_NO_INHERIT=true PIPENV_VENV_IN_PROJECT=true pipenv
# The Bear versions have a slightly tragic history: Due to the clang bug
# https://llvm.org/bugs/show_bug.cgi?id=24710 we need absolute paths in our
@@ -540,11 +541,19 @@ ifeq ($(ENTERPRISE),yes)
endif
Pipfile.lock: Pipfile
- PIPENV_VENV_IN_PROJECT=true pipenv lock
+ $(PIPENV) lock
+# TODO: pipenv and make don't really cooperate nicely: Locking alone already
+# creates a virtual environment with setuptools/pip/wheel. This could lead to a
+# wrong up-to-date status of it later, so let's remove it here. What we really
+# want is a check if the contents of .venv match the contents of Pipfile.lock.
+# We should do this via some move-if-change Kung Fu, but for now rm suffices.
+ rm -rf .venv
.venv: Pipfile.lock
- PIPENV_VENV_IN_PROJECT=true pipenv install --dev
- pipenv clean
+ $(PIPENV) install --dev
+ $(PIPENV) clean
+# TODO: Part 2 of the hack for the Pipfile.lock target.
+ touch .venv
# This dummy rule is called from subdirectories whenever one of the
# top-level Makefile's dependencies must be updated. It does not
Module: check_mk
Branch: master
Commit: 6fd97dcd36ef6d6524025ece1018af263d731c7c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6fd97dcd36ef6d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon May 28 21:22:32 2018 +0200
Updated text
Change-Id: I6870fba6b41769c27938d2d857bca3598c9f8db7
---
.werks/6185 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.werks/6185 b/.werks/6185
index 168bcd3..c2901ad 100644
--- a/.werks/6185
+++ b/.werks/6185
@@ -11,3 +11,6 @@ Date: 1527535164
The agent section generating code has been reworked for better performance.
You will have to update the agent to get this improvement. In case you use
the old agent with the new check, you will get no image label information.
+
+The agent is not processing all images anymore. It skips the intermediate
+images (were shown as "<none>:<none>" before).
Module: check_mk
Branch: master
Commit: cf2b593b8666d4d3a992cc88c81e4555ae6d613a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cf2b593b8666d4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon May 28 17:29:43 2018 +0200
Removed c buffer flushing of stderr redurector
Change-Id: Ie5e1fde150aa56c6eac74ef274e4eeef537a94ae
---
web/plugins/userdb/ldap.py | 6 ------
1 file changed, 6 deletions(-)
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 0aa505b..c9b6ce9 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -47,7 +47,6 @@ import time
import copy
from contextlib import contextmanager
-import ctypes
import io
import sys
import tempfile
@@ -1227,9 +1226,6 @@ multisite_user_connectors['ldap'] = LDAPUserConnector
# | the help of this wrapper in case the LDAP logging debug level is on |
# '----------------------------------------------------------------------'
-libc = ctypes.CDLL(None)
-c_stderr = ctypes.c_void_p.in_dll(libc, 'stderr')
-
@contextmanager
def stderr_redirector(stream):
# The original fd stderr points to. Usually 1 on POSIX systems.
@@ -1237,8 +1233,6 @@ def stderr_redirector(stream):
def _redirect_stderr(to_fd):
"""Redirect stderr to the given file descriptor."""
- # Flush the C-level buffer stderr
- libc.fflush(c_stderr)
# Flush and close sys.stderr - also closes the file descriptor (fd)
sys.stderr.close()
# Make original_stderr_fd point to the same file as to_fd
Module: check_mk
Branch: master
Commit: 44becb544db7f5936a552e1ab83fe92a167fc2b1
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=44becb544db7f5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon May 28 10:43:02 2018 +0200
6183 FIX LDAP: Improved debug logging during connect
When the LDAP logging of the GUI is set to debug the web.log will now get the
debug outputs of the lower level python-ldap and libldap components added.
This will show up detailed information about why connection attempts fail.
Change-Id: Ia3a7a5b23058d3f93c8e2b2e81ef566a7618413d
---
.werks/6183 | 14 +++++++++
web/plugins/userdb/ldap.py | 71 ++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/.werks/6183 b/.werks/6183
new file mode 100644
index 0000000..6f51e61
--- /dev/null
+++ b/.werks/6183
@@ -0,0 +1,14 @@
+Title: LDAP: Improved debug logging during connect
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1527496871
+
+When the LDAP logging of the GUI is set to debug the web.log will now get the
+debug outputs of the lower level python-ldap and libldap components added.
+
+This will show up detailed information about why connection attempts fail.
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 3c8033d..b189735 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -46,6 +46,12 @@ import os
import time
import copy
+from contextlib import contextmanager
+import ctypes
+import io
+import sys
+import tempfile
+
# docs: http://www.python-ldap.org/doc/html/index.html
import ldap
import ldap.filter
@@ -56,6 +62,7 @@ import cmk.paths
import config
import watolib
import log
+import cmk.log
# LDAP attributes are case insensitive, we only use lower case!
# Please note: This are only default values. The user might override this
@@ -204,8 +211,14 @@ class LDAPUserConnector(UserConnector):
def connect_server(self, server):
try:
+ trace_args = {}
+ if self._logger.isEnabledFor(cmk.log.DEBUG):
+ ldap.set_option(ldap.OPT_DEBUG_LEVEL, 4095)
+ trace_args["trace_level"] = 2
+ trace_args["trace_file"] = sys.stderr
+
uri = self.format_ldap_uri(server)
- conn = ldap.ldapobject.ReconnectLDAPObject(uri)
+ conn = ldap.ldapobject.ReconnectLDAPObject(uri, **trace_args)
conn.protocol_version = self._config.get('version', 3)
conn.network_timeout = self._config.get('connect_timeout', 2.0)
conn.retry_delay = 0.5
@@ -276,10 +289,14 @@ class LDAPUserConnector(UserConnector):
servers = self.servers()
for server in servers:
- ldap_obj, error_msg = self.connect_server(server)
+ debug_buffer = io.BytesIO()
+ with stderr_redirector(debug_buffer):
+ ldap_obj, error_msg = self.connect_server(server)
+
if ldap_obj:
self._ldap_obj = ldap_obj
else:
+ self._logger.debug("libldap debug output: %s" % debug_buffer.getvalue())
errors.append(error_msg)
continue # In case of an error, try the (optional) fallback servers
@@ -1193,6 +1210,56 @@ class LDAPUserConnector(UserConnector):
multisite_user_connectors['ldap'] = LDAPUserConnector
+#.
+# .--Debugging-----------------------------------------------------------.
+# | ____ _ _ |
+# | | _ \ ___| |__ _ _ __ _ __ _(_)_ __ __ _ |
+# | | | | |/ _ \ '_ \| | | |/ _` |/ _` | | '_ \ / _` | |
+# | | |_| | __/ |_) | |_| | (_| | (_| | | | | | (_| | |
+# | |____/ \___|_.__/ \__,_|\__, |\__, |_|_| |_|\__, | |
+# | |___/ |___/ |___/ |
+# +----------------------------------------------------------------------+
+# | A context manuer to catch the debug output for libldap that is sent |
+# | to stderr. We need all information in the web.log. This is done with |
+# | the help of this wrapper in case the LDAP logging debug level is on |
+# '----------------------------------------------------------------------'
+
+libc = ctypes.CDLL(None)
+c_stderr = ctypes.c_void_p.in_dll(libc, 'stderr')
+
+@contextmanager
+def stderr_redirector(stream):
+ # The original fd stderr points to. Usually 1 on POSIX systems.
+ original_stderr_fd = sys.stderr.fileno()
+
+ def _redirect_stderr(to_fd):
+ """Redirect stderr to the given file descriptor."""
+ # Flush the C-level buffer stderr
+ libc.fflush(c_stderr)
+ # Flush and close sys.stderr - also closes the file descriptor (fd)
+ sys.stderr.close()
+ # Make original_stderr_fd point to the same file as to_fd
+ os.dup2(to_fd, original_stderr_fd)
+ # Create a new sys.stderr that points to the redirected fd
+ sys.stderr = os.fdopen(original_stderr_fd, 'wb')
+
+ # Save a copy of the original stderr fd in saved_stderr_fd
+ saved_stderr_fd = os.dup(original_stderr_fd)
+ try:
+ # Create a temporary file and redirect stderr to it
+ tfile = tempfile.TemporaryFile(mode='w+b')
+ _redirect_stderr(tfile.fileno())
+ # Yield to caller, then redirect stderr back to the saved fd
+ yield
+ _redirect_stderr(saved_stderr_fd)
+ # Copy contents of temporary file to the given stream
+ tfile.flush()
+ tfile.seek(0, io.SEEK_SET)
+ stream.write(tfile.read())
+ finally:
+ tfile.close()
+ os.close(saved_stderr_fd)
+
#.
# .--Attributes----------------------------------------------------------.