From: Otto Moerbeek Date: Sat, 16 Sep 2023 12:58:25 +0000 (+0200) Subject: rec: Fix sysconfdir handling in new settings code X-Git-Tag: rec-5.0.0-alpha2~54^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=94ec52cd67180c6b1a3ecf3feb2e2f0d2b5dc27f;p=thirdparty%2Fpdns.git rec: Fix sysconfdir handling in new settings code Partly from @RvdE Fixes #13259 --- diff --git a/pdns/recursordist/docs/settings.rst b/pdns/recursordist/docs/settings.rst index 23682e1a01..89c14d3d46 100644 --- a/pdns/recursordist/docs/settings.rst +++ b/pdns/recursordist/docs/settings.rst @@ -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` diff --git a/pdns/recursordist/docs/yamlsettings.rst b/pdns/recursordist/docs/yamlsettings.rst index ccaa639cc3..5e9baea439 100644 --- a/pdns/recursordist/docs/yamlsettings.rst +++ b/pdns/recursordist/docs/yamlsettings.rst @@ -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` diff --git a/pdns/recursordist/settings/generate.py b/pdns/recursordist/settings/generate.py index 84051fb6cd..5129da3105 100644 --- a/pdns/recursordist/settings/generate.py +++ b/pdns/recursordist/settings/generate.py @@ -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' diff --git a/pdns/recursordist/settings/rust/Makefile.am b/pdns/recursordist/settings/rust/Makefile.am index ac1a27e330..1f95a6f77d 100644 --- a/pdns/recursordist/settings/rust/Makefile.am +++ b/pdns/recursordist/settings/rust/Makefile.am @@ -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 diff --git a/pdns/recursordist/settings/table.py b/pdns/recursordist/settings/table.py index e57ea13940..02dd1ab928 100644 --- a/pdns/recursordist/settings/table.py +++ b/pdns/recursordist/settings/table.py @@ -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``).