diff options
author | Christian Poessinger <christian@poessinger.com> | 2018-04-15 18:54:31 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2018-04-15 18:54:31 +0200 |
commit | ded491574ed5d65e34368b979578a1e71f9d89fd (patch) | |
tree | 5711b42b6a8ed6529286799a1ed9bf8a0809c51c /src/conf-mode/vyos-config-dns-forwarding.py | |
parent | af31124beacb0c9f4c5798236376b0298a79f1fc (diff) | |
download | vyos-1x-ded491574ed5d65e34368b979578a1e71f9d89fd.tar.gz vyos-1x-ded491574ed5d65e34368b979578a1e71f9d89fd.zip |
dns-forwarding.py: be more tolerant on missconfigured DHCP source
If a user configures 'set service dns forwarding dhcp <if>' and <if> is not a
DHCP interface, this won't corrupt the recursor.conf.
The missconfiguration is simply ignored.
Diffstat (limited to 'src/conf-mode/vyos-config-dns-forwarding.py')
-rwxr-xr-x | src/conf-mode/vyos-config-dns-forwarding.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/conf-mode/vyos-config-dns-forwarding.py b/src/conf-mode/vyos-config-dns-forwarding.py index 7a8aed75d..537e47d85 100755 --- a/src/conf-mode/vyos-config-dns-forwarding.py +++ b/src/conf-mode/vyos-config-dns-forwarding.py @@ -37,8 +37,8 @@ def get_resolvers(file): if 'nameserver' in line: resolvers.append(line.split()[1]) return resolvers - except IOError as error: - return error.strerror + except IOError: + return [] def get_config(): dns = {} @@ -57,11 +57,12 @@ def get_config(): interfaces = conf.return_values('dhcp') for interface in interfaces: resolvers = get_resolvers("/etc/resolv.conf.dhclient-new-{0}".format(interface)) - dhcp = { - "interface": interface, - "resolvers": resolvers - } - dns['dhcp'].append(dhcp) + if len(resolvers) > 0: + dhcp = { + "interface": interface, + "resolvers": resolvers + } + dns['dhcp'].append(dhcp) if conf.exists('domain'): dns.setdefault('domain', []) |