X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/blobdiff_plain/c49dfd272d994b1cdaa14107fee66be84b80c06b..c181bf984d4c5c8b189e3ffcf6bb52f5ed6b0d98:/tools/actions/container_manager.py?ds=inline diff --git a/tools/actions/container_manager.py b/tools/actions/container_manager.py index e537e18..3ce85b3 100644 --- a/tools/actions/container_manager.py +++ b/tools/actions/container_manager.py @@ -3,11 +3,8 @@ from shutil import which import logging import os -import time import glob import signal -import sys -import uuid import tools.config from tools import helpers from tools import services @@ -28,6 +25,9 @@ class DbusContainerManager(dbus.service.Object): uid = dbus_info.GetConnectionUnixUser(sender) if str(uid) not in ["0", session["user_id"]]: raise RuntimeError("Cannot start a session on behalf of another user") + pid = dbus_info.GetConnectionUnixProcessID(sender) + if str(uid) != "0" and str(pid) != session["pid"]: + raise RuntimeError("Invalid session pid") do_start(self.args, session) @dbus.service.method("id.waydro.ContainerManager", in_signature='b', out_signature='') @@ -77,16 +77,19 @@ def set_permissions(args, perm_list=None, mode="777"): "/dev/mtk_cmdq", # Graphics - "/dev/dri", "/dev/graphics", "/dev/pvr_sync", "/dev/ion", ] + # DRM render nodes + perm_list.extend(glob.glob("/dev/dri/renderD*")) # Framebuffers perm_list.extend(glob.glob("/dev/fb*")) # Videos perm_list.extend(glob.glob("/dev/video*")) + # DMA-BUF Heaps + perm_list.extend(glob.glob("/dev/dma_heap/*")) for path in perm_list: chmod(path, mode) @@ -139,24 +142,32 @@ def do_start(args, session): tools.helpers.run.user( args, ["waydroid-sensord", "/dev/" + args.HWBINDER_DRIVER], output="background") - # Mount rootfs - cfg = tools.config.load(args) - helpers.images.mount_rootfs(args, cfg["waydroid"]["images_path"], session) - - helpers.protocol.set_aidl_version(args) - # Cgroup hacks if which("start"): command = ["start", "cgroup-lite"] tools.helpers.run.user(args, command, check=False) + + # Keep schedtune around in case nesting is supported if os.path.ismount("/sys/fs/cgroup/schedtune"): - command = ["umount", "-l", "/sys/fs/cgroup/schedtune"] - tools.helpers.run.user(args, command, check=False) + try: + os.mkdir("/sys/fs/cgroup/schedtune/probe0") + os.mkdir("/sys/fs/cgroup/schedtune/probe0/probe1") + except: + command = ["umount", "-l", "/sys/fs/cgroup/schedtune"] + tools.helpers.run.user(args, command, check=False) + finally: + if os.path.exists("/sys/fs/cgroup/schedtune/probe0/probe1"): + os.rmdir("/sys/fs/cgroup/schedtune/probe0/probe1") + if os.path.exists("/sys/fs/cgroup/schedtune/probe0"): + os.rmdir("/sys/fs/cgroup/schedtune/probe0") #TODO: remove NFC hacks if which("stop"): command = ["stop", "nfcd"] tools.helpers.run.user(args, command, check=False) + elif which("systemctl") and (tools.helpers.run.user(args, ["systemctl", "is-active", "-q", "nfcd"], check=False) == 0): + command = ["systemctl", "stop", "nfcd"] + tools.helpers.run.user(args, command, check=False) # Set permissions set_permissions(args) @@ -169,6 +180,12 @@ def do_start(args, session): helpers.mount.bind(args, session["waydroid_data"], tools.config.defaults["data"]) + # Mount rootfs + cfg = tools.config.load(args) + helpers.images.mount_rootfs(args, cfg["waydroid"]["images_path"], session) + + helpers.protocol.set_aidl_version(args) + helpers.lxc.start(args) services.hardware_manager.start(args) @@ -192,6 +209,9 @@ def stop(args, quit_session=True): if which("start"): command = ["start", "nfcd"] tools.helpers.run.user(args, command, check=False) + elif which("systemctl") and (tools.helpers.run.user(args, ["systemctl", "is-enabled", "-q", "nfcd"], check=False) == 0): + command = ["systemctl", "start", "nfcd"] + tools.helpers.run.user(args, command, check=False) # Sensors if which("waydroid-sensord"):