mirror of
https://github.com/containers/podman.git
synced 2025-06-27 05:26:50 +08:00
Fix handling of CheckRootlessUIDRange
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 <dwalsh@redhat.com>
This commit is contained in:
@ -60,11 +60,12 @@ func CheckRootlessUIDRange(uid int) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
total := 0
|
||||||
for _, u := range uids {
|
for _, u := range uids {
|
||||||
// add 1 since we also map in the user's own UID
|
total += u.Size
|
||||||
if uid > u.Size+1 {
|
|
||||||
return errors.Errorf("requested user's UID %d is too large for the rootless user namespace", uid)
|
|
||||||
}
|
}
|
||||||
|
if uid > total {
|
||||||
|
return errors.Errorf("requested user's UID %d is too large for the rootless user namespace", uid)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user