Skip to content

Commit

Permalink
Fix handling of CheckRootlessUIDRange
Browse files Browse the repository at this point in the history
If I have multiple ranges of UIDs specified in the /etc/subuid, this check
blows up and incorrectly blocks the use of --user flag.

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Oct 5, 2020
1 parent caace52 commit 30bd8ed
Showing 1 changed file with 5 additions and 4 deletions.
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)
}
return nil
}

0 comments on commit 30bd8ed

Please sign in to comment.