Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions qrexec/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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")
4 changes: 2 additions & 2 deletions qrexec/policy/parser_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions qrexec/tests/qrexec_legacy_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion qrexec/tests/socket/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_")
Expand Down
2 changes: 1 addition & 1 deletion qrexec/tools/qrexec_policy_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# License along with this library; if not, see <https://www.gnu.org/licenses/>.
#

""" 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
Expand Down
4 changes: 2 additions & 2 deletions qrexec/tools/qubes_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]"
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions qrexec/tools/qubes_policy_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Expand Down