summaryrefslogtreecommitdiff
path: root/pkg/resolvconf/resolvconf.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-12-06 03:20:16 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2018-12-06 03:20:16 -0500
commit40678b119c0186bf7c56dc09d131e697c55cb9fd (patch)
treedfb1cc13b0bdc1abad1ada51970bf0ac03d46810 /pkg/resolvconf/resolvconf.go
parentdcb68d1aa24b2dd00d793f5a66f96cc5403b43c3 (diff)
parent75b19ca8abe1957f3c48035767960a6b20c10519 (diff)
downloadpodman-40678b119c0186bf7c56dc09d131e697c55cb9fd.tar.gz
podman-40678b119c0186bf7c56dc09d131e697c55cb9fd.tar.bz2
podman-40678b119c0186bf7c56dc09d131e697c55cb9fd.zip
Merge branch 'master' of github.com:containers/libpod into vendor
Diffstat (limited to 'pkg/resolvconf/resolvconf.go')
-rw-r--r--pkg/resolvconf/resolvconf.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/pkg/resolvconf/resolvconf.go b/pkg/resolvconf/resolvconf.go
index fccd60093..e85bcb377 100644
--- a/pkg/resolvconf/resolvconf.go
+++ b/pkg/resolvconf/resolvconf.go
@@ -103,13 +103,21 @@ func GetLastModified() *File {
}
// FilterResolvDNS cleans up the config in resolvConf. It has two main jobs:
-// 1. It looks for localhost (127.*|::1) entries in the provided
+// 1. If a netns is enabled, it looks for localhost (127.*|::1) entries in the provided
// resolv.conf, removing local nameserver entries, and, if the resulting
// cleaned config has no defined nameservers left, adds default DNS entries
// 2. Given the caller provides the enable/disable state of IPv6, the filter
// code will remove all IPv6 nameservers if it is not enabled for containers
//
-func FilterResolvDNS(resolvConf []byte, ipv6Enabled bool) (*File, error) {
+func FilterResolvDNS(resolvConf []byte, ipv6Enabled bool, netnsEnabled bool) (*File, error) {
+ // If we're using the host netns, we have nothing to do besides hash the file.
+ if !netnsEnabled {
+ hash, err := ioutils.HashData(bytes.NewReader(resolvConf))
+ if err != nil {
+ return nil, err
+ }
+ return &File{Content: resolvConf, Hash: hash}, nil
+ }
cleanedResolvConf := localhostNSRegexp.ReplaceAll(resolvConf, []byte{})
// if IPv6 is not enabled, also clean out any IPv6 address nameserver
if !ipv6Enabled {