Skip to content

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

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

AkihiroSuda merged 1 commit into
rootless-containers:masterfrom
i-do-cpp:fix-dynid-duplicate-ranges

Conversation

@i-do-cpp

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

Copy link
Copy Markdown
Contributor

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
Comment thread pkg/parent/dynidtools/dynidtools.go Outdated
"github.com/sirupsen/logrus"
)

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

Copy link
Copy Markdown
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>

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

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
@ghost ghost mentioned this pull request Jun 6, 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