Commit graph

12840 commits

Author SHA1 Message Date
Mark Andrews
3a7f8e1d12 Expect created.* and unused.* files 2025-10-16 10:22:43 +11:00
Mark Andrews
a0abef4fa3 Don't hardcode shared library extension 2025-10-15 17:51:55 +11:00
Mark Andrews
5beba4d292 'nextpart' and 'grep -q' don't work together
'nextpart file | grep -q' doesn't work as expected.  'grep -q' is not
required to read all of the input and that causes 'nextpart' to fail.
2025-10-14 17:47:25 +11:00
Evan Hunt
a373671f5e remove "bindkeys-file" option
The bindkeys-file option was only used for testing purposes, and
has now been replaced with a "-T bindkeys=<filename>" option for
named.
2025-10-12 23:37:49 -07:00
Evan Hunt
15b0ff5036 clean up bind.keys
the comments in the bind.keys file were outdated; the file now only
exists to be converted into bind.keys.h and compiled into named and
delv.

some tests also referenced it, and have been cleaned up, since
the keys in it are already built into named.
2025-10-10 17:41:07 -07:00
Matthijs Mekking
4df536e0dc Add dnssec-policy text for dnssec-importkey
You should not use dnssec-importkey to import DNSKEY records from
other providers (for example when setting up multi-signer).

Clarify this in the manpage.
2025-10-10 16:49:55 +02:00
Nicki Křížek
2ecbe46e0d Disable keyfromlabel collision avoidance in tests
With the collision avoidance on, some of the tests would occasionally
fail. None of the tests using keyfromlabel are revoking the keys so it
should be safe to disable it.
2025-10-10 10:39:04 +02:00
Ondřej Surý
94b4d105e8
Apply the changes from updated set_if_not_null semantic patch 2025-10-08 17:44:50 +02:00
Matthijs Mekking
2d7ab28ce2 Make properties direct attribute of KeyProperties
There is no real reason to keep those in a dictionary.
2025-10-08 09:56:58 +02:00
Matthijs Mekking
ade333bb64 Remove KeyProperties property expect
This property is unused, so we can just remove it.
2025-10-08 09:56:58 +02:00
Colin Vidal
99724cf9e2 synthrecord: fixing code nits
Fixing an (invalid) Coverity NULL-dereference (ns_pluginctx_t is always
defined) by enforcing a REQUIRE, and add a missing return value check.
2025-10-07 07:05:40 +02:00
Michał Kępień
abfec597b8
Simplify named_tkeyctx_fromconfig()
With the code handling the "tkey-gssapi-credential" statement removed,
the named_tkeyctx_fromconfig() function can no longer fail.  Update its
return type to void and revise its only call site accordingly.  Clean up
the function's documentation.  Declare the 's' helper variable only in
the scope it is used in to improve readability.
2025-10-06 13:19:50 +02:00
Michał Kępień
84b96df153
Remove "tkey-gssapi-credential" and related code
Since the "tkey-gssapi-credential" statement has been previously
deprecated, mark it as ancient and remove all code related to it:

  - The code processing the "tkey-gssapi-credential" statement in the
    configuration is the only user of the dst_gssapi_acquirecred() and
    dst_gssapi_releasecred() functions, so remove them along with their
    static helper functions and a backup definition of the
    GSS_KRB5_MECHANISM macro.

  - When calling gss_accept_sec_context(), pass GSS_C_NO_CREDENTIAL
    instead of the credential acquired by gss_acquire_cred().
    (Previously, NULL was passed when "tkey-gssapi-credential" was not
    specified.  Kerberos headers define GSS_C_NO_CREDENTIAL as
    (gss_cred_id_t) 0, so the logic was effectively the same, but using
    the GSS_C_NO_CREDENTIAL macro is more appropriate.)  This renders
    the 'cred' parameter for dst_gssapi_acceptctx() redundant, so remove
    it from the prototype of the latter.  (Contrary to what the
    documentation for dst_gssapi_acceptctx() claims,
    dst_gssapi_releasecred() does not need to subsequently be called to
    free the GSS-API context; a dst_gssapi_deletectx() call in
    gssapi_destroy() takes care of that when the dynamically generated
    TSIG key is destroyed.)

  - Remove the 'gsscred' member from struct dns_tkeyctx, along with its
    related dns_gss_cred_id_t typedef.

Update the relevant sections of the ARM and code comments accordingly.

This makes the "tkey-gssapi-keytab" statement the only way to set up
GSS-TSIG in named.

Remove redundant code from bin/named/tkeyconf.c while at it.
2025-10-06 13:19:50 +02:00
Michał Kępień
73197feec7
Stop using "tkey-gssapi-credential" in tests
Since the "tkey-gssapi-credential" statement is now deprecated and is
about to be removed, migrate the only system test using it ("nsupdate")
to "tkey-gssapi-keytab".

Currently, the GSS-TSIG parts of the "nsupdate" system test require
properly setting up a combination of:

  - "tkey-gssapi-credential" statements in named.conf files,
  - the KRB5_KTNAME environment variable.

Specifically, this configuration causes named startup to include
acquiring the credential that GSS-API is allowed to match keys against
from a keytab file specified by the KRB5_KTNAME environment variable.

By contrast, the revised configuration uses the "tkey-gssapi-keytab"
statement, which makes GSS-API match keys against any credential present
in the specified keytab file.

Since both keytabs in question (ns9/dns.keytab, ns10/dns.keytab) only
contain a single credential, the two configurations are functionally
equivalent, with the revised one being significantly more readable and
simpler to prepare.
2025-10-06 13:19:50 +02:00
Michał Kępień
99d4e7a944
Reorganize imports in tests_synthrecord.py
bin/tests/system/synthrecord/tests_synthrecord.py imports hypothesis
before importing isctest.hypothesis, which causes the "synthrecord"
system test to fail on platforms on which the Hypothesis module is not
available.  Reorganize Python imports in tests_synthrecord.py to fix the
above issue and also to make it more in line with other similar test
scripts.
2025-10-02 11:13:05 +02:00
Matthijs Mekking
893f417e1e Convert kasp sub-test comments to info logs
Follow-up on the discussion on the kasp system test rewrite to pytest.
2025-10-02 07:23:05 +00:00
Colin Vidal
62002cfa9c rename ns_pluginregister_ctx_t into ns_pluginctx_t
The type `ns_pluginregister_ctx_t` was initially added to pass plugin
contextual data when the plugin is registered, but this is also now
passed into `plugin_check`. Furthermore, those various data are not
specific to the registration in particular. Rename the type into
`ns_pluginctx_t` for clarity.
2025-10-01 20:20:48 +02:00
Evan Hunt
a8f2f41013 make "origin" optional for forward zones
The "origin" parameter for synthrecord is now mandatory for reverse
zones, but when configured in a non-reverse zone, it will default to
the zone name.
2025-10-01 12:16:05 +02:00
Evan Hunt
c4b5deb750 remove "mode" parameter from synthrecord
the plugin's operating mode is now determined automatically
from the zone name: if the name ends in "ip6.arpa" or "in-addr.arpa",
then the plugin is in reverse mode, otherwise forward.
2025-10-01 12:16:05 +02:00
Colin Vidal
7b2eab90c0 add synthrecord plugin documentation
Add synthrecord plugin documentation as well as update some
documentation for the other filter-a and filter-aaaa plugins.
2025-10-01 12:16:05 +02:00
Colin Vidal
c201b429f4 add synthesized record system tests
Add system tests for the dynamically synthesized record plugin. This
covers the various cases the plugin should handle: generating a PTR
record only when (1) no answer is found locally and (2) the IP address
extracted from the query name is part of an allowed network. This also
covered the cases of forward synthesized records; answering a A/AAAA/ANY
query from a PTR address when this match the prefix, ACL and origin.
2025-10-01 12:16:05 +02:00
Colin Vidal
a0da784993 add support for synthesized PTR answers
Add a BIND9 plugin which, in "reverse" mode, enables the server to build
a synthesized response to a PTR query when the PTR record requested is
not found in the zone. (The plugin won't be called for names below a
delegation point, because it couldn't know whether a name actually
exists within the delegation.)

The dynamically-built name is constructed from a static prefix (passed
as a plugin parameter), the IP address (extracted from the query name)
and a suffx (also passed as a plugin parameter).  An "allow-synth"
address-match list is used to limit the network addresses for which
the plugin may generate responses.

The plugin can also be used in "forward" mode, to build synthesized
A/AAAA records from names using the same format as he dynamically-built
PTR names, if the query name and type are not found in the zone.
The same parameters are used when the plugin is in forward mode:
the plugin will react and answer a query if the name matches the
configured prefix and origin, and encodes an IP address that is
within "allow-synth".
2025-10-01 12:16:05 +02:00
Colin Vidal
25e258fb0b provide a context structure for plugin_register()
This commit introduces a new type, ns_pluginregister_ctx_t,
which is passed to plugin_check() and plugin_register() in place of the
'source' parameter. The source value is now just part of the structure,
which also holds a pointer to the zone origin if the plugin is loaded at
a zone level.

This provides more contextual information, enabling the plugin to make
specific configuration decisions based on the name of the zone for which
it is loaded.

It's also flexible if more contextual data are needed in the future:
add a new field to ns_pluginregister_ctx_t, and new plugins can use
it without affecting compatibility with existing plugins.
2025-10-01 11:11:00 +02:00
Evan Hunt
92cefc52bc check plugin config before registering
In named_config_parsefile(), when checking the validity of
named.conf, the checking of plugin correctness was deliberately
postponed until the plugin is loaded and registered. However,
when the plugin was registered, the checking was never actually
done: the plugin_register() implementation was called, but
plugin_check() was not.

This made it necessary to duplicate the correctness checking in both
functions, so that both named-checkconf and named could catch errors.
That should not be required.

ns_plugin_register() now calls the check function before the register
function, and aborts if either one fails.  ns_plugin_check() calls only
the check function.  ns_plugin_check() is used by named-checkconf, and
ns_plugin_register() is used by named. (Note: this design has a
side effect that a call to ns_plugin_register() will result in the
plugin parameters being parsed twice at registration time.)

ns_plugin_check() now takes an additional argument for the hook
source: zone or view.
2025-09-30 15:42:26 -07:00
Colin Vidal
47dd27d87b test views are detached before leaving exclusive mode
Adds a log-based test ensuring that when a reconfiguration fails inside
the view configuration, the newly created view are always detached
before the exclusive mode is ended.
2025-09-26 14:55:01 +02:00
Colin Vidal
d7dbfbb011 apply_configuration: leave exclusive mode after viewlist cleanup
When a re-configuration fails, `apply_configuration` flows jump to a
cleanup label and, at some point, leave the exclusive mode and cleanup
the viewlist. It looks fine as the viewlist is at this point only
locally known (if this is a configuration failure, this is the new view
list, if this is a success, this is the old list which has been swapped
out from the production list during the exclusive mode).

However, the view and zone initialization code enqueues job callbacks,
for instance from `dns_zone_setsigninginterval` (but there are others
cases) which will be called for the new views and zones after the
exclusive mode is over.

Depending where the configuration fails, those views and zones can be
half-configured, for instance a view might have an unfrozen resolver.
Hence, leaving the exclusive mode before cleaning up those views ans
zones will immediately called the previously enqueued callbacks and lead
to this reconfiguration-failure crash stack:

```
isc_assertion_failed
dns_resolver_createfetch
do_keyfetch
isc__async_cb
...
uv_run
loop_thread
thread_body
thread_run
start_thread
...
```

To avoid the problem, the views are now cleaned up before leaving the
exclusive mode (which also clean up the zones and enqueued callbacks).

As context, the bug was introduced by !10910 which moved the creation
(not configuration) of the view outsides of the exclusive mode. This is
a safe move (as at this point, the newly view are only known locally by
`apply_configuration`) but the re-order was wrong regarding the point
where the exclusive mode was ended (before the change, the exclusive
mode as always ended before the new view are detached).
2025-09-26 14:55:01 +02:00
Matthijs Mekking
acbf110b18 Test the next key event after full sign
After a full sign we no longer have to need to take the sign delay into
account.
2025-09-26 12:49:23 +02:00
Matthijs Mekking
008d3d2a9c Test rndc sign updates the signatures
Add a check to the ZSK rollover test case that ensures the zone is
signed with the successor key only, after a 'rndc sign' is commanded.
2025-09-26 12:49:23 +02:00
Matthijs Mekking
81d3a29e4e Check disable-algorithms with non-zone names
Test that if disable-algorithms is configured on a name that is below
the zonecut, it still validates (z.secure.example).

Test that if disable-algorithms is configured on a name that is above
the zonecut, it is treated as insecure (zonecut.ent.secure.example).
2025-09-25 11:14:27 +10:00
Mark Andrews
21934102d3 Check that badalg.secure.example resolves
Previously, badalg.secure.example would return SERVFAIL because the DS
records (from the parent) could not be validated.
2025-09-25 11:14:27 +10:00
Mark Andrews
a0945f6337 Use signer name when disabling DNSSEC algorithms
When disabling algorithms, use the signer name to determine if the
algorithm is disabled or not.  This allows for algorithms to be
cleanly disabled on a zone level basis.  Previously, just using the
records owner name, "disable-algorithms" could impact resolution of
names that where not disabled.  This does now mean that
"disable-algorithms" can not be used to disable part of a zone anymore.
2025-09-25 11:14:27 +10:00
Colin Vidal
36a05c81b4 rename cfg_aclconfctx_t variables to aclctx
ACL configuration context variables are inconsistently named as `actx`,
`ac`, or `aclconfctx`, which caused confusion during code reviews. This
commit renames all `cfg_aclconfctx_t` variables to `aclctx`, which is
short, consistent, and unambiguous.
2025-09-24 20:14:49 +02:00
Matthijs Mekking
dcd49f2ead Change checkconf to include built-in dnssec-policy
The configuration should also take into account the built-in
DNSSEC policies when verifying the keys in the key-directory match the
given policy. Update the code accordingly and add some good and
failure test cases.
2025-09-24 17:03:06 +02:00
Matthijs Mekking
3918a8ca4c Test named-checkconf -k
Test named-checkconf -k option, that checks the dnssec-policy against
the configured keystores.
2025-09-24 17:03:06 +02:00
Matthijs Mekking
9fe520ece9 Implement named-checkconf -k (check keys)
With named-checkconf -k you can check your configuration including
checking the dnssec-policy keys against the configured keystores. If
there is a mismatch in the key files versus the policy, named-checkconf
will fail. This is useful for running before migrating to dnssec-policy.

For logging purposes, introduce a function that writes the identifying
information about a policy key into a string.

Allow a dnssec key to be initialized outside the keymgr code.

Add 'log_errors' to 'cfg_kasp_fromconfig' to avoid duplicate error
logs.
2025-09-24 17:03:06 +02:00
Nicki Křížek
7e118fdb06 Re-enable delv tests with TSAN
With the loopmgr rewrite in 9.20, the delv issue shoud no longer happen,
thus the delv tests can be executed under TSAN as well.
2025-09-24 13:34:16 +02:00
Colin Vidal
17a2cbcbc5 comment about ifs scan twice the first time
Add comment message about why we're scanning interfaces twice during the
initial configuration (FreeBSD compatibility). See #3583
2025-09-24 10:54:50 +02:00
Colin Vidal
3fe239e5cf apply_configuration: log subroutines for tests
In order to have a (minimal) test ensuring we don't move back
`apply_configuration` subroutines which can be done before the exclusive
lock is taken, `APPLY_CONFIGURATION_SUBROUTINE_LOG` macro is added and
used for the few subroutines already extracted from the exclusive mode.
Those expected logs are added in `configloading` system test checks.
2025-09-24 10:54:50 +02:00
Colin Vidal
c225ba17c2 creation of client TLS ctx before exclusive mode
When the server is configured (inside `apply_configuration`) a client
TLS context cache is created and attached to the global server object.
It is then used by `configure_view` flow (and also during runtime though
the zone manager).

It is now created before the exclusive mode, and the swap of the
previous TLS cache ctx is done at the end of the exclusive mode, if
everything went well.

This allows us (among other follow-up changes) to move the
`configure_views` function outside of the exclusive mode.
2025-09-24 10:54:50 +02:00
Colin Vidal
e1be2be4ef move creation of keystores, kasp list and view outside of exclusive mode
The keystores initialization, the KASP list initialization as well as
the initialization of the view no longer depends of any data shared by
running "production" objects during re-configuration of the server. This
allows us to move those outside (before) the exclusive mode is taken.
2025-09-24 10:54:50 +02:00
Colin Vidal
201f62d9ef cfg_aclconfctx_t object is part of named_server
`named_g_actconfctx` is a global variable holding the ACL configuration
context alive (in particular, to dynamically load zones). However, this
object is build once per configuration (early) and is used only inside
server.c `apply_configuration` flow. (Two exceptions: the shutdown flow,
still in server.c and plugin check flow, which doesn't need it, so it's
NULL in such case).

Instead of leaving this global publicly exposed, it is now part of the
`named_server_t` object. This allows us to clearly see that, when
reconfigureing the server, the new instance of the ACL context is known
only by the newly built object and not currently used by "production"
object; and will help to move move logic before the exclusive mode is
taken.

The other advantage is that the ACL configuration context can now be
built before the exclusive lock as well.
2025-09-24 10:54:50 +02:00
Colin Vidal
4523852ded apply_configuration: bump config map before exclusive mode
Moving the config map building outside of the exclusive mode, and this
is local data only and no runtime object uses it.
2025-09-24 10:54:50 +02:00
Colin Vidal
de11150e47 apply_configuation: add configure_keystores
The keystores list build logic was inlined in apply_configuration, this
commit extracts it into its own function.
2025-09-24 10:54:50 +02:00
Colin Vidal
c97be6a7f5 apply_configuration: add configure_kasplist
The kasplist (dnssec-policy defined in the builtin and global
configuration options) was built inside apply_configuration. This
commit extracts this logic into its separate function.

In order to make the view configuration independent of the global
`server` object, the newly built kasplist is now passed as parameter.
(This eventually will help to be able to configure the views outside of
the exclusive mode by limiting its dependency to the global
`server`/`named_g_server`).
2025-09-24 10:54:50 +02:00
Colin Vidal
0fb6c9ae74 apply_configuration: remove builtin_viewlist
When creating/configuring the view, the user-defined views are built and
set into the viewlist, then builtin-view inside the builtin_viewlist.
But there is no seperate logic applied to those two lists, and they are
immediately merged into viewlist right after. This commit removes this
intermediate list and add builtin-views directly into the main viewlist
instead.
2025-09-24 10:54:50 +02:00
Colin Vidal
36c74c58c1 refactor view creation/config in apply_configuration
In order to help splitting apply_configuration, the inline loops and bit
of logic around it for views creation and configuration, each of those
are now in a dedicatated function.
2025-09-24 10:54:50 +02:00
Colin Vidal
a1703fa35b preserve cache when reload fails
If the server is reloaded, new views are created and preexisting cache
is attached to those _but_ something goes wrong later, the previous
views are restored but the previous cache list is destroyed. This makes
the subsequent reload to drop the existing cache. This fixes it by
avoiding a mutation of the old cache list.
2025-09-17 16:45:51 +02:00
Colin Vidal
714693742e test that cache is preserved on reconfing failure
A named bug scrap the cache on a second reload after an initial reload
failure. Adds a test checking that the cache is preserved between server
reconfiguration/reloads even if it fails at some point (after attempting
to re-use the cache) and the server is re-loaded later.
2025-09-17 16:45:51 +02:00
Ondřej Surý
9e2d5d94bd
Remove dns_dbtree_t and its usage
As we removed the ability to count nodes in the auxiliary trees (because
there are no auxiliary trees), we can also cleanup the API and
associated enum type (dns_dbtree_t).
2025-09-17 15:58:44 +02:00
Ondřej Surý
70c8054b84
Remove CacheNSECNodes statistics counter
There is no auxiliary NSEC tree, so we can't count the NSEC nodes
separately.  Remove the CacheNSECNodes statistics counter as it would be
always zero.
2025-09-17 15:58:44 +02:00