From 5c7935057c34cbdb27be3a584d35bff3fcd81202 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 16 Sep 2021 11:01:52 +0200 Subject: Do not allow network modes to be used as network names `podman network create` should not allow users to create networks with a name which is already used for a network mode in `podman run --network`. Fixes #11448 Signed-off-by: Paul Holzinger --- pkg/api/handlers/compat/networks.go | 5 +++-- pkg/api/handlers/libpod/networks.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'pkg/api/handlers') diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index 28727a22b..b1456ed9e 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -224,7 +224,8 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) { // FIXME can we use the IPAM driver and options? } - network, err := runtime.Network().NetworkCreate(network) + ic := abi.ContainerEngine{Libpod: runtime} + newNetwork, err := ic.NetworkCreate(r.Context(), network) if err != nil { utils.InternalServerError(w, err) return @@ -234,7 +235,7 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) { ID string `json:"Id"` Warning []string }{ - ID: network.ID, + ID: newNetwork.ID, } utils.WriteResponse(w, http.StatusCreated, body) } diff --git a/pkg/api/handlers/libpod/networks.go b/pkg/api/handlers/libpod/networks.go index fcd8e0231..1f7f2e26c 100644 --- a/pkg/api/handlers/libpod/networks.go +++ b/pkg/api/handlers/libpod/networks.go @@ -25,7 +25,7 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) { } ic := abi.ContainerEngine{Libpod: runtime} - report, err := ic.Libpod.Network().NetworkCreate(network) + report, err := ic.NetworkCreate(r.Context(), network) if err != nil { utils.InternalServerError(w, err) return -- cgit v1.2.3-54-g00ecf