diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2021-08-10 12:55:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-10 12:55:52 +0000 |
commit | e136ad485c626e09e361c37bbd529bb599448ac0 (patch) | |
tree | e3b1c0a96222831481de1358e13dbb086185a9d3 /libpod/options.go | |
parent | 6f61e229911e399d92f8fbe0574654f308f73b39 (diff) | |
parent | 221b1add74e17ded10e8f2f832a53065578aa264 (diff) | |
download | podman-e136ad485c626e09e361c37bbd529bb599448ac0.tar.gz podman-e136ad485c626e09e361c37bbd529bb599448ac0.tar.bz2 podman-e136ad485c626e09e361c37bbd529bb599448ac0.zip |
Merge pull request #10589 from umohnani8/pod-userns
Add support for pod inside of user namespace.
Diffstat (limited to 'libpod/options.go')
-rw-r--r-- | libpod/options.go | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/libpod/options.go b/libpod/options.go index 071b085e7..b94ef88ba 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -956,8 +956,9 @@ func WithUserNSFrom(nsCtr *Container) CtrCreateOption { } ctr.config.UserNsCtr = nsCtr.ID() - ctr.config.IDMappings = nsCtr.config.IDMappings - + if err := JSONDeepCopy(nsCtr.IDMappings(), &ctr.config.IDMappings); err != nil { + return err + } g := generate.Generator{Config: ctr.config.Spec} g.ClearLinuxUIDMappings() @@ -968,7 +969,6 @@ func WithUserNSFrom(nsCtr *Container) CtrCreateOption { 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 } } @@ -2423,6 +2423,24 @@ func WithVolatile() CtrCreateOption { } ctr.config.Volatile = true + + return nil + } +} + +// WithPodUserns sets the userns for the infra container in a pod. +func WithPodUserns(userns specgen.Namespace) PodCreateOption { + return func(pod *Pod) error { + if pod.valid { + return define.ErrPodFinalized + } + + if !pod.config.InfraContainer.HasInfraContainer { + return errors.Wrapf(define.ErrInvalidArg, "cannot configure pod userns as no infra container is being created") + } + + pod.config.InfraContainer.Userns = userns + return nil } } |