commit 33d8a6b16d3489821f5563f0db104ccfdbafc2b0 Author: Florian Best Date: Mon May 13 14:43:53 2019 +0200 Bug #42241: fix detection of samba4 service diff --git a/base/univention-config-registry/python/univention/service_info.py b/base/univention-config-registry/python/univention/service_info.py index 42ce601350..77010d0891 100644 --- a/base/univention-config-registry/python/univention/service_info.py +++ b/base/univention-config-registry/python/univention/service_info.py @@ -98,6 +98,7 @@ def pidof(name, docker='/var/run/docker.pid'): try: with open(cmdline, 'r') as fd: commandline = fd.read() + link = os.readlink(os.path.join('/proc', proc, 'exe')) except EnvironmentError: continue # kernel thread @@ -115,13 +116,14 @@ def pidof(name, docker='/var/run/docker.pid'): log.error('Failed getting parent: %s', ex) args = commandline.split('\0') - if cmd[0] not in args and not commandline.startswith(name): - log.debug('skip %d: %s', pid, commandline) - continue - if len(args) >= len(cmd) > 1: - if any(a != c for a, c in zip(args, cmd)): - log.debug('mismatch %d: %r != %r', pid, args, cmd) + if len(cmd) != 1 or link not in cmd: + if cmd[0] not in args and not commandline.startswith(name): + log.debug('skip %d: %s', pid, commandline) continue + if len(args) >= len(cmd) > 1: + if any(a != c for a, c in zip(args, cmd)): + log.debug('mismatch %d: %r != %r', pid, args, cmd) + continue log.info('found %d: %r', pid, commandline) result.add(pid) diff --git a/management/univention-management-console-module-services/umc/python/services/__init__.py b/management/univention-management-console-module-services/umc/python/services/__init__.py index 89cec8475b..5dfbfddeef 100644 --- a/management/univention-management-console-module-services/umc/python/services/__init__.py +++ b/management/univention-management-console-module-services/umc/python/services/__init__.py @@ -97,13 +97,15 @@ class Instance(Base): def _change_services(self, services, action): error_messages = [] + srvs = ServiceInfo() for srv in services: - process = subprocess.Popen(('/usr/sbin/service', srv, action), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + service_name = srvs.get_service(srv).get('systemd', srv) + process = subprocess.Popen(('/usr/sbin/service', service_name, action), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = process.communicate()[0] if process.returncode: try: - MODULE.warn('Error during %s of %s: %s' % (action, srv, output.strip())) - process = subprocess.Popen(('/bin/systemctl', 'status', srv), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + MODULE.warn('Error during %s of %s: %s' % (action, service_name, output.strip())) + process = subprocess.Popen(('/bin/systemctl', 'status', service_name), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) output = process.communicate()[0] except EnvironmentError: pass