From 086c95b4f96548544961d2b6856108a121744079 Mon Sep 17 00:00:00 2001 From: William Brown Date: Oct 11 2017 15:24:19 +0000 Subject: Ticket 49010 - Lib389 fails to start with systemctl changes Bug Description: systemctl changed their api to status which broke the lib389 wrapper. Pyldap doesn't work with bytes mode on fedora 24 and python 2. Asan would not allow the server to start correctly without the env options Fix Description: Change the systemctl interface to use is-active, check pyldap for python 3, and add the asan passthrough options. https://fedorahosted.org/389/ticket/49010 Author: wibrown Review by: spichugi (Thanks!) --- diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index f71092f..554b92a 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -985,7 +985,7 @@ class DirSrv(SimpleLDAPObject): uri = self.toLDAPURL() if self.verbose: self.log.info('open(): Connecting to uri %s' % uri) - if hasattr(ldap, 'PYLDAP_VERSION'): + if hasattr(ldap, 'PYLDAP_VERSION') and MAJOR >= 3: SimpleLDAPObject.__init__(self, uri, bytes_mode=False) else: SimpleLDAPObject.__init__(self, uri) @@ -1098,11 +1098,20 @@ class DirSrv(SimpleLDAPObject): # Start the process. # Wait for it to terminate # This means the server is probably ready to go .... + env = {} + if self.has_asan(): + log.error("NOTICE: Starting instance with ASAN options") + log.error("This is probably not what you want. Please contact support.") + log.error("ASAN options will be copied from your environment") + env['ASAN_SYMBOLIZER_PATH'] = "/usr/bin/llvm-symbolizer" + env['ASAN_OPTIONS'] = "symbolize=1 detect_deadlocks=1 log_path=%s/ns-slapd-%s.asan" % (self.ds_paths.run_dir, self.serverid) + env.update(os.environ) + log.error(env) subprocess.check_call(["%s/ns-slapd" % self.get_sbin_dir(), "-D", self.ds_paths.config_dir, "-i", - self.ds_paths.pid_file]) + self.ds_paths.pid_file], env=env) count = timeout pid = pid_from_file(self.ds_paths.pid_file) while (pid is None) and count > 0: @@ -1169,7 +1178,7 @@ class DirSrv(SimpleLDAPObject): if self.with_systemd() and not self.containerised: # Do systemd things here ... rc = subprocess.call(["/usr/bin/systemctl", - "status", + "is-active", "--quiet", "dirsrv@%s" % self.serverid]) if rc == 0: return True diff --git a/src/lib389/lib389/tests/plugin_test.py b/src/lib389/lib389/tests/plugin_test.py index adbff56..ca10faf 100644 --- a/src/lib389/lib389/tests/plugin_test.py +++ b/src/lib389/lib389/tests/plugin_test.py @@ -21,7 +21,7 @@ from lib389.utils import * from lib389.plugins import * -DEBUGGING = True +DEBUGGING = False if DEBUGGING: logging.getLogger(__name__).setLevel(logging.DEBUG)