From 116b8d2d821daa4e804249bd109819003dd9ef3d Mon Sep 17 00:00:00 2001 From: hagbard Date: Fri, 22 Feb 2019 11:05:10 -0800 Subject: Fixes: T1262 - dhcp requested WAN ip address doesn't get search parameter in /etc/resolv.conf --- src/conf_mode/host_name.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/conf_mode') diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py index 6886324f2..486d1ec8f 100755 --- a/src/conf_mode/host_name.py +++ b/src/conf_mode/host_name.py @@ -86,6 +86,18 @@ def get_resolvers(file): except IOError: return [] +def get_dhcp_search_doms(file): + search_doms = [] + try: + with open(file, 'r') as resolvconf: + for line in resolvconf.readlines(): + line = line.split('#',1)[0]; + line = line.rstrip(); + if 'search' in line: + return re.sub('^search','',line).lstrip().split() + except IOError: + return [] + default_config_data = { 'hostname': 'vyos', 'domain_name': '', @@ -174,6 +186,8 @@ def generate(config): if not config['no_dhcp_ns']: config['nameserver'] += dhcp_ns + for file in glob.glob('/etc/resolv.conf.dhclient-new*'): + config['domain_search'] = get_dhcp_search_doms(file) # We have third party scripts altering /etc/hosts, too. # One example are the DHCP hostname update scripts thus we need to cache in @@ -204,6 +218,7 @@ def generate(config): tmpl = jinja2.Template(config_tmpl_resolv) config_text = tmpl.render(config) + print (config_text) with open(config_file_resolv, 'w') as f: f.write(config_text) -- cgit v1.2.3