diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-12-06 12:02:33 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-12-06 12:02:33 +0100 |
commit | 8d20ad4a909ec5e512ca17965a5bbbc7f33c24b6 (patch) | |
tree | 310998e53400da1a1ed07bac46c7abf7fb3a28f4 | |
parent | e46def834483ebd76282965a86e875c4cfacebca (diff) | |
download | vyos-1x-8d20ad4a909ec5e512ca17965a5bbbc7f33c24b6.tar.gz vyos-1x-8d20ad4a909ec5e512ca17965a5bbbc7f33c24b6.zip |
dhcp: T3113: bugfix for multiple domain-search entries
While rewriting the code to get_config_dict() in commit 84b7ade286 ("dhcp: T3100:
migrate server configuration to get_config_dict()") a regression was added not
properly joining strings when multiple search-somains had been given.
Wrong: domain-search "domain1, domain2";
Correct: domain-search "domain1", "domain2";
-rw-r--r-- | data/templates/dhcp-server/dhcpd.conf.tmpl | 5 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_service_dhcp-server.py | 10 |
2 files changed, 8 insertions, 7 deletions
diff --git a/data/templates/dhcp-server/dhcpd.conf.tmpl b/data/templates/dhcp-server/dhcpd.conf.tmpl index e8425aa6c..bcf425abd 100644 --- a/data/templates/dhcp-server/dhcpd.conf.tmpl +++ b/data/templates/dhcp-server/dhcpd.conf.tmpl @@ -4,7 +4,6 @@ # https://www.isc.org/wp-content/uploads/2017/08/dhcp43options.html # # log-facility local7; - {% if hostfile_update is defined %} on release { set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name); @@ -13,7 +12,6 @@ on release { set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!"); execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "release", ClientName, ClientIp, ClientMac, ClientDomain); } - on expiry { set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name); set ClientIp = binary-to-ascii(10, 8, ".",leased-address); @@ -25,7 +23,6 @@ on expiry { {{ 'use-host-decl-names on;' if host_decl_name is defined }} ddns-update-style {{ 'interim' if dynamic_dns_update is defined else 'none' }}; - option rfc3442-static-route code 121 = array of integer 8; option windows-static-route code 249 = array of integer 8; option wpad-url code 252 = text; @@ -87,7 +84,7 @@ shared-network {{ network | replace('_','-') }} { option domain-name-servers {{ subnet_config.dns_server | join(', ') }}; {% endif %} {% if subnet_config.domain_search is defined and subnet_config.domain_search is not none %} - option domain-search "{{ subnet_config.domain_search | join(', ') }}"; + option domain-search "{{ subnet_config.domain_search | join('", "') }}"; {% endif %} {% if subnet_config.ntp_server is defined and subnet_config.ntp_server is not none %} option ntp-servers {{ subnet_config.ntp_server | join(', ') }}; diff --git a/smoketest/scripts/cli/test_service_dhcp-server.py b/smoketest/scripts/cli/test_service_dhcp-server.py index 2ee26c8bb..a86b99db4 100755 --- a/smoketest/scripts/cli/test_service_dhcp-server.py +++ b/smoketest/scripts/cli/test_service_dhcp-server.py @@ -101,7 +101,7 @@ class TestServiceDHCPServer(unittest.TestCase): smtp_server = '1.2.3.4' time_server = '4.3.2.1' tftp_server = 'tftp.vyos.io' - search_domain = 'foo.vyos.net' + search_domains = ['foo.vyos.net', 'bar.vyos.net'] bootfile_name = 'vyos' bootfile_server = '192.0.2.1' wpad = 'http://wpad.vyos.io/foo/bar' @@ -118,7 +118,8 @@ class TestServiceDHCPServer(unittest.TestCase): self.session.set(pool + ['pop-server', smtp_server]) self.session.set(pool + ['time-server', time_server]) self.session.set(pool + ['tftp-server-name', tftp_server]) - self.session.set(pool + ['domain-search', search_domain]) + for search in search_domains: + self.session.set(pool + ['domain-search', search]) self.session.set(pool + ['bootfile-name', bootfile_name]) self.session.set(pool + ['bootfile-server', bootfile_server]) self.session.set(pool + ['wpad-url', wpad]) @@ -168,7 +169,10 @@ class TestServiceDHCPServer(unittest.TestCase): self.assertIn(f'option domain-name-servers {dns_1}, {dns_2};', config) self.assertIn(f'option routers {router};', config) self.assertIn(f'option domain-name "{domain_name}";', config) - self.assertIn(f'option domain-search "{search_domain}";', config) + + search = '"' + ('", "').join(search_domains) + '"' + self.assertIn(f'option domain-search {search};', config) + self.assertIn(f'option ip-forwarding true;', config) self.assertIn(f'option smtp-server {smtp_server};', config) self.assertIn(f'option pop-server {smtp_server};', config) |