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

Fix handling of CheckRootlessUIDRange #7919

Merged
merged 1 commit into from
Oct 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pkg/util/utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ func CheckRootlessUIDRange(uid int) error {
if err != nil {
return err
}
total := 0
for _, u := range uids {
// add 1 since we also map in the user's own UID
if uid > u.Size+1 {
return errors.Errorf("requested user's UID %d is too large for the rootless user namespace", uid)
}
total += u.Size
}
if uid > total {
return errors.Errorf("requested user's UID %d is too large for the rootless user namespace", uid)
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to keep this if statement inside of the for still to have it break ASAP?

Copy link
Member Author

Choose a reason for hiding this comment

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

No because we need to add all of the ranges together to see if UID is less then. We could check on each loop, I guess to see if it is less then, but that seems to be an optimization with little value. There are not going to be large numbers of ranges in the /etc/subuid file.

}
return nil
}