summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJernej Jakob <jernej.jakob@gmail.com>2020-06-11 08:39:15 +0200
committerJernej Jakob <jernej.jakob@gmail.com>2020-06-11 22:10:47 +0200
commit8b3f96e58b865bcaf31d7eca80c7e2edaf9482f2 (patch)
treedfa1a3554b1cc313f30b542ee8976e4595e4e845 /src
parentd6d72d37606849607979d410db75d1803f18f159 (diff)
downloadvyos-1x-8b3f96e58b865bcaf31d7eca80c7e2edaf9482f2.tar.gz
vyos-1x-8b3f96e58b865bcaf31d7eca80c7e2edaf9482f2.zip
dns forwarding: T2486: generate recursor conf files
- generate recursor.conf, recursor.conf.lua - if recursor.vyos-hostsd.conf.lua and recursor.forward-zones.conf don't exist, create empty ones (they are/will be generated by vyos-hostsd)
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/dns_forwarding.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/conf_mode/dns_forwarding.py b/src/conf_mode/dns_forwarding.py
index 06bdab12b..1d5ee84a4 100755
--- a/src/conf_mode/dns_forwarding.py
+++ b/src/conf_mode/dns_forwarding.py
@@ -22,12 +22,13 @@ from copy import deepcopy
from vyos.config import Config
from vyos.hostsd_client import Client as hostsd_client
from vyos import ConfigError
-from vyos.util import call
+from vyos.util import call, chown
from vyos.template import render
from vyos import airbag
airbag.enable()
+pdns_rec_user = pdns_rec_group = 'pdns'
pdns_rec_run_dir = '/run/powerdns'
pdns_rec_lua_conf_file = f'{pdns_rec_run_dir}/recursor.conf.lua'
pdns_rec_hostsd_lua_conf_file = f'{pdns_rec_run_dir}/recursor.vyos-hostsd.conf.lua'
@@ -144,7 +145,18 @@ def generate(dns):
if dns is None:
return None
- render(config_file, 'dns-forwarding/recursor.conf.tmpl', dns, trim_blocks=True, user='pdns', group='pdns')
+ render(pdns_rec_config_file, 'dns-forwarding/recursor.conf.tmpl',
+ dns, user=pdns_rec_user, group=pdns_rec_group)
+
+ render(pdns_rec_lua_conf_file, 'dns-forwarding/recursor.conf.lua.tmpl',
+ dns, user=pdns_rec_user, group=pdns_rec_group)
+
+ # if vyos-hostsd didn't create its files yet, create them (empty)
+ for f in [pdns_rec_hostsd_lua_conf_file, pdns_rec_hostsd_zones_file]:
+ with open(f, 'a'):
+ pass
+ chown(f, user=pdns_rec_user, group=pdns_rec_group)
+
return None
def apply(dns):