diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-09-03 07:02:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-03 07:02:44 -0700 |
commit | a16f63e96e9993a1e2542b6f5c85903cc4659c6e (patch) | |
tree | 2704f163395e48b0aa781aec82fc272f31addb15 /pkg/util/utils.go | |
parent | c03949986feffd489e6fd41538d6a5bda233e850 (diff) | |
parent | 1a24ac7ad63464817a1b3df46ab7da1c0be6c842 (diff) | |
download | podman-a16f63e96e9993a1e2542b6f5c85903cc4659c6e.tar.gz podman-a16f63e96e9993a1e2542b6f5c85903cc4659c6e.tar.bz2 podman-a16f63e96e9993a1e2542b6f5c85903cc4659c6e.zip |
Merge pull request #3926 from giuseppe/add-warning-mismatch-configuration
rootless: detect user namespace configuration changes
Diffstat (limited to 'pkg/util/utils.go')
-rw-r--r-- | pkg/util/utils.go | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go index 3f73639e7..2261934f0 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -3,7 +3,6 @@ package util import ( "fmt" "os" - ouser "os/user" "path/filepath" "strings" "sync" @@ -156,22 +155,15 @@ func ParseIDMapping(mode namespaces.UsernsMode, UIDMapSlice, GIDMapSlice []strin uid := rootless.GetRootlessUID() gid := rootless.GetRootlessGID() - username := os.Getenv("USER") - if username == "" { - user, err := ouser.LookupId(fmt.Sprintf("%d", uid)) - if err == nil { - username = user.Username - } - } - mappings, err := idtools.NewIDMappings(username, username) + uids, gids, err := rootless.GetConfiguredMappings() if err != nil { - return nil, errors.Wrapf(err, "cannot find mappings for user %s", username) + return nil, errors.Wrapf(err, "cannot read mappings") } maxUID, maxGID := 0, 0 - for _, u := range mappings.UIDs() { + for _, u := range uids { maxUID += u.Size } - for _, g := range mappings.GIDs() { + for _, g := range gids { maxGID += g.Size } |