summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-02-01 15:58:27 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2022-02-02 11:01:09 -0500
commita1bc8cb52cefd49e8cc54ae14d1864b8a1ec216e (patch)
tree95d2f1d578949c885acc74abbe17f15efd3cea36
parent4ddc4e79d73eea56929ed522f7d7fce6285a41d4 (diff)
downloadpodman-a1bc8cb52cefd49e8cc54ae14d1864b8a1ec216e.tar.gz
podman-a1bc8cb52cefd49e8cc54ae14d1864b8a1ec216e.tar.bz2
podman-a1bc8cb52cefd49e8cc54ae14d1864b8a1ec216e.zip
Move each search dns to its own line
Alpine does not seem to use search correctly when there are multiple search domains on the same line. It only uses the first with the advent. When podman runs within a separate network we are appending on dns.podman as a search, if you add a search domain, then this causes the local search on network to fail. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
-rw-r--r--cmd/podman/common/netflags.go10
-rw-r--r--pkg/resolvconf/resolvconf.go8
-rw-r--r--test/system/500-networking.bats7
3 files changed, 13 insertions, 12 deletions
diff --git a/cmd/podman/common/netflags.go b/cmd/podman/common/netflags.go
index cfe4956b0..9dfe81d62 100644
--- a/cmd/podman/common/netflags.go
+++ b/cmd/podman/common/netflags.go
@@ -103,7 +103,7 @@ func NetFlagsToNetOptions(opts *entities.NetOptions, flags pflag.FlagSet) (*enti
opts = &entities.NetOptions{}
}
- if flags.Changed("add-hosts") {
+ if flags.Changed("add-host") {
opts.AddHosts, err = flags.GetStringSlice("add-host")
if err != nil {
return nil, err
@@ -178,11 +178,9 @@ func NetFlagsToNetOptions(opts *entities.NetOptions, flags pflag.FlagSet) (*enti
}
}
- if flags.Changed("no-host") {
- opts.NoHosts, err = flags.GetBool("no-hosts")
- if err != nil {
- return nil, err
- }
+ opts.NoHosts, err = flags.GetBool("no-hosts")
+ if err != nil {
+ return nil, err
}
// parse the network only when network was changed
diff --git a/pkg/resolvconf/resolvconf.go b/pkg/resolvconf/resolvconf.go
index f23cd61b0..d7505e049 100644
--- a/pkg/resolvconf/resolvconf.go
+++ b/pkg/resolvconf/resolvconf.go
@@ -221,11 +221,9 @@ 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)
- 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 _, search := range dnsSearch {
+ if _, err := content.WriteString("search " + search + "\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 9f70c1c6c..e54b8d26a 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"]
+ dns_searches = [ "example.com", "test1.com"]
dns_servers = [
"1.1.1.1",
"$searchIP",
@@ -605,9 +605,14 @@ 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