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

snap, hooks: make host-hunspell a system-files interface #53

Open
wants to merge 4 commits into
base: stable
Choose a base branch
from

Conversation

bboozzoo
Copy link

The host-hunspell plug was a mount-control interface, which means that the snap could request snapd to set up a mount from/to a specific location. The problem is that the mount is visible in the host mount namespace, i.e. the mounts created a system wide. The mount-control interface was really intended to be used in Ubuntu Core oriented scenarios, when for instance a gadget mounts some external storage at a system wide location.

The particular care of the Firefox snap only really needs access to the hunspell dictionaries on the host. In this case a system-files interface allowing access to /usr/share/hunspell inside the host filesystem (exposed to the snap mount ns at /var/lib/snapd/hostfs) will be sufficient.

This will fix issues like LP#2059195

The host-hunspell plug was a mount-control interface, which means that the snap
could request snapd to set up a mount from/to a specific location. The problem
is that the mount is visible in the host mount namespace, i.e. the mounts
created a system wide. The mount-control interface was really intended to be
used in Ubuntu Core oriented scenarios, when for instance a gadget mounts some
external storage at a system wide location.

The particular care of the Firefox snap only really needs access to the hunspell
dictionaries on the host. In this case a system-files interface allowing access
to /usr/share/hunspell inside the host filesystem (exposed to the snap mount ns
at /var/lib/snapd/hostfs) will be sufficient.

This will fix issues like LP#2059195

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
Copy link

@zyga zyga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me

where: $SNAP_COMMON/host-hunspell
persistent: true
options: [ro, bind, noatime, noexec]
interface: system-files

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will require an update to the firefox snap declaration in the store.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Do you know if the store can handle the case where the plug name is unchanged? Maybe it'd be better if I changed the name to say host-usr-share-hunspell?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've renamed the plug to host-usr-share-hunspell to avoid potential name conflicts in snap declaration.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yep I think this is better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename the plug to host-usr-share-hunspell to avoid potential issue with
conflicting names in the snap declaration.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
@seb128
Copy link
Collaborator

seb128 commented Mar 27, 2024

Not a review but a side comment but we should start by targeting nightly and beta which are higher risk channels where we usually land changes to get testing before cherry-picking to stable

@bandali0
Copy link
Member

bandali0 commented Apr 5, 2024

Thanks for the PR. From a quick look and test, it looks good. I've pushed the change to the nightly and beta branches, and the corresponding builds are now pending manual review on the store. Once the approval is granted, I'll test a few other scenarios as well, before merging this into stable.

@ssbatema
Copy link

ssbatema commented Apr 10, 2024

installs and runs on raspberry pi4b+ubuntu core22 (arm64), closing 52!

We need this to be able to unmount the existing mount point for the
last time, otherwise removal of the Firefox snap fails halfway through
with this error:

error: cannot perform the following tasks:
- Remove data for snap "firefox" (4111) (unlinkat /var/snap/firefox/common/host-hunspell/en_US.dic: read-only file system)
@bandali0
Copy link
Member

bandali0 commented Apr 25, 2024

Hi @bboozzoo, (all,)

As mentioned above, I'd cherry-picked your changes into nightly and beta earlier, and after closer examination/review and testing several scenarios since then, I found a few issues with the proposed changes:

  • With the changes applied, attempting to remove the Firefox snap would fail midway through with the following error:

    error: cannot perform the following tasks:
    - Remove data for snap "firefox" (4111) (unlinkat /var/snap/firefox/common/host-hunspell/en_US.dic: read-only file system)
    

    Which appears to be due to the leftover mount point after the switch away from mount-control, and snapd not cleaning it up.
    As such, I added a commit to restore the mount-control declaration to snapcraft.yaml for the time being and also restored snap/hooks/disconnect-plug-host-hunspell to clean up after ourselves when disconnecting the plug. With this, running sudo snap remove firefox seems to be all good again and the removal completes successfully.

  • Your patch set DICPATH to /var/lib/snapd/hostfs/usr/share/hunspell, but it was previously deliberately set to not point directly to the host dictionaries, mainly to avoid potential incompatibility issues between differing versions of hunspell in the snap and outside the snap on the host. So I added a commit restoring the previous DICPATH, and adapting snap/hooks/post-refresh accordingly along with comments explaining the setup and the reasons for it.

  • Lastly, related to the first point, since your proposed changes had been live on nightly and beta for a few weeks, we can assume a nonzero number of people already their Firefox snap updated to those revisions, meaning their host-hunspell plug was disconnected without proper cleanup (since the initial proposed changes dropped snap/hooks/disconnect-plug-host-hunspell) so they would run into the aforementioned error if they were to attempt to remove the Firefox snap. For that reason, I added a third commit to attempt a cleanup as part of snap/hooks/post-refresh. I added the commit only to nightly and beta, and not this PR, since none of these changes are merged into stable yet, and so I believe for stable doing the cleanup only in snap/hooks/disconnect-plug-host-hunspell should be sufficient.

Thanks again for the patch, and thanks in advance for reviewing my proposed changes.

EDIT: also cc @lissyx

@bandali0 bandali0 requested review from zyga and seb128 and removed request for zyga April 25, 2024 03:15
Copy link
Author

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the update and extensive comments!

Copy link
Collaborator

@seb128 seb128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, if it's fine by the snapd reviewers I'm also +1 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants