Skip to content

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

Merged
AkihiroSuda merged 1 commit intorootless-containers:masterfrom
i-do-cpp:fix-dynid-duplicate-ranges
May 29, 2023
Merged

Remove duplicate id ranges returned by getsubu/gid for username/uid#369
AkihiroSuda merged 1 commit intorootless-containers:masterfrom
i-do-cpp:fix-dynid-duplicate-ranges

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.

@AkihiroSuda AkihiroSuda added this to the v1.2.0 milestone May 29, 2023
"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>
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
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.

2 participants