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

Change filesystem access to xdg-music only #108

Closed
wants to merge 6 commits into from
Closed

Conversation

Eonfge
Copy link
Collaborator

@Eonfge Eonfge commented Oct 12, 2020

Not functional at the moment, requires some upstream attention

@flathubbot
Copy link
Contributor

Started test build 30130

@Eonfge
Copy link
Collaborator Author

Eonfge commented Oct 12, 2020

@bellegarde-c In line with Flatpak specs, I made a special Lollypop branch that has the sandbox more restrictive. I hope you can take a look at it, because at the moment there are two issues:

  • The player crashes when you try to access an existing catalog directly
  • The folder-selector is very rough, and doesn't seem to integrate with the GtkFileChooserNative

I have no intention of releasing this in its current state, but I do want you and others to be able to test it.

@flathubbot
Copy link
Contributor

Build 30130 successful
To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/29016/org.gnome.Lollypop.flatpakref

@bellegarde-c
Copy link
Collaborator

flatpak install --user https://dl.flathub.org/build-repo/29016/org.gnome.Lollypop.flatpakref

Done this but looks like Lollypop is not sandboxed here.

@bellegarde-c
Copy link
Collaborator

sandbox

@Eonfge
Copy link
Collaborator Author

Eonfge commented Oct 13, 2020

Weird. I previously had issues opening the portal browser. Well, I'll run it through a few more tests in that case.

The primary problem right now... is that this change is not backwards compatible. Users will have to re-select their music folders (other then dxg-music) to reimport their libraries. Is this worth the hassle?

Do you foresee any issues when we tighten up the sandbox permissions?

@bilelmoussaoui do you have any comments concerning the sandboxing of Lollypop?

@flathubbot
Copy link
Contributor

Started test build 30498

@flathubbot
Copy link
Contributor

Build 30498 successful
To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/29378/org.gnome.Lollypop.flatpakref

@bilelmoussaoui
Copy link
Member

As lollypop allows the user to select their music folder/add new ones, the change in the permissions won't work for everyone. Although the portal does support selecting folders now, it won't work for users with older version :/ So I would prefer to wait a bit before merging this.

@Eonfge
Copy link
Collaborator Author

Eonfge commented Oct 19, 2020

I actually ran into that myself. My version of Lollypop had a direct link to a non-xdg location. So over time, people will have to re-configure lollypop for the paths to properly migrate? I'll test that a few times, and we might have to hold off on it for a year or so, making sure that the fallout is not to big.

@flathubbot
Copy link
Contributor

Started test build 30912

@flathubbot
Copy link
Contributor

Build 30912 successful
To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/29778/org.gnome.Lollypop.flatpakref

@flathubbot
Copy link
Contributor

Started test build 30979

@flathubbot
Copy link
Contributor

Build 30979 successful
To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/29844/org.gnome.Lollypop.flatpakref

@Eonfge
Copy link
Collaborator Author

Eonfge commented Oct 25, 2020

@bilelmoussaoui I've done some testing. As of right now, it will cause issues when we deploy this update, even for users who only downloaded Lollypop yesterday.

What I've tested:

  • Clean environment (Fedora 33, GNOME Boxes)
  • Install lollypop flathub master
  • Add custom folder with music (~/CustomMusicFolder/)
  • Import, refresh, play for testing purposes
  • Status: All good so far
  • Install lollypop flathub NoMoreHost
  • import, refresh
  • Status: Files can't be found

I had to re-select my music library and I had to reimport it. The current version of Lollypop and GtkFileChooserNetive, don't use a a /var/run/ mount when selecting files, if they don't have to. As such, when updating lollypop it will be unable to access the files in ~/CustomMusicFolder/

So, what's the plan? I do want to improve the security in the future

@bellegarde-c
Copy link
Collaborator

@Eonfge Can I do something from Lollypop POV ?

@bilelmoussaoui
Copy link
Member

Nothing can be done regarding the migration as the files/directories you grant an application the permission to open/read/write are stored in the flatpak documents store and are added once you open a file using the portal (the native file dialog). The directories has to be re-added so that Lollypop has actually the permission granted to open/read those files instead of "having permissions to everything"

@bilelmoussaoui
Copy link
Member

@Eonfge Can I do something from Lollypop POV ?

what would be nice is to migrate all file choosers to native ones as a first step

@Eonfge
Copy link
Collaborator Author

Eonfge commented Oct 26, 2020

@bellegarde-c I was thinking about that. Would it be possible to add a -DFlatpak=true flag to meson?

You can then show a message that informs users about their folders and permissions when they start Lollypop and a folder is missing. If a folder is missing, you can tell users like like "Sandboxing good. Sandboxing WIP. Please re-import".

The comment of @bilelmoussaoui is certainly true, making sure all file choosers are up-to-date is important, but I think we can't escape the realization that enforcing sandboxing does require a minor action from the user.

@Eonfge
Copy link
Collaborator Author

Eonfge commented Nov 12, 2020

@bellegarde-c Would it be possible to provide some user-notification when they start the Flatpak version first?

If you could include such a message, I can combine it with this change. Then, when users update Lollypop to a more sandboxed version, they'll be informed about the change. The flag and notification could be temporary, because as time progresses all people will migrate. After a few months, we could remove it.

@flathubbot
Copy link
Contributor

Started test build 32608

@flathubbot
Copy link
Contributor

Build 32608 successful
To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/31417/org.gnome.Lollypop.flatpakref

@flathubbot
Copy link
Contributor

Started test build 32676

@flathubbot
Copy link
Contributor

Build 32676 successful
To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/31475/org.gnome.Lollypop.flatpakref

@bilelmoussaoui
Copy link
Member

@bilelmoussaoui What I want is detecting configured folders in Lollypop with access denied by sandbox.

You can query the documents portal and see which permissions your app has for a specific folder/file

@Eonfge
Copy link
Collaborator Author

Eonfge commented Dec 27, 2020

  • The pop-up about 'Automatically download metadata?' doesn't actually enable network access, thus being non-functional

This one is working here. Do you mean that lollypop is not downloading artwork or that the setting is not updated ?

It would be the setting then. This is what I see after I click agree:
Screenshot from 2020-12-27 14-28-35

@bellegarde-c
Copy link
Collaborator

It modifies the background data, it's another issue :D

@bellegarde-c
Copy link
Collaborator

Updated Lollypop to handle migration only if needed.

@flathubbot
Copy link
Contributor

Started test build 35501

@flathubbot
Copy link
Contributor

Build 35501 successful
To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/34162/org.gnome.Lollypop.flatpakref

@Eonfge
Copy link
Collaborator Author

Eonfge commented Dec 27, 2020

I've successfully tested the following scenarios:

  • Do a fresh installation, select custom folder
  • Do a fresh installation, use xdg-music
  • Have an existing library, have music in a custom folder, re-import folder required
  • Have an existing library, have music in xdg-music and a custom folder, xdg-folder is instantly available, custom folder must be re-imported
  • Have an existing library, have music in xdg-music only, no re-import required

Bugs

  • UI Bug: in scenario 2, the dxg-folder is not visible when I open the preferences menu for the first time. It only becomes visible if I then clos it and re-open it.
  • Underwater Bug: In all scenarios, I get a message that Last FM and Listen Brains can't find the appropriate files.
    log.txt

In summary

I think we have this fully working 😄 I would invite others to try it, but I haven't found any issues.

@bellegarde-c
Copy link
Collaborator

UI bug was a Lollypop bug, fixed ;)

@flathubbot
Copy link
Contributor

Started test build 35514

@flathubbot
Copy link
Contributor

Build 35514 successful
To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/34174/org.gnome.Lollypop.flatpakref

@Eonfge
Copy link
Collaborator Author

Eonfge commented Dec 28, 2020

Well, all seems well. Let me know when there is a new Lollypop release and I'll release it with the improved sandboxing.

@flathubbot
Copy link
Contributor

Started test build 35572

@flathubbot
Copy link
Contributor

Build 35572 failed

@flathubbot
Copy link
Contributor

Started test build 35573

@flathubbot
Copy link
Contributor

Started test build 35574

@flathubbot
Copy link
Contributor

Build 35573 successful
To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/34228/org.gnome.Lollypop.flatpakref

@flathubbot
Copy link
Contributor

Build 35574 successful
To test this build, install it from the testing repository:

flatpak install --user https://dl.flathub.org/build-repo/34229/org.gnome.Lollypop.flatpakref

@bellegarde-c
Copy link
Collaborator

Time to merge this, 1.4.8 is out.

@Eonfge Eonfge mentioned this pull request Jan 7, 2021
@Eonfge
Copy link
Collaborator Author

Eonfge commented Jan 7, 2021

Closing this branch in favour of #122 so we don't have a whole series of surplus comments on Git

@Eonfge Eonfge closed this Jan 7, 2021
@Eonfge Eonfge deleted the NoMoreHost branch January 7, 2021 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants