2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

35708 Commits

Author SHA1 Message Date
Michał Kępień
9c27a3b0e2 Merge branch '2950-confidential-cache-acceptance-rules' into 'main'
[CVE-2021-25220] prevent cache poisoning from forwarder responses

See merge request isc-projects/bind9!5986
2022-03-16 21:30:34 +00:00
Petr Špaček
51546e8892 Add Release Note for [GL #2950] 2022-03-16 22:11:49 +01:00
Petr Špaček
612f277877 Add CHANGES note for [GL #2950] 2022-03-16 22:11:49 +01:00
Mark Andrews
fe1bbba259 Look for zones deeper than the current domain or forward name
When caching glue, we need to ensure that there is no closer
source of truth for the name. If the owner name for the glue
record would be answered by a locally configured zone, do not
cache.
2022-03-16 22:11:49 +01:00
Mark Andrews
c289913e5c Check cached names for possible "forward only" clause
When caching additional and glue data *not* from a forwarder, we must
check that there is no "forward only" clause covering the owner name
that would take precedence.  Such names would normally be allowed by
baliwick rules, but a "forward only" zone introduces a new baliwick
scope.
2022-03-16 22:11:49 +01:00
Mark Andrews
7e37b5e379 Check that the forward declaration is unchanged and not overridden
If we are using a fowarder, in addition to checking that names to
be cached are subdomains of the forwarded namespace, we must also
check that there are no subsidiary forwarded namespaces which would
take precedence. To be safe, we don't cache any responses if the
forwarding configuration has changed since the query was sent.
2022-03-16 22:11:49 +01:00
Mark Andrews
5dc3b25d03 Add additional name checks when using a forwarder
When using a forwarder, check that the owner name of response
records are within the bailiwick of the forwarded name space.
2022-03-16 22:11:49 +01:00
Matthijs Mekking
fd8dd9841d Merge branch '3185-follow-up-fix-zone-documentation' into 'main'
Fix zone named.conf man page documentation

Closes #3185

See merge request isc-projects/bind9!5977
2022-03-15 13:14:25 +00:00
Matthijs Mekking
01b125ff05 Fix named.conf man page documentation
Commit 4ca74eee49363a9c24c561a742f0abdd7f71d2a8 update the zone grammar
such that the zone statement is printed with the valid options per
zone type.

This commit is a follow-up, putting back the ZONE heading and adding
a note that these zone statements may also be put inside the view
statement.

It is tricky to actually print the zone statements inside
the view statement, and so we decided that we would add a note to say
that this is possible.
2022-03-15 14:13:45 +01:00
Ondřej Surý
13b20ef411 Merge branch '3202-cleanup-isc_timer-API' into 'main'
Refactor and simplify isc_timer API

See merge request isc-projects/bind9!5966
2022-03-14 21:13:24 +00:00
Ondřej Surý
7f91f1ecaa Add CHANGES note for [GL #3202] 2022-03-14 13:00:05 -07:00
Ondřej Surý
79b5ccbf34 Implement isc_interval_t on top of isc_time_t
Change the isc_interval_t implementation from separate data type and
separate implementation to be shim implementation on top of isc_time_t.
The distinction between isc_interval_t and isc_time_t has been kept
because they are semantically different - isc_interval_t is relative and
isc_time_t is absolute, but this allows isc_time_t and isc_interval_t to
be freely interchangeable, f.e. this:

    isc_time_t *t1;
    isc_interval_t *interval;
    isc_time_t *t2;

    isc_interval_set(interval, isc_time_seconds(t2), isc_time_nanoseconds(t2);;
    isc_time_subtract(t1, interval, t2);
    isc_interval_set(interval, isc_time_seconds(t2), isc_time_nanoseconds(t2));

to just:

    isc_time_t *t1;
    isc_interval_t *interval;
    isc_time_t *t2;

    isc_time_subtract(t1, t2, interval);

without introducing a whole set of new functions.
2022-03-14 13:00:05 -07:00
Ondřej Surý
e6ca2a651f Refactor isc_timer_reset() use with semantic patch
Add and apply semantic patch to remove expires argument from the
isc_timer_reset() calls through the codebase.
2022-03-14 13:00:05 -07:00
Ondřej Surý
6437bcc488 Remove expires argument from isc_timer API
The isc_timer_reset() now works only with intervals for once timers.

This makes the API almost 1:1 compatible with the libuv timers making
the further refactoring possible.
2022-03-14 13:00:05 -07:00
Ondřej Surý
27850a5ad2 Change isc_timer_reset() usage to never use expires argument
There were two places where expires argument (absolute isc_time_t value)
was being used.  Both places has been converted to use relative interval
argument in preparation of simplification and refactoring of isc_timer
API.
2022-03-14 13:00:05 -07:00
Ondřej Surý
c259cecc90 Refactor isc_timer_create() to just create timer
The isc_timer_create() function was a bit conflated.  It could have been
used to create a timer and start it at the same time.  As there was a
single place where this was done before (see the previous commit for
nta.c), this was cleaned up and the isc_timer_create() function was
changed to only create new timer.
2022-03-14 13:00:05 -07:00
Ondřej Surý
514053f244 Change lib/dns/nta.c to create inactive timer and then reset it
In nta.c, it was the only place where the active timer was created
directly instead of first creating inactive timer and then starting it
with isc_timer_reset().

Change the code to create inactive timer first, so we can refactor the
isc_timer_create() function.
2022-03-14 13:00:05 -07:00
Ondřej Surý
8fbb42c49c Remove "a temporary hack, 'rndc timerpoke'"
In 2002, "a temporary hack, 'rndc timerpoke'" was added.  It's time
for it to go, so it was removed.
2022-03-14 13:00:05 -07:00
Ondřej Surý
f4751a91f7 Remove unused isc_timer_touch() function
The isc_timer_touch() was unused, just remove it.
2022-03-14 13:00:05 -07:00
Ondřej Surý
bbe1c06a8b Remove isc_timertype_limited from isc_timer API
The isc_timertype_limited timer type was never used (not even in tests).
Remove isc_timertype_limited timer type before planned refactoring.
2022-03-14 13:00:05 -07:00
Petr Špaček
c752dff3b4 Merge branch 'pspacek/manpage-hyperlinks-fix' into 'main'
Fix dig option hyperlinks in the TSIG section of the ARM

See merge request isc-projects/bind9!5979
2022-03-14 12:38:30 +00:00
Petr Špaček
f98a6a5308
Fix dig option hyperlinks in the TSIG section of the ARM
While backporting !5934 I noticed a copy&paste mistake in TSIG
chapter of the ARM.

The incorrect reference was introduced by "Add hyperlinks from
program options to definition in man pages" commit but it is not
worth creating separate MR for that when the backport is not merged
yet.

(cherry picked from commit 4daef4a2a74278a25f4d9935ffa78b01f44bbd83)
2022-03-14 13:22:40 +01:00
Petr Špaček
49d2a12e7c Merge branch 'pspacek/manpage-hyperlinks' into 'main'
Add hyperlinks to manual pages

See merge request isc-projects/bind9!5934
2022-03-14 09:53:02 +00:00
Tony Finch
ad5b0402c9
Regenerate the named.conf manual with hyperlinks
The named.conf grammar is exported to the manual via
doc/misc/rst-options.pl which is the ultimate source
for the non-grammar parts of the man page.
2022-03-14 10:47:45 +01:00
Petr Špaček
1d4d008fc9
Add internal hyperlinks to See Also section of manual pages
Replace :manpage: with :iscman: to generate internal hyperlinks. That
way reader can use links even when offline, and jumps to man pages
for the same version.

Formerly HTML version of man pages did not have links in See Also
section because :manpage: role in Sphinx can generate only external
hyperlinks - and we do not have that enabled.
Enabling the Sphinx :manpage: linking could reliably create hyperlinks
only to external URLs, but that would take users to another version
of docs.

Generated by:
    find bin -name '*.rst' | xargs sed -i -e 's/:manpage:`\([^(]\+\)(\([0-9]\))`/:iscman:`\1(\2) <\1>`/g'
+ hand-edit to revert change for mmencode reference which is
  not provided in our source tree.
2022-03-14 10:46:36 +01:00
Petr Špaček
420a71df57
Remove reference to ndc utility from BIND 8 2022-03-14 10:46:36 +01:00
Petr Špaček
53a5776025
Hyperlink program names to their manual pages
Use the new role :iscman: to replace all occurences or ``binary``
with :iscman:`binary`, creating a hyperlink to the manual page.

Generated using:
    find bin -name *.rst | xargs fgrep --files-with-matches '.. iscman' | xargs -I{} -n1 basename {} .rst > /tmp/progs
    for PROG in $(cat /tmp/progs); do find -name '*.rst' | xargs sed -i -e "s/\`\`$PROG\`\`/:iscman:\`$PROG\`/g"; done

Additional hand-edits were done mainly around filter-aaaa and
filter-a which are program names and and option names at the
same time. Couple more edits was neede to fix .rst syntax broken by
automatic replacement.
2022-03-14 10:46:36 +01:00
Petr Špaček
c7085be211
Use semantic markup for :program: self-references
Sphinx has it's own :program: syntax for refering to program names.
Use it for self-references in manual pages. These self-references are
not clickable and not as eye-cathing as links, which is a good thing.
There is no point in attracting attention to ``dig`` several times on a
single page dedicated to dig itself.

Substituted automatically using:
    find bin  -name *.rst | xargs fgrep --files-with-matches '.. program' | xargs -n1 bash /tmp/repl.sh

With /tmp/repl.sh being:
    BASE=$(basename "$1" .rst)
    sed -i -e "s/\`\`$BASE\`\`/:program:\`$BASE\`/g" "$1"
2022-03-14 10:46:36 +01:00
Petr Špaček
7e7a946d44
Introduce new Sphinx role iscman for ISC manual pages
The new directive and role "iscman" allow to tag & reference man pages in
our source tree. Essentially it is just namespacing for ISC man pages,
but it comes with couple benefits.

Differences from .. _man_program label we formerly used:
- Does not expand :ref:`man_program` into full text of the page header.
- Generates index entry with category "manual page".
- Rendering style is closer to ubiquitous to the one produced
  by ``named`` syntax.

Differences from Sphinx built-in :manpage: role:
- Supports all builders with support for cross-references.
- Generates internal links (unlike :manpage: which generates external
  URLs).
- Checks that target exists withing our source tree.
2022-03-14 10:46:36 +01:00
Tony Finch
ccc6378355
More man page option hyperlinks
The dig man page wanted -h option hyperlink and anchor, and there
were a couple of missing cross-references in the rndc man page.
2022-03-14 10:46:36 +01:00
Petr Špaček
a85df3ff9c
Add hyperlinks from program options to definition in man pages
Side-effect of hyperlinking is that typos in program and option names
are now detected by Sphinx.

Candidate -options were detected using:
    find -name *.rst | xargs grep '``-[^`]'
and then modified from ``-o`` to :option:`-o` using regex
    s/``\(-[^`]\+\)``/:option:`\1`/
+ manual modifications where necessary.

Non-hyphenated options were detected by looking at context around
program names:
    find bin -name *.rst | xargs -I{} -n1 basename {} .rst | sort -u
and grepping for program name with trailing whitespace.

Stand-alone program names like ``named`` are not hyperlinked in this
commit.
2022-03-14 10:46:36 +01:00
Petr Špaček
5f0ee7c303
Fix rndc command in release notes for 9.17.12
rndc checkds does not exist, it should have been rndc dnssec

Related: #2488, !4813
2022-03-14 10:46:36 +01:00
Petr Špaček
8537878c01
Add semantic markup for program names into manual pages
It allows to cross-reference options in man pages from other
documents using :option:`named -g` syntax.
2022-03-14 10:46:36 +01:00
Petr Špaček
ec30944aa4
Denote all command line options using semantic markup (.. option::)
The markup allows referencing individual options, and also makes them
more legible (no more thin red text on gray background).

Most of the work was done using regexes:
    s/^``-\(.*\)``$/.. option:: -\1\r/
    s/^``+\(.*\)``$/.. option:: +\1\r/
on bin/**/*.rst files along with visual inspection and hand-edits,
mostly for positional arguments.

Regex for rndc.rst:
    s/^``\(.*\)``/.. option:: \1\r/
+ hand edits to remove extra asterisk and whitespace here and there.
2022-03-14 10:46:32 +01:00
Michał Kępień
e9f4d00bf0 Merge branch 'michal/tidy-setup-of-python-based-tests' into 'main'
Tidy setup of Python-based tests

See merge request isc-projects/bind9!5960
2022-03-14 08:30:05 +00:00
Michał Kępień
173ad9cf46 Tweak Automake conditionals for pytest-based tests
Since pytest itself skips tests using dnspython if the latter is not
available, also using Automake conditionals for silently skipping
pytest-based tests requiring dnspython is redundant and hides
information.  Allow all pytest-based tests requiring dnspython to be run
whenever pytest itself is available, in order to ensure test skipping is
done in a uniform manner.

Note that the above reasoning only applies to pytest-based tests, so
similar adjustments were not made for shell-based tests using Python
scripts that require dnspython ("chain", "cookie", "dnssec", "qmin").
2022-03-14 08:59:32 +01:00
Michał Kępień
00392921f0 Rework skipping long tests
The ability to conveniently mark tests which should only be run when the
CI_ENABLE_ALL_TESTS environment variable is set seems to be useful on a
general level and therefore it should not be limited to the "timeouts"
system test, where it is currently used.

pytest documentation [1] suggests to reuse commonly used test markers by
putting them all in a single Python module which then has to be imported
by test files that want to use the markers defined therein.  Follow that
advice by creating a new bin/tests/system/pytest_custom_markers.py
Python module containing the relevant marker definitions.

Note that "import pytest_custom_markers" works from a test-specific
subdirectory because pytest modifies sys.path so that it contains the
paths to all parent directories containing a conftest.py file (and
bin/tests/system/ is one).  PyLint does not like that, though, so add a
relevant PyLint suppression.

The above changes make bin/tests/system/timeouts/conftest.py redundant,
so remove it.

[1] https://docs.pytest.org/en/7.0.x/how-to/skipping.html#id1
2022-03-14 08:59:32 +01:00
Michał Kępień
49312d6bb2 Rework imports in dnspython-based system tests
Ensure all "import dns.*" statements are always placed after
pytest.importorskip('dns') calls, in order to allow the latter to
fulfill their purpose.  Explicitly import all dnspython modules used by
each dnspython-based test to avoid relying on nested imports.  Replace
function-scoped imports with global imports to reduce code duplication.
2022-03-14 08:59:32 +01:00
Michał Kępień
05c97f2329 Fix skipping tests requiring dnspython
The intended purpose of the @pytest.mark.dnspython{,2} decorators was to
cause dnspython-based tests to be skipped if dnspython is not available
(or not recent enough).  However, a number of system tests employing
those decorators contain global "import dns.resolver" statements which
trigger ImportError exceptions during test initialization if dnspython
is not available.  In other words, the @pytest.mark.dnspython{,2}
decorators serve no useful purpose.

Currently, whenever a Python-based test requires dnspython, that
requirement applies to all tests in a given *.py file.  Given that,
employ global pytest.importorskip() calls to ensure dnspython-based
parts of various system tests are skipped when dnspython is not
available.  Remove all occurrences of the @pytest.mark.dnspython{,2}
decorators (and all associated code) to prevent confusion.
2022-03-14 08:59:32 +01:00
Michał Kępień
704ad2907f Fix skipping tests requiring the requests module
The intended purpose of the @pytest.mark.requests decorator was to cause
Python-based parts of the "statschannel" system test to be skipped if
the requests Python module is not available.  However, both
tests-json.py and tests-xml.py contain a global "import requests"
statement which triggers ImportError exceptions during test
initialization if the requests module is not available.  In other words,
the @pytest.mark.requests decorator serves no useful purpose.

Since all tests in both tests-json.py and tests-xml.py depend on the
requests Python module, employ pytest.importorskip() to ensure the
Python-based parts of the "statschannel" system test are skipped when
the requests module is not available.  Remove all occurrences of the
@pytest.mark.requests decorator (and all associated code) to prevent
confusion.
2022-03-14 08:59:32 +01:00
Michał Kępień
286b57c7f1 Simplify skipping tests depending on libxml2
All tests in bin/tests/system/statschannel/tests-xml.py require libxml2
support to be enabled in BIND 9 at build-time.  Instead of applying the
same pytest.mark.skipif() decorator to every test in that file, set the
'pytestmark' global accordingly in order to immediately skip all tests
in tests-xml.py if libxml2 support is not compiled in.

Remove all occurrences of the @pytest.mark.xml decorator (and all
associated code) from the "statschannel" system test as the
xml.etree.ElementTree module is a part of the Python standard library
since Python 2.5 (so checking whether it is available is redundant) and
checking for libxml2 support in the tested BIND 9 build is already
handled by setting the 'pytestmark' global accordingly.
2022-03-14 08:59:32 +01:00
Michał Kępień
0a76f186a5 Simplify skipping tests depending on json-c
All tests in bin/tests/system/statschannel/tests-json.py require json-c
support to be enabled in BIND 9 at build-time.  Instead of applying the
same pytest.mark.skipif() decorator to every test in that file, set the
'pytestmark' global accordingly in order to immediately skip all tests
in tests-json.py if json-c support is not compiled in.

Remove all occurrences of the @pytest.mark.json decorator (and all
associated code) from the "statschannel" system test as the json module
is a part of the Python standard library since Python 2.6 (so checking
whether it is available is redundant) and checking for json-c support in
the tested BIND 9 build is already handled by setting the 'pytestmark'
global accordingly.

Also remove a related excerpt from bin/tests/system/rpzextra/conftest.py
as it is a copy-paste artifact that serves no purpose in the "rpzextra"
system test.
2022-03-14 08:59:32 +01:00
Michał Kępień
96b7f9f9aa Refactor "statschannel" test's helper modules
The "statschannel" system test contains two Python helper modules:

  - generic.py: test functions directly invoked by both tests-json.py
    and test-xml.py,

  - helper.py: helper functions invoked by test functions in generic.py.

The above logic for splitting helper functions into Python modules
prevents selective test skipping from working due to unconditional
import statements being present in both helper modules.  For example, if
dnspython is not available on the test host, tests-json.py imports
generic.py, which in turn imports helper.py, which in turn attempts to
import various dnspython modules, triggering ImportError exceptions
during test initialization.  Various decorators used for some tests
(like @pytest.mark.dnspython) suggest that such a scenario should be
handled gracefully, but that is not the case - modifying the test
collection in conftest.py does not prevent pytest from failing due to
import errors.

Fix by moving helper functions around to achieve a different split:

  - generic.py: helper functions only relying on the Python standard
    library,

  - generic_dnspython.py: helper functions requiring dnspython.

Only two tests in tests-{json,xml}.py need dnspython to work
(test_traffic_json(), test_traffic_xml()).  Since all
dnspython-dependent code is now present in generic_dnspython.py, employ
pytest.importorskip() in those two tests to ensure they can be
selectively skipped when dnspython is not available.  Adjust other code
to account for the revised Python helper module layout.  Remove all
occurrences of the @pytest.mark.dnspython decorator (and all associated
code) from the "statschannel" system test to prevent confusion.
2022-03-14 08:59:32 +01:00
Michał Kępień
4e0d576858 Improve test discovery logic in get_ports.sh
The find invocation used by the bin/tests/system/get_ports.sh script
("find . -maxdepth 1 -mindepth 1 -type d") assumes the list of
directories in bin/tests/system/ remains unchanged throughout the run
time of a single system test suite.  With pytest in use and the
conftest.py file now present in bin/tests/system/, that assumption is no
longer true as a __pycache__ directory may be created when the first
pytest-based test is started.  Since the list of names returned by the
above find invocation serves as a fixed-size array of "port range
slots", any changes to that list during a system test suite run may lead
to port assignment collisions [1].

Fix by making the find invocation more nuanced, so that it only returns
names of directories containing test code.  Squash a grep / cut pipeline
into a single awk invocation.

[1] see commit 31e5ca4bd9f50b9e0ad5a88685225afacb073a8a
2022-03-14 08:59:32 +01:00
Michał Kępień
53ef8835c1 Reuse common port-related test fixtures
Most Python-based system tests need to know which ports were assigned to
a given test by bin/tests/system/get_ports.sh.  This is currently
handled by inspecting the values of various environment variables (set
by bin/tests/system/run.sh) and passing the port numbers to Python
scripts via pytest fixtures.  However, this glue code has so far been
copy-pasted into each system test using it, rather than reused.

Since pytest also looks for conftest.py files in parent directories,
move commonly used fixtures to bin/tests/system/conftest.py.  Set the
scope of all the moved fixtures to "session" as their return values are
only based on environment variables, so there is no point in recreating
them for every test requesting them.  Adjust test code accordingly.
2022-03-14 08:59:32 +01:00
Ondřej Surý
342c06c335 Merge branch '3203-fix-the-build-flag-order' into 'main'
Fix the remaining cases of <prog>_CFLAGS -> <prog>_CPPFLAGS

Closes #3203

See merge request isc-projects/bind9!5971
2022-03-13 17:50:50 +00:00
Ondřej Surý
41a60a0e21 Fix the remaining cases of <prog>_CFLAGS -> <prog>_CPPFLAGS
Building BIND 9 with older version of BIND 9 installed would result in
build failure.  Fix the last two remaining cases where <prog>_CFLAGS was
being used leading to wrong order of the build flags on the command line.
2022-03-13 17:42:09 +01:00
Petr Špaček
b103f516d0 Merge branch '2799-doc-build-fixes' into 'main'
Fix docs build

See merge request isc-projects/bind9!5961
2022-03-11 11:20:50 +00:00
Petr Špaček
524fce77fe
Fix docs build from tarball broken by MR !5254
Related: !5254
2022-03-11 10:54:39 +01:00
Petr Špaček
b0f6fc7f2f
Shorten artifact retention for docs:tarball job to one day
We now run both docs and docs:tarball jobs at the same time and keeping
artifacts for longer period of time is a waste.

Artifacts for docs job has to be kept for long period of time because
they are used by scripts behind bind.isc.org web site.
2022-03-11 10:54:35 +01:00