summaryrefslogtreecommitdiff
path: root/src/conf_mode/dns_forwarding.py
diff options
context:
space:
mode:
authorLucas Christian <lucas@lucasec.com>2021-10-12 22:38:06 -0700
committerLucas Christian <lucas@lucasec.com>2021-10-12 22:42:05 -0700
commit9386ac0e3d7f3bd3b566fa67ad42e1be98057274 (patch)
treef27746680129927e4d2a6444cad31d0aa19d15ed /src/conf_mode/dns_forwarding.py
parent36e5f07f8dda51cc5bb0a105077e751f1c851435 (diff)
downloadvyos-1x-9386ac0e3d7f3bd3b566fa67ad42e1be98057274.tar.gz
vyos-1x-9386ac0e3d7f3bd3b566fa67ad42e1be98057274.zip
Fix error when no domains are defined
Diffstat (limited to 'src/conf_mode/dns_forwarding.py')
-rwxr-xr-xsrc/conf_mode/dns_forwarding.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/conf_mode/dns_forwarding.py b/src/conf_mode/dns_forwarding.py
index c2816589c..278fa7226 100755
--- a/src/conf_mode/dns_forwarding.py
+++ b/src/conf_mode/dns_forwarding.py
@@ -74,7 +74,7 @@ def get_config(config=None):
dns['authoritative_zone_errors'] = []
for node in dns['authoritative_domain']:
zonedata = dns['authoritative_domain'][node]
- if ('disable' in zonedata) || (not 'records' in zonedata):
+ if ('disable' in zonedata) or (not 'records' in zonedata):
continue
zone = {
'name': node,
@@ -266,7 +266,7 @@ def verify(dns):
if 'server' not in dns['domain'][domain]:
raise ConfigError(f'No server configured for domain {domain}!')
- if dns['authoritative_zone_errors']:
+ if ('authoritative_zone_errors' in dns) and dns['authoritative_zone_errors']:
for error in dns['authoritative_zone_errors']:
print(error)
raise ConfigError('Invalid authoritative records have been defined')
@@ -292,9 +292,10 @@ def generate(dns):
for zone_filename in glob(f'{pdns_rec_run_dir}/zone.*.conf'):
os.unlink(zone_filename)
- for zone in dns['authoritative_zones']:
- render(zone['file'], 'dns-forwarding/recursor.zone.conf.tmpl',
- zone, user=pdns_rec_user, group=pdns_rec_group)
+ if 'authoritative_zones' in dns:
+ for zone in dns['authoritative_zones']:
+ render(zone['file'], 'dns-forwarding/recursor.zone.conf.tmpl',
+ zone, user=pdns_rec_user, group=pdns_rec_group)
# if vyos-hostsd didn't create its files yet, create them (empty)