Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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