From a8ab8d4efff00686d11284e21d461a9ca6614891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Wed, 5 May 2021 11:19:21 +0200 Subject: [PATCH] dnf plugin: don't try to execute qrexec if service is not running Needed for QubesOS/qubes-issues#4867 --- package-managers/dnf-qubes-hooks.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package-managers/dnf-qubes-hooks.py b/package-managers/dnf-qubes-hooks.py index 473553d..3a957fd 100644 --- a/package-managers/dnf-qubes-hooks.py +++ b/package-managers/dnf-qubes-hooks.py @@ -28,6 +28,10 @@ import subprocess PLUGIN_CONF = 'qubes-hooks' +def is_active(service): + status = subprocess.call(["systemctl", "is-active", "--quiet", service]) + return status == 0 + class QubesHooks(dnf.Plugin): name = 'qubes-hooks' @@ -37,6 +41,8 @@ class QubesHooks(dnf.Plugin): self.log = logging.getLogger('dnf') def resolved(self): + if not is_active("qubes-qrexec-agent"): + return # in case of no action to do, transaction() hook won't be called; # report updates availability here - especially when everything is up # to date - to clear updates-available flag @@ -53,6 +59,8 @@ class QubesHooks(dnf.Plugin): ]) def transaction(self): + if not is_active("qubes-qrexec-agent"): + return if LooseVersion(dnf.const.VERSION) < '2.0.0': config = self.read_config(self.base.conf, PLUGIN_CONF) else: