From 48c912b193cb9be1f804b95f30711dfac5bed4e9 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 11 Jul 2014 20:53:31 +0200 Subject: Another import bugfix --- whatmaps/debiandistro.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/whatmaps/debiandistro.py b/whatmaps/debiandistro.py index 9294c9f..3a3bf16 100644 --- a/whatmaps/debiandistro.py +++ b/whatmaps/debiandistro.py @@ -31,12 +31,12 @@ import subprocess import sys import string -import whatmaps.distro +from . distro import Distro from . debianpkg import DebianPkg from . pkg import PkgError from . systemd import Systemd -class DebianDistro(whatmaps.distro.Distro): +class DebianDistro(Distro): "Debian (dpkg) based distribution" id = 'Debian' -- cgit v1.2.3 From 1a501af16db1f1122b7709b83c41cb4c1115f661 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 14 Jul 2014 16:12:43 +0200 Subject: Abort early if we found a match Once we found a shared object that a process maps we don't need to continue with the other shared objects since one is enough to require a process restart. --- whatmaps/command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whatmaps/command.py b/whatmaps/command.py index 7690ef8..e649cbb 100755 --- a/whatmaps/command.py +++ b/whatmaps/command.py @@ -39,7 +39,7 @@ def check_maps(procs, shared_objects): restart_procs[proc.exe] += [ proc ] else: restart_procs[proc.exe] = [ proc ] - continue + break return restart_procs -- cgit v1.2.3 From 506e87c479fb181b800c4bfdb8ca018f1a1bb6c1 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 28 Dec 2014 14:32:52 +0100 Subject: Report PIDs of deleted executables at debug level It's not of any interest to the user. --- whatmaps/process.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whatmaps/process.py b/whatmaps/process.py index 1abde23..23ed7ab 100644 --- a/whatmaps/process.py +++ b/whatmaps/process.py @@ -36,7 +36,7 @@ class Process(object): if m: self.exe = m.group('exe') self.deleted = True - logging.info("Using deleted exe %s", self.exe) + logging.debug("Using deleted exe %s", self.exe) if not os.path.exists(self.exe): logging.debug("%s doesn't exist", self.exe) self.cmdline = open(self._procpath('%d/cmdline' % self.pid)).read() -- cgit v1.2.3 From 8c5b2930b37f7cf6fd0a44e4283bf2c79fbc13bd Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 28 Dec 2014 14:37:00 +0100 Subject: Log services to restart in apt pipeline too All other code paths log this at debug level. We should to so too to get improved output when using unattended-upgrades. --- whatmaps/command.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/whatmaps/command.py b/whatmaps/command.py index e649cbb..0a4eb7b 100755 --- a/whatmaps/command.py +++ b/whatmaps/command.py @@ -59,7 +59,7 @@ def write_cmd_file(services, cmd_file, distro): out = open(cmd_file, 'w') print('#! /bin/sh', file=out) for service in services: - logging.debug("Need to restart %s", service) + logging.info("Need to restart '%s'", service) print(" ".join(distro.restart_service_cmd(service)), file=out) out.close() os.chmod(cmd_file, 0o755) @@ -225,7 +225,7 @@ def main(argv): write_cmd_file(services, options.print_cmds, distro) else: for service in services: - logging.info("Restarting %s" % service) + logging.info("Restarting '%s'" % service) distro.restart_service(service) elif services: print("Services that possibly need to be restarted:") -- cgit v1.2.3 From 9b32d5e86ef7ad4b4e802ec8fb16b21fb47d45b8 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 28 Dec 2014 14:49:03 +0100 Subject: Fix service name parsing for systemd >= 215 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Newer systemd put a colored bullet point '●' in front of the service name output: # sudo systemctl status 971 ● libvirtd.service - Virtualization daemon ... Skip that. --- whatmaps/command.py | 7 ++++++- whatmaps/systemd.py | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/whatmaps/command.py b/whatmaps/command.py index 0a4eb7b..d0f5c3e 100755 --- a/whatmaps/command.py +++ b/whatmaps/command.py @@ -113,7 +113,12 @@ def find_systemd_units(procmap, distro): for dummy, procs in procmap.items(): for proc in procs: - unit = Systemd.process_to_unit(proc) + try: + unit = Systemd.process_to_unit(proc) + except ValueError as e: + logging.warning("No systemd unit found for '%s': %s" + "- restart manually" % (proc.exe, e)) + continue if not unit: logging.warning("No systemd unit found for '%s'" "- restart manually" % proc.exe) diff --git a/whatmaps/systemd.py b/whatmaps/systemd.py index add6d0e..3407128 100644 --- a/whatmaps/systemd.py +++ b/whatmaps/systemd.py @@ -38,4 +38,10 @@ class Systemd(object): if systemctl_status.returncode: return None else: - return output.split()[0] + parts = output.split() + if parts[0].endswith('.service'): + return parts[0] + elif parts[1].endswith('.service'): + return parts[1] + else: + raise ValueError("Can't parse service name from\n%s" % output) -- cgit v1.2.3 From 1ee865fefdd5267c2ada84cc370f2005b6b1a5b6 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Sun, 28 Dec 2014 15:01:39 +0100 Subject: Install apt.conf configuration on derivatives too Closes: #761054 --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7e7ed00..cdadd50 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,8 @@ data_files = [] try: import lsb_release - if lsb_release.get_distro_information()['ID'] in [ 'Debian' ]: + if (lsb_release.get_distro_information()['ID'] in [ 'Debian' ] or + os.path.exists('/etc/debian_version')): data_files = [('../etc/apt/apt.conf.d/', ['apt/50whatmaps_apt']), ('../etc/apt/apt.conf.d/', -- cgit v1.2.3