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

Remove duplicate id ranges returned by getsubu/gid for username/uid #369

Merged

Conversation

i-do-cpp
Copy link
Contributor

@i-do-cpp i-do-cpp commented May 28, 2023

In LDAP-based environments both getsubids myusername and getsubids 1234 (where id myusername equals to 1234) can return exactly the same subuid ranges. This happens when one of /etc/subuid or nss returns mappings for both the user id and the user name. Both newgidmap and newuidmap fail when the parameters contain duplicate ranges.

This PR fixes the problem by removing duplicates from the list of subid mappings in dynidtools.
idtools (/etc/subuid handling) is left untouched.

@i-do-cpp i-do-cpp force-pushed the fix-dynid-duplicate-ranges branch from bbc1b27 to da8db9a Compare May 28, 2023 10:23
@AkihiroSuda AkihiroSuda added this to the v1.2.0 milestone May 29, 2023
@@ -14,6 +14,18 @@ import (
"github.com/sirupsen/logrus"
)

func withoutDuplicates[T idtools.SubIDRange](sliceList []T) []T {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need T?

Signed-off-by: i-do-cpp <62053234+i-do-cpp@users.noreply.github.com>
@i-do-cpp i-do-cpp force-pushed the fix-dynid-duplicate-ranges branch from da8db9a to 15e2415 Compare May 29, 2023 12:31
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit 40f1843 into rootless-containers:master May 29, 2023
5 checks passed
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

2 participants