Commit graph

11734 commits

Author SHA1 Message Date
Evan Hunt
f6c3b13522 dnstap: if recursion is not available, log queries as AQ instead of CQ
(cherry picked from commit 1f578cdb12)
2019-04-11 15:45:52 -07:00
Mark Andrews
b27ef87c38 Add debug printfs
(cherry picked from commit b78e128a2f)
2019-04-11 19:47:44 +10:00
Mark Andrews
86bb6e23ce Prevent WIRE_INVALID() being called without a argument
(cherry picked from commit e73a5b0ce3)
2019-04-11 19:47:44 +10:00
Mark Andrews
1eb7267e60 Check multi-line output from dns_rdata_tofmttext()
Check that multi-line output from dns_rdata_tofmttext() can be read
back in by dns_rdata_fromtext().

(cherry picked from commit b089f43b7a)
2019-04-11 19:47:44 +10:00
Mark Andrews
14c2db8c5d Process master file comments and make input invalid again
(cherry picked from commit 1a75a5cee6)
2019-04-11 19:47:43 +10:00
Mark Andrews
4395311280 Set 'specials' to match 'specials' in 'lib/dns/master.c'
(cherry picked from commit 7941a9554f)
2019-04-11 19:47:43 +10:00
Mark Andrews
c5b191e78f Fix whitespace so that the names align
(cherry picked from commit cc5e16e4d3)
2019-04-11 19:47:43 +10:00
Mark Andrews
56a534ab06 Add dns_rdata_totext() and dns_rdata_fromtext() to fromwire
Add dns_rdata_totext() and dns_rdata_fromtext() to fromwire for
valid inputs to ensure that what we accept in dns_rdata_fromwire()
can be written out and read back in.

(cherry picked from commit 36f30f5731)
2019-04-11 19:47:43 +10:00
Mark Andrews
10fba8fd8d Initialise mincachettl and minncachettl to zero in dns_view_create.
(cherry picked from commit 8fd4308bda)
2019-04-10 15:08:33 +10:00
Mark Andrews
480bcb314d add ds unit test
(cherry picked from commit 6eb28eda1e)
2019-04-10 14:44:05 +10:00
Mark Andrews
b24c128a2c enforce DS hash exists
(cherry picked from commit b274f3fad7)
2019-04-10 14:44:05 +10:00
Mark Andrews
d006ae2195 check that from fromtext produces valid towire input
(cherry picked from commit 7b0a653858)
2019-04-10 13:24:17 +10:00
Mark Andrews
53a62e2977 for rkey flags MUST be zero
(cherry picked from commit 82d4931440)
2019-04-09 14:22:50 +10:00
Mark Andrews
07d024a4da check flags for no key in fromwire for *KEY
(cherry picked from commit 2592e91516)
2019-04-09 14:22:50 +10:00
Mark Andrews
14313d798a <dns/ecs.h> was missing ISC_LANG_ENDDECLS.
(cherry picked from commit 698a6f955e)
2019-04-09 12:05:57 +10:00
Witold Kręcicki
6e63d7047d Fix deadlock in RPZ update code.
In dns_rpz_update_from_db we call setup_update which creates the db
iterator and calls dns_dbiterator_first. This unpauses the iterator and
might cause db->tree_lock to be acquired. We then do isc_task_send(...)
on an event to do quantum_update, which (correctly) after each iteration
calls dns_dbiterator_pause, and re-isc_task_sends itself.

That's an obvious bug, as we're holding a lock over an async task send -
if a task requesting write (e.g. prune_tree) is scheduled on the same
workers queue as update_quantum but before it, it will wait for the
write lock indefinitely, resulting in a deadlock.

To fix it we have to pause dbiterator in setup_update.

(cherry picked from commit 06021b3529)
2019-04-06 12:41:36 -07:00
Witold Kręcicki
9ff296afeb In resume_qmin check if the fetch context is already shutting down - if so, try to destroy it, don't continue
(cherry picked from commit 7c960e89ea)
2019-04-03 16:34:33 +02:00
Witold Kręcicki
69d3bb78c2 Fix assertion failure in nslookup/dig/mdig when message has multiple SIG(0) options.
When parsing message with DNS_MESSAGE_BESTEFFORT (used exclusively in
tools, never in named itself) if we hit an invalid SIG(0) in wrong
place we continue parsing the message, and put the sig0 in msg->sig0.
If we then hit another sig0 in a proper place we see that msg->sig0
is already 'taken' and we don't free name and rdataset, and we don't
set seen_problem. This causes an assertion failure.
This fixes that issue by setting seen_problem if we hit second sig0,
tsig or opt, which causes name and rdataset to be always freed.

(cherry picked from commit 51a55ddbb7)
2019-03-26 21:32:08 +11:00
Ondřej Surý
7485a4332e Make lib/dns/dnstap.pb-c.h private header
This changes dns_dtdata struct to not expose data types from dnstap.pb-c.h to
prevent the need for including this header where not really needed.

(cherry picked from commit 8ccce7e24b)
2019-03-22 12:07:31 +01:00
Evan Hunt
dde35a8edf don't fail when allow-update{,-forwarding} is used globally
(cherry picked from commit 91dca0f8da)
2019-03-22 00:14:52 -07:00
Mark Andrews
753d77c51f Disallow empty ZONEMD hashes
This change is the result of discussions with the authors of
draft-wessels-dns-zone-digest.

(cherry picked from commit 473987d8d9)
2019-03-22 06:52:10 +11:00
Mark Andrews
c52dfb2063 add brackets for multi-line output
(cherry picked from commit 40a770b932)
2019-03-21 20:26:02 +11:00
Petr Menšík
7885bbff99 Fix regression in dnstap_test with native pkcs11
Change to cmocka broken initialization of TZ environment. This time,
commit 1cf1254051 is not soon enough. Has
to be moved more forward, before any other tests. It library is not full
reinitialized on each test.

(cherry picked from commit 71c4fad592)
2019-03-15 16:17:52 +11:00
Mark Andrews
b30e5f11fb force promotion to unsigned int
(cherry picked from commit 1eba2c5b06)
2019-03-14 13:51:30 -07:00
Mark Andrews
68608eaa3c assert hevent->rdataset is non NULL
(cherry picked from commit d8d04edfba)
2019-03-14 13:16:43 -07:00
Mark Andrews
cdaf04f043 missing #include <isc/lang.h>
(cherry picked from commit 719b1d7fdc)
2019-03-14 12:24:19 -07:00
Mark Andrews
e9a1087e96 add missing MAYBE_UNLOCK
(cherry picked from commit ff8bf617e7)
2019-03-14 09:01:12 +11:00
Witold Kręcicki
fcb5642ec0 Clean up client->ecs when we're done with the request.
(cherry picked from commit aa3da7a232)
2019-03-12 13:59:12 -07:00
Witold Kręcicki
fcc7a8c6ca Fix a race in fctx_cancelquery.
When sending an udp query (resquery_send) we first issue an asynchronous
isc_socket_connect and increment query->connects, then isc_socket_sendto2
and increment query->sends.
If we happen to cancel this query (fctx_cancelquery) we need to cancel
all operations we might have issued on this socket. If we are under very high
load the callback from isc_socket_connect (resquery_udpconnected) might have
not yet been fired. In this case we only cancel the CONNECT event on socket,
and ignore the SEND that's waiting there (as there is an `else if`).
Then we call dns_dispatch_removeresponse which kills the dispatcher socket
and calls isc_socket_close - but if system is under very high load, the send
we issued earlier might still not be complete - which triggers an assertion
because we're trying to close a socket that's still in use.

The fix is to always check if we have incomplete sends on the socket and cancel
them if we do.

(cherry picked from commit 56183a3917)
2019-03-12 11:54:43 -07:00
Mark Andrews
d974a28898 use client->query.qname
(cherry picked from commit 8758d36a5e)
2019-03-11 11:19:00 -07:00
Ondřej Surý
a169e35634 Restore missing check for flockfile and getc_unlocked
(cherry picked from commit 7eea756858)
2019-03-08 21:35:08 +01:00
Michał Kępień
040d631027 Make delv use OS-supplied ephemeral port range
Make delv honor the operating system's preferred ephemeral port range
instead of always using the default 1024-65535 range for outgoing
messages.

(cherry picked from commit ada6846a10)
2019-03-08 13:14:00 +01:00
Tony Finch
1e2bfb1460 cleanup: use dns_secalg_t and dns_dsdigest_t where appropriate
Use them in structs for various rdata types where they are missing.
This doesn't change the structs since we are replacing explicit
uint8_t field types with aliases for uint8_t.

Use dns_dsdigest_t in library function arguments.

Improve dnssec-cds with these more specific types.

(cherry picked from commit 0f219714e1)
2019-03-08 22:16:48 +11:00
Mark Andrews
8faca93b37 #include <limits.h> for PATH_MAX, define if not found
(cherry picked from commit 1fc7be36eb)
2019-03-08 18:23:59 +11:00
Evan Hunt
e2ee2e9e0b silence a warning about potential snprintf overrun
(cherry picked from commit 7f26cad247)
2019-03-07 21:46:50 -08:00
Mark Andrews
cdf928d391 Handle EDQUOT and ENOSPC errors
(cherry picked from commit 435ae2f29a)
2019-03-07 21:23:39 -08:00
Mark Andrews
c1489dfa4f fix the use of dns_wildcardname as an optimisation in DLZ
(cherry picked from commit cb32cd98bd)
2019-03-07 20:27:57 -08:00
Mark Andrews
c117605812 add noreturn attribute
(cherry picked from commit 3f2b7e1006)
2019-03-08 12:13:18 +11:00
Mark Andrews
edc607bced add the ability to control whether SOA records are added response-policy modified answers
(cherry picked from commit d1fa8be611)
2019-03-07 13:29:11 -08:00
Witold Kręcicki
54f9c1d306 Fix a race in socket code when internal_{accept, send, receive} is called
from event loop on an socket and, in the meantime, someone has closed this
socket.

(cherry picked from commit b57a38ae43)
2019-03-06 14:15:19 -08:00
Michał Kępień
9036952f84 Log plugin unloading at debug level
During server reconfiguration, plugin instances set up for the old views
are unloaded very close to the end of the whole process, after new
plugin instances are set up.  As the log message announcing plugin
unloading is emitted at the default "info" level, the user might be
misled into thinking that it is the new plugin instances that are being
unloaded for some reason, particularly because all other messages logged
at the "info" level around the same time inform about setting things up
rather than tearing them down.  Since no distinction is currently made
between destroying a view due to reconfiguration and due to a shutdown
in progress, there is no easy way to vary the contents of the log
message depending on circumstances.  Since this message is not a
particularly critical one, demote it to debug level to prevent
confusion.

(cherry picked from commit af4b81f944)
2019-03-06 12:55:29 -08:00
Michał Kępień
9b72458b1e Look for named plugins in ${libdir}/named
When the "library" part of a "plugin" configuration stanza does not
contain at least one path separator, treat it as a filename and assume
it is a name of a shared object present in the named plugin installation
directory.  Absolute and relative paths can still be used and will be
used verbatim.  Get the full path to a plugin before attempting to
check/register it so that all relevant log messages include the same
plugin path (apart from the one logged when the full path cannot be
determined).

(cherry picked from commit 1a9fc624ca)
2019-03-05 16:52:49 -08:00
Michał Kępień
3883acc5c2 Add ns_plugin_expandpath()
Implement a helper function which, given an input string:

  - copies it verbatim if it contains at least one path separator,
  - prepends the named plugin installation directory to it otherwise.

This function will allow configuration parsing code to conveniently
determine the full path to a plugin module given either a path or a
filename.

While other, simpler ways exist for making sure filenames passed to
dlopen() cause the latter to look for shared objects in a specific
directory, they are very platform-specific.  Using full paths is thus
likely the most portable and reliable solution.

Also added unit tests for ns_plugin_expandpath() to ensure it behaves
as expected for absolute paths, relative paths, and filenames, for
various target buffer sizes.

(Note: plugins share a directory with named on Windows; there is no
default plugin path. Therefore the source path is copied to the
destination path with no modification.)

(cherry picked from commit d181c28c60)
2019-03-05 16:52:49 -08:00
Mark Andrews
7c78e5b90a improve clang / cmocka integration
(cherry picked from commit cb913177ae)
2019-03-05 10:42:01 -08:00
Evan Hunt
ed72b9434d fix crash in query_respond_any() from all records being hidden
in query_respond_any(), the assumption had previously been made that it
was impossible to get past iterating the node with a return value of
ISC_R_NOMORE but not have found any records, unless we were searching
for RRSIG or SIG. however, it is possible for other types to exist but
be hidden, such as when the zone is transitioning from insecure to
secure and DNSSEC types are encountered, and this situation could
trigger an assertion.  removed the assertion and reorganized the code.

(cherry picked from commit 3e74c7e5ff)
2019-02-28 16:06:38 -08:00
Evan Hunt
3396f9396f documentation changes establishing the 9.14 stable branch 2019-02-27 18:06:35 -05:00
Matthijs Mekking
0f520ac026 Update CHANGES 2019-02-22 15:26:43 +01:00
Matthijs Mekking
05f156e8ba Unregister RPZ CATZ db cbs when zone load fails
In case when a zone fails to load because the file does not exist
or is malformed, we should not run the callback that updates the
zone database when the load is done.  This is achieved by
unregistering the callbacks if at zone load end if the result
indicates something else than success.
2019-02-22 15:24:24 +01:00
Matthijs Mekking
6594f7acb2 Remove rpz->db_registered
As pointed out in !813 db_registered is sort of redundant.  It is
set to `true` only in `dns_zone_rpz_enable_db()` right before the
`dns_rpz_dbupdate_callback()` callback is registered.  It is only
required in that callback and it is the only place that the callback
is registered.  Therefore there is no path that that `REQUIRE` can
fail.

The `db_registered` variable is only set to `false` in
`dns_rpz_new_zone`, so it is not like the variable is unset again
later.

The only other place where `db_registered` is checked is in
`rpz_detach()`.  If `true`, it will call
`dns_db_updatenotify_unregister()`.  However if that happens, the
`db_registered` is not set back to `false` thus this implies that
this may happen multiple times.  If called a second time, most
likely the unregister function will return `ISC_R_NOTFOUND`, but
the return value is not checked anyway.  So it can do without the
`db_registered` check.
2019-02-22 15:23:59 +01:00
Matthijs Mekking
a4cd74e71a Add curly brackets on if statements 2019-02-22 15:23:44 +01:00