]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Fix sysconfdir handling in new settings code
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Sat, 16 Sep 2023 12:58:25 +0000 (14:58 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 19 Sep 2023 07:10:42 +0000 (09:10 +0200)
Partly from @RvdE
Fixes #13259

pdns/recursordist/docs/settings.rst
pdns/recursordist/docs/yamlsettings.rst
pdns/recursordist/settings/generate.py
pdns/recursordist/settings/rust/Makefile.am
pdns/recursordist/settings/table.py

index 23682e1a01f82b18807d34078ddec68c200b8ae1..89c14d3d46cec9c559b352f676da1e3aa9948c92 100644 (file)
@@ -363,7 +363,7 @@ Time to wait for data from TCP clients.
 ~~~~~~~~~~~~~~
 
 -  String
--  Default: /etc/powerdns
+-  Default: SYSCONFDIR
 
 - YAML setting: :ref:`setting-yaml-recursor.config_dir`
 
index ccaa639cc3dc7e298eff5f5e90073510e4e711f2..5e9baea4398cfd428aff1d151f2eb3da5fa9735d 100644 (file)
@@ -2030,7 +2030,7 @@ Either do not ``chroot`` on these systems or set the 'Type' of this service to '
 ^^^^^^^^^^^^^^^^^^^^^^^
 
 -  String
--  Default: ``/etc/powerdns``
+-  Default: ``SYSCONFDIR``
 
 - Old style setting: :ref:`setting-config-dir`
 
index 84051fb6cd595709fba2e10af0947455e2195c34..5129da3105f99275093a7d096ec7bffcbc2a8796 100644 (file)
@@ -209,7 +209,8 @@ def gen_cxx_defineoldsettings(file, entries):
         elif entry['type'] == LType.Command:
             file.write(f"  ::arg().setCmd({oldname}, {helptxt});\n")
         else:
-            file.write(f"  ::arg().set({oldname}, {helptxt}) = {quote(entry['default'])};\n")
+            cxxdef = 'SYSCONFDIR' if entry['default'] == 'SYSCONFDIR' else quote(entry['default'])
+            file.write(f"  ::arg().set({oldname}, {helptxt}) = {cxxdef};\n")
     file.write('}\n\n')
 
 def gen_cxx_oldstylesettingstobridgestruct(file, entries):
@@ -402,7 +403,8 @@ def gen_rust_default_functions(entry, name, rust_type):
         return gen_rust_authzonevec_default_functions(name)
     ret = f'// DEFAULT HANDLING for {name}\n'
     ret += f'fn default_value_{name}() -> {rust_type} {{\n'
-    ret += f"    String::from({quote(entry['default'])})\n"
+    rustdef = 'env!("SYSCONFDIR")' if entry['default'] == 'SYSCONFDIR' else quote(entry['default'])
+    ret += f"    String::from({rustdef})\n"
     ret += '}\n'
     if rust_type == 'String':
         rust_type = 'str'
index ac1a27e330ff5fc9b4de53076dc912fa645d508e..1f95a6f77de3911cb3bbd45fdac91e361f750a92 100644 (file)
@@ -11,7 +11,7 @@ EXTRA_DIST = \
 
 # should actually end up in a target specific dir...
 libsettings.a lib.rs.h: src/bridge.rs src/lib.rs src/helpers.rs Cargo.toml Cargo.lock build.rs
-       $(CARGO) build --release $(RUST_TARGET)
+       SYSCONFDIR=$(sysconfdir) $(CARGO) build --release $(RUST_TARGET)
        cp target/$(RUSTC_TARGET_ARCH)/release/libsettings.a libsettings.a
        cp target/$(RUSTC_TARGET_ARCH)/cxxbridge/settings/src/lib.rs.h lib.rs.h
        cp target/$(RUSTC_TARGET_ARCH)/cxxbridge/rust/cxx.h cxx.h
index e57ea13940b1a27d016113a370cbe26eada23592..02dd1ab928980a217618d5044155b1836be1900b 100644 (file)
@@ -379,7 +379,7 @@ EMPTY?  '''
         'name' : 'config_dir',
         'section' : 'recursor',
         'type' : LType.String,
-        'default' : '/etc/powerdns',
+        'default' : 'SYSCONFDIR',
         'help' : 'Location of configuration directory (recursor.conf)',
         'doc' : '''
 Location of configuration directory (``recursor.conf``).