flatpak / xdg-desktop-portal

Desktop integration portal
https://flatpak.github.io/xdg-desktop-portal/
GNU Lesser General Public License v2.1
564 stars 189 forks source link

[RFC] A "scoped storage"-like portal #334

Open refi64 opened 5 years ago

refi64 commented 5 years ago

The rationale

The file chooser portal is great, but currently it doesn't allow opening directories. Of course this is intentional, since that would open up quite the potential security hole.

However, this also means two things:

There are some other similar problems, like VLC needed full filesystem access to be able to work with playlists and the like (even though it may be reading files from the internet and therefore should be constrained somehow).

Scoped storage

Android had a similar issue, and the solution they took inspired this post: scoped storage. Scoped storage and the Storage Access Framework are a lot like portals, but there's a bit of extra behavior that makes them more flexible. Consider the following scenarios:

The summarized API

So with all that laid out, here's how I imagine the API might look:

org.freedesktop.portal.Storage

OpenPersistentStorageAccessList(
  IN s parent_window  # same as usual
  IN a{sv} options
    # valid options:
      hints as (e.g. ['xdg-music', 'xdg-download'])
      rw-default b (e.g. true / false, default false)
  OUT o handle
)

GetPersistentStorageAccessList(
  OUT a(ss)  # list of pairs (host path, document portal path)
)

OpenDirectory(
  IN s parent_window  # same as usual
  IN reason s
  IN a{sv} options
    # valid options:
      rw b (e.g. true/false, default false)
  OUT o handle
)

Closing notes

Of course the specifics are all up for debate, but I just thought this would be a helpful addition to the current system, since it would make permissions a lot less coarse overall.

TingPing commented 5 years ago

The file chooser portal is great, but currently it doesn't allow opening directories. Of course this is intentional, since that would open up quite the potential security hole.

Its not intentional; Its a hard problem.

Anyway this discussion belongs on xdg-desktop-portal.

matthiasclasen commented 4 years ago

How is this different from just plugging a hole for XDG_MUSIC ?

TingPing commented 4 years ago

That it is dynamic and chosen by the user not the packager.

@alexlarsson and I discussed alternatives at GUADEC. For example having everything written to a private directory and then exposing them to the host, rather than the reverse.

refi64 commented 4 years ago

Pretty much, that way you have a sort of bridge between opening directories and having controlled access.

On Tue, Sep 17, 2019, 9:40 PM Patrick notifications@github.com wrote:

That it is dynamic and chosen by the user not the packager.

@alexlarsson https://github.com/alexlarsson and I discussed alternatives at GUADEC. For example having everything written to a private directory and then exposing them to the host, rather than the reverse.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/flatpak/xdg-desktop-portal/issues/334?email_source=notifications&email_token=AAM4YSOCRAZY3UPQ3LIDFPDQKGILTA5CNFSM4HREMIA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD66TKRY#issuecomment-532493639, or mute the thread https://github.com/notifications/unsubscribe-auth/AAM4YSOIQL3CQIMW2H7I7RDQKGILTANCNFSM4HREMIAQ .

matthiasclasen commented 4 years ago

I don't understand the description. You say the app calls into an api after it is launched - so that is just a portal ? Why is it important that it is called at launch ? And it doesn't explain how the application gets access. Your api sketch sounds like you just want to put directories into the document store after all, which, as is well-known, is problematic.

refi64 commented 4 years ago

You say the app calls into an api after it is launched - so that is just a portal ? Why is it important that it is called at launch ?

That was just an example for a music app, which would presumably need to know what music directories are available to show the user.

Your api sketch sounds like you just want to put directories into the document store after all, which, as is well-known, is problematic.

...touche on that, I guess maybe this could also bind mount into a directory visible by the Flatpak or similar?

Mikenux commented 1 year ago

Linked issue: https://github.com/flatpak/xdg-desktop-portal/issues/133

Telling the user that a folder or files will be permanently accessible by an application seems make sense, assuming the access to the selected folders/files is temporary. However, this means revisiting the fact that apps retain access to all files they have open, even after they are closed.

Mikenux commented 11 months ago

The case of VLC belongs to neighboring files.

To warn about permanent access, it would be better to warn about it directly in the file chooser.

For hidden dotfiles, it would be best not to access them unless there is a reason.

  • Presumably, there would also be an API to get the list of directories and their corresponding document portal locations, so that Music can bridge what's picked up from Tracker with the portal-mounted locations.

Maybe open another issue explaining better what is expected?

I'm wondering if it's possible here to only have read-only access and write access for specific cases, or if I should consider that for https://github.com/flatpak/xdg-desktop-portal/issues/808?