]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: fix generation of recursor config if PDNS_RECURSOR_API_KEY is set 15368/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 26 Mar 2025 13:44:43 +0000 (14:44 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 26 Mar 2025 13:44:43 +0000 (14:44 +0100)
Fixes #15367

dockerdata/startup.py

index 114bc8d90275f96b6167bb88444384954f9f5bd1..432b90538dbcb8932272978c6e3f047738045ab5 100755 (executable)
@@ -11,16 +11,19 @@ apiconftemplate = None
 templateroot = '/etc/powerdns/templates.d'
 templatedestination = ''
 args = []
+suffix='.conf' # default suffix, rec uses .yml
 
 if product == 'pdns_recursor':
     args = ['--disable-syslog']
     apienvvar = 'PDNS_RECURSOR_API_KEY'
-    apiconftemplate = """webserver
-api-key={{ apikey }}
-webserver-address=0.0.0.0
-webserver-allow-from=0.0.0.0/0
-webserver-password={{ apikey }}
-    """
+    suffix = '.yml'
+    apiconftemplate = """webservice:
+  webserver: true
+  api_key: '{{ apikey }}'
+  address: 0.0.0.0
+  allow_from: [0.0.0.0/0]
+  password: '{{ apikey }}'
+"""
     templatedestination = '/etc/powerdns/recursor.d'
 elif product == 'pdns_server':
     args = ['--disable-syslog']
@@ -50,7 +53,7 @@ debug = os.getenv("DEBUG_CONFIG", 'no').lower() == 'yes'
 apikey = os.getenv(apienvvar)
 if apikey is not None:
     webserver_conf = jinja2.Template(apiconftemplate).render(apikey=apikey)
-    conffile = os.path.join(templatedestination, '_api.conf')
+    conffile = os.path.join(templatedestination, '_api' + suffix)
     with open(conffile, 'w') as f:
         f.write(webserver_conf)
     if debug:
@@ -63,7 +66,7 @@ if templates is not None:
         with open(os.path.join(templateroot, templateFile + '.j2')) as f:
             template = jinja2.Template(f.read())
         rendered = template.render(os.environ)
-        target = os.path.join(templatedestination, templateFile + '.conf')
+        target = os.path.join(templatedestination, templateFile + suffix)
         with open(target, 'w') as f:
             f.write(rendered)
         if debug: