summaryrefslogtreecommitdiff
path: root/libpod/network/network.go
diff options
context:
space:
mode:
authorjortkoopmans <jort@jabo-solutions.eu>2020-11-30 15:58:23 +0100
committerGitHub <noreply@github.com>2020-11-30 15:58:23 +0100
commit84e8b2afa795ca060f4d2c5206f47d320292ed9b (patch)
treeea0e985d3f50d389b33fdb403d240e817251fd8c /libpod/network/network.go
parent5cfbe0b78e3672dd67cd028b85d816fc19d6a614 (diff)
parentfc85ec942ee3273f5ad56381a0f6b9e78aea59bf (diff)
downloadpodman-84e8b2afa795ca060f4d2c5206f47d320292ed9b.tar.gz
podman-84e8b2afa795ca060f4d2c5206f47d320292ed9b.tar.bz2
podman-84e8b2afa795ca060f4d2c5206f47d320292ed9b.zip
Merge branch 'master' into patch-1
Diffstat (limited to 'libpod/network/network.go')
-rw-r--r--libpod/network/network.go28
1 files changed, 17 insertions, 11 deletions
diff --git a/libpod/network/network.go b/libpod/network/network.go
index 7327a1a7d..0febb52f6 100644
--- a/libpod/network/network.go
+++ b/libpod/network/network.go
@@ -10,6 +10,7 @@ import (
"github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v2/libpod/define"
+ "github.com/containers/podman/v2/pkg/rootless"
"github.com/containers/podman/v2/pkg/util"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -181,21 +182,26 @@ func RemoveNetwork(config *config.Config, name string) error {
// Before we delete the configuration file, we need to make sure we can read and parse
// it to get the network interface name so we can remove that too
interfaceName, err := GetInterfaceNameFromConfig(cniPath)
- if err != nil {
- return errors.Wrapf(err, "failed to find network interface name in %q", cniPath)
- }
- liveNetworkNames, err := GetLiveNetworkNames()
- if err != nil {
- return errors.Wrapf(err, "failed to get live network names")
- }
- if util.StringInSlice(interfaceName, liveNetworkNames) {
- if err := RemoveInterface(interfaceName); err != nil {
- return errors.Wrapf(err, "failed to delete the network interface %q", interfaceName)
+ if err == nil {
+ // Don't try to remove the network interface if we are not root
+ if !rootless.IsRootless() {
+ liveNetworkNames, err := GetLiveNetworkNames()
+ if err != nil {
+ return errors.Wrapf(err, "failed to get live network names")
+ }
+ if util.StringInSlice(interfaceName, liveNetworkNames) {
+ if err := RemoveInterface(interfaceName); err != nil {
+ return errors.Wrapf(err, "failed to delete the network interface %q", interfaceName)
+ }
+ }
}
+ } else if err != ErrNoSuchNetworkInterface {
+ // Don't error if we couldn't find the network interface name
+ return err
}
// Remove the configuration file
if err := os.Remove(cniPath); err != nil {
- return errors.Wrapf(err, "failed to remove network configuration file %q", cniPath)
+ return errors.Wrap(err, "failed to remove network configuration")
}
return nil
}