mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 15:56:01 +00:00
fix(flatpak): file dialogs and forwarded descriptors work in Flatpak apps (#3190)
* 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
This commit is contained in:
1 parent
19d8819137
commit
953549704a
14 files changed
+1336
-7
No files matched your search
@@ -143,6 +143,7 @@ object SessionFiles {
|
||||
"usr/local/bin/droiddeck-proton-extra" to "usr/local/bin/droiddeck-proton-extra",
|
||||
"usr/local/bin/droiddeck-netmanager" to "usr/local/bin/droiddeck-netmanager",
|
||||
"usr/local/bin/droiddeck-login1" to "usr/local/bin/droiddeck-login1",
|
||||
"usr/local/bin/droiddeck-documents" to "usr/local/bin/droiddeck-documents",
|
||||
"usr/local/bin/droiddeck-steam-launch" to "usr/local/bin/droiddeck-steam-launch",
|
||||
"usr/local/bin/droiddeck-desktop-games" to "usr/local/bin/droiddeck-desktop-games",
|
||||
"usr/local/bin/droiddeck-desktop-programs" to "usr/local/bin/droiddeck-desktop-programs",
|
||||
|
||||
@@ -61,9 +61,11 @@ class BwrapSpawnerTest {
|
||||
"DDNATV_ROOT" to rootfs, "DDNATV_BINDS" to "/dev:/dev", "HOME" to "/root",
|
||||
"SPA_PLUGIN_DIR" to "/usr/local/lib/droiddeck-pipewire/lib/spa-0.2",
|
||||
"LD_PRELOAD" to "/run/droiddeck-preload/libddsession.so:$rootfs/usr/local/lib/libddsession.so:$rootfs/usr/lib/libddnatv-hook.so",
|
||||
"DROIDDECK_FDS" to "droiddeck-fds-1",
|
||||
)
|
||||
BwrapSpawner.withoutRootfsSettings(env, rootfs)
|
||||
assertEquals(mapOf("HOME" to "/root", "LD_PRELOAD" to "/run/droiddeck-preload/libddsession.so"), env)
|
||||
assertEquals(mapOf("HOME" to "/root", "LD_PRELOAD" to "/run/droiddeck-preload/libddsession.so",
|
||||
"DROIDDECK_FDS" to "droiddeck-fds-1"), env)
|
||||
val onlySession = mutableMapOf("LD_PRELOAD" to "$rootfs/usr/lib/libddnatv-hook.so")
|
||||
BwrapSpawner.withoutRootfsSettings(onlySession, rootfs)
|
||||
assertTrue(onlySession.isEmpty())
|
||||
|
||||
Reference in new issue
Block a user