summaryrefslogtreecommitdiffstats
path: root/sbin/unwind/resolver.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* annoying trailing whitespacesflorian2019-09-291-2/+2
|
* If we find ourselves behind a captive portal shutdown the service port.florian2019-05-231-7/+14
| | | | | | | | | | | | | | This lets us get past captive portals that - correctly answer SOA queries for the root zone with edns0 option - return NXDOAMIN for the captive portal redirect domain if edns0 is present Observed by many after g2k19 in maple leaf lounges. While here improve handling of captive portal configuration removal while unwind thinks we are behind a captive portal. For example because the host we are checking is down. Previously unwind would think we are stuck behind a captive portal forever.
* typoflorian2019-05-231-2/+3
|
* Move common config passing code into a function.florian2019-05-141-63/+2
| | | | OK pamela
* Implement DNS block lists. If unwind is queried for a domainflorian2019-05-101-1/+8
| | | | in the block list it answers with rcode REFUSED.
* Only try to resolve the DNSSEC trust anchor if we have a validatingflorian2019-05-061-2/+2
| | | | | resolver context. Otherwise we will ignore the answer later on anyway.
* the fiendishly that needed some extra space here didn't pan outflorian2019-04-021-2/+2
|
* Simplify code; we can loop over our resolvers now.florian2019-04-021-18/+6
|
* Add a config option to specify the preference of name servers.florian2019-04-021-66/+61
| | | | | Unfortunately the nameserver types enums needed to be renamed to not collide with yacc tokens.
* Collapse case statements to a common fall through and use the passedflorian2019-04-021-16/+3
| | | | | in type to identify the resolver now that they can be addressed by index.
* Introduce array of resolvers in preparation of custom orderingflorian2019-04-021-66/+73
|
* Reduce code duplication and ensure that a type of resolver and it'sflorian2019-04-011-29/+21
| | | | checking counterpart are created the same way.
* Implement "Authentication Domain Names" configuration as per RFC 8310florian2019-04-011-8/+11
| | | | | | | | | | | | | | | section 7.1 for DoT servers. We are setting the CA cert bundle path (/etc/ssl/cert.pem) directly in libunbound so we need to losen pledge(2) a bit and allow rpath. At the same time we unveil only /etc/ssl/cert.pem. We can drop the chroot(2) since pledge(2) and unveil(2) give us more fine grained isolation. prodding by tb@. p.s. for portable it might be necessary to pass in a file descriptor from the parent, slurp in the file and then use X509_STORE_load_mem() (pointed out by sthen) in the guts of libunbound.
* we don't need to set openssl lock callbacks. this code is not threaded.tedu2019-03-311-43/+1
| | | | ok florian
* Shuffle captive portal detection around.florian2019-03-301-83/+2
| | | | | | | | | | | | | | | While we are behind a captive portal we have to ask the dhcp provided resolvers. However it is possible that those resolvers do not like to talk to unwind because of EDNS0. Unwind handles this case by closing its listening socket and hands over to asr. Except for the resolving of the captive portal host which it still tries to resolve via libunbound. Turns out there is no need for this we can just use getaddrinfo_async from asr which then either hits unwind which does the right thing or unwind closed its listening socket and asr moves on to talk directly to the dhcp resolvers.
* Do not try to print NULL with %s.florian2019-03-301-5/+5
| | | | Brainfart pointed out by tb
* Reduce debug logging in best_resolver() to two lines, helps a bit withflorian2019-03-241-25/+21
| | | | | seeing what is going on. There is still a lot to do wrt logging but it's not a priority yet.
* recheck all resolvers when we are no longer behind a captive portalflorian2019-03-241-2/+4
|
* Do not check every resolver every 30 seconds as that is wasteful andflorian2019-03-241-6/+67
| | | | | | | | | | | | | | pointless. Trigger a check - on startup - when forwarders change on config reload - when dhcp provided forwarders change - on network interface state change When a check finishes and the checked resolver cannot resolve anything configure a timer to run another check in the future using an exponential backoff for the timeout.
* If we can't check the resolver its state is UNKNOWN.florian2019-03-241-1/+2
|
* remove useless debug outputflorian2019-03-241-2/+1
|
* Correctly interlock config reloads imsgs.florian2019-03-151-1/+7
| | | | | | Only accept a new config reload if it's not currently running and on accept a config reload end if one is currently running. OK pamela
* Due to the way we build libunbound inside of unwind .o files collide inflorian2019-03-011-2/+2
| | | | | | | | | | | | | | | | | | the obj directory. Previously this was solved by keeping the libunbound file name (to be able to keep in sync with upstream) and prefixing the source filename of colliding .o files in unwind with uw_. However, these files are shared through out our tree (namely parse.y, log.c and log.h) and we try to keep them in sync. Move files back to their original name and instead symlink colliding source files in libunbound to unique filenames by prefixing them with the directory they live in: obj/sldns_parse.c -> /usr/src/sbin/unwind/libunbound/sldns/parse.c obj/util_log.c -> /usr/src/sbin/unwind/libunbound/util/log.c Idea to use symlinks deraadt@ via jsg@ OK benno
* Introduce IMSG_DATA_SIZE() macro to to replace reoccuring math onflorian2019-02-181-33/+26
| | | | | imsg.hdr.len and shorten code. Input & OK pamela
* Since we do a naive string comparison to see if the trust anchorflorian2019-02-171-4/+1
| | | | | | | | | | changed we need to fix the TTL to the value we would get from the root for the ksk DNSKEY (currently 2 days). Otherwise we would interpret a lowerd TTL from a cache as changed trust anchor. Use the same define everywhere. (Considering the glacial speed with which the root ksk rotates this should be fine for the forseable future.)
* On log verbosity change we need to restart all resolvers: add missingflorian2019-02-171-1/+2
| | | | DoT resolver.
* s/unwind_/uw_/ to save screen real estate; fix style(9) issues while hereflorian2019-02-171-190/+186
|
* Rewrite trust anchor handling.florian2019-02-071-31/+216
| | | | | | | | | | | | | | | | | | | | | Do not use the libunbound's auto trust anchor file feature since it then the resolver process needs rpath, wpath, and cpath pledges and permission on the trust anchor file. Instead configure the trust anchor as resource record strings. The parent process opens the file, passes a filedescriptor to the frontend process to parse the file and then passes trust anchors to the resolver process to (re-) configure the resolver contexts. The resolver process periodically probes for new trust anchors (DNSKEY records of the root zone) and passes those to the frontend process. This in turn requests a file descripter for writing from the parent process. Once the trust anchors have been written the parent process renames the tmp file to the final location. Also provide a built in trust anchor for boot strapping purposes if no file is found on disk. That way we can get rid of unbound-anchor in unwind's rc.d script.
* unref resolver in error branchflorian2019-02-051-2/+4
|
* Captive portal detection for unwind(8).florian2019-02-031-18/+336
|
* Make imsg processing much more paranoid.florian2019-01-291-12/+29
| | | | | | | | | | | | | | | If it comes from one of our processes and the size does not match what we expect call fatalx to crash and burn. We either hit a logic bug or something is fishy on the other end and we can't trust that process any longer. Not that we trust those processes to begin with. This also applies to receiving resources that we don't expect. For example if we have an open UDP listen socket and get a new one passed from the main process something is wrong and we should crash and burn. The only place where we are more lenient is on the control socket. We just ignore wrong sized messages so that users can't bring down unwind.
* We don't need IMSG_SHUTDOWN, we can just close the sockets.florian2019-01-291-5/+1
| | | | pointed out by deraadt
* Implement DNS over TLS (DoT).florian2019-01-271-1/+60
|
* unwind(8) traces its ancestry to rad(8) and inherited all of its includeflorian2019-01-271-10/+4
| | | | | directives, some of them no longer necessary. Cleanup by Caspar Schutijser, thank you very much!
* We are not holding on to a ref to the resolver if ub_resolve_event fails.florian2019-01-251-2/+4
|
* make sure resolver exists before sending detailed infoflorian2019-01-251-1/+4
|
* typoflorian2019-01-251-2/+2
|
* We also need to check the rcode in the wire paket.florian2019-01-251-2/+3
| | | | | This lets us get past the broken Dutch railway wifi that responds NXDOMAIN if an edns0 option is present.
* pasto; from Caspar Schutijser, thanks!florian2019-01-251-2/+2
|
* Open and close listening sockets on localhost:53 depending on if we canflorian2019-01-241-1/+16
| | | | | | | | | | | | | | | | | | | | resolve at all. We come up without listening and open IPv4 and IPv6 sockets once the resolver process has determinded that we can speak DNS to the outside world. Furthermore close the listening sockets when the resolver process notices that we can no longer speak DNS to the outside. This is a last-ditch effort to get out of libc resolver's way and let it speak directly to e.g. dhcp provided resolvers. With the recomended configuration of having 127.0.0.1 first in /etc/resolv.conf and then add dhcp provided resolvers after that our libc resolver will receive a port unreachable error and immediately switch to the next one if unwind is not listening on port 53. (Networks have been observed in the wild that intercept DNS packets and answer NXDOMAIN if an edns0 option is send with the query.)
* Switch to libunbound internals for packet parsing.florian2019-01-241-22/+31
| | | | | | These functions / macros (from (s)ldns) are not part of the public libunbound API so we couldn't use them before. Due to the way we use libunbound (a local copy) we now have access.
* When we switched from the fork based ub_resolve_async() toflorian2019-01-241-5/+3
| | | | | | | | | | ub_resolve_event() the heuristic to detect if the authoritative server is unreachable was adapted in the wrong way. Turns out when using ub_resolve_event() we get the correct rcode passed in (SERVFAIL). The rcode in the wire format answer_packet is still wrong though (NOERROR). But that doesn't matter since we can just check the passed in rcode.
* Import unwind(8).florian2019-01-231-0/+1042
unwind(8) is a hybrid validating stub & recursive resolver. It actively observes the local net to decide how to best resolve names. It can chose to recurse on it's own or talk to dhcp provided forwardes or statically defined forwarders in the config file. The intention is to be able to run it on localhost on every machine. "toss it in man" deraadt@