mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #83069 from fcgravalos/remove_trailing_dots_from_searches
remove trailing dots from the parsed searches from host resolv.conf
This commit is contained in:
commit
39ba488be3
@ -230,7 +230,11 @@ func parseResolvConf(reader io.Reader) (nameservers []string, searches []string,
|
||||
}
|
||||
}
|
||||
if fields[0] == "search" {
|
||||
searches = fields[1:]
|
||||
// Normalise search fields so the same domain with and without trailing dot will only count once, to avoid hitting search validation limits.
|
||||
searches = []string{}
|
||||
for _, s := range fields[1:] {
|
||||
searches = append(searches, strings.TrimSuffix(s, "."))
|
||||
}
|
||||
}
|
||||
if fields[0] == "options" {
|
||||
options = fields[1:]
|
||||
|
@ -74,6 +74,7 @@ func TestParseResolvConf(t *testing.T) {
|
||||
{"search ", []string{}, []string{}, []string{}, false}, // search empty
|
||||
{"search foo", []string{}, []string{"foo"}, []string{}, false},
|
||||
{"search foo bar", []string{}, []string{"foo", "bar"}, []string{}, false},
|
||||
{"search foo. bar", []string{}, []string{"foo", "bar"}, []string{}, false},
|
||||
{"search foo bar bat\n", []string{}, []string{"foo", "bar", "bat"}, []string{}, false},
|
||||
{"search foo\nsearch bar", []string{}, []string{"bar"}, []string{}, false},
|
||||
{"nameserver 1.2.3.4\nsearch foo bar", []string{"1.2.3.4"}, []string{"foo", "bar"}, []string{}, false},
|
||||
|
Loading…
Reference in New Issue
Block a user