diff --git a/binfmt.py b/binfmt.py index 7c536fc..fe8fea2 100644 --- a/binfmt.py +++ b/binfmt.py @@ -2,8 +2,8 @@ import os import logging -import subprocess +from exec import run_root_cmd from utils import mount @@ -63,7 +63,7 @@ def register(arch): # Register in binfmt_misc logging.info(f"Registering qemu binfmt ({arch})") - subprocess.run(["sh", "-c", 'echo "' + code + '" > ' + register + ' 2>/dev/null']) + run_root_cmd(["sh", "-c", f'echo "{code}" > {register} 2>/dev/null']) if not is_registered(arch): logging.debug(f'binfmt line: {code}') raise Exception(f'Failed to register qemu-user for {arch} with binfmt_misc, {binfmt}/{info["name"]} not found') @@ -74,4 +74,4 @@ def unregister(arch): if not os.path.exists(binfmt_file): return logging.info(f"Unregistering qemu binfmt ({arch})") - subprocess.run(["sh", "-c", "echo -1 > " + binfmt_file]) + run_root_cmd(["sh", "-c", f"echo -1 > {binfmt_file}"])