Hello there, first post here.
Wasn’t able to find anything which answers my question in the level of detail I’d wish.
I know that Flatpak uses Portals to access files outside of the sandbox and that these files are mapped into the sandbox at /run/user/$UID/doc/$HASH/$FILE which isn’t available on the host.
However I work on an application which also works with DBUS to send unix file descriptors to a dbus interface. To do this the following happens:
- User selects file via the file portal
- File is propagated to the sandbox
- File is opened inside the sandbox
- File Descriptor (int) is received
- dbus interface is called with the file descriptor attached to it
- Host service can’t open file and thinks it has been “deleted”
Therefore I concluded the FD (file descriptor) is unknown to the host and do not seem to be identical between host and sandbox. Despite being already an abstract representation as they are only integers.
Is there a way to have persistent FD’s between sandbox and host? Or is this already supported and I just receive the file descriptor the wrong way?
In order to open the file I use:
Python:
fd = os.open(file_path)
However file_path is the property of GLocalFile.get_path() and is the sandbox path located at /run/user/$UID/doc/$HASH/$FILEof that file.
Is there a way to get the file descriptor directly from the host (without –filesystem=home or similar) as it will be passed back to the host anyway?
To circumvent this issue I just allowed my app to access xdg-downloads and the same code works as expected. (As long as the file in question is located in the users Downloads directory.)
My app gets the “real” path and running os.open on it returns a fd which also the host knowns and I can send over dbus to the external service which then can access that file just fine.