Skip to content

Commit

Permalink
Merge pull request #13276 from omoerbeek/rec-conf-dir
Browse files Browse the repository at this point in the history
rec: Fix sysconfdir handling in new settings code
  • Loading branch information
omoerbeek authored Sep 20, 2023
2 parents 8f31dec + bc3700f commit f0d95e2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions pdns/recursordist/docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,13 @@ Time to wait for data from TCP clients.
~~~~~~~~~~~~~~

- String
- Default: /etc/powerdns
- Default: SYSCONFDIR

- YAML setting: :ref:`setting-yaml-recursor.config_dir`

Location of configuration directory (``recursor.conf``).
Location of configuration directory (where ``recursor.conf`` or ``recursor.yml`` is stored).
Usually ``/etc/powerdns``, but this depends on ``SYSCONFDIR`` during compile-time.
Use default or set on command line.

.. _setting-config-name:

Expand Down
5 changes: 3 additions & 2 deletions pdns/recursordist/docs/yamlsettings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2034,12 +2034,13 @@ 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`

Location of configuration directory (``recursor.conf``).
Location of configuration directory (where ``recursor.conf`` or ``recursor.yml`` is stored).
Usually ``/etc/powerdns``, but this depends on ``SYSCONFDIR`` during compile-time.
Use default or set on command line.

.. _setting-yaml-recursor.config_name:

Expand Down
6 changes: 4 additions & 2 deletions pdns/recursordist/settings/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion pdns/recursordist/settings/rust/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions pdns/recursordist/settings/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,12 @@
'name' : 'config_dir',
'section' : 'recursor',
'type' : LType.String,
'default' : '/etc/powerdns',
'help' : 'Location of configuration directory (recursor.conf)',
'default' : 'SYSCONFDIR',
'help' : 'Location of configuration directory (recursor.conf or recursor.yml)',
'doc' : '''
Location of configuration directory (``recursor.conf``).
Location of configuration directory (where ``recursor.conf`` or ``recursor.yml`` is stored).
Usually ``/etc/powerdns``, but this depends on ``SYSCONFDIR`` during compile-time.
Use default or set on command line.
''',
},
{
Expand Down

0 comments on commit f0d95e2

Please sign in to comment.