From: Otto Moerbeek Date: Fri, 8 Dec 2023 08:38:24 +0000 (+0100) Subject: Use correct compile time values for the NOD and UDR dirs X-Git-Tag: dnsdist-1.9.0-alpha4~11^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb9708c016d72251dc79b34b8972392a5a6542e6;p=thirdparty%2Fpdns.git Use correct compile time values for the NOD and UDR dirs --- diff --git a/pdns/recursordist/Makefile.am b/pdns/recursordist/Makefile.am index 8c482ab8fc..36285b9546 100644 --- a/pdns/recursordist/Makefile.am +++ b/pdns/recursordist/Makefile.am @@ -23,7 +23,7 @@ AM_CXXFLAGS = \ if NOD_ENABLED AM_CXXFLAGS += \ - -DNODCACHEDIR=\"$(nodcachedir)\" + -DNODCACHEDIRNOD=\"$(nodcachedir)/nod\" -DNODCACHEDIRUDR=\"$(nodcachedir)/udr\" endif if FSTRM diff --git a/pdns/recursordist/settings/generate.py b/pdns/recursordist/settings/generate.py index c06923e698..e60dea3272 100644 --- a/pdns/recursordist/settings/generate.py +++ b/pdns/recursordist/settings/generate.py @@ -205,6 +205,9 @@ def quote(arg): """Return a quoted string""" return '"' + arg + '"' +def isEnvVar(name): + return name in ('SYSCONFDIR', 'NODCACHEDIRNOD', 'NODCACHEDIRUDR') + def gen_cxx_defineoldsettings(file, entries): """Generate C++ code to declare old-style settings""" file.write('void pdns::settings::rec::defineOldStyleSettings()\n{\n') @@ -221,7 +224,7 @@ def gen_cxx_defineoldsettings(file, entries): elif entry['type'] == LType.Command: file.write(f" ::arg().setCmd({oldname}, {helptxt});\n") else: - cxxdef = 'SYSCONFDIR' if entry['default'] == 'SYSCONFDIR' else quote(entry['default']) + cxxdef = entry['default'] if isEnvVar(entry['default']) else quote(entry['default']) file.write(f" ::arg().set({oldname}, {helptxt}) = {cxxdef};\n") file.write('}\n\n') @@ -415,7 +418,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' - rustdef = 'env!("SYSCONFDIR")' if entry['default'] == 'SYSCONFDIR' else quote(entry['default']) + defvalue = entry['default'] + rustdef = f'env!("{defvalue}")' if isEnvVar(defvalue) else quote(defvalue) ret += f" String::from({rustdef})\n" ret += '}\n' if rust_type == 'String': diff --git a/pdns/recursordist/settings/rust/Makefile.am b/pdns/recursordist/settings/rust/Makefile.am index 1f95a6f77d..517ca56bac 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 - SYSCONFDIR=$(sysconfdir) $(CARGO) build --release $(RUST_TARGET) + SYSCONFDIR=$(sysconfdir) NODCACHEDIRNOD=$(localstatedir)/nod NODCACHEDIRUDR=$(localstatedir)/udr $(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 75158bc495..2a79096cd4 100644 --- a/pdns/recursordist/settings/table.py +++ b/pdns/recursordist/settings/table.py @@ -1715,7 +1715,7 @@ have no effect unless you remove the existing files. 'section' : 'nod', 'oldname' : 'new-domain-history-dir', 'type' : LType.String, - 'default' : '/usr/local/var/lib/pdns-recursor/nod', + 'default' : 'NODCACHEDIRNOD', 'help' : 'Persist new domain tracking data here to persist between restarts', 'doc' : ''' This setting controls which directory is used to store the on-disk @@ -2358,6 +2358,7 @@ Where to store the control socket and pidfile. The default depends on ``LOCALSTATEDIR`` or the ``--with-socketdir`` setting when building (usually ``/var/run`` or ``/run``). When using :ref:`setting-chroot` the default becomes ``/``. +Defaults to the ``RUNTIME_DIRECTORY`` environment variable when that variable has a value (e.g. under systemd). ''', }, { @@ -2820,7 +2821,7 @@ have no effect unless you remove the existing files. 'name' : 'unique_response_history_dir', 'section' : 'nod', 'type' : LType.String, - 'default' : '/usr/local/var/lib/pdns-recursor/udr', + 'default' : 'NODCACHEDIRUDR', 'help' : 'Persist unique response tracking data here to persist between restarts', 'doc' : ''' This setting controls which directory is used to store the on-disk