diff options
-rw-r--r-- | pkg/resolvconf/resolvconf.go | 8 | ||||
-rw-r--r-- | test/system/500-networking.bats | 7 |
2 files changed, 6 insertions, 9 deletions
diff --git a/pkg/resolvconf/resolvconf.go b/pkg/resolvconf/resolvconf.go index d7505e049..f23cd61b0 100644 --- a/pkg/resolvconf/resolvconf.go +++ b/pkg/resolvconf/resolvconf.go @@ -221,9 +221,11 @@ func GetOptions(resolvConf []byte) []string { // dnsSearch, and an "options" entry for every element in dnsOptions. func Build(path string, dns, dnsSearch, dnsOptions []string) (*File, error) { content := bytes.NewBuffer(nil) - for _, search := range dnsSearch { - if _, err := content.WriteString("search " + search + "\n"); err != nil { - return nil, err + if len(dnsSearch) > 0 { + if searchString := strings.Join(dnsSearch, " "); strings.Trim(searchString, " ") != "." { + if _, err := content.WriteString("search " + searchString + "\n"); err != nil { + return nil, err + } } } for _, dns := range dns { diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index e54b8d26a..9f70c1c6c 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -597,7 +597,7 @@ load helpers searchIP="100.100.100.100" cat >$containersconf <<EOF [containers] - dns_searches = [ "example.com", "test1.com"] + dns_searches = [ "example.com"] dns_servers = [ "1.1.1.1", "$searchIP", @@ -605,14 +605,9 @@ load helpers "8.8.8.8", ] EOF -export searchDNS="search example.com -search test1.com -search a.b" CONTAINERS_CONF=$containersconf run_podman run --rm $IMAGE grep "example.com" /etc/resolv.conf CONTAINERS_CONF=$containersconf run_podman run --rm $IMAGE grep $searchIP /etc/resolv.conf is "$output" "nameserver $searchIP" "Should only be one $searchIP not multiple" - CONTAINERS_CONF=$containersconf run_podman run --dns-search a.b --rm $IMAGE grep search /etc/resolv.conf - is "$output" "$searchDNS" "Searches should be on different lines" } # vim: filetype=sh |