Commit graph

2526 commits

Author SHA1 Message Date
Michał Kępień
b6c77202cb Restore zone database and zone node if cache search results are to be ignored
When query processing hits a delegation from a locally configured zone,
an attempt may be made to look for a better answer in the cache.  In
such a case, the zone-sourced delegation data is set aside and the
lookup is retried using the cache database.  When that lookup is
completed, a decision is made whether the answer found in the cache is
better than the answer found in the zone.

Currently, if the zone-sourced answer turns out to be better than the
one found in the cache:

  - qctx->zdb is not restored into qctx->db,
  - qctx->node, holding the zone database node found, is not even saved.

Thus, in such a case both qctx->db and qctx->node will point at cache
data.  This is not an issue for BIND versions which do not support
mirror zones because in these versions non-recursive queries always
cause the zone-sourced delegation to be returned and thus the
non-recursive part of query_delegation() is never reached if the
delegation is coming from a zone.  With mirror zones, however,
non-recursive queries may cause cache lookups even after a zone
delegation is found.  Leaving qctx->db assigned to the cache database
when query_delegation() determines that the zone-sourced delegation is
the best answer to the client's query prevents DS records from being
added to delegations coming from mirror zones.  Fix this issue by
keeping the zone database and zone node in qctx while the cache is
searched for an answer and then restoring them into qctx->db and
qctx->node, respectively, if the zone-sourced delegation turns out to be
the best answer.  Since this change means that qctx->zdb cannot be used
as the glue database any more as it will be reset to NULL by RESTORE(),
ensure that qctx->db is not a cache database before attaching it to
qctx->client->query.gluedb.

Furthermore, current code contains a conditional statement which
prevents a mirror zone from being used as a source of glue records.
Said statement was added to prevent assertion failures caused by
attempting to use a zone database's glue cache for finding glue for an
NS RRset coming from a cache database.  However, that check is overly
strict since it completely prevents glue from being added to delegations
coming from mirror zones.  With the changes described above in place,
the scenario this check was preventing can no longer happen, so remove
the aforementioned check.

If qctx->zdb is not NULL, qctx->zfname will also not be NULL;
qctx->zsigrdataset may be NULL in such a case, but query_putrdataset()
handles pointers to NULL pointers gracefully.  Remove redundant
conditional expressions to make the cleanup code in query_freedata()
match the corresponding sequences of SAVE() / RESTORE() macros more
closely.
2018-08-08 08:07:46 +02:00
Ondřej Surý
afddc2781e Modify the rrsetorder test to cope with the rrset order randomization (only four orders are now possible) 2018-08-06 11:24:14 +02:00
Mark Andrews
a94db46631 only check the bit map 2018-08-03 08:21:48 +10:00
Mark Andrews
abe41ba011 use guard values for testing unixtime serial 2018-08-02 10:25:56 +10:00
Mark Andrews
6b30bc73c0 save SOA values 2018-08-01 20:04:09 -04:00
Mark Andrews
2e688488f7 test mdig '+ednsopt=:' handling 2018-08-02 08:55:01 +10:00
Ondřej Surý
71877806e8 Fix ax_check_openssl to accept yes and improve it to modern autotools standard 2018-07-23 22:10:52 +02:00
Ondřej Surý
83cde08522 Introduce USE_OPENSSL define to Windows build, remove CRYPTO and AES conditions. 2018-07-19 16:54:53 -04:00
Ondřej Surý
c40425d0f6 RSA and ECDSA cryptography is now mandatory; remove the checks for those 2018-07-19 12:47:03 -04:00
Ondřej Surý
c3b8130fe8 Make OpenSSL mandatory 2018-07-19 12:47:03 -04:00
Michał Kępień
8666f8d28f Fix handling of TAT sending failures
dns_view_zonecut() may associate the dns_rdataset_t structure passed to
it even if it returns a result different then ISC_R_SUCCESS.  Not
handling this properly may cause a reference leak.  Fix by ensuring
'nameservers' is cleaned up in all relevant failure modes.
2018-07-20 01:55:50 +10:00
Michał Kępień
e10e6756c9 [squash] Make resolver tests even more civilized (ans8.pl)
Set AA=1 even for truncated responses.  Put glue record in responses to
no-questions/NS queries.  Add comments, simplify code.
2018-07-17 13:01:42 +02:00
Michał Kępień
82082ecd56 [squash] Make resolver tests even more civilized (ans2.pl and ans3.pl)
Prevent ans2.pl from responding authoritatively for any name at or below
example.net.

Make ans3.pl properly answer example.net/NS queries.  Use string
comparisons instead of regular expressions where possible.
2018-07-17 13:00:34 +02:00
Michał Kępień
122a1a00be [squash] Put Perl code extracting a tree from a cache dump in a separate function 2018-07-17 11:31:09 +02:00
Witold Kręcicki
c96ca40023 cacheclean test: take into account that we can have multiple RRs at one name 2018-07-17 11:31:09 +02:00
Witold Kręcicki
c8b36ea6b9 Make resolver tests more civilized 2018-07-17 11:31:09 +02:00
Michał Kępień
618921902a Do not replace lo0 address on Solaris
lo0 and lo0:0 are the same interface on Solaris.  Make sure
bin/tests/system/ifconfig.sh does not touch lo0:0 in order to prevent it
from changing the address of the loopback interface on Solaris.
2018-07-16 08:55:22 +02:00
Michał Kępień
2be97feb46 Do not spam console if "git status --ignored" fails during tests
The "git status" command in Git versions before 1.7.2 does not support
the "--ignored" option.  Prevent spamming the console when running
system tests from a Git repository on a host with an ancient Git version
installed.
2018-07-13 08:22:12 +02:00
Michał Kępień
fd30a03f2b Remove IDN subtest from the "digdelv" system test
The output of certain "dig +idnout" invocations may be locale-dependent.
Remove the "dig +idnout" subtest from the "digdelv" system test as IDN
support is already thoroughly tested by the "idna" system test.
2018-07-13 08:22:12 +02:00
Michał Kępień
cc0e8cda71 Include conf.sh from all prereq.sh scripts
Every prereq.sh script must include bin/tests/system/conf.sh, otherwise
if some prerequisite is not met, errors about echo_i not being found
will be printed instead of actual error messages.
2018-07-13 08:22:12 +02:00
Mark Andrews
ad86878d61 add test for bad dig option '+ednsopt=:' being handled gracefully 2018-07-11 11:22:26 -07:00
Mukund Sivaraman
a7e6a584ea Add system tests for "tcp-self" update-policy 2018-07-11 10:55:24 -07:00
Mark Andrews
9bd14e2d1f add required whitespace 2018-07-11 09:30:10 +02:00
Michał Kępień
a7657dc150 Send upstream TAT queries for locally served zones
Trying to resolve a trust anchor telemetry query for a locally served
zone does not cause upstream queries to be sent as the response is
determined just by consulting local data.  Work around this issue by
calling dns_view_findzonecut() first in order to determine the NS RRset
for a given domain name and then passing the zone cut found to
dns_resolver_createfetch().

Note that this change only applies to TAT queries generated by the
resolver itself, not to ones received from downstream resolvers.
2018-07-11 08:27:10 +02:00
Michał Kępień
dbfd19c668 Do not reuse zones whose "mirror" setting was changed
Update named_zone_reusable() so that it does not consider a zone to be
eligible for reuse if its old value of the "mirror" option differs from
the new one.  This causes "rndc reconfig" to create a new zone structure
whenever the value of the "mirror" option is changed, which ensures that
the previous zone database is not reused and that flags are properly set
in responses sourced from zones whose "mirror" setting was changed at
runtime.
2018-07-10 17:36:22 -07:00
Michał Kępień
c4209418a5 Do not use Net::DNS::Nameserver in the "serve-stale" system test
Net::DNS versions older than 0.67 respond to queries sent to a
Net::DNS::Nameserver even if its ReplyHandler returns undef.  This makes
the "serve-stale" system test fail as it takes advantage of the newer
behavior.  Since the latest Net::DNS version available with stock
RHEL/CentOS 6 packages is 0.65 and we officially support that operating
system, bin/tests/system/serve-stale/ans2/ans.pl should behave
consistently for various Net::DNS versions.  Ensure that by reworking it
so that it does not use Net::DNS::Nameserver.
2018-07-10 15:04:14 +02:00
Michał Kępień
6c3c6aea37 Fix a Net::DNS version quirk in the "resolver" system test
Net::DNS versions older than 0.68 insert a ./ANY RR into the QUESTION
section if the latter is empty.  Since the latest Net::DNS version
available with stock RHEL/CentOS 6 packages is 0.65 and we officially
support that operating system, bin/tests/system/resolver/ans8/ans.pl
should behave consistently for various Net::DNS versions.  Ensure that
by making handleUDP() return the query ID and flags generated by
Net::DNS with 8 zero bytes appended.
2018-07-10 14:53:29 +02:00
Michał Kępień
b896fc4972 Improve error handling in idn_ace_to_locale()
While idn2_to_unicode_8zlz() takes a 'flags' argument, it is ignored and
thus cannot be used to perform IDN checks on the output string.

The bug in libidn2 versions before 2.0.5 was not that a call to
idn2_to_unicode_8zlz() with certain flags set did not cause IDN checks
to be performed.  The bug was that idn2_to_unicode_8zlz() did not check
whether a conversion can be performed between UTF-8 and the current
locale's character encoding.  In other words, with libidn2 version
2.0.5+, if the current locale's character encoding is ASCII, then
idn2_to_unicode_8zlz() will fail when it is passed any Punycode string
which decodes to a non-ASCII string, even if it is a valid IDNA2008
name.

Rework idn_ace_to_locale() so that invalid IDNA2008 names are properly
and consistently detected for all libidn2 versions and locales.

Update the "idna" system test accordingly.  Add checks for processing a
server response containing Punycode which decodes to an invalid IDNA2008
name.  Fix invalid subtest description.
2018-07-10 14:34:35 +02:00
Michał Kępień
59cdaef4f7 Remove IDNA2003 fallback from dig
Certain characters, like symbols, are allowed by IDNA2003, but not by
IDNA2008.  Make dig reject such symbols when IDN input processing is
enabled to ensure BIND only supports IDNA2008.  Update the "idna" system
test so that it uses one of such symbols rather than one which is
disallowed by both IDNA2003 and IDNA2008.
2018-07-10 14:34:35 +02:00
Michał Kępień
a0571d3851 Rework libidn2 detection
Clean up the parts of configure.in responsible for handling libidn2
detection and adjust other pieces of the build system to match these
cleanups:

  - use pkg-config when --with-libidn2 is used without an explicit path,

  - look for idn2_to_ascii_lz() rather than idn2_to_ascii_8z() as the
    former is used in BIND while the latter is not,

  - do not look for idn2_to_unicode_8zlz() as it is present in all
    libidn2 versions which have idn2_to_ascii_lz(),

  - check whether the <idn2.h> header is usable,

  - set LDFLAGS in the Makefile for dig so that, if specified, the
    requested libidn2 path is used when linking with libidn2,

  - override CPPFLAGS when looking for libidn2 components so that the
    configure script does not produce warnings when libidn2 is not
    installed system-wide,

  - merge the AS_CASE() call into the AS_IF() call below it to simplify
    code,

  - indicate the default value of --with-libidn2 in "./configure --help"
    output,

  - use $with_libidn2 rather than $use_libidn2 to better match the name
    of the configure script argument,

  - stop differentiating between IDN "in" and "out" support, i.e. make
    dig either support libidn2 or not; remove WITH_* Autoconf macros and
    use a new one, HAVE_LIBIDN2, to determine whether libidn2 support
    should be enabled.
2018-07-10 14:34:35 +02:00
Witold Kręcicki
7f60bb39df Don't synthesize NXDOMAIN from NSEC for records under a DNAME 2018-07-10 03:20:21 -04:00
Michał Kępień
73d64de779 Make "rndc zonestatus" output for mirror zones different than for regular slave zones
Replace "type: slave" with "type: mirror" in "rndc zonestatus" output
for mirror zones in order to enable the user to tell a regular slave
zone and a mirror zone apart.
2018-06-28 13:38:39 +02:00
Michał Kępień
dd30f53edc Disable notifies for mirror zones unless also-notify is used
Since the mirror zone feature is expected to mostly be used for the root
zone, prevent slaves from sending NOTIFY messages for mirror zones by
default.  Retain the possibility to use "also-notify" as it might be
useful in certain cases.
2018-06-28 13:38:39 +02:00
Michał Kępień
3af412c0e0 Disable outgoing mirror zone transfers by default
As mirror zone data should be treated the way validated, cached DNS
responses are, outgoing mirror zone transfers should be disabled unless
they are explicitly enabled by zone configuration.
2018-06-28 13:38:39 +02:00
Michał Kępień
c3f3b824e7 Treat mirror zone data as cache data for access control purposes
As mirror zone data should be treated the way validated, cached DNS
responses are, it should not be used when responding to clients who are
not allowed cache access.  Reuse code responsible for determining cache
database access for evaluating mirror zone access.
2018-06-28 13:38:39 +02:00
Michał Kępień
8d996fd79c Fall back to normal recursion when mirror zone data is unavailable
If transferring or loading a mirror zone fails, resolution should still
succeed by means of falling back to regular recursive queries.
Currently, though, if a slave zone is present in the zone table and not
loaded, a SERVFAIL response is generated.  Thus, mirror zones need
special handling in this regard.

Add a new dns_zt_find() flag, DNS_ZTFIND_MIRROR, and set it every time a
domain name is looked up rather than a zone itself.  Handle that flag in
dns_zt_find() in such a way that a mirror zone which is expired or not
yet loaded is ignored when looking up domain names, but still possible
to find when the caller wants to know whether the zone is configured.
This causes a fallback to recursion when mirror zone data is unavailable
without making unloaded mirror zones invisible to code checking a zone's
existence.
2018-06-28 13:38:39 +02:00
Michał Kępień
e3160b27f7 Ensure responses sourced from mirror zones have the AD bit set
Zone RRsets are assigned trust level "ultimate" upon load, which causes
the AD bit to not be set in responses coming from slave zones, including
mirror zones.  Make dns_zoneverify_dnssec() update the trust level of
verified RRsets to "secure" so that the AD bit is set in such responses.
No rollback mechanism is implemented as dns_zoneverify_dnssec() fails in
case of any DNSSEC failure, which causes the mirror zone version being
verified to be discarded.
2018-06-28 13:38:39 +02:00
Michał Kępień
ad0ec2ea93 Do not treat mirror zone data as authoritative
Section 4 of RFC 7706 suggests that responses sourced from a local copy
of a zone should not have the AA bit set.  Follow that recommendation by
setting 'qctx->authoritative' to ISC_FALSE when a response to a query is
coming from a mirror zone.
2018-06-28 13:38:39 +02:00
Michał Kępień
179d5faa28 Ensure delegations inside mirror zones are properly handled for non-recursive queries
When a resolver is a regular slave (i.e. not a mirror) for some zone,
non-recursive queries for names below that slaved zone will return a
delegation sourced from it.  This behavior is suboptimal for mirror
zones as their contents should rather be treated as validated, cached
DNS responses.  Modify query_delegation() and query_zone_delegation() to
permit clients allowed cache access to check its contents for a better
answer when responding to non-recursive queries.
2018-06-28 13:38:39 +02:00
Michał Kępień
c9accfde28 Perform basic resolution checks with a mirror zone in use
Make ns3 mirror the "root" zone from ns1 and query the former for a
properly signed record below the root.  Ensure ns1 is not queried during
resolution and that the AD bit is set in the response.
2018-06-28 13:38:39 +02:00
Michał Kępień
edbb256c3a Verify mirror zone journals
As mirror zone files are verified when they are loaded from disk, verify
journal files as well to ensure invalid data is not used.  Reuse the
journals generated during IXFR tests to test this.
2018-06-28 13:38:39 +02:00
Michał Kępień
befd429434 Verify mirror zone files loaded from disk
Verify data read from mirror zone files before it is used in order to
prevent loading corrupt mirror zones from disk.
2018-06-28 13:38:39 +02:00
Michał Kępień
6439a76c6d Verify mirror zone IXFRs
Update ixfr_commit() so that all incoming versions of a mirror zone
transferred using IXFR are verified before being used.
2018-06-28 13:38:39 +02:00
Michał Kępień
d86f1d00ad Verify mirror zone AXFRs
Update axfr_commit() so that all incoming versions of a mirror zone
transferred using AXFR are verified before being used.  If zone
verification fails, discard the received version of the zone, wait until
the next refresh and retry.
2018-06-28 13:38:39 +02:00
Michał Kępień
f86f314d7e Add a system test for mirror zones
Create the basic files comprising a system test and define a few helper
functions which will be useful when testing mirror zones.
2018-06-28 13:38:39 +02:00
Michał Kępień
facb68b22e Implement a "read-only" version of nextpart()
The system test helper function nextpart() always updates the "lines
read so far" marker ("<file>.prev") when it is called, which somewhat
limits its flexibility.  Add two new helper functions, nextpartpeek()
and nextpartreset(), so that certain parts of log files can be easily
examined more than once.  Add some documentation to help understand the
purpose of each function in the nextpart*() family.
2018-06-28 13:38:39 +02:00
Mark Andrews
7288d321ae remove re-signing race when testing dnskey-sig-validity 2018-06-27 07:27:07 -04:00
Mark Andrews
75888a1f16 improve forensics 2018-06-27 07:27:06 -04:00
Mukund Sivaraman
a60cef9dec Add system test
(cherry picked from commit a5933fa2bb)
2018-06-26 15:10:34 -07:00
Mukund Sivaraman
06d3106002 return FORMERR when question section is empty if COOKIE is not present 2018-06-26 13:50:15 -07:00