Merge pull request #18601 from giuseppe/block-PODMAN_USERNS-and---pod

run: block PODMAN_USERNS and --pod
This commit is contained in:
OpenShift Merge Robot
2023-05-17 14:15:53 -04:00
committed by GitHub
3 changed files with 9 additions and 4 deletions

View File

@ -4,7 +4,7 @@
####> are applicable to all of those. ####> are applicable to all of those.
#### **--userns**=*mode* #### **--userns**=*mode*
Set the user namespace mode for the container. It defaults to the **PODMAN_USERNS** environment variable. An empty value ("") means user namespaces are disabled unless an explicit mapping is set with the **--uidmap** and **--gidmap** options. Set the user namespace mode for the container. It defaults to the **PODMAN_USERNS** environment variable unless `--pod` is specified. An empty value ("") means user namespaces are disabled unless an explicit mapping is set with the **--uidmap** and **--gidmap** options.
This option is incompatible with **--gidmap**, **--uidmap**, **--subuidname** and **--subgidname**. This option is incompatible with **--gidmap**, **--uidmap**, **--subuidname** and **--subgidname**.

View File

@ -220,9 +220,9 @@ func setNamespaces(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions)
return err return err
} }
} }
userns := os.Getenv("PODMAN_USERNS") userns := c.UserNS
if c.UserNS != "" { if userns == "" && c.Pod == "" {
userns = c.UserNS userns = os.Getenv("PODMAN_USERNS")
} }
// userns must be treated differently // userns must be treated differently
if userns != "" { if userns != "" {

View File

@ -395,6 +395,11 @@ var _ = Describe("Podman UserNS support", func() {
inspect.WaitWithDefaultTimeout() inspect.WaitWithDefaultTimeout()
Expect(inspect.OutputToString()).To(Not(Equal("<nil>"))) Expect(inspect.OutputToString()).To(Not(Equal("<nil>")))
// --pod should work.
result = podmanTest.Podman([]string{"create", "--pod=new:new-pod", ALPINE, "true"})
result.WaitWithDefaultTimeout()
Expect(result).Should(Exit(0))
if IsRemote() { if IsRemote() {
podmanTest.RestartRemoteService() podmanTest.RestartRemoteService()
} }