Skip to content

Commit

Permalink
Merge pull request #8960 from giuseppe/bridge-no-post-config
Browse files Browse the repository at this point in the history
network: disallow CNI networks with user namespaces
  • Loading branch information
openshift-merge-robot authored Jan 13, 2021
2 parents b2b1423 + ee68466 commit bbff9c8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/specgen/generate/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ func namespaceOptions(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.
case specgen.Private:
fallthrough
case specgen.Bridge:
if postConfigureNetNS && rootless.IsRootless() {
return nil, errors.New("CNI networks not supported with user namespaces")
}
portMappings, err := createPortMappings(ctx, s, img)
if err != nil {
return nil, err
Expand Down
22 changes: 20 additions & 2 deletions test/e2e/run_networking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ var _ = Describe("Podman run networking", func() {

It("podman run in custom CNI network with --static-ip", func() {
SkipIfRootless("Rootless mode does not support --ip")
netName := "podmantestnetwork"
netName := stringid.GenerateNonCryptoID()
ipAddr := "10.25.30.128"
create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.25.30.0/24", netName})
create.WaitWithDefaultTimeout()
Expand All @@ -639,9 +639,27 @@ var _ = Describe("Podman run networking", func() {
Expect(create.ExitCode()).To(BeZero())
})

It("podman rootless fails custom CNI network with --uidmap", func() {
SkipIfNotRootless("The configuration works with rootless")

netName := stringid.GenerateNonCryptoID()
create := podmanTest.Podman([]string{"network", "create", netName})
create.WaitWithDefaultTimeout()
Expect(create.ExitCode()).To(BeZero())
defer podmanTest.removeCNINetwork(netName)

run := podmanTest.Podman([]string{"run", "--rm", "--net", netName, "--uidmap", "0:1:4096", ALPINE, "true"})
run.WaitWithDefaultTimeout()
Expect(run.ExitCode()).To(Equal(125))

remove := podmanTest.Podman([]string{"network", "rm", netName})
remove.WaitWithDefaultTimeout()
Expect(remove.ExitCode()).To(BeZero())
})

It("podman run with new:pod and static-ip", func() {
SkipIfRootless("Rootless does not support --ip")
netName := "podmantestnetwork2"
netName := stringid.GenerateNonCryptoID()
ipAddr := "10.25.40.128"
podname := "testpod"
create := podmanTest.Podman([]string{"network", "create", "--subnet", "10.25.40.0/24", netName})
Expand Down

0 comments on commit bbff9c8

Please sign in to comment.