Commit graph

9959 commits

Author SHA1 Message Date
Witold Kręcicki
38b78f59a0 Add DoT support to bind
Parse the configuration of tls objects into SSL_CTX* objects.  Listen on
DoT if 'tls' option is setup in listen-on directive.  Use DoT/DoH ports
for DoT/DoH.
2020-11-10 14:16:55 +01:00
Evan Hunt
8ed005f924 add parser support for TLS configuration options
This commit adds stub parser support and tests for:
- "tls" statement, specifying key and cert.
- an optional "tls" keyvalue in listen-on statements for DoT
  configuration.

Documentation for these options has also been added to the ARM, but
needs further work.
2020-11-10 14:16:49 +01:00
Evan Hunt
8886569e9d report peer address in TLS mode, and specify protocol
- peer address was not being reported correctly by "dig +tls"
- the protocol used is now reported in the dig output: UDP, TCP, or TLS.
2020-11-10 14:16:41 +01:00
Witold Kręcicki
03b2c948b6 add "dig +tls"
- add "+[no]tls" option to dig to enable TLS mode
- override the default port number in dig from 53 to 853 when using TLS
2020-11-10 14:16:35 +01:00
Mark Andrews
2b7128fede Check that DNSTAP captures forwarded UPDATE responses 2020-11-10 06:15:46 +00:00
Mark Andrews
06db7a153f Retry edns512 multiple times to trigger fallback to edns at 512
We want named to have slow resolving (multiple retries) when
there is a very small working MTU
2020-11-09 21:45:44 +00:00
Mark Andrews
b5145f46dc Fixup legacy test to account for not falling back to EDNS 512 lookups.
The SOA lookup for edns512 could succeed if the negative response
for ns.edns512/AAAA completed before all the edns512/SOA query
attempts are made.  The ns.edns512/AAAA lookup returns tc=1 and
the SOA record is cached after processing the NODATA response.
Lookup a TXT record at edns512 and look it up instead of the
SOA record.

Removed 'checking that TCP failures do not influence EDNS statistics
in the ADB' as it is no longer appropriate.
2020-11-09 21:45:44 +00:00
Evan Hunt
e011521ef1 address some possible shutdown races in xfrin
there were two failures during observed in testing, both occurring
when 'rndc halt' was run rather than 'rndc stop' - the latter dumps
zone contents to disk and presumably introduced enough delay to
prevent the races:

- a failure when the zone was shut down and called dns_xfrin_detach()
  before the xfrin had finished connecting; the connect timeout
  terminated without detaching its handle
- a failure when the tcpdns socket timer fired after the outerhandle
  had already been cleared.

this commit incidentally addresses a failure observed in mutexatomic
due to a variable having been initialized incorrectly.
2020-11-09 12:33:37 -08:00
Ondřej Surý
127ba7e930 Add libssl libraries to Windows build
This commit extends the perl Configure script to also check for libssl
in addition to libcrypto and change the vcxproj source files to link
with both libcrypto and libssl.
2020-11-09 16:00:28 +01:00
Evan Hunt
49d53a4aa9 use netmgr for xfrin
Use isc_nm_tcpdnsconnect() in xfrin.c for zone transfers.
2020-11-09 13:45:43 +01:00
Ondřej Surý
b558eca633 dig: Refactor recv_done, so there's less exit paths
The recv_done() callback had many exit paths with different conditions,
and every path had it's own set of destructors.  The refactored code now
has unified exit path with descriptive goto labels matching the intent:

 - cancel_lookup
 - next_lookup
 - detach_query
 - keep_query

The only exception to the rule is check_for_more_data() path, where the
part of the query gets reused, so the query->readhandle and query gets
detached on it's own, and by going to the keep_query, we are just
skipping calling the destructors again.
2020-11-08 13:36:12 -08:00
Evan Hunt
88f5f3915b dig: prevent query from being detached if udpconnect fails on first attempt
FreeBSD sometimes returns spurious errors in UDP connect() attempts,
so we try a few times before giving up. However, each failed attempt
triggers a call to udp_ready() in dighost.c, and that was causing
the query object to be detached prematurely.
2020-11-07 21:11:58 +01:00
Ondřej Surý
6d63ffe46d dig: add reference counter to the dig_lookup_t object
Sometimes, the dig_lookup_t could be destroyed before the final
send_done() callback was be called, leading to dereferencing an
already freed dig_lookup_t object.  By making the dig_lookup_t
reference counted, we are ensuring that it won't be freed until
the last reference (from dig_query_t .lookup) is released.
2020-11-07 21:11:42 +01:00
Ondřej Surý
ecd70eb4b5 dig: add new debugging output
track creation, attachment and detachment of dig_query objects.
2020-11-07 20:49:53 +01:00
Ondřej Surý
a2bc627c30 dig: add reference counting to dig_query_t
add a reference counter to the dig_query object to ensure
it isn't freed until the last caller releases it.
2020-11-07 20:49:53 +01:00
Evan Hunt
5307bf64ce reduce timing dependencies in system tests
one of the tests in the resolver system test depends on dig
getting no response to its first two query attempts, and SERVFAIL
on the third after resolution times out.

using a 5-second retry timer in dig means the SERVFAIL response
could occur while dig is discarding the second query and preparing
to send the third. in this case the server's response could be
missed.  shortening the retry interval to 4 seconds ensures that
dig has already sent the third query when the SERVFAIL response
arrives.

also, the serve-stale system test could fail due to a race in which
it timed out after waiting ten seconds for a file to be written, and
the dig timeout was just a bit longer. this is addressed by extending
the dig timeout to 11 seconds for this test.
2020-11-07 20:49:53 +01:00
Evan Hunt
ea2b04c361 dig: use new netmgr timeout mechanism
use isc_nmhandle_settimeout() to set read/recv timeouts, and get rid
of connect_timeout() and related functions in dighost.c.
2020-11-07 20:49:53 +01:00
Evan Hunt
e12dc1faa2 dig: setup IDN whenever printing a message
because dig now uses the netmgr, printing of response messages
happens in a different thread than setup. the IDN output filtering
procedure, which set using dns_name_settotextfilter(), is stored as
thread-local data, and so if it's set during setup, it won't be
accessible when printing. we now set it immediately before printing,
in the same thread, and clear it immedately afterward.
2020-11-07 20:49:53 +01:00
Evan Hunt
cde27d2d2b dig: remove "+unexpected" option
The network manager does not support returning UDP datagrams to
clients from unexpected sources; it is therefore not possible for
dig to accept them.  The "+[no]unexpected" option has therefore
been removed from the dig command and its documentation.
2020-11-07 20:49:53 +01:00
Evan Hunt
94b7988efb convert dig/host/nslookup to use the netmgr
use netmgr functions instead of isc_socket for dig, host, and
nslookup. note that `dig +unexpected` is not working.
2020-11-07 20:49:53 +01:00
Michal Nowak
ef6703351a
Drop bigkey
The 'bigkey' binary is not used anywhere, therefor it's sources should
be removed.
2020-11-05 17:17:14 +01:00
Michał Kępień
39191052ad Wait for the "fast-expire" zone to be transferred
In order for a "fast-expire/IN: response-policy zone expired" message to
be logged in ns3/named.run, the "fast-expire" zone must first be
transferred in by that server.  However, with unfavorable timing, ns3
may be stopped before it manages to fetch the "fast-expire" zone from
ns5 and after the latter has been reconfigured to no longer serve that
zone.  In such a case, the "rpz" system test will report a false
positive for the relevant check.  Prevent that from happening by
ensuring ns3 manages to transfer the "fast-expire" zone before getting
shut down.
2020-11-05 07:53:43 +01:00
Matthijs Mekking
518dd0bb17 kasp test: Use DEFAULT_ALGORITHM in tests.sh
Some setup scripts uses DEFAULT_ALGORITHM in their dnssec-policy
and/or initial signing. The tests still used the literal values
13, ECDSAP256SHA256, and 256. Replace those occurrences where
appropriate.
2020-11-04 12:41:25 +01:00
Matthijs Mekking
7e0ec9f624 Add a test for RFC 8901 signer model 2
The new 'dnssec-policy' was already compatible with multi-signer
model 2, now we also have a test for it.
2020-11-04 12:40:04 +01:00
Mark Andrews
40ae128922 dnssec system test needs python and perl 2020-11-03 11:22:36 +11:00
Evan Hunt
5dcdc00b93 add netmgr functions to support outgoing DNS queries
- isc_nm_tcpdnsconnect() sets up up an outgoing TCP DNS connection.
- isc_nm_tcpconnect(), _udpconnect() and _tcpdnsconnect() now take a
  timeout argument to ensure connections time out and are correctly
  cleaned up on failure.
- isc_nm_read() now supports UDP; it reads a single datagram and then
  stops until the next time it's called.
- isc_nm_cancelread() now runs asynchronously to prevent assertion
  failure if reading is interrupted by a non-network thread (e.g.
  a timeout).
- isc_nm_cancelread() can now apply to UDP sockets.
- added shim code to support UDP connection in versions of libuv
  prior to 1.27, when uv_udp_connect() was added

all these functions will be used to support outgoing queries in dig,
xfrin, dispatch, etc.
2020-10-30 11:11:54 +01:00
Mark Andrews
d7840f4b93 Check that a zone in the process of being signed resolves
ans10 simulates a local anycast server which has both signed and
unsigned instances of a zone.  'A' queries get answered from the
signed instance.  Everything else gets answered from the unsigned
instance.  The resulting answer should be insecure.
2020-10-30 00:17:24 +11:00
Evan Hunt
78af071c11 fix a typo in rpz test
"tcp-only" was not being tested correctly in the RPZ system test
because the option to the "digcmd" function that causes queries to
be sent via TCP was misspelled in one case, and was being interpreted
as a query name.

the "ckresult" function has also been changed to be case sensitive
for consistency with "digcmd".
2020-10-28 21:39:35 -07:00
Ondřej Surý
38f34c266d Fix possible NULL dereference in cd->dlz_destroy()
If the call to cd->dlz_create() in dlopen_dlz_create() fails, cd->dbdata
may be NULL when dlopen_dlz_destroy() gets called in the cleanup path
and passing NULL to the cd->dlz_destroy() callback may cause a NULL
dereference.  Ensure that does not happen by checking whether cd->dbdata
is non-NULL before calling the cd->dlz_destroy() callback.
2020-10-28 15:48:58 +01:00
Ondřej Surý
37b9511ce1 Use libuv's shared library handling capabilities
While libltdl is a feature-rich library, BIND 9 code only uses its basic
capabilities, which are also provided by libuv and which BIND 9 already
uses for other purposes.  As libuv's cross-platform shared library
handling interface is modeled after the POSIX dlopen() interface,
converting code using the latter to the former is simple.  Replace
libltdl function calls with their libuv counterparts, refactoring the
code as necessary.  Remove all use of libltdl from the BIND 9 source
tree.
2020-10-28 15:48:58 +01:00
Ondřej Surý
e2436159ab Refactor the cleanup code in lt_dl code
The cleanup code that would clean the object after plugin/dlz/dyndb
loading has failed was duplicating the destructor for the object, so
instead of the extra code, we just use the destructor instead.
2020-10-28 15:48:58 +01:00
Ondřej Surý
4e9a58a3e6 Unify lt_dlopen() error handling
Make sure an error gets logged when any lt_dlopen() call in the source
tree fails.  Also make sure that NULL values returned by lt_dlerror()
are replaced with a generic error message to prevent passing NULL as an
argument for the %s format specifier.
2020-10-28 15:48:58 +01:00
Ondřej Surý
0f49b02fc5 Remove redundant lt_dlerror() calls
The redundant lt_dlerror() calls were taken from the examples to clean
any previous errors from lt_dl...() calls.  However upon code
inspection, it was discovered there are no such paths that could cause
the lt_dlerror() to return spurious error messages.
2020-10-28 15:48:58 +01:00
Michal Nowak
c0c4c024c6
Replace a seq invocation with a shell loop
seq is not portable.  Use a while loop instead to make the "dnssec"
system test script POSIX-compatible.
2020-10-27 12:21:53 +01:00
Michal Nowak
481dfb9671
Get rid of bashisms in string comparisons
The double equal sign ('==') is a Bash-specific string comparison
operator.  Ensure the single equal sign ('=') is used in all POSIX shell
scripts in the system test suite in order to retain their portability.
2020-10-27 12:21:07 +01:00
Michal Nowak
f0b13873a3
Fix system test backtrace generation on OpenBSD
On Linux core dump contains absolute path to crashed binary

    Core was generated by `/home/newman/isc/ws/bind9/bin/named/.libs/lt-named -D glue-ns1 -X named.lock -m'.

However, on OpenBSD there's only a basename

    Core was generated by `named'.

This commit adds support for the latter, retains the former.
2020-10-26 14:58:15 +01:00
Michal Nowak
a0426e0466
Use a POSIX shell in bin/tests/system/ifconfig.sh
Some non-POSIX shells, like /bin/csh on FreeBSD, are unable to execute
the config.guess file:

    + /bin/csh /var/tmp/gitlab_runner/builds/YdCaoq4b/0/mnowak/bind9/config.guess
    timestamp=2018-02-24: Command not found.
    me=config.guess: Command not found.
    Unmatched '"'.

When ./configure is run, it attempts to locate a POSIX-compliant shell.
Use the result of that search in the bin/tests/system/ifconfig.sh
script.
2020-10-23 10:32:21 +02:00
Ondřej Surý
64e56a9704 Postpone the isc_app_shutdown() after rndc response has been sent
When `rndc stop` is received, the isc_app_shutdown() was being called
before response to the rndc client has been sent; as the
isc_app_shutdown() also tears down the netmgr, the message was never
sent and rndc would complain about connection being interrupted in the
middle of the transaction.  We now postpone the shutdown after the rndc
response has been sent.
2020-10-22 11:46:58 -07:00
Ondřej Surý
f7c82e406e Fix the isc_nm_closedown() to actually close the pending connections
1. The isc__nm_tcp_send() and isc__nm_tcp_read() was not checking
   whether the socket was still alive and scheduling reads/sends on
   closed socket.

2. The isc_nm_read(), isc_nm_send() and isc_nm_resumeread() have been
   changed to always return the error conditions via the callbacks, so
   they always succeed.  This applies to all protocols (UDP, TCP and
   TCPDNS).
2020-10-22 11:37:16 -07:00
Michal Nowak
7ef268bb4b
Drop unused bufferlist code 2020-10-22 13:11:16 +02:00
Michal Nowak
1f6f7ccad6
Drop unused portlist code 2020-10-22 13:11:16 +02:00
Michal Nowak
1319875c46
Ensure use of "echo_i" where possible
In many instances 'echo "I:' construct was used where echo_i function
should have been.
2020-10-22 09:54:24 +02:00
Michał Kępień
43beb080fc Minor documentation formatting tweaks 2020-10-22 08:54:32 +02:00
Diego Fronza
8f5545fa0b Adjusted additional system test (NS, non-root zone)
After the updates from this branch, BIND now sends glue records for
NS queries even when configured with minimal-responses yes.
2020-10-21 12:03:42 -03:00
Diego Fronza
b0f61f92b3 Added test for the proposed fix
This test is very simple, two nameserver instances are created:
    - ns4: master, with 'minimal-responses yes', authoritative
        for example. zone
    - ns5: slave, stub zone

The first thing verified is the transfer of zone data from master
to slave, which should be saved in ns5/example.db.

After that, a query is issued to ns5 asking for target.example.
TXT, a record present in the master database with the "test" string
as content.

If that query works, it means stub zone successfully request
nameserver addresses from master, ns4.example. A/AAAA

The presence of both A/AAAA records for ns4 is also verified in the
stub zone local file, ns5/example.db.
2020-10-21 12:03:42 -03:00
Diego Fronza
d934513c42 Fix dnstap system test on FreeBSD
This commit ensures that dnstap output files captured
by fstrm_capture are properly flushed before any attempt
on reading them with dnstap-read is done.

By reading fstrm-capture source code it was noticed that
signal SIGHUP is used to flush the capture file.
2020-10-20 10:18:28 -03:00
Matthijs Mekking
6c5ff94218 Don't increment network error stats on UV_EOF
When networking statistics was added to the netmgr (in commit
5234a8e00a), two lines were added that
increment the 'STATID_RECVFAIL' statistic: One if 'uv_read_start'
fails and one at the end of the 'read_cb'.  The latter happens
if 'nread < 0'.

According to the libuv documentation, I/O read callbacks (such as for
files and sockets) are passed a parameter 'nread'. If 'nread' is less
than 0, there was an error and 'UV_EOF' is the end of file error, which
you may want to handle differently.

In other words, we should not treat EOF as a RECVFAIL error.
2020-10-20 10:57:16 +02:00
Mark Andrews
0abb49034e Drop the expected minimum number of buckets to 4.
The previous value of 5 produced too many false errors.
2020-10-15 00:40:14 +00:00
Mark Andrews
92cdc7b6c7 Try to improve rrl timing
Add a +burst option to mdig so that we have a second to setup the
mdig calls then they run at the start of the next second.

RRL uses 'queries in a second' as a approximation to
'queries per second'. Getting the bursts of traffic to all happen in
the same second should prevent false negatives in the system test.

We now have a second to setup the traffic in.  Then the traffic should
be sent at the start of the next second.  If that still fails we
should move to +burst=<now+2> (further extend mdig) instead of the
implicit <now+1> as the trigger second.
2020-10-15 00:05:12 +00:00
Matthijs Mekking
fedd621f37 The kasp system test requires Python
Only run the kasp system test if HAVE_PYTHON.
2020-10-07 10:21:43 +00:00