mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Merge pull request #17175 from Luap99/default-invalid-netname
network create: do not allow `default` as name
This commit is contained in:
@ -151,7 +151,7 @@ func (ic *ContainerEngine) NetworkRm(ctx context.Context, namesOrIds []string, o
|
||||
|
||||
func (ic *ContainerEngine) NetworkCreate(ctx context.Context, network types.Network, createOptions *types.NetworkCreateOptions) (*types.Network, error) {
|
||||
// TODO (5.0): Stop accepting "pasta" as value here
|
||||
if util.StringInSlice(network.Name, []string{"none", "host", "bridge", "private", "slirp4netns", "container", "ns"}) {
|
||||
if util.StringInSlice(network.Name, []string{"none", "host", "bridge", "private", "slirp4netns", "container", "ns", "default"}) {
|
||||
return nil, fmt.Errorf("cannot create network with name %q because it conflicts with a valid network mode", network.Name)
|
||||
}
|
||||
network, err := ic.Libpod.Network().NetworkCreate(network, createOptions)
|
||||
|
@ -366,7 +366,7 @@ var _ = Describe("Podman network create", func() {
|
||||
})
|
||||
|
||||
It("podman network create with invalid name", func() {
|
||||
for _, name := range []string{"none", "host", "bridge", "private", "slirp4netns", "container", "ns"} {
|
||||
for _, name := range []string{"none", "host", "bridge", "private", "slirp4netns", "container", "ns", "default"} {
|
||||
nc := podmanTest.Podman([]string{"network", "create", name})
|
||||
nc.WaitWithDefaultTimeout()
|
||||
Expect(nc).To(Exit(125))
|
||||
|
Reference in New Issue
Block a user