Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real directory name not accessible from file opened via document portal #475

Closed
chergert opened this issue Apr 17, 2020 · 11 comments · Fixed by #1364
Closed

Real directory name not accessible from file opened via document portal #475

chergert opened this issue Apr 17, 2020 · 11 comments · Fixed by #1364
Assignees
Labels
enhancement help wanted needs discussion Needs discussion on how to implement or fix the corresponding task portal: documents Issues with the documents portal

Comments

@chergert
Copy link

Currently, when accessing documents via the document portal we're provided with a file in the format of /run/user/1000/doc/abcdef/filename.txt. This is fine and a nice way to implement things using a FUSE mount to ensure access.

However, it's very problematic for applications like text editors. We want to provide information to the user about what file was accessed (including the path). We also want to allow the user to open a file browser or terminal where that file exists. Both of these things are impossible currently unless we grant access to $HOME or get lucky with access like xdg-documents or something like that.

I know it's a bit extra work, even for applications, but perhaps we could add a new G_FILE_ATTRIBUTE_STANDARD_DIRNAME that could grab an extended attribute from the FUSE driver.

My main argument is that I don't think there is value to obscuring a directory path from the application even if that is not how they access it. As a user, browsing to a directory and selecting a file certainly doesn't convey to me that the application wouldn't know where that file was (even if it accesses it via another path). It feels very much like an implementation detail due to how FUSE works, and if so, it would be nice to find a workaround for applications to exist with stronger sandboxing even for this use case.

@chergert chergert changed the title Directory name from document accessed via document portal Real directory name not accessible from file opened via document portal Apr 17, 2020
@hadess
Copy link
Contributor

hadess commented Apr 17, 2020

We also want to allow the user to open a file browser or terminal where that file exists.

The OpenDirectory portal does just that:

Asks to open the directory containing a local file in the file browser.

I'm not sure why the application needs to know what the name of the directory the file is in is.

@hadess
Copy link
Contributor

hadess commented Apr 17, 2020

Also, adding a G_FILE_ATTRIBUTE_STANDARD_DIRNAME attribute won't fix the terminal use case either.

@chergert
Copy link
Author

I'm not sure why the application needs to know what the name of the directory the file is in is.

Because in a text editor it's helpful to give context to the user as you might have multiple files with the same name in different directories.

For example, Makefile.

@hadess
Copy link
Contributor

hadess commented Apr 17, 2020

So, this use case: #463 ?

Sorry misread that. But it still doesn't fix it for gio/tests/meson.build vs. tests/meson.build (as I've seen happen).

@chergert
Copy link
Author

Additionally, it's nice to open a new GtkFileChooserNative in the same location as the focused file. If you can't actually get that location, you always end up at $HOME or Recent or something annoying like that.

@hadess
Copy link
Contributor

hadess commented Apr 22, 2020

Additionally, it's nice to open a new GtkFileChooserNative in the same location as the focused file. If you can't actually get that location, you always end up at $HOME or Recent or something annoying like that.

I've filed this as #477

@sophie-h
Copy link
Contributor

Both of these things are impossible currently unless we grant access to $HOME

I'm struggling with the same issue for Pika Backup. However, I'm not sure if the portal is supposed to give me the correct path with --filesystem=host? Text Editor seems to be able to show the correct path inside the user's home while using GtkFileChooserNative inside flatpak. However, I cannot reproduce this behavior.

Can someone update me what's the exact status of this issue?

@chergert
Copy link
Author

I'm struggling with the same issue for Pika Backup. However, I'm not sure if the portal is supposed to give me the correct path with --filesystem=host? Text Editor seems to be able to show the correct path inside the user's home while using GtkFileChooserNative inside flatpak. However, I cannot reproduce this behavior.

Text Editor can show the correct path because while we use GtkFileChooserNative, we don't use the document portal FUSE because the logic in Flatpak knows we can access it by the real path (due to how it scans for symlinks and having set --filesystem=host).

However, you can see where this breaks by opening Nautilus and browsing to somewhere like /etc and opening a file. In Text Editor it will show as /run/user/1000/... because the /etc path isn't available to the Flatpak container.

@sophie-h
Copy link
Contributor

I didn't get the correct filename because of some strange issue with my build system.

Maybe worth adding to the portal docs that the returned path is not always in /run/.

@septatrix
Copy link

My naive first guess would have been that all application simply access files through an overlayfs or similar and that paths (once given the permission) would be accessed at the original URL as it is currently done when using e.g. --filesystem=xdg-download. This evidently is not the case (and according to @smvc in flatpak/flatpak#4543 (comment) changing this would break other features - not sure what exactly would be affected though).

I would also like to add the problem in which this affects me. For me the problems first showed up once org.telegram.desktop locked down permissions even further by removing xdg-download and going full in on portals. Currently there are still a few issues on their side (like telegramdesktop/tdesktop#25390) but in general I think this is something other apps are likely to do in the future. Now, when opening downloaded files from the app I obviously land in some /run folder which is annoying. However, the more annoying part is, that this also clash with opening downloaded files when the handler is another flatpak application (which obviously does not have access to the same /run directory). Opening e.g. an xlsx file instead only shows an empty page. (Actually the usual handler should be Libreoffice but I guess that does not get discovered from inside the Flatpak?) Regardless, the user experience is bad and there is no workaround.

@fastrizwaan
Copy link

This bug is still present with ro access. --filesystem=host works, but --filesystem=host:ro or --filesystem=home:ro causes this bug with freedesktop sdk 22.08.
flatpak/flatpak#5413

@GeorgesStavracas GeorgesStavracas moved this to Needs Triage in Triage Oct 2, 2023
@GeorgesStavracas GeorgesStavracas added enhancement help wanted portal: documents Issues with the documents portal needs discussion Needs discussion on how to implement or fix the corresponding task labels Oct 6, 2023
@GeorgesStavracas GeorgesStavracas moved this from Needs Triage to Triaged in Triage Oct 6, 2023
@sonnyp sonnyp moved this to Todo in Flatpak STF Nov 6, 2023
@sonnyp sonnyp moved this from Todo to Ready in Flatpak STF Nov 9, 2023
@sonnyp sonnyp self-assigned this Nov 9, 2023
@sonnyp sonnyp moved this from Ready to In Progress in Flatpak STF Nov 23, 2023
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue May 27, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue May 27, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue May 27, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue May 27, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue May 28, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue May 29, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue Jun 3, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue Jun 7, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue Jun 7, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue Jun 7, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue Jun 7, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue Jun 7, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
grulja added a commit to grulja/xdg-desktop-portal that referenced this issue Jun 7, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes flatpak#475
github-merge-queue bot pushed a commit that referenced this issue Jun 7, 2024
This method allows apps to get path as exists on the host filesystem for
documents exported through the document portal.

This method takes a list of document IDs as a string array and returns
a dictionary mapping document IDs to the paths in the host filesystem.
It is expected an app making this request to have access to given list
of documents.

This is based on initial work made by @JakobDev

Fixes #475
@github-project-automation github-project-automation bot moved this from In Progress to Done in Flatpak STF Jun 7, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in @hfiguiere's xdg-portal Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted needs discussion Needs discussion on how to implement or fix the corresponding task portal: documents Issues with the documents portal
Projects
Status: Triaged
8 participants
@sonnyp @chergert @hadess @fastrizwaan @sophie-h @GeorgesStavracas @septatrix and others