Commit graph

12885 commits

Author SHA1 Message Date
Colin Vidal
6643345a5b effective config: specific prefetch/trigger case
The prefetch statement can be overriden by the user, but the user might
specify the prefetch without the trigger value, which needs to be
pulled from the default configuration. Handle this case by directly
getting the default value if needed from the default configuration when
building the effective configuration tree.

Also take care of keeping the values inside their bounds, and simplify
the server configuration code which then just have to read effective
configuration values.
2025-10-29 13:55:04 -07:00
Colin Vidal
1f54a9107d effective config: specific dnssec-policy case
Default dnssec-policies are not overridden by user-provided ones. Add
this specific case to make sure those are kept, and also ensure that the
default dnssec-policy is always in the first position (which is an
implicit requirement in the existing implementation).

Also simplify the server configuration code, as it only needs to build
the list of dnssec-policy based on the effective config list.
2025-10-29 13:55:04 -07:00
Colin Vidal
27c4f68dcc effective config: specific view cases
User specified views don't override default views. In particular, the
_bind/CH view is still active. However, the order is important: if the
user defines a foo/CH view, it must be able to override _bind/CH by
matching clients first (this is how the view is documented).

The server configuration code is now simpler; it only has to build the
views based on the effective view list, and only creates the _default
view if there are no explicit views created by the user.
2025-10-29 13:55:04 -07:00
Colin Vidal
a99573d648 effective config: specific options/acl cases
Implement the specific rules of ACL inheritance when buiding the
effective configuration. As those rules are directly implemented in the
configuration tree, they are removed from `apply_configuation`.
2025-10-29 13:55:04 -07:00
Colin Vidal
72862c2abc move default configuration to common bin/include folder
Two programs need to be able to provide the effective configuration:
named (through a future rndc command) and named-checkconf (though a
future command line switch). In order to calculate the effective
configuration from named-checkconf, the default configuration
needs to be accessible.

The default configuration has now been moved from bin/named/config.c
into a common include directory for binaries: bin/include/defaultconfig.h.
2025-10-29 13:55:04 -07:00
Evan Hunt
0bf2df7316 set cfgmaps correctly
a typo in MR !11165 caused cfgmaps to be set with only the top-level
configuration, not the view configuration.
2025-10-29 12:45:31 -07:00
Evan Hunt
cf409e814f fix "response-padding" configuration and remove optionmaps
Add a default "response-padding" option in the global defaults,
to disable the option, and simplify the configuration code so that
looks at the global defaults if the option is not set in named.conf.

This enables us to remove the 'optionmaps' variable in configure_view(),
which was used for options that only look in named.conf.
2025-10-29 18:28:12 +00:00
Evan Hunt
fffae65e27 simplify "dnssec-validation" configuration
In the past, "dnssec-validation" was not looked up in the global
defaults unless "dnssec-enable" was true. "dnssec-enable" has been
obsolete for several years, but dnssec-validation was still being
configured in two steps.  This commit removes the vestigial bits of
the old logic.
2025-10-29 18:28:12 +00:00
Evan Hunt
cd921cc7ef fix a "max-cache-size" configuration bug
"max-cache-size default;" is allowed, according to the documentation
and the parser, but when it's configured, named crashes due to an
INSIST that the only legal string value is "unlimited". this has
been fied.

the configuration has also been simplified. previously, we checked for
max-cache-size in view and options, then determined whether to look in
the global default options based on whether the view had recursion set.
the default value set there was only applicable to views with recursion.
now, the default is an explicit "default", which affects views with
and without recursion in different ways.

the cfg type for "max-cache-size" has been changed from
cfg_type_sizeorpercent to cfg_type_maxcachesize.
2025-10-29 18:28:12 +00:00
Štěpán Balážik
2ba3726207 Use isctest.asyncserver in the "statistics" test
Reimplement the custom server using the asyncserver Python module.

Behavior change: The new server doesn't copy CD and DO flags and a
client cookie to responses.
2025-10-29 18:09:52 +01:00
Michał Kępień
a556199c7b Add a response handler matching on specific QNAMEs
Add a new ResponseHandler subclass, QnameHandler, which enables
conveniently matching specific QNAMEs (without also matching their
subdomains like DomainHandler does).
2025-10-29 18:09:52 +01:00
Štěpán Balážik
848b721d1d Allow users of AsyncDnsServer to set a default RCODE
This is mostly for cases where no zone is set up and all response stubs
come to response handler with REFUSED as RCODE.

This commit allows to override the RCODE before QueryContext is passed
to response handlers.
2025-10-29 18:09:25 +01:00
Štěpán Balážik
02c2f76e30 Use isctest.asyncserver in the "cookie" test
Replace the custom DNS servers in the "cookie" system test with new code
based on the isctest.asyncserver module. The convoluted test logic is
split into multiple response handlers which are shared between the two
servers.

Behavior change: returned SOA records have the zone name set properly.
2025-10-29 16:26:15 +01:00
Štěpán Balážik
1faf5c47a5 Use isctest.asyncserver in the "rpzrecurse" test
Replace the custom server with new implementation using the
AsyncDnsServer class.

Behavior changes:
- DNS cookie is not copied to the responses.
- CD, DO flags aren't set on responses.
2025-10-29 15:10:25 +01:00
Štěpán Balážik
ade2e995a9 Use isctest.asyncserver in the "dnssec" test
Reimplement the custom server using isctest.asyncserver. Factor most of
the logic out of the server code to two (identical) zones and only
implement the non-standard behavior.

Behavior changes:
- RRSIG Expiration and Inception is now static and covering the whole
  timeline instead of being calculated everytime.
- NXDOMAIN is returned where suitable by standard.
- Returned SOA records have properly set zone names.
2025-10-29 14:20:02 +01:00
Mark Andrews
ba5053cddf Fix "good-viewzonelevel.conf.j2 has hard coded library extension"
Use @DYLIB@ instead of hard coded extension "so".
2025-10-28 05:40:28 +11:00
Mark Andrews
de81887c2a test-syncplugin.c:plugin_register was broken
The variables example2com, example3com, and example4com where not
being initalised on all paths leading to Coverity issues ID 637690,
ID 637691 and ID 637692 being raised.  In addition the tests to free
them were wrong as they depended on the unintialised variables. This
has been fixed.
2025-10-27 23:00:08 +11:00
Michał Kępień
4797b2a155
Stop prettifying JSON statistics
Passing the JSON_C_TO_STRING_PRETTY flag to
json_object_to_json_string_ext() makes the latter produce prettified
JSON output.  This results in a huge amount of redundant whitespace
being inserted into each HTTP response (whitespace amounts to about 40%
of the entire JSON payload).

The bandwidth cost can be amortized by enabling HTTP compression on the
client side ("Accept-Encoding: deflate"), but that does not affect the
size of data at rest.

Use the JSON_C_TO_STRING_PLAIN flag instead of JSON_C_TO_STRING_PRETTY
to minimize the size of JSON responses sent via the statistics channel.
External tools should be used for prettifying JSON data.
2025-10-27 10:56:38 +01:00
Michał Kępień
5110dbacb9
Remove unused Perl scripts
The traffic-json.pl and traffic-xml.pl scripts that were used in the
"statschannel" system test in the past became dead code when commit
1202fd912a rewrote parts of that test to
Python.  Remove those scripts.
2025-10-25 07:37:48 +02:00
Michał Kępień
5872000d9e
Use xmllint in system tests inspecting XML data
Inspecting XML data using sed and grep is error-prone, overly lax in
some ways, overly strict in others, and neither accurate nor expressive.
Use xmllint and XPath expressions for inspecting XML data in the
"statistics", "statschannel", and "synthfromdnssec" system tests to
address these deficiencies.
2025-10-25 07:37:48 +02:00
Michał Kępień
85773d4d21
Detect xmllint at build time
Detect whether and where the xmllint utility is available at build time,
so that it can be used in system tests.  If the tool is not found,
specific checks employing it will be skipped.
2025-10-25 07:37:48 +02:00
Michał Kępień
b494e02761
Use jq in system tests inspecting JSON data
Inspecting JSON data using grep is error-prone, overly lax in some ways,
overly strict in others, and neither accurate nor expressive.  Use jq
for inspecting JSON data in the "statschannel" and "synthfromdnssec"
system tests to address these deficiencies.
2025-10-25 07:37:48 +02:00
Michał Kępień
273b4bbfd7
Detect jq at build time
Detect whether and where the jq utility is available at build time, so
that it can be used in system tests.  If the tool is not found, specific
checks employing it will be skipped.
2025-10-25 07:37:48 +02:00
Evan Hunt
2877b57735 restore the former change_directory logging
change_directory() now lives in libisccfg. when it was moved,
the logging behavior changed: previously it had been logged
by named only, in the general logging category, and without the
named.conf filename and line number. it was not logged by
named-checkconf. this behavior has now been restored.
2025-10-23 13:01:31 -07:00
Colin Vidal
6f4d4ddb1c test rndc showzone works for named.conf zones
Since the zone now has a reference to their respective configuration
tree, `rndc showzone` can be used for any zones (including those
defined in namedconf), without `allow-new-zones` being enabled.
Add a test for this.

The test is part of the addzone suite because showzone used to be
related to addzone, but this could be moved elsewhere in the future
if more specific tests are needed for showzone.
2025-10-23 13:01:11 -07:00
Colin Vidal
6b5246b3d2 ensure parser/cfg_obj log includes the line number
Since the `file` property of cfg_obj_t can now be null (instead of
"none"), cfg_obj_t would take a fallback flow where the line was not
logged. This fixes it.

Also, add the log line when parser_complain is called and `file` is null
(which might happend when parsing buffer only) to also include the line
number.
2025-10-23 13:01:11 -07:00
Evan Hunt
0db377da57 simplify and regularize cfg_* functions
- several functions that can no longer fail have been changed to
  type void, and unnecessary 'cleanup' sections were removed
- renamed cfg_create_obj() to cfg_obj_create(), and cfg_create_tuple()
  to cfg_tuple_create(), to match typical nomenclature.
- fixed a memory leak bug, in which an element could be removed
  from a list in delete_zoneconf() without being freed. this has
  been addressed by adding a cfg_list_unlink() function.
  list elements are now allocated based on the list they will
  be stored in, using the same mctx.
2025-10-23 13:01:10 -07:00
Evan Hunt
4f7f2dae59 simplify cfg_parser API
- the cfg_parser_create() and cfg_parser_destroy() calls are no
  longer used outside parser.c, so they are now static functions
- cfg_parser_attach(), cfg_parser_reset(), and cfg_parser_setflags()
  are no longer used at all, and have been removed.
- cfg_parser_mapadd() has been renamed for clarity to cfg_map_add().
2025-10-23 13:01:09 -07:00
Colin Vidal
d03f6e6fd4 cfg_parse_ functions internally handle the parser
Instead of (1) allocating a parser, (2) parsing a file/buffer then (3)
freeing the parser, the parser is now internally created/destroyed from
within the `cfg_parse_*` functions. This simplifies a lot the use cases,
especially around the error cases where the parser needs to be freed in
a cleanup goto.

The only trick was the parser callback mechanism, which would previously
have been set up between steps 1 and 2.  Since it's never been used for
any purpose other than the "directory" option, the chdir call has now
been moved inside the parser and the generic callback mechanism has been
removed, replacing CFG_CLAUSEFLAG_CALLBACK with CFG_CLAUSEFLAG_CHDIR.
2025-10-23 13:01:08 -07:00
Evan Hunt
0191ba5540 store the zone configuration object in the zone
when configuring a zone, we can now save the zone's configuration
object in the zone itself by calling dns_zone_setcfg().  this can
then be used by "rndc showzone" to print the zone's configuration,
which is simpler than searching for it using the new-zones
configuration, and allows it to work even if "allow-new-zones"
is disabled.
2025-10-23 13:01:06 -07:00
Evan Hunt
6de1d0dbc4 update cfg_obj_attach/destroy
now that cfg_obj_destroy() has been simplified, we can use the
ISC_REFCOUNT macros to declare cfg_obj_attach() and _detach().
2025-10-23 13:01:02 -07:00
Colin Vidal
ea03d743f7 remove all shared and global parsers
Remove all global cfg_parser objects as well as shared parsers between
views to dynamically add zones. Instead, parser are transirently created
whenever needed.
2025-10-23 13:00:03 -07:00
Colin Vidal
a72b8a1a60 remove global named defaults parser
Remove the global named defaults parser. Instead, a parser is created
during the execution time of named_config_parsedefaults(). This
simplifies the API (no parser to pass around) and the life-cycle of the
default configuration tree (it doesn't depends on a parser instance).
2025-10-23 13:00:02 -07:00
Colin Vidal
7706f5acec remove parser context field from cfg_obj_t
cfg_obj_t doesn't store a pointer to its a parser context anymore,
and does not depend on the parser's lifecycle. Instead, it stores a
reference to its own memory context (and in principle, each node
could have different memory context). This also slightly simplifies
the _destroy API as there is no need to pass a context through it
anymore.
2025-10-23 12:59:58 -07:00
Štěpán Balážik
99b0cf2dd7 Use isctest.asyncserver in the "nsupdate" test
Reimplement the custom server written in Perl in Python using the
AsyncDnsServer class.
2025-10-23 11:44:20 +00:00
Štěpán Balážik
4042b805ff Enable ignoring TCP connections
Add a TCP connection handler, IgnoreAllConnections that allows
establishing TCP connection but not reading anything from it.

This re-uses the horrible hack from ConnectionReset handler and might
break at any point in the future.

See the comments and e407888507 for more
details.
2025-10-23 11:44:20 +00:00
Petr Špaček
0e770685d6 Fix typo in tools test's shell path 2025-10-22 13:50:08 +11:00
Mark Andrews
ac3fba068e dnssec-verify now returns failure on bad arguments 2025-10-22 12:45:03 +11:00
Aram Sargsyan
49b7ce9a54 Fix dnssec-keygen key collision checking for KEY rrtype keys
When generating a new key, dnssec-keygen checks for possible
key ID collisions with existing keys. The dnssec.c:findmatchingkeys()
function, which is supposed to get the list of the existing keys,
fails to do that for the existing KEY rrtype keys (i.e. generated
using 'dnssec-keygen -T KEY') because it doesn't pass down to the
dst_key_fromnamedfile() -> dst_key_read_public() functions the type
of the keys it's interested in. Fix the issue by introducing a new
function parameter which tells in which type of keys the caller is
currently interested in.
2025-10-22 09:42:43 +11:00
Nicki Křížek
377724c26d Use common name for post-startup server functions
Unify the names of autouse module-wide fixtures that perform
after_servers_start() setup. The consistent naming doesn't just help
readability, but also makes it simpler for the vulture exception (since
it doesn't properly deal with autouse fixtures).
2025-10-21 15:07:49 +02:00
Nicki Křížek
fb4345afd4 Use bootstrap() in pytest where applicable
Replace the autouse fixtures which were only used to change the initial
server configuration into proper bootstrap() functions. This gets rid of
an extraneous reconfigure.

In the tests_validation_many_anchors.py, split the fixture into a proper
bootstrap() and a separate test for checking the expected log lines for
the ignored keys. Previously, the test was broken - it should check for
all the messages being present in the log, and some of the keys are
actually initial-key rather than static-key. This has been fixed in the
parametrized test.
2025-10-21 15:07:49 +02:00
Nicki Křížek
7474d38295 Add module-specific python setup to system tests
During the system test execution, allow use of module-specific
bootstrap() function in addition to the setup.sh script which this
function should ultimately replace.

The purpose of bootstrap() is two-fold. First, it can execute any
commands needed to create the initial conditions for the test, such as
creating key materials, manipulating files etc. Second, it should return
any test-specific template values as a dictionary. Those will be used to
render the jinja2 templates.
2025-10-21 15:07:49 +02:00
Mark Andrews
a949184eb7 Fix parse_dnskey in bin/dnssec/dnssec-ksr.c was failing to reset comments
If dns_name_fromtext failed or the subsequent dns_name_compare
failed the lexer's comments state wasn't cleaned up.
2025-10-20 10:54:32 +11:00
Evan Hunt
43f53b5010 report when zone reload already in progress
if a zone reload is already in progress when 'rndc reload <zone>' is
run, currently the message returned in "zone reload queued", which
is correct, but it's identical to the message returned when a reload
was *not* in progress, so the user can't easily tell what happened.
a user could reload a zone twice and not realize that only one
reload actually took place.

this has been addressed by changing the message returned to
"zone reload was already queued".

a new result code ISC_R_LOADING has been added to signal this
condition, taking the place of ISC_R_RELOAD, which was obsolete
and has been removed.
2025-10-17 20:36:18 +00:00
Colin Vidal
2b4825dbad fix random failure on synthrecord system test
One of the synthrecord system tests uses a test function to generate an
expected name based on some randomly generated IPv6 (using Hypothesis).
Turns out the test function generating the name didn't handle the case
where the label which encodes the IPv6 could have a leading or trailing
'-' character. (The plugin needs to add a leading or trailing 0 so as
not to break IDN compatibility.)
2025-10-17 12:28:04 -07:00
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