Files
DroidDeck/tools/tests/test_desktop_root_apps.py
MaxsTechReview 65ebefc38f fix(desktop): Help Center, Software Sources and the driver manager open (#3371)
* fix(desktop): apps built on Qt's web engine start in the desktop and from AppImages

The desktop runs as root, and Qt WebEngine refuses to start as root with its
sandbox on, so Help Center and any other QtWebEngine app exited at once. Flatpaks
already had the sandbox off; the desktop and the AppImage runner now set it the
same way they turn off Firefox's sandboxes.

* fix(desktop): Software Sources and the driver manager open

software-properties-qt imports PyQt6.uic and UbuntuDrivers but does not depend
on the packages that ship them, so both tools died with an ImportError on the
installed-without-recommends desktop. The desktop package list now carries
pyqt6-dev-tools and ubuntu-drivers-common.
2026-11-28 10:24:50 -05:00

37 lines
1.6 KiB
Python

import os
from pathlib import Path
import subprocess
import unittest
TOOLS = Path(__file__).resolve().parents[1]
DESKTOP = (TOOLS / "linuxfs/desktop/droiddeck-desktop").read_text()
PACKAGES = (TOOLS / "ubuntu/packages-desktop.txt").read_text().split()
SANDBOXES = ("MOZ_DISABLE_CONTENT_SANDBOX", "MOZ_SHM_NO_SEALS", "QTWEBENGINE_DISABLE_SANDBOX")
class DesktopRootAppsTest(unittest.TestCase):
def desktop_environment(self):
head = DESKTOP[:DESKTOP.index("\nexport KWIN_COMPOSE=")]
env = {k: v for k, v in os.environ.items() if k not in SANDBOXES}
probe = "".join('echo %s=${%s-unset}\n' % (name, name) for name in SANDBOXES)
result = subprocess.run(["bash", "-c", head + "\nsh -c '" + probe + "'"], env=env,
capture_output=True, text=True, timeout=10)
self.assertEqual(0, result.returncode, result.stderr)
return dict(line.split("=", 1) for line in result.stdout.splitlines())
def test_web_engine_apps_start_as_root_like_firefox(self):
self.assertEqual({name: "1" for name in SANDBOXES}, self.desktop_environment())
def test_the_sandbox_switches_are_set_before_plasma(self):
self.assertLess(DESKTOP.index("export QTWEBENGINE_DISABLE_SANDBOX=1"),
DESKTOP.index("dbus-run-session -- startplasma-wayland"))
def test_software_sources_gets_the_modules_it_imports(self):
self.assertIn("software-properties-qt", PACKAGES)
for module in ("pyqt6-dev-tools", "ubuntu-drivers-common"):
self.assertIn(module, PACKAGES)
if __name__ == "__main__":
unittest.main()