Only force DNS handling if there is DNS data
Currently Glean rewrites resolve.conf and disables DNS handling in NetworkManager even if there is no DNS information provided, making it impossible to e.g. build DNS servers into the image. This behavior also does not play way with the --no-dhcp-fallback flag. Change-Id: I59cf2ece4e665d569d1db08d1df19b0892c6ba9d
This commit is contained in:
parent
a469de6eea
commit
ab686d9749
14
glean/cmd.py
14
glean/cmd.py
|
@ -26,6 +26,7 @@ import subprocess
|
|||
import sys
|
||||
import time
|
||||
|
||||
from glean import install
|
||||
from glean import systemlock
|
||||
from glean import utils
|
||||
from glean._vendor import distro
|
||||
|
@ -959,7 +960,10 @@ def write_debian_interfaces(interfaces, sys_interfaces, args):
|
|||
return files_to_write
|
||||
|
||||
|
||||
def write_dns_info(dns_servers):
|
||||
def write_dns_info(dns_servers, args):
|
||||
# exit early if there are no DNS servers
|
||||
if not dns_servers:
|
||||
return {}
|
||||
# will fail on non-systemd systems (what we want)
|
||||
# will exit 1 if not enabled (what we want)
|
||||
# will exit 0 if enabled (or indirectly enabled)
|
||||
|
@ -994,6 +998,12 @@ def write_dns_info(dns_servers):
|
|||
resolved_conf_fd.close()
|
||||
# add the config to files to be written
|
||||
resolve_confs['/etc/systemd/resolved.conf'] = resolved_conf_output
|
||||
# make sure NetworkManager does not override our configuration
|
||||
if args.use_nm:
|
||||
install.install(
|
||||
'nm-no-resolv-handling.conf',
|
||||
'/etc/NetworkManager/conf.d/nm-no-resolv-handling.conf',
|
||||
mode='0644')
|
||||
return resolve_confs
|
||||
|
||||
|
||||
|
@ -1390,7 +1400,7 @@ def write_network_info_from_config_drive(args):
|
|||
|
||||
dns = {}
|
||||
if not args.skip_dns:
|
||||
dns = write_dns_info(get_dns_from_config_drive(network_info))
|
||||
dns = write_dns_info(get_dns_from_config_drive(network_info), args)
|
||||
interfaces = get_config_drive_interfaces(network_info)
|
||||
if 'meta' in meta_data and 'glean_ignore_interfaces' in meta_data['meta']:
|
||||
# Force DHCP to be used ignoring the interface information.
|
||||
|
|
|
@ -152,12 +152,6 @@ def main():
|
|||
'/etc/udev/rules.d/99-glean.rules',
|
||||
mode='0644')
|
||||
if args.use_nm:
|
||||
# glean handles resolv.conf, so this turns off nm touching
|
||||
# it
|
||||
install('nm-no-resolv-handling.conf',
|
||||
'/etc/NetworkManager/conf.d/nm-no-resolv-handling.conf',
|
||||
mode='0644')
|
||||
|
||||
# NetworkManager has a "after" network-pre, and
|
||||
# glean@<interface> services have a "before". However, if
|
||||
# udev has not yet triggered and started the glean
|
||||
|
|
Loading…
Reference in New Issue