Fix supplementary groups for machine users - #2125
Open
rupinajay wants to merge 1 commit into
Open
Conversation
Machine users were launched using numeric UID/GID credentials, which prevented the guest runtime from resolving supplementary groups from /etc/group. Use the configured guest username when available so the runtime resolves the user's current supplementary groups, including groups added with usermod -aG. Fixes apple#2108
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2108.
container machine runwas constructing the default machine user as a numeric.id(uid:gid:), which prevented the guest containerization runtime from resolving supplementary groups from/etc/group.Updating
UserSetup.userto return.raw(userString: username)when a username is available allows the existing guest credential-resolution mechanism in the containerization runtime to look up/etc/passwdand/etc/groupinside the guest VM. Consequently, supplementary groups added to the machine user (e.g. viausermod -aG <group> <user>oraddgroup) are dynamically inherited on subsequentcontainer machine runinvocations.This fix uses the existing
ProcessConfiguration.User.rawabstraction designed for username lookup and avoids running/sbin.machine/initas root or introducingsu -l.Testing
Production build:
swift build --target ContainerBuildcompleted successfully.Formatting & linting:
make fmtandgit diff --checkcompleted cleanly with no warnings or errors. Pre-commit hooks installed.Unit test suite:
make testexecuted locally and passed all 757 unit tests (0 failures).Machine integration test:
Added
testMachineUsermodSupplementaryGroupsinTests/IntegrationTests/Machine/TestCLIMachineRuntimeSerial.swift. Verified end-to-end inside an actual VM that supplementary groups created withaddgroupand assigned to the user are dynamically reflected in subsequentcontainer machine runcommands.