Skip to content

Commit

Permalink
Revert "Move each search dns to its own line"
Browse files Browse the repository at this point in the history
This reverts commit a1bc8cb.
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 <[email protected]>
  • Loading branch information
Luap99 authored and mheon committed Feb 3, 2022
1 parent 48f10e1 commit 7062379
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 5 additions & 3 deletions pkg/resolvconf/resolvconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions test/system/500-networking.bats
Original file line number Diff line number Diff line change
Expand Up @@ -597,22 +597,17 @@ 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",
"1.0.0.1",
"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

0 comments on commit 7062379

Please sign in to comment.