feat: fuck proot and proots mama (#2300)

* feat: experimental native userland that runs the Linux side without proot

* fix(native): keep the visible name of link2symlink binaries

* fix(ci): run the native hook build through bash

* fix(native): address review findings in the hook and the ctl fallback

* fix(ctl): use the broadcast fallback only when content is missing

* fix(native): survive Android's seccomp filter in ld.so, libc and posix_spawn children

* docs(native): how to test under Android's seccomp filter

* fix(session): hide an unlistable /sys/bus/pci/devices so libpci does not abort Chromium's GPU init

* fix(native): nested syscall() redirects no longer loop with libblsession's openat2

* fix(native): controllers reach Steam and the install-script evaluator no longer blocks game moves

* fix(native): write the hook's NUL character literals as escapes

* fix(native): proot fast path turns off and greys out while running without proot

* fix(native): D-Bus logins work and Xwayland still admits root once peers read as root

* fix(native): scripts on session mounts outside the rootfs run with the rootfs shell

* fix(native): games on the SD card library start in their own folder

* fix(native): Wine drive links proot made point at their real places

* fix(native): at-calls, uid lookups and relative programs follow the session's mounts

* fix(native): close-from in spawned programs covers what is open at the spawn

* fix(native): service names resolve and the DNS fallback answers what was asked

* build(native): the hook is built with its Go support and tracked by the preload recipe

* fix(native): drive links into identity mounts stay, and relink and seccomp patch failures are logged

* fix(native): seccomp-sim's filter holds every allowed call

* fix(ctl): the broadcast fallback only stands in for a missing content command

* fix(native): pre-2.33 glibc stat calls present owners as root too

* fix(native): res_init and res_ninit call glibc, so Steam's store resolves names

* fix(ci): a preload lock older than a new output rebuilds that group, and generated headers are not hashed

* fix(native): a second seccomp patch run leaves other system calls alone

* fix(native): the terminal and bottom desktop keep proot's environment in a native session

* fix(native): any number of session mounts, and openat2 relative to a mounted folder

* fix(agent): a native command's stdin is written beside its timeout

* fix(ctl): native rejects --env without = and timeouts outside 0-600 s

* fix(native): the resolver fallback has the network's IPv6 servers, and lookups keep the fallback's validation errors

* fix(native): a spawn whose dup2 source close-from closed fails with EBADF

* fix(native): __getcwd_chk checks its buffer, and seccomp-sim -a takes only call numbers

* feat(native): guests see the session hostname from uname and gethostname

* feat(native): the terminal and bottom desktop run without proot

* fix(components): an origin APK without a newer preload output still proves the rest

* fix(native): seccomp-sim -a rejects empty fields

* fix(native): gethostbyname no longer answers failed lookups with Ubuntu and Debian addresses

* feat(native): store installers, root helpers, Comet and Xodus run without proot

* fix(native): the hook finds libraries, preloads and itself through a sandbox's mounts, and ldconfig -C makes its cache

* feat(native): Flatpak sandboxes run without proot, and apply_extra runs without a runtime

* fix(native): remove, glob and nftw take guest paths, and links in a mount are followed as the guest sees them

* fix(native): Flatpak sandboxes get the session's mounts, their libraries' RUNPATHs, and no rootfs-only settings

* fix(native): gethostbyname asks the network's DNS servers, nftw of / gives single slashes, and the library path fits mapped directories

* fix(native): a native process starts in its working directory's real place

* fix(native): the library path given to ld.so holds whole directories only

* fix(native): Wine drive links keep their guest paths, so proot finds the library after a native session

* fix(native): droiddeckctl native prepares the rootfs with the setting off

* fix(native): a SysV segment stays while any process has it attached

* fix(native): DNS lookups ask the network's own servers before public ones

* fix(native): a program's own seccomp traps reach its own SIGSYS handler

* feat(native): run native sessions under a device's own app seccomp filter for testing

* fix(native): SysV attaches and collection take a lock, a failed mark fails the attach, and collection closes its directory

* fix(native): shmat fails when it cannot take the segment lock

* fix(native): the SysV segment lock is retried when a signal interrupts it

* fix(native): process tools see the session's processes as root's

* fix(native): native processes are named after their program, not ld.so

* fix(native): a session's helpers keep the mode the session started in

* fix(native): a keyed SysV segment stays until IPC_RMID

* fix(native): a rootfs link to an absolute guest path is followed in the guest, so Wine finds its z: drive

* fix(native): a sandbox whose loader can't be patched runs under proot

* fix(native): creating a private SysV segment also collects stale ones

* fix(native): a session stopped during startup forgets its mode

* fix(xbox): a native backend is authorized by its process ancestry

* fix(native): Wine's drive links are followed in the guest from any prefix

* fix(native): only the startup that owns the running session publishes its mode

* fix(native): a SysV segment stays until IPC_RMID even after its maker ends

* fix(native): a sandbox mount nested in another mount gets its own place

* fix(native): a sandbox whose mount places can't be made runs under proot
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-11 09:13:17 -05:00
1 parent b1a410ccd2
commit 2848484a99
67 files changed
+13157 -113

No files matched your search

+46 -1
View File
@@ -417,12 +417,14 @@ class DroiddeckctlTest(FakeAdbTest):
return ctl.subprocess.CompletedProcess(args, 127, b"", b"/system/bin/sh: content: inaccessible or not found")
if args[:2] == ("shell", "am"):
return ctl.subprocess.CompletedProcess(args, 0, b"Broadcast completed: result=0", b"")
if args[:2] == ("shell", "pidof " + ctl.PACKAGE):
return ctl.subprocess.CompletedProcess(args, 0, b"4940\n", b"")
return ctl.subprocess.CompletedProcess(args, 0, next(answers), b"")
with unittest.mock.patch.object(ctl, "run_adb", adb), unittest.mock.patch.object(ctl.time, "sleep"):
answer = ctl.provider_call("adb", "fake-1", "state", arg="a b", request={"x": 1})
self.assertEqual({"ok": True, "command": "state"}, answer)
broadcast = calls[1]
broadcast = next(c for c in calls if c[:2] == ("shell", "am"))
self.assertEqual(("shell", "am", "broadcast", "-a", ctl.PACKAGE + ".AGENT_CALL", "-p", ctl.PACKAGE), broadcast[:7])
self.assertIn("'a b'", broadcast)
self.assertEqual(ctl.encode_request({"x": 1}), broadcast[broadcast.index("request") + 1])
@@ -823,5 +825,48 @@ class ScenarioTest(FakeAdbTest):
self.assertEqual([{"appId": 7, "timeout": 15.0}] * 2, [c["request"] for c in self.calls("quit")])
class ProviderFallbackTest(unittest.TestCase):
MISSING = "/system/bin/sh: content: inaccessible or not found\n"
def adb(self, answers):
calls = []
def run(adb, serial, *args, timeout=None):
calls.append(args)
for prefix, (code, out, err) in answers:
if " ".join(args).startswith(" ".join(prefix)):
return unittest.mock.Mock(returncode=code, stdout=out.encode(), stderr=err.encode())
raise AssertionError(f"unexpected adb call {args}")
return calls, unittest.mock.patch.object(ctl, "run_adb", run)
def test_a_command_that_prints_the_shell_error_is_not_run_again(self):
result = 'Result: Bundle[{json={"ok":true,"stdout":{"text":"' + self.MISSING.strip() + '"}}}]'
calls, patch = self.adb([(["shell", "content"], (0, result, ""))])
with patch:
self.assertTrue(ctl.provider_call("adb", "s", "native", request={"argv": ["x"]})["ok"])
self.assertEqual(1, len(calls))
def test_a_shell_without_content_uses_the_broadcast(self):
calls, patch = self.adb([
(["shell", "content"], (127, "", self.MISSING)),
(["shell", "pidof"], (0, "4940\n", "")),
(["shell", "am", "broadcast"], (0, "Broadcast completed", "")),
(["shell"], (0, '{"ok": true}', "")),
])
with patch:
self.assertTrue(ctl.provider_call("adb", "s", "state")["ok"])
self.assertEqual(["shell", "am", "broadcast"], list(calls[2][:3]))
def test_the_broadcast_needs_the_app_running(self):
calls, patch = self.adb([
(["shell", "content"], (127, "", self.MISSING)),
(["shell", "pidof"], (1, "", "")),
])
with patch, self.assertRaises(ctl.ControlError) as raised:
ctl.provider_call("adb", "s", "state")
self.assertEqual("APP_NOT_RUNNING", raised.exception.code)
self.assertFalse(any(c[:3] == ("shell", "am", "broadcast") for c in calls))
if __name__ == "__main__":
unittest.main()
+24
View File
@@ -150,6 +150,30 @@ class PreloadSnapshotTest(unittest.TestCase):
with self.assertRaisesRegex(ValueError, 'successful main'):
snapshots.artifact_bytes(self.data['origin'], self.root / 'cache')
def test_origin_apk_without_a_newer_output_reads_the_rest(self):
from zipfile import ZipFile
newest = 'libddnatv-hook.so'
apk = io.BytesIO()
with ZipFile(apk, 'w') as z:
for name, value in self.binaries.items():
if name != newest:
z.writestr('assets/linuxfs/' + name, value)
outer = io.BytesIO()
with ZipFile(outer, 'w') as z:
z.writestr('app-release.apk', apk.getvalue())
digest = snapshots.sha(outer.getvalue())
origin = dict(self.data['origin'], artifact_sha256=digest)
build = dict(event='push', head_branch='main', conclusion='success', head_sha=origin['commit'],
path='.github/workflows/build.yml', repository=dict(full_name=snapshots.REPO))
artifact = dict(name='droiddeck-apk', workflow_run=dict(id=origin['run']), digest='sha256:' + digest)
cache = self.root / 'cache'
cache.mkdir()
(cache / (digest + '.zip')).write_bytes(outer.getvalue())
with patch.object(snapshots, 'api', side_effect=[build, artifact]):
content = snapshots.artifact_bytes(origin, cache)
self.assertNotIn(newest, content)
self.assertEqual(set(content), snapshots.FILES - {newest})
def test_corrupt_archive_is_rejected(self):
with self.assertRaisesRegex(ValueError, 'checksum'):
snapshots.unpack(self.content + b'tampered', self.data)