net/dns/resolvd: properly handle not having "search" entries

This prevents adding an empty "search" line when no search domains are set.

Signed-off-by: Aaron Bieber <aaron@bolddaemon.com>
This commit is contained in:
Aaron Bieber 2022-01-28 05:18:58 -07:00 committed by Brad Fitzpatrick
parent bd90781b34
commit e5cd765e00

View File

@ -60,7 +60,9 @@ func (m *resolvdManager) SetDNS(config OSConfig) error {
newSearch = append(newSearch, s.WithoutTrailingDot())
}
newResolvConf = append(newResolvConf, []byte(strings.Join(newSearch, " "))...)
if len(newSearch) > 1 {
newResolvConf = append(newResolvConf, []byte(strings.Join(newSearch, " "))...)
}
err = m.fs.WriteFile(resolvConf, newResolvConf, 0644)
if err != nil {