Commit graph

44198 commits

Author SHA1 Message Date
Colin Vidal
5b7445f507 effective config: specific check-names case
There are multiple check-names options provided in the default
configuration, and they must "complete" those provided by the user.
This is now handled when building the effective tree.
2025-10-29 13:55:04 -07:00
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
9d477aa3d4 add cfg_effective_config() API
Add the entry point of the logic to merge the user and the default
configuration, called cfg_effective_config(). This function takes a user
configuration and a default configuration. It internally clones the user
configuration tree, then walks through the clauses recursively applying
default values if they are missing.

The newly built configuration tree, called the effective configuration
tree, is then returned.

Currently this is just the basic mechanism which is implemented (i.e.
enable to walk from clause to clause, goes into a nested clause, and so
on). The next commits will introduce the implementation of
clause-specific merge functions in order to preserve the existing
named.conf semantics.
2025-10-29 13:55:04 -07:00
Colin Vidal
a9a0af4359 add an optional merge method on cfg_clausedef_t
In order to handle specific cases when merging configurations (i.e.
some specific clauses which require specific handling, not just
overriding values for instance), the cfg_clausedef_t includes an
optional merge method.

The merge function is NULL by default. If it is defined for a given
clause, and this clause is defined in both the user and default
configurations, the merge function is then called with both the user and
default clause instances. It's up the the implementation of that function
do to anything needed to keep the correct named.conf semantic.
2025-10-29 13:55:04 -07:00
Colin Vidal
473bbeb54b add helper API calls to manipulate maps and lists
cfg_map_addclone() is a variant of cfg_map_add which internally clones
an object and adds it to a map. It ensures that the object is an
implicit list if the map clause has the CFG_CLAUSEFLAG_MULTI set

cfg_list_addclone() clones a list (internally cloning each individual
element) and appends or preprends it to an existing target list.

Both of these will be needed to merge the default configuration
with the user configuration.
2025-10-29 13:55:04 -07:00
Colin Vidal
35c8768fde parser firstclause/nextclause API changes
In order to make upcoming configuration tree changes easier, the
cfg_map_firstclause() and _nextclause() functions have been changed
to return the clause itself rather than only the clause name.
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
2e8ecebc63 fix: nil: set cfgmaps correctly
A typo in MR !11165 caused `cfgmaps` to be set with only the top-level
configuration, not the view configuration.

Merge branch 'each-fix-cfgmaps' into 'main'

See merge request isc-projects/bind9!11173
2025-10-29 20:24:56 +00: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
539cda62a7 fix: dev: fix configuration bugs involving global defaults
The configuration code for the `max-cache-size`, `dnssec-validation`, and `response-padding` options were unnecessarily complicated, and in the case of `max-cache-size`, buggy. These have been fixed. The `optionmaps` variable in `configure_view()` is no longer needed and has been removed.

Merge branch 'each-cleanup-defaultconfig' into 'main'

See merge request isc-projects/bind9!11165
2025-10-29 18:28:45 +00: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
655f2452a3 chg: test: 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.

Merge branch 'stepan/statistics-asyncserver' into 'main'

See merge request isc-projects/bind9!10928
2025-10-29 17:45:14 +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
1ff1c4d042 chg: test: 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.

Merge branch 'stepan/cookie-asyncserver' into 'main'

See merge request isc-projects/bind9!10691
2025-10-29 16:06:26 +00: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
9d79b768d7 chg: test: 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.

Merge branch 'stepan/rpzrecurse-asyncserver' into 'main'

See merge request isc-projects/bind9!10916
2025-10-29 14:45:35 +00: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
eb29b7ff6f chg: test: 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.

Merge branch 'stepan/dnssec-asyncserver' into 'main'

See merge request isc-projects/bind9!10906
2025-10-29 13:56:15 +00: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
8c009d31ae fix: usr: Fix shutdown INSIST in dns_dispatchmgr_getblackhole
Previously, `named` could trigger an assertion in `dns_dispatchmgr_getblackhole`
while shutting down. This has been fixed.

Closes #5525

Merge branch '5525-attach-to-dispatchmgr-to-fctx' into 'main'

See merge request isc-projects/bind9!11131
2025-10-28 09:37:00 +11:00
Mark Andrews
012a47476d Fix "shutdown system test crashed in dns_dispatchmgr_getblackhole"
While shutting down view->dispatchmgr is no longer valid.  Attach
to it and when creates a fetch context and use that pointer instead
of view->dispatchmgr.  Use dns_view_getdispatchmgr to do the attaching
as view->dispatchmgr is it managed using rcu.
2025-10-28 09:02:12 +11:00
Colin Vidal
d951cedd02 new: dev: introduce cfg_obj_clone to clone a config tree
Introduce `cfg_obj_clone` which takes a `cfg_obj_t` node and clones it.
it allocates a new node, copies its scalar values and recursively
allocates child nodes, copying their scalar values as well and so on.
    
Internally, a new method `cfg_copyfunc_t` copy is added in `cfg_rep_t`,
which enables implementing a copy function specific for each
representation type a node can hold.

This is pre-require work for MR !11121 !11122 !11123

Merge branch 'colin/effective-config-clone' into 'main'

See merge request isc-projects/bind9!11124
2025-10-27 22:15:39 +01:00
Colin Vidal
1439635118 add unit test for cfg_obj_clone
Add a unit test for `cfg_obj_clone` to verify that the cloned tree
indeed has independent child nodes. The test also verifies that the
clone is semantically correct by comparing a text dump of the original
tree and the cloned one.
2025-10-27 21:33:18 +01:00
Colin Vidal
cc91a5d1ec introduce cfg_obj_clone to clone a config tree
Introduce `cfg_obj_clone` which takes a `cfg_obj_t` node and clones it.
it allocates a new node, copies its scalar values and recursively
allocates child nodes, copying their scalar values as well and so on.

Internally, a new method `cfg_copyfunc_t` copy is added in `cfg_rep_t`,
which enables implementing a copy function specific for each
representation type a node can hold.
2025-10-27 21:33:18 +01:00
Mark Andrews
1b0c84bb41 fix: nil: Remove unnecessary NULL checks causing Coverity warnings
In cfg_parse_buffer and cfg_parse_file 'pctx' was being checked
for being non-NULL when it was guaranteed to be non-NULL.  This
raised Coverity issues ID 637688 and ID 637689.

Closes #5599

Merge branch '5599-remove-unnecessary-null-checks' into 'main'

See merge request isc-projects/bind9!11154
2025-10-28 07:05:27 +11:00
Mark Andrews
3594ad04e5 Remove unnecessary NULL checks in parser.c
In cfg_parse_buffer and cfg_parse_file 'pctx' was being checked
for being non-NULL when it was guarenteed to be non-NULL.  This
raised Coverity issues ID 637688 and ID 637689.
2025-10-28 06:28:52 +11:00
Mark Andrews
b6917630f4 fix: test: Fix "hooks/conf/good-viewzonelevel.conf.j2 has hard coded library extension"
Use @DYLIB@ instead of hard coded extension "so".

Closes #5600

Merge branch '5600-fix-hooks-conf-good-viewzonelevel-conf-j2' into 'main'

See merge request isc-projects/bind9!11156
2025-10-28 06:15:32 +11: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
Andoni Duarte
40e8baf6d5 new: ci: Add tarball publication process to pipeline
Tarball uploading steps are to be included in the pipeline.

They are manual jobs that:

1. uploads a release tarball prepared by the "sign" job.
2. publish a previously staged release to a destination.
3. publishes a previously staged release to a well-known URL.

A template has been included since all three follow the same pattern.
Besides, rules commonly used by tag pipeline jobs.

Merge branch 'andoni/ci-release-process' into 'main'

See merge request isc-projects/bind9!11158
2025-10-27 15:51:58 +00:00
Michał Kępień
0734ec2a68 Deduplicate triggering rules for tag pipeline jobs
Define and use more YAML anchors for triggering rules commonly used by
tag pipeline jobs.  This builds on top of the work done in commit
675d9c7425, improving readability and
reuse.
2025-10-27 16:16:48 +01:00
Andoni Duarte Pintado
a27b1954f2 Add the "publish" job
Add a new SSH-confirmed GitLab CI job that publishes a previously staged
release to a well-known URL.  The details of what specifically this
entails are controlled by the staging environment.
2025-10-27 16:16:48 +01:00
Andoni Duarte Pintado
1d88db4d63 Add the "publish-private" job
Add a new SSH-confirmed GitLab CI job that publishes a previously staged
release to a destination that is not a well-known URL.  The details of
what specifically this entails are controlled by the staging
environment.
2025-10-27 16:16:48 +01:00
Andoni Duarte Pintado
a7fd3ebd0b Add the "staging" job
Add a new SSH-confirmed GitLab CI job that uploads a release tarball
prepared by the "sign" job to a staging environment specified using CI
variables.
2025-10-27 16:16:48 +01:00
Michał Kępień
868887ac65 Rework the "sign" job
Adapt the "sign" job to use the YAML template for SSH-confirmed jobs.
Make the signing process user-agnostic.
2025-10-27 16:16:48 +01:00
Michał Kępień
c61767453d Add a template for SSH-confirmed jobs
Add a YAML template for jobs that require an SSH connection to a
dedicated, locked-down runner for signing off on sensitive operations
(e.g. signing, publishing).

These jobs all follow a similar scheme:

 1. Runner prepares the necessary files in a well-known location (/tmp).
 2. Runner generates a shell script to be run by an authorized user.
 3. Runner sleeps while waiting for a signal that the script was run.
 4. Authorized user logs in to the runner over SSH and runs the script.
 5. Runner collects the relevant files and logs as job artifacts.

One additional complication is that each of the above steps needs to be
carried out under the assumption that GitLab Runner is running under a
different user account than the one used for logging in over SSH,
necessitating careful file permission handling.

Having a YAML template for jobs that need to follow the above scheme
significantly improves readability and reuse as each job only needs to
define (via the "variables" YAML key):

  - SSH_SCRIPT_RUNNER_PRE: the code the runner should execute before an
    authorized user logs in over SSH (typically: setting up files in a
    well-known location),

  - SSH_SCRIPT_CLIENT: contents of the shell script to be run by an
    authorized user,

  - SSH_SCRIPT_RUNNER_POST: the code the runner should execute after an
    authorized user runs the script over SSH (typically: artifact
    collection and cleanup).
2025-10-27 16:16:48 +01:00
Michał Kępień
8d548cbb58 Revise release directory naming
Include the Git tag in the name of the release directory rather than
just the version number.  Revise the script for the "release" job
accordingly.  This enables using the $CI_COMMIT_TAG variable in job
scripts without the need to resort to string manipulation to strip the
leading "v", improving readability.  The only place where string
manipulation is applied to the Git tag is now the "release" job itself,
to verify that the Git tag matches the version number embedded in the
source tarball name.
2025-10-27 14:00:04 +01:00
Mark Andrews
b14a6935ea fix: test: 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.

Closes #5598

Merge branch '5598-properly-determine-if-name-is-dynamic' into 'main'

See merge request isc-projects/bind9!11155
2025-10-27 23:46:39 +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ń
90408b813d chg: dev: 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.

Closes #3304

Merge branch '3304-stop-prettifying-json-statistics' into 'main'

See merge request isc-projects/bind9!10786
2025-10-27 10:57:58 +01: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ń
3219874fe7 chg: test: Properly process JSON and XML in tests
Processing JSON and XML using `grep` and `sed` is error-prone, overly
lax in some ways, overly strict in others, and neither accurate nor
expressive.  Use `jq` and `xmllint` with XPath expressions to make
things right in system tests.

See #3304

Merge branch '3304-properly-process-json-and-xml-in-tests' into 'main'

See merge request isc-projects/bind9!10942
2025-10-25 08:00:41 +02: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ń
d08addc2be
Remove unused xmllint-html.sh script
There are no longer any HTML files in the BIND 9 source repository.
Remove the xmllint-html.sh script that was used in the past to check
those for errors.
2025-10-25 07:37:48 +02:00