parent: exclude the own UID/GID from the subid ranges - #623
Open
AbhinavMir wants to merge 2 commits into
Open
Conversation
/etc/subuid and /etc/subgid can contain a range that covers the user's own ID, e.g. `dog:1001:1` for the user `dog` with the UID 1001. The own ID is already mapped to the ID 0 in the user namespace, so such a range makes newuidmap map the same host ID twice. The kernel rejects an overlapping map, and newuidmap fails with "write to uid_map failed: Invalid argument". Remove the own ID from the ranges before the map is built. A range that contains the own ID in the middle is split into two ranges, so no host ID is lost. Signed-off-by: abhinavmir <atg271@gmail.com>
The own UID/GID is silently removed from the subid ranges. An admin cannot see why the container gets fewer sub-IDs than /etc/subuid grants. Print a warning for each range that contains the own ID. The warning names the file, the range, and the own ID, and it says that the own ID is already mapped in the user namespace. The warning appears once per range. `withoutSelfID` stays free of logging: it returns the removed ranges, and the caller prints them. Signed-off-by: abhinavmir <atg271@gmail.com>
Member
|
How to test? |
Author
|
End-to-end on Linux, as a user whose subuid range contains their own UID: Before: newuidmap: write to uid_map failed: Invalid argument. |
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.
#476