From be8c9c9fe9ce2e7e074abda84a17cbdf7f6cf438 Mon Sep 17 00:00:00 2001 From: Ben Grande Date: Thu, 4 Dec 2025 12:20:20 +0100 Subject: [PATCH 1/2] Fix pylint complaints --- qrexec/client.py | 14 +++++++------- qrexec/policy/parser_compat.py | 4 ++-- qrexec/tools/qubes_policy.py | 4 ++-- qrexec/tools/qubes_policy_editor.py | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/qrexec/client.py b/qrexec/client.py index 0a19be86..b836c338 100644 --- a/qrexec/client.py +++ b/qrexec/client.py @@ -24,13 +24,13 @@ QREXEC_CLIENT_DOM0 = "/usr/bin/qrexec-client" QREXEC_CLIENT_VM = "/usr/bin/qrexec-client-vm" - -VERSION = None +# pylint: disable=invalid-name +IN_DOM0 = None if pathlib.Path(QREXEC_CLIENT_DOM0).is_file(): - VERSION = "dom0" + IN_DOM0 = True elif pathlib.Path(QREXEC_CLIENT_VM).is_file(): - VERSION = "vm" + IN_DOM0 = False def call(dest: str, rpcname: str, arg: Optional[str] = None, *, input=None): @@ -104,15 +104,15 @@ def make_command(dest, rpcname, arg): assert " " not in arg rpcname = f"{rpcname}+{arg}" - if VERSION == "dom0": + if IN_DOM0 is True: return [ QREXEC_CLIENT_DOM0, "-d", dest, f"DEFAULT:QUBESRPC {rpcname} dom0", ] - if VERSION == "vm": + if IN_DOM0 is False: return [QREXEC_CLIENT_VM, "--", dest, rpcname] - assert VERSION is None + assert IN_DOM0 is None raise NotImplementedError("qrexec not available") diff --git a/qrexec/policy/parser_compat.py b/qrexec/policy/parser_compat.py index 22971255..59a01603 100644 --- a/qrexec/policy/parser_compat.py +++ b/qrexec/policy/parser_compat.py @@ -82,11 +82,11 @@ def _list_compat_files(legacy_path): continue if filepath.suffix in IGNORED_SUFFIXES: - logging.info("ignoring %s (ignored suffix)") + logging.info("ignoring %s (ignored suffix)", filepath) continue if filepath.name.startswith("."): - logging.info("ignoring %s (dotfile)") + logging.info("ignoring %s (dotfile)", filepath) continue invalid_chars = parser.get_invalid_characters(filepath.name) diff --git a/qrexec/tools/qubes_policy.py b/qrexec/tools/qubes_policy.py index 90759287..440ee006 100755 --- a/qrexec/tools/qubes_policy.py +++ b/qrexec/tools/qubes_policy.py @@ -28,7 +28,7 @@ from ..policy.admin_client import PolicyClient from .. import RPCNAME_ALLOWED_CHARSET -from ..client import VERSION +from ..client import IN_DOM0 parser = argparse.ArgumentParser( usage="qubes-policy {[-l]|-g|-r|-d} [include/][RPCNAME[+ARGUMENT]]" @@ -116,7 +116,7 @@ def run_method(method, name, client, is_include): def main(args=None): args = parser.parse_args(args) - if VERSION == "dom0" and os.getuid() != 0: + if IN_DOM0 and os.getuid() != 0: print("You need to run as root in dom0") sys.exit(1) diff --git a/qrexec/tools/qubes_policy_editor.py b/qrexec/tools/qubes_policy_editor.py index 2706aa71..ffe938dd 100644 --- a/qrexec/tools/qubes_policy_editor.py +++ b/qrexec/tools/qubes_policy_editor.py @@ -31,7 +31,7 @@ import tempfile from ..policy.admin_client import PolicyClient from .. import RPCNAME_ALLOWED_CHARSET, POLICYPATH, INCLUDEPATH -from ..client import VERSION +from ..client import IN_DOM0 def validate_name(name): @@ -185,7 +185,7 @@ def main(): ) args = parser.parse_args() - if VERSION == "dom0" and os.getuid() != 0: + if IN_DOM0 and os.getuid() != 0: print("You need to run as root in dom0") sys.exit(1) From 1fa231c4aa3079867ec92eba8eb9326532448794 Mon Sep 17 00:00:00 2001 From: Ben Grande Date: Wed, 10 Dec 2025 09:15:39 +0100 Subject: [PATCH 2/2] Lint with Black 25.1.0 --- qrexec/tests/qrexec_legacy_convert.py | 6 +++--- qrexec/tests/socket/agent.py | 2 +- qrexec/tools/qrexec_policy_agent.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/qrexec/tests/qrexec_legacy_convert.py b/qrexec/tests/qrexec_legacy_convert.py index f4838de9..a474654b 100644 --- a/qrexec/tests/qrexec_legacy_convert.py +++ b/qrexec/tests/qrexec_legacy_convert.py @@ -243,7 +243,7 @@ def test_complex_rules(mock_policy_dirs: Tuple[pathlib.Path, pathlib.Path]): def test_input_rules_simple( - mock_policy_dirs: Tuple[pathlib.Path, pathlib.Path] + mock_policy_dirs: Tuple[pathlib.Path, pathlib.Path], ): # rules that are too complex for the configtool new_policy_dir, old_policy_dir = mock_policy_dirs @@ -285,7 +285,7 @@ def test_input_rules_simple( def test_input_multiple_rules( - mock_policy_dirs: Tuple[pathlib.Path, pathlib.Path] + mock_policy_dirs: Tuple[pathlib.Path, pathlib.Path], ): # rules that are too complex for the configtool new_policy_dir, old_policy_dir = mock_policy_dirs @@ -341,7 +341,7 @@ def test_input_multiple_rules( def test_input_multiple_sys_usbs( - mock_policy_dirs: Tuple[pathlib.Path, pathlib.Path] + mock_policy_dirs: Tuple[pathlib.Path, pathlib.Path], ): # rules that are too complex for the configtool new_policy_dir, old_policy_dir = mock_policy_dirs diff --git a/qrexec/tests/socket/agent.py b/qrexec/tests/socket/agent.py index e014df16..62363f67 100644 --- a/qrexec/tests/socket/agent.py +++ b/qrexec/tests/socket/agent.py @@ -1590,7 +1590,7 @@ def test_run_client_bidirectional_shutdown_early_exit(self): def test_run_client_replace_chars(self): target_client = self.run_service(options=["-t"]) target_client.send_message( - qrexec.MSG_DATA_STDOUT, b"hello\x00world\xFF" + qrexec.MSG_DATA_STDOUT, b"hello\x00world\xff" ) target_client.send_message(qrexec.MSG_DATA_STDOUT, b"") self.assertEqual(self.client.stdout.read(), b"hello_world_") diff --git a/qrexec/tools/qrexec_policy_agent.py b/qrexec/tools/qrexec_policy_agent.py index 3a6c9d98..653af827 100644 --- a/qrexec/tools/qrexec_policy_agent.py +++ b/qrexec/tools/qrexec_policy_agent.py @@ -20,7 +20,7 @@ # License along with this library; if not, see . # -""" Agent running in user session, responsible for asking the user about policy +"""Agent running in user session, responsible for asking the user about policy decisions.""" import itertools