* fix(flatpak): file dialogs and forwarded descriptors work in Flatpak apps Flatpak apps opened from the desktop could not open files: the file chooser's result went through a document store that cannot mount on Android, and image loaders started with flatpak-spawn --forward-fd lost their D-Bus descriptor because the app relaunches sandboxes and only stdio survived. - A session document store hands picked files and folders back in place instead of failing without a mount. - The bwrap shim offers its inherited descriptors once over a private socket, and the native hook puts them back on their original numbers before the program starts. - The native hook resolves /proc/<pid>/root paths to the other process's sandbox, so xdg-desktop-portal reads .flatpak-info and identifies the calling app. * fix(flatpak): check documents against the app's view and harden fd forwarding The document store hands a picked file back in place only when the calling app's own sandbox can open it with the requested access, so paths the app cannot see are refused instead of handed out broken. /proc/<pid>/root lookups follow links inside that process's view, duplicated root descriptors keep their mapping, and close_range drops stale records. Forwarded descriptors survive targets at the fd limit, truncated offers are ignored, and the shim refuses more descriptors than one message can carry. * fix(flatpak): match picked documents by file identity and keep O_NOFOLLOW on process roots The document store accepts an in-place path only when the app's view holds the same file (device and inode) as the picked descriptor, and reads each process root once. A bare /proc/<pid>/root opened with O_NOFOLLOW is no longer mapped, so it fails like the kernel's link. * Keep a trailing-slash process root translated and track only directory roots
Native userland (no proot)
libddnatv-hook.so is an LD_PRELOAD library that lets the glibc rootfs run directly on Android:
it maps the guest's absolute paths into the rootfs (plus the mounts proot used to provide, from
DDNATV_BINDS), starts every program through the rootfs's ld.so, and answers the system calls
Android's seccomp policy kills a process for (SIGSYS handler). There is no tracer. The app side
is runtime/NativeGuest.kt; the setting is Performance > "Run without proot (experimental)".
The hook is derived from the Apache-2.0 libcortex-hook of
ssfuisu/cortex (see LICENSE), renamed (cortex -> ddnatv,
same length: the code compares environment names by length) and extended with:
DDNATV_BINDSmounts,DDNATV_PRELOAD(what/etc/ld.so.preloaddoes for proot), and mapping of guest paths insideLD_PRELOAD;- POSIX
shm_open/shm_unlinkthrough/dev/shm; - starting Wine without its static preloader, which opens files with raw system calls.
Build: tools/nativeguest/build.sh out.so with an aarch64 glibc cross compiler.
Testing under Android's seccomp filter
Some devices (eng builds, setenforce 0 ROMs) run apps with no seccomp filter, so a hook that
passes there can still die with SIGSYS on a stock phone (GUEST_EXIT 159). seccomp-sim.c applies
a filter that answers the calls Android blocks with SIGSYS, then runs the program:
aarch64-linux-gnu-gcc -static -O2 -o seccomp-sim tools/nativeguest/seccomp-sim.c
# copy it into the rootfs, then name it for every native launch:
echo /usr/local/bin/seccomp-sim > <rootfs>/etc/droiddeck/seccomp-sim
grep Seccomp: /proc/<pid>/status should then show 2 for the session's processes. Empty the file
to turn it off. seccomp-sim -a NR,NR PROGRAM leaves the listed calls allowed, to find which one
kills a program.