From 0b8e5400a3d76f30bbe16717415714dadd99d3d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Tue, 18 Feb 2020 11:44:57 +0100 Subject: [PATCH] config: specify dom0 services path --- qubes/config.py | 2 ++ qubes/ext/services.py | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/qubes/config.py b/qubes/config.py index 889ed850..6b56b90b 100644 --- a/qubes/config.py +++ b/qubes/config.py @@ -44,6 +44,8 @@ system_path = { # qubes_icon_dir is obsolete # use QIcon.fromTheme() where applicable 'qubes_icon_dir': '/usr/share/icons/hicolor/128x128/devices', + + 'dom0_services_dir': '/var/lib/qubes-services', } defaults = { diff --git a/qubes/ext/services.py b/qubes/ext/services.py index dc43e378..392bd0db 100644 --- a/qubes/ext/services.py +++ b/qubes/ext/services.py @@ -22,6 +22,9 @@ import os import qubes.ext +import qubes.config + +dom0_services_dir = qubes.config.system_path['dom0_services_dir'] class ServicesExtension(qubes.ext.Extension): @@ -32,19 +35,21 @@ class ServicesExtension(qubes.ext.Extension): @staticmethod def add_dom0_services(vm, service): try: - os.makedirs('/var/run/qubes-service/', exist_ok=True) - if not os.path.exists('/var/run/qubes-service/{}'.format(service)): - os.mknod('/var/run/qubes-service/{}'.format(service)) + os.makedirs(dom0_services_dir, exist_ok=True) + service = '{}/{}'.format(dom0_services_dir, service) + if not os.path.exists(service): + os.mknod(service) except PermissionError: - vm.log.warning("Cannot write to /var/run/qubes-service") + vm.log.warning("Cannot write to {}".format(dom0_services_dir)) @staticmethod def remove_dom0_services(vm, service): try: - if os.path.exists('/var/run/qubes-service/{}'.format(service)): - os.remove('/var/run/qubes-service/{}'.format(service)) + service = '{}/{}'.format(dom0_services_dir, service) + if os.path.exists(service): + os.remove(service) except PermissionError: - vm.log.warning("Cannot write to /var/run/qubes-service") + vm.log.warning("Cannot write to {}".format(dom0_services_dir)) # pylint: disable=no-self-use @qubes.ext.handler('domain-qdb-create')