summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-10-05 08:34:48 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-10-05 10:13:40 -0400
commit30bd8ed506cd497d7790e6e4cc7258c043cc9315 (patch)
tree1c2b764cc43ae863ad6ea118cb7ed197edefeccb /pkg
parentcaace52d54c846c948c88a62f973f4d11808532e (diff)
downloadpodman-30bd8ed506cd497d7790e6e4cc7258c043cc9315.tar.gz
podman-30bd8ed506cd497d7790e6e4cc7258c043cc9315.tar.bz2
podman-30bd8ed506cd497d7790e6e4cc7258c043cc9315.zip
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>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/util/utils_linux.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/pkg/util/utils_linux.go b/pkg/util/utils_linux.go
index 29b16f765..e4957f442 100644
--- a/pkg/util/utils_linux.go
+++ b/pkg/util/utils_linux.go
@@ -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
}