-
Notifications
You must be signed in to change notification settings - Fork 239
cmd/create: keep host supplementary groups with --group-add keep-groups #1732
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
base: main
Are you sure you want to change the base?
Conversation
Toolbx currently fails to create or start containers on hosts where the user has group-only access to device nodes under /dev, for example when VirtualBox creates /dev/vboxusb/* owned by root:vboxusers with 0750 permissions. In this situation a rootless Toolbx container inherits /dev from the host, the /dev/vboxusb directory is visible, but the container process has no group membership for vboxusers. When the OCI runtime walks /dev it eventually tries to open or create device nodes under /dev/vboxusb and fails with an OCI permission denied error, so `toolbox enter` aborts with "failed to start container". This behaviour is described in containers#1348, which generalizes the problem to any directory under /dev with 0750 permissions where the user only has access via a supplementary group (eg. dialout, vboxusers, docker). It is also the root cause behind reports like containers#1297 and the older containers#247, and matches similar issues seen with rootless Podman and VirtualBox in other projects (distrobox, crun, Debian bug reports). Rootless Podman already has a mechanism to address this class of problems: passing `--group-add keep-groups` to `podman create` or `podman run` tells Podman to keep the caller's supplementary groups instead of dropping them during container setup. The Podman documentation explicitly recommends this flag for cases where device access is granted only via group membership and notes that otherwise accessing such devices from rootless containers will fail with permission errors. This patch wires that mechanism into Toolbx by adding `--group-add keep-groups` to the `podman create` invocation used by the `toolbox create` command when running as a non-root user and when the Podman version is >= 3.2.0, which is when the flag became available. The call is gated through the existing podman.CheckVersion helper, so older Podman versions are not affected and keep the previous behaviour. With this change, the OCI runtime sees the same supplementary groups as the host process, so a user who is a member of vboxusers (or dialout, docker, etc.) can access devices that are only group readable from inside a rootless Toolbx container. On systems with VirtualBox installed this fixes errors of the form: crun: creating `/dev/vboxusb/00x/00y`: openat2 `dev/vboxusb`: Permission denied: OCI permission denied when entering a freshly created Toolbx container. This patch intentionally does not change how /dev is mounted into the container and does not implement the more invasive /dev filtering approach discussed in containers#1348. It is a minimal, backwards compatible improvement that fixes the common VirtualBox and other group-only device cases by leveraging Podman's existing `--group-add keep-groups` support. Tests: * On Fedora 42 with VirtualBox installed and the user in the vboxusers group, verified that `toolbox create` logs the `podman create` command including `--group-add keep-groups`. * Confirmed that `toolbox enter` succeeds for a new container where it previously failed with an OCI permission denied on /dev/vboxusb. * Verified that behaviour is unchanged on a system without VirtualBox and that the flag is not added when running as root. Fixes: containers#1348 Related: containers#1297, containers#247
Summary of ChangesHello @Knogle, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a crucial enhancement to Toolbx's container creation process, specifically targeting rootless environments. It resolves persistent permission denied errors encountered when containers attempt to access device nodes under /dev that are only accessible via a host user's supplementary groups (like vboxusers or dialout). By conditionally adding the --group-add keep-groups flag to Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly adds the --group-add keep-groups flag to podman create for non-root users on systems with a compatible Podman version. This is a good fix for the reported issue of device access from within rootless Toolbx containers. The logic is sound and the change is well-contained. My review includes a couple of minor suggestions to fix indentation inconsistencies to align with Go's standard formatting practices.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
Build failed. ✔️ unit-test SUCCESS in 2m 06s |
Toolbx currently fails to create or start containers on hosts where the user has group-only access to device nodes under /dev, for example when VirtualBox creates /dev/vboxusb/* owned by root:vboxusers with 0750 permissions. In this situation a rootless Toolbx container inherits /dev from the host, the /dev/vboxusb directory is visible, but the container process has no group membership for vboxusers. When the OCI runtime walks /dev it eventually tries to open or create device nodes under /dev/vboxusb and fails with an OCI permission denied error, so
toolbox enteraborts with "failed to start container".This behaviour is described in #1348, which generalizes the problem to any directory under /dev with 0750 permissions where the user only has access via a supplementary group (eg. dialout, vboxusers, docker). It is also the root cause behind reports like #1297 and the older #247, and matches similar issues seen with rootless Podman and VirtualBox in other projects (distrobox, crun, Debian bug reports).
Rootless Podman already has a mechanism to address this class of problems: passing
--group-add keep-groupstopodman createorpodman runtells Podman to keep the caller's supplementary groups instead of dropping them during container setup. The Podman documentation explicitly recommends this flag for cases where device access is granted only via group membership and notes that otherwise accessing such devices from rootless containers will fail with permission errors.This patch wires that mechanism into Toolbx by adding
--group-add keep-groupsto thepodman createinvocation used by thetoolbox createcommand when running as a non-root user and when the Podman version is >= 3.2.0, which is when the flag became available. The call is gated through the existing podman.CheckVersion helper, so older Podman versions are not affected and keep the previous behaviour.With this change, the OCI runtime sees the same supplementary groups as the host process, so a user who is a member of vboxusers (or dialout, docker, etc.) can access devices that are only group readable from inside a rootless Toolbx container. On systems with VirtualBox installed this fixes errors of the form:
crun: creating
/dev/vboxusb/00x/00y: openat2dev/vboxusb:Permission denied: OCI permission denied
when entering a freshly created Toolbx container.
This patch intentionally does not change how /dev is mounted into the container and does not implement the more invasive /dev filtering approach discussed in #1348. It is a minimal, backwards compatible improvement that fixes the common VirtualBox and other group-only device cases by leveraging Podman's existing
--group-add keep-groupssupport.Tests:
toolbox createlogs thepodman createcommand including--group-add keep-groups.toolbox entersucceeds for a new container where it previously failed with an OCI permission denied on /dev/vboxusb.Fixes: #1348
Related: #1297, #247