binfmt.py: use exec.run_root_cmd()

This commit is contained in:
InsanePrawn 2022-08-15 06:42:19 +02:00
parent fdf03e2b97
commit b32099c4f1

View file

@ -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}"])