From 70623790d07a0de6dbd9a4e0d8e665298c73f04c Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 2 Feb 2022 18:42:35 +0100 Subject: [PATCH] Revert "Move each search dns to its own line" This reverts commit a1bc8cb52cefd49e8cc54ae14d1864b8a1ec216e. Please see resolv.conf(5) search domains must be on the same line. If you use multiple seach key words only the last one is used. I tested this with alpine and it works correctly when they are on the same line so I am not sure what issues Dan had with it but this is not correct. Signed-off-by: Paul Holzinger --- pkg/resolvconf/resolvconf.go | 8 +++++--- 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 d7505e049a..f23cd61b07 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 e54b8d26a6..9f70c1c6ca 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 <