diff options
author | Robert Schweikert <rjschwei@suse.com> | 2019-01-23 22:35:32 +0000 |
---|---|---|
committer | Server Team CI Bot <josh.powers+server-team-bot@canonical.com> | 2019-01-23 22:35:32 +0000 |
commit | b74ebca563a21332b29482c8029e7908f60225a4 (patch) | |
tree | f1d6abf264583b77fbab2de41f68a17b99403003 /cloudinit/net/sysconfig.py | |
parent | 3861102fcaf47a882516d8b6daab518308eb3086 (diff) | |
download | vyos-cloud-init-b74ebca563a21332b29482c8029e7908f60225a4.tar.gz vyos-cloud-init-b74ebca563a21332b29482c8029e7908f60225a4.zip |
net/sysconfig: do not write a resolv.conf file with only the header.
Writing the file with no dns information may prevent distro tools
from writing a resolv.conf file with dns information obtained from
a dhcp server.
Diffstat (limited to 'cloudinit/net/sysconfig.py')
-rw-r--r-- | cloudinit/net/sysconfig.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index ae41f7b3..fd8e5010 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -557,6 +557,8 @@ class Renderer(renderer.Renderer): content.add_nameserver(nameserver) for searchdomain in network_state.dns_searchdomains: content.add_search_domain(searchdomain) + if not str(content): + return None header = _make_header(';') content_str = str(content) if not content_str.startswith(header): @@ -666,7 +668,8 @@ class Renderer(renderer.Renderer): dns_path = util.target_path(target, self.dns_path) resolv_content = self._render_dns(network_state, existing_dns_path=dns_path) - util.write_file(dns_path, resolv_content, file_mode) + if resolv_content: + util.write_file(dns_path, resolv_content, file_mode) if self.networkmanager_conf_path: nm_conf_path = util.target_path(target, self.networkmanager_conf_path) |