diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-06 23:08:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-06 23:08:36 +0200 |
commit | 64b6a197339e0436168e254ef9caf674ee9ff932 (patch) | |
tree | 0a250dd21bb551b94b72f2b768442f9b4e5154a0 /libpod/container_internal_linux.go | |
parent | 843fa25890199c04b8419833d39bdedf4ead391c (diff) | |
parent | 3a0a727110c59332e1a0f5b4a5be311244668a8c (diff) | |
download | podman-64b6a197339e0436168e254ef9caf674ee9ff932.tar.gz podman-64b6a197339e0436168e254ef9caf674ee9ff932.tar.bz2 podman-64b6a197339e0436168e254ef9caf674ee9ff932.zip |
Merge pull request #5478 from giuseppe/auto-userns
userns: support --userns=auto
Diffstat (limited to 'libpod/container_internal_linux.go')
-rw-r--r-- | libpod/container_internal_linux.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index a3f97f2a6..c40ad45b9 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -396,6 +396,20 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { } } + if c.config.IDMappings.AutoUserNs { + if err := g.AddOrReplaceLinuxNamespace(string(spec.UserNamespace), ""); err != nil { + return nil, err + } + g.ClearLinuxUIDMappings() + for _, uidmap := range c.config.IDMappings.UIDMap { + g.AddLinuxUIDMapping(uint32(uidmap.HostID), uint32(uidmap.ContainerID), uint32(uidmap.Size)) + } + g.ClearLinuxGIDMappings() + for _, gidmap := range c.config.IDMappings.GIDMap { + g.AddLinuxGIDMapping(uint32(gidmap.HostID), uint32(gidmap.ContainerID), uint32(gidmap.Size)) + } + } + g.SetRootPath(c.state.Mountpoint) g.AddAnnotation(annotations.Created, c.config.CreatedTime.Format(time.RFC3339Nano)) g.AddAnnotation("org.opencontainers.image.stopSignal", fmt.Sprintf("%d", c.config.StopSignal)) |