summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-09-10 15:16:51 -0400
committerGitHub <noreply@github.com>2020-09-10 15:16:51 -0400
commit41bd5e298a8d16d1d43f5e9d5a25e5ec6436e87b (patch)
tree310d0e3ebd97035958096ee54ba5fb67b3e2c25e /libpod/options.go
parent89a348346df1f87a4cf8bc90c7f047f8ac6a074f (diff)
parent686f6eccee0c20e1dc0789bde76a38cba7535e8e (diff)
downloadpodman-41bd5e298a8d16d1d43f5e9d5a25e5ec6436e87b.tar.gz
podman-41bd5e298a8d16d1d43f5e9d5a25e5ec6436e87b.tar.bz2
podman-41bd5e298a8d16d1d43f5e9d5a25e5ec6436e87b.zip
Merge pull request #7578 from giuseppe/join-userns-reuse-mappings
libpod: read mappings when joining a container userns
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go
index dccbb8741..7eec530ea 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -18,6 +18,7 @@ import (
"github.com/containers/storage"
"github.com/containers/storage/pkg/idtools"
"github.com/cri-o/ocicni/pkg/ocicni"
+ "github.com/opencontainers/runtime-tools/generate"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -897,6 +898,17 @@ func WithUserNSFrom(nsCtr *Container) CtrCreateOption {
ctr.config.UserNsCtr = nsCtr.ID()
ctr.config.IDMappings = nsCtr.config.IDMappings
+ g := generate.NewFromSpec(ctr.config.Spec)
+
+ g.ClearLinuxUIDMappings()
+ for _, uidmap := range nsCtr.config.IDMappings.UIDMap {
+ g.AddLinuxUIDMapping(uint32(uidmap.HostID), uint32(uidmap.ContainerID), uint32(uidmap.Size))
+ }
+ g.ClearLinuxGIDMappings()
+ for _, gidmap := range nsCtr.config.IDMappings.GIDMap {
+ g.AddLinuxGIDMapping(uint32(gidmap.HostID), uint32(gidmap.ContainerID), uint32(gidmap.Size))
+ }
+ ctr.config.IDMappings = nsCtr.config.IDMappings
return nil
}
}