diff options
| author | christos <christos@NetBSD.org> | 2019-02-24 20:01:26 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2019-02-24 20:01:26 +0000 |
| commit | cc2e102b19afa2f92c54513a1bf2b91af12ee47e (patch) | |
| tree | 147ecaf736fad5662285bb7897e88a5085290b3d | |
| parent | 27f06925e3413c1064689ffe7bf00a1abc73fd78 (diff) | |
merge conflicts
243 files changed, 3823 insertions, 9057 deletions
diff --git a/external/mpl/bind/bind2netbsd b/external/mpl/bind/bind2netbsd index d08f9b18f3b..64535ead968 100755 --- a/external/mpl/bind/bind2netbsd +++ b/external/mpl/bind/bind2netbsd @@ -1,6 +1,6 @@ #! /bin/sh # -# $NetBSD: bind2netbsd,v 1.2 2019/01/09 16:54:58 christos Exp $ +# $NetBSD: bind2netbsd,v 1.3 2019/02/24 20:01:26 christos Exp $ # # Copyright (c) 2000 The NetBSD Foundation, Inc. # All rights reserved. @@ -27,21 +27,21 @@ # POSSIBILITY OF SUCH DAMAGE. # # bind2netbsd: convert a bind tree into a -# netbsd bind source tree, under src/external/bsd/bind/dist, +# netbsd bind source tree, under src/external/mpl/bind/dist, # based on bind2netbsd by Bernd Ernesti and changes by Simon Burge # # Rough instructions for importing new bind release: # # $ cd /some/where/temporary # $ tar xpfz /new/bind/release/tar/file -# $ sh /usr/src/external/bsd/bind/bind2netbsd bind-9.x.y `pwd` -# $ cd src/external/bsd/bind/dist -# $ cvs -d cvs.netbsd.org:/cvsroot import -m "Import bind 9.x.y" src/external/bsd/bind/dist ISC bind-9-x-y +# $ sh /usr/src/external/mpl/bind/bind2netbsd bind-9.x.y `pwd` +# $ cd src/external/mpl/bind/dist +# $ cvs -d cvs.netbsd.org:/cvsroot import -m "Import bind 9.x.y" src/external/mpl/bind/dist ISC bind-9-x-y # $ cd ../../../../../bind-9.x.y # $ run ./configure --enable-dnsrps --enable-querytrace --enable-fixed-rrset # $ run make # - use the binclude4netbsd to create and import the new headers in -# /usr/src/external/bsd/bind/include +# /usr/src/external/mpl/bind/include # - check makefiles to see if any extra sources have been added. # - update distrib/sets if necessary. # @@ -52,7 +52,7 @@ if [ $# -ne 2 ]; then echo "bind2netbsd src dest"; exit 1; fi r=$1 -d=$2/src/external/bsd/bind/dist +d=$2/src/external/mpl/bind/dist case "$d" in /*) diff --git a/external/mpl/bind/dist/bin/check/named-checkconf.8 b/external/mpl/bind/dist/bin/check/named-checkconf.8 index 757868a61d3..658451667ea 100644 --- a/external/mpl/bind/dist/bin/check/named-checkconf.8 +++ b/external/mpl/bind/dist/bin/check/named-checkconf.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: named-checkconf.8,v 1.3 2019/01/09 16:54:58 christos Exp $ +.\" $NetBSD: named-checkconf.8,v 1.4 2019/02/24 20:01:26 christos Exp $ .\" -.\" Copyright (C) 2000-2002, 2004, 2005, 2007, 2009, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2000-2002, 2004, 2005, 2007, 2009, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -145,5 +145,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2000-2002, 2004, 2005, 2007, 2009, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2000-2002, 2004, 2005, 2007, 2009, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/check/named-checkzone.8 b/external/mpl/bind/dist/bin/check/named-checkzone.8 index 034a34546e7..b78b3be0250 100644 --- a/external/mpl/bind/dist/bin/check/named-checkzone.8 +++ b/external/mpl/bind/dist/bin/check/named-checkzone.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: named-checkzone.8,v 1.2 2018/08/12 13:02:26 christos Exp $ +.\" $NetBSD: named-checkzone.8,v 1.3 2019/02/24 20:01:26 christos Exp $ .\" -.\" Copyright (C) 2000-2002, 2004-2007, 2009-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2000-2002, 2004-2007, 2009-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -327,5 +327,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2000-2002, 2004-2007, 2009-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2000-2002, 2004-2007, 2009-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/confgen/ddns-confgen.8 b/external/mpl/bind/dist/bin/confgen/ddns-confgen.8 index 72e08b5b9b9..fac6f44d1fd 100644 --- a/external/mpl/bind/dist/bin/confgen/ddns-confgen.8 +++ b/external/mpl/bind/dist/bin/confgen/ddns-confgen.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: ddns-confgen.8,v 1.3 2019/01/09 16:54:58 christos Exp $ +.\" $NetBSD: ddns-confgen.8,v 1.4 2019/02/24 20:01:26 christos Exp $ .\" -.\" Copyright (C) 2009, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2009, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -146,5 +146,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2009, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2009, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/confgen/rndc-confgen.8 b/external/mpl/bind/dist/bin/confgen/rndc-confgen.8 index 59f77c13d49..00c8eadc5fd 100644 --- a/external/mpl/bind/dist/bin/confgen/rndc-confgen.8 +++ b/external/mpl/bind/dist/bin/confgen/rndc-confgen.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: rndc-confgen.8,v 1.3 2019/01/09 16:54:58 christos Exp $ +.\" $NetBSD: rndc-confgen.8,v 1.4 2019/02/24 20:01:26 christos Exp $ .\" -.\" Copyright (C) 2001, 2003-2005, 2007, 2009, 2013-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2001, 2003-2005, 2007, 2009, 2013-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -208,5 +208,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2001, 2003-2005, 2007, 2009, 2013-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2001, 2003-2005, 2007, 2009, 2013-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/delv/delv.1 b/external/mpl/bind/dist/bin/delv/delv.1 index 04e110321cf..dd2481a937c 100644 --- a/external/mpl/bind/dist/bin/delv/delv.1 +++ b/external/mpl/bind/dist/bin/delv/delv.1 @@ -1,6 +1,6 @@ -.\" $NetBSD: delv.1,v 1.2 2018/08/12 13:02:27 christos Exp $ +.\" $NetBSD: delv.1,v 1.3 2019/02/24 20:01:26 christos Exp $ .\" -.\" Copyright (C) 2014-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2014-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -439,5 +439,5 @@ RFC5155\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2014-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2014-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/delv/delv.c b/external/mpl/bind/dist/bin/delv/delv.c index b6791cdfbe6..541fa9daaf5 100644 --- a/external/mpl/bind/dist/bin/delv/delv.c +++ b/external/mpl/bind/dist/bin/delv/delv.c @@ -1,4 +1,4 @@ -/* $NetBSD: delv.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: delv.c,v 1.4 2019/02/24 20:01:26 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -745,8 +745,8 @@ setup_dnsseckeys(dns_client_t *client) { isc_buffer_init(&b, anchortext, sizeof(anchortext) - 1); isc_buffer_add(&b, sizeof(anchortext) - 1); - result = cfg_parse_buffer(parser, &b, &cfg_type_bindkeys, - &bindkeys); + result = cfg_parse_buffer(parser, &b, NULL, 0, + &cfg_type_bindkeys, 0, &bindkeys); if (result != ISC_R_SUCCESS) fatal("Unable to parse built-in keys"); } diff --git a/external/mpl/bind/dist/bin/dig/dig.1 b/external/mpl/bind/dist/bin/dig/dig.1 index bd7b1a50a56..366937f08e5 100644 --- a/external/mpl/bind/dist/bin/dig/dig.1 +++ b/external/mpl/bind/dist/bin/dig/dig.1 @@ -1,6 +1,6 @@ -.\" $NetBSD: dig.1,v 1.3 2019/01/09 16:54:59 christos Exp $ +.\" $NetBSD: dig.1,v 1.4 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2000-2011, 2013-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2000-2011, 2013-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -826,5 +826,5 @@ There are probably too many query options\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2000-2011, 2013-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2000-2011, 2013-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/dig/dighost.c b/external/mpl/bind/dist/bin/dig/dighost.c index 184f1116928..4361a158275 100644 --- a/external/mpl/bind/dist/bin/dig/dighost.c +++ b/external/mpl/bind/dist/bin/dig/dighost.c @@ -1,4 +1,4 @@ -/* $NetBSD: dighost.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: dighost.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -2732,27 +2732,6 @@ send_tcp_connect(dig_query_t *query) { return; } - if (specified_source && - (isc_sockaddr_pf(&query->sockaddr) != - isc_sockaddr_pf(&bind_address))) { - printf(";; Skipping server %s, incompatible " - "address family\n", query->servname); - query->waiting_connect = false; - if (ISC_LINK_LINKED(query, link)) - next = ISC_LIST_NEXT(query, link); - else - next = NULL; - l = query->lookup; - clear_query(query); - if (next == NULL) { - printf(";; No acceptable nameservers\n"); - check_next_lookup(l); - return; - } - send_tcp_connect(next); - return; - } - INSIST(query->sock == NULL); if (keep != NULL && isc_sockaddr_equal(&keepaddr, &query->sockaddr)) { @@ -2904,6 +2883,36 @@ send_udp(dig_query_t *query) { } /*% + * If there are more servers available for querying within 'lookup', initiate a + * TCP or UDP query to the next available server and return true; otherwise, + * return false. + */ +static bool +try_next_server(dig_lookup_t *lookup) { + dig_query_t *current_query, *next_query; + + current_query = lookup->current_query; + if (current_query == NULL || !ISC_LINK_LINKED(current_query, link)) { + return (false); + } + + next_query = ISC_LIST_NEXT(current_query, link); + if (next_query == NULL) { + return (false); + } + + debug("trying next server..."); + + if (lookup->tcp_mode) { + send_tcp_connect(next_query); + } else { + send_udp(next_query); + } + + return (true); +} + +/*% * IO timeout handler, used for both connect and recv timeouts. If * retries are still allowed, either resend the UDP packet or queue a * new TCP lookup. Otherwise, cancel the lookup. @@ -2911,7 +2920,7 @@ send_udp(dig_query_t *query) { static void connect_timeout(isc_task_t *task, isc_event_t *event) { dig_lookup_t *l = NULL; - dig_query_t *query = NULL, *cq; + dig_query_t *query = NULL; UNUSED(task); REQUIRE(event->ev_type == ISC_TIMEREVENT_IDLE); @@ -2931,18 +2940,14 @@ connect_timeout(isc_task_t *task, isc_event_t *event) { return; } - if ((query != NULL) && (query->lookup->current_query != NULL) && - ISC_LINK_LINKED(query->lookup->current_query, link) && - (ISC_LIST_NEXT(query->lookup->current_query, link) != NULL)) { - debug("trying next server..."); - cq = query->lookup->current_query; - if (!l->tcp_mode) - send_udp(ISC_LIST_NEXT(cq, link)); - else { - if (query->sock != NULL) + if (try_next_server(l)) { + if (l->tcp_mode) { + if (query->sock != NULL) { isc_socket_cancel(query->sock, NULL, ISC_SOCKCANCEL_ALL); - send_tcp_connect(ISC_LIST_NEXT(cq, link)); + } else { + clear_query(query); + } } UNLOCK_LOOKUP; return; @@ -2989,6 +2994,27 @@ connect_timeout(isc_task_t *task, isc_event_t *event) { } /*% + * Called when a peer closes a TCP socket prematurely. + */ +static void +requeue_or_update_exitcode(dig_lookup_t *lookup) { + if (lookup->eoferr == 0U) { + /* + * Peer closed the connection prematurely for the first time + * for this lookup. Try again, keeping track of this failure. + */ + dig_lookup_t *requeued_lookup = requeue_lookup(lookup, true); + requeued_lookup->eoferr++; + } else { + /* + * Peer closed the connection prematurely and it happened + * previously for this lookup. Indicate an error. + */ + exitcode = 9; + } +} + +/*% * Event handler for the TCP recv which gets the length header of TCP * packets. Start the next recv of length bytes. */ @@ -2999,7 +3025,7 @@ tcp_length_done(isc_task_t *task, isc_event_t *event) { isc_region_t r; isc_result_t result; dig_query_t *query = NULL; - dig_lookup_t *l, *n; + dig_lookup_t *l; uint16_t length; REQUIRE(event->ev_type == ISC_SOCKEVENT_RECVDONE); @@ -3038,9 +3064,8 @@ tcp_length_done(isc_task_t *task, isc_event_t *event) { sockcount--; debug("sockcount=%d", sockcount); INSIST(sockcount >= 0); - if (sevent->result == ISC_R_EOF && l->eoferr == 0U) { - n = requeue_lookup(l, true); - n->eoferr++; + if (sevent->result == ISC_R_EOF) { + requeue_or_update_exitcode(l); } isc_event_free(&event); clear_query(query); @@ -3399,7 +3424,7 @@ process_cookie(dig_lookup_t *l, dns_message_t *msg, } INSIST(msg->cc_ok == 0 && msg->cc_bad == 0); - if (optlen >= len && optlen >= 8U) { + if (len >= 8 && optlen >= 8U) { if (isc_safe_memequal(isc_buffer_current(optbuf), sent, 8)) { msg->cc_ok = 1; } else { @@ -3486,6 +3511,7 @@ recv_done(isc_task_t *task, isc_event_t *event) { dig_lookup_t *n, *l; bool docancel = false; bool match = true; + bool done_process_opt = false; unsigned int parseflags; dns_messageid_t id; unsigned int msgflags; @@ -3541,9 +3567,8 @@ recv_done(isc_task_t *task, isc_event_t *event) { debug("sockcount=%d", sockcount); INSIST(sockcount >= 0); } - if (sevent->result == ISC_R_EOF && l->eoferr == 0U) { - n = requeue_lookup(l, true); - n->eoferr++; + if (sevent->result == ISC_R_EOF) { + requeue_or_update_exitcode(l); } isc_event_free(&event); clear_query(query); @@ -3780,6 +3805,7 @@ recv_done(isc_task_t *task, isc_event_t *event) { UNLOCK_LOOKUP; return; } + done_process_opt = true; } if ((msg->rcode == dns_rcode_servfail && !l->servfail_stops) || (check_ra && (msg->flags & DNS_MESSAGEFLAG_RA) == 0 && l->recurse)) @@ -3869,13 +3895,17 @@ recv_done(isc_task_t *task, isc_event_t *event) { } } - if (l->cookie != NULL) { - if (msg->opt == NULL) - printf(";; expected opt record in response\n"); - else + if (!done_process_opt) { + if (l->cookie != NULL) { + if (msg->opt == NULL) { + printf(";; expected opt record in response\n"); + } else { + process_opt(l, msg); + } + } else if (l->sendcookie && msg->opt != NULL) { process_opt(l, msg); - } else if (l->sendcookie && msg->opt != NULL) - process_opt(l, msg); + } + } if (!l->doing_xfr || l->xfr_q == query) { if (msg->rcode == dns_rcode_nxdomain && (l->origin != NULL || l->need_search)) { diff --git a/external/mpl/bind/dist/bin/dig/host.1 b/external/mpl/bind/dist/bin/dig/host.1 index d941de46db2..f74e94cd6ba 100644 --- a/external/mpl/bind/dist/bin/dig/host.1 +++ b/external/mpl/bind/dist/bin/dig/host.1 @@ -1,6 +1,6 @@ -.\" $NetBSD: host.1,v 1.3 2019/01/09 16:54:59 christos Exp $ +.\" $NetBSD: host.1,v 1.4 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2000-2002, 2004, 2005, 2007-2009, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2000-2002, 2004, 2005, 2007-2009, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -271,5 +271,5 @@ runs\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2000-2002, 2004, 2005, 2007-2009, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2000-2002, 2004, 2005, 2007-2009, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/dig/nslookup.1 b/external/mpl/bind/dist/bin/dig/nslookup.1 index 60b76999c16..18d6b118a47 100644 --- a/external/mpl/bind/dist/bin/dig/nslookup.1 +++ b/external/mpl/bind/dist/bin/dig/nslookup.1 @@ -1,6 +1,6 @@ -.\" $NetBSD: nslookup.1,v 1.3 2019/01/09 16:54:59 christos Exp $ +.\" $NetBSD: nslookup.1,v 1.4 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2004-2007, 2010, 2013-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2004-2007, 2010, 2013-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -303,5 +303,5 @@ runs or when the standard output is not a tty\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2004-2007, 2010, 2013-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2004-2007, 2010, 2013-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/dig/nslookup.c b/external/mpl/bind/dist/bin/dig/nslookup.c index 8939e85ac88..c2b13f4f6d3 100644 --- a/external/mpl/bind/dist/bin/dig/nslookup.c +++ b/external/mpl/bind/dist/bin/dig/nslookup.c @@ -1,4 +1,4 @@ -/* $NetBSD: nslookup.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: nslookup.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -881,12 +881,29 @@ get_next_command(void) { isc_mem_free(mctx, buf); } +ISC_PLATFORM_NORETURN_PRE static void +usage(void) ISC_PLATFORM_NORETURN_POST; + +static void +usage(void) { + fprintf(stderr, "Usage:\n"); + fprintf(stderr, +" nslookup [-opt ...] # interactive mode using default server\n"); + fprintf(stderr, +" nslookup [-opt ...] - server # interactive mode using 'server'\n"); + fprintf(stderr, +" nslookup [-opt ...] host # just look up 'host' using default server\n"); + fprintf(stderr, +" nslookup [-opt ...] host server # just look up 'host' using 'server'\n"); + exit(1); +} + static void parse_args(int argc, char **argv) { bool have_lookup = false; usesearch = true; - for (argc--, argv++; argc > 0; argc--, argv++) { + for (argc--, argv++; argc > 0 && argv[0] != NULL; argc--, argv++) { debug("main parsing %s", argv[0]); if (argv[0][0] == '-') { if (strncasecmp(argv[0], "-ver", 4) == 0) { @@ -902,6 +919,9 @@ parse_args(int argc, char **argv) { in_use = true; addlookup(argv[0]); } else { + if (argv[1] != NULL) { + usage(); + } set_nameserver(argv[0]); check_ra = false; } diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-cds.8 b/external/mpl/bind/dist/bin/dnssec/dnssec-cds.8 index 991a27f3890..eaa7f68340e 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-cds.8 +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-cds.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-cds.8,v 1.3 2019/01/09 16:54:59 christos Exp $ +.\" $NetBSD: dnssec-cds.8,v 1.4 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2017, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2017-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -104,7 +104,7 @@ Specify a digest algorithm to use when converting CDNSKEY records to DS records\ .sp The \fIalgorithm\fR -must be one of SHA\-1 (SHA1), SHA\-256 (SHA256), or SHA\-384 (SHA384)\&. These values are case insensitive\&. If no algorithm is specified, the default is SHA\-256\&. +must be one of SHA\-1, SHA\-256, or SHA\-384\&. These values are case insensitive, and the hyphen may be omitted\&. If no algorithm is specified, the default is SHA\-256\&. .RE .PP \-c \fIclass\fR @@ -295,5 +295,5 @@ RFC 7344\&. .RE .SH "COPYRIGHT" .br -Copyright \(co 2017, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2017-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-cds.c b/external/mpl/bind/dist/bin/dnssec/dnssec-cds.c index 5d62f27c4cc..8e215190831 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-cds.c +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-cds.c @@ -1,4 +1,4 @@ -/* $NetBSD: dnssec-cds.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: dnssec-cds.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -484,7 +484,6 @@ match_key_dsset(keyinfo_t *ki, dns_rdataset_t *dsset, strictness_t strictness) dns_rdata_ds_t ds; dns_rdata_t dsrdata = DNS_RDATA_INIT; dns_rdata_t newdsrdata = DNS_RDATA_INIT; - dns_rdatatype_t keytype; bool c; dns_rdataset_current(dsset, &dsrdata); @@ -495,12 +494,8 @@ match_key_dsset(keyinfo_t *ki, dns_rdataset_t *dsset, strictness_t strictness) continue; } - /* allow for both DNSKEY and CDNSKEY */ - keytype = ki->rdata.type; - ki->rdata.type = dns_rdatatype_dnskey; result = dns_ds_buildrdata(name, &ki->rdata, ds.digest_type, dsbuf, &newdsrdata); - ki->rdata.type = keytype; if (result != ISC_R_SUCCESS) { vbprintf(3, "dns_ds_buildrdata(" "keytag=%d, algo=%d, digest=%d): %s\n", @@ -575,7 +570,7 @@ match_keyset_dsset(dns_rdataset_t *keyset, dns_rdataset_t *dsset, ki->algo = dnskey.algorithm; dns_rdata_toregion(keyrdata, &r); - ki->tag = dst_region_computeid(&r, ki->algo); + ki->tag = dst_region_computeid(&r); ki->dst = NULL; if (!match_key_dsset(ki, dsset, strictness)) { @@ -828,7 +823,6 @@ ds_from_cdnskey(dns_rdatalist_t *dslist, isc_buffer_t *buf, return (ISC_R_NOSPACE); } - cdnskey->type = dns_rdatatype_dnskey; rdata = rdata_get(); result = dns_ds_buildrdata(name, cdnskey, dtype[i], r.base, rdata); diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-dsfromkey.8 b/external/mpl/bind/dist/bin/dnssec/dnssec-dsfromkey.8 index a020d5de38c..e92c40756d4 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-dsfromkey.8 +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-dsfromkey.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-dsfromkey.8,v 1.3 2019/01/09 16:54:59 christos Exp $ +.\" $NetBSD: dnssec-dsfromkey.8,v 1.4 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2008-2012, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2008-2012, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -41,61 +41,103 @@ dnssec-dsfromkey \- DNSSEC DS RR generation tool .SH "SYNOPSIS" .HP \w'\fBdnssec\-dsfromkey\fR\ 'u -\fBdnssec\-dsfromkey\fR [\fB\-v\ \fR\fB\fIlevel\fR\fR] [\fB\-1\fR] [\fB\-2\fR] [\fB\-a\ \fR\fB\fIalg\fR\fR] [\fB\-C\fR] [\fB\-l\ \fR\fB\fIdomain\fR\fR] [\fB\-T\ \fR\fB\fITTL\fR\fR] {keyfile} +\fBdnssec\-dsfromkey\fR [\fB\-1\fR | \fB\-2\fR | \fB\-a\ \fR\fB\fIalg\fR\fR] [\fB\-C\fR | \fB\-l\ \fR\fB\fIdomain\fR\fR] [\fB\-T\ \fR\fB\fITTL\fR\fR] [\fB\-v\ \fR\fB\fIlevel\fR\fR] [\fB\-K\ \fR\fB\fIdirectory\fR\fR] {keyfile} .HP \w'\fBdnssec\-dsfromkey\fR\ 'u -\fBdnssec\-dsfromkey\fR {\-s} [\fB\-1\fR] [\fB\-2\fR] [\fB\-a\ \fR\fB\fIalg\fR\fR] [\fB\-K\ \fR\fB\fIdirectory\fR\fR] [\fB\-l\ \fR\fB\fIdomain\fR\fR] [\fB\-s\fR] [\fB\-c\ \fR\fB\fIclass\fR\fR] [\fB\-T\ \fR\fB\fITTL\fR\fR] [\fB\-f\ \fR\fB\fIfile\fR\fR] [\fB\-A\fR] [\fB\-v\ \fR\fB\fIlevel\fR\fR] {dnsname} +\fBdnssec\-dsfromkey\fR [\fB\-1\fR | \fB\-2\fR | \fB\-a\ \fR\fB\fIalg\fR\fR] [\fB\-C\fR | \fB\-l\ \fR\fB\fIdomain\fR\fR] [\fB\-T\ \fR\fB\fITTL\fR\fR] [\fB\-v\ \fR\fB\fIlevel\fR\fR] [\fB\-c\ \fR\fB\fIclass\fR\fR] [\fB\-A\fR] {\fB\-f\ \fR\fB\fIfile\fR\fR} [dnsname] .HP \w'\fBdnssec\-dsfromkey\fR\ 'u -\fBdnssec\-dsfromkey\fR [\fB\-h\fR] [\fB\-V\fR] +\fBdnssec\-dsfromkey\fR [\fB\-1\fR | \fB\-2\fR | \fB\-a\ \fR\fB\fIalg\fR\fR] [\fB\-C\fR | \fB\-l\ \fR\fB\fIdomain\fR\fR] [\fB\-T\ \fR\fB\fITTL\fR\fR] [\fB\-v\ \fR\fB\fIlevel\fR\fR] [\fB\-c\ \fR\fB\fIclass\fR\fR] [\fB\-K\ \fR\fB\fIdirectory\fR\fR] {\-s} {dnsname} +.HP \w'\fBdnssec\-dsfromkey\fR\ 'u +\fBdnssec\-dsfromkey\fR [\fB\-h\fR | \fB\-V\fR] .SH "DESCRIPTION" .PP +The \fBdnssec\-dsfromkey\fR -outputs the Delegation Signer (DS) resource record (RR), as defined in RFC 3658 and RFC 4509, for the given key(s)\&. +command outputs DS (Delegation Signer) resource records (RRs) and other similarly\-constructed RRs: with the +\fB\-l\fR +option it outputs DLV (DNSSEC Lookaside Validation) RRs; or with the +\fB\-C\fR +it outputs CDS (Child DS) RRs\&. +.PP +The input keys can be specified in a number of ways: +.PP +By default, +\fBdnssec\-dsfromkey\fR +reads a key file named like +Knnnn\&.+aaa+iiiii\&.key, as generated by +\fBdnssec\-keygen\fR\&. +.PP +With the +\fB\-f \fR\fB\fIfile\fR\fR +option, +\fBdnssec\-dsfromkey\fR +reads keys from a zone file or partial zone file (which can contain just the DNSKEY records)\&. +.PP +With the +\fB\-s\fR +option, +\fBdnssec\-dsfromkey\fR +reads a +keyset\- +file, as generated by +\fBdnssec\-keygen\fR\fB\-C\fR\&. .SH "OPTIONS" .PP \-1 .RS 4 -Use SHA\-1 as the digest algorithm (the default is to use both SHA\-1 and SHA\-256)\&. +An abbreviation for +\fB\-a SHA1\fR .RE .PP \-2 .RS 4 -Use SHA\-256 as the digest algorithm\&. +An abbreviation for +\fB\-a SHA\-256\fR .RE .PP \-a \fIalgorithm\fR .RS 4 -Select the digest algorithm\&. The value of -\fBalgorithm\fR -must be one of SHA\-1 (SHA1), SHA\-256 (SHA256) or SHA\-384 (SHA384)\&. These values are case insensitive\&. +Specify a digest algorithm to use when converting DNSKEY records to DS records\&. This option can be repeated, so that multiple DS records are created for each DNSKEY record\&. +.sp +The +\fIalgorithm\fR +must be one of SHA\-1, SHA\-256, or SHA\-384\&. These values are case insensitive, and the hyphen may be omitted\&. If no algorithm is specified, the default is SHA\-256\&. .RE .PP -\-C +\-A .RS 4 -Generate CDS records rather than DS records\&. This is mutually exclusive with generating lookaside records\&. +Include ZSKs when generating DS records\&. Without this option, only keys which have the KSK flag set will be converted to DS records and printed\&. Useful only in +\fB\-f\fR +zone file mode\&. .RE .PP -\-T \fITTL\fR +\-c \fIclass\fR .RS 4 -Specifies the TTL of the DS records\&. +Specifies the DNS class (default is IN)\&. Useful only in +\fB\-s\fR +keyset or +\fB\-f\fR +zone file mode\&. .RE .PP -\-K \fIdirectory\fR +\-C .RS 4 -Look for key files (or, in keyset mode, -keyset\- -files) in -\fBdirectory\fR\&. +Generate CDS records rather than DS records\&. This is mutually exclusive with the +\fB\-l\fR +option for generating DLV records\&. .RE .PP \-f \fIfile\fR .RS 4 -Zone file mode: in place of the keyfile name, the argument is the DNS domain name of a zone master file, which can be read from +Zone file mode: +\fBdnssec\-dsfromkey\fR\*(Aqs final +\fIdnsname\fR +argument is the DNS domain name of a zone whose master file can be read from \fBfile\fR\&. If the zone name is the same as \fBfile\fR, then it may be omitted\&. .sp If -\fBfile\fR -is set to +\fIfile\fR +is "\-", then the zone data is read from the standard input\&. This makes it possible to use the output of the \fBdig\fR command as input, as in: @@ -103,26 +145,41 @@ command as input, as in: \fBdig dnskey example\&.com | dnssec\-dsfromkey \-f \- example\&.com\fR .RE .PP -\-A +\-h .RS 4 -Include ZSKs when generating DS records\&. Without this option, only keys which have the KSK flag set will be converted to DS records and printed\&. Useful only in zone file mode\&. +Prints usage information\&. +.RE +.PP +\-K \fIdirectory\fR +.RS 4 +Look for key files or +keyset\- +files in +\fBdirectory\fR\&. .RE .PP \-l \fIdomain\fR .RS 4 Generate a DLV set instead of a DS set\&. The specified -\fBdomain\fR -is appended to the name for each record in the set\&. The DNSSEC Lookaside Validation (DLV) RR is described in RFC 4431\&. This is mutually exclusive with generating CDS records\&. +\fIdomain\fR +is appended to the name for each record in the set\&. This is mutually exclusive with the +\fB\-C\fR +option for generating CDS records\&. .RE .PP \-s .RS 4 -Keyset mode: in place of the keyfile name, the argument is the DNS domain name of a keyset file\&. +Keyset mode: +\fBdnssec\-dsfromkey\fR\*(Aqs final +\fIdnsname\fR +argument is the DNS domain name used to locate a +keyset\- +file\&. .RE .PP -\-c \fIclass\fR +\-T \fITTL\fR .RS 4 -Specifies the DNS class (default is IN)\&. Useful only in keyset or zone file mode\&. +Specifies the TTL of the DS records\&. By default the TTL is omitted\&. .RE .PP \-v \fIlevel\fR @@ -130,11 +187,6 @@ Specifies the DNS class (default is IN)\&. Useful only in keyset or zone file mo Sets the debugging level\&. .RE .PP -\-h -.RS 4 -Prints usage information\&. -.RE -.PP \-V .RS 4 Prints version information\&. @@ -143,16 +195,16 @@ Prints version information\&. .PP To build the SHA\-256 DS RR from the \fBKexample\&.com\&.+003+26160\fR -keyfile name, the following command would be issued: +keyfile name, you can issue the following command: .PP \fBdnssec\-dsfromkey \-2 Kexample\&.com\&.+003+26160\fR .PP The command would print something like: .PP -\fBexample\&.com\&. IN DS 26160 5 2 3A1EADA7A74B8D0BA86726B0C227AA85AB8BBD2B2004F41A868A54F0 C5EA0B94\fR +\fBexample\&.com\&. IN DS 26160 5 2 3A1EADA7A74B8D0BA86726B0C227AA85AB8BBD2B2004F41A868A54F0C5EA0B94\fR .SH "FILES" .PP -The keyfile can be designed by the key identification +The keyfile can be designated by the key identification Knnnn\&.+aaa+iiiii or the full file name Knnnn\&.+aaa+iiiii\&.key @@ -172,13 +224,20 @@ A keyfile error can give a "file not found" even if the file exists\&. \fBdnssec-keygen\fR(8), \fBdnssec-signzone\fR(8), BIND 9 Administrator Reference Manual, -RFC 3658, -RFC 4431\&. -RFC 4509\&. +RFC 3658 +(DS RRs), +RFC 4431 +(DLV RRs), +RFC 4509 +(SHA\-256 for DS RRs), +RFC 6605 +(SHA\-384 for DS RRs), +RFC 7344 +(CDS and CDNSKEY RRs)\&. .SH "AUTHOR" .PP \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2008-2012, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2008-2012, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-dsfromkey.c b/external/mpl/bind/dist/bin/dnssec/dnssec-dsfromkey.c index d762935939f..d50042f4e3a 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-dsfromkey.c +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-dsfromkey.c @@ -1,4 +1,4 @@ -/* $NetBSD: dnssec-dsfromkey.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: dnssec-dsfromkey.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -320,30 +320,27 @@ usage(void) ISC_PLATFORM_NORETURN_POST; static void usage(void) { fprintf(stderr, "Usage:\n"); - fprintf(stderr, " %s options [-K dir] keyfile\n\n", program); - fprintf(stderr, " %s options [-K dir] [-c class] -s dnsname\n\n", - program); - fprintf(stderr, " %s options -f zonefile (as zone name)\n\n", program); - fprintf(stderr, " %s options -f zonefile zonename\n\n", program); + fprintf(stderr, " %s [options] keyfile\n\n", program); + fprintf(stderr, " %s [options] -f zonefile [zonename]\n\n", program); + fprintf(stderr, " %s [options] -s dnsname\n\n", program); + fprintf(stderr, " %s [-h|-V]\n\n", program); fprintf(stderr, "Version: %s\n", VERSION); - fprintf(stderr, "Options:\n"); - fprintf(stderr, " -v <verbose level>\n"); - fprintf(stderr, " -V: print version information\n"); - fprintf(stderr, " -K <directory>: directory in which to find " - "key file or keyset file\n"); - fprintf(stderr, " -a algorithm: digest algorithm " - "(SHA-1, SHA-256 or SHA-384)\n"); - fprintf(stderr, " -1: use SHA-1\n"); - fprintf(stderr, " -2: use SHA-256\n"); - fprintf(stderr, " -C: print CDS record\n"); - fprintf(stderr, " -l: add lookaside zone and print DLV records\n"); - fprintf(stderr, " -s: read keyset from keyset-<dnsname> file\n"); - fprintf(stderr, " -c class: rdata class for DS set (default: IN)\n"); - fprintf(stderr, " -T TTL\n"); - fprintf(stderr, " -f file: read keyset from zone file\n"); - fprintf(stderr, " -A: when used with -f, " - "include all keys in DS set, not just KSKs\n"); - fprintf(stderr, "Output: DS or DLV RRs\n"); + fprintf(stderr, "Options:\n" +" -1: digest algorithm SHA-1\n" +" -2: digest algorithm SHA-256\n" +" -a algorithm: digest algorithm (SHA-1, SHA-256 or SHA-384)\n" +" -A: include all keys in DS set, not just KSKs (-f only)\n" +" -c class: rdata class for DS set (default IN) (-f or -s only)\n" +" -C: print CDS records\n" +" -f zonefile: read keys from a zone file\n" +" -h: print help information\n" +" -K directory: where to find key or keyset files\n" +" -l zone: print DLV records in the given lookaside zone\n" +" -s: read keys from keyset-<dnsname> file\n" +" -T: TTL of output records (omitted by default)\n" +" -v level: verbosity\n" +" -V: print version information\n"); + fprintf(stderr, "Output: DS, DLV, or CDS RRs\n"); exit (-1); } diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-importkey.8 b/external/mpl/bind/dist/bin/dnssec/dnssec-importkey.8 index 58852259dfb..22e8370fb67 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-importkey.8 +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-importkey.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-importkey.8,v 1.2 2018/08/12 13:02:27 christos Exp $ +.\" $NetBSD: dnssec-importkey.8,v 1.3 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2013-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2013-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -136,5 +136,5 @@ RFC 5011\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2013-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2013-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-keyfromlabel.8 b/external/mpl/bind/dist/bin/dnssec/dnssec-keyfromlabel.8 index dfb438649e1..738b575f4f2 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-keyfromlabel.8 +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-keyfromlabel.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-keyfromlabel.8,v 1.3 2019/01/09 16:54:59 christos Exp $ +.\" $NetBSD: dnssec-keyfromlabel.8,v 1.4 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2008-2012, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2008-2012, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -57,7 +57,7 @@ of the key is specified on the command line\&. This must match the name of the z .RS 4 Selects the cryptographic algorithm\&. The value of \fBalgorithm\fR -must be one of RSAMD5, RSASHA1, NSEC3RSASHA1, RSASHA256, RSASHA512, ECDSAP256SHA256, ECDSAP384SHA384, ED25519 or ED448\&. +must be one of RSASHA1, NSEC3RSASHA1, RSASHA256, RSASHA512, ECDSAP256SHA256, ECDSAP384SHA384, ED25519 or ED448\&. .sp If no algorithm is specified, then RSASHA1 will be used by default, unless the \fB\-3\fR @@ -309,5 +309,5 @@ The PKCS#11 URI Scheme (draft\-pechanec\-pkcs11uri\-13)\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2008-2012, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2008-2012, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-keyfromlabel.c b/external/mpl/bind/dist/bin/dnssec/dnssec-keyfromlabel.c index 685a2a0d4c5..4f4bcd9cd5e 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-keyfromlabel.c +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-keyfromlabel.c @@ -1,4 +1,4 @@ -/* $NetBSD: dnssec-keyfromlabel.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: dnssec-keyfromlabel.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -66,7 +66,7 @@ usage(void) { fprintf(stderr, " name: owner of the key\n"); fprintf(stderr, "Other options:\n"); fprintf(stderr, " -a algorithm: \n" - " RSA | RSAMD5 | DH | RSASHA1 |\n" + " DH | RSASHA1 |\n" " NSEC3RSASHA1 |\n" " RSASHA256 | RSASHA512 |\n" " ECDSAP256SHA256 | ECDSAP384SHA384\n"); @@ -384,22 +384,14 @@ main(int argc, char **argv) { fatal("no algorithm specified"); } - if (strcasecmp(algname, "RSA") == 0) { - fprintf(stderr, "The use of RSA (RSAMD5) is not " - "recommended.\nIf you still wish to " - "use RSA (RSAMD5) please specify " - "\"-a RSAMD5\"\n"); - if (freeit != NULL) - free(freeit); - return (1); - } else { - r.base = algname; - r.length = strlen(algname); - ret = dns_secalg_fromtext(&alg, &r); - if (ret != ISC_R_SUCCESS) - fatal("unknown algorithm %s", algname); - if (alg == DST_ALG_DH) - options |= DST_TYPE_KEY; + r.base = algname; + r.length = strlen(algname); + ret = dns_secalg_fromtext(&alg, &r); + if (ret != ISC_R_SUCCESS) { + fatal("unknown algorithm %s", algname); + } + if (alg == DST_ALG_DH) { + options |= DST_TYPE_KEY; } if (use_nsec3) { @@ -641,10 +633,10 @@ main(int argc, char **argv) { if (setdel) dst_key_settime(key, DST_TIME_DELETE, deltime); - if (setsyncadd) - dst_key_settime(key, DST_TIME_SYNCPUBLISH, syncadd); - if (setsyncdel) - dst_key_settime(key, DST_TIME_SYNCDELETE, syncdel); + if (setsyncadd) + dst_key_settime(key, DST_TIME_SYNCPUBLISH, syncadd); + if (setsyncdel) + dst_key_settime(key, DST_TIME_SYNCDELETE, syncdel); } else { if (setpub || setact || setrev || setinact || diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-keygen.8 b/external/mpl/bind/dist/bin/dnssec/dnssec-keygen.8 index f13dcb1a359..0d0d0a035d0 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-keygen.8 +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-keygen.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-keygen.8,v 1.3 2019/01/09 16:54:59 christos Exp $ +.\" $NetBSD: dnssec-keygen.8,v 1.4 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2000-2005, 2007-2012, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2000-2005, 2007-2012, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -64,7 +64,7 @@ may be preferable to direct use of .RS 4 Selects the cryptographic algorithm\&. For DNSSEC keys, the value of \fBalgorithm\fR -must be one of RSAMD5, RSASHA1, NSEC3RSASHA1, RSASHA256, RSASHA512, ECDSAP256SHA256, ECDSAP384SHA384, ED25519 or ED448\&. For TKEY, the value must be DH (Diffie Hellman); specifying his value will automatically set the +must be one of RSASHA1, NSEC3RSASHA1, RSASHA256, RSASHA512, ECDSAP256SHA256, ECDSAP384SHA384, ED25519 or ED448\&. For TKEY, the value must be DH (Diffie Hellman); specifying his value will automatically set the \fB\-T KEY\fR option as well\&. .sp @@ -356,5 +356,5 @@ RFC 4034\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2000-2005, 2007-2012, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2000-2005, 2007-2012, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-keygen.c b/external/mpl/bind/dist/bin/dnssec/dnssec-keygen.c index 55d14bf79f6..2c70ee5261e 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-keygen.c +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-keygen.c @@ -1,4 +1,4 @@ -/* $NetBSD: dnssec-keygen.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: dnssec-keygen.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -81,14 +81,12 @@ usage(void) { fprintf(stderr, "Options:\n"); fprintf(stderr, " -K <directory>: write keys into directory\n"); fprintf(stderr, " -a <algorithm>:\n"); - fprintf(stderr, " RSA | RSAMD5 | RSASHA1 | NSEC3RSASHA1" - " |\n"); + fprintf(stderr, " RSASHA1 | NSEC3RSASHA1 |\n"); fprintf(stderr, " RSASHA256 | RSASHA512 |\n"); fprintf(stderr, " ECDSAP256SHA256 | ECDSAP384SHA384 |\n"); fprintf(stderr, " ED25519 | ED448 | DH\n"); fprintf(stderr, " -3: use NSEC3-capable algorithm\n"); fprintf(stderr, " -b <key size in bits>:\n"); - fprintf(stderr, " RSAMD5:\t[1024..%d]\n", MAX_RSA); fprintf(stderr, " RSASHA1:\t[1024..%d]\n", MAX_RSA); fprintf(stderr, " NSEC3RSASHA1:\t[1024..%d]\n", MAX_RSA); fprintf(stderr, " RSASHA256:\t[1024..%d]\n", MAX_RSA); @@ -510,23 +508,14 @@ main(int argc, char **argv) { fatal("no algorithm specified"); } - if (strcasecmp(algname, "RSA") == 0) { - fprintf(stderr, "The use of RSA (RSAMD5) is not " - "recommended.\nIf you still wish to " - "use RSA (RSAMD5) please specify " - "\"-a RSAMD5\"\n"); - INSIST(freeit == NULL); - return (1); - } else { - r.base = algname; - r.length = strlen(algname); - ret = dns_secalg_fromtext(&alg, &r); - if (ret != ISC_R_SUCCESS) { - fatal("unknown algorithm %s", algname); - } - if (alg == DST_ALG_DH) { - options |= DST_TYPE_KEY; - } + r.base = algname; + r.length = strlen(algname); + ret = dns_secalg_fromtext(&alg, &r); + if (ret != ISC_R_SUCCESS) { + fatal("unknown algorithm %s", algname); + } + if (alg == DST_ALG_DH) { + options |= DST_TYPE_KEY; } if (!dst_algorithm_supported(alg)) { @@ -700,7 +689,6 @@ main(int argc, char **argv) { } switch (alg) { - case DNS_KEYALG_RSAMD5: case DNS_KEYALG_RSASHA1: case DNS_KEYALG_NSEC3RSASHA1: case DNS_KEYALG_RSASHA256: @@ -782,7 +770,6 @@ main(int argc, char **argv) { } switch(alg) { - case DNS_KEYALG_RSAMD5: case DNS_KEYALG_RSASHA1: case DNS_KEYALG_NSEC3RSASHA1: case DNS_KEYALG_RSASHA256: diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-revoke.8 b/external/mpl/bind/dist/bin/dnssec/dnssec-revoke.8 index 78de3a62e63..d3526127f15 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-revoke.8 +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-revoke.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-revoke.8,v 1.2 2018/08/12 13:02:27 christos Exp $ +.\" $NetBSD: dnssec-revoke.8,v 1.3 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2009, 2011, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2009, 2011, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -101,5 +101,5 @@ RFC 5011\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2009, 2011, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2009, 2011, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-revoke.c b/external/mpl/bind/dist/bin/dnssec/dnssec-revoke.c index 7e2896f6db6..76e32405229 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-revoke.c +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-revoke.c @@ -1,4 +1,4 @@ -/* $NetBSD: dnssec-revoke.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: dnssec-revoke.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -59,13 +59,13 @@ usage(void) { #else fprintf(stderr, " -E engine: specify OpenSSL engine\n"); #endif - fprintf(stderr, " -f: force overwrite\n"); + fprintf(stderr, " -f: force overwrite\n"); + fprintf(stderr, " -h: help\n"); fprintf(stderr, " -K directory: use directory for key files\n"); - fprintf(stderr, " -h: help\n"); - fprintf(stderr, " -r: remove old keyfiles after " + fprintf(stderr, " -r: remove old keyfiles after " "creating revoked version\n"); - fprintf(stderr, " -v level: set level of verbosity\n"); - fprintf(stderr, " -V: print version information\n"); + fprintf(stderr, " -v level: set level of verbosity\n"); + fprintf(stderr, " -V: print version information\n"); fprintf(stderr, "Output:\n"); fprintf(stderr, " K<name>+<alg>+<new id>.key, " "K<name>+<alg>+<new id>.private\n"); @@ -241,7 +241,7 @@ main(int argc, char **argv) { * Remove old key file, if told to (and if * it isn't the same as the new file) */ - if (removefile && dst_key_alg(key) != DST_ALG_RSAMD5) { + if (removefile) { isc_buffer_init(&buf, oldname, sizeof(oldname)); dst_key_setflags(key, flags & ~DNS_KEYFLAG_REVOKE); dst_key_buildfilename(key, DST_TYPE_PRIVATE, dir, &buf); diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-settime.8 b/external/mpl/bind/dist/bin/dnssec/dnssec-settime.8 index 4db1e0620ca..f2f3ce71926 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-settime.8 +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-settime.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-settime.8,v 1.2 2018/08/12 13:02:27 christos Exp $ +.\" $NetBSD: dnssec-settime.8,v 1.3 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2009-2011, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2009-2011, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -202,5 +202,5 @@ RFC 5011\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2009-2011, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2009-2011, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-signzone.8 b/external/mpl/bind/dist/bin/dnssec/dnssec-signzone.8 index 7831b0fa80f..2c6a5cc63f8 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-signzone.8 +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-signzone.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-signzone.8,v 1.3 2019/01/09 16:54:59 christos Exp $ +.\" $NetBSD: dnssec-signzone.8,v 1.4 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2000-2009, 2011-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2000-2009, 2011-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -470,5 +470,5 @@ RFC 4641\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2000-2009, 2011-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2000-2009, 2011-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/dnssec/dnssec-verify.8 b/external/mpl/bind/dist/bin/dnssec/dnssec-verify.8 index 82cf4fe185e..ac0264989ba 100644 --- a/external/mpl/bind/dist/bin/dnssec/dnssec-verify.8 +++ b/external/mpl/bind/dist/bin/dnssec/dnssec-verify.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-verify.8,v 1.2 2018/08/12 13:02:27 christos Exp $ +.\" $NetBSD: dnssec-verify.8,v 1.3 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2012, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2012, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -115,5 +115,5 @@ RFC 4033\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2012, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2012, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/named/config.c b/external/mpl/bind/dist/bin/named/config.c index 1426127340c..e927552111b 100644 --- a/external/mpl/bind/dist/bin/named/config.c +++ b/external/mpl/bind/dist/bin/named/config.c @@ -1,4 +1,4 @@ -/* $NetBSD: config.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: config.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -325,9 +325,9 @@ named_config_parsedefaults(cfg_parser_t *parser, cfg_obj_t **conf) { isc_buffer_init(&b, defaultconf, sizeof(defaultconf) - 1); isc_buffer_add(&b, sizeof(defaultconf) - 1); - return (cfg_parse_buffer4(parser, &b, __FILE__, 0, - &cfg_type_namedconf, - CFG_PCTX_NODEPRECATED, conf)); + return (cfg_parse_buffer(parser, &b, __FILE__, 0, + &cfg_type_namedconf, + CFG_PCTX_NODEPRECATED, conf)); } isc_result_t diff --git a/external/mpl/bind/dist/bin/named/control.c b/external/mpl/bind/dist/bin/named/control.c index 911d339b2b3..b1bc88b3345 100644 --- a/external/mpl/bind/dist/bin/named/control.c +++ b/external/mpl/bind/dist/bin/named/control.c @@ -1,4 +1,4 @@ -/* $NetBSD: control.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: control.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -154,16 +154,11 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly, "received control channel command '%s'", cmdline); - if (command_compare(command, NAMED_COMMAND_RELOAD)) { - result = named_server_reloadcommand(named_g_server, lex, text); - } else if (command_compare(command, NAMED_COMMAND_RECONFIG)) { - result = named_server_reconfigcommand(named_g_server); - } else if (command_compare(command, NAMED_COMMAND_REFRESH)) { - result = named_server_refreshcommand(named_g_server, lex, text); - } else if (command_compare(command, NAMED_COMMAND_RETRANSFER)) { - result = named_server_retransfercommand(named_g_server, - lex, text); - } else if (command_compare(command, NAMED_COMMAND_HALT)) { + /* + * After the lengthy "halt" and "stop", the commands are + * handled in alphabetical order of the NAMED_COMMAND_ macros. + */ + if (command_compare(command, NAMED_COMMAND_HALT)) { #ifdef HAVE_LIBSCF /* * If we are managed by smf(5), AND in chroot, then @@ -208,83 +203,90 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly, named_os_shutdownmsg(cmdline, *text); isc_app_shutdown(); result = ISC_R_SUCCESS; - } else if (command_compare(command, NAMED_COMMAND_DUMPSTATS)) { - result = named_server_dumpstats(named_g_server); - } else if (command_compare(command, NAMED_COMMAND_QUERYLOG)) { - result = named_server_togglequerylog(named_g_server, lex); + } else if (command_compare(command, NAMED_COMMAND_ADDZONE) || + command_compare(command, NAMED_COMMAND_MODZONE)) { + result = named_server_changezone(named_g_server, cmdline, text); + } else if (command_compare(command, NAMED_COMMAND_DELZONE)) { + result = named_server_delzone(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_DNSTAP) || + command_compare(command, NAMED_COMMAND_DNSTAPREOPEN)) { + result = named_server_dnstap(named_g_server, lex, text); } else if (command_compare(command, NAMED_COMMAND_DUMPDB)) { named_server_dumpdb(named_g_server, lex, text); result = ISC_R_SUCCESS; - } else if (command_compare(command, NAMED_COMMAND_SECROOTS)) { - result = named_server_dumpsecroots(named_g_server, lex, text); - } else if (command_compare(command, NAMED_COMMAND_TRACE)) { - result = named_server_setdebuglevel(named_g_server, lex); - } else if (command_compare(command, NAMED_COMMAND_NOTRACE)) { - named_g_debuglevel = 0; - isc_log_setdebuglevel(named_g_lctx, named_g_debuglevel); - result = ISC_R_SUCCESS; + } else if (command_compare(command, NAMED_COMMAND_DUMPSTATS)) { + result = named_server_dumpstats(named_g_server); } else if (command_compare(command, NAMED_COMMAND_FLUSH)) { result = named_server_flushcache(named_g_server, lex); } else if (command_compare(command, NAMED_COMMAND_FLUSHNAME)) { result = named_server_flushnode(named_g_server, lex, false); } else if (command_compare(command, NAMED_COMMAND_FLUSHTREE)) { result = named_server_flushnode(named_g_server, lex, true); - } else if (command_compare(command, NAMED_COMMAND_STATUS)) { - result = named_server_status(named_g_server, text); - } else if (command_compare(command, NAMED_COMMAND_TSIGLIST)) { - result = named_server_tsiglist(named_g_server, text); - } else if (command_compare(command, NAMED_COMMAND_TSIGDELETE)) { - result = named_server_tsigdelete(named_g_server, lex, text); } else if (command_compare(command, NAMED_COMMAND_FREEZE)) { - result = named_server_freeze(named_g_server, true, lex, - text); - } else if (command_compare(command, NAMED_COMMAND_UNFREEZE) || - command_compare(command, NAMED_COMMAND_THAW)) { - result = named_server_freeze(named_g_server, false, lex, - text); - } else if (command_compare(command, NAMED_COMMAND_SCAN)) { + result = named_server_freeze(named_g_server, true, lex, text); + } else if (command_compare(command, NAMED_COMMAND_LOADKEYS) || + command_compare(command, NAMED_COMMAND_SIGN)) { + result = named_server_rekey(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_MKEYS)) { + result = named_server_mkeys(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_NOTIFY)) { + result = named_server_notifycommand(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_NOTRACE)) { + named_g_debuglevel = 0; + isc_log_setdebuglevel(named_g_lctx, named_g_debuglevel); + result = ISC_R_SUCCESS; + } else if (command_compare(command, NAMED_COMMAND_NTA)) { + result = named_server_nta(named_g_server, lex, readonly, text); + } else if (command_compare(command, NAMED_COMMAND_NULL)) { result = ISC_R_SUCCESS; + } else if (command_compare(command, NAMED_COMMAND_QUERYLOG)) { + result = named_server_togglequerylog(named_g_server, lex); + } else if (command_compare(command, NAMED_COMMAND_RECONFIG)) { + result = named_server_reconfigcommand(named_g_server); + } else if (command_compare(command, NAMED_COMMAND_RECURSING)) { + result = named_server_dumprecursing(named_g_server); + } else if (command_compare(command, NAMED_COMMAND_REFRESH)) { + result = named_server_refreshcommand(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_RELOAD)) { + result = named_server_reloadcommand(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_RETRANSFER)) { + result = named_server_retransfercommand(named_g_server, + lex, text); + } else if (command_compare(command, NAMED_COMMAND_SCAN)) { named_server_scan_interfaces(named_g_server); + result = ISC_R_SUCCESS; + } else if (command_compare(command, NAMED_COMMAND_SECROOTS)) { + result = named_server_dumpsecroots(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_SERVESTALE)) { + result = named_server_servestale(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_SHOWZONE)) { + result = named_server_showzone(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_SIGNING)) { + result = named_server_signing(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_STATUS)) { + result = named_server_status(named_g_server, text); } else if (command_compare(command, NAMED_COMMAND_SYNC)) { result = named_server_sync(named_g_server, lex, text); - } else if (command_compare(command, NAMED_COMMAND_RECURSING)) { - result = named_server_dumprecursing(named_g_server); + } else if (command_compare(command, NAMED_COMMAND_TCPTIMEOUTS)) { + result = named_server_tcptimeouts(lex, text); + } else if (command_compare(command, NAMED_COMMAND_TESTGEN)) { + result = named_server_testgen(lex, text); + } else if (command_compare(command, NAMED_COMMAND_THAW) || + command_compare(command, NAMED_COMMAND_UNFREEZE)) { + result = named_server_freeze(named_g_server, false, lex, text); } else if (command_compare(command, NAMED_COMMAND_TIMERPOKE)) { - result = ISC_R_SUCCESS; isc_timermgr_poke(named_g_timermgr); - } else if (command_compare(command, NAMED_COMMAND_NULL)) { result = ISC_R_SUCCESS; - } else if (command_compare(command, NAMED_COMMAND_NOTIFY)) { - result = named_server_notifycommand(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_TRACE)) { + result = named_server_setdebuglevel(named_g_server, lex); + } else if (command_compare(command, NAMED_COMMAND_TSIGDELETE)) { + result = named_server_tsigdelete(named_g_server, lex, text); + } else if (command_compare(command, NAMED_COMMAND_TSIGLIST)) { + result = named_server_tsiglist(named_g_server, text); } else if (command_compare(command, NAMED_COMMAND_VALIDATION)) { result = named_server_validation(named_g_server, lex, text); - } else if (command_compare(command, NAMED_COMMAND_SIGN) || - command_compare(command, NAMED_COMMAND_LOADKEYS)) { - result = named_server_rekey(named_g_server, lex, text); - } else if (command_compare(command, NAMED_COMMAND_ADDZONE) || - command_compare(command, NAMED_COMMAND_MODZONE)) { - result = named_server_changezone(named_g_server, cmdline, text); - } else if (command_compare(command, NAMED_COMMAND_DELZONE)) { - result = named_server_delzone(named_g_server, lex, text); - } else if (command_compare(command, NAMED_COMMAND_SHOWZONE)) { - result = named_server_showzone(named_g_server, lex, text); - } else if (command_compare(command, NAMED_COMMAND_SIGNING)) { - result = named_server_signing(named_g_server, lex, text); } else if (command_compare(command, NAMED_COMMAND_ZONESTATUS)) { result = named_server_zonestatus(named_g_server, lex, text); - } else if (command_compare(command, NAMED_COMMAND_NTA)) { - result = named_server_nta(named_g_server, lex, readonly, text); - } else if (command_compare(command, NAMED_COMMAND_TESTGEN)) { - result = named_server_testgen(lex, text); - } else if (command_compare(command, NAMED_COMMAND_MKEYS)) { - result = named_server_mkeys(named_g_server, lex, text); - } else if (command_compare(command, NAMED_COMMAND_DNSTAP) || - command_compare(command, NAMED_COMMAND_DNSTAPREOPEN)) { - result = named_server_dnstap(named_g_server, lex, text); - } else if (command_compare(command, NAMED_COMMAND_TCPTIMEOUTS)) { - result = named_server_tcptimeouts(lex, text); - } else if (command_compare(command, NAMED_COMMAND_SERVESTALE)) { - result = named_server_servestale(named_g_server, lex, text); } else { isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_CONTROL, ISC_LOG_WARNING, diff --git a/external/mpl/bind/dist/bin/named/include/named/globals.h b/external/mpl/bind/dist/bin/named/include/named/globals.h index 09ffe1d75ea..07cd0515ebf 100644 --- a/external/mpl/bind/dist/bin/named/include/named/globals.h +++ b/external/mpl/bind/dist/bin/named/include/named/globals.h @@ -1,4 +1,4 @@ -/* $NetBSD: globals.h,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: globals.h,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -92,7 +92,8 @@ EXTERN cfg_obj_t * named_g_config INIT(NULL); EXTERN const cfg_obj_t * named_g_defaults INIT(NULL); EXTERN const char * named_g_conffile INIT(NAMED_SYSCONFDIR "/named.conf"); -EXTERN cfg_obj_t * named_g_bindkeys INIT(NULL); +EXTERN const char * named_g_defaultbindkeys INIT(NAMED_SYSCONFDIR + "/bind.keys"); EXTERN const char * named_g_keyfile INIT(NAMED_SYSCONFDIR "/rndc.key"); diff --git a/external/mpl/bind/dist/bin/named/include/named/server.h b/external/mpl/bind/dist/bin/named/include/named/server.h index eda0cfe14d7..6051ac41c0b 100644 --- a/external/mpl/bind/dist/bin/named/include/named/server.h +++ b/external/mpl/bind/dist/bin/named/include/named/server.h @@ -1,4 +1,4 @@ -/* $NetBSD: server.h,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: server.h,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -80,6 +80,7 @@ struct named_server { isc_mutex_t reload_event_lock; isc_event_t * reload_event; + bool reload_in_progress; bool flushonshutdown; diff --git a/external/mpl/bind/dist/bin/named/main.c b/external/mpl/bind/dist/bin/named/main.c index cf56f68c6b5..a8dc69a25be 100644 --- a/external/mpl/bind/dist/bin/named/main.c +++ b/external/mpl/bind/dist/bin/named/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: main.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -451,6 +451,98 @@ set_flags(const char *arg, struct flag_def *defs, unsigned int *ret) { } static void +printversion(bool verbose) { + char rndcconf[PATH_MAX], *dot = NULL; + + printf("%s %s%s%s <id:%s>\n", + named_g_product, named_g_version, + (*named_g_description != '\0') ? " " : "", + named_g_description, named_g_srcid); + + if (!verbose) { + return; + } + + printf("running on %s\n", named_os_uname()); + printf("built by %s with %s\n", + named_g_builder, named_g_configargs); +#ifdef __clang__ + printf("compiled by CLANG %s\n", __VERSION__); +#else +#if defined(__ICC) || defined(__INTEL_COMPILER) + printf("compiled by ICC %s\n", __VERSION__); +#else +#ifdef __GNUC__ + printf("compiled by GCC %s\n", __VERSION__); +#endif +#endif +#endif +#ifdef _MSC_VER + printf("compiled by MSVC %d\n", _MSC_VER); +#endif +#ifdef __SUNPRO_C + printf("compiled by Solaris Studio %x\n", __SUNPRO_C); +#endif + printf("compiled with OpenSSL version: %s\n", + OPENSSL_VERSION_TEXT); +#if !defined(LIBRESSL_VERSION_NUMBER) && \ +OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 or higher */ + printf("linked to OpenSSL version: %s\n", + OpenSSL_version(OPENSSL_VERSION)); + +#else + printf("linked to OpenSSL version: %s\n", + SSLeay_version(SSLEAY_VERSION)); +#endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */ +#ifdef HAVE_LIBXML2 + printf("compiled with libxml2 version: %s\n", + LIBXML_DOTTED_VERSION); + printf("linked to libxml2 version: %s\n", + xmlParserVersion); +#endif +#if defined(HAVE_JSON) && defined(JSON_C_VERSION) + printf("compiled with libjson-c version: %s\n", + JSON_C_VERSION); + printf("linked to libjson-c version: %s\n", + json_c_version()); +#endif +#if defined(HAVE_ZLIB) && defined(ZLIB_VERSION) + printf("compiled with zlib version: %s\n", + ZLIB_VERSION); + printf("linked to zlib version: %s\n", + zlibVersion()); +#endif + printf("threads support is enabled\n\n"); + + + /* + * The default rndc.conf and rndc.key paths are in the same + * directory, but named only has rndc.key defined internally. + * We construct the rndc.conf path from it. (We could use + * NAMED_SYSCONFDIR here but the result would look wrong on + * Windows.) + */ + strlcpy(rndcconf, named_g_keyfile, sizeof(rndcconf)); + dot = strrchr(rndcconf, '.'); + if (dot != NULL) { + size_t len = dot - rndcconf + 1; + snprintf(dot + 1, PATH_MAX - len, "conf"); + } + + /* + * Print default configuration paths. + */ + printf("default paths:\n"); + printf(" named configuration: %s\n", named_g_conffile); + printf(" rndc configuration: %s\n", rndcconf); + printf(" DNSSEC root key: %s\n", named_g_defaultbindkeys); + printf(" nsupdate session key: %s\n", named_g_defaultsessionkeyfile); + printf(" named PID file: %s\n", named_g_defaultpidfile); + printf(" named lock file: %s\n", named_g_defaultlockfile); + +} + +static void parse_fuzz_arg(void) { if (!strncmp(isc_commandline_argument, "client:", 7)) { named_g_fuzz_addr = isc_commandline_argument + 7; @@ -675,66 +767,10 @@ parse_command_line(int argc, char *argv[]) { named_g_username = isc_commandline_argument; break; case 'v': - printf("%s %s%s%s <id:%s>\n", - named_g_product, named_g_version, - (*named_g_description != '\0') ? " " : "", - named_g_description, named_g_srcid); + printversion(false); exit(0); case 'V': - printf("%s %s%s%s <id:%s>\n", - named_g_product, named_g_version, - (*named_g_description != '\0') ? " " : "", - named_g_description, named_g_srcid); - printf("running on %s\n", named_os_uname()); - printf("built by %s with %s\n", - named_g_builder, named_g_configargs); -#ifdef __clang__ - printf("compiled by CLANG %s\n", __VERSION__); -#else -#if defined(__ICC) || defined(__INTEL_COMPILER) - printf("compiled by ICC %s\n", __VERSION__); -#else -#ifdef __GNUC__ - printf("compiled by GCC %s\n", __VERSION__); -#endif -#endif -#endif -#ifdef _MSC_VER - printf("compiled by MSVC %d\n", _MSC_VER); -#endif -#ifdef __SUNPRO_C - printf("compiled by Solaris Studio %x\n", __SUNPRO_C); -#endif - printf("compiled with OpenSSL version: %s\n", - OPENSSL_VERSION_TEXT); -#if !defined(LIBRESSL_VERSION_NUMBER) && \ - OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 or higher */ - printf("linked to OpenSSL version: %s\n", - OpenSSL_version(OPENSSL_VERSION)); - -#else - printf("linked to OpenSSL version: %s\n", - SSLeay_version(SSLEAY_VERSION)); -#endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */ -#ifdef HAVE_LIBXML2 - printf("compiled with libxml2 version: %s\n", - LIBXML_DOTTED_VERSION); - printf("linked to libxml2 version: %s\n", - xmlParserVersion); -#endif -#if defined(HAVE_JSON) && defined(JSON_C_VERSION) - printf("compiled with libjson-c version: %s\n", - JSON_C_VERSION); - printf("linked to libjson-c version: %s\n", - json_c_version()); -#endif -#if defined(HAVE_ZLIB) && defined(ZLIB_VERSION) - printf("compiled with zlib version: %s\n", - ZLIB_VERSION); - printf("linked to zlib version: %s\n", - zlibVersion()); -#endif - printf("threads support is enabled\n"); + printversion(true); exit(0); case 'x': /* Obsolete. No longer in use. Ignore. */ diff --git a/external/mpl/bind/dist/bin/named/named.8 b/external/mpl/bind/dist/bin/named/named.8 index e6fe820ba5f..b673763742d 100644 --- a/external/mpl/bind/dist/bin/named/named.8 +++ b/external/mpl/bind/dist/bin/named/named.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: named.8,v 1.2 2018/08/12 13:02:27 christos Exp $ +.\" $NetBSD: named.8,v 1.3 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2000, 2001, 2003-2009, 2011, 2013-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2000, 2001, 2003-2009, 2011, 2013-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -380,5 +380,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2000, 2001, 2003-2009, 2011, 2013-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2000, 2001, 2003-2009, 2011, 2013-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/named/named.conf.5 b/external/mpl/bind/dist/bin/named/named.conf.5 index cce4d86ebef..361b27064a7 100644 --- a/external/mpl/bind/dist/bin/named/named.conf.5 +++ b/external/mpl/bind/dist/bin/named/named.conf.5 @@ -1,6 +1,6 @@ -.\" $NetBSD: named.conf.5,v 1.3 2019/01/09 16:54:59 christos Exp $ +.\" $NetBSD: named.conf.5,v 1.4 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2004-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2004-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,12 +12,12 @@ .\" Title: named.conf .\" Author: .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/> -.\" Date: 2018-10-23 +.\" Date: 2018-12-07 .\" Manual: BIND9 .\" Source: ISC .\" Language: English .\" -.TH "NAMED\&.CONF" "5" "2018\-10\-23" "ISC" "BIND9" +.TH "NAMED\&.CONF" "5" "2018\-12\-07" "ISC" "BIND9" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -211,9 +211,9 @@ options { bindkeys\-file \fIquoted_string\fR; blackhole { \fIaddress_match_element\fR; \&.\&.\&. }; cache\-file \fIquoted_string\fR; - catalog\-zones { zone \fIquoted_string\fR [ default\-masters [ port - \fIinteger\fR ] [ dscp \fIinteger\fR ] { ( \fImasters\fR | \fIipv4_address\fR [ - port \fIinteger\fR ] | \fIipv6_address\fR [ port \fIinteger\fR ] ) [ key + catalog\-zones { zone \fIstring\fR [ default\-masters [ port \fIinteger\fR ] + [ dscp \fIinteger\fR ] { ( \fImasters\fR | \fIipv4_address\fR [ port + \fIinteger\fR ] | \fIipv6_address\fR [ port \fIinteger\fR ] ) [ key \fIstring\fR ]; \&.\&.\&. } ] [ zone\-directory \fIquoted_string\fR ] [ in\-memory \fIboolean\fR ] [ min\-update\-interval \fIttlval\fR ]; \&.\&.\&. }; check\-dup\-records ( fail | warn | ignore ); @@ -267,12 +267,15 @@ options { dnssec\-secure\-to\-insecure \fIboolean\fR; dnssec\-update\-mode ( maintain | no\-resign ); dnssec\-validation ( yes | no | auto ); - dnstap { ( all | auth | client | forwarder | resolver | update ) [ - ( query | response ) ]; \&.\&.\&. }; - dnstap\-identity ( \fIquoted_string\fR | none | hostname ); - dnstap\-output ( file | unix ) \fIquoted_string\fR [ size ( unlimited | - \fIsize\fR ) ] [ versions ( unlimited | \fIinteger\fR ) ] [ suffix ( - increment | timestamp ) ]; + dnstap { ( all | auth | client | forwarder | + resolver | update ) [ ( query | response ) ]; + \&.\&.\&. }; + dnstap\-identity ( \fIquoted_string\fR | none | + hostname ); + dnstap\-output ( file | unix ) \fIquoted_string\fR [ + size ( unlimited | \fIsize\fR ) ] [ versions ( + unlimited | \fIinteger\fR ) ] [ suffix ( increment + | timestamp ) ]; dnstap\-version ( \fIquoted_string\fR | none ); dscp \fIinteger\fR; dual\-stack\-servers [ port \fIinteger\fR ] { ( \fIquoted_string\fR [ port @@ -288,9 +291,6 @@ options { fetches\-per\-server \fIinteger\fR [ ( drop | fail ) ]; fetches\-per\-zone \fIinteger\fR [ ( drop | fail ) ]; files ( default | unlimited | \fIsizeval\fR ); - filter\-aaaa { \fIaddress_match_element\fR; \&.\&.\&. }; - filter\-aaaa\-on\-v4 ( break\-dnssec | \fIboolean\fR ); - filter\-aaaa\-on\-v6 ( break\-dnssec | \fIboolean\fR ); flush\-zones\-on\-shutdown \fIboolean\fR; forward ( first | only ); forwarders [ port \fIinteger\fR ] [ dscp \fIinteger\fR ] { ( \fIipv4_address\fR @@ -411,18 +411,17 @@ options { resolver\-retry\-interval \fIinteger\fR; response\-padding { \fIaddress_match_element\fR; \&.\&.\&. } block\-size \fIinteger\fR; - response\-policy { zone \fIquoted_string\fR [ log \fIboolean\fR ] [ - max\-policy\-ttl \fIttlval\fR ] [ min\-update\-interval \fIttlval\fR ] [ - policy ( cname | disabled | drop | given | no\-op | nodata | - nxdomain | passthru | tcp\-only \fIquoted_string\fR ) ] [ - recursive\-only \fIboolean\fR ] [ nsip\-enable \fIboolean\fR ] [ - nsdname\-enable \fIboolean\fR ]; \&.\&.\&. } [ break\-dnssec \fIboolean\fR ] [ - max\-policy\-ttl \fIttlval\fR ] [ min\-update\-interval \fIttlval\fR ] [ - min\-ns\-dots \fIinteger\fR ] [ nsip\-wait\-recurse \fIboolean\fR ] [ - qname\-wait\-recurse \fIboolean\fR ] [ recursive\-only \fIboolean\fR ] [ - nsip\-enable \fIboolean\fR ] [ nsdname\-enable \fIboolean\fR ] [ - dnsrps\-enable \fIboolean\fR ] [ dnsrps\-options { \fIunspecified\-text\fR - } ]; + response\-policy { zone \fIstring\fR [ log \fIboolean\fR ] [ max\-policy\-ttl + \fIttlval\fR ] [ min\-update\-interval \fIttlval\fR ] [ policy ( cname | + disabled | drop | given | no\-op | nodata | nxdomain | passthru + | tcp\-only \fIquoted_string\fR ) ] [ recursive\-only \fIboolean\fR ] [ + nsip\-enable \fIboolean\fR ] [ nsdname\-enable \fIboolean\fR ]; \&.\&.\&. } [ + break\-dnssec \fIboolean\fR ] [ max\-policy\-ttl \fIttlval\fR ] [ + min\-update\-interval \fIttlval\fR ] [ min\-ns\-dots \fIinteger\fR ] [ + nsip\-wait\-recurse \fIboolean\fR ] [ qname\-wait\-recurse \fIboolean\fR ] + [ recursive\-only \fIboolean\fR ] [ nsip\-enable \fIboolean\fR ] [ + nsdname\-enable \fIboolean\fR ] [ dnsrps\-enable \fIboolean\fR ] [ + dnsrps\-options { \fIunspecified\-text\fR } ]; root\-delegation\-only [ exclude { \fIstring\fR; \&.\&.\&. } ]; root\-key\-sentinel \fIboolean\fR; rrset\-order { [ class \fIstring\fR ] [ type \fIstring\fR ] [ name @@ -483,6 +482,18 @@ options { .if n \{\ .RE .\} +.SH "PLUGIN" +.sp +.if n \{\ +.RS 4 +.\} +.nf +plugin ( query ) \fIstring\fR [ { \fIunspecified\-text\fR + } ]; +.fi +.if n \{\ +.RE +.\} .SH "SERVER" .sp .if n \{\ @@ -582,9 +593,9 @@ view \fIstring\fR [ \fIclass\fR ] { auth\-nxdomain \fIboolean\fR; // default changed auto\-dnssec ( allow | maintain | off ); cache\-file \fIquoted_string\fR; - catalog\-zones { zone \fIquoted_string\fR [ default\-masters [ port - \fIinteger\fR ] [ dscp \fIinteger\fR ] { ( \fImasters\fR | \fIipv4_address\fR [ - port \fIinteger\fR ] | \fIipv6_address\fR [ port \fIinteger\fR ] ) [ key + catalog\-zones { zone \fIstring\fR [ default\-masters [ port \fIinteger\fR ] + [ dscp \fIinteger\fR ] { ( \fImasters\fR | \fIipv4_address\fR [ port + \fIinteger\fR ] | \fIipv6_address\fR [ port \fIinteger\fR ] ) [ key \fIstring\fR ]; \&.\&.\&. } ] [ zone\-directory \fIquoted_string\fR ] [ in\-memory \fIboolean\fR ] [ min\-update\-interval \fIttlval\fR ]; \&.\&.\&. }; check\-dup\-records ( fail | warn | ignore ); @@ -637,8 +648,9 @@ view \fIstring\fR [ \fIclass\fR ] { dnssec\-secure\-to\-insecure \fIboolean\fR; dnssec\-update\-mode ( maintain | no\-resign ); dnssec\-validation ( yes | no | auto ); - dnstap { ( all | auth | client | forwarder | resolver | update ) [ - ( query | response ) ]; \&.\&.\&. }; + dnstap { ( all | auth | client | forwarder | + resolver | update ) [ ( query | response ) ]; + \&.\&.\&. }; dual\-stack\-servers [ port \fIinteger\fR ] { ( \fIquoted_string\fR [ port \fIinteger\fR ] [ dscp \fIinteger\fR ] | \fIipv4_address\fR [ port \fIinteger\fR ] [ dscp \fIinteger\fR ] | \fIipv6_address\fR [ port @@ -652,9 +664,6 @@ view \fIstring\fR [ \fIclass\fR ] { fetch\-quota\-params \fIinteger\fR \fIfixedpoint\fR \fIfixedpoint\fR \fIfixedpoint\fR; fetches\-per\-server \fIinteger\fR [ ( drop | fail ) ]; fetches\-per\-zone \fIinteger\fR [ ( drop | fail ) ]; - filter\-aaaa { \fIaddress_match_element\fR; \&.\&.\&. }; - filter\-aaaa\-on\-v4 ( break\-dnssec | \fIboolean\fR ); - filter\-aaaa\-on\-v6 ( break\-dnssec | \fIboolean\fR ); forward ( first | only ); forwarders [ port \fIinteger\fR ] [ dscp \fIinteger\fR ] { ( \fIipv4_address\fR | \fIipv6_address\fR ) [ port \fIinteger\fR ] [ dscp \fIinteger\fR ]; \&.\&.\&. }; @@ -695,6 +704,8 @@ view \fIstring\fR [ \fIclass\fR ] { max\-udp\-size \fIinteger\fR; max\-zone\-ttl ( unlimited | \fIttlval\fR ); message\-compression \fIboolean\fR; + min\-cache\-ttl \fIttlval\fR; + min\-ncache\-ttl \fIttlval\fR; min\-refresh\-time \fIinteger\fR; min\-retry\-time \fIinteger\fR; minimal\-any \fIboolean\fR; @@ -713,6 +724,8 @@ view \fIstring\fR [ \fIclass\fR ] { nta\-lifetime \fIttlval\fR; nta\-recheck \fIttlval\fR; nxdomain\-redirect \fIstring\fR; + plugin ( query ) \fIstring\fR [ { + \fIunspecified\-text\fR } ]; preferred\-glue \fIstring\fR; prefetch \fIinteger\fR [ \fIinteger\fR ]; provide\-ixfr \fIboolean\fR; @@ -750,18 +763,17 @@ view \fIstring\fR [ \fIclass\fR ] { resolver\-retry\-interval \fIinteger\fR; response\-padding { \fIaddress_match_element\fR; \&.\&.\&. } block\-size \fIinteger\fR; - response\-policy { zone \fIquoted_string\fR [ log \fIboolean\fR ] [ - max\-policy\-ttl \fIttlval\fR ] [ min\-update\-interval \fIttlval\fR ] [ - policy ( cname | disabled | drop | given | no\-op | nodata | - nxdomain | passthru | tcp\-only \fIquoted_string\fR ) ] [ - recursive\-only \fIboolean\fR ] [ nsip\-enable \fIboolean\fR ] [ - nsdname\-enable \fIboolean\fR ]; \&.\&.\&. } [ break\-dnssec \fIboolean\fR ] [ - max\-policy\-ttl \fIttlval\fR ] [ min\-update\-interval \fIttlval\fR ] [ - min\-ns\-dots \fIinteger\fR ] [ nsip\-wait\-recurse \fIboolean\fR ] [ - qname\-wait\-recurse \fIboolean\fR ] [ recursive\-only \fIboolean\fR ] [ - nsip\-enable \fIboolean\fR ] [ nsdname\-enable \fIboolean\fR ] [ - dnsrps\-enable \fIboolean\fR ] [ dnsrps\-options { \fIunspecified\-text\fR - } ]; + response\-policy { zone \fIstring\fR [ log \fIboolean\fR ] [ max\-policy\-ttl + \fIttlval\fR ] [ min\-update\-interval \fIttlval\fR ] [ policy ( cname | + disabled | drop | given | no\-op | nodata | nxdomain | passthru + | tcp\-only \fIquoted_string\fR ) ] [ recursive\-only \fIboolean\fR ] [ + nsip\-enable \fIboolean\fR ] [ nsdname\-enable \fIboolean\fR ]; \&.\&.\&. } [ + break\-dnssec \fIboolean\fR ] [ max\-policy\-ttl \fIttlval\fR ] [ + min\-update\-interval \fIttlval\fR ] [ min\-ns\-dots \fIinteger\fR ] [ + nsip\-wait\-recurse \fIboolean\fR ] [ qname\-wait\-recurse \fIboolean\fR ] + [ recursive\-only \fIboolean\fR ] [ nsip\-enable \fIboolean\fR ] [ + nsdname\-enable \fIboolean\fR ] [ dnsrps\-enable \fIboolean\fR ] [ + dnsrps\-options { \fIunspecified\-text\fR } ]; root\-delegation\-only [ exclude { \fIstring\fR; \&.\&.\&. } ]; root\-key\-sentinel \fIboolean\fR; rrset\-order { [ class \fIstring\fR ] [ type \fIstring\fR ] [ name @@ -897,9 +909,7 @@ view \fIstring\fR [ \fIclass\fR ] { notify\-source\-v6 ( \fIipv6_address\fR | * ) [ port ( \fIinteger\fR | * ) ] [ dscp \fIinteger\fR ]; notify\-to\-soa \fIboolean\fR; - pubkey \fIinteger\fR - \fIinteger\fR - \fIinteger\fR + pubkey \fIinteger\fR \fIinteger\fR \fIinteger\fR request\-expire \fIboolean\fR; request\-ixfr \fIboolean\fR; serial\-update\-method ( date | increment | unixtime ); @@ -1005,7 +1015,6 @@ zone \fIstring\fR [ \fIclass\fR ] { notify\-source\-v6 ( \fIipv6_address\fR | * ) [ port ( \fIinteger\fR | * ) ] [ dscp \fIinteger\fR ]; notify\-to\-soa \fIboolean\fR; - pubkey \fIinteger\fR \fIinteger\fR request\-expire \fIboolean\fR; request\-ixfr \fIboolean\fR; serial\-update\-method ( date | increment | unixtime ); @@ -1053,5 +1062,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2004-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2004-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/named/server.c b/external/mpl/bind/dist/bin/named/server.c index 6945585ab70..3a6bec3ba75 100644 --- a/external/mpl/bind/dist/bin/named/server.c +++ b/external/mpl/bind/dist/bin/named/server.c @@ -1,4 +1,4 @@ -/* $NetBSD: server.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: server.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -779,8 +779,7 @@ dstkey_fromconfig(const cfg_obj_t *vconfig, const cfg_obj_t *key, keystruct.datalen = r.length; keystruct.data = r.base; - if ((keystruct.algorithm == DST_ALG_RSASHA1 || - keystruct.algorithm == DST_ALG_RSAMD5) && + if ((keystruct.algorithm == DST_ALG_RSASHA1) && r.length > 1 && r.base[0] == 1 && r.base[1] == 3) cfg_obj_log(key, named_g_lctx, ISC_LOG_WARNING, "%s key '%s' has a weak exponent", @@ -2292,21 +2291,18 @@ configure_rpz(dns_view_t *view, const cfg_obj_t **maps, if (zone_element == NULL) return (ISC_R_SUCCESS); -#ifdef ENABLE_RPZ_NSIP nsip_enabled = true; - nsdname_enabled = true; -#else - nsip_enabled = false; - nsdname_enabled = false; -#endif sub_obj = cfg_tuple_get(rpz_obj, "nsip-enable"); - if (!cfg_obj_isvoid(sub_obj)) + if (!cfg_obj_isvoid(sub_obj)) { nsip_enabled = cfg_obj_asboolean(sub_obj); + } nsip_on = nsip_enabled ? DNS_RPZ_ALL_ZBITS : 0; + nsdname_enabled = true; sub_obj = cfg_tuple_get(rpz_obj, "nsdname-enable"); - if (!cfg_obj_isvoid(sub_obj)) + if (!cfg_obj_isvoid(sub_obj)) { nsdname_enabled = cfg_obj_asboolean(sub_obj); + } nsdname_on = nsdname_enabled ? DNS_RPZ_ALL_ZBITS : 0; /* @@ -2581,8 +2577,8 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) { result = dns_catz_generate_zonecfg(ev->origin, ev->entry, &confbuf); if (result == ISC_R_SUCCESS) { cfg_parser_reset(cfg->add_parser); - result = cfg_parse_buffer3(cfg->add_parser, confbuf, "catz", 0, - &cfg_type_addzoneconf, &zoneconf); + result = cfg_parse_buffer(cfg->add_parser, confbuf, "catz", 0, + &cfg_type_addzoneconf, 0, &zoneconf); isc_buffer_free(&confbuf); } /* @@ -4998,16 +4994,10 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, &view->sortlist)); /* - * Configure default allow-notify, allow-update - * and allow-update-forwarding ACLs, so they can be - * inherited by zones. (Note these cannot be set at + * Configure default allow-update and allow-update-forwarding ACLs, + * so they can be inherited by zones. (Note these cannot be set at * options/view level.) */ - if (view->notifyacl == NULL) { - CHECK(configure_view_acl(vconfig, config, named_g_config, - "allow-notify", NULL, actx, - named_g_mctx, &view->notifyacl)); - } if (view->updateacl == NULL) { CHECK(configure_view_acl(NULL, NULL, named_g_config, "allow-update", NULL, actx, @@ -5020,14 +5010,19 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, } /* - * Configure default allow-transer ACL so it can be inherited - * by zones. (Note this *can* be set at options or view level.) + * Configure default allow-transfer and allow-notify ACLs so they + * can be inherited by zones. */ if (view->transferacl == NULL) { CHECK(configure_view_acl(vconfig, config, named_g_config, "allow-transfer", NULL, actx, named_g_mctx, &view->transferacl)); } + if (view->notifyacl == NULL) { + CHECK(configure_view_acl(vconfig, config, named_g_config, + "allow-notify", NULL, actx, + named_g_mctx, &view->notifyacl)); + } obj = NULL; result = named_config_get(maps, "provide-ixfr", &obj); @@ -7649,8 +7644,8 @@ data_to_cfg(dns_view_t *view, MDB_val *key, MDB_val *data, CHECK(putstr(text, ";\n")); cfg_parser_reset(named_g_addparser); - result = cfg_parse_buffer3(named_g_addparser, *text, zone_name, 0, - &cfg_type_addzoneconf, &zoneconf); + result = cfg_parse_buffer(named_g_addparser, *text, zone_name, 0, + &cfg_type_addzoneconf, 0, &zoneconf); if (result != ISC_R_SUCCESS) { isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR, @@ -8029,6 +8024,7 @@ load_configuration(const char *filename, named_server_t *server, ns_altsecretlist_t altsecrets, tmpaltsecrets; unsigned int maxsocks; uint32_t softquota = 0; + uint32_t max; unsigned int initial, idle, keepalive, advertised; dns_aclenv_t *env = ns_interfacemgr_getaclenv(named_g_server->interfacemgr); @@ -8221,20 +8217,20 @@ load_configuration(const char *filename, named_server_t *server, configure_server_quota(maps, "recursive-clients", &server->sctx->recursionquota); - if (server->sctx->recursionquota.max > 1000) { - int margin = ISC_MAX(100, named_g_cpus + 1); - if (margin > server->sctx->recursionquota.max - 100) { + max = isc_quota_getmax(&server->sctx->recursionquota); + if (max > 1000) { + unsigned margin = ISC_MAX(100, named_g_cpus + 1); + if (margin + 100 > max) { isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR, "'recursive-clients %d' too low when " "running with %d worker threads", - server->sctx->recursionquota.max, - named_g_cpus); + max, named_g_cpus); CHECK(ISC_R_RANGE); } - softquota = server->sctx->recursionquota.max - margin; + softquota = max - margin; } else { - softquota = (server->sctx->recursionquota.max * 90) / 100; + softquota = (max * 90) / 100; } isc_quota_soft(&server->sctx->recursionquota, softquota); @@ -9329,6 +9325,7 @@ view_loaded(void *arg) { "FIPS mode is %s", FIPS_mode() ? "enabled" : "disabled"); #endif + server->reload_in_progress = false; isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, ISC_LOG_NOTICE, @@ -9384,7 +9381,7 @@ load_zones(named_server_t *server, bool init, bool reconfig) { isc_refcount_increment(&zl->refs); result = dns_view_asyncload(view, reconfig, view_loaded, zl); if (result != ISC_R_SUCCESS) { - isc_refcount_decrement(&zl->refs); + (void)isc_refcount_decrement(&zl->refs); goto cleanup; } } @@ -9664,6 +9661,7 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) { CHECKFATAL(server->reload_event == NULL ? ISC_R_NOMEMORY : ISC_R_SUCCESS, "allocating reload event"); + server->reload_in_progress = true; /* * Setup the server task, which is responsible for coordinating @@ -9719,7 +9717,8 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) { CHECKFATAL(server->statsfile == NULL ? ISC_R_NOMEMORY : ISC_R_SUCCESS, "isc_mem_strdup"); - server->bindkeysfile = isc_mem_strdup(server->mctx, "bind.keys"); + server->bindkeysfile = isc_mem_strdup(server->mctx, + named_g_defaultbindkeys); CHECKFATAL(server->bindkeysfile == NULL ? ISC_R_NOMEMORY : ISC_R_SUCCESS, "isc_mem_strdup"); @@ -9974,6 +9973,7 @@ loadconfig(named_server_t *server) { static isc_result_t reload(named_server_t *server) { isc_result_t result; + server->reload_in_progress = true; CHECK(loadconfig(server)); result = load_zones(server, false, false); @@ -10320,6 +10320,7 @@ named_server_reloadcommand(named_server_t *server, isc_lex_t *lex, isc_result_t named_server_reconfigcommand(named_server_t *server) { isc_result_t result; + server->reload_in_progress = true; CHECK(loadconfig(server)); @@ -11456,15 +11457,20 @@ named_server_status(named_server_t *server, isc_buffer_t **text) { CHECK(putstr(text, line)); snprintf(line, sizeof(line), "recursive clients: %d/%d/%d\n", - server->sctx->recursionquota.used, - server->sctx->recursionquota.soft, - server->sctx->recursionquota.max); + isc_quota_getused(&server->sctx->recursionquota), + isc_quota_getsoft(&server->sctx->recursionquota), + isc_quota_getmax(&server->sctx->recursionquota)); CHECK(putstr(text, line)); snprintf(line, sizeof(line), "tcp clients: %d/%d\n", - server->sctx->tcpquota.used, server->sctx->tcpquota.max); + isc_quota_getused(&server->sctx->tcpquota), + isc_quota_getmax(&server->sctx->tcpquota)); CHECK(putstr(text, line)); + if (server->reload_in_progress) { + CHECK(putstr(text, "reload/reconfig in progress")); + } + CHECK(putstr(text, "server is up and running")); CHECK(putnull(text)); @@ -12727,8 +12733,8 @@ newzone_parse(named_server_t *server, char *command, dns_view_t **viewp, isc_buffer_forward(&argbuf, 3); cfg_parser_reset(named_g_addparser); - CHECK(cfg_parse_buffer3(named_g_addparser, &argbuf, bn, 0, - &cfg_type_addzoneconf, &zoneconf)); + CHECK(cfg_parse_buffer(named_g_addparser, &argbuf, bn, 0, + &cfg_type_addzoneconf, 0, &zoneconf)); CHECK(cfg_map_get(zoneconf, "zone", &zlist)); if (!cfg_obj_islist(zlist)) CHECK(ISC_R_FAILURE); @@ -14709,7 +14715,7 @@ named_server_nta(named_server_t *server, isc_lex_t *lex, CHECK(ISC_R_NOTFOUND); } - CHECK(putnull(text)); + (void) putnull(text); cleanup: if (msg != NULL) { @@ -14914,7 +14920,7 @@ mkey_dumpzone(dns_view_t *view, isc_buffer_t **text) { dns_rdata_toregion(&rdata, &r); isc_region_consume(&r, 12); - keyid = dst_region_computeid(&r, kd.algorithm); + keyid = dst_region_computeid(&r); snprintf(buf, sizeof(buf), "\n keyid: %u", keyid); CHECK(putstr(text, buf)); @@ -15045,29 +15051,17 @@ named_server_mkeys(named_server_t *server, isc_lex_t *lex, /* Look for the optional class name. */ classtxt = next_token(lex, text); if (classtxt != NULL) { - /* Look for the optional view name. */ - viewtxt = next_token(lex, text); - } - - if (classtxt == NULL) { - rdclass = dns_rdataclass_in; - } else { isc_textregion_t r; r.base = classtxt; r.length = strlen(classtxt); result = dns_rdataclass_fromtext(&rdclass, &r); if (result != ISC_R_SUCCESS) { - if (viewtxt == NULL) { - rdclass = dns_rdataclass_in; - viewtxt = classtxt; - result = ISC_R_SUCCESS; - } else { - snprintf(msg, sizeof(msg), - "unknown class '%s'", classtxt); - (void) putstr(text, msg); - goto cleanup; - } + snprintf(msg, sizeof(msg), + "unknown class '%s'", classtxt); + (void) putstr(text, msg); + goto cleanup; } + viewtxt = next_token(lex, text); } for (view = ISC_LIST_HEAD(server->viewlist); @@ -15096,6 +15090,9 @@ named_server_mkeys(named_server_t *server, isc_lex_t *lex, switch (opt) { case REFRESH: + if (!first) { + CHECK(putstr(text, "\n")); + } CHECK(mkey_refresh(view, text)); break; case STATUS: @@ -15103,12 +15100,14 @@ named_server_mkeys(named_server_t *server, isc_lex_t *lex, CHECK(putstr(text, "\n\n")); } CHECK(mkey_status(view, text)); - first = false; break; case SYNC: CHECK(dns_zone_flush(view->managed_keys)); break; case DESTROY: + if (!first) { + CHECK(putstr(text, "\n")); + } CHECK(mkey_destroy(server, view, text)); break; default: @@ -15119,6 +15118,7 @@ named_server_mkeys(named_server_t *server, isc_lex_t *lex, if (viewtxt != NULL) { break; } + first = false; } if (!found) { diff --git a/external/mpl/bind/dist/bin/named/unix/dlz_dlopen_driver.c b/external/mpl/bind/dist/bin/named/unix/dlz_dlopen_driver.c index 72b593644c3..2d6198d4db4 100644 --- a/external/mpl/bind/dist/bin/named/unix/dlz_dlopen_driver.c +++ b/external/mpl/bind/dist/bin/named/unix/dlz_dlopen_driver.c @@ -1,4 +1,4 @@ -/* $NetBSD: dlz_dlopen_driver.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: dlz_dlopen_driver.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -259,7 +259,7 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[], /* Open the library */ dlopen_flags = RTLD_NOW|RTLD_GLOBAL; -#ifdef RTLD_DEEPBIND +#if defined(RTLD_DEEPBIND) && !__SANITIZE_ADDRESS__ /* * If RTLD_DEEPBIND is available then use it. This can avoid * issues with a module using a different version of a system diff --git a/external/mpl/bind/dist/bin/named/win32/os.c b/external/mpl/bind/dist/bin/named/win32/os.c index 7605a9c6403..9339b6473a4 100644 --- a/external/mpl/bind/dist/bin/named/win32/os.c +++ b/external/mpl/bind/dist/bin/named/win32/os.c @@ -1,4 +1,4 @@ -/* $NetBSD: os.c,v 1.3 2019/01/09 16:54:59 christos Exp $ */ +/* $NetBSD: os.c,v 1.4 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -61,6 +61,7 @@ named_paths_init(void) { named_g_defaultlockfile = isc_ntpaths_get(NAMED_LOCK_PATH); named_g_keyfile = isc_ntpaths_get(RNDC_KEY_PATH); named_g_defaultsessionkeyfile = isc_ntpaths_get(SESSION_KEY_PATH); + named_g_defaultbindkeys = isc_ntpaths_get(BIND_KEYS_PATH); named_g_defaultdnstap = NULL; Initialized = TRUE; diff --git a/external/mpl/bind/dist/bin/nsupdate/nsupdate.1 b/external/mpl/bind/dist/bin/nsupdate/nsupdate.1 index 11d6432cdaa..b56013fa79d 100644 --- a/external/mpl/bind/dist/bin/nsupdate/nsupdate.1 +++ b/external/mpl/bind/dist/bin/nsupdate/nsupdate.1 @@ -1,6 +1,6 @@ -.\" $NetBSD: nsupdate.1,v 1.3 2019/01/09 16:55:00 christos Exp $ +.\" $NetBSD: nsupdate.1,v 1.4 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2000-2012, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2000-2012, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -521,5 +521,5 @@ The TSIG key is redundantly stored in two separate files\&. This is a consequenc \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2000-2012, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2000-2012, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/pkcs11/pkcs11-destroy.8 b/external/mpl/bind/dist/bin/pkcs11/pkcs11-destroy.8 index fcff5dc757d..7be8eb2a48d 100644 --- a/external/mpl/bind/dist/bin/pkcs11/pkcs11-destroy.8 +++ b/external/mpl/bind/dist/bin/pkcs11/pkcs11-destroy.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: pkcs11-destroy.8,v 1.2 2018/08/12 13:02:28 christos Exp $ +.\" $NetBSD: pkcs11-destroy.8,v 1.3 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2009, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2009, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -95,5 +95,5 @@ Specify how long to pause before carrying out key destruction\&. The default is \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2009, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2009, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/pkcs11/pkcs11-keygen.8 b/external/mpl/bind/dist/bin/pkcs11/pkcs11-keygen.8 index dce94580df8..c779c8a3c56 100644 --- a/external/mpl/bind/dist/bin/pkcs11/pkcs11-keygen.8 +++ b/external/mpl/bind/dist/bin/pkcs11/pkcs11-keygen.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: pkcs11-keygen.8,v 1.2 2018/08/12 13:02:28 christos Exp $ +.\" $NetBSD: pkcs11-keygen.8,v 1.3 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2009, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2009, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -118,5 +118,5 @@ Open the session with the given PKCS#11 slot\&. The default is slot 0\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2009, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2009, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/pkcs11/pkcs11-list.8 b/external/mpl/bind/dist/bin/pkcs11/pkcs11-list.8 index 8fea866f3c3..40a53917ee6 100644 --- a/external/mpl/bind/dist/bin/pkcs11/pkcs11-list.8 +++ b/external/mpl/bind/dist/bin/pkcs11/pkcs11-list.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: pkcs11-list.8,v 1.2 2018/08/12 13:02:28 christos Exp $ +.\" $NetBSD: pkcs11-list.8,v 1.3 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2009, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2009, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -96,5 +96,5 @@ will prompt for it\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2009, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2009, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/pkcs11/pkcs11-tokens.8 b/external/mpl/bind/dist/bin/pkcs11/pkcs11-tokens.8 index acb939caa2c..bce9d4a06f0 100644 --- a/external/mpl/bind/dist/bin/pkcs11/pkcs11-tokens.8 +++ b/external/mpl/bind/dist/bin/pkcs11/pkcs11-tokens.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: pkcs11-tokens.8,v 1.2 2018/08/12 13:02:28 christos Exp $ +.\" $NetBSD: pkcs11-tokens.8,v 1.3 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -67,5 +67,5 @@ Make the PKCS#11 libisc initialization verbose\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/plugins/filter-aaaa.8 b/external/mpl/bind/dist/bin/plugins/filter-aaaa.8 index 4483e0cee9f..1e84788fbea 100644 --- a/external/mpl/bind/dist/bin/plugins/filter-aaaa.8 +++ b/external/mpl/bind/dist/bin/plugins/filter-aaaa.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: filter-aaaa.8,v 1.2 2019/01/09 16:55:00 christos Exp $ +.\" $NetBSD: filter-aaaa.8,v 1.3 2019/02/24 20:01:27 christos Exp $ .\" -.\" Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -114,5 +114,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/plugins/filter-aaaa.c b/external/mpl/bind/dist/bin/plugins/filter-aaaa.c index afb0cac4593..10ecf09956f 100644 --- a/external/mpl/bind/dist/bin/plugins/filter-aaaa.c +++ b/external/mpl/bind/dist/bin/plugins/filter-aaaa.c @@ -1,4 +1,4 @@ -/* $NetBSD: filter-aaaa.c,v 1.2 2019/01/09 16:55:00 christos Exp $ */ +/* $NetBSD: filter-aaaa.c,v 1.3 2019/02/24 20:01:27 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -309,8 +309,8 @@ parse_parameters(filter_instance_t *inst, const char *parameters, isc_buffer_constinit(&b, parameters, strlen(parameters)); isc_buffer_add(&b, strlen(parameters)); - CHECK(cfg_parse_buffer4(parser, &b, cfg_file, cfg_line, - &cfg_type_parameters, 0, ¶m_obj)); + CHECK(cfg_parse_buffer(parser, &b, cfg_file, cfg_line, + &cfg_type_parameters, 0, ¶m_obj)); CHECK(check_syntax(param_obj, cfg, mctx, lctx, actx)); @@ -422,8 +422,8 @@ plugin_check(const char *parameters, isc_buffer_constinit(&b, parameters, strlen(parameters)); isc_buffer_add(&b, strlen(parameters)); - CHECK(cfg_parse_buffer4(parser, &b, cfg_file, cfg_line, - &cfg_type_parameters, 0, ¶m_obj)); + CHECK(cfg_parse_buffer(parser, &b, cfg_file, cfg_line, + &cfg_type_parameters, 0, ¶m_obj)); CHECK(check_syntax(param_obj, cfg, mctx, lctx, actx)); @@ -594,8 +594,9 @@ process_name(query_ctx_t *qctx, filter_aaaa_t mode, const dns_name_t *name, CHECK(dns_message_findtype(name, dns_rdatatype_a, 0, NULL)); } - dns_message_findtype(name, type, 0, &rdataset); - dns_message_findtype(name, dns_rdatatype_rrsig, type, &sigrdataset); + (void)dns_message_findtype(name, type, 0, &rdataset); + (void)dns_message_findtype(name, dns_rdatatype_rrsig, type, + &sigrdataset); if (rdataset != NULL && (sigrdataset == NULL || !WANTDNSSEC(qctx->client) || diff --git a/external/mpl/bind/dist/bin/python/dnssec-checkds.8 b/external/mpl/bind/dist/bin/python/dnssec-checkds.8 index fb4b8c4cb9d..589fb0749e1 100644 --- a/external/mpl/bind/dist/bin/python/dnssec-checkds.8 +++ b/external/mpl/bind/dist/bin/python/dnssec-checkds.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-checkds.8,v 1.2 2018/08/12 13:02:28 christos Exp $ +.\" $NetBSD: dnssec-checkds.8,v 1.3 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -89,5 +89,5 @@ binary\&. Used for testing\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2012-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2012-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/python/dnssec-coverage.8 b/external/mpl/bind/dist/bin/python/dnssec-coverage.8 index 266c1c6b86e..feb42cae2c7 100644 --- a/external/mpl/bind/dist/bin/python/dnssec-coverage.8 +++ b/external/mpl/bind/dist/bin/python/dnssec-coverage.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-coverage.8,v 1.2 2018/08/12 13:02:28 christos Exp $ +.\" $NetBSD: dnssec-coverage.8,v 1.3 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2013-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2013-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -154,5 +154,5 @@ binary\&. Used for testing\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2013-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2013-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/python/dnssec-keymgr.8 b/external/mpl/bind/dist/bin/python/dnssec-keymgr.8 index 327376203c6..80cdd4f34c1 100644 --- a/external/mpl/bind/dist/bin/python/dnssec-keymgr.8 +++ b/external/mpl/bind/dist/bin/python/dnssec-keymgr.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnssec-keymgr.8,v 1.3 2019/01/09 16:55:00 christos Exp $ +.\" $NetBSD: dnssec-keymgr.8,v 1.4 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2016-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2016-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -51,7 +51,7 @@ and \fBdnssec\-settime\fR\&. .PP DNSSEC policy can be read from a configuration file (default -/etc/dnssec\-policy\&.conf), from which the key parameters, publication and rollover schedule, and desired coverage duration for any given zone can be determined\&. This file may be used to define individual DNSSEC policies on a per\-zone basis, or to set a default policy used for all zones\&. +/etc/dnssec\-policy\&.conf), from which the key parameters, publication and rollover schedule, and desired coverage duration for any given zone can be determined\&. This file may be used to define individual DNSSEC policies on a per\-zone basis, or to set a "default" policy used for all zones\&. .PP When \fBdnssec\-keymgr\fR @@ -71,6 +71,10 @@ will search the key directory (either the current working directory or the direc \fB\-K\fR option), and check the keys for all the zones represented in the directory\&. .PP +Key times that are in the past will not be updated unless the +\fB\-f\fR +is used (see below)\&. Key inactivation and deletion times that are less than five minutes in the future will be delayed by five minutes\&. +.PP It is expected that this tool will be run automatically and unattended (for example, by \fBcron\fR)\&. .SH "OPTIONS" @@ -179,7 +183,8 @@ would be used for zones that had unusually high security needs\&. .sp -1 .IP \(bu 2.3 .\} -Algorithm policies: (\fBalgorithm\-policy \fR\fB\fIalgorithm\fR\fR\fB { \&.\&.\&. };\fR +\fIAlgorithm policies:\fR +(\fBalgorithm\-policy \fR\fB\fIalgorithm\fR\fR\fB { \&.\&.\&. };\fR ) override default per\-algorithm settings\&. For example, by default, RSASHA256 keys use 2048\-bit key sizes for both KSK and ZSK\&. This can be modified using \fBalgorithm\-policy\fR, and the new key sizes would then be used for any key of type RSASHA256\&. .RE @@ -192,59 +197,60 @@ Algorithm policies: (\fBalgorithm\-policy \fR\fB\fIalgorithm\fR\fR\fB { \&.\&.\& .sp -1 .IP \(bu 2.3 .\} -Zone policies: (\fBzone \fR\fB\fIname\fR\fR\fB { \&.\&.\&. };\fR +\fIZone policies:\fR +(\fBzone \fR\fB\fIname\fR\fR\fB { \&.\&.\&. };\fR ) set policy for a single zone by name\&. A zone policy can inherit a policy class by including a \fBpolicy\fR -option\&. Zone names beginning with digits (i\&.e\&., 0\-9) must be quoted\&. +option\&. Zone names beginning with digits (i\&.e\&., 0\-9) must be quoted\&. If a zone does not have its own policy then the "default" policy applies\&. .RE .PP Options that can be specified in policies: .PP -\fBalgorithm\fR +\fBalgorithm\fR \fIname\fR; .RS 4 The key algorithm\&. If no policy is defined, the default is RSASHA256\&. .RE .PP -\fBcoverage\fR +\fBcoverage\fR \fIduration\fR; .RS 4 The length of time to ensure that keys will be correct; no action will be taken to create new keys to be activated after this time\&. This can be represented as a number of seconds, or as a duration using human\-readable units (examples: "1y" or "6 months")\&. A default value for this option can be set in algorithm policies as well as in policy classes or zone policies\&. If no policy is configured, the default is six months\&. .RE .PP -\fBdirectory\fR +\fBdirectory\fR \fIpath\fR; .RS 4 Specifies the directory in which keys should be stored\&. .RE .PP -\fBkey\-size\fR +\fBkey\-size\fR \fIkeytype\fR \fIsize\fR; .RS 4 -Specifies the number of bits to use in creating keys\&. Takes two arguments: keytype (eihter "zsk" or "ksk") and size\&. A default value for this option can be set in algorithm policies as well as in policy classes or zone policies\&. If no policy is configured, the default is 2048 bits for RSA keys\&. +Specifies the number of bits to use in creating keys\&. The keytype is either "zsk" or "ksk"\&. A default value for this option can be set in algorithm policies as well as in policy classes or zone policies\&. If no policy is configured, the default is 2048 bits for RSA keys\&. .RE .PP -\fBkeyttl\fR +\fBkeyttl\fR \fIduration\fR; .RS 4 The key TTL\&. If no policy is defined, the default is one hour\&. .RE .PP -\fBpost\-publish\fR +\fBpost\-publish\fR \fIkeytype\fR \fIduration\fR; .RS 4 How long after inactivation a key should be deleted from the zone\&. Note: If \fBroll\-period\fR -is not set, this value is ignored\&. Takes two arguments: keytype (eihter "zsk" or "ksk") and a duration\&. A default value for this option can be set in algorithm policies as well as in policy classes or zone policies\&. The default is one month\&. +is not set, this value is ignored\&. The keytype is either "zsk" or "ksk"\&. A default duration for this option can be set in algorithm policies as well as in policy classes or zone policies\&. The default is one month\&. .RE .PP -\fBpre\-publish\fR +\fBpre\-publish\fR \fIkeytype\fR \fIduration\fR; .RS 4 How long before activation a key should be published\&. Note: If \fBroll\-period\fR -is not set, this value is ignored\&. Takes two arguments: keytype (either "zsk" or "ksk") and a duration\&. A default value for this option can be set in algorithm policies as well as in policy classes or zone policies\&. The default is one month\&. +is not set, this value is ignored\&. The keytype is either "zsk" or "ksk"\&. A default duration for this option can be set in algorithm policies as well as in policy classes or zone policies\&. The default is one month\&. .RE .PP -\fBroll\-period\fR +\fBroll\-period\fR \fIkeytype\fR \fIduration\fR; .RS 4 -How frequently keys should be rolled over\&. Takes two arguments: keytype (eihter "zsk" or "ksk") and a duration\&. A default value for this option can be set in algorithm policies as well as in policy classes or zone policies\&. If no policy is configured, the default is one year for ZSK\*(Aqs\&. KSK\*(Aqs do not roll over by default\&. +How frequently keys should be rolled over\&. The keytype is either "zsk" or "ksk"\&. A default duration for this option can be set in algorithm policies as well as in policy classes or zone policies\&. If no policy is configured, the default is one year for ZSKs\&. KSKs do not roll over by default\&. .RE .PP -\fBstandby\fR +\fBstandby\fR \fIkeytype\fR \fInumber\fR; .RS 4 Not yet implemented\&. .RE @@ -290,5 +296,5 @@ Allow configuration of standby keys and use of the REVOKE bit, for keys that use \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2016-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2016-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/rndc/rndc.8 b/external/mpl/bind/dist/bin/rndc/rndc.8 index 2de8bd00ad7..ef6a62c0152 100644 --- a/external/mpl/bind/dist/bin/rndc/rndc.8 +++ b/external/mpl/bind/dist/bin/rndc/rndc.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: rndc.8,v 1.3 2019/01/09 16:55:00 christos Exp $ +.\" $NetBSD: rndc.8,v 1.4 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2000, 2001, 2004, 2005, 2007, 2013-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2000, 2001, 2004, 2005, 2007, 2013-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -752,5 +752,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2000, 2001, 2004, 2005, 2007, 2013-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2000, 2001, 2004, 2005, 2007, 2013-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/rndc/rndc.conf.5 b/external/mpl/bind/dist/bin/rndc/rndc.conf.5 index ea9f8fbb54a..4c0c887a572 100644 --- a/external/mpl/bind/dist/bin/rndc/rndc.conf.5 +++ b/external/mpl/bind/dist/bin/rndc/rndc.conf.5 @@ -1,6 +1,6 @@ -.\" $NetBSD: rndc.conf.5,v 1.2 2018/08/12 13:02:28 christos Exp $ +.\" $NetBSD: rndc.conf.5,v 1.3 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2000, 2001, 2004, 2005, 2007, 2013-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2000, 2001, 2004, 2005, 2007, 2013-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -232,5 +232,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2000, 2001, 2004, 2005, 2007, 2013-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2000, 2001, 2004, 2005, 2007, 2013-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/tests/optional/dst_test.c b/external/mpl/bind/dist/bin/tests/optional/dst_test.c deleted file mode 100644 index 04ecb674eca..00000000000 --- a/external/mpl/bind/dist/bin/tests/optional/dst_test.c +++ /dev/null @@ -1,282 +0,0 @@ -/* $NetBSD: dst_test.c,v 1.3 2019/01/09 16:55:00 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#include <config.h> - -#include <stdbool.h> -#include <stdlib.h> -#include <unistd.h> - -#include <isc/buffer.h> -#include <isc/mem.h> -#include <isc/print.h> -#include <isc/region.h> -#include <isc/string.h> /* Required for HP/UX (and others?) */ - -#include <dns/fixedname.h> -#include <dns/log.h> -#include <dns/name.h> -#include <dns/result.h> - -#include <dst/dst.h> -#include <dst/result.h> - -char *current; -const char *tmp = "/tmp"; - -static void -use(dst_key_t *key, isc_mem_t *mctx) { - isc_result_t ret; - const char *data = "This is some data"; - unsigned char sig[512]; - isc_buffer_t databuf, sigbuf; - isc_region_t datareg, sigreg; - dst_context_t *ctx = NULL; - - isc_buffer_init(&sigbuf, sig, sizeof(sig)); - /* - * Advance 1 byte for fun. - */ - isc_buffer_add(&sigbuf, 1); - - isc_buffer_constinit(&databuf, data, strlen(data)); - isc_buffer_add(&databuf, strlen(data)); - isc_buffer_usedregion(&databuf, &datareg); - - ret = dst_context_create(key, mctx, - DNS_LOGCATEGORY_GENERAL, true, 0, &ctx); - if (ret != ISC_R_SUCCESS) { - printf("contextcreate(%u) returned: %s\n", dst_key_alg(key), - isc_result_totext(ret)); - return; - } - ret = dst_context_adddata(ctx, &datareg); - if (ret != ISC_R_SUCCESS) { - printf("adddata(%u) returned: %s\n", dst_key_alg(key), - isc_result_totext(ret)); - dst_context_destroy(&ctx); - return; - } - ret = dst_context_sign(ctx, &sigbuf); - printf("sign(%u) returned: %s\n", dst_key_alg(key), - isc_result_totext(ret)); - dst_context_destroy(&ctx); - - isc_buffer_forward(&sigbuf, 1); - isc_buffer_remainingregion(&sigbuf, &sigreg); - ret = dst_context_create(key, mctx, - DNS_LOGCATEGORY_GENERAL, false, 0, &ctx); - if (ret != ISC_R_SUCCESS) { - printf("contextcreate(%u) returned: %s\n", dst_key_alg(key), - isc_result_totext(ret)); - return; - } - ret = dst_context_adddata(ctx, &datareg); - if (ret != ISC_R_SUCCESS) { - printf("adddata(%u) returned: %s\n", dst_key_alg(key), - isc_result_totext(ret)); - dst_context_destroy(&ctx); - return; - } - ret = dst_context_verify(ctx, &sigreg); - printf("verify(%u) returned: %s\n", dst_key_alg(key), - isc_result_totext(ret)); - dst_context_destroy(&ctx); -} - -static void -dns(dst_key_t *key, isc_mem_t *mctx) { - unsigned char buffer1[2048]; - unsigned char buffer2[2048]; - isc_buffer_t buf1, buf2; - isc_region_t r1, r2; - dst_key_t *newkey = NULL; - isc_result_t ret; - bool match; - - isc_buffer_init(&buf1, buffer1, sizeof(buffer1)); - ret = dst_key_todns(key, &buf1); - printf("todns(%u) returned: %s\n", dst_key_alg(key), - isc_result_totext(ret)); - if (ret != ISC_R_SUCCESS) - return; - ret = dst_key_fromdns(dst_key_name(key), dns_rdataclass_in, - &buf1, mctx, &newkey); - printf("fromdns(%u) returned: %s\n", dst_key_alg(key), - isc_result_totext(ret)); - if (ret != ISC_R_SUCCESS) - return; - isc_buffer_init(&buf2, buffer2, sizeof(buffer2)); - ret = dst_key_todns(newkey, &buf2); - printf("todns2(%u) returned: %s\n", dst_key_alg(key), - isc_result_totext(ret)); - if (ret != ISC_R_SUCCESS) - return; - isc_buffer_usedregion(&buf1, &r1); - isc_buffer_usedregion(&buf2, &r2); - match = (r1.length == r2.length && - memcmp(r1.base, r2.base, r1.length) == 0); - printf("compare(%u): %s\n", dst_key_alg(key), - match ? "true" : "false"); - dst_key_free(&newkey); -} - -static void -io(dns_name_t *name, int id, int alg, int type, isc_mem_t *mctx) { - dst_key_t *key = NULL; - isc_result_t ret; - - ret = dst_key_fromfile(name, id, alg, type, current, mctx, &key); - printf("read(%d) returned: %s\n", alg, isc_result_totext(ret)); - if (ret != 0) - return; - ret = dst_key_tofile(key, type, tmp); - printf("write(%d) returned: %s\n", alg, isc_result_totext(ret)); - if (ret != 0) - return; - use(key, mctx); - dns(key, mctx); - dst_key_free(&key); -} - -static void -dh(dns_name_t *name1, int id1, dns_name_t *name2, int id2, isc_mem_t *mctx) { - dst_key_t *key1 = NULL, *key2 = NULL; - isc_result_t ret; - isc_buffer_t b1, b2; - isc_region_t r1, r2; - unsigned char array1[1024], array2[1024]; - int alg = DST_ALG_DH; - int type = DST_TYPE_PUBLIC|DST_TYPE_PRIVATE|DST_TYPE_KEY; - - ret = dst_key_fromfile(name1, id1, alg, type, current, mctx, &key1); - printf("read(%d) returned: %s\n", alg, isc_result_totext(ret)); - if (ret != 0) - return; - ret = dst_key_fromfile(name2, id2, alg, type, current, mctx, &key2); - printf("read(%d) returned: %s\n", alg, isc_result_totext(ret)); - if (ret != 0) - return; - - ret = dst_key_tofile(key1, type, tmp); - printf("write(%d) returned: %s\n", alg, isc_result_totext(ret)); - if (ret != 0) - return; - ret = dst_key_tofile(key2, type, tmp); - printf("write(%d) returned: %s\n", alg, isc_result_totext(ret)); - if (ret != 0) - return; - - isc_buffer_init(&b1, array1, sizeof(array1)); - ret = dst_key_computesecret(key1, key2, &b1); - printf("computesecret() returned: %s\n", isc_result_totext(ret)); - if (ret != 0) - return; - - isc_buffer_init(&b2, array2, sizeof(array2)); - ret = dst_key_computesecret(key2, key1, &b2); - printf("computesecret() returned: %s\n", isc_result_totext(ret)); - if (ret != 0) - return; - - isc_buffer_usedregion(&b1, &r1); - isc_buffer_usedregion(&b2, &r2); - - if (r1.length != r2.length || memcmp(r1.base, r2.base, r1.length) != 0) - { - int i; - printf("secrets don't match\n"); - printf("secret 1: %u bytes\n", r1.length); - for (i = 0; i < (int) r1.length; i++) - printf("%02x ", r1.base[i]); - printf("\n"); - printf("secret 2: %u bytes\n", r2.length); - for (i = 0; i < (int) r2.length; i++) - printf("%02x ", r2.base[i]); - printf("\n"); - } - dst_key_free(&key1); - dst_key_free(&key2); -} - -static void -generate(int alg, isc_mem_t *mctx) { - isc_result_t ret; - dst_key_t *key = NULL; - - ret = dst_key_generate(dns_rootname, alg, 512, 0, 0, 0, - dns_rdataclass_in, mctx, &key, NULL); - printf("generate(%d) returned: %s\n", alg, isc_result_totext(ret)); - if (ret != ISC_R_SUCCESS) - return; - - if (alg != DST_ALG_DH) - use(key, mctx); - - dst_key_free(&key); -} - -int -main(void) { - isc_mem_t *mctx = NULL; - isc_buffer_t b; - dns_fixedname_t fname; - dns_name_t *name; - isc_result_t result; - - result = isc_mem_create(0, 0, &mctx); - if (result != ISC_R_SUCCESS) - return (1); - - current = isc_mem_get(mctx, 256); - if (current == NULL) - return (1); - if (getcwd(current, 256) == NULL) { - perror("getcwd"); - return (1); - } - - dns_result_register(); - - dst_lib_init(mctx, NULL); - - name = dns_fixedname_initname(&fname); - isc_buffer_constinit(&b, "test.", 5); - isc_buffer_add(&b, 5); - result = dns_name_fromtext(name, &b, NULL, 0, NULL); - if (result != ISC_R_SUCCESS) - return (1); - io(name, 54622, DST_ALG_RSAMD5, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, - mctx); - - io(name, 2, DST_ALG_RSAMD5, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx); - - isc_buffer_constinit(&b, "dh.", 3); - isc_buffer_add(&b, 3); - result = dns_name_fromtext(name, &b, NULL, 0, NULL); - if (result != ISC_R_SUCCESS) - return (1); - dh(name, 18602, name, 48957, mctx); - - generate(DST_ALG_RSAMD5, mctx); - generate(DST_ALG_DH, mctx); - generate(DST_ALG_HMACMD5, mctx); - - dst_lib_destroy(); - - isc_mem_put(mctx, current, 256); -/* isc_mem_stats(mctx, stdout);*/ - isc_mem_destroy(&mctx); - - return (0); -} diff --git a/external/mpl/bind/dist/bin/tests/system/digdelv/ns2/example.db b/external/mpl/bind/dist/bin/tests/system/digdelv/ns2/example.db deleted file mode 100644 index f4e30f51e51..00000000000 --- a/external/mpl/bind/dist/bin/tests/system/digdelv/ns2/example.db +++ /dev/null @@ -1,57 +0,0 @@ -; Copyright (C) Internet Systems Consortium, Inc. ("ISC") -; -; This Source Code Form is subject to the terms of the Mozilla Public -; License, v. 2.0. If a copy of the MPL was not distributed with this -; file, You can obtain one at http://mozilla.org/MPL/2.0/. -; -; See the COPYRIGHT file distributed with this work for additional -; information regarding copyright ownership. - -$TTL 300 ; 5 minutes -@ IN SOA mname1. . ( - 2000042407 ; serial - 20 ; refresh (20 seconds) - 20 ; retry (20 seconds) - 1814400 ; expire (3 weeks) - 3600 ; minimum (1 hour) - ) - NS ns2 - NS ns3 -ns2 A 10.53.0.2 -ns2 AAAA fd92:7065:b8e:ffff::2 -ns3 A 10.53.0.3 -ns3 AAAA fd92:7065:b8e:ffff::3 - -a A 10.0.0.1 -a AAAA fd92:7065:b8e:ffff::1 -b A 10.0.0.2 -b AAAA fd92:7065:b8e:ffff::2 -c A 10.0.0.3 -c AAAA fd92:7065:b8e:ffff::3 - -xn--caf-dma A 10.1.2.3 - -foo TXT "testing" -foo A 10.0.1.0 -foo SSHFP 2 1 123456789abcdef67890123456789abcdef67890 - -;; -;; we are not testing DNSSEC behavior, so we don't care about the semantics -;; of the following records. -dnskey 300 DNSKEY 256 3 1 ( - AQPTpWyReB/e9Ii6mVGnakS8hX2zkh/iUYAg - +Ge4noWROpTWOIBvm76zeJPWs4Zfqa1IsswD - Ix5Mqeg0zwclz59uecKsKyx5w9IhtZ8plc4R - b9VIE5x7KNHAYTvTO5d4S8M= - ) - -; TTL of 3 weeks -weeks 1814400 A 10.53.0.2 -; TTL of 3 days -days 259200 A 10.53.0.2 -; TTL of 3 hours -hours 10800 A 10.53.0.2 -;TTL of 45 minutes -minutes 2700 A 10.53.0.2 -;TTL of 45 seconds -seconds 45 A 10.53.0.2 diff --git a/external/mpl/bind/dist/bin/tests/system/dlzexternal/driver.c b/external/mpl/bind/dist/bin/tests/system/dlzexternal/driver.c index 54d66d26f8c..105ed271993 100644 --- a/external/mpl/bind/dist/bin/tests/system/dlzexternal/driver.c +++ b/external/mpl/bind/dist/bin/tests/system/dlzexternal/driver.c @@ -1,4 +1,4 @@ -/* $NetBSD: driver.c,v 1.3 2019/01/09 16:55:02 christos Exp $ */ +/* $NetBSD: driver.c,v 1.4 2019/02/24 20:01:28 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -538,10 +538,22 @@ dlz_lookup(const char *zone, const char *name, void *dbdata, */ isc_result_t dlz_allowzonexfr(void *dbdata, const char *name, const char *client) { - UNUSED(client); + isc_result_t result; + + result = dlz_findzonedb(dbdata, name, NULL, NULL); + if (result != ISC_R_SUCCESS) { + return (result); + } - /* Just say yes for all our zones */ - return (dlz_findzonedb(dbdata, name, NULL, NULL)); + /* + * Exception for 10.53.0.5 so we can test that allow-transfer + * is effective. + */ + if (strcmp(client, "10.53.0.5") == 0) { + return (ISC_R_NOPERM); + } + + return (ISC_R_SUCCESS); } /* diff --git a/external/mpl/bind/dist/bin/tests/system/dnssec/ns5/trusted.conf.bad b/external/mpl/bind/dist/bin/tests/system/dnssec/ns5/trusted.conf.bad deleted file mode 100644 index ed30460bda4..00000000000 --- a/external/mpl/bind/dist/bin/tests/system/dnssec/ns5/trusted.conf.bad +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -trusted-keys { - "." 256 3 1 "AQO6Cl+slAf+iuieDim9L3kujFHQD7s/IOj03ClMOpKYcTXtK4mRpuULVfvWxDi9Ew/gj0xLnnX7z9OJHIxLI+DSrAHd8Dm0XfBEAtVtJSn70GaPZgnLMw1rk5ap2DsEoWk="; -}; diff --git a/external/mpl/bind/dist/bin/tests/system/feature-test.c b/external/mpl/bind/dist/bin/tests/system/feature-test.c index 0118dac4326..11be1488198 100644 --- a/external/mpl/bind/dist/bin/tests/system/feature-test.c +++ b/external/mpl/bind/dist/bin/tests/system/feature-test.c @@ -1,4 +1,4 @@ -/* $NetBSD: feature-test.c,v 1.3 2019/01/09 16:55:01 christos Exp $ */ +/* $NetBSD: feature-test.c,v 1.4 2019/02/24 20:01:28 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -47,8 +47,6 @@ usage() { fprintf(stderr, " --have-geoip\n"); fprintf(stderr, " --have-libxml2\n"); fprintf(stderr, " --ipv6only=no\n"); - fprintf(stderr, " --rpz-nsdname\n"); - fprintf(stderr, " --rpz-nsip\n"); fprintf(stderr, " --with-idn\n"); fprintf(stderr, " --with-lmdb\n"); } @@ -138,22 +136,6 @@ main(int argc, char **argv) { #endif } - if (strcmp(argv[1], "--rpz-nsip") == 0) { -#ifdef ENABLE_RPZ_NSIP - return (0); -#else - return (1); -#endif - } - - if (strcmp(argv[1], "--rpz-nsdname") == 0) { -#ifdef ENABLE_RPZ_NSDNAME - return (0); -#else - return (1); -#endif - } - if (strcmp(argv[1], "--with-idn") == 0) { #ifdef HAVE_LIBIDN2 return (0); diff --git a/external/mpl/bind/dist/bin/tests/system/inline/ns2/nsec3-loop.db b/external/mpl/bind/dist/bin/tests/system/inline/ns2/nsec3-loop.db deleted file mode 100644 index ba0db9d3e9e..00000000000 --- a/external/mpl/bind/dist/bin/tests/system/inline/ns2/nsec3-loop.db +++ /dev/null @@ -1,23 +0,0 @@ -; Copyright (C) Internet Systems Consortium, Inc. ("ISC") -; -; This Source Code Form is subject to the terms of the Mozilla Public -; License, v. 2.0. If a copy of the MPL was not distributed with this -; file, You can obtain one at http://mozilla.org/MPL/2.0/. -; -; See the COPYRIGHT file distributed with this work for additional -; information regarding copyright ownership. - -; NOTE: This zone's data has been crafted in order to reproduce a very specific -; scenario (see ns7/named.conf for more details). Please do not modify this -; file. - -$TTL 300 ; 5 minutes -@ IN SOA ns2 . ( - 1 ; serial - 20 ; refresh (20 seconds) - 20 ; retry (20 seconds) - 1814400 ; expire (3 weeks) - 3600 ; minimum (1 hour) - ) - NS ns2 -ns2 A 10.53.0.2 diff --git a/external/mpl/bind/dist/bin/tests/system/sfcache/ns5/trusted.conf.bad b/external/mpl/bind/dist/bin/tests/system/sfcache/ns5/trusted.conf.bad deleted file mode 100644 index ed30460bda4..00000000000 --- a/external/mpl/bind/dist/bin/tests/system/sfcache/ns5/trusted.conf.bad +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -trusted-keys { - "." 256 3 1 "AQO6Cl+slAf+iuieDim9L3kujFHQD7s/IOj03ClMOpKYcTXtK4mRpuULVfvWxDi9Ew/gj0xLnnX7z9OJHIxLI+DSrAHd8Dm0XfBEAtVtJSn70GaPZgnLMw1rk5ap2DsEoWk="; -}; diff --git a/external/mpl/bind/dist/bin/tests/system/sfcache/prereq.sh b/external/mpl/bind/dist/bin/tests/system/sfcache/prereq.sh deleted file mode 100644 index 0b7e20cc386..00000000000 --- a/external/mpl/bind/dist/bin/tests/system/sfcache/prereq.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# See the COPYRIGHT file distributed with this work for additional -# information regarding copyright ownership. - -SYSTEMTESTTOP=.. -. $SYSTEMTESTTOP/conf.sh - -if $KEYGEN -q -a RSAMD5 -b 1024 -n zone foo > /dev/null 2>&1 -then - rm -f Kfoo* -else - echo "I:This test requires that --with-openssl was used." >&2 - exit 255 -fi diff --git a/external/mpl/bind/dist/bin/tools/arpaname.1 b/external/mpl/bind/dist/bin/tools/arpaname.1 index 38c82ce5931..4a417453ef1 100644 --- a/external/mpl/bind/dist/bin/tools/arpaname.1 +++ b/external/mpl/bind/dist/bin/tools/arpaname.1 @@ -1,6 +1,6 @@ -.\" $NetBSD: arpaname.1,v 1.2 2018/08/12 13:02:30 christos Exp $ +.\" $NetBSD: arpaname.1,v 1.3 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2009, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2009, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -54,5 +54,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2009, 2014-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2009, 2014-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/tools/dnstap-read.1 b/external/mpl/bind/dist/bin/tools/dnstap-read.1 index 83bfc14ba03..eec33412807 100644 --- a/external/mpl/bind/dist/bin/tools/dnstap-read.1 +++ b/external/mpl/bind/dist/bin/tools/dnstap-read.1 @@ -1,6 +1,6 @@ -.\" $NetBSD: dnstap-read.1,v 1.2 2018/08/12 13:02:30 christos Exp $ +.\" $NetBSD: dnstap-read.1,v 1.3 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -93,5 +93,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2015-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2015-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/tools/mdig.1 b/external/mpl/bind/dist/bin/tools/mdig.1 index 9e8323bc118..8a6f8a29e11 100644 --- a/external/mpl/bind/dist/bin/tools/mdig.1 +++ b/external/mpl/bind/dist/bin/tools/mdig.1 @@ -1,6 +1,6 @@ -.\" $NetBSD: mdig.1,v 1.3 2019/01/09 16:55:05 christos Exp $ +.\" $NetBSD: mdig.1,v 1.4 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2015-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -400,5 +400,5 @@ RFC1035\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2015-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2015-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/tools/named-journalprint.8 b/external/mpl/bind/dist/bin/tools/named-journalprint.8 index df42662d99c..f22f29aadf5 100644 --- a/external/mpl/bind/dist/bin/tools/named-journalprint.8 +++ b/external/mpl/bind/dist/bin/tools/named-journalprint.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: named-journalprint.8,v 1.2 2018/08/12 13:02:30 christos Exp $ +.\" $NetBSD: named-journalprint.8,v 1.3 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2009, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2009, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -66,5 +66,5 @@ BIND 9 Administrator Reference Manual\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2009, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2009, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/tools/named-nzd2nzf.8 b/external/mpl/bind/dist/bin/tools/named-nzd2nzf.8 index 7079e191677..dbb1882e755 100644 --- a/external/mpl/bind/dist/bin/tools/named-nzd2nzf.8 +++ b/external/mpl/bind/dist/bin/tools/named-nzd2nzf.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: named-nzd2nzf.8,v 1.2 2018/08/12 13:02:30 christos Exp $ +.\" $NetBSD: named-nzd2nzf.8,v 1.3 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -65,5 +65,5 @@ BIND 9 Administrator Reference Manual Internet Systems Consortium .SH "COPYRIGHT" .br -Copyright \(co 2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/tools/named-rrchecker.1 b/external/mpl/bind/dist/bin/tools/named-rrchecker.1 index 05405c1a4e8..bdf68d1c03a 100644 --- a/external/mpl/bind/dist/bin/tools/named-rrchecker.1 +++ b/external/mpl/bind/dist/bin/tools/named-rrchecker.1 @@ -1,6 +1,6 @@ -.\" $NetBSD: named-rrchecker.1,v 1.2 2018/08/12 13:02:30 christos Exp $ +.\" $NetBSD: named-rrchecker.1,v 1.3 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2013-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2013-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -79,5 +79,5 @@ RFC 1035, \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2013-2016, 2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2013-2016, 2018, 2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/tools/nsec3hash.8 b/external/mpl/bind/dist/bin/tools/nsec3hash.8 index b1af6ed5e98..d5d5496df9a 100644 --- a/external/mpl/bind/dist/bin/tools/nsec3hash.8 +++ b/external/mpl/bind/dist/bin/tools/nsec3hash.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: nsec3hash.8,v 1.2 2018/08/12 13:02:30 christos Exp $ +.\" $NetBSD: nsec3hash.8,v 1.3 2019/02/24 20:01:28 christos Exp $ .\" -.\" Copyright (C) 2009, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2009, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -86,5 +86,5 @@ RFC 5155\&. \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2009, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2009, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/bin/win32/BINDInstall/StdAfx.h b/external/mpl/bind/dist/bin/win32/BINDInstall/StdAfx.h index 3cb28757a92..5e5ec0ec147 100644 --- a/external/mpl/bind/dist/bin/win32/BINDInstall/StdAfx.h +++ b/external/mpl/bind/dist/bin/win32/BINDInstall/StdAfx.h @@ -1,4 +1,4 @@ -/* $NetBSD: StdAfx.h,v 1.3 2019/01/09 16:55:05 christos Exp $ */ +/* $NetBSD: StdAfx.h,v 1.4 2019/02/24 20:01:29 christos Exp $ */ // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but @@ -6,10 +6,10 @@ // /* - * Minimum version is Windows Vista and Windows Server 2008 + * Minimum version is Windows 8 and Windows Server 2012 */ -#define _WIN32_WINNT 0x0600 -#define NTDDI_VERSION 0x06000100 +#define _WIN32_WINNT 0x0602 +#define NTDDI_VERSION 0x06020000 #ifndef _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE 1 diff --git a/external/mpl/bind/dist/config.h.in b/external/mpl/bind/dist/config.h.in index 81c5ce8653b..dd6598aa984 100644 --- a/external/mpl/bind/dist/config.h.in +++ b/external/mpl/bind/dist/config.h.in @@ -21,12 +21,6 @@ /* Define to enable American Fuzzy Lop test harness */ #undef ENABLE_AFL -/* Define to enable rpz nsdname rules. */ -#undef ENABLE_RPZ_NSDNAME - -/* Define to enable rpz nsip rules. */ -#undef ENABLE_RPZ_NSIP - /* define if you want TCP_FASTOPEN enabled if available */ #undef ENABLE_TCP_FASTOPEN @@ -60,21 +54,15 @@ /* define if the compiler supports __builtin_unreachable(). */ #undef HAVE_BUILTIN_UNREACHABLE -/* Define to 1 if you have the `catgets' function. */ -#undef HAVE_CATGETS - /* Define to 1 if you have the `chroot' function. */ #undef HAVE_CHROOT /* Define if clock_gettime is available. */ #undef HAVE_CLOCK_GETTIME -/* Use cmocka */ +/* Use CMocka */ #undef HAVE_CMOCKA -/* Define to 1 if you have the <cmocka.h> header file. */ -#undef HAVE_CMOCKA_H - /* Define to 1 if you have the `cpuset_setaffinity' function. */ #undef HAVE_CPUSET_SETAFFINITY diff --git a/external/mpl/bind/dist/configure b/external/mpl/bind/dist/configure index 22680bcb240..c34291ed3ed 100755 --- a/external/mpl/bind/dist/configure +++ b/external/mpl/bind/dist/configure @@ -917,8 +917,6 @@ enable_isc_spnego enable_chroot enable_linux_caps enable_fixed_rrset -enable_rpz_nsip -enable_rpz_nsdname enable_dnstap with_protobuf_c with_libfstrm @@ -1605,8 +1603,6 @@ Optional Features: --disable-chroot disable chroot --disable-linux-caps disable Linux capabilities --enable-fixed-rrset enable fixed rrset ordering [default=no] - --disable-rpz-nsip disable rpz nsip rules [default=enabled] - --disable-rpz-nsdname disable rpz nsdname rules [default=enabled] --enable-dnstap enable dnstap support (requires fstrm, protobuf-c) --enable-querytrace enable very verbose query trace logging [default=no] --enable-auto-validation @@ -1655,7 +1651,7 @@ Optional Packages: --with-docbook-xsl=PATH specify path for Docbook-XSL stylesheets --with-libidn2=PATH enable IDN support using GNU libidn2 [yes|no(default)|path] - --with-cmocka=no enable cmocka based tests (default is no) + --with-cmocka=detect enable CMocka based tests (default is detect) --with-tuning=ARG Specify server tuning (large or default) --with-dlopen=ARG support dynamically loadable DLZ and DYNDB drivers --with-dnsrps-libname DNSRPS provider library name (librpz.so) @@ -11699,7 +11695,7 @@ else /*) : if "$ac_cv_prog_shell" -c "$ac_test_shell_script" 2>/dev/null; then : - ac_cv_path_shell=$SHELL + break fi ;; #( *) : @@ -12180,12 +12176,14 @@ except: exit(1)' testply='try: import ply except: exit(1)' +default_with_python="python python3 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python2 python2.7" + # Check whether --with-python was given. if test "${with_python+set}" = set; then : withval=$with_python; else - with_python="python python3 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python2 python2.7" + with_python=$default_with_python fi @@ -12197,6 +12195,10 @@ else fi +if test "$with_python" = "yes"; then : + with_python=$default_with_python +fi + if test "$with_python" = "no"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python support" >&5 $as_echo_n "checking for Python support... " >&6; } @@ -13573,7 +13575,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - as_fn_error $? "no, try adding -march=native or -march=armv7-a to CFLAGS (see PLATFORM.md for more information)" "$LINENO" 5 + as_fn_error $? "no, try adding -march=native or -march=armv7-a to CFLAGS (see PLATFORMS.md for more information)" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; #( *) : @@ -15611,10 +15613,11 @@ $as_echo_n "checking for ECDSA P-256 support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <openssl/evp.h> + #include <openssl/ec.h> int main () { -EVP_PKEY_CTX *ctx = NID_X9_62_prime256v1; +EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); ; return 0; } @@ -15635,10 +15638,11 @@ $as_echo_n "checking for ECDSA P-384 support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <openssl/evp.h> + #include <openssl/ec.h> int main () { -EVP_PKEY_CTX *ctx = NID_secp384r1; +EC_KEY *key = EC_KEY_new_by_curve_name(NID_secp384r1); ; return 0; } @@ -15659,10 +15663,11 @@ $as_echo_n "checking for Ed25519 support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <openssl/evp.h> + #include <openssl/ec.h> int main () { -EVP_PKEY_CTX *ctx = NID_ED25519; +EC_KEY *key = EC_KEY_new_by_curve_name(NID_ED25519); ; return 0; } @@ -15684,8 +15689,9 @@ $as_echo_n "checking for Ed448 support... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: broken" >&5 $as_echo "broken" >&6; } #AC_COMPILE_IFELSE( -# [AC_LANG_PROGRAM([[#include <openssl/evp.h>]], -# [[EVP_PKEY_CTX *ctx = NID_ED448;]])], +# [AC_LANG_PROGRAM([[#include <openssl/evp.h> +# #include <openssl/ec.h>]], +# [[EC_KEY *key = EC_KEY_new_by_curve_name(NID_ED448);]])], # [AC_DEFINE([HAVE_OPENSSL_ED448], [1], [define if OpenSSL supports Ed448]) # AC_MSG_RESULT([yes])], # [AC_MSG_RESULT([no])]) @@ -17070,21 +17076,6 @@ fi # -# NLS -# -for ac_func in catgets -do : - ac_fn_c_check_func "$LINENO" "catgets" "ac_cv_func_catgets" -if test "x$ac_cv_func_catgets" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_CATGETS 1 -_ACEOF - -fi -done - - -# # -lxnet buys us one big porting headache... standards, gotta love 'em. # # AC_CHECK_LIB(xnet, socket, , @@ -18189,50 +18180,6 @@ $as_echo "#define DNS_RDATASET_FIXED 1" >>confdefs.h esac # -# Enable response policy rewriting using NS IP addresses -# -# Check whether --enable-rpz-nsip was given. -if test "${enable_rpz_nsip+set}" = set; then : - enableval=$enable_rpz_nsip; enable_nsip="$enableval" -else - enable_nsip="yes" -fi - -case "$enable_nsip" in - yes) - -$as_echo "#define ENABLE_RPZ_NSIP 1" >>confdefs.h - - ;; - no) - ;; - *) - ;; -esac - -# -# Enable response policy rewriting using NS name -# -# Check whether --enable-rpz-nsdname was given. -if test "${enable_rpz_nsdname+set}" = set; then : - enableval=$enable_rpz_nsdname; enable_nsdname="$enableval" -else - enable_nsdname="yes" -fi - -case "$enable_nsdname" in - yes) - -$as_echo "#define ENABLE_RPZ_NSDNAME 1" >>confdefs.h - - ;; - no) - ;; - *) - ;; -esac - -# # Activate dnstap? # # Check whether --enable-dnstap was given. @@ -19581,17 +19528,91 @@ esac # Check whether --with-cmocka was given. if test "${with_cmocka+set}" = set; then : - withval=$with_cmocka; : + withval=$with_cmocka; else - with_cmocka=no + with_cmocka=detect fi case $with_cmocka in #( no) : - : ;; #( - yes) : + ;; #( + detect) : + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cmocka >= 1.0.0" >&5 +$as_echo_n "checking for cmocka >= 1.0.0... " >&6; } + +if test -n "$CMOCKA_CFLAGS"; then + pkg_cv_CMOCKA_CFLAGS="$CMOCKA_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cmocka >= 1.0.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "cmocka >= 1.0.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_CMOCKA_CFLAGS=`$PKG_CONFIG --cflags "cmocka >= 1.0.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$CMOCKA_LIBS"; then + pkg_cv_CMOCKA_LIBS="$CMOCKA_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"cmocka >= 1.0.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "cmocka >= 1.0.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_CMOCKA_LIBS=`$PKG_CONFIG --libs "cmocka >= 1.0.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + CMOCKA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "cmocka >= 1.0.0" 2>&1` + else + CMOCKA_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "cmocka >= 1.0.0" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$CMOCKA_PKG_ERRORS" >&5 + + with_cmocka=no +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + with_cmocka=no +else + CMOCKA_CFLAGS=$pkg_cv_CMOCKA_CFLAGS + CMOCKA_LIBS=$pkg_cv_CMOCKA_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_CMOCKA 1" >>confdefs.h + + UNITTESTS=tests +fi ;; #( + yes) : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cmocka >= 1.0.0" >&5 @@ -19685,100 +19706,10 @@ $as_echo "yes" >&6; } $as_echo "#define HAVE_CMOCKA 1" >>confdefs.h fi - UNITTESTS=tests - ;; #( - *) : - - save_CFLAGS="$CFLAGS" - save_LIBS="$LIBS" - CFLAGS="$CFLAGS -I$with_cmocka/include" - LIBS="$LIBS -L$with_cmocka/lib" - for ac_header in cmocka.h -do : - ac_fn_c_check_header_compile "$LINENO" "cmocka.h" "ac_cv_header_cmocka_h" "#include <stdarg.h> - #include <stddef.h> - #include <setjmp.h> - -" -if test "x$ac_cv_header_cmocka_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_CMOCKA_H 1 -_ACEOF - : -else - as_fn_error $? "cmocka.h not found" "$LINENO" 5 -fi - -done - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing cmocka_set_message_output" >&5 -$as_echo_n "checking for library containing cmocka_set_message_output... " >&6; } -if ${ac_cv_search_cmocka_set_message_output+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char cmocka_set_message_output (); -int -main () -{ -return cmocka_set_message_output (); - ; - return 0; -} -_ACEOF -for ac_lib in '' cmocka; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_cmocka_set_message_output=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_cmocka_set_message_output+:} false; then : - break -fi -done -if ${ac_cv_search_cmocka_set_message_output+:} false; then : - -else - ac_cv_search_cmocka_set_message_output=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_cmocka_set_message_output" >&5 -$as_echo "$ac_cv_search_cmocka_set_message_output" >&6; } -ac_res=$ac_cv_search_cmocka_set_message_output -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - - CMOCKA_CFLAGS="-I$with_cmocka/include" - CMOCKA_LIBS="-L$with_cmocka/lib -lcmocka" - UNITTESTS=tests - -$as_echo "#define HAVE_CMOCKA 1" >>confdefs.h - - -else - as_fn_error $? "cmocka unit testing framework not found in $with_cmocka path" "$LINENO" 5 -fi - - ;; #( + UNITTESTS=tests ;; #( *) : - ;; + as_fn_error $? "Use PKG_CONFIG_PATH to specify path to CMocka library" "$LINENO" 5 + ;; esac @@ -21550,7 +21481,7 @@ ac_config_commands="$ac_config_commands chmod" # elsewhere if there's a good reason for doing so. # -ac_config_files="$ac_config_files make/Makefile make/mkdep Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/delv/Makefile bin/dig/Makefile bin/dnssec/Makefile bin/named/Makefile bin/named/unix/Makefile bin/nsupdate/Makefile bin/pkcs11/Makefile bin/plugins/Makefile bin/python/Makefile bin/python/isc/Makefile bin/python/isc/utils.py bin/python/isc/tests/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/python/dnssec-keymgr.py bin/python/isc/__init__.py bin/python/isc/checkds.py bin/python/isc/coverage.py bin/python/isc/dnskey.py bin/python/isc/eventlist.py bin/python/isc/keydict.py bin/python/isc/keyevent.py bin/python/isc/keymgr.py bin/python/isc/keyseries.py bin/python/isc/keyzone.py bin/python/isc/policy.py bin/python/isc/rndc.py bin/python/isc/tests/dnskey_test.py bin/python/isc/tests/policy_test.py bin/rndc/Makefile bin/tests/Makefile bin/tests/headerdep_test.sh bin/tests/optional/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/dlz/prereq.sh bin/tests/system/dlzexternal/Makefile bin/tests/system/dlzexternal/ns1/dlzs.conf bin/tests/system/dyndb/Makefile bin/tests/system/dyndb/driver/Makefile bin/tests/system/pipelined/Makefile bin/tests/system/rndc/Makefile bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/tkey/Makefile bin/tests/virtual-time/Makefile bin/tests/virtual-time/conf.sh bin/tools/Makefile contrib/scripts/check-secure-delegation.pl contrib/scripts/zone-edit.sh doc/Makefile doc/arm/Makefile doc/arm/noteversion.xml doc/arm/pkgversion.xml doc/arm/releaseinfo.xml doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/misc/Makefile doc/tex/Makefile doc/tex/armstyle.sty doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-manpage.xsl doc/xsl/isc-notes-html.xsl isc-config.sh lib/Makefile lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/dns/tests/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/irs/tests/Makefile lib/isc/pthreads/Makefile lib/isc/pthreads/include/Makefile lib/isc/pthreads/include/isc/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/include/pk11/Makefile lib/isc/include/pkcs11/Makefile lib/isc/tests/Makefile lib/isc/nls/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isc/unix/include/pkcs11/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccc/tests/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/isccfg/tests/Makefile lib/ns/Makefile lib/ns/include/Makefile lib/ns/include/ns/Makefile lib/ns/tests/Makefile lib/samples/Makefile lib/samples/Makefile-postinstall unit/unittest.sh fuzz/Makefile" +ac_config_files="$ac_config_files make/Makefile make/mkdep Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/delv/Makefile bin/dig/Makefile bin/dnssec/Makefile bin/named/Makefile bin/named/unix/Makefile bin/nsupdate/Makefile bin/pkcs11/Makefile bin/plugins/Makefile bin/python/Makefile bin/python/isc/Makefile bin/python/isc/utils.py bin/python/isc/tests/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/python/dnssec-keymgr.py bin/python/isc/__init__.py bin/python/isc/checkds.py bin/python/isc/coverage.py bin/python/isc/dnskey.py bin/python/isc/eventlist.py bin/python/isc/keydict.py bin/python/isc/keyevent.py bin/python/isc/keymgr.py bin/python/isc/keyseries.py bin/python/isc/keyzone.py bin/python/isc/policy.py bin/python/isc/rndc.py bin/python/isc/tests/dnskey_test.py bin/python/isc/tests/policy_test.py bin/rndc/Makefile bin/tests/Makefile bin/tests/headerdep_test.sh bin/tests/optional/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/dlz/prereq.sh bin/tests/system/dlzexternal/Makefile bin/tests/system/dlzexternal/ns1/dlzs.conf bin/tests/system/dyndb/Makefile bin/tests/system/dyndb/driver/Makefile bin/tests/system/pipelined/Makefile bin/tests/system/rndc/Makefile bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/tkey/Makefile bin/tests/virtual-time/Makefile bin/tests/virtual-time/conf.sh bin/tools/Makefile contrib/scripts/check-secure-delegation.pl contrib/scripts/zone-edit.sh doc/Makefile doc/arm/Makefile doc/arm/noteversion.xml doc/arm/pkgversion.xml doc/arm/releaseinfo.xml doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/misc/Makefile doc/tex/Makefile doc/tex/armstyle.sty doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-manpage.xsl doc/xsl/isc-notes-html.xsl isc-config.sh lib/Makefile lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/dns/tests/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/irs/tests/Makefile lib/isc/pthreads/Makefile lib/isc/pthreads/include/Makefile lib/isc/pthreads/include/isc/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/include/pk11/Makefile lib/isc/include/pkcs11/Makefile lib/isc/tests/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isc/unix/include/pkcs11/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccc/tests/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/isccfg/tests/Makefile lib/ns/Makefile lib/ns/include/Makefile lib/ns/include/ns/Makefile lib/ns/tests/Makefile lib/samples/Makefile lib/samples/Makefile-postinstall unit/unittest.sh fuzz/Makefile" # @@ -22651,7 +22582,6 @@ do "lib/isc/include/pk11/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/include/pk11/Makefile" ;; "lib/isc/include/pkcs11/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/include/pkcs11/Makefile" ;; "lib/isc/tests/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/tests/Makefile" ;; - "lib/isc/nls/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/nls/Makefile" ;; "lib/isc/unix/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/unix/Makefile" ;; "lib/isc/unix/include/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/unix/include/Makefile" ;; "lib/isc/unix/include/isc/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/unix/include/isc/Makefile" ;; @@ -23976,7 +23906,7 @@ report() { echo " Very verbose query trace logging (--enable-querytrace)" test "yes" = "$use_libtool" || echo " Use GNU libtool (--with-libtool)" - test "no" = "$with_cmocka" && echo " CMocka Unit Testng Framework (--with-cmocka)" + test "no" = "$with_cmocka" && echo " CMocka Unit Testing Framework (--with-cmocka)" test "X$PYTHON" = "X" && echo " Python tools (--with-python)" test "X$XMLSTATS" = "X" && echo " XML statistics (--with-libxml2)" diff --git a/external/mpl/bind/dist/contrib/dlz/drivers/dlz_stub_driver.c b/external/mpl/bind/dist/contrib/dlz/drivers/dlz_stub_driver.c index ae766d4e001..d8a250686be 100644 --- a/external/mpl/bind/dist/contrib/dlz/drivers/dlz_stub_driver.c +++ b/external/mpl/bind/dist/contrib/dlz/drivers/dlz_stub_driver.c @@ -1,4 +1,4 @@ -/* $NetBSD: dlz_stub_driver.c,v 1.2 2018/08/12 13:02:31 christos Exp $ */ +/* $NetBSD: dlz_stub_driver.c,v 1.3 2019/02/24 20:01:29 christos Exp $ */ /* * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl. @@ -106,11 +106,17 @@ static isc_result_t stub_dlz_allowzonexfr(void *driverarg, void *dbdata, const char *name, const char *client) { + config_data_t *cd; + UNUSED(driverarg); - UNUSED(dbdata); - UNUSED(name); UNUSED(client); - return ISC_R_SUCCESS; + + cd = (config_data_t *) dbdata; + + if (strcmp(name, cd->myname) == 0) { + return (ISC_R_SUCCESS); + } + return (ISC_R_NOTFOUND); } static isc_result_t diff --git a/external/mpl/bind/dist/contrib/dlz/drivers/include/dlz/sdlz_helper.h b/external/mpl/bind/dist/contrib/dlz/drivers/include/dlz/sdlz_helper.h index 3fb7de96d71..a95f6eb4ee5 100644 --- a/external/mpl/bind/dist/contrib/dlz/drivers/include/dlz/sdlz_helper.h +++ b/external/mpl/bind/dist/contrib/dlz/drivers/include/dlz/sdlz_helper.h @@ -1,4 +1,4 @@ -/* $NetBSD: sdlz_helper.h,v 1.3 2019/01/09 16:55:06 christos Exp $ */ +/* $NetBSD: sdlz_helper.h,v 1.4 2019/02/24 20:01:29 christos Exp $ */ /* * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl. @@ -61,7 +61,7 @@ typedef struct driverinstance driverinstance_t; struct query_segment { void *sql; unsigned int strlen; - bool direct; + bool direct; ISC_LINK(query_segment_t) link; }; diff --git a/external/mpl/bind/dist/contrib/dlz/drivers/sdlz_helper.c b/external/mpl/bind/dist/contrib/dlz/drivers/sdlz_helper.c index a104d55ae50..1c1207300e1 100644 --- a/external/mpl/bind/dist/contrib/dlz/drivers/sdlz_helper.c +++ b/external/mpl/bind/dist/contrib/dlz/drivers/sdlz_helper.c @@ -1,4 +1,4 @@ -/* $NetBSD: sdlz_helper.c,v 1.3 2019/01/09 16:55:05 christos Exp $ */ +/* $NetBSD: sdlz_helper.c,v 1.4 2019/02/24 20:01:29 christos Exp $ */ /* * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl. @@ -108,11 +108,11 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone, bool foundzone = false; bool foundrecord = false; bool foundclient = false; + char *free_me = NULL; char *temp_str = NULL; - char *right_str = NULL; query_list_t *tql; query_segment_t *tseg = NULL; - char *last; + char *last = NULL; REQUIRE(querylist != NULL && *querylist == NULL); REQUIRE(mctx != NULL); @@ -137,15 +137,24 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone, ISC_LIST_INIT(*tql); /* make a copy of query_str so we can chop it up */ - temp_str = right_str = isc_mem_strdup(mctx, query_str); + free_me = temp_str = isc_mem_strdup(mctx, query_str); /* couldn't make a copy, problem!! */ - if (right_str == NULL) { + if (temp_str == NULL) { result = ISC_R_NOMEMORY; goto cleanup; } /* loop through the string and chop it up */ - while (right_str != NULL) { + for (;;) { + /* + * Split string into tokens at '$'. + */ + const char *sql = strtok_r(temp_str, "$", &last); + if (sql == NULL) { + break; + } + temp_str = NULL; + /* allocate memory for tseg */ tseg = isc_mem_get(mctx, sizeof(query_segment_t)); if (tseg == NULL) { /* no memory, clean everything up. */ @@ -159,13 +168,7 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone, /* append the query segment to the list */ ISC_LIST_APPEND(*tql, tseg, link); - /* - * split string at the first "$". set query segment to - * left portion - */ - last = NULL; - tseg->sql = isc_mem_strdup(mctx, - strtok_r(right_str, "$", &last)); + tseg->sql = isc_mem_strdup(mctx, sql); if (tseg->sql == NULL) { /* no memory, clean everything up. */ result = ISC_R_NOMEMORY; @@ -183,7 +186,7 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone, */ isc_mem_free(mctx, tseg->sql); /* set tseg->sql to in-direct zone string */ - tseg->sql = (char**) zone; + tseg->sql = zone; tseg->strlen = 0; /* tseg->sql points in-directly to a string */ tseg->direct = false; @@ -196,9 +199,9 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone, */ isc_mem_free(mctx, tseg->sql); /* set tseg->sql to in-direct record string */ - tseg->sql = (char**) record; + tseg->sql = record; tseg->strlen = 0; - /* tseg->sql points in-directly poinsts to a string */ + /* tseg->sql points in-directly points to a string */ tseg->direct = false; foundrecord = true; /* check if we encountered "$client$" token */ @@ -209,16 +212,16 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone, */ isc_mem_free(mctx, tseg->sql); /* set tseg->sql to in-direct record string */ - tseg->sql = (char**) client; + tseg->sql = client; tseg->strlen = 0; - /* tseg->sql points in-directly poinsts to a string */ + /* tseg->sql points in-directly points to a string */ tseg->direct = false; foundclient = true; } } /* we don't need temp_str any more */ - isc_mem_free(mctx, temp_str); + isc_mem_free(mctx, free_me); /* * add checks later to verify zone and record are found if * necessary. @@ -261,9 +264,9 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone, return (ISC_R_SUCCESS); cleanup: - /* get rid of temp_str */ - if (temp_str != NULL) - isc_mem_free(mctx, temp_str); + /* get rid of free_me */ + if (free_me != NULL) + isc_mem_free(mctx, free_me); flag_fail: /* get rid of what was build of the query list */ diff --git a/external/mpl/bind/dist/contrib/dlz/modules/common/dlz_dbi.c b/external/mpl/bind/dist/contrib/dlz/modules/common/dlz_dbi.c index 58fb253f0e0..bbfadf2c676 100644 --- a/external/mpl/bind/dist/contrib/dlz/modules/common/dlz_dbi.c +++ b/external/mpl/bind/dist/contrib/dlz/modules/common/dlz_dbi.c @@ -1,4 +1,4 @@ -/* $NetBSD: dlz_dbi.c,v 1.3 2019/01/09 16:55:06 christos Exp $ */ +/* $NetBSD: dlz_dbi.c,v 1.4 2019/02/24 20:01:29 christos Exp $ */ /* * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl. @@ -103,6 +103,7 @@ build_querylist(const char *query_str, char **zone, char **record, bool foundclient = false; char *temp_str = NULL; char *right_str = NULL; + char *token = NULL; query_list_t *tql; query_segment_t *tseg = NULL; diff --git a/external/mpl/bind/dist/contrib/dlz/modules/filesystem/dir.c b/external/mpl/bind/dist/contrib/dlz/modules/filesystem/dir.c index 22236c2a871..ba8d7b917ce 100644 --- a/external/mpl/bind/dist/contrib/dlz/modules/filesystem/dir.c +++ b/external/mpl/bind/dist/contrib/dlz/modules/filesystem/dir.c @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.2 2018/08/12 13:02:31 christos Exp $ */ +/* $NetBSD: dir.c,v 1.3 2019/02/24 20:01:29 christos Exp $ */ /* * Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC") @@ -59,15 +59,20 @@ dir_open(dir_t *dir, const char *dirname) { case ENAMETOOLONG: case EBADF: result = ISC_R_INVALIDFILE; + break; case ENOENT: result = ISC_R_FILENOTFOUND; + break; case EACCES: case EPERM: result = ISC_R_NOPERM; + break; case ENOMEM: result = ISC_R_NOMEMORY; + break; default: result = ISC_R_UNEXPECTED; + break; } } diff --git a/external/mpl/bind/dist/contrib/sdb/bdb/README b/external/mpl/bind/dist/contrib/sdb/bdb/README deleted file mode 100644 index d2acf4e3687..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/bdb/README +++ /dev/null @@ -1,37 +0,0 @@ -(Message trash:37216) - -Date: Wed, 15 May 2002 20:44:45 +0100 -To: <bind-workers@isc.org> -From: Nuno Miguel Rodrigues <nmr@co.sapo.pt> -Subject: Berkeley DB BIND9 SDB - -Replied: Thu, 16 May 2002 11:47:35 +1000 -Replied: Nuno Miguel Rodrigues <nmr@co.sapo.pt> -Return-Path: <bind-workers-bounce@isc.org> -X-X-Sender: <nmr@angelina.sl.pt> -MIME-Version: 1.0 -X-ecartis-version: Ecartis v1.0.0 -Sender: bind-workers-bounce@isc.org -Errors-To: bind-workers-bounce@isc.org -X-original-sender: nmr@co.sapo.pt -Precedence: bulk -X-list: bind-workers -Status: - - - -Hello all, - -I'm making available a BIND9 SDB using Berkeley DB 4.0. - -You can get it at http://www.dhis.org/~nmr/bind9_berkeleydb_sdb-1.0.tar - -Thanks, - - --- -Nuno M. Rodrigues <nmr@co.sapo.pt> - - - - diff --git a/external/mpl/bind/dist/contrib/sdb/bdb/bdb.c b/external/mpl/bind/dist/contrib/sdb/bdb/bdb.c deleted file mode 100644 index bd03aba8199..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/bdb/bdb.c +++ /dev/null @@ -1,249 +0,0 @@ -/* $NetBSD: bdb.c,v 1.3 2019/01/09 16:55:10 christos Exp $ */ - -/* - * Copyright (C) 2002 Nuno M. Rodrigues. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND NUNO M. RODRIGUES - * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL - * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING - * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -/* - * BIND 9.1.x simple database driver - * implementation, using Berkeley DB. - */ - -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#include <isc/file.h> -#include <isc/log.h> -#include <isc/lib.h> -#include <isc/mem.h> -#include <isc/msgs.h> -#include <isc/msgcat.h> -#include <isc/region.h> -#include <isc/result.h> -#include <isc/types.h> -#include <isc/util.h> - -#include <dns/sdb.h> -#include <dns/log.h> -#include <dns/lib.h> -#include <dns/ttl.h> - -#include <named/bdb.h> -#include <named/globals.h> -#include <named/config.h> - -#include <db.h> - -#define DRIVERNAME "bdb" - -static dns_sdbimplementation_t *bdb_imp; - -static isc_result_t -bdb_create(const char *zone, int argc, char **argv, - void *unused, void **dbdata) -{ - int ret; - - UNUSED(zone); - UNUSED(unused); - - if (argc < 1) - return ISC_R_FAILURE; /* database path must be given */ - - if (db_create((DB **)dbdata, NULL, 0) != 0) { - /* - * XXX Should use dns_msgcat et al - * but seems to be unavailable. - */ - isc_log_iwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_SDB, ISC_LOG_CRITICAL, isc_msgcat, - ISC_MSGSET_GENERAL, ISC_MSG_FATALERROR, - "db_create"); - return ISC_R_FAILURE; - } - - if (isc_file_exists(*argv) != true) { - isc_log_iwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_SDB, ISC_LOG_CRITICAL, isc_msgcat, - ISC_MSGSET_GENERAL, ISC_MSG_FATALERROR, - "isc_file_exists: %s", *argv); - return ISC_R_FAILURE; - } - - if ((ret = (*(DB **)dbdata)->open(*(DB **)dbdata, *argv, NULL, DB_HASH, - DB_RDONLY, 0)) != 0) { - isc_log_iwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_SDB, ISC_LOG_CRITICAL, - isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FATALERROR, "DB->open: %s", - db_strerror(ret)); - return ISC_R_FAILURE; - } - return ISC_R_SUCCESS; -} - -static isc_result_t -#ifdef DNS_CLIENTINFO_VERSION -bdb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *l, dns_clientinfomethods_t *methods, - dns_clientinfo_t *clientinfo) -#else -bdb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *l) -#endif /* DNS_CLIENTINFO_VERSION */ -{ - int ret; - char *type, *rdata; - dns_ttl_t ttl; - isc_consttextregion_t ttltext; - DBC *c; - DBT key, data; - char *last; - - UNUSED(zone); -#ifdef DNS_CLIENTINFO_VERSION - UNUSED(methods); - UNUSED(clientinfo); -#endif /* DNS_CLIENTINFO_VERSION */ - - if ((ret = ((DB *)dbdata)->cursor((DB *)dbdata, NULL, &c, 0)) != 0) { - isc_log_iwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_SDB, ISC_LOG_ERROR, - isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "DB->cursor: %s", - db_strerror(ret)); - return ISC_R_FAILURE; - } - - memset(&key, 0, sizeof(DBT)); - memset(&data, 0, sizeof(DBT)); - - (const char *)key.data = name; - key.size = strlen(name); - - ret = c->c_get(c, &key, &data, DB_SET); - while (ret == 0) { - ((char *)key.data)[key.size] = 0; - ((char *)data.data)[data.size] = 0; - ttltext.base = strtok_r((char *)data.data, " ", &last); - ttltext.length = strlen(ttltext.base); - dns_ttl_fromtext((isc_textregion_t *)&ttltext, &ttl); - type = strtok_r(NULL, " ", &last); - rdata = type + strlen(type) + 1; - - if (dns_sdb_putrr(l, type, ttl, rdata) != ISC_R_SUCCESS) { - isc_log_iwrite(dns_lctx, - DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_SDB, ISC_LOG_ERROR, - isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "dns_sdb_putrr"); - return ISC_R_FAILURE; - } - ret = c->c_get(c, &key, &data, DB_NEXT_DUP); - } - - c->c_close(c); - return ISC_R_SUCCESS; -} - -static isc_result_t -bdb_allnodes(const char *zone, void *dbdata, dns_sdballnodes_t *n) -{ - int ret; - char *type, *rdata; - dns_ttl_t ttl; - isc_consttextregion_t ttltext; - DBC *c; - DBT key, data; - - UNUSED(zone); - - if ((ret = ((DB *)dbdata)->cursor((DB *)dbdata, NULL, &c, 0)) != 0) { - isc_log_iwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_SDB, ISC_LOG_ERROR, - isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "DB->cursor: %s", - db_strerror(ret)); - return ISC_R_FAILURE; - } - - memset(&key, 0, sizeof(DBT)); - memset(&data, 0, sizeof(DBT)); - - while (c->c_get(c, &key, &data, DB_NEXT) == 0) { - char *last; - ((char *)key.data)[key.size] = 0; - ((char *)data.data)[data.size] = 0; - ttltext.base = strtok_r((char *)data.data, " ", &last); - ttltext.length = strlen(ttltext.base); - dns_ttl_fromtext((isc_textregion_t *)&ttltext, &ttl); - type = strtok_r(NULL, " ", &last); - rdata = type + strlen(type) + 1; - - if (dns_sdb_putnamedrr(n, key.data, type, ttl, rdata) != - ISC_R_SUCCESS) { - isc_log_iwrite(dns_lctx, - DNS_LOGCATEGORY_DATABASE, - DNS_LOGMODULE_SDB, ISC_LOG_ERROR, - isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "dns_sdb_putnamedrr"); - return ISC_R_FAILURE; - } - - } - - c->c_close(c); - return ISC_R_SUCCESS; -} - -static isc_result_t -bdb_destroy(const char *zone, void *unused, void **dbdata) -{ - - UNUSED(zone); - UNUSED(unused); - - (*(DB **)dbdata)->close(*(DB **)dbdata, 0); - - return ISC_R_SUCCESS; -} - -isc_result_t -bdb_init(void) -{ - static dns_sdbmethods_t bdb_methods = { - bdb_lookup, - NULL, - bdb_allnodes, - bdb_create, - bdb_destroy, - NULL /* lookup2 */ - }; - - return dns_sdb_register(DRIVERNAME, &bdb_methods, NULL, 0, ns_g_mctx, - &bdb_imp); -} - -void -bdb_clear(void) -{ - - if (bdb_imp != NULL) - dns_sdb_unregister(&bdb_imp); -} diff --git a/external/mpl/bind/dist/contrib/sdb/bdb/bdb.h b/external/mpl/bind/dist/contrib/sdb/bdb/bdb.h deleted file mode 100644 index 33da03a8221..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/bdb/bdb.h +++ /dev/null @@ -1,32 +0,0 @@ -/* $NetBSD: bdb.h,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * Copyright (C) 2002 Nuno M. Rodrigues. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND NUNO M. RODRIGUES - * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL - * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING - * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -#ifndef BDB_H -#define BDB_H 1 - -#include <isc/types.h> - -/* - * Prototypes. - */ -isc_result_t bdb_init(void); -void bdb_clear(void); - -#endif /* BDB_H */ diff --git a/external/mpl/bind/dist/contrib/sdb/bdb/zone2bdb.c b/external/mpl/bind/dist/contrib/sdb/bdb/zone2bdb.c deleted file mode 100644 index 81a4f84b4a2..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/bdb/zone2bdb.c +++ /dev/null @@ -1,189 +0,0 @@ -/* $NetBSD: zone2bdb.c,v 1.3 2019/01/09 16:55:10 christos Exp $ */ - -/* - * Copyright (C) 2002 Nuno M. Rodrigues. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND NUNO M. RODRIGUES - * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL - * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING - * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -#include <stdio.h> - -#include <isc/mem.h> -#include <isc/result.h> -#include <isc/types.h> -#include <isc/util.h> - -#include <dns/db.h> -#include <dns/dbiterator.h> -#include <dns/fixedname.h> -#include <dns/name.h> -#include <dns/rdata.h> -#include <dns/rdataset.h> -#include <dns/rdatasetiter.h> -#include <dns/rdatatype.h> -#include <dns/ttl.h> -#include <dns/types.h> - -#include <db.h> - -#define MAX_RDATATEXT 63 + 4 + 65535 + 2 /* ttl + type + rdata + sep */ - -/* - * Returns a valid 'DB' handle. - * - * Requires: - * 'file' is a valid non-existant path. - */ -DB * -bdb_init(const char *file) -{ - DB *db; - - REQUIRE(db_create(&db, NULL, 0) == 0); - REQUIRE(db->set_flags(db, DB_DUP) == 0); - REQUIRE(db->open(db, file, NULL, DB_HASH, DB_CREATE | DB_EXCL, 0) == 0); - - return db; -} - -/* - * Puts resource record data on 'db'. - */ -isc_result_t -bdb_putrdata(DB *db, dns_name_t *name, dns_ttl_t ttl, dns_rdata_t *rdata) -{ - static DBT key, data; - isc_buffer_t keybuf, databuf; - char nametext[DNS_NAME_MAXTEXT]; - char rdatatext[MAX_RDATATEXT]; - - isc_buffer_init(&keybuf, nametext, DNS_NAME_MAXTEXT); - - dns_name_totext(name, true, &keybuf); - - key.data = isc_buffer_base(&keybuf); - key.size = isc_buffer_usedlength(&keybuf); - - isc_buffer_init(&databuf, rdatatext, MAX_RDATATEXT); - - dns_ttl_totext(ttl, false, true, &databuf); - *(char *)isc_buffer_used(&databuf) = ' '; - isc_buffer_add(&databuf, 1); - - dns_rdatatype_totext(rdata->type, &databuf); /* XXX private data */ - *(char *)isc_buffer_used(&databuf) = ' '; - isc_buffer_add(&databuf, 1); - - dns_rdata_totext(rdata, NULL, &databuf); - - data.data = isc_buffer_base(&databuf); - data.size = isc_buffer_usedlength(&databuf); - - REQUIRE(db->put(db, NULL, &key, &data, 0) == 0); - - return ISC_R_SUCCESS; -} - -isc_result_t -bdb_destroy(DB *db) -{ - - return (db->close(db, 0) == 0) ? ISC_R_SUCCESS : ISC_R_FAILURE; -} - -void -usage(const char *prog) -{ - - fprintf(stderr, "Usage: %s <origin> <zonefile> <db>\n", prog); - exit(1); -} - -int -main(int argc, char *argv[]) -{ - isc_mem_t *mctx = NULL; - isc_buffer_t b; - int n; - dns_fixedname_t origin, name; - dns_db_t *db = NULL; - dns_dbiterator_t *dbiter = NULL; - isc_result_t res; - dns_dbnode_t *node = NULL; - dns_rdataset_t rdataset; - dns_rdatasetiter_t *rdatasetiter = NULL; - dns_rdata_t rdata; - DB *bdb; - - if (argc != 4) usage(*argv); - - REQUIRE(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS); - - n = strlen(argv[1]); - isc_buffer_init(&b, argv[1], n); - isc_buffer_add(&b, n); - - dns_fixedname_init(&origin); - - REQUIRE(dns_name_fromtext(dns_fixedname_name(&origin), &b, dns_rootname, - 0, NULL) == ISC_R_SUCCESS); - REQUIRE(dns_db_create(mctx, "rbt", dns_fixedname_name(&origin), - dns_dbtype_zone, dns_rdataclass_in, 0, NULL, - &db) == ISC_R_SUCCESS); - - REQUIRE(dns_db_load(db, argv[2], dns_masterformat_text, 0) - == ISC_R_SUCCESS); - - REQUIRE(dns_db_createiterator(db, 0, &dbiter) == ISC_R_SUCCESS); - - dns_rdataset_init(&rdataset); - dns_rdata_init(&rdata); - dns_fixedname_init(&name); - bdb = bdb_init(argv[3]); - - for (res = dns_dbiterator_first(dbiter); res == ISC_R_SUCCESS; - res = dns_dbiterator_next(dbiter)) { - dns_dbiterator_current(dbiter, &node, dns_fixedname_name(&name)); - REQUIRE(dns_db_allrdatasets(db, node, NULL, 0, &rdatasetiter) - == ISC_R_SUCCESS); - - for (res = dns_rdatasetiter_first(rdatasetiter); - res == ISC_R_SUCCESS; - res = dns_rdatasetiter_next(rdatasetiter)) { - dns_rdatasetiter_current(rdatasetiter, &rdataset); - - res = dns_rdataset_first(&rdataset); - while (res == ISC_R_SUCCESS) { - dns_rdataset_current(&rdataset, &rdata); - REQUIRE(bdb_putrdata(bdb, - dns_fixedname_name(&name), - rdataset.ttl, &rdata) - == ISC_R_SUCCESS); - - dns_rdata_reset(&rdata); - res = dns_rdataset_next(&rdataset); - } - - dns_rdataset_disassociate(&rdataset); - } - dns_rdatasetiter_destroy(&rdatasetiter); - dns_db_detachnode(db, &node); - } - dns_dbiterator_destroy(&dbiter); - - REQUIRE(bdb_destroy(bdb) == ISC_R_SUCCESS); - - return 0; -} diff --git a/external/mpl/bind/dist/contrib/sdb/dir/dirdb.c b/external/mpl/bind/dist/contrib/sdb/dir/dirdb.c deleted file mode 100644 index eca7063bcbb..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/dir/dirdb.c +++ /dev/null @@ -1,202 +0,0 @@ -/* $NetBSD: dirdb.c,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -/* - * A simple database driver that returns basic information about - * files and directories in the Unix file system as DNS data. - */ - -#include <config.h> - -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <sys/stat.h> -#include <sys/sysmacros.h> - -#include <isc/mem.h> -#include <isc/print.h> -#include <isc/result.h> -#include <isc/util.h> - -#include <dns/sdb.h> - -#include <named/globals.h> - -#include "dirdb.h" - -static dns_sdbimplementation_t *dirdb = NULL; - -#define CHECK(op) \ - do { result = (op); \ - if (result != ISC_R_SUCCESS) return (result); \ - } while (/*CONSTCOND*/0) - -#define CHECKN(op) \ - do { n = (op); \ - if (n < 0) return (ISC_R_FAILURE); \ - } while (/*CONSTCOND*/0) - - -/* - * This database operates on relative names. - * - * Any name will be interpreted as a pathname offset from the directory - * specified in the configuration file. - */ -#ifdef DNS_CLIENTINFO_VERSION -static isc_result_t -dirdb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods, - dns_clientinfo_t *clientinfo) -#else -static isc_result_t -dirdb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup) -#endif /* DNS_CLIENTINFO_VERSION */ -{ - char filename[255]; - char filename2[255]; - char buf[1024]; - struct stat statbuf; - isc_result_t result; - int n; - - UNUSED(zone); - UNUSED(dbdata); -#ifdef DNS_CLIENTINFO_VERSION - UNUSED(methods); - UNUSED(clientinfo); -#endif /* DNS_CLIENTINFO_VERSION */ - - if (strcmp(name, "@") == 0) - snprintf(filename, sizeof(filename), "%s", (char *)dbdata); - else - snprintf(filename, sizeof(filename), "%s/%s", - (char *)dbdata, name); - CHECKN(lstat(filename, &statbuf)); - - if (S_ISDIR(statbuf.st_mode)) - CHECK(dns_sdb_putrr(lookup, "txt", 3600, "dir")); - else if (S_ISCHR(statbuf.st_mode) || S_ISBLK(statbuf.st_mode)) { - CHECKN(snprintf(buf, sizeof(buf), - "\"%sdev\" \"major %d\" \"minor %d\"", - S_ISCHR(statbuf.st_mode) ? "chr" : "blk", - major(statbuf.st_rdev), - minor(statbuf.st_rdev))); - CHECK(dns_sdb_putrr(lookup, "txt", 3600, buf)); - } else if (S_ISFIFO(statbuf.st_mode)) - CHECK(dns_sdb_putrr(lookup, "txt", 3600, "pipe")); - else if (S_ISSOCK(statbuf.st_mode)) - CHECK(dns_sdb_putrr(lookup, "txt", 3600, "socket")); - else if (S_ISLNK(statbuf.st_mode)) { - CHECKN(readlink(filename, filename2, sizeof(filename2) - 1)); - buf[n] = 0; - CHECKN(snprintf(buf, sizeof(buf), "\"symlink\" \"%s\"", - filename2)); - CHECK(dns_sdb_putrr(lookup, "txt", 3600, buf)); - } else if (!S_ISREG(statbuf.st_mode)) - CHECK(dns_sdb_putrr(lookup, "txt", 3600, "unknown")); - else { - CHECKN(snprintf(buf, sizeof(buf), "\"file\" \"size = %u\"", - (unsigned int)statbuf.st_size)); - CHECK(dns_sdb_putrr(lookup, "txt", 3600, buf)); - } - - return (ISC_R_SUCCESS); -} - -/* - * lookup () does not return SOA or NS records, so authority() must be defined. - */ -static isc_result_t -dirdb_authority(const char *zone, void *dbdata, dns_sdblookup_t *lookup) { - isc_result_t result; - - UNUSED(zone); - UNUSED(dbdata); - - result = dns_sdb_putsoa(lookup, "ns", "hostmaster", 0); - INSIST(result == ISC_R_SUCCESS); - result = dns_sdb_putrr(lookup, "ns", 86400, "ns1"); - INSIST(result == ISC_R_SUCCESS); - result = dns_sdb_putrr(lookup, "ns", 86400, "ns2"); - INSIST(result == ISC_R_SUCCESS); - return (ISC_R_SUCCESS); -} - -/* - * Each database stores the top-level directory as the dbdata opaque - * object. The create() function allocates it. argv[0] holds the top - * level directory. - */ -static isc_result_t -dirdb_create(const char *zone, int argc, char **argv, - void *driverdata, void **dbdata) -{ - UNUSED(zone); - UNUSED(driverdata); - - if (argc < 1) - return (ISC_R_FAILURE); - *dbdata = isc_mem_strdup((isc_mem_t *)driverdata, argv[0]); - if (*dbdata == NULL) - return (ISC_R_NOMEMORY); - return (ISC_R_SUCCESS); -} - -/* - * The destroy() function frees the memory allocated by create(). - */ -static void -dirdb_destroy(const char *zone, void *driverdata, void **dbdata) { - UNUSED(zone); - UNUSED(driverdata); - isc_mem_free((isc_mem_t *)driverdata, *dbdata); -} - -/* - * This zone does not support zone transfer, so allnodes() is NULL. - */ -static dns_sdbmethods_t dirdb_methods = { - dirdb_lookup, - dirdb_authority, - NULL, /* allnodes */ - dirdb_create, - dirdb_destroy, - NULL /* lookup2 */ -}; - -/* - * Wrapper around dns_sdb_register(). Note that the first ns_g_mctx is - * being passed as the "driverdata" parameter, so that will it will be - * passed to create() and destroy(). - */ -isc_result_t -dirdb_init(void) { - unsigned int flags; - flags = DNS_SDBFLAG_RELATIVEOWNER | DNS_SDBFLAG_RELATIVERDATA | - DNS_SDBFLAG_THREADSAFE; - return (dns_sdb_register("dir", &dirdb_methods, ns_g_mctx, flags, - ns_g_mctx, &dirdb)); -} - -/* - * Wrapper around dns_sdb_unregister(). - */ -void -dirdb_clear(void) { - if (dirdb != NULL) - dns_sdb_unregister(&dirdb); -} diff --git a/external/mpl/bind/dist/contrib/sdb/dir/dirdb.h b/external/mpl/bind/dist/contrib/sdb/dir/dirdb.h deleted file mode 100644 index 29dc98985f5..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/dir/dirdb.h +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: dirdb.h,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -#include <isc/types.h> - -isc_result_t dirdb_init(void); - -void dirdb_clear(void); - diff --git a/external/mpl/bind/dist/contrib/sdb/ldap/INSTALL.ldap b/external/mpl/bind/dist/contrib/sdb/ldap/INSTALL.ldap deleted file mode 100644 index 91511296257..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/ldap/INSTALL.ldap +++ /dev/null @@ -1,83 +0,0 @@ -This is the INSTALL file for 1.0-beta. See -http://www.venaas.no/ldap/bind-sdb/ for updates or other information. - -BUILDING - -You need the source for BIND 9.1.0 or newer (for zone transfers you -will need at least 9.1.1rc3 due to a bug). Basically you need to follow -the instructions in doc/misc/sdb, if my instructions don't make sense, -please have a look at those as well. - -Copy ldapdb.c to bin/named and ldapdb.h to bin/named/include in the -source tree. - -Next alter bin/named/Makefile.in. Add ldapdb.@O@ to DBDRIVER_OBJS and -ldapdb.c to DBDRIVER_SRCS. You also need to add something like --I/usr/local/include to DBDRIVER_INCLUDES and --L/usr/local/lib -lldap -llber -lresolv to DBDRIVER_LIBS -depending on what LDAP library you have and where you installed it. - -Finally you need to edit bin/named/main.c. Below where it says -"#include "xxdb.h"", add the line "#include <ldapdb.h>". Below where -it says "xxdb_init();" add the line "ldapdb_init();", and finally -below where it says "xxdb_clear();", add "ldapdb_clear();". - -Now you should hopefully be able to build as usual; first configure -and then make. If you get an error message about ldap_memfree() not -being defined, you're probably using an LDAP library with the -interface defined in RFC 1823. To build, uncomment the "#define -LDAPDB_RFC1823API" line near the top of ldapdb.c. - -Also, if you're using an LDAPv2 only server, you need to change -the line "#define LDAPDB_LDAP_VERSION 3" in ldapdb.c. Simply -replace 3 with 2. Instead of editing the file, you may define -LDAPDB_LDAP_VERSION yourself. - -If you want to use TLS, you need to uncommed the #define LDAPDB_TLS" -line near the top of ldapdb.c. - -CONFIGURING - -Before you do any configuring of LDAP stuff, please try to configure -and start bind as usual to see if things work. - -To do anything useful, you need to store a zone in some LDAP server. -You must use a schema called dNSZone. Note that it relies on some -attribute definitions in the Cosine schema, so that must be included -as well. The Cosine schema probably comes with your LDAP server. You -can find dNSZone and further details on how to store the data in your -LDAP server at http://www.venaas.no/ldap/bind-sdb/ - -To make BIND use a zone stored in LDAP, you will have to put something -like this in named.conf: - -zone "venaas.com" { - type master; - database "ldap ldap://158.38.160.245/dc=venaas,dc=com,o=DNS,dc=venaas,dc=no 172800"; -}; - -When doing lookups BIND will do a sub-tree search below the base in the -URL. The number 172800 is the TTL which will be used for all entries that -haven't got the dNSTTL attribute. It is also possible to add a filter to -the URL, say "ldap://host/base???(o=internal)". - -Version 1.0 also has support for simple LDAP bind, that is, binding to -LDAP using plain text authentication. The bind dn and password is coded -into the URL as extensions, according to RFC 2255. If you want simple -bind with say dn "cn=Manager,dc=venaas,dc=no" and password "secret", the -URL will be something like this: - -ldap://158.38.160.245/dc=venaas,dc=com,o=DNS,dc=venaas,dc=no????!bindname=cn=Manager%2cdc=venaas%2cdc=no,!x-bindpw=secret - -This URL may also include a filter part if you need it. Note that in -the bind dn, "," is hex-escaped as "%2c". This is necessary since "," -is the separator between the extension elements. The "!" in front of -"bindname" and "x-bindpw" can be omitted if you prefer. "x-bindpw" is -not standardized, but it's used by several other LDAP applications. See -RFC 2255 for details. - -Finally, if you enabled TLS when compiling, you can also use TLS if -you like. To do this you use the extension "x-tls", e.g. -ldap://158.38.160.245/dc=venaas,dc=com,o=DNS,dc=venaas,dc=no????!bindname=cn=Manager%2cdc=venaas%2cdc=no,!x-bindpw=secret,x-tls - -Stig Venaas <venaas@uninett.no> 2004-08-15 diff --git a/external/mpl/bind/dist/contrib/sdb/ldap/README.ldap b/external/mpl/bind/dist/contrib/sdb/ldap/README.ldap deleted file mode 100644 index b4ea18ab462..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/ldap/README.ldap +++ /dev/null @@ -1,48 +0,0 @@ -This is an attempt at an LDAP back-end for BIND 9 using the new simplified -database interface "sdb". This is release 1.0-beta and should be pretty -stable. Note that since version 0.4 a new schema is used. It is not -backwards compatible with versions before 0.4. - -1.0-beta fixes a large memory leak. An extension x-tls for enabling TLS -has been added. - -1.0-alpha uses LDAPv3 by default and also supports LDAP simple bind. That -is, one can use plain text password for authentication. The bind dn and -password is coded into the URL using extensions bindname and x-bindpw -per RFC 2255. - -In 0.9 the code has been cleaned up a bit and should be slightly faster -than previous versions. It also fixes an error with zone transfers (AXFR) -and entries with multiple relativeDomainName values. The problem was -that it would only use the first value in the result. There's no need -to upgrade unless you use such entries. - -0.8 uses asynchronous LDAP search which should give better performance. -Thanks to Ashley Burston for providing patch. Another new feature is -allowing filters in URLs. The syntax is as in RFC 2255. Few people will -need this, but if you have say an internal and external version of the -same zone, you could stick say o=internal and o=external into different -entries, and specify for instance ldap://host/base???(o=internal) -Some error logging has also been added. - -0.7 allows space and other characters to be used in URLs by use of %-quoting. -For instance space can be written as %20. It also fixes a problem with some -servers and/or APIs that do not preserve attribute casing. - -0.6 fixes some memory leaks present in older versions unless compiled with -the RFC 1823 API. - -The big changes in 0.5 are thread support and improved connection handling. -Multiple threads can now access the back-end simultaneously, and rather than -having one connection per zone, there is now one connection per thread per -LDAP server. This should help people with multiple CPUs and people with a -huge number of zones. One final change is support for literal IPv6 addresses -in LDAP URLs. At least OpenLDAP 2 has IPv6 support, so if you use OpenLDAP 2 -libraries and server, you got all you need. - -If you have bug reports, fixes, comments, questions or whatever, please -contact me. See also http://www.venaas.no/ldap/bind-sdb/ for information. - -See INSTALL for how to build, install and use. - -Stig Venaas <venaas@uninett.no> 2004-08-15 diff --git a/external/mpl/bind/dist/contrib/sdb/ldap/README.zone2ldap b/external/mpl/bind/dist/contrib/sdb/ldap/README.zone2ldap deleted file mode 100644 index dacb56bfa26..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/ldap/README.zone2ldap +++ /dev/null @@ -1,17 +0,0 @@ -INSTALLATION - -To Compile zone2ldap from contrib/sdb directory: - - gcc -g `../../../isc-config.sh --cflags isc dns` -c zone2ldap.c - gcc -g -o zone2ldap zone2ldap.o `../../../isc-config.sh --libs isc dns` -lldap -llber -lresolv - -USAGE: - -See zone2ldap.1 - -BUGS: - -Jeff McNeil <jeff@snapcase.g-rock.net> - - - diff --git a/external/mpl/bind/dist/contrib/sdb/ldap/ldapdb.c b/external/mpl/bind/dist/contrib/sdb/ldap/ldapdb.c deleted file mode 100644 index 4a48132a98f..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/ldap/ldapdb.c +++ /dev/null @@ -1,692 +0,0 @@ -/* $NetBSD: ldapdb.c,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * ldapdb.c version 1.0-beta - * - * Copyright (C) 2002, 2004 Stig Venaas - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * Contributors: Jeremy C. McDermond - */ - -/* - * If you want to use TLS, uncomment the define below - */ -/* #define LDAPDB_TLS */ - -/* - * If you are using an old LDAP API uncomment the define below. Only do this - * if you know what you're doing or get compilation errors on ldap_memfree(). - * This also forces LDAPv2. - */ -/* #define LDAPDB_RFC1823API */ - -/* Using LDAPv3 by default, change this if you want v2 */ -#ifndef LDAPDB_LDAP_VERSION -#define LDAPDB_LDAP_VERSION 3 -#endif - -#include <config.h> - -#include <string.h> -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> - -#include <isc/mem.h> -#include <isc/print.h> -#include <isc/result.h> -#include <isc/util.h> -#include <isc/thread.h> - -#include <dns/sdb.h> - -#include <named/globals.h> -#include <named/log.h> - -#include <ldap.h> -#include "ldapdb.h" - -/* - * A simple database driver for LDAP - */ - -/* enough for name with 8 labels of max length */ -#define MAXNAMELEN 519 - -static dns_sdbimplementation_t *ldapdb = NULL; - -struct ldapdb_data { - char *hostport; - char *hostname; - int portno; - char *base; - int defaultttl; - char *filterall; - int filteralllen; - char *filterone; - int filteronelen; - char *filtername; - char *bindname; - char *bindpw; -#ifdef LDAPDB_TLS - int tls; -#endif -}; - -/* used by ldapdb_getconn */ - -struct ldapdb_entry { - void *index; - size_t size; - void *data; - struct ldapdb_entry *next; -}; - -static struct ldapdb_entry *ldapdb_find(struct ldapdb_entry *stack, - const void *index, size_t size) { - while (stack != NULL) { - if (stack->size == size && !memcmp(stack->index, index, size)) - return stack; - stack = stack->next; - } - return NULL; -} - -static void ldapdb_insert(struct ldapdb_entry **stack, - struct ldapdb_entry *item) { - item->next = *stack; - *stack = item; -} - -static void ldapdb_lock(int what) { - static isc_mutex_t lock; - - switch (what) { - case 0: - isc_mutex_init(&lock); - break; - case 1: - LOCK(&lock); - break; - case -1: - UNLOCK(&lock); - break; - } -} - -/* data == NULL means cleanup */ -static LDAP ** -ldapdb_getconn(struct ldapdb_data *data) -{ - static struct ldapdb_entry *allthreadsdata = NULL; - struct ldapdb_entry *threaddata, *conndata; - unsigned long threadid; - - if (data == NULL) { - /* cleanup */ - /* lock out other threads */ - ldapdb_lock(1); - while (allthreadsdata != NULL) { - threaddata = allthreadsdata; - free(threaddata->index); - while (threaddata->data != NULL) { - conndata = threaddata->data; - if (conndata->data != NULL) - ldap_unbind((LDAP *)conndata->data); - threaddata->data = conndata->next; - free(conndata); - } - allthreadsdata = threaddata->next; - free(threaddata); - } - ldapdb_lock(-1); - return (NULL); - } - - /* look for connection data for current thread */ - threadid = isc_thread_self(); - threaddata = ldapdb_find(allthreadsdata, &threadid, sizeof(threadid)); - if (threaddata == NULL) { - /* no data for this thread, create empty connection list */ - threaddata = malloc(sizeof(*threaddata)); - if (threaddata == NULL) - return (NULL); - threaddata->index = malloc(sizeof(threadid)); - if (threaddata->index == NULL) { - free(threaddata); - return (NULL); - } - *(unsigned long *)threaddata->index = threadid; - threaddata->size = sizeof(threadid); - threaddata->data = NULL; - - /* need to lock out other threads here */ - ldapdb_lock(1); - ldapdb_insert(&allthreadsdata, threaddata); - ldapdb_lock(-1); - } - - /* threaddata points at the connection list for current thread */ - /* look for existing connection to our server */ - conndata = ldapdb_find((struct ldapdb_entry *)threaddata->data, - data->hostport, strlen(data->hostport)); - if (conndata == NULL) { - /* no connection data structure for this server, create one */ - conndata = malloc(sizeof(*conndata)); - if (conndata == NULL) - return (NULL); - conndata->index = data->hostport; - conndata->size = strlen(data->hostport); - conndata->data = NULL; - ldapdb_insert((struct ldapdb_entry **)&threaddata->data, - conndata); - } - - return (LDAP **)&conndata->data; -} - -static void -ldapdb_bind(struct ldapdb_data *data, LDAP **ldp) -{ -#ifndef LDAPDB_RFC1823API - const int ver = LDAPDB_LDAP_VERSION; -#endif - - if (*ldp != NULL) - ldap_unbind(*ldp); - *ldp = ldap_open(data->hostname, data->portno); - if (*ldp == NULL) - return; - -#ifndef LDAPDB_RFC1823API - ldap_set_option(*ldp, LDAP_OPT_PROTOCOL_VERSION, &ver); -#endif - -#ifdef LDAPDB_TLS - if (data->tls) { - ldap_start_tls_s(*ldp, NULL, NULL); - } -#endif - - if (ldap_simple_bind_s(*ldp, data->bindname, data->bindpw) != LDAP_SUCCESS) { - ldap_unbind(*ldp); - *ldp = NULL; - } -} - -#ifdef DNS_CLIENTINFO_VERSION -static isc_result_t -ldapdb_search(const char *zone, const char *name, void *dbdata, void *retdata, - dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo) -#else -static isc_result_t -ldapdb_search(const char *zone, const char *name, void *dbdata, void *retdata, - void *methods, void *clientinfo) -#endif /* DNS_CLIENTINFO_VERSION */ -{ - struct ldapdb_data *data = dbdata; - isc_result_t result = ISC_R_NOTFOUND; - LDAP **ldp; - LDAPMessage *res, *e; - char *fltr, *a, **vals = NULL, **names = NULL; - char type[64]; -#ifdef LDAPDB_RFC1823API - void *ptr; -#else - BerElement *ptr; -#endif - int i, j, errno, msgid; - - UNUSED(methods); - UNUSED(clientinfo); - - ldp = ldapdb_getconn(data); - if (ldp == NULL) - return (ISC_R_FAILURE); - if (*ldp == NULL) { - ldapdb_bind(data, ldp); - if (*ldp == NULL) { - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, - "LDAP sdb zone '%s': bind failed", zone); - return (ISC_R_FAILURE); - } - } - - if (name == NULL) { - fltr = data->filterall; - } else { - if (strlen(name) > MAXNAMELEN) { - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, - "LDAP sdb zone '%s': name %s too long", zone, name); - return (ISC_R_FAILURE); - } - sprintf(data->filtername, "%s))", name); - fltr = data->filterone; - } - - msgid = ldap_search(*ldp, data->base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0); - if (msgid == -1) { - ldapdb_bind(data, ldp); - if (*ldp != NULL) - msgid = ldap_search(*ldp, data->base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0); - } - - if (*ldp == NULL || msgid == -1) { - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, - "LDAP sdb zone '%s': search failed, filter %s", zone, fltr); - return (ISC_R_FAILURE); - } - - /* Get the records one by one as they arrive and return them to bind */ - while ((errno = ldap_result(*ldp, msgid, 0, NULL, &res)) != LDAP_RES_SEARCH_RESULT ) { - LDAP *ld = *ldp; - int ttl = data->defaultttl; - - /* not supporting continuation references at present */ - if (errno != LDAP_RES_SEARCH_ENTRY) { - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, - "LDAP sdb zone '%s': ldap_result returned %d", zone, errno); - ldap_msgfree(res); - return (ISC_R_FAILURE); - } - - /* only one entry per result message */ - e = ldap_first_entry(ld, res); - if (e == NULL) { - ldap_msgfree(res); - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, - "LDAP sdb zone '%s': ldap_first_entry failed", zone); - return (ISC_R_FAILURE); - } - - if (name == NULL) { - names = ldap_get_values(ld, e, "relativeDomainName"); - if (names == NULL) - continue; - } - - vals = ldap_get_values(ld, e, "dNSTTL"); - if (vals != NULL) { - ttl = atoi(vals[0]); - ldap_value_free(vals); - } - - for (a = ldap_first_attribute(ld, e, &ptr); a != NULL; a = ldap_next_attribute(ld, e, ptr)) { - char *s; - - for (s = a; *s; s++) - *s = toupper(*s); - s = strstr(a, "RECORD"); - if ((s == NULL) || (s == a) || (s - a >= (signed int)sizeof(type))) { -#ifndef LDAPDB_RFC1823API - ldap_memfree(a); -#endif - continue; - } - - strncpy(type, a, s - a); - type[s - a] = '\0'; - vals = ldap_get_values(ld, e, a); - if (vals != NULL) { - for (i = 0; vals[i] != NULL; i++) { - if (name != NULL) { - result = dns_sdb_putrr(retdata, type, ttl, vals[i]); - } else { - for (j = 0; names[j] != NULL; j++) { - result = dns_sdb_putnamedrr(retdata, names[j], type, ttl, vals[i]); - if (result != ISC_R_SUCCESS) - break; - } - } -; if (result != ISC_R_SUCCESS) { - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, - "LDAP sdb zone '%s': dns_sdb_put... failed for %s", zone, vals[i]); - ldap_value_free(vals); -#ifndef LDAPDB_RFC1823API - ldap_memfree(a); - if (ptr != NULL) - ber_free(ptr, 0); -#endif - if (name == NULL) - ldap_value_free(names); - ldap_msgfree(res); - return (ISC_R_FAILURE); - } - } - ldap_value_free(vals); - } -#ifndef LDAPDB_RFC1823API - ldap_memfree(a); -#endif - } -#ifndef LDAPDB_RFC1823API - if (ptr != NULL) - ber_free(ptr, 0); -#endif - if (name == NULL) - ldap_value_free(names); - - /* free this result */ - ldap_msgfree(res); - } - - /* free final result */ - ldap_msgfree(res); - return (result); -} - - -/* callback routines */ -#ifdef DNS_CLIENTINFO_VERSION -static isc_result_t -ldapdb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods, - dns_clientinfo_t *clientinfo) -{ - UNUSED(methods); - UNUSED(clientinfo); - return (ldapdb_search(zone, name, dbdata, lookup, NULL, NULL)); -} -#else -static isc_result_t -ldapdb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup) -{ - return (ldapdb_search(zone, name, dbdata, lookup, methods, - clientinfo)); -} -#endif /* DNS_CLIENTINFO_VERSION */ - -static isc_result_t -ldapdb_allnodes(const char *zone, void *dbdata, - dns_sdballnodes_t *allnodes) -{ - return (ldapdb_search(zone, NULL, dbdata, allnodes, NULL, NULL)); -} - -static char * -unhex(char *in) -{ - static const char hexdigits[] = "0123456789abcdef"; - char *p, *s = in; - int d1, d2; - - while ((s = strchr(s, '%'))) { - if (!(s[1] && s[2])) - return NULL; - if ((p = strchr(hexdigits, tolower(s[1]))) == NULL) - return NULL; - d1 = p - hexdigits; - if ((p = strchr(hexdigits, tolower(s[2]))) == NULL) - return NULL; - d2 = p - hexdigits; - *s++ = d1 << 4 | d2; - memmove(s, s + 2, strlen(s) - 1); - } - return in; -} - -/* returns 0 for ok, -1 for bad syntax, -2 for unknown critical extension */ -static int -parseextensions(char *extensions, struct ldapdb_data *data) -{ - char *s, *next, *name, *value; - int critical; - - while (extensions != NULL) { - s = strchr(extensions, ','); - if (s != NULL) { - *s++ = '\0'; - next = s; - } else { - next = NULL; - } - - if (*extensions != '\0') { - s = strchr(extensions, '='); - if (s != NULL) { - *s++ = '\0'; - value = *s != '\0' ? s : NULL; - } else { - value = NULL; - } - name = extensions; - - critical = *name == '!'; - if (critical) { - name++; - } - if (*name == '\0') { - return -1; - } - - if (!strcasecmp(name, "bindname")) { - data->bindname = value; - } else if (!strcasecmp(name, "x-bindpw")) { - data->bindpw = value; -#ifdef LDAPDB_TLS - } else if (!strcasecmp(name, "x-tls")) { - data->tls = value == NULL || !strcasecmp(value, "true"); -#endif - } else if (critical) { - return -2; - } - } - extensions = next; - } - return 0; -} - -static void -free_data(struct ldapdb_data *data) -{ - if (data->hostport != NULL) - isc_mem_free(ns_g_mctx, data->hostport); - if (data->hostname != NULL) - isc_mem_free(ns_g_mctx, data->hostname); - if (data->filterall != NULL) - isc_mem_put(ns_g_mctx, data->filterall, data->filteralllen); - if (data->filterone != NULL) - isc_mem_put(ns_g_mctx, data->filterone, data->filteronelen); - isc_mem_put(ns_g_mctx, data, sizeof(struct ldapdb_data)); -} - - -static isc_result_t -ldapdb_create(const char *zone, int argc, char **argv, - void *driverdata, void **dbdata) -{ - struct ldapdb_data *data; - char *s, *filter = NULL, *extensions = NULL; - int defaultttl; - - UNUSED(driverdata); - - /* we assume that only one thread will call create at a time */ - /* want to do this only once for all instances */ - - if ((argc < 2) - || (argv[0] != strstr( argv[0], "ldap://")) - || ((defaultttl = atoi(argv[1])) < 1)) - return (ISC_R_FAILURE); - data = isc_mem_get(ns_g_mctx, sizeof(struct ldapdb_data)); - if (data == NULL) - return (ISC_R_NOMEMORY); - - memset(data, 0, sizeof(struct ldapdb_data)); - data->hostport = isc_mem_strdup(ns_g_mctx, argv[0] + strlen("ldap://")); - if (data->hostport == NULL) { - free_data(data); - return (ISC_R_NOMEMORY); - } - - data->defaultttl = defaultttl; - - s = strchr(data->hostport, '/'); - if (s != NULL) { - *s++ = '\0'; - data->base = s; - /* attrs, scope, filter etc? */ - s = strchr(s, '?'); - if (s != NULL) { - *s++ = '\0'; - /* ignore attributes */ - s = strchr(s, '?'); - if (s != NULL) { - *s++ = '\0'; - /* ignore scope */ - s = strchr(s, '?'); - if (s != NULL) { - *s++ = '\0'; - /* filter */ - filter = s; - s = strchr(s, '?'); - if (s != NULL) { - *s++ = '\0'; - /* extensions */ - extensions = s; - s = strchr(s, '?'); - if (s != NULL) { - *s++ = '\0'; - } - if (*extensions == '\0') { - extensions = NULL; - } - } - if (*filter == '\0') { - filter = NULL; - } - } - } - } - if (*data->base == '\0') { - data->base = NULL; - } - } - - /* parse extensions */ - if (extensions != NULL) { - int err; - - err = parseextensions(extensions, data); - if (err < 0) { - /* err should be -1 or -2 */ - free_data(data); - if (err == -1) { - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, - "LDAP sdb zone '%s': URL: extension syntax error", zone); - } else if (err == -2) { - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, - "LDAP sdb zone '%s': URL: unknown critical extension", zone); - } - return (ISC_R_FAILURE); - } - } - - if ((data->base != NULL && unhex(data->base) == NULL) || - (filter != NULL && unhex(filter) == NULL) || - (data->bindname != NULL && unhex(data->bindname) == NULL) || - (data->bindpw != NULL && unhex(data->bindpw) == NULL)) { - free_data(data); - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, - "LDAP sdb zone '%s': URL: bad hex values", zone); - return (ISC_R_FAILURE); - } - - /* compute filterall and filterone once and for all */ - if (filter == NULL) { - data->filteralllen = strlen(zone) + strlen("(zoneName=)") + 1; - data->filteronelen = strlen(zone) + strlen("(&(zoneName=)(relativeDomainName=))") + MAXNAMELEN + 1; - } else { - data->filteralllen = strlen(filter) + strlen(zone) + strlen("(&(zoneName=))") + 1; - data->filteronelen = strlen(filter) + strlen(zone) + strlen("(&(zoneName=)(relativeDomainName=))") + MAXNAMELEN + 1; - } - - data->filterall = isc_mem_get(ns_g_mctx, data->filteralllen); - if (data->filterall == NULL) { - free_data(data); - return (ISC_R_NOMEMORY); - } - data->filterone = isc_mem_get(ns_g_mctx, data->filteronelen); - if (data->filterone == NULL) { - free_data(data); - return (ISC_R_NOMEMORY); - } - - if (filter == NULL) { - sprintf(data->filterall, "(zoneName=%s)", zone); - sprintf(data->filterone, "(&(zoneName=%s)(relativeDomainName=", zone); - } else { - sprintf(data->filterall, "(&%s(zoneName=%s))", filter, zone); - sprintf(data->filterone, "(&%s(zoneName=%s)(relativeDomainName=", filter, zone); - } - data->filtername = data->filterone + strlen(data->filterone); - - /* support URLs with literal IPv6 addresses */ - data->hostname = isc_mem_strdup(ns_g_mctx, data->hostport + (*data->hostport == '[' ? 1 : 0)); - if (data->hostname == NULL) { - free_data(data); - return (ISC_R_NOMEMORY); - } - - if (*data->hostport == '[' && - (s = strchr(data->hostname, ']')) != NULL ) - *s++ = '\0'; - else - s = data->hostname; - s = strchr(s, ':'); - if (s != NULL) { - *s++ = '\0'; - data->portno = atoi(s); - } else - data->portno = LDAP_PORT; - - *dbdata = data; - return (ISC_R_SUCCESS); -} - -static void -ldapdb_destroy(const char *zone, void *driverdata, void **dbdata) { - struct ldapdb_data *data = *dbdata; - - UNUSED(zone); - UNUSED(driverdata); - - free_data(data); -} - -static dns_sdbmethods_t ldapdb_methods = { - ldapdb_lookup, - NULL, /* authority */ - ldapdb_allnodes, - ldapdb_create, - ldapdb_destroy, - NULL /* lookup2 */ -}; - -/* Wrapper around dns_sdb_register() */ -isc_result_t -ldapdb_init(void) { - unsigned int flags = - DNS_SDBFLAG_RELATIVEOWNER | - DNS_SDBFLAG_RELATIVERDATA | - DNS_SDBFLAG_THREADSAFE; - - ldapdb_lock(0); - return (dns_sdb_register("ldap", &ldapdb_methods, NULL, flags, - ns_g_mctx, &ldapdb)); -} - -/* Wrapper around dns_sdb_unregister() */ -void -ldapdb_clear(void) { - if (ldapdb != NULL) { - /* clean up thread data */ - ldapdb_getconn(NULL); - dns_sdb_unregister(&ldapdb); - } -} diff --git a/external/mpl/bind/dist/contrib/sdb/ldap/ldapdb.h b/external/mpl/bind/dist/contrib/sdb/ldap/ldapdb.h deleted file mode 100644 index dce51a994a7..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/ldap/ldapdb.h +++ /dev/null @@ -1,8 +0,0 @@ -/* $NetBSD: ldapdb.h,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -#include <isc/types.h> - -isc_result_t ldapdb_init(void); - -void ldapdb_clear(void); - diff --git a/external/mpl/bind/dist/contrib/sdb/ldap/zone2ldap.1 b/external/mpl/bind/dist/contrib/sdb/ldap/zone2ldap.1 deleted file mode 100644 index 1d6690a5c54..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/ldap/zone2ldap.1 +++ /dev/null @@ -1,66 +0,0 @@ -.\" $NetBSD: zone2ldap.1,v 1.2 2018/08/12 13:02:34 christos Exp $ -.\" -.TH zone2ldap 1 "8 March 2001" -.SH NAME -zone2ldap /- Load BIND 9 Zone files into LDAP Directory -.SH SYNOPSIS -zone2ldap [-D Bind DN] [-w Bind Password] [-b Base DN] [-z Zone] [-f Zone File ] [-h Ldap Host] [-cd] [-v] -.SH DESCRIPTION -zone2ldap will parse a complete BIND 9 format DNS zone file, and load -the contents into an LDAP directory, for use with the LDAP sdb back-end. - -If the zone already exists, zone2ldap will exit succesfully. If the zone does not exists, or -partially exists, zone2ldap will attempt to add all/missing zone data. - -.SS Options -.TP --b -LDAP Base DN. LDAP systems require a "base dn", which is generally considered the LDAP Directory root. -If the zone you are loading is different from the base, then you will need to tell zone2ldap what your LDAP -base is. -.TP --v -Print version information, and immediatly exit. -.TP --f -Zone file. Bind 9.1 compatible zone file, from which zone information will be read. -.TP --d -Dump debug information to standard out. -.TP --w -LDAP Bind password, corresponding the the value of "-b". -.TP --h -LDAP Directory host. This is the hostname of the LDAP system you wish to store zone information on. -An LDAP server should be listening on port 389 of the target system. This may be ommited, and will default -to "localhost". -.TP --c -This will create the zone portion of the DN you are importing. For instance, if you are creating a domain.com zone, -zone2ldap should first create "dc=domain,dc=com". This is useful if you are creating multiple domains. -.TP --z -This is the name of the zone specified in the SOA record. -.SH EXAMPLES -Following are brief examples of how to import a zone file into your LDAP DIT. -.SS Loading zone domain.com, with an LDAP Base DN of dc=domain,dc=com -zone2ldap -D dc=root -w secret -h localhost -z domain.com -f domain.com.zone - -This will add Resource Records into an ALREADY EXISTING dc=domain,dc=com. The final SOA DN in this case, will be -dc=@,dc=domain,dc=com - -.SS Loading customer.com, if your LDAP Base DN is dc=provider,dc=net. -zone2ldap -D dc=root -w secret -h localhost -z customer.com -b dc=provider,dc=net -f customer.com.zone -c - -This will create dc=customer,dc=com under dc=provider,dc=net, and add all necessary Resource Records. The final -root DN to the SOA will be dc=@,dc=customer,dc=com,dc=provider,dc=net. - -.SH "SEE ALSO" -named(8) ldap(3) -http://www.venaas.no/ldap/bind-sdb/ -.SH "BUGS" -Send all bug reports to Jeff McNeil <jeff@snapcase.g-rock.net> -.SH AUTHOR -Jeff McNeil <jeff@snapcase.g-rock.net> - diff --git a/external/mpl/bind/dist/contrib/sdb/ldap/zone2ldap.c b/external/mpl/bind/dist/contrib/sdb/ldap/zone2ldap.c deleted file mode 100644 index 7b0760f75a3..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/ldap/zone2ldap.c +++ /dev/null @@ -1,764 +0,0 @@ -/* $NetBSD: zone2ldap.c,v 1.3 2019/01/09 16:55:10 christos Exp $ */ - -/* - * Copyright (C) 2001 Jeff McNeil <jeff@snapcase.g-rock.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * Change Log - * - * Tue May 1 19:19:54 EDT 2001 - Jeff McNeil - * Update to objectClass code, and add_to_rr_list function - * (I need to rename that) to support the dNSZone schema, - * ditched dNSDomain2 schema support. Version 0.3-ALPHA - */ - -#include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> -#include <getopt.h> - -#include <isc/buffer.h> -#include <isc/hash.h> -#include <isc/mem.h> -#include <isc/print.h> -#include <isc/result.h> -#include <isc/string.h> - -#include <dns/db.h> -#include <dns/dbiterator.h> -#include <dns/fixedname.h> -#include <dns/name.h> -#include <dns/rdata.h> -#include <dns/rdataset.h> -#include <dns/rdatasetiter.h> -#include <dns/result.h> -#include <dns/rdatatype.h> - -#define LDAP_DEPRECATED 1 - -#include <ldap.h> - -#define DNS_OBJECT 6 -#define DNS_TOP 2 - -#define VERSION "0.4-ALPHA" - -#define NO_SPEC 0 -#define WI_SPEC 1 - -/* Global Zone Pointer */ -char *gbl_zone = NULL; - -typedef struct LDAP_INFO -{ - char *dn; - LDAPMod **attrs; - struct LDAP_INFO *next; - int attrcnt; -} -ldap_info; - -/* usage Info */ -void usage (); - -/* Add to the ldap dit */ -void add_ldap_values (ldap_info * ldinfo); - -/* Init an ldap connection */ -void init_ldap_conn (); - -/* Ldap error checking */ -void ldap_result_check (char *msg, char *dn, int err); - -/* Put a hostname into a char ** array */ -char **hostname_to_dn_list (char *hostname, char *zone, unsigned int flags); - -/* Find out how many items are in a char ** array */ -int get_attr_list_size (char **tmp); - -/* Get a DN */ -char *build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag); - -/* Add to RR list */ -void add_to_rr_list (char *dn, char *name, char *type, char *data, - unsigned int ttl, unsigned int flags); - -/* Error checking */ -void isc_result_check (isc_result_t res, char *errorstr); - -/* Generate LDIF Format files */ -void generate_ldap (dns_name_t * dnsname, dns_rdata_t * rdata, - unsigned int ttl); - -/* head pointer to the list */ -ldap_info *ldap_info_base = NULL; - -char *argzone, *ldapbase, *binddn, *bindpw = NULL; -char *ldapsystem = "localhost"; -static char *objectClasses[] = - { "top", "dNSZone", NULL }; -static char *topObjectClasses[] = { "top", NULL }; -LDAP *conn; -unsigned int debug = 0; - -#ifdef DEBUG -debug = 1; -#endif - -static void -fatal(const char *msg) { - perror(msg); - if (conn != NULL) - ldap_unbind_s(conn); - exit(1); -} - -int -main (int argc, char **argv) -{ - isc_mem_t *mctx = NULL; - isc_result_t result; - char *basedn; - ldap_info *tmp; - LDAPMod *base_attrs[2]; - LDAPMod base; - isc_buffer_t buff; - char *zonefile; - char fullbasedn[1024]; - char *ctmp; - dns_fixedname_t fixedzone, fixedname; - dns_rdataset_t rdataset; - char **dc_list; - dns_rdata_t rdata = DNS_RDATA_INIT; - dns_rdatasetiter_t *riter; - dns_name_t *zone, *name; - dns_db_t *db = NULL; - dns_dbiterator_t *dbit = NULL; - dns_dbnode_t *node; - extern char *optarg; - extern int optind, opterr, optopt; - int create_base = 0; - int topt; - - if (argc < 2) - { - usage (); - exit (-1); - } - - while ((topt = getopt (argc, argv, "D:w:b:z:f:h:?dcv")) != -1) - { - switch (topt) - { - case 'v': - printf("%s\n", VERSION); - exit(0); - case 'c': - create_base++; - break; - case 'd': - debug++; - break; - case 'D': - binddn = strdup (optarg); - if (binddn == NULL) - fatal("strdup"); - break; - case 'w': - bindpw = strdup (optarg); - if (bindpw == NULL) - fatal("strdup"); - break; - case 'b': - ldapbase = strdup (optarg); - if (ldapbase == NULL) - fatal("strdup"); - break; - case 'z': - argzone = strdup (optarg); - // We wipe argzone all to hell when we parse it for the DN */ - gbl_zone = strdup(argzone); - if (argzone == NULL || gbl_zone == NULL) - fatal("strdup"); - break; - case 'f': - zonefile = strdup (optarg); - if (zonefile == NULL) - fatal("strdup"); - break; - case 'h': - ldapsystem = strdup (optarg); - if (ldapsystem == NULL) - fatal("strdup"); - break; - case '?': - default: - usage (); - exit (0); - } - } - - if ((argzone == NULL) || (zonefile == NULL)) - { - usage (); - exit (-1); - } - - if (debug) - printf ("Initializing ISC Routines, parsing zone file\n"); - - result = isc_mem_create (0, 0, &mctx); - isc_result_check (result, "isc_mem_create"); - - isc_buffer_init (&buff, argzone, strlen (argzone)); - isc_buffer_add (&buff, strlen (argzone)); - zone = dns_fixedname_initname(&fixedzone); - result = dns_name_fromtext (zone, &buff, dns_rootname, 0, NULL); - isc_result_check (result, "dns_name_fromtext"); - - result = dns_db_create (mctx, "rbt", zone, dns_dbtype_zone, - dns_rdataclass_in, 0, NULL, &db); - isc_result_check (result, "dns_db_create"); - - result = dns_db_load(db, zonefile, dns_masterformat_text, 0); - isc_result_check (result, "Check Zone Syntax: dns_db_load"); - - result = dns_db_createiterator (db, 0, &dbit); - isc_result_check (result, "dns_db_createiterator"); - - result = dns_dbiterator_first (dbit); - isc_result_check (result, "dns_dbiterator_first"); - - name = dns_fixedname_initname(&fixedname); - dns_rdataset_init (&rdataset); - dns_rdata_init (&rdata); - - while (result == ISC_R_SUCCESS) - { - node = NULL; - result = dns_dbiterator_current (dbit, &node, name); - - if (result == ISC_R_NOMORE) - break; - - isc_result_check (result, "dns_dbiterator_current"); - - riter = NULL; - result = dns_db_allrdatasets (db, node, NULL, 0, &riter); - isc_result_check (result, "dns_db_allrdatasets"); - - result = dns_rdatasetiter_first (riter); - //isc_result_check(result, "dns_rdatasetiter_first"); - - while (result == ISC_R_SUCCESS) - { - dns_rdatasetiter_current (riter, &rdataset); - result = dns_rdataset_first (&rdataset); - isc_result_check (result, "dns_rdatasetiter_current"); - - while (result == ISC_R_SUCCESS) - { - dns_rdataset_current (&rdataset, &rdata); - generate_ldap (name, &rdata, rdataset.ttl); - dns_rdata_reset (&rdata); - result = dns_rdataset_next (&rdataset); - } - dns_rdataset_disassociate (&rdataset); - result = dns_rdatasetiter_next (riter); - - } - dns_rdatasetiter_destroy (&riter); - result = dns_dbiterator_next (dbit); - - } - - /* Initialize the LDAP Connection */ - if (debug) - printf ("Initializing LDAP Connection to %s as %s\n", ldapsystem, binddn); - - init_ldap_conn (); - - if (create_base) - { - if (debug) - printf ("Creating base zone DN %s\n", argzone); - - dc_list = hostname_to_dn_list (argzone, argzone, DNS_TOP); - basedn = build_dn_from_dc_list (dc_list, 0, NO_SPEC); - - for (ctmp = &basedn[strlen (basedn)]; ctmp >= &basedn[0]; ctmp--) - { - if ((*ctmp == ',') || (ctmp == &basedn[0])) - { - base.mod_op = LDAP_MOD_ADD; - base.mod_type = "objectClass"; - base.mod_values = topObjectClasses; - base_attrs[0] = &base; - base_attrs[1] = NULL; - - if (ldapbase) - { - if (ctmp != &basedn[0]) - sprintf (fullbasedn, "%s,%s", ctmp + 1, ldapbase); - else - sprintf (fullbasedn, "%s,%s", ctmp, ldapbase); - - } - else - { - if (ctmp != &basedn[0]) - sprintf (fullbasedn, "%s", ctmp + 1); - else - sprintf (fullbasedn, "%s", ctmp); - } - result = ldap_add_s (conn, fullbasedn, base_attrs); - ldap_result_check ("intial ldap_add_s", fullbasedn, result); - } - - } - } - else - { - if (debug) - printf ("Skipping zone base dn creation for %s\n", argzone); - } - - for (tmp = ldap_info_base; tmp != NULL; tmp = tmp->next) - { - - if (debug) - printf ("Adding DN: %s\n", tmp->dn); - - add_ldap_values (tmp); - } - - if (debug) - printf("Operation Complete.\n"); - - /* Cleanup */ - isc_mem_destroy(&mctx); - if (zonefile) - free(zonefile); - - return 0; -} - - -/* Check the status of an isc_result_t after any isc routines. - * I should probably rename this function, as not to cause any - * confusion with the isc* routines. Will exit on error. */ -void -isc_result_check (isc_result_t res, char *errorstr) -{ - if (res != ISC_R_SUCCESS) - { - fprintf (stderr, " %s: %s\n", errorstr, isc_result_totext (res)); - exit (-1); - } -} - - -/* Takes DNS information, in bind data structure format, and adds textual - * zone information to the LDAP run queue. */ -void -generate_ldap (dns_name_t * dnsname, dns_rdata_t * rdata, unsigned int ttl) -{ - char name[DNS_NAME_MAXTEXT + 1]; - unsigned int len; - char type[20]; - char data[2048]; - char **dc_list; - char *dn; - - isc_buffer_t buff; - isc_result_t result; - - isc_buffer_init (&buff, name, sizeof (name)); - result = dns_name_totext (dnsname, true, &buff); - isc_result_check (result, "dns_name_totext"); - name[isc_buffer_usedlength (&buff)] = 0; - - isc_buffer_init (&buff, type, sizeof (type)); - result = dns_rdatatype_totext (rdata->type, &buff); - isc_result_check (result, "dns_rdatatype_totext"); - type[isc_buffer_usedlength (&buff)] = 0; - - isc_buffer_init (&buff, data, sizeof (data)); - result = dns_rdata_totext (rdata, NULL, &buff); - isc_result_check (result, "dns_rdata_totext"); - data[isc_buffer_usedlength (&buff)] = 0; - - dc_list = hostname_to_dn_list (name, argzone, DNS_OBJECT); - len = (get_attr_list_size (dc_list) - 2); - dn = build_dn_from_dc_list (dc_list, ttl, WI_SPEC); - - if (debug) - printf ("Adding %s (%s %s) to run queue list.\n", dn, type, data); - - add_to_rr_list (dn, dc_list[len], type, data, ttl, DNS_OBJECT); -} - - -/* Locate an item in the Run queue linked list, by DN. Used by functions - * which add items to the run queue. - */ -ldap_info * -locate_by_dn (char *dn) -{ - ldap_info *tmp; - for (tmp = ldap_info_base; tmp != (ldap_info *) NULL; tmp = tmp->next) - { - if (!strncmp (tmp->dn, dn, strlen (dn))) - return tmp; - } - return (ldap_info *) NULL; -} - - - -/* Take textual zone data, and add to the LDAP Run queue. This works like so: - * If locate_by_dn does not return, alloc a new ldap_info structure, and then - * calloc a LDAPMod array, fill in the default "everyone needs this" information, - * including object classes and dc's. If it locate_by_dn does return, then we'll - * realloc for more LDAPMod structs, and appened the new data. If an LDAPMod exists - * for the parameter we're adding, then we'll realloc the mod_values array, and - * add the new value to the existing LDAPMod. Finnaly, it assures linkage exists - * within the Run queue linked ilst*/ - -void -add_to_rr_list (char *dn, char *name, char *type, - char *data, unsigned int ttl, unsigned int flags) -{ - int i; - int x; - ldap_info *tmp; - int attrlist; - char ldap_type_buffer[128]; - char charttl[64]; - - - if ((tmp = locate_by_dn (dn)) == NULL) - { - - /* There wasn't one already there, so we need to allocate a new one, - * and stick it on the list */ - - tmp = (ldap_info *) malloc (sizeof (ldap_info)); - if (tmp == (ldap_info *) NULL) - fatal("malloc"); - - tmp->dn = strdup (dn); - if (tmp->dn == NULL) - fatal("strdup"); - - tmp->attrs = (LDAPMod **) calloc (sizeof (LDAPMod *), flags); - if (tmp->attrs == (LDAPMod **) NULL) - fatal("calloc"); - - for (i = 0; i < flags; i++) - { - tmp->attrs[i] = (LDAPMod *) malloc (sizeof (LDAPMod)); - if (tmp->attrs[i] == (LDAPMod *) NULL) - fatal("malloc"); - } - tmp->attrs[0]->mod_op = LDAP_MOD_ADD; - tmp->attrs[0]->mod_type = "objectClass"; - - if (flags == DNS_OBJECT) - tmp->attrs[0]->mod_values = objectClasses; - else - { - tmp->attrs[0]->mod_values = topObjectClasses; - tmp->attrs[1] = NULL; - tmp->attrcnt = 2; - tmp->next = ldap_info_base; - ldap_info_base = tmp; - return; - } - - tmp->attrs[1]->mod_op = LDAP_MOD_ADD; - tmp->attrs[1]->mod_type = "relativeDomainName"; - tmp->attrs[1]->mod_values = (char **) calloc (sizeof (char *), 2); - - if (tmp->attrs[1]->mod_values == (char **)NULL) - fatal("calloc"); - - tmp->attrs[1]->mod_values[0] = strdup (name); - tmp->attrs[1]->mod_values[2] = NULL; - - if (tmp->attrs[1]->mod_values[0] == NULL) - fatal("strdup"); - - sprintf (ldap_type_buffer, "%sRecord", type); - - tmp->attrs[2]->mod_op = LDAP_MOD_ADD; - tmp->attrs[2]->mod_type = strdup (ldap_type_buffer); - tmp->attrs[2]->mod_values = (char **) calloc (sizeof (char *), 2); - - if (tmp->attrs[2]->mod_type == NULL || - tmp->attrs[2]->mod_values == (char **)NULL) - fatal("strdup/calloc"); - - tmp->attrs[2]->mod_values[0] = strdup (data); - tmp->attrs[2]->mod_values[1] = NULL; - - if (tmp->attrs[2]->mod_values[0] == NULL) - fatal("strdup"); - - tmp->attrs[3]->mod_op = LDAP_MOD_ADD; - tmp->attrs[3]->mod_type = "dNSTTL"; - tmp->attrs[3]->mod_values = (char **) calloc (sizeof (char *), 2); - - if (tmp->attrs[3]->mod_values == (char **)NULL) - fatal("calloc"); - - sprintf (charttl, "%d", ttl); - tmp->attrs[3]->mod_values[0] = strdup (charttl); - tmp->attrs[3]->mod_values[1] = NULL; - - if (tmp->attrs[3]->mod_values[0] == NULL) - fatal("strdup"); - - tmp->attrs[4]->mod_op = LDAP_MOD_ADD; - tmp->attrs[4]->mod_type = "zoneName"; - tmp->attrs[4]->mod_values = (char **)calloc(sizeof(char *), 2); - - if (tmp->attrs[4]->mod_values == (char **)NULL) - fatal("calloc"); - - tmp->attrs[4]->mod_values[0] = gbl_zone; - tmp->attrs[4]->mod_values[1] = NULL; - - tmp->attrs[5] = NULL; - tmp->attrcnt = flags; - tmp->next = ldap_info_base; - ldap_info_base = tmp; - } - else - { - - for (i = 0; tmp->attrs[i] != NULL; i++) - { - sprintf (ldap_type_buffer, "%sRecord", type); - if (!strncmp - (ldap_type_buffer, tmp->attrs[i]->mod_type, - strlen (tmp->attrs[i]->mod_type))) - { - attrlist = get_attr_list_size (tmp->attrs[i]->mod_values); - tmp->attrs[i]->mod_values = - (char **) realloc (tmp->attrs[i]->mod_values, - sizeof (char *) * (attrlist + 1)); - - if (tmp->attrs[i]->mod_values == (char **) NULL) - fatal("realloc"); - - for (x = 0; tmp->attrs[i]->mod_values[x] != NULL; x++); - - tmp->attrs[i]->mod_values[x] = strdup (data); - if (tmp->attrs[i]->mod_values[x] == NULL) - fatal("strdup"); - tmp->attrs[i]->mod_values[x + 1] = NULL; - - return; - } - } - tmp->attrs = - (LDAPMod **) realloc (tmp->attrs, - sizeof (LDAPMod) * ++(tmp->attrcnt)); - if (tmp->attrs == NULL) - fatal("realloc"); - - for (x = 0; tmp->attrs[x] != NULL; x++); - tmp->attrs[x] = (LDAPMod *) malloc (sizeof (LDAPMod)); - if (tmp->attrs[x] == NULL) - fatal("malloc"); - tmp->attrs[x]->mod_op = LDAP_MOD_ADD; - tmp->attrs[x]->mod_type = strdup (ldap_type_buffer); - tmp->attrs[x]->mod_values = (char **) calloc (sizeof (char *), 2); - - if (tmp->attrs[x]->mod_type == NULL || - tmp->attrs[x]->mod_values == (char **)NULL) - fatal("strdup/calloc"); - - tmp->attrs[x]->mod_values[0] = strdup (data); - if (tmp->attrs[x]->mod_values[0] == NULL) - fatal("strdup"); - tmp->attrs[x]->mod_values[1] = NULL; - tmp->attrs[x + 1] = NULL; - } -} - -/* Size of a mod_values list, plus the terminating NULL field. */ -int -get_attr_list_size (char **tmp) -{ - int i = 0; - char **ftmp = tmp; - while (*ftmp != NULL) - { - i++; - ftmp++; - } - return ++i; -} - - -/* take a hostname, and split it into a char ** of the dc parts, - * example, we have www.domain.com, this function will return: - * array[0] = com, array[1] = domain, array[2] = www. */ - -char ** -hostname_to_dn_list (char *hostname, char *zone, unsigned int flags) -{ - char *tmp; - static char *dn_buffer[64]; - int i = 0; - char *zname; - char *hnamebuff; - - zname = strdup (hostname); - if (zname == NULL) - fatal("strdup"); - - if (flags == DNS_OBJECT) - { - - if (strlen (zname) != strlen (zone)) - { - tmp = &zname[strlen (zname) - strlen (zone)]; - *--tmp = '\0'; - hnamebuff = strdup (zname); - if (hnamebuff == NULL) - fatal("strdup"); - zname = ++tmp; - } - else - hnamebuff = "@"; - } - else - { - zname = zone; - hnamebuff = NULL; - } - - for (tmp = strrchr (zname, '.'); tmp != (char *) 0; - tmp = strrchr (zname, '.')) - { - *tmp++ = '\0'; - dn_buffer[i++] = tmp; - } - dn_buffer[i++] = zname; - dn_buffer[i++] = hnamebuff; - dn_buffer[i] = NULL; - - return dn_buffer; -} - - -/* build an sdb compatible LDAP DN from a "dc_list" (char **). - * will append dNSTTL information to each RR Record, with the - * exception of "@"/SOA. */ - -char * -build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag) -{ - int size; - int x; - static char dn[1024]; - char tmp[128]; - - bzero (tmp, sizeof (tmp)); - bzero (dn, sizeof (dn)); - size = get_attr_list_size (dc_list); - for (x = size - 2; x > 0; x--) - { - if (flag == WI_SPEC) - { - if (x == (size - 2) && (strncmp (dc_list[x], "@", 1) == 0) && (ttl)) - sprintf (tmp, "relativeDomainName=%s + dNSTTL=%d,", dc_list[x], ttl); - else if (x == (size - 2)) - sprintf(tmp, "relativeDomainName=%s,",dc_list[x]); - else - sprintf(tmp,"dc=%s,", dc_list[x]); - } - else - { - sprintf(tmp, "dc=%s,", dc_list[x]); - } - - - strlcat (dn, tmp, sizeof (dn)); - } - - sprintf (tmp, "dc=%s", dc_list[0]); - strlcat (dn, tmp, sizeof (dn)); - - fflush(NULL); - return dn; -} - - -/* Initialize LDAP Conn */ -void -init_ldap_conn () -{ - int result; - conn = ldap_open (ldapsystem, LDAP_PORT); - if (conn == NULL) - { - fprintf (stderr, "Error opening Ldap connection: %s\n", - strerror (errno)); - exit (-1); - } - - result = ldap_simple_bind_s (conn, binddn, bindpw); - ldap_result_check ("ldap_simple_bind_s", "LDAP Bind", result); -} - -/* Like isc_result_check, only for LDAP */ -void -ldap_result_check (char *msg, char *dn, int err) -{ - if ((err != LDAP_SUCCESS) && (err != LDAP_ALREADY_EXISTS)) - { - fprintf(stderr, "Error while adding %s (%s):\n", - dn, msg); - ldap_perror (conn, dn); - ldap_unbind_s (conn); - exit (-1); - } -} - - - -/* For running the ldap_info run queue. */ -void -add_ldap_values (ldap_info * ldinfo) -{ - int result; - char dnbuffer[1024]; - - - if (ldapbase != NULL) - sprintf (dnbuffer, "%s,%s", ldinfo->dn, ldapbase); - else - sprintf (dnbuffer, "%s", ldinfo->dn); - - result = ldap_add_s (conn, dnbuffer, ldinfo->attrs); - ldap_result_check ("ldap_add_s", dnbuffer, result); -} - - - - -/* name says it all */ -void -usage () -{ - fprintf (stderr, - "zone2ldap -D [BIND DN] -w [BIND PASSWORD] -b [BASE DN] -z [ZONE] -f [ZONE FILE] -h [LDAP HOST] " - "[-c Create LDAP Base structure][-d Debug Output (lots !)] \n ");} diff --git a/external/mpl/bind/dist/contrib/sdb/pgsql/pgsqldb.c b/external/mpl/bind/dist/contrib/sdb/pgsql/pgsqldb.c deleted file mode 100644 index f4c1386f7e8..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/pgsql/pgsqldb.c +++ /dev/null @@ -1,355 +0,0 @@ -/* $NetBSD: pgsqldb.c,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -#include <config.h> - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#include <pgsql/libpq-fe.h> - -#include <isc/mem.h> -#include <isc/print.h> -#include <isc/result.h> -#include <isc/util.h> - -#include <dns/sdb.h> -#include <dns/result.h> - -#include <named/globals.h> - -#include "pgsqldb.h" - -/* - * A simple database driver that interfaces to a PostgreSQL database. This - * is not complete, and not designed for general use. It opens one - * connection to the database per zone, which is inefficient. It also may - * not handle quoting correctly. - * - * The table must contain the fields "name", "rdtype", and "rdata", and - * is expected to contain a properly constructed zone. The program "zonetodb" - * creates such a table. - */ - -static dns_sdbimplementation_t *pgsqldb = NULL; - -struct dbinfo { - PGconn *conn; - char *database; - char *table; - char *host; - char *user; - char *passwd; -}; - -static void -pgsqldb_destroy(const char *zone, void *driverdata, void **dbdata); - -/* - * Canonicalize a string before writing it to the database. - * "dest" must be an array of at least size 2*strlen(source) + 1. - */ -static void -quotestring(const char *source, char *dest) { - while (*source != 0) { - if (*source == '\'') - *dest++ = '\''; - /* SQL doesn't treat \ as special, but PostgreSQL does */ - else if (*source == '\\') - *dest++ = '\\'; - *dest++ = *source++; - } - *dest++ = 0; -} - -/* - * Connect to the database. - */ -static isc_result_t -db_connect(struct dbinfo *dbi) { - dbi->conn = PQsetdbLogin(dbi->host, NULL, NULL, NULL, dbi->database, - dbi->user, dbi->passwd); - - if (PQstatus(dbi->conn) == CONNECTION_OK) - return (ISC_R_SUCCESS); - else - return (ISC_R_FAILURE); -} - -/* - * Check to see if the connection is still valid. If not, attempt to - * reconnect. - */ -static isc_result_t -maybe_reconnect(struct dbinfo *dbi) { - if (PQstatus(dbi->conn) == CONNECTION_OK) - return (ISC_R_SUCCESS); - - return (db_connect(dbi)); -} - -/* - * This database operates on absolute names. - * - * Queries are converted into SQL queries and issued synchronously. Errors - * are handled really badly. - */ -#ifdef DNS_CLIENTINFO_VERSION -static isc_result_t -pgsqldb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods, - dns_clientinfo_t *clientinfo) -#else -static isc_result_t -pgsqldb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup) -#endif /* DNS_CLIENTINFO_VERSION */ -{ - isc_result_t result; - struct dbinfo *dbi = dbdata; - PGresult *res; - char str[1500]; - char *canonname; - int i; - - UNUSED(zone); -#ifdef DNS_CLIENTINFO_VERSION - UNUSED(methods); - UNUSED(clientinfo); -#endif /* DNS_CLIENTINFO_VERSION */ - - canonname = isc_mem_get(ns_g_mctx, strlen(name) * 2 + 1); - if (canonname == NULL) - return (ISC_R_NOMEMORY); - quotestring(name, canonname); - snprintf(str, sizeof(str), - "SELECT TTL,RDTYPE,RDATA FROM \"%s\" WHERE " - "lower(NAME) = lower('%s')", dbi->table, canonname); - isc_mem_put(ns_g_mctx, canonname, strlen(name) * 2 + 1); - - result = maybe_reconnect(dbi); - if (result != ISC_R_SUCCESS) - return (result); - - res = PQexec(dbi->conn, str); - if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) { - PQclear(res); - return (ISC_R_FAILURE); - } - if (PQntuples(res) == 0) { - PQclear(res); - return (ISC_R_NOTFOUND); - } - - for (i = 0; i < PQntuples(res); i++) { - char *ttlstr = PQgetvalue(res, i, 0); - char *type = PQgetvalue(res, i, 1); - char *data = PQgetvalue(res, i, 2); - dns_ttl_t ttl; - char *endp; - ttl = strtol(ttlstr, &endp, 10); - if (*endp != '\0') { - PQclear(res); - return (DNS_R_BADTTL); - } - result = dns_sdb_putrr(lookup, type, ttl, data); - if (result != ISC_R_SUCCESS) { - PQclear(res); - return (ISC_R_FAILURE); - } - } - - PQclear(res); - return (ISC_R_SUCCESS); -} - -/* - * Issue an SQL query to return all nodes in the database and fill the - * allnodes structure. - */ -static isc_result_t -pgsqldb_allnodes(const char *zone, void *dbdata, dns_sdballnodes_t *allnodes) { - struct dbinfo *dbi = dbdata; - PGresult *res; - isc_result_t result; - char str[1500]; - int i; - - UNUSED(zone); - - snprintf(str, sizeof(str), - "SELECT TTL,NAME,RDTYPE,RDATA FROM \"%s\" ORDER BY NAME", - dbi->table); - - result = maybe_reconnect(dbi); - if (result != ISC_R_SUCCESS) - return (result); - - res = PQexec(dbi->conn, str); - if (!res || PQresultStatus(res) != PGRES_TUPLES_OK ) { - PQclear(res); - return (ISC_R_FAILURE); - } - if (PQntuples(res) == 0) { - PQclear(res); - return (ISC_R_NOTFOUND); - } - - for (i = 0; i < PQntuples(res); i++) { - char *ttlstr = PQgetvalue(res, i, 0); - char *name = PQgetvalue(res, i, 1); - char *type = PQgetvalue(res, i, 2); - char *data = PQgetvalue(res, i, 3); - dns_ttl_t ttl; - char *endp; - ttl = strtol(ttlstr, &endp, 10); - if (*endp != '\0') { - PQclear(res); - return (DNS_R_BADTTL); - } - result = dns_sdb_putnamedrr(allnodes, name, type, ttl, data); - if (result != ISC_R_SUCCESS) { - PQclear(res); - return (ISC_R_FAILURE); - } - } - - PQclear(res); - return (ISC_R_SUCCESS); -} - -/* - * Create a connection to the database and save any necessary information - * in dbdata. - * - * argv[0] is the name of the database - * argv[1] is the name of the table - * argv[2] (if present) is the name of the host to connect to - * argv[3] (if present) is the name of the user to connect as - * argv[4] (if present) is the name of the password to connect with - */ -static isc_result_t -pgsqldb_create(const char *zone, int argc, char **argv, - void *driverdata, void **dbdata) -{ - struct dbinfo *dbi; - isc_result_t result; - - UNUSED(zone); - UNUSED(driverdata); - - if (argc < 2) - return (ISC_R_FAILURE); - - dbi = isc_mem_get(ns_g_mctx, sizeof(struct dbinfo)); - if (dbi == NULL) - return (ISC_R_NOMEMORY); - dbi->conn = NULL; - dbi->database = NULL; - dbi->table = NULL; - dbi->host = NULL; - dbi->user = NULL; - dbi->passwd = NULL; - -#define STRDUP_OR_FAIL(target, source) \ - do { \ - target = isc_mem_strdup(ns_g_mctx, source); \ - if (target == NULL) { \ - result = ISC_R_NOMEMORY; \ - goto cleanup; \ - } \ - } while (/*CONSTCOND*/0); - - STRDUP_OR_FAIL(dbi->database, argv[0]); - STRDUP_OR_FAIL(dbi->table, argv[1]); - if (argc > 2) - STRDUP_OR_FAIL(dbi->host, argv[2]); - if (argc > 3) - STRDUP_OR_FAIL(dbi->user, argv[3]); - if (argc > 4) - STRDUP_OR_FAIL(dbi->passwd, argv[4]); - - result = db_connect(dbi); - if (result != ISC_R_SUCCESS) - goto cleanup; - - *dbdata = dbi; - return (ISC_R_SUCCESS); - - cleanup: - pgsqldb_destroy(zone, driverdata, (void **)&dbi); - return (result); -} - -/* - * Close the connection to the database. - */ -static void -pgsqldb_destroy(const char *zone, void *driverdata, void **dbdata) { - struct dbinfo *dbi = *dbdata; - - UNUSED(zone); - UNUSED(driverdata); - - if (dbi->conn != NULL) - PQfinish(dbi->conn); - if (dbi->database != NULL) - isc_mem_free(ns_g_mctx, dbi->database); - if (dbi->table != NULL) - isc_mem_free(ns_g_mctx, dbi->table); - if (dbi->host != NULL) - isc_mem_free(ns_g_mctx, dbi->host); - if (dbi->user != NULL) - isc_mem_free(ns_g_mctx, dbi->user); - if (dbi->passwd != NULL) - isc_mem_free(ns_g_mctx, dbi->passwd); - if (dbi->database != NULL) - isc_mem_free(ns_g_mctx, dbi->database); - isc_mem_put(ns_g_mctx, dbi, sizeof(struct dbinfo)); -} - -/* - * Since the SQL database corresponds to a zone, the authority data should - * be returned by the lookup() function. Therefore the authority() function - * is NULL. - */ -static dns_sdbmethods_t pgsqldb_methods = { - pgsqldb_lookup, - NULL, /* authority */ - pgsqldb_allnodes, - pgsqldb_create, - pgsqldb_destroy, - NULL /* lookup2 */ -}; - -/* - * Wrapper around dns_sdb_register(). - */ -isc_result_t -pgsqldb_init(void) { - unsigned int flags; - flags = 0; - return (dns_sdb_register("pgsql", &pgsqldb_methods, NULL, flags, - ns_g_mctx, &pgsqldb)); -} - -/* - * Wrapper around dns_sdb_unregister(). - */ -void -pgsqldb_clear(void) { - if (pgsqldb != NULL) - dns_sdb_unregister(&pgsqldb); -} diff --git a/external/mpl/bind/dist/contrib/sdb/pgsql/pgsqldb.h b/external/mpl/bind/dist/contrib/sdb/pgsql/pgsqldb.h deleted file mode 100644 index d0a1271ea27..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/pgsql/pgsqldb.h +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: pgsqldb.h,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -#include <isc/types.h> - -isc_result_t pgsqldb_init(void); - -void pgsqldb_clear(void); - diff --git a/external/mpl/bind/dist/contrib/sdb/pgsql/zonetodb.c b/external/mpl/bind/dist/contrib/sdb/pgsql/zonetodb.c deleted file mode 100644 index 3f1876d987b..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/pgsql/zonetodb.c +++ /dev/null @@ -1,275 +0,0 @@ -/* $NetBSD: zonetodb.c,v 1.3 2019/01/09 16:55:10 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -#include <stdlib.h> -#include <string.h> - -#include <isc/buffer.h> -#include <isc/hash.h> -#include <isc/mem.h> -#include <isc/print.h> -#include <isc/result.h> - -#include <dns/db.h> -#include <dns/dbiterator.h> -#include <dns/fixedname.h> -#include <dns/name.h> -#include <dns/rdata.h> -#include <dns/rdataset.h> -#include <dns/rdatasetiter.h> -#include <dns/rdatatype.h> -#include <dns/result.h> - -#include <pgsql/libpq-fe.h> - -/* - * Generate a PostgreSQL table from a zone. - * - * This is compiled this with something like the following (assuming bind9 has - * been installed): - * - * gcc -g `isc-config.sh --cflags isc dns` -c zonetodb.c - * gcc -g -o zonetodb zonetodb.o `isc-config.sh --libs isc dns` -lpq - */ - -PGconn *conn = NULL; -char *dbname, *dbtable; -char str[10240]; - -void -closeandexit(int status) { - if (conn != NULL) - PQfinish(conn); - exit(status); -} - -void -check_result(isc_result_t result, const char *message) { - if (result != ISC_R_SUCCESS) { - fprintf(stderr, "%s: %s\n", message, - isc_result_totext(result)); - closeandexit(1); - } -} - -/* - * Canonicalize a string before writing it to the database. - * "dest" must be an array of at least size 2*strlen(source) + 1. - */ -static void -quotestring(const unsigned char *source, unsigned char *dest) { - while (*source != 0) { - if (*source == '\'') - *dest++ = '\''; - else if (*source == '\\') - *dest++ = '\\'; - *dest++ = *source++; - } - *dest++ = 0; -} - -void -addrdata(dns_name_t *name, dns_ttl_t ttl, dns_rdata_t *rdata) { - unsigned char namearray[DNS_NAME_MAXTEXT + 1]; - unsigned char canonnamearray[2 * DNS_NAME_MAXTEXT + 1]; - unsigned char typearray[20]; - unsigned char canontypearray[40]; - unsigned char dataarray[2048]; - unsigned char canondataarray[4096]; - isc_buffer_t b; - isc_result_t result; - PGresult *res; - - isc_buffer_init(&b, namearray, sizeof(namearray) - 1); - result = dns_name_totext(name, true, &b); - check_result(result, "dns_name_totext"); - namearray[isc_buffer_usedlength(&b)] = 0; - quotestring((const unsigned char *)namearray, canonnamearray); - - isc_buffer_init(&b, typearray, sizeof(typearray) - 1); - result = dns_rdatatype_totext(rdata->type, &b); - check_result(result, "dns_rdatatype_totext"); - typearray[isc_buffer_usedlength(&b)] = 0; - quotestring((const unsigned char *)typearray, canontypearray); - - isc_buffer_init(&b, dataarray, sizeof(dataarray) - 1); - result = dns_rdata_totext(rdata, NULL, &b); - check_result(result, "dns_rdata_totext"); - dataarray[isc_buffer_usedlength(&b)] = 0; - quotestring((const unsigned char *)dataarray, canondataarray); - - snprintf(str, sizeof(str), - "INSERT INTO %s (NAME, TTL, RDTYPE, RDATA)" - " VALUES ('%s', %d, '%s', '%s')", - dbtable, canonnamearray, ttl, canontypearray, canondataarray); - printf("%s\n", str); - res = PQexec(conn, str); - if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) { - fprintf(stderr, "INSERT INTO command failed: %s\n", - PQresultErrorMessage(res)); - PQclear(res); - closeandexit(1); - } - PQclear(res); -} - -int -main(int argc, char **argv) { - char *porigin, *zonefile; - dns_fixedname_t forigin, fname; - dns_name_t *origin, *name; - dns_db_t *db = NULL; - dns_dbiterator_t *dbiter; - dns_dbnode_t *node; - dns_rdatasetiter_t *rdsiter; - dns_rdataset_t rdataset; - dns_rdata_t rdata = DNS_RDATA_INIT; - isc_mem_t *mctx = NULL; - isc_buffer_t b; - isc_result_t result; - PGresult *res; - - if (argc != 5) { - printf("usage: %s origin file dbname dbtable\n", argv[0]); - printf("Note that dbname must be an existing database.\n"); - exit(1); - } - - porigin = argv[1]; - zonefile = argv[2]; - dbname = argv[3]; - dbtable = argv[4]; - - dns_result_register(); - - mctx = NULL; - result = isc_mem_create(0, 0, &mctx); - check_result(result, "isc_mem_create"); - - isc_buffer_init(&b, porigin, strlen(porigin)); - isc_buffer_add(&b, strlen(porigin)); - origin = dns_fixedname_initname(&forigin); - result = dns_name_fromtext(origin, &b, dns_rootname, 0, NULL); - check_result(result, "dns_name_fromtext"); - - db = NULL; - result = dns_db_create(mctx, "rbt", origin, dns_dbtype_zone, - dns_rdataclass_in, 0, NULL, &db); - check_result(result, "dns_db_create"); - - result = dns_db_load(db, zonefile, dns_masterformat_text, 0); - if (result == DNS_R_SEENINCLUDE) - result = ISC_R_SUCCESS; - check_result(result, "dns_db_load"); - - printf("Connecting to '%s'\n", dbname); - conn = PQsetdb(NULL, NULL, NULL, NULL, dbname); - if (PQstatus(conn) == CONNECTION_BAD) { - fprintf(stderr, "Connection to database '%s' failed: %s\n", - dbname, PQerrorMessage(conn)); - closeandexit(1); - } - - snprintf(str, sizeof(str), - "DROP TABLE %s", dbtable); - printf("%s\n", str); - res = PQexec(conn, str); - if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) - fprintf(stderr, "DROP TABLE command failed: %s\n", - PQresultErrorMessage(res)); - PQclear(res); - - snprintf(str, sizeof(str), "BEGIN"); - printf("%s\n", str); - res = PQexec(conn, str); - if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) { - fprintf(stderr, "BEGIN command failed: %s\n", - PQresultErrorMessage(res)); - PQclear(res); - closeandexit(1); - } - PQclear(res); - - snprintf(str, sizeof(str), - "CREATE TABLE %s " - "(NAME TEXT, TTL INTEGER, RDTYPE TEXT, RDATA TEXT)", - dbtable); - printf("%s\n", str); - res = PQexec(conn, str); - if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) { - fprintf(stderr, "CREATE TABLE command failed: %s\n", - PQresultErrorMessage(res)); - PQclear(res); - closeandexit(1); - } - PQclear(res); - - dbiter = NULL; - result = dns_db_createiterator(db, 0, &dbiter); - check_result(result, "dns_db_createiterator()"); - - result = dns_dbiterator_first(dbiter); - check_result(result, "dns_dbiterator_first"); - - name = dns_fixedname_initname(&fname); - dns_rdataset_init(&rdataset); - dns_rdata_init(&rdata); - - while (result == ISC_R_SUCCESS) { - node = NULL; - result = dns_dbiterator_current(dbiter, &node, name); - if (result == ISC_R_NOMORE) - break; - check_result(result, "dns_dbiterator_current"); - - rdsiter = NULL; - result = dns_db_allrdatasets(db, node, NULL, 0, &rdsiter); - check_result(result, "dns_db_allrdatasets"); - - result = dns_rdatasetiter_first(rdsiter); - - while (result == ISC_R_SUCCESS) { - dns_rdatasetiter_current(rdsiter, &rdataset); - result = dns_rdataset_first(&rdataset); - check_result(result, "dns_rdataset_first"); - while (result == ISC_R_SUCCESS) { - dns_rdataset_current(&rdataset, &rdata); - addrdata(name, rdataset.ttl, &rdata); - dns_rdata_reset(&rdata); - result = dns_rdataset_next(&rdataset); - } - dns_rdataset_disassociate(&rdataset); - result = dns_rdatasetiter_next(rdsiter); - } - dns_rdatasetiter_destroy(&rdsiter); - dns_db_detachnode(db, &node); - result = dns_dbiterator_next(dbiter); - } - - snprintf(str, sizeof(str), "COMMIT TRANSACTION"); - printf("%s\n", str); - res = PQexec(conn, str); - if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) { - fprintf(stderr, "COMMIT command failed: %s\n", - PQresultErrorMessage(res)); - PQclear(res); - closeandexit(1); - } - PQclear(res); - dns_dbiterator_destroy(&dbiter); - dns_db_detach(&db); - isc_mem_destroy(&mctx); - closeandexit(0); - exit(0); -} diff --git a/external/mpl/bind/dist/contrib/sdb/sqlite/README.sdb_sqlite b/external/mpl/bind/dist/contrib/sdb/sqlite/README.sdb_sqlite deleted file mode 100644 index 36128e1926c..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/sqlite/README.sdb_sqlite +++ /dev/null @@ -1,67 +0,0 @@ - SQLite BIND SDB driver - -The SQLite BIND SDB "driver" is intended as an alternative both to the -pgsqldb and dirdb drivers, for situations that would like the management -simplicity and convenience of single filesystem files, with the additional -capability of SQL databases. It is also intended as an alternative to -the standard dynamic DNS update capability in bind, which effectively -requires use of DNSSEC keys for authorization and is limited to 'nsupdate' -for updates. An sqlite database, by contrast, uses and requires only -normal filesystem permissions, and may be updated however a typical SQLite -database might be updated, e.g., via a web service with an SQLite backend. - -This driver is not considered suitable for very high volume public -nameserver use, while likely useful for smaller private nameserver -applications, whether or not in a production environment. It should -generally be suitable wherever SQLite is preferable over larger database -engines, and not suitable where SQLite is not preferable. - -Usage: - -o Use the named_sdb process ( put ENABLE_SDB=yes in /etc/sysconfig/named ) - -o Edit your named.conf to contain a database zone, eg.: - -zone "mydomain.net." IN { - type master; - database "sqlite /etc/named.d/mydomain.db mydomain"; - # ^- DB file ^-Table -}; - -o Create the database zone table - The table must contain the columns "name", "rdtype", and "rdata", and - is expected to contain a properly constructed zone. The program - "zone2sqlite" creates such a table. - - zone2sqlite usage: - - zone2sqlite origin zonefile dbfile dbtable - - where - origin : zone origin, eg "mydomain.net." - zonefile : master zone database file, eg. mydomain.net.zone - dbfile : name of SQLite database file - dbtable : name of table in database - ---- -# mydomain.net.zone: -$TTL 1H -@ SOA localhost. root.localhost. ( 1 - 3H - 1H - 1W - 1H ) - NS localhost. -host1 A 192.168.2.1 -host2 A 192.168.2.2 -host3 A 192.168.2.3 -host4 A 192.168.2.4 -host5 A 192.168.2.5 -host6 A 192.168.2.6 -host7 A 192.168.2.7 ---- - -# zone2sqlite mydomain.net. mydomain.net.zone mydomain.net.db mydomain - -will create/update the 'mydomain' table in database file 'mydomain.net.db'. - diff --git a/external/mpl/bind/dist/contrib/sdb/sqlite/sqlitedb.c b/external/mpl/bind/dist/contrib/sdb/sqlite/sqlitedb.c deleted file mode 100644 index 977d49405e1..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/sqlite/sqlitedb.c +++ /dev/null @@ -1,327 +0,0 @@ -/* $NetBSD: sqlitedb.c,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * Copyright (C) 2007, 2016 Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - - -#include <config.h> - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> - -#include <sqlite3.h> - -#include <isc/mem.h> -#include <isc/print.h> -#include <isc/result.h> -#include <isc/util.h> - -#include <dns/sdb.h> -#include <dns/result.h> - -#include <named/globals.h> - -#include "sqlitedb.h" - -/* - * A simple database driver that interfaces to a SQLite database. - * - * The table must contain the fields "name", "rdtype", and "rdata", and - * is expected to contain a properly constructed zone. The program "zonetodb" - * creates such a table. - */ - -static dns_sdbimplementation_t *sqlitedb = NULL; - -typedef struct _dbinfo { - sqlite3 *db; - char *filename; - char *table; -} dbinfo_t; - - -static isc_result_t -db_connect(dbinfo_t *dbi) -{ - if (sqlite3_open(dbi->filename, &dbi->db) == SQLITE_OK) { - return (ISC_R_SUCCESS); - } else { - /* a connection is returned even if the open fails */ - sqlite3_close(dbi->db); - dbi->db = NULL; - return (ISC_R_FAILURE); - } -} - - -typedef struct _lookup_parm_t { - int i; - dns_sdblookup_t *lookup; - isc_result_t result; -} lookup_parm_t; - - -static int -sqlitedb_lookup_cb(void *p, int cc, char **cv, char **cn) -{ - lookup_parm_t *parm = p; - dns_ttl_t ttl; - char *endp; - - /* FIXME - check these(num/names); I'm assuming a mapping for now */ - char *ttlstr = cv[0]; - char *type = cv[1]; - char *data = cv[2]; - - UNUSED(cc); - UNUSED(cn); - - ttl = strtol(ttlstr, &endp, 10); - if (*endp) { - parm->result = DNS_R_BADTTL; - return 1; - } - - parm->result = dns_sdb_putrr(parm->lookup, type, ttl, data); - - if (parm->result != ISC_R_SUCCESS) - return 1; - - (parm->i)++; - - return 0; -} - - -#ifdef DNS_CLIENTINFO_VERSION -static isc_result_t -sqlitedb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods, - dns_clientinfo_t *clientinfo) -#else -static isc_result_t -sqlitedb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup) -#endif /* DNS_CLIENTINFO_VERSION */ -/* - * synchronous absolute name lookup - */ -{ - dbinfo_t *dbi = (dbinfo_t *) dbdata; - char *sql; - lookup_parm_t parm = { 0, lookup, ISC_R_SUCCESS }; - char *errmsg = NULL; - int result; - - UNUSED(zone); -#ifdef DNS_CLIENTINFO_VERSION - UNUSED(methods); - UNUSED(clientinfo); -#endif /* DNS_CLIENTINFO_VERSION */ - - sql = sqlite3_mprintf( - "SELECT TTL,RDTYPE,RDATA FROM \"%q\" WHERE " - "lower(NAME) = lower('%q')", - dbi->table, name); - - result = sqlite3_exec(dbi->db, sql, - &sqlitedb_lookup_cb, &parm, - &errmsg); - sqlite3_free(sql); - - if (result != SQLITE_OK) - return (ISC_R_FAILURE); - if (parm.i == 0) - return (ISC_R_NOTFOUND); - - return (ISC_R_SUCCESS); -} - - -typedef struct _allnodes_parm_t { - int i; - dns_sdballnodes_t *allnodes; - isc_result_t result; -} allnodes_parm_t; - - -static int -sqlitedb_allnodes_cb(void *p, int cc, char **cv, char **cn) -{ - allnodes_parm_t *parm = p; - dns_ttl_t ttl; - char *endp; - - /* FIXME - check these(num/names); I'm assuming a mapping for now */ - char *ttlstr = cv[0]; - char *name = cv[1]; - char *type = cv[2]; - char *data = cv[3]; - - UNUSED(cc); - UNUSED(cn); - - ttl = strtol(ttlstr, &endp, 10); - if (*endp) { - parm->result = DNS_R_BADTTL; - return 1; - } - - parm->result = dns_sdb_putnamedrr(parm->allnodes, name, type, ttl, data); - - if (parm->result != ISC_R_SUCCESS) - return 1; - - (parm->i)++; - - return 0; -} - - -static isc_result_t -sqlitedb_allnodes(const char *zone, - void *dbdata, - dns_sdballnodes_t *allnodes) -{ - dbinfo_t *dbi = (dbinfo_t *) dbdata; - char *sql; - allnodes_parm_t parm = { 0, allnodes, ISC_R_SUCCESS }; - char *errmsg = NULL; - int result; - - UNUSED(zone); - - sql = sqlite3_mprintf( - "SELECT TTL,NAME,RDTYPE,RDATA FROM \"%q\" ORDER BY NAME", - dbi->table); - - result = sqlite3_exec(dbi->db, sql, - &sqlitedb_allnodes_cb, &parm, - &errmsg); - sqlite3_free(sql); - - if (result != SQLITE_OK) - return (ISC_R_FAILURE); - if (parm.i == 0) - return (ISC_R_NOTFOUND); - - return (ISC_R_SUCCESS); -} - - -static void -sqlitedb_destroy(const char *zone, void *driverdata, void **dbdata) -{ - dbinfo_t *dbi = *dbdata; - - UNUSED(zone); - UNUSED(driverdata); - - if (dbi->db != NULL) - sqlite3_close(dbi->db); - if (dbi->table != NULL) - isc_mem_free(ns_g_mctx, dbi->table); - if (dbi->filename != NULL) - isc_mem_free(ns_g_mctx, dbi->filename); - - isc_mem_put(ns_g_mctx, dbi, sizeof(dbinfo_t)); -} - - -#define STRDUP_OR_FAIL(target, source) \ - do { \ - target = isc_mem_strdup(ns_g_mctx, source); \ - if (target == NULL) { \ - result = ISC_R_NOMEMORY; \ - goto cleanup; \ - } \ - } while (/*CONSTCOND*/0); - -/* - * Create a connection to the database and save any necessary information - * in dbdata. - * - * argv[0] is the name of the database file - * argv[1] is the name of the table - */ -static isc_result_t -sqlitedb_create(const char *zone, - int argc, char **argv, - void *driverdata, void **dbdata) -{ - dbinfo_t *dbi; - isc_result_t result; - - UNUSED(zone); - UNUSED(driverdata); - - if (argc < 2) - return (ISC_R_FAILURE); - - dbi = isc_mem_get(ns_g_mctx, sizeof(dbinfo_t)); - if (dbi == NULL) - return (ISC_R_NOMEMORY); - dbi->db = NULL; - dbi->filename = NULL; - dbi->table = NULL; - - STRDUP_OR_FAIL(dbi->filename, argv[0]); - STRDUP_OR_FAIL(dbi->table, argv[1]); - - result = db_connect(dbi); - if (result != ISC_R_SUCCESS) - goto cleanup; - - *dbdata = dbi; - return (ISC_R_SUCCESS); - -cleanup: - sqlitedb_destroy(zone, driverdata, (void **)&dbi); - return (result); -} - - -/* - * Since the SQL database corresponds to a zone, the authority data should - * be returned by the lookup() function. Therefore the authority() function - * is NULL. - */ -static dns_sdbmethods_t sqlitedb_methods = { - sqlitedb_lookup, - NULL, /* authority */ - sqlitedb_allnodes, - sqlitedb_create, - sqlitedb_destroy, - NULL /* lookup2 */ -}; - - -/* - * Wrapper around dns_sdb_register(). - */ -isc_result_t -sqlitedb_init(void) -{ - unsigned int flags; - flags = 0; - return (dns_sdb_register("sqlite", &sqlitedb_methods, NULL, flags, - ns_g_mctx, &sqlitedb)); -} - - -/* - * Wrapper around dns_sdb_unregister(). - */ -void -sqlitedb_clear(void) -{ - if (sqlitedb != NULL) - dns_sdb_unregister(&sqlitedb); -} diff --git a/external/mpl/bind/dist/contrib/sdb/sqlite/sqlitedb.h b/external/mpl/bind/dist/contrib/sdb/sqlite/sqlitedb.h deleted file mode 100644 index 17964905a54..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/sqlite/sqlitedb.h +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: sqlitedb.h,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * Copyright (C) 2000-2002, 2016 Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - - -#include <isc/types.h> - -isc_result_t sqlitedb_init(void); - -void sqlitedb_clear(void); - diff --git a/external/mpl/bind/dist/contrib/sdb/sqlite/zone2sqlite.c b/external/mpl/bind/dist/contrib/sdb/sqlite/zone2sqlite.c deleted file mode 100644 index aedfbc6a8bf..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/sqlite/zone2sqlite.c +++ /dev/null @@ -1,290 +0,0 @@ -/* $NetBSD: zone2sqlite.c,v 1.3 2019/01/09 16:55:10 christos Exp $ */ - -/* - * Copyright (C) 2007, 2016 Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include <stdlib.h> -#include <string.h> - -#include <isc/buffer.h> -#include <isc/mem.h> -#include <isc/print.h> -#include <isc/result.h> - -#include <dns/db.h> -#include <dns/dbiterator.h> -#include <dns/fixedname.h> -#include <isc/hash.h> -#include <dns/name.h> -#include <dns/rdata.h> -#include <dns/rdataset.h> -#include <dns/rdatasetiter.h> -#include <dns/rdatatype.h> -#include <dns/result.h> - -#include <sqlite3.h> - -#ifndef UNUSED -#define UNUSED(x) (void)&(x) -#endif - -/* - * Generate an SQLite table from a zone. - */ - -typedef struct _dbinfo { - sqlite3 *db; - char *filename; - char *table; -} dbinfo_t; - -dbinfo_t dbi = { NULL, NULL, NULL }; - - -static void -closeandexit(int status) -{ - if (dbi.db) { - sqlite3_close(dbi.db); - dbi.db = NULL; - } - exit(status); -} - -static void -check_result(isc_result_t result, const char *message) -{ - if (result != ISC_R_SUCCESS) { - fprintf(stderr, "%s: %s\n", message, - isc_result_totext(result)); - closeandexit(1); - } -} - -static isc_result_t -db_connect(dbinfo_t *dbi) -{ - if (sqlite3_open(dbi->filename, &dbi->db) == SQLITE_OK) { - return (ISC_R_SUCCESS); - } else { - /* a connection is returned even if the open fails */ - sqlite3_close(dbi->db); - dbi->db = NULL; - return (ISC_R_FAILURE); - } -} - -static int -add_rdata_cb(void *parm, int cc, char **cv, char **cn) -{ - UNUSED(parm); - UNUSED(cc); - UNUSED(cv); - UNUSED(cn); - - return 0; -} - - -static void -addrdata(dns_name_t *name, dns_ttl_t ttl, dns_rdata_t *rdata) -{ - unsigned char namearray[DNS_NAME_MAXTEXT + 1]; - unsigned char typearray[20]; - unsigned char dataarray[2048]; - isc_buffer_t b; - isc_result_t result; - char *sql; - char *errmsg = NULL; - int res; - - isc_buffer_init(&b, namearray, sizeof(namearray) - 1); - result = dns_name_totext(name, true, &b); - check_result(result, "dns_name_totext"); - namearray[isc_buffer_usedlength(&b)] = 0; - - isc_buffer_init(&b, typearray, sizeof(typearray) - 1); - result = dns_rdatatype_totext(rdata->type, &b); - check_result(result, "dns_rdatatype_totext"); - typearray[isc_buffer_usedlength(&b)] = 0; - - isc_buffer_init(&b, dataarray, sizeof(dataarray) - 1); - result = dns_rdata_totext(rdata, NULL, &b); - check_result(result, "dns_rdata_totext"); - dataarray[isc_buffer_usedlength(&b)] = 0; - - sql = sqlite3_mprintf( - "INSERT INTO %Q (NAME, TTL, RDTYPE, RDATA)" - " VALUES ('%q', %d, '%q', '%q') ", - dbi.table, - namearray, ttl, typearray, dataarray); - printf("%s\n", sql); - res = sqlite3_exec(dbi.db, sql, add_rdata_cb, NULL, &errmsg); - sqlite3_free(sql); - - if (res != SQLITE_OK) { - fprintf(stderr, "INSERT failed: %s\n", errmsg); - closeandexit(1); - } -} - -int -main(int argc, char *argv[]) -{ - char *sql; - int res; - char *errmsg = NULL; - char *porigin, *zonefile; - dns_fixedname_t forigin, fname; - dns_name_t *origin, *name; - dns_db_t *db = NULL; - dns_dbiterator_t *dbiter; - dns_dbnode_t *node; - dns_rdatasetiter_t *rdsiter; - dns_rdataset_t rdataset; - dns_rdata_t rdata = DNS_RDATA_INIT; - isc_mem_t *mctx = NULL; - isc_buffer_t b; - isc_result_t result; - - if (argc != 5) { - printf("usage: %s <zone> <zonefile> <dbfile> <dbtable>\n", argv[0]); - exit(1); - } - - porigin = argv[1]; - zonefile = argv[2]; - - dbi.filename = argv[3]; - dbi.table = argv[4]; - - dns_result_register(); - - result = isc_mem_create(0, 0, &mctx); - check_result(result, "isc_mem_create"); - - isc_buffer_init(&b, porigin, strlen(porigin)); - isc_buffer_add(&b, strlen(porigin)); - origin = dns_fixedname_initname(&forigin); - result = dns_name_fromtext(origin, &b, dns_rootname, 0, NULL); - check_result(result, "dns_name_fromtext"); - - db = NULL; - result = dns_db_create(mctx, "rbt", origin, dns_dbtype_zone, - dns_rdataclass_in, 0, NULL, &db); - check_result(result, "dns_db_create"); - - result = dns_db_load(db, zonefile, dns_masterformat_text, 0); - if (result == DNS_R_SEENINCLUDE) - result = ISC_R_SUCCESS; - check_result(result, "dns_db_load"); - - printf("Connecting to '%s'\n", dbi.filename); - - if ((result = db_connect(&dbi)) != ISC_R_SUCCESS) { - fprintf(stderr, "Connection to database '%s' failed\n", - dbi.filename); - closeandexit(1); - } - - sql = sqlite3_mprintf("DROP TABLE %Q ", dbi.table); - printf("%s\n", sql); - res = sqlite3_exec(dbi.db, sql, NULL, NULL, &errmsg); - sqlite3_free(sql); -#if 0 - if (res != SQLITE_OK) { - fprintf(stderr, "DROP TABLE %s failed: %s\n", - dbi.table, errmsg); - } -#endif - -#if 0 - sql = sqlite3_mprintf(sql, "BEGIN TRANSACTION"); - printf("%s\n", sql); - res = sqlite3_exec(dbi.db, sql, NULL, NULL, &errmsg); - sqlite3_free(sql); - if (res != SQLITE_OK) { - fprintf(stderr, "BEGIN TRANSACTION failed: %s\n", errmsg); - closeandexit(1); - } -#endif - - sql = sqlite3_mprintf( - "CREATE TABLE %Q " - "(NAME TEXT, TTL INTEGER, RDTYPE TEXT, RDATA TEXT) ", - dbi.table); - printf("%s\n", sql); - res = sqlite3_exec(dbi.db, sql, NULL, NULL, &errmsg); - sqlite3_free(sql); - if (res != SQLITE_OK) { - fprintf(stderr, "CREATE TABLE %s failed: %s\n", - dbi.table, errmsg); - closeandexit(1); - } - - dbiter = NULL; - result = dns_db_createiterator(db, 0, &dbiter); - check_result(result, "dns_db_createiterator()"); - - result = dns_dbiterator_first(dbiter); - check_result(result, "dns_dbiterator_first"); - - name = dns_fixedname_initname(&fname); - dns_rdataset_init(&rdataset); - dns_rdata_init(&rdata); - - while (result == ISC_R_SUCCESS) { - node = NULL; - result = dns_dbiterator_current(dbiter, &node, name); - if (result == ISC_R_NOMORE) - break; - check_result(result, "dns_dbiterator_current"); - - rdsiter = NULL; - result = dns_db_allrdatasets(db, node, NULL, 0, &rdsiter); - check_result(result, "dns_db_allrdatasets"); - - result = dns_rdatasetiter_first(rdsiter); - - while (result == ISC_R_SUCCESS) { - dns_rdatasetiter_current(rdsiter, &rdataset); - result = dns_rdataset_first(&rdataset); - check_result(result, "dns_rdataset_first"); - while (result == ISC_R_SUCCESS) { - dns_rdataset_current(&rdataset, &rdata); - addrdata(name, rdataset.ttl, &rdata); - dns_rdata_reset(&rdata); - result = dns_rdataset_next(&rdataset); - } - dns_rdataset_disassociate(&rdataset); - result = dns_rdatasetiter_next(rdsiter); - } - dns_rdatasetiter_destroy(&rdsiter); - dns_db_detachnode(db, &node); - result = dns_dbiterator_next(dbiter); - } - -#if 0 - sql = sqlite3_mprintf(sql, "COMMIT TRANSACTION "); - printf("%s\n", sql); - res = sqlite3_exec(dbi.db, sql, NULL, NULL, &errmsg); - sqlite3_free(sql); - if (res != SQLITE_OK) { - fprintf(stderr, "COMMIT TRANSACTION failed: %s\n", errmsg); - closeandexit(1); - } -#endif - - dns_dbiterator_destroy(&dbiter); - dns_db_detach(&db); - isc_mem_destroy(&mctx); - - closeandexit(0); - - exit(0); -} diff --git a/external/mpl/bind/dist/contrib/sdb/tcl/lookup.tcl b/external/mpl/bind/dist/contrib/sdb/tcl/lookup.tcl deleted file mode 100644 index 7672ed1a04d..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/tcl/lookup.tcl +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# See the COPYRIGHT file distributed with this work for additional -# information regarding copyright ownership. - -# -# Sample lookup procedure for tcldb -# -# This lookup procedure defines zones with identical SOA, NS, and MX -# records at the apex and a single A record that varies from zone to -# zone at the name "www". -# -# Something like this could be used by a web hosting company to serve -# a number of domains without needing to create a separate master file -# for each domain. Instead, all per-zone data (in this case, a single -# IP address) specified in the named.conf file like this: -# -# zone "a.com." { type master; database "tcl 10.0.0.42"; }; -# zone "b.com." { type master; database "tcl 10.0.0.99"; }; -# -# Since the tcldb driver doesn't support zone transfers, there should -# be at least two identically configured master servers. In the -# example below, they are assumed to be called ns1.isp.nil and -# ns2.isp.nil. -# - -proc lookup {zone name} { - global dbargs - switch -- $name { - @ { return [list \ - {SOA 86400 "ns1.isp.nil. hostmaster.isp.nil. \ - 1 3600 1800 1814400 3600"} \ - {NS 86400 "ns1.isp.nil."} \ - {NS 86400 "ns2.isp.nil."} \ - {MX 86400 "10 mail.isp.nil."} ] } - www { return [list [list A 3600 $dbargs($zone)] ] } - } - return NXDOMAIN -} diff --git a/external/mpl/bind/dist/contrib/sdb/tcl/tcldb.c b/external/mpl/bind/dist/contrib/sdb/tcl/tcldb.c deleted file mode 100644 index a490d85277a..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/tcl/tcldb.c +++ /dev/null @@ -1,240 +0,0 @@ -/* $NetBSD: tcldb.c,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -/* - * A simple database driver that calls a Tcl procedure to define - * the contents of the DNS namespace. The procedure is loaded - * from the file lookup.tcl; look at the comments there for - * more information. - */ - -#include <config.h> - -#include <string.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/stat.h> - -#include <isc/mem.h> -#include <isc/print.h> -#include <isc/result.h> -#include <isc/util.h> - -#include <dns/log.h> -#include <dns/sdb.h> - -#include <named/globals.h> - -#include <tcl.h> - -#include <tcldb.h> - -#define CHECK(op) \ - do { result = (op); \ - if (result != ISC_R_SUCCESS) return (result); \ - } while (/*CONSTCOND*/0) - -typedef struct tcldb_driver { - isc_mem_t *mctx; - Tcl_Interp *interp; -} tcldb_driver_t; - -static tcldb_driver_t *the_driver = NULL; - -static dns_sdbimplementation_t *tcldb = NULL; - -static isc_result_t -tcldb_driver_create(isc_mem_t *mctx, tcldb_driver_t **driverp) { - int tclres; - isc_result_t result = ISC_R_SUCCESS; - tcldb_driver_t *driver = isc_mem_get(mctx, sizeof(tcldb_driver_t)); - if (driver == NULL) - return (ISC_R_NOMEMORY); - driver->mctx = mctx; - driver->interp = Tcl_CreateInterp(); - - tclres = Tcl_EvalFile(driver->interp, (char *) "lookup.tcl"); - if (tclres != TCL_OK) { - isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, - DNS_LOGMODULE_SDB, ISC_LOG_ERROR, - "initializing tcldb: " - "loading 'lookup.tcl' failed: %s", - driver->interp->result); - result = ISC_R_FAILURE; - goto cleanup; - } - *driverp = driver; - return (ISC_R_SUCCESS); - - cleanup: - isc_mem_put(mctx, driver, sizeof(tcldb_driver_t)); - return (result); - -} - -static void -tcldb_driver_destroy(tcldb_driver_t **driverp) { - tcldb_driver_t *driver = *driverp; - Tcl_DeleteInterp(driver->interp); - isc_mem_put(driver->mctx, driver, sizeof(tcldb_driver_t)); -} - -/* - * Perform a lookup, by invoking the Tcl procedure "lookup". - */ -#ifdef DNS_CLIENTINFO_VERSION -static isc_result_t -tcldb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods, - dns_clientinfo_t *clientinfo) -#else -static isc_result_t -tcldb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup) -#endif /* DNS_CLIENTINFO_VERSION */ -{ - isc_result_t result = ISC_R_SUCCESS; - int tclres; - int rrc; /* RR count */ - char **rrv; /* RR vector */ - int i; - char *cmdv[3]; - char *cmd; - -#ifdef DNS_CLIENTINFO_VERSION - UNUSED(methods); - UNUSED(clientinfo); -#endif /* DNS_CLIENTINFO_VERSION */ - - tcldb_driver_t *driver = (tcldb_driver_t *) dbdata; - - cmdv[0] = "lookup"; - cmdv[1] = zone; - cmdv[2] = name; - cmd = Tcl_Merge(3, cmdv); - tclres = Tcl_Eval(driver->interp, cmd); - Tcl_Free(cmd); - - if (tclres != TCL_OK) { - isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, - DNS_LOGMODULE_SDB, ISC_LOG_ERROR, - "zone '%s': tcl lookup function failed: %s", - zone, driver->interp->result); - return (ISC_R_FAILURE); - } - - if (strcmp(driver->interp->result, "NXDOMAIN") == 0) { - result = ISC_R_NOTFOUND; - goto fail; - } - - tclres = Tcl_SplitList(driver->interp, driver->interp->result, - &rrc, &rrv); - if (tclres != TCL_OK) - goto malformed; - - for (i = 0; i < rrc; i++) { - isc_result_t tmpres; - int fieldc; /* Field count */ - char **fieldv; /* Field vector */ - tclres = Tcl_SplitList(driver->interp, rrv[i], - &fieldc, &fieldv); - if (tclres != TCL_OK) { - tmpres = ISC_R_FAILURE; - goto failrr; - } - if (fieldc != 3) - goto malformed; - tmpres = dns_sdb_putrr(lookup, fieldv[0], atoi(fieldv[1]), - fieldv[2]); - Tcl_Free((char *) fieldv); - failrr: - if (tmpres != ISC_R_SUCCESS) - result = tmpres; - } - Tcl_Free((char *) rrv); - if (result == ISC_R_SUCCESS) - return (result); - - malformed: - isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, - DNS_LOGMODULE_SDB, ISC_LOG_ERROR, - "zone '%s': " - "malformed return value from tcl lookup function: %s", - zone, driver->interp->result); - result = ISC_R_FAILURE; - fail: - return (result); -} - -/* - * Set up per-zone state. In our case, the database arguments of the - * zone are collected into a Tcl list and assigned to an element of - * the global array "dbargs". - */ -static isc_result_t -tcldb_create(const char *zone, int argc, char **argv, - void *driverdata, void **dbdata) -{ - tcldb_driver_t *driver = (tcldb_driver_t *) driverdata; - - char *list = Tcl_Merge(argc, argv); - - Tcl_SetVar2(driver->interp, (char *) "dbargs", (char *) zone, list, 0); - - Tcl_Free(list); - - *dbdata = driverdata; - - return (ISC_R_SUCCESS); -} - -/* - * This driver does not support zone transfer, so allnodes() is NULL. - */ -static dns_sdbmethods_t tcldb_methods = { - tcldb_lookup, - NULL, /* authority */ - NULL, /* allnodes */ - tcldb_create, - NULL, /* destroy */ - NULL /* lookup2 */ -}; - -/* - * Initialize the tcldb driver. - */ -isc_result_t -tcldb_init(void) { - isc_result_t result; - int flags = DNS_SDBFLAG_RELATIVEOWNER | DNS_SDBFLAG_RELATIVERDATA; - - result = tcldb_driver_create(ns_g_mctx, &the_driver); - if (result != ISC_R_SUCCESS) - return (result); - - return (dns_sdb_register("tcl", &tcldb_methods, the_driver, flags, - ns_g_mctx, &tcldb)); -} - -/* - * Wrapper around dns_sdb_unregister(). - */ -void -tcldb_clear(void) { - if (tcldb != NULL) - dns_sdb_unregister(&tcldb); - if (the_driver != NULL) - tcldb_driver_destroy(&the_driver); -} diff --git a/external/mpl/bind/dist/contrib/sdb/tcl/tcldb.h b/external/mpl/bind/dist/contrib/sdb/tcl/tcldb.h deleted file mode 100644 index 3ca1a004740..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/tcl/tcldb.h +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: tcldb.h,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -#include <isc/types.h> - -isc_result_t tcldb_init(void); - -void tcldb_clear(void); - diff --git a/external/mpl/bind/dist/contrib/sdb/time/timedb.c b/external/mpl/bind/dist/contrib/sdb/time/timedb.c deleted file mode 100644 index be9690a6799..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/time/timedb.c +++ /dev/null @@ -1,150 +0,0 @@ -/* $NetBSD: timedb.c,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -/* - * A simple database driver that enables the server to return the - * current time in a DNS record. - */ - -#include <config.h> - -#include <string.h> -#include <stdio.h> -#include <time.h> - -#include <isc/print.h> -#include <isc/result.h> -#include <isc/util.h> - -#include <dns/sdb.h> - -#include <named/globals.h> - -#include "timedb.h" - -static dns_sdbimplementation_t *timedb = NULL; - -/* - * This database operates on relative names. - * - * "time" and "@" return the time in a TXT record. - * "clock" is a CNAME to "time" - * "current" is a DNAME to "@" (try time.current.time) - */ -#ifdef DNS_CLIENTINFO_VERSION -static isc_result_t -timedb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods, - dns_clientinfo_t *clientinfo) -#else -static isc_result_t -timedb_lookup(const char *zone, const char *name, void *dbdata, - dns_sdblookup_t *lookup) -#endif /* DNS_CLIENTINFO_VERSION */ -{ - isc_result_t result; - - UNUSED(zone); - UNUSED(dbdata); -#ifdef DNS_CLIENTINFO_VERSION - UNUSED(methods); - UNUSED(clientinfo); -#endif /* DNS_CLIENTINFO_VERSION */ - - if (strcmp(name, "@") == 0 || strcmp(name, "time") == 0) { - time_t now = time(NULL); - char buf[100]; - int n; - - /* - * Call ctime to create the string, put it in quotes, and - * remove the trailing newline. - */ - n = snprintf(buf, sizeof(buf), "\"%s", ctime(&now)); - if (n < 0) - return (ISC_R_FAILURE); - buf[n - 1] = '\"'; - result = dns_sdb_putrr(lookup, "txt", 1, buf); - if (result != ISC_R_SUCCESS) - return (ISC_R_FAILURE); - } else if (strcmp(name, "clock") == 0) { - result = dns_sdb_putrr(lookup, "cname", 1, "time"); - if (result != ISC_R_SUCCESS) - return (ISC_R_FAILURE); - } else if (strcmp(name, "current") == 0) { - result = dns_sdb_putrr(lookup, "dname", 1, "@"); - if (result != ISC_R_SUCCESS) - return (ISC_R_FAILURE); - } else - return (ISC_R_NOTFOUND); - - return (ISC_R_SUCCESS); -} - -/* - * lookup() does not return SOA or NS records, so authority() must be defined. - */ -static isc_result_t -timedb_authority(const char *zone, void *dbdata, dns_sdblookup_t *lookup) { - isc_result_t result; - - UNUSED(zone); - UNUSED(dbdata); - - result = dns_sdb_putsoa(lookup, "localhost.", "root.localhost.", 0); - if (result != ISC_R_SUCCESS) - return (ISC_R_FAILURE); - - result = dns_sdb_putrr(lookup, "ns", 86400, "ns1.localdomain."); - if (result != ISC_R_SUCCESS) - return (ISC_R_FAILURE); - result = dns_sdb_putrr(lookup, "ns", 86400, "ns2.localdomain."); - if (result != ISC_R_SUCCESS) - return (ISC_R_FAILURE); - - return (ISC_R_SUCCESS); -} - -/* - * This zone does not support zone transfer, so allnodes() is NULL. There - * is no database specific data, so create() and destroy() are NULL. - */ -static dns_sdbmethods_t timedb_methods = { - timedb_lookup, - timedb_authority, - NULL, /* allnodes */ - NULL, /* create */ - NULL, /* destroy */ - NULL /* lookup2 */ -}; - -/* - * Wrapper around dns_sdb_register(). - */ -isc_result_t -timedb_init(void) { - unsigned int flags; - flags = DNS_SDBFLAG_RELATIVEOWNER | DNS_SDBFLAG_RELATIVERDATA; - return (dns_sdb_register("time", &timedb_methods, NULL, flags, - ns_g_mctx, &timedb)); -} - -/* - * Wrapper around dns_sdb_unregister(). - */ -void -timedb_clear(void) { - if (timedb != NULL) - dns_sdb_unregister(&timedb); -} diff --git a/external/mpl/bind/dist/contrib/sdb/time/timedb.h b/external/mpl/bind/dist/contrib/sdb/time/timedb.h deleted file mode 100644 index bece3afc01f..00000000000 --- a/external/mpl/bind/dist/contrib/sdb/time/timedb.h +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: timedb.h,v 1.2 2018/08/12 13:02:34 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -#include <isc/types.h> - -isc_result_t timedb_init(void); - -void timedb_clear(void); - diff --git a/external/mpl/bind/dist/doc/misc/sdb b/external/mpl/bind/dist/doc/misc/sdb deleted file mode 100644 index bc9844954ba..00000000000 --- a/external/mpl/bind/dist/doc/misc/sdb +++ /dev/null @@ -1,167 +0,0 @@ -Copyright (C) Internet Systems Consortium, Inc. ("ISC") - -See COPYRIGHT in the source root or http://isc.org/copyright.html for terms. - -Using the BIND 9 Simplified Database Interface - -This document describes the care and feeding of the BIND 9 Simplified -Database Interface, which allows you to extend BIND 9 with new ways -of obtaining the data that is published as DNS zones. - - -The Original BIND 9 Database Interface - -BIND 9 has a well-defined "back-end database interface" that makes it -possible to replace the component of the name server responsible for -the storage and retrieval of zone data, called the "database", on a -per-zone basis. The default database is an in-memory, red-black-tree -data structure commonly referred to as "rbtdb", but it is possible to -write drivers to support any number of alternative database -technologies such as in-memory hash tables, application specific -persistent on-disk databases, object databases, or relational -databases. - -The original BIND 9 database interface defined in <dns/db.h> is -designed to efficiently support the full set of database functionality -needed by a name server that implements the complete DNS protocols, -including features such as zone transfers, dynamic update, and DNSSEC. -Each of these aspects of name server operations places its own set of -demands on the data store, with the result that the database API is -quite complex and contains operations that are highly specific to the -DNS. For example, data are stored in a binary format, the name space -is tree structured, and sets of data records are conceptually -associated with DNSSEC signature sets. For these reasons, writing a -driver using this interface is a highly nontrivial undertaking. - - -The Simplified Database Interface - -Many BIND users wish to provide access to various data sources through -the DNS, but are not necessarily interested in completely replacing -the in-memory "rbt" database or in supporting features like dynamic -update, DNSSEC, or even zone transfers. - -Often, all you want is limited, read-only DNS access to an existing -system. For example, you may have an existing relational database -containing hostname/address mappings and wish to provide forvard and -reverse DNS lookups based on this information. Or perhaps you want to -set up a simple DNS-based load balancing system where the name server -answers queries about a single DNS name with a dynamically changing -set of A records. - -BIND 9.1 introduced a new, simplified database interface, or "sdb", -which greatly simplifies the writing of drivers for these kinds of -applications. - - -The sdb Driver - -An sdb driver is an object module, typically written in C, which is -linked into the name server and registers itself with the sdb -subsystem. It provides a set of callback functions, which also serve -to advertise its capabilities. When the name server receives DNS -queries, invokes the callback functions to obtain the data to respond -with. - -Unlike the full database interface, the sdb interface represents all -domain names and resource records as ASCII text. - - -Writing an sdb Driver - -When a driver is registered, it specifies its name, a list of callback -functions, and flags. - -The flags specify whether the driver wants to use relative domain -names where possible. - -The callback functions are as follows. The only one that must be -defined is lookup(). - - - create(zone, argc, argv, driverdata, dbdata) - Create a database object for "zone". - - - destroy(zone, driverdata, dbdata) - Destroy the database object for "zone". - - - lookup(zone, name, dbdata, lookup) - Return all the records at the domain name "name". - - - authority(zone, dbdata, lookup) - Return the SOA and NS records at the zone apex. - - - allnodes(zone, dbdata, allnodes) - Return all data in the zone, for zone transfers. - -For more detail about these functions and their parameters, see -bind9/lib/dns/include/dns/sdb.h. For example drivers, see -bind9/contrib/sdb. - - -Rebuilding the Server - -The driver module and header file must be copied to (or linked into) -the bind9/bin/named and bind9/bin/named/include directories -respectively, and must be added to the DBDRIVER_OBJS and DBDRIVER_SRCS -lines in bin/named/Makefile.in (e.g. for the timedb sample sdb driver, -add timedb.c to DBDRIVER_SRCS and timedb.@O@ to DBDRIVER_OBJS). If -the driver needs additional header files or libraries in nonstandard -places, the DBDRIVER_INCLUDES and DBDRIVER_LIBS lines should also be -updated. - -Calls to dns_sdb_register() and dns_sdb_unregister() (or wrappers, -e.g. timedb_init() and timedb_clear() for the timedb sample sdb -driver) must be inserted into the server, in bind9/bin/named/main.c. -Registration should be in setup(), before the call to -named_server_create(). Unregistration should be in cleanup(), -after the call to ns_server_destroy(). A #include should be added -corresponding to the driver header file. - -You should try doing this with one or more of the sample drivers -before attempting to write a driver of your own. - - -Configuring the Server - -To make a zone use a new database driver, specify a "database" option -in its "zone" statement in named.conf. For example, if the driver -registers itself under the name "acmedb", you might say - - zone "foo.com" { - database "acmedb"; - }; - -You can pass arbitrary arguments to the create() function of the -driver by adding any number of whitespace-separated words after the -driver name: - - zone "foo.com" { - database "acmedb -mode sql -connect 10.0.0.1"; - }; - - -Hints for Driver Writers - - - If a driver is generating data on the fly, it probably should - not implement the allnodes() function, since a zone transfer - will not be meaningful. The allnodes() function is more relevant - with data from a database. - - - The authority() function is necessary if and only if the lookup() - function will not add SOA and NS records at the zone apex. If - SOA and NS records are provided by the lookup() function, - the authority() function should be NULL. - - - When a driver is registered, an opaque object can be provided. This - object is passed into the database create() and destroy() functions. - - - When a database is created, an opaque object can be created that - is associated with that database. This object is passed into the - lookup(), authority(), and allnodes() functions, and is - destroyed by the destroy() function. - - -Future Directions - -A future release may support dynamic loading of sdb drivers. - diff --git a/external/mpl/bind/dist/isc-config.sh.1 b/external/mpl/bind/dist/isc-config.sh.1 index 063e477c2c0..871cc6f2164 100644 --- a/external/mpl/bind/dist/isc-config.sh.1 +++ b/external/mpl/bind/dist/isc-config.sh.1 @@ -1,6 +1,6 @@ -.\" $NetBSD: isc-config.sh.1,v 1.2 2018/08/12 13:02:26 christos Exp $ +.\" $NetBSD: isc-config.sh.1,v 1.3 2019/02/24 20:01:26 christos Exp $ .\" -.\" Copyright (C) 2009, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +.\" Copyright (C) 2009, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .\" .\" This Source Code Form is subject to the terms of the Mozilla Public .\" License, v. 2.0. If a copy of the MPL was not distributed with this @@ -92,5 +92,5 @@ returns an exit status of 1 if invoked with invalid arguments or no arguments at \fBInternet Systems Consortium, Inc\&.\fR .SH "COPYRIGHT" .br -Copyright \(co 2009, 2014-2018 Internet Systems Consortium, Inc. ("ISC") +Copyright \(co 2009, 2014-2019 Internet Systems Consortium, Inc. ("ISC") .br diff --git a/external/mpl/bind/dist/lib/bind9/check.c b/external/mpl/bind/dist/lib/bind9/check.c index 04be32e50f2..ef0c3f5c728 100644 --- a/external/mpl/bind/dist/lib/bind9/check.c +++ b/external/mpl/bind/dist/lib/bind9/check.c @@ -1,4 +1,4 @@ -/* $NetBSD: check.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: check.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -486,6 +486,43 @@ check_viewacls(cfg_aclconfctx_t *actx, const cfg_obj_t *voptions, return (result); } +static isc_result_t +check_non_viewacls(const cfg_obj_t *voptions, const cfg_obj_t *config, + isc_log_t *logctx) +{ + const cfg_obj_t *aclobj = NULL; + const cfg_obj_t *options; + const char *where = NULL; + int i; + + static const char *acls[] = { + "allow-update", "allow-update-forwarding", NULL + }; + + for (i = 0; acls[i] != NULL; i++) { + if (voptions != NULL && aclobj == NULL) { + cfg_map_get(voptions, acls[i], &aclobj); + where = "view"; + } + if (config != NULL && aclobj == NULL) { + options = NULL; + cfg_map_get(config, "options", &options); + if (options != NULL) { + cfg_map_get(options, acls[i], &aclobj); + where = "options"; + } + } + if (aclobj != NULL) { + cfg_obj_log(aclobj, logctx, ISC_LOG_ERROR, + "'%s' can only be set per-zone, " + "not in '%s'", acls[i], where); + return (ISC_R_FAILURE); + } + } + + return (ISC_R_SUCCESS); +} + static const unsigned char zeros[16]; static isc_result_t @@ -1960,7 +1997,7 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, unsigned int i; dns_rdataclass_t zclass; dns_fixedname_t fixedname; - dns_name_t *zname = NULL; + dns_name_t *zname = NULL; /* NULL if parsing of zone name fails. */ isc_buffer_t b; bool root = false; bool rfc1918 = false; @@ -1979,10 +2016,10 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, }; static optionstable dialups[] = { - { "notify", CFG_ZONE_MASTER | CFG_ZONE_SLAVE }, - { "notify-passive", CFG_ZONE_SLAVE }, - { "passive", CFG_ZONE_SLAVE | CFG_ZONE_STUB }, - { "refresh", CFG_ZONE_SLAVE | CFG_ZONE_STUB }, + { "notify", CFG_ZONE_MASTER | CFG_ZONE_SLAVE }, + { "notify-passive", CFG_ZONE_SLAVE }, + { "passive", CFG_ZONE_SLAVE | CFG_ZONE_STUB }, + { "refresh", CFG_ZONE_SLAVE | CFG_ZONE_STUB }, }; znamestr = cfg_obj_asstring(cfg_tuple_get(zconfig, "name")); @@ -2275,7 +2312,8 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, * server list is used in the absence of one explicitly specified. */ if (ztype == CFG_ZONE_SLAVE || ztype == CFG_ZONE_STUB || - (ztype == CFG_ZONE_MIRROR && !dns_name_equal(zname, dns_rootname))) + (ztype == CFG_ZONE_MIRROR && zname != NULL && + !dns_name_equal(zname, dns_rootname))) { obj = NULL; if (cfg_map_get(zoptions, "masters", &obj) != ISC_R_SUCCESS) { @@ -2436,10 +2474,10 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, if (ztype == CFG_ZONE_MASTER || ztype == CFG_ZONE_SLAVE || ztype == CFG_ZONE_STUB) { - const cfg_obj_t *dialup = NULL; - (void)cfg_map_get(zoptions, "dialup", &dialup); - if (dialup != NULL && cfg_obj_isstring(dialup)) { - const char *str = cfg_obj_asstring(dialup); + obj = NULL; + (void)cfg_map_get(zoptions, "dialup", &obj); + if (obj != NULL && cfg_obj_isstring(obj)) { + const char *str = cfg_obj_asstring(obj); for (i = 0; i < sizeof(dialups) / sizeof(dialups[0]); i++) @@ -2569,7 +2607,6 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions, } } - /* * Check that max-zone-ttl isn't used with masterfile-format map */ @@ -3134,7 +3171,7 @@ check_trusted_key(const cfg_obj_t *key, bool managed, } else { isc_buffer_usedregion(&b, &r); - if ((alg == DST_ALG_RSASHA1 || alg == DST_ALG_RSAMD5) && + if ((alg == DST_ALG_RSASHA1) && r.length > 1 && r.base[0] == 1 && r.base[1] == 3) cfg_obj_log(key, logctx, ISC_LOG_WARNING, "%s key '%s' has a weak exponent", @@ -3694,6 +3731,11 @@ check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions, if (tresult != ISC_R_SUCCESS) result = tresult; + tresult = check_non_viewacls(voptions, config, logctx); + if (tresult != ISC_R_SUCCESS) { + result = tresult; + } + tresult = check_recursionacls(actx, voptions, viewname, config, logctx, mctx); if (tresult != ISC_R_SUCCESS) diff --git a/external/mpl/bind/dist/lib/dns/catz.c b/external/mpl/bind/dist/lib/dns/catz.c index cae65e71f50..9f42d34a22a 100644 --- a/external/mpl/bind/dist/lib/dns/catz.c +++ b/external/mpl/bind/dist/lib/dns/catz.c @@ -1,4 +1,4 @@ -/* $NetBSD: catz.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: catz.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -839,8 +839,9 @@ dns_catz_zone_detach(dns_catz_zone_t **zonep) { void dns_catz_catzs_detach(dns_catz_zones_t **catzsp) { + dns_catz_zones_t *catzs; + REQUIRE(catzsp != NULL && *catzsp != NULL); - dns_catz_zones_t *catzs = *catzsp; catzs = *catzsp; *catzsp = NULL; diff --git a/external/mpl/bind/dist/lib/dns/dnssec.c b/external/mpl/bind/dist/lib/dns/dnssec.c index 21864e8aa73..02b647ad7a4 100644 --- a/external/mpl/bind/dist/lib/dns/dnssec.c +++ b/external/mpl/bind/dist/lib/dns/dnssec.c @@ -1,4 +1,4 @@ -/* $NetBSD: dnssec.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: dnssec.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -1624,6 +1624,15 @@ dns_dnssec_keylistfromrdataset(const dns_name_t *origin, result = dns_rdataset_next(&keys)) { dns_rdata_reset(&rdata); dns_rdataset_current(&keys, &rdata); + + REQUIRE(rdata.type == dns_rdatatype_key || + rdata.type == dns_rdatatype_dnskey); + REQUIRE(rdata.length > 3); + + /* Skip unsupported algorithms */ + if (!dst_algorithm_supported(rdata.data[3])) + goto skip; + RETERR(dns_dnssec_keyfromrdata(origin, &rdata, mctx, &pubkey)); dst_key_setttl(pubkey, keys.ttl); @@ -1811,23 +1820,20 @@ publish_key(dns_diff_t *diff, dns_dnsseckey_t *key, const dns_name_t *origin, isc_result_t result; dns_difftuple_t *tuple = NULL; unsigned char buf[DST_KEY_MAXSIZE]; + char keystr[DST_KEY_FORMATSIZE]; dns_rdata_t dnskey = DNS_RDATA_INIT; - char alg[80]; dns_rdata_reset(&dnskey); RETERR(make_dnskey(key->key, buf, sizeof(buf), &dnskey)); + dst_key_format(key->key, keystr, sizeof(keystr)); - dns_secalg_format(dst_key_alg(key->key), alg, sizeof(alg)); - report("Fetching %s %d/%s from key %s.", - key->ksk ? (allzsk ? "KSK/ZSK" : "KSK") : "ZSK", - dst_key_id(key->key), alg, + report("Fetching %s (%s) from key %s.", + keystr, key->ksk ? (allzsk ? "KSK/ZSK" : "KSK") : "ZSK", key->source == dns_keysource_user ? "file" : "repository"); if (key->prepublish && ttl > key->prepublish) { - char keystr[DST_KEY_FORMATSIZE]; isc_stdtime_t now; - dst_key_format(key->key, keystr, sizeof(keystr)); report("Key %s: Delaying activation to match the DNSKEY TTL.\n", keystr, ttl); @@ -2041,9 +2047,11 @@ dns_dnssec_updatekeys(dns_dnsseckeylist_t *keys, dns_dnsseckeylist_t *newkeys, */ for (key = ISC_LIST_HEAD(*keys); key != NULL; - key = ISC_LIST_NEXT(key, link)) { + key = ISC_LIST_NEXT(key, link)) + { if (key->source == dns_keysource_user && - (key->hint_publish || key->force_publish)) { + (key->hint_publish || key->force_publish)) + { RETERR(publish_key(diff, key, origin, ttl, mctx, allzsk, report)); } @@ -2062,15 +2070,19 @@ dns_dnssec_updatekeys(dns_dnsseckeylist_t *keys, dns_dnsseckeylist_t *newkeys, for (key = ISC_LIST_HEAD(*newkeys); key != NULL; - key = ISC_LIST_NEXT(key, link)) { + key = ISC_LIST_NEXT(key, link)) + { dns_ttl_t thisttl = dst_key_getttl(key->key); if (thisttl != 0 && (shortest == 0 || thisttl < shortest)) + { shortest = thisttl; + } } - if (shortest != 0) + if (shortest != 0) { ttl = shortest; + } } /* @@ -2079,20 +2091,23 @@ dns_dnssec_updatekeys(dns_dnsseckeylist_t *keys, dns_dnsseckeylist_t *newkeys, */ for (key1 = ISC_LIST_HEAD(*newkeys); key1 != NULL; key1 = next) { bool key_revoked = false; + char keystr1[DST_KEY_FORMATSIZE]; + char keystr2[DST_KEY_FORMATSIZE]; next = ISC_LIST_NEXT(key1, link); for (key2 = ISC_LIST_HEAD(*keys); key2 != NULL; - key2 = ISC_LIST_NEXT(key2, link)) { + key2 = ISC_LIST_NEXT(key2, link)) + { int f1 = dst_key_flags(key1->key); int f2 = dst_key_flags(key2->key); int nr1 = f1 & ~DNS_KEYFLAG_REVOKE; int nr2 = f2 & ~DNS_KEYFLAG_REVOKE; if (nr1 == nr2 && dst_key_alg(key1->key) == dst_key_alg(key2->key) && - dst_key_pubcompare(key1->key, key2->key, - true)) { + dst_key_pubcompare(key1->key, key2->key, true)) + { int r1, r2; r1 = dst_key_flags(key1->key) & DNS_KEYFLAG_REVOKE; @@ -2103,33 +2118,68 @@ dns_dnssec_updatekeys(dns_dnsseckeylist_t *keys, dns_dnsseckeylist_t *newkeys, } } + /* Printable version of key1 (the newly aquired key) */ + dst_key_format(key1->key, keystr1, sizeof(keystr1)); + /* No match found in keys; add the new key. */ if (key2 == NULL) { ISC_LIST_UNLINK(*newkeys, key1, link); ISC_LIST_APPEND(*keys, key1, link); if (key1->source != dns_keysource_zoneapex && - (key1->hint_publish || key1->force_publish)) { + (key1->hint_publish || key1->force_publish)) + { RETERR(publish_key(diff, key1, origin, ttl, mctx, allzsk, report)); - if (key1->hint_sign || key1->force_sign) + isc_log_write(dns_lctx, + DNS_LOGCATEGORY_DNSSEC, + DNS_LOGMODULE_DNSSEC, + ISC_LOG_INFO, + "DNSKEY %s (%s) is now published", + keystr1, key1->ksk ? + (allzsk ? "KSK/ZSK" : "KSK") : + "ZSK"); + if (key1->hint_sign || key1->force_sign) { key1->first_sign = true; + isc_log_write(dns_lctx, + DNS_LOGCATEGORY_DNSSEC, + DNS_LOGMODULE_DNSSEC, + ISC_LOG_INFO, + "DNSKEY %s (%s) is now " + "active", + keystr1, key1->ksk ? + (allzsk ? "KSK/ZSK" : + "KSK") : "ZSK"); + } } continue; } + /* Printable version of key2 (the old key, if any) */ + dst_key_format(key2->key, keystr2, sizeof(keystr2)); + /* Match found: remove or update it as needed */ if (key1->hint_remove) { RETERR(remove_key(diff, key2, origin, ttl, mctx, "expired", report)); ISC_LIST_UNLINK(*keys, key2, link); - if (removed != NULL) + + if (removed != NULL) { ISC_LIST_APPEND(*removed, key2, link); - else + isc_log_write(dns_lctx, + DNS_LOGCATEGORY_DNSSEC, + DNS_LOGMODULE_DNSSEC, + ISC_LOG_INFO, + "DNSKEY %s (%s) is now deleted", + keystr2, key2->ksk ? (allzsk ? + "KSK/ZSK" : "KSK") : "ZSK"); + } else { dns_dnsseckey_destroy(mctx, &key2); + } } else if (key_revoked && - (dst_key_flags(key1->key) & DNS_KEYFLAG_REVOKE) != 0) { + (dst_key_flags(key1->key) & DNS_KEYFLAG_REVOKE) != 0) + { /* * A previously valid key has been revoked. @@ -2139,10 +2189,20 @@ dns_dnssec_updatekeys(dns_dnsseckeylist_t *keys, dns_dnsseckeylist_t *newkeys, RETERR(remove_key(diff, key2, origin, ttl, mctx, "revoked", report)); ISC_LIST_UNLINK(*keys, key2, link); - if (removed != NULL) + if (removed != NULL) { ISC_LIST_APPEND(*removed, key2, link); - else + isc_log_write(dns_lctx, + DNS_LOGCATEGORY_DNSSEC, + DNS_LOGMODULE_DNSSEC, + ISC_LOG_INFO, + "DNSKEY %s (%s) is now revoked; " + "new ID is %05d", + keystr2, key2->ksk ? (allzsk ? + "KSK/ZSK" : "KSK") : "ZSK", + dst_key_id(key1->key)); + } else { dns_dnsseckey_destroy(mctx, &key2); + } RETERR(publish_key(diff, key1, origin, ttl, mctx, allzsk, report)); @@ -2162,7 +2222,27 @@ dns_dnssec_updatekeys(dns_dnsseckeylist_t *keys, dns_dnsseckeylist_t *newkeys, } else { if (!key2->is_active && (key1->hint_sign || key1->force_sign)) + { key2->first_sign = true; + isc_log_write(dns_lctx, + DNS_LOGCATEGORY_DNSSEC, + DNS_LOGMODULE_DNSSEC, + ISC_LOG_INFO, + "DNSKEY %s (%s) is now active", + keystr1, key1->ksk ? (allzsk ? + "KSK/ZSK" : "KSK") : "ZSK"); + } else if (key2->is_active && + !key1->hint_sign && !key1->force_sign) + { + isc_log_write(dns_lctx, + DNS_LOGCATEGORY_DNSSEC, + DNS_LOGMODULE_DNSSEC, + ISC_LOG_INFO, + "DNSKEY %s (%s) is now inactive", + keystr1, key1->ksk ? (allzsk ? + "KSK/ZSK" : "KSK") : "ZSK"); + } + key2->hint_sign = key1->hint_sign; key2->hint_publish = key1->hint_publish; } diff --git a/external/mpl/bind/dist/lib/dns/dnstap.c b/external/mpl/bind/dist/lib/dns/dnstap.c index c54c2773507..fd404cdc3d5 100644 --- a/external/mpl/bind/dist/lib/dns/dnstap.c +++ b/external/mpl/bind/dist/lib/dns/dnstap.c @@ -1,4 +1,4 @@ -/* $NetBSD: dnstap.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: dnstap.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -211,26 +211,26 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, generation++; env = isc_mem_get(mctx, sizeof(dns_dtenv_t)); - if (env == NULL) - CHECK(ISC_R_NOMEMORY); memset(env, 0, sizeof(dns_dtenv_t)); - + env->reopen_task = reopen_task; + isc_mutex_init(&env->reopen_lock); + env->reopen_queued = false; + env->path = isc_mem_strdup(mctx, path); isc_refcount_init(&env->refcount, 1); CHECK(isc_stats_create(mctx, &env->stats, dns_dnstapcounter_max)); - env->path = isc_mem_strdup(mctx, path); - if (env->path == NULL) - CHECK(ISC_R_NOMEMORY); fwopt = fstrm_writer_options_init(); - if (fwopt == NULL) + if (fwopt == NULL) { CHECK(ISC_R_NOMEMORY); + } res = fstrm_writer_options_add_content_type(fwopt, DNSTAP_CONTENT_TYPE, sizeof(DNSTAP_CONTENT_TYPE) - 1); - if (res != fstrm_res_success) + if (res != fstrm_res_success) { CHECK(ISC_R_FAILURE); + } if (mode == dns_dtmode_file) { ffwopt = fstrm_file_options_init(); @@ -245,11 +245,13 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, env->path); fw = fstrm_unix_writer_init(fuwopt, fwopt); } - } else + } else { CHECK(ISC_R_FAILURE); + } - if (fw == NULL) + if (fw == NULL) { CHECK(ISC_R_FAILURE); + } env->iothr = fstrm_iothr_init(*foptp, &fw); if (env->iothr == NULL) { @@ -265,10 +267,6 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, env->fopt = *foptp; *foptp = NULL; - env->reopen_task = reopen_task; - isc_mutex_init(&env->reopen_lock); - env->reopen_queued = false; - isc_mem_attach(mctx, &env->mctx); env->magic = DTENV_MAGIC; @@ -285,16 +283,12 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path, fstrm_writer_options_destroy(&fwopt); if (result != ISC_R_SUCCESS) { - if (env != NULL) { - isc_mutex_destroy(&env->reopen_lock); - if (env->mctx != NULL) - isc_mem_detach(&env->mctx); - if (env->path != NULL) - isc_mem_free(mctx, env->path); - if (env->stats != NULL) - isc_stats_detach(&env->stats); - isc_mem_put(mctx, env, sizeof(dns_dtenv_t)); + isc_mutex_destroy(&env->reopen_lock); + isc_mem_free(mctx, env->path); + if (env->stats != NULL) { + isc_stats_detach(&env->stats); } + isc_mem_putanddetach(&env->mctx, env, sizeof(dns_dtenv_t)); } return (result); diff --git a/external/mpl/bind/dist/lib/dns/ds.c b/external/mpl/bind/dist/lib/dns/ds.c index 5fdbe07e725..f2320da7d17 100644 --- a/external/mpl/bind/dist/lib/dns/ds.c +++ b/external/mpl/bind/dist/lib/dns/ds.c @@ -1,4 +1,4 @@ -/* $NetBSD: ds.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: ds.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -49,7 +49,8 @@ dns_ds_buildrdata(dns_name_t *owner, dns_rdata_t *key, isc_result_t ret; REQUIRE(key != NULL); - REQUIRE(key->type == dns_rdatatype_dnskey); + REQUIRE(key->type == dns_rdatatype_dnskey || + key->type == dns_rdatatype_cdnskey); if (!dst_ds_digest_supported(digest_type)) { return (ISC_R_NOTIMPLEMENTED); @@ -110,7 +111,7 @@ dns_ds_buildrdata(dns_name_t *owner, dns_rdata_t *key, ds.common.rdclass = key->rdclass; ds.common.rdtype = dns_rdatatype_ds; ds.algorithm = r.base[3]; - ds.key_tag = dst_region_computeid(&r, ds.algorithm); + ds.key_tag = dst_region_computeid(&r); ds.digest_type = digest_type; ds.digest = digest; ds.length = digestlen; diff --git a/external/mpl/bind/dist/lib/dns/dst_api.c b/external/mpl/bind/dist/lib/dns/dst_api.c index 4c053a80873..af0f2b38215 100644 --- a/external/mpl/bind/dist/lib/dns/dst_api.c +++ b/external/mpl/bind/dist/lib/dns/dst_api.c @@ -1,4 +1,4 @@ -/* $NetBSD: dst_api.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: dst_api.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -145,8 +145,6 @@ dst_lib_init(isc_mem_t *mctx, const char *engine) { RETERR(dst__openssl_init(mctx, engine)); RETERR(dst__openssldh_init(&dst_t_func[DST_ALG_DH])); #if USE_OPENSSL - RETERR(dst__opensslrsa_init(&dst_t_func[DST_ALG_RSAMD5], - DST_ALG_RSAMD5)); RETERR(dst__opensslrsa_init(&dst_t_func[DST_ALG_RSASHA1], DST_ALG_RSASHA1)); RETERR(dst__opensslrsa_init(&dst_t_func[DST_ALG_NSEC3RSASHA1], @@ -167,7 +165,6 @@ dst_lib_init(isc_mem_t *mctx, const char *engine) { #if USE_PKCS11 RETERR(dst__pkcs11_init(mctx, engine)); - RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSAMD5])); RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSASHA1])); RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_NSEC3RSASHA1])); RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSASHA256])); @@ -645,8 +642,8 @@ dst_key_fromdns(const dns_name_t *name, dns_rdataclass_t rdclass, proto = isc_buffer_getuint8(source); alg = isc_buffer_getuint8(source); - id = dst_region_computeid(&r, alg); - rid = dst_region_computerid(&r, alg); + id = dst_region_computeid(&r); + rid = dst_region_computerid(&r); if ((flags & DNS_KEYFLAG_EXTENDED) != 0) { if (isc_buffer_remaininglength(source) < 2) @@ -988,8 +985,6 @@ comparekeys(const dst_key_t *key1, const dst_key_t *key2, if (key1->key_id != key2->key_id) { if (!match_revoked_key) return (false); - if (key1->key_alg == DST_ALG_RSAMD5) - return (false); if ((key1->key_flags & DNS_KEYFLAG_REVOKE) == (key2->key_flags & DNS_KEYFLAG_REVOKE)) return (false); @@ -1145,7 +1140,6 @@ dst_key_sigsize(const dst_key_t *key, unsigned int *n) { /* XXXVIX this switch statement is too sparse to gen a jump table. */ switch (key->key_alg) { - case DST_ALG_RSAMD5: case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: case DST_ALG_RSASHA256: @@ -1475,7 +1469,6 @@ issymmetric(const dst_key_t *key) { /* XXXVIX this switch statement is too sparse to gen a jump table. */ switch (key->key_alg) { - case DST_ALG_RSAMD5: case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: case DST_ALG_RSASHA256: @@ -1699,8 +1692,8 @@ computeid(dst_key_t *key) { return (ret); isc_buffer_usedregion(&dnsbuf, &r); - key->key_id = dst_region_computeid(&r, key->key_alg); - key->key_rid = dst_region_computerid(&r, key->key_alg); + key->key_id = dst_region_computeid(&r); + key->key_rid = dst_region_computerid(&r); return (ISC_R_SUCCESS); } diff --git a/external/mpl/bind/dist/lib/dns/dst_lib.c b/external/mpl/bind/dist/lib/dns/dst_lib.c deleted file mode 100644 index a18a9dfee95..00000000000 --- a/external/mpl/bind/dist/lib/dns/dst_lib.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: dst_lib.c,v 1.2 2018/08/12 13:02:35 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -/*! \file */ - -#include <config.h> - -#include <stddef.h> - -#include <isc/once.h> -#include <isc/msgcat.h> -#include <isc/util.h> - -#include <dst/lib.h> - -/*** - *** Globals - ***/ - -LIBDNS_EXTERNAL_DATA isc_msgcat_t * dst_msgcat = NULL; - - -/*** - *** Private - ***/ - -static isc_once_t msgcat_once = ISC_ONCE_INIT; - - -/*** - *** Functions - ***/ - -static void -open_msgcat(void) { - isc_msgcat_open("libdst.cat", &dst_msgcat); -} - -void -dst_lib_initmsgcat(void) { - - /* - * Initialize the DST library's message catalog, dst_msgcat, if it - * has not already been initialized. - */ - - RUNTIME_CHECK(isc_once_do(&msgcat_once, open_msgcat) == ISC_R_SUCCESS); -} diff --git a/external/mpl/bind/dist/lib/dns/dst_parse.c b/external/mpl/bind/dist/lib/dns/dst_parse.c index facacbccb24..85d1659e376 100644 --- a/external/mpl/bind/dist/lib/dns/dst_parse.c +++ b/external/mpl/bind/dist/lib/dns/dst_parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: dst_parse.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: dst_parse.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -188,7 +188,7 @@ check_rsa(const dst_private_t *priv, bool external) { for (j = 0; j < priv->nelements; j++) { for (i = 0; i < RSA_NTAGS; i++) - if (priv->elements[j].tag == TAG(DST_ALG_RSAMD5, i)) + if (priv->elements[j].tag == TAG(DST_ALG_RSA, i)) break; if (i == RSA_NTAGS) return (-1); @@ -338,7 +338,7 @@ check_data(const dst_private_t *priv, const unsigned int alg, { /* XXXVIX this switch statement is too sparse to gen a jump table. */ switch (alg) { - case DST_ALG_RSAMD5: + case DST_ALG_RSA: case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: case DST_ALG_RSASHA256: @@ -663,9 +663,6 @@ dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv, /* XXXVIX this switch statement is too sparse to gen a jump table. */ switch (dst_key_alg(key)) { - case DST_ALG_RSAMD5: - fprintf(fp, "(RSA)\n"); - break; case DST_ALG_DH: fprintf(fp, "(DH)\n"); break; diff --git a/external/mpl/bind/dist/lib/dns/dst_parse.h b/external/mpl/bind/dist/lib/dns/dst_parse.h index 5a4f4a23e1c..1b8e5f6bb52 100644 --- a/external/mpl/bind/dist/lib/dns/dst_parse.h +++ b/external/mpl/bind/dist/lib/dns/dst_parse.h @@ -1,4 +1,4 @@ -/* $NetBSD: dst_parse.h,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: dst_parse.h,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -46,18 +46,18 @@ #define TAG_ALG(tag) ((unsigned int)(tag) >> TAG_SHIFT) #define TAG(alg, off) (((alg) << TAG_SHIFT) + (off)) -/* These are used by both RSA-MD5 and RSA-SHA1 */ +/* These are used by RSA-SHA1, RSASHA256 and RSASHA512 */ #define RSA_NTAGS 11 -#define TAG_RSA_MODULUS ((DST_ALG_RSAMD5 << TAG_SHIFT) + 0) -#define TAG_RSA_PUBLICEXPONENT ((DST_ALG_RSAMD5 << TAG_SHIFT) + 1) -#define TAG_RSA_PRIVATEEXPONENT ((DST_ALG_RSAMD5 << TAG_SHIFT) + 2) -#define TAG_RSA_PRIME1 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 3) -#define TAG_RSA_PRIME2 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 4) -#define TAG_RSA_EXPONENT1 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 5) -#define TAG_RSA_EXPONENT2 ((DST_ALG_RSAMD5 << TAG_SHIFT) + 6) -#define TAG_RSA_COEFFICIENT ((DST_ALG_RSAMD5 << TAG_SHIFT) + 7) -#define TAG_RSA_ENGINE ((DST_ALG_RSAMD5 << TAG_SHIFT) + 8) -#define TAG_RSA_LABEL ((DST_ALG_RSAMD5 << TAG_SHIFT) + 9) +#define TAG_RSA_MODULUS ((DST_ALG_RSA << TAG_SHIFT) + 0) +#define TAG_RSA_PUBLICEXPONENT ((DST_ALG_RSA << TAG_SHIFT) + 1) +#define TAG_RSA_PRIVATEEXPONENT ((DST_ALG_RSA << TAG_SHIFT) + 2) +#define TAG_RSA_PRIME1 ((DST_ALG_RSA << TAG_SHIFT) + 3) +#define TAG_RSA_PRIME2 ((DST_ALG_RSA << TAG_SHIFT) + 4) +#define TAG_RSA_EXPONENT1 ((DST_ALG_RSA << TAG_SHIFT) + 5) +#define TAG_RSA_EXPONENT2 ((DST_ALG_RSA << TAG_SHIFT) + 6) +#define TAG_RSA_COEFFICIENT ((DST_ALG_RSA << TAG_SHIFT) + 7) +#define TAG_RSA_ENGINE ((DST_ALG_RSA << TAG_SHIFT) + 8) +#define TAG_RSA_LABEL ((DST_ALG_RSA << TAG_SHIFT) + 9) #define DH_NTAGS 4 #define TAG_DH_PRIME ((DST_ALG_DH << TAG_SHIFT) + 0) diff --git a/external/mpl/bind/dist/lib/dns/dst_result.c b/external/mpl/bind/dist/lib/dns/dst_result.c index 6b2ae997079..41bd48c18ec 100644 --- a/external/mpl/bind/dist/lib/dns/dst_result.c +++ b/external/mpl/bind/dist/lib/dns/dst_result.c @@ -1,4 +1,4 @@ -/* $NetBSD: dst_result.c,v 1.2 2018/08/12 13:02:35 christos Exp $ */ +/* $NetBSD: dst_result.c,v 1.3 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,6 @@ #include <isc/util.h> #include <dst/result.h> -#include <dst/lib.h> static const char *text[DST_R_NRESULTS] = { "algorithm is unsupported", /*%< 0 */ @@ -80,12 +79,12 @@ initialize_action(void) { isc_result_t result; result = isc_result_register(ISC_RESULTCLASS_DST, DST_R_NRESULTS, - text, dst_msgcat, DST_RESULT_RESULTSET); + text, DST_RESULT_RESULTSET); if (result != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_result_register() failed: %u", result); result = isc_result_registerids(ISC_RESULTCLASS_DST, DST_R_NRESULTS, - ids, dst_msgcat, DST_RESULT_RESULTSET); + ids, DST_RESULT_RESULTSET); if (result != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_result_registerids() failed: %u", result); @@ -93,7 +92,6 @@ initialize_action(void) { static void initialize(void) { - dst_lib_initmsgcat(); RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS); } diff --git a/external/mpl/bind/dist/lib/dns/dyndb.c b/external/mpl/bind/dist/lib/dns/dyndb.c index 24e21ad83f1..551d4952cc3 100644 --- a/external/mpl/bind/dist/lib/dns/dyndb.c +++ b/external/mpl/bind/dist/lib/dns/dyndb.c @@ -1,4 +1,4 @@ -/* $NetBSD: dyndb.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: dyndb.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -135,7 +135,7 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname, instname, filename); flags = RTLD_NOW|RTLD_LOCAL; -#ifdef RTLD_DEEPBIND +#if defined(RTLD_DEEPBIND) && !__SANITIZE_ADDRESS__ flags |= RTLD_DEEPBIND; #endif diff --git a/external/mpl/bind/dist/lib/dns/gssapictx.c b/external/mpl/bind/dist/lib/dns/gssapictx.c index 14c477c8543..0d7987c6779 100644 --- a/external/mpl/bind/dist/lib/dns/gssapictx.c +++ b/external/mpl/bind/dist/lib/dns/gssapictx.c @@ -1,4 +1,4 @@ -/* $NetBSD: gssapictx.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: gssapictx.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -489,7 +489,6 @@ dst_gssapi_identitymatchesrealmms(const dns_name_t *signer, */ rname++; *sname = '\0'; - sname = sbuf; if (strcmp(rname, rbuf) != 0) { return (false); diff --git a/external/mpl/bind/dist/lib/dns/include/dns/dnssec.h b/external/mpl/bind/dist/lib/dns/include/dns/dnssec.h index 87ae4e57747..ffab774ee1c 100644 --- a/external/mpl/bind/dist/lib/dns/include/dns/dnssec.h +++ b/external/mpl/bind/dist/lib/dns/include/dns/dnssec.h @@ -1,4 +1,4 @@ -/* $NetBSD: dnssec.h,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: dnssec.h,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -51,22 +51,22 @@ typedef enum { */ struct dns_dnsseckey { dst_key_t *key; - bool hint_publish; /*% metadata says to publish */ - bool force_publish; /*% publish regardless of metadata */ - bool hint_sign; /*% metadata says to sign with this key */ - bool force_sign; /*% sign with key regardless of metadata */ - bool hint_remove; /*% metadata says *don't* publish */ - bool is_active; /*% key is already active */ - bool first_sign; /*% key is newly becoming active */ - unsigned int prepublish; /*% how long until active? */ - dns_keysource_t source; /*% how the key was found */ - bool ksk; /*% this is a key-signing key */ - bool legacy; /*% this is old-style key with no - metadata (possibly generated by - an older version of BIND9) and - should be ignored when searching - for keys to import into the zone */ - unsigned int index; /*% position in list */ + bool hint_publish; /*% metadata says to publish */ + bool force_publish; /*% publish regardless of metadata */ + bool hint_sign; /*% metadata says to sign with this key */ + bool force_sign; /*% sign with key regardless of metadata */ + bool hint_remove; /*% metadata says *don't* publish */ + bool is_active; /*% key is already active */ + bool first_sign; /*% key is newly becoming active */ + unsigned int prepublish; /*% how long until active? */ + dns_keysource_t source; /*% how the key was found */ + bool ksk; /*% this is a key-signing key */ + bool legacy; /*% this is old-style key with no + metadata (possibly generated by + an older version of BIND9) and + should be ignored when searching + for keys to import into the zone */ + unsigned int index; /*% position in list */ ISC_LINK(dns_dnsseckey_t) link; }; @@ -276,7 +276,7 @@ dns_dnssec_findmatchingkeys(const dns_name_t *origin, const char *directory, /*%< * Search 'directory' for K* key files matching the name in 'origin'. * Append all such keys, along with use hints gleaned from their - * metadata, onto 'keylist'. + * metadata, onto 'keylist'. Skip any unsupported algorithms. * * Requires: *\li 'keylist' is not NULL diff --git a/external/mpl/bind/dist/lib/dns/include/dns/ds.h b/external/mpl/bind/dist/lib/dns/include/dns/ds.h index a4ab345f94a..872338235b2 100644 --- a/external/mpl/bind/dist/lib/dns/include/dns/ds.h +++ b/external/mpl/bind/dist/lib/dns/include/dns/ds.h @@ -1,4 +1,4 @@ -/* $NetBSD: ds.h,v 1.2 2018/08/12 13:02:35 christos Exp $ */ +/* $NetBSD: ds.h,v 1.3 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -39,7 +39,7 @@ dns_ds_buildrdata(dns_name_t *owner, dns_rdata_t *key, * Build the rdata of a DS record. * * Requires: - *\li key Points to a valid DNS KEY record. + *\li key Points to a valid DNSKEY or CDNSKEY record. *\li buffer Points to a temporary buffer of at least * #DNS_DS_BUFFERSIZE bytes. *\li rdata Points to an initialized dns_rdata_t. diff --git a/external/mpl/bind/dist/lib/dns/include/dns/keyvalues.h b/external/mpl/bind/dist/lib/dns/include/dns/keyvalues.h index ee640624766..b20e49b50eb 100644 --- a/external/mpl/bind/dist/lib/dns/include/dns/keyvalues.h +++ b/external/mpl/bind/dist/lib/dns/include/dns/keyvalues.h @@ -1,4 +1,4 @@ -/* $NetBSD: keyvalues.h,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: keyvalues.h,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -55,7 +55,7 @@ /* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ #define DNS_KEYALG_RSAMD5 1 /*%< RSA with MD5 */ -#define DNS_KEYALG_RSA DNS_KEYALG_RSAMD5 +#define DNS_KEYALG_RSA 1 /*%< Used just for tagging */ #define DNS_KEYALG_DH 2 /*%< Diffie Hellman KEY */ #define DNS_KEYALG_DSA 3 /*%< DSA KEY */ #define DNS_KEYALG_NSEC3DSA 6 diff --git a/external/mpl/bind/dist/lib/dns/include/dns/lib.h b/external/mpl/bind/dist/lib/dns/include/dns/lib.h index ab74cfb36df..f1cc1469cbc 100644 --- a/external/mpl/bind/dist/lib/dns/include/dns/lib.h +++ b/external/mpl/bind/dist/lib/dns/include/dns/lib.h @@ -1,4 +1,4 @@ -/* $NetBSD: lib.h,v 1.2 2018/08/12 13:02:35 christos Exp $ */ +/* $NetBSD: lib.h,v 1.3 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -26,14 +26,6 @@ ISC_LANG_BEGINDECLS * Tuning: external query load in packets per seconds. */ LIBDNS_EXTERNAL_DATA extern unsigned int dns_pps; -LIBDNS_EXTERNAL_DATA extern isc_msgcat_t *dns_msgcat; - -void -dns_lib_initmsgcat(void); -/*%< - * Initialize the DNS library's message catalog, dns_msgcat, if it - * has not already been initialized. - */ isc_result_t dns_lib_init(void); diff --git a/external/mpl/bind/dist/lib/dns/include/dns/message.h b/external/mpl/bind/dist/lib/dns/include/dns/message.h index fdd8560283d..e9909c265eb 100644 --- a/external/mpl/bind/dist/lib/dns/include/dns/message.h +++ b/external/mpl/bind/dist/lib/dns/include/dns/message.h @@ -1,4 +1,4 @@ -/* $NetBSD: message.h,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: message.h,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -180,9 +180,9 @@ typedef int dns_messagetextflag_t; #define DNS_MESSAGERENDER_PARTIAL 0x0002 /*%< allow a partial rdataset */ #define DNS_MESSAGERENDER_OMITDNSSEC 0x0004 /*%< omit DNSSEC records */ #define DNS_MESSAGERENDER_PREFER_A 0x0008 /*%< prefer A records in - additional section. */ + additional section. */ #define DNS_MESSAGERENDER_PREFER_AAAA 0x0010 /*%< prefer AAAA records in - additional section. */ + additional section. */ /* Obsolete: DNS_MESSAGERENDER_FILTER_AAAA 0x0020 */ typedef struct dns_msgblock dns_msgblock_t; diff --git a/external/mpl/bind/dist/lib/dns/include/dns/rdata.h b/external/mpl/bind/dist/lib/dns/include/dns/rdata.h index 8d9dbec796a..6abac51f2a8 100644 --- a/external/mpl/bind/dist/lib/dns/include/dns/rdata.h +++ b/external/mpl/bind/dist/lib/dns/include/dns/rdata.h @@ -1,4 +1,4 @@ -/* $NetBSD: rdata.h,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: rdata.h,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -592,7 +592,6 @@ dns_rdatatype_isknown(dns_rdatatype_t type); * */ - isc_result_t dns_rdata_additionaldata(dns_rdata_t *rdata, dns_additionaldatafunc_t add, void *arg); @@ -685,6 +684,16 @@ dns_rdatatype_atparent(dns_rdatatype_t type); * */ +bool +dns_rdatatype_atcname(dns_rdatatype_t type); +/*%< + * Return true iff rdata of type 'type' can appear beside a cname. + * + * Requires: + * \li 'type' is a valid rdata type. + * + */ + unsigned int dns_rdatatype_attributes(dns_rdatatype_t rdtype); /*%< @@ -713,10 +722,12 @@ dns_rdatatype_attributes(dns_rdatatype_t rdtype); #define DNS_RDATATYPEATTR_UNKNOWN 0x00000040U /*% Is META, and can only be in a question section */ #define DNS_RDATATYPEATTR_QUESTIONONLY 0x00000080U -/*% is META, and can NOT be in a question section */ +/*% Is META, and can NOT be in a question section */ #define DNS_RDATATYPEATTR_NOTQUESTION 0x00000100U /*% Is present at zone cuts in the parent, not the child */ #define DNS_RDATATYPEATTR_ATPARENT 0x00000200U +/*% Can exist along side a CNAME */ +#define DNS_RDATATYPEATTR_ATCNAME 0x00000400U dns_rdatatype_t dns_rdata_covers(dns_rdata_t *rdata); diff --git a/external/mpl/bind/dist/lib/dns/include/dns/rdataset.h b/external/mpl/bind/dist/lib/dns/include/dns/rdataset.h index d0792365330..e953287b076 100644 --- a/external/mpl/bind/dist/lib/dns/include/dns/rdataset.h +++ b/external/mpl/bind/dist/lib/dns/include/dns/rdataset.h @@ -1,4 +1,4 @@ -/* $NetBSD: rdataset.h,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: rdataset.h,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -110,6 +110,7 @@ struct dns_rdataset { unsigned int magic; /* XXX ? */ dns_rdatasetmethods_t * methods; ISC_LINK(dns_rdataset_t) link; + /* * XXX do we need these, or should they be retrieved by methods? * Leaning towards the latter, since they are not frequently required @@ -118,12 +119,19 @@ struct dns_rdataset { dns_rdataclass_t rdclass; dns_rdatatype_t type; dns_ttl_t ttl; + /* + * Stale ttl is used to see how long this RRset can still be used + * to serve to clients, after the TTL has expired. + */ + dns_ttl_t stale_ttl; dns_trust_t trust; dns_rdatatype_t covers; + /* * attributes */ unsigned int attributes; + /*% * the counter provides the starting point in the "cyclic" order. * The value UINT32_MAX has a special meaning of "picking up a @@ -131,11 +139,13 @@ struct dns_rdataset { * increment the counter. */ uint32_t count; + /* * This RRSIG RRset should be re-generated around this time. * Only valid if DNS_RDATASETATTR_RESIGN is set in attributes. */ isc_stdtime_t resign; + /*@{*/ /*% * These are for use by the rdataset implementation, and MUST NOT diff --git a/external/mpl/bind/dist/lib/dns/include/dns/resolver.h b/external/mpl/bind/dist/lib/dns/include/dns/resolver.h index c5d881ef827..bc80080d173 100644 --- a/external/mpl/bind/dist/lib/dns/include/dns/resolver.h +++ b/external/mpl/bind/dist/lib/dns/include/dns/resolver.h @@ -1,4 +1,4 @@ -/* $NetBSD: resolver.h,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: resolver.h,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -120,6 +120,8 @@ typedef enum { when doing qname minimization on ip6.arpa. */ +#define DNS_FETCHOPT_NOFORWARD 0x00080000 /*%< Do not use forwarders + if possible. */ /* Reserved in use by adb.c 0x00400000 */ #define DNS_FETCHOPT_EDNSVERSIONSET 0x00800000 diff --git a/external/mpl/bind/dist/lib/dns/include/dst/dst.h b/external/mpl/bind/dist/lib/dns/include/dst/dst.h index 52af5c61342..2ac5923c3a8 100644 --- a/external/mpl/bind/dist/lib/dns/include/dst/dst.h +++ b/external/mpl/bind/dist/lib/dns/include/dst/dst.h @@ -1,4 +1,4 @@ -/* $NetBSD: dst.h,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: dst.h,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -48,8 +48,8 @@ typedef struct dst_context dst_context_t; /* DST algorithm codes */ #define DST_ALG_UNKNOWN 0 +#define DST_ALG_RSA 1 /* Used for parsing RSASHA1, RSASHA256 and RSASHA512 */ #define DST_ALG_RSAMD5 1 -#define DST_ALG_RSA DST_ALG_RSAMD5 /*%< backwards compatibility */ #define DST_ALG_DH 2 #define DST_ALG_DSA 3 #define DST_ALG_ECC 4 @@ -72,8 +72,7 @@ typedef struct dst_context dst_context_t; #define DST_ALG_HMACSHA512 165 /* XXXMPA */ #define DST_ALG_INDIRECT 252 #define DST_ALG_PRIVATE 254 -#define DST_ALG_EXPAND 255 -#define DST_MAX_ALGS 255 +#define DST_MAX_ALGS 256 /*% A buffer of this size is large enough to hold any key */ #define DST_KEY_MAXSIZE 1280 @@ -753,12 +752,12 @@ dst_key_secretsize(const dst_key_t *key, unsigned int *n); */ uint16_t -dst_region_computeid(const isc_region_t *source, unsigned int alg); +dst_region_computeid(const isc_region_t *source); uint16_t -dst_region_computerid(const isc_region_t *source, unsigned int alg); +dst_region_computerid(const isc_region_t *source); /*%< * Computes the (revoked) key id of the key stored in the provided - * region with the given algorithm. + * region. * * Requires: *\li "source" contains a valid, non-NULL region. diff --git a/external/mpl/bind/dist/lib/dns/include/dst/lib.h b/external/mpl/bind/dist/lib/dns/include/dst/lib.h deleted file mode 100644 index 1a31bb0403a..00000000000 --- a/external/mpl/bind/dist/lib/dns/include/dst/lib.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: lib.h,v 1.2 2018/08/12 13:02:35 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -#ifndef DST_LIB_H -#define DST_LIB_H 1 - -/*! \file dst/lib.h */ - -#include <isc/types.h> -#include <isc/lang.h> - -ISC_LANG_BEGINDECLS - -LIBDNS_EXTERNAL_DATA extern isc_msgcat_t *dst_msgcat; - -void -dst_lib_initmsgcat(void); -/* - * Initialize the DST library's message catalog, dst_msgcat, if it - * has not already been initialized. - */ - -ISC_LANG_ENDDECLS - -#endif /* DST_LIB_H */ diff --git a/external/mpl/bind/dist/lib/dns/key.c b/external/mpl/bind/dist/lib/dns/key.c index 10c0d965be1..9c18fc527d8 100644 --- a/external/mpl/bind/dist/lib/dns/key.c +++ b/external/mpl/bind/dist/lib/dns/key.c @@ -1,4 +1,4 @@ -/* $NetBSD: key.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: key.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -29,7 +29,7 @@ #include "dst_internal.h" uint16_t -dst_region_computeid(const isc_region_t *source, unsigned int alg) { +dst_region_computeid(const isc_region_t *source) { uint32_t ac; const unsigned char *p; int size; @@ -40,9 +40,6 @@ dst_region_computeid(const isc_region_t *source, unsigned int alg) { p = source->base; size = source->length; - if (alg == DST_ALG_RSAMD5) - return ((p[size - 3] << 8) + p[size - 2]); - for (ac = 0; size > 1; size -= 2, p += 2) ac += ((*p) << 8) + *(p + 1); @@ -54,7 +51,7 @@ dst_region_computeid(const isc_region_t *source, unsigned int alg) { } uint16_t -dst_region_computerid(const isc_region_t *source, unsigned int alg) { +dst_region_computerid(const isc_region_t *source) { uint32_t ac; const unsigned char *p; int size; @@ -65,9 +62,6 @@ dst_region_computerid(const isc_region_t *source, unsigned int alg) { p = source->base; size = source->length; - if (alg == DST_ALG_RSAMD5) - return ((p[size - 3] << 8) + p[size - 2]); - ac = ((*p) << 8) + *(p + 1); ac |= DNS_KEYFLAG_REVOKE; for (size -= 2, p +=2; size > 1; size -= 2, p += 2) diff --git a/external/mpl/bind/dist/lib/dns/lib.c b/external/mpl/bind/dist/lib/dns/lib.c index e94460970b6..ace2842f0be 100644 --- a/external/mpl/bind/dist/lib/dns/lib.c +++ b/external/mpl/bind/dist/lib/dns/lib.c @@ -1,4 +1,4 @@ -/* $NetBSD: lib.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: lib.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -20,7 +20,6 @@ #include <isc/hash.h> #include <isc/mem.h> -#include <isc/msgcat.h> #include <isc/mutex.h> #include <isc/once.h> #include <isc/util.h> @@ -38,36 +37,12 @@ ***/ LIBDNS_EXTERNAL_DATA unsigned int dns_pps = 0U; -LIBDNS_EXTERNAL_DATA isc_msgcat_t * dns_msgcat = NULL; - - -/*** - *** Private - ***/ - -static isc_once_t msgcat_once = ISC_ONCE_INIT; /*** *** Functions ***/ -static void -open_msgcat(void) { - isc_msgcat_open("libdns.cat", &dns_msgcat); -} - -void -dns_lib_initmsgcat(void) { - - /* - * Initialize the DNS library's message catalog, dns_msgcat, if it - * has not already been initialized. - */ - - RUNTIME_CHECK(isc_once_do(&msgcat_once, open_msgcat) == ISC_R_SUCCESS); -} - static isc_once_t init_once = ISC_ONCE_INIT; static isc_mem_t *dns_g_mctx = NULL; static dns_dbimplementation_t *dbimp = NULL; diff --git a/external/mpl/bind/dist/lib/dns/masterdump.c b/external/mpl/bind/dist/lib/dns/masterdump.c index e28b2da505d..3ccb02dd65e 100644 --- a/external/mpl/bind/dist/lib/dns/masterdump.c +++ b/external/mpl/bind/dist/lib/dns/masterdump.c @@ -1,4 +1,4 @@ -/* $NetBSD: masterdump.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: masterdump.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -83,6 +83,9 @@ struct dns_master_style { */ #define DNS_TOTEXT_LINEBREAK_MAXLEN 100 +/*% Does the rdataset 'r' contain a stale answer? */ +#define STALE(r) (((r)->attributes & DNS_RDATASETATTR_STALE) != 0) + /*% * Context structure for a masterfile dump in progress. */ @@ -1042,8 +1045,12 @@ dump_rdatasets_text(isc_mem_t *mctx, const dns_name_t *name, /* Omit negative cache entries */ } else { isc_result_t result; - if (rds->ttl < ctx->serve_stale_ttl) - fprintf(f, "; stale\n"); + if (STALE(rds)) { + fprintf(f, "; stale (will be retained for " + "%u more seconds)\n", + (rds->stale_ttl - + ctx->serve_stale_ttl)); + } result = dump_rdataset(mctx, name, rds, ctx, buffer, f); if (result != ISC_R_SUCCESS) dumpresult = result; @@ -1511,13 +1518,14 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, dctx->do_date = dns_db_iscache(dctx->db); if (dctx->do_date) { - /* - * Adjust the date backwards by the serve-stale TTL, if any. - * This is so the TTL will be loaded correctly when next started. - */ - (void)dns_db_getservestalettl(dctx->db, - &dctx->tctx.serve_stale_ttl); - dctx->now -= dctx->tctx.serve_stale_ttl; + /* + * Adjust the date backwards by the serve-stale TTL, if any. + * This is so the TTL will be loaded correctly when next + * started. + */ + (void)dns_db_getservestalettl(dctx->db, + &dctx->tctx.serve_stale_ttl); + dctx->now -= dctx->tctx.serve_stale_ttl; } if (dctx->format == dns_masterformat_text && diff --git a/external/mpl/bind/dist/lib/dns/message.c b/external/mpl/bind/dist/lib/dns/message.c index a97c19e669a..49b2c289560 100644 --- a/external/mpl/bind/dist/lib/dns/message.c +++ b/external/mpl/bind/dist/lib/dns/message.c @@ -1,4 +1,4 @@ -/* $NetBSD: message.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: message.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -2803,7 +2803,6 @@ dns_message_settsigkey(dns_message_t *msg, dns_tsigkey_t *key) { */ REQUIRE(DNS_MESSAGE_VALID(msg)); - REQUIRE(msg->state == DNS_SECTION_ANY); if (key == NULL && msg->tsigkey != NULL) { if (msg->sig_reserved != 0) { diff --git a/external/mpl/bind/dist/lib/dns/ncache.c b/external/mpl/bind/dist/lib/dns/ncache.c index 6459a990899..c289b770a24 100644 --- a/external/mpl/bind/dist/lib/dns/ncache.c +++ b/external/mpl/bind/dist/lib/dns/ncache.c @@ -1,4 +1,4 @@ -/* $NetBSD: ncache.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: ncache.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -30,7 +30,7 @@ #include <dns/rdataset.h> #include <dns/rdatastruct.h> -#define DNS_NCACHE_RDATA 20U +#define DNS_NCACHE_RDATA 100U /* * The format of an ncache rdata is a sequence of zero or more records of @@ -135,7 +135,7 @@ addoptout(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node, dns_rdata_t rdata[DNS_NCACHE_RDATA]; dns_rdataset_t ncrdataset; dns_rdatalist_t ncrdatalist; - unsigned char data[4096]; + unsigned char data[65536]; unsigned int next = 0; /* diff --git a/external/mpl/bind/dist/lib/dns/nsec3.c b/external/mpl/bind/dist/lib/dns/nsec3.c index 54fc7a96054..302303e815c 100644 --- a/external/mpl/bind/dist/lib/dns/nsec3.c +++ b/external/mpl/bind/dist/lib/dns/nsec3.c @@ -1,4 +1,4 @@ -/* $NetBSD: nsec3.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: nsec3.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -1813,8 +1813,18 @@ dns_nsec3_maxiterations(dns_db_t *db, dns_dbversion_t *version, result == ISC_R_SUCCESS; result = dns_rdataset_next(&rdataset)) { dns_rdata_t rdata = DNS_RDATA_INIT; - dns_rdataset_current(&rdataset, &rdata); + + REQUIRE(rdata.type == dns_rdatatype_key || + rdata.type == dns_rdatatype_dnskey); + REQUIRE(rdata.length > 3); + + /* Skip unsupported algorithms when + * calculating the maximum iterations. + */ + if (!dst_algorithm_supported(rdata.data[3])) + continue; + isc_buffer_init(&buffer, rdata.data, rdata.length); isc_buffer_add(&buffer, rdata.length); CHECK(dst_key_fromdns(dns_db_origin(db), rdataset.rdclass, diff --git a/external/mpl/bind/dist/lib/dns/opensslrsa_link.c b/external/mpl/bind/dist/lib/dns/opensslrsa_link.c index bd00472b352..26456e3eee9 100644 --- a/external/mpl/bind/dist/lib/dns/opensslrsa_link.c +++ b/external/mpl/bind/dist/lib/dns/opensslrsa_link.c @@ -1,4 +1,4 @@ -/* $NetBSD: opensslrsa_link.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: opensslrsa_link.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -193,8 +193,7 @@ opensslrsa_createctx(dst_key_t *key, dst_context_t *dctx) { const EVP_MD *type = NULL; UNUSED(key); - REQUIRE(dctx->key->key_alg == DST_ALG_RSAMD5 || - dctx->key->key_alg == DST_ALG_RSASHA1 || + REQUIRE(dctx->key->key_alg == DST_ALG_RSASHA1 || dctx->key->key_alg == DST_ALG_NSEC3RSASHA1 || dctx->key->key_alg == DST_ALG_RSASHA256 || dctx->key->key_alg == DST_ALG_RSASHA512); @@ -203,7 +202,6 @@ opensslrsa_createctx(dst_key_t *key, dst_context_t *dctx) { * Reject incorrect RSA key lengths. */ switch (dctx->key->key_alg) { - case DST_ALG_RSAMD5: case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: /* From RFC 3110 */ @@ -232,9 +230,6 @@ opensslrsa_createctx(dst_key_t *key, dst_context_t *dctx) { return (ISC_R_NOMEMORY); switch (dctx->key->key_alg) { - case DST_ALG_RSAMD5: - type = EVP_md5(); /* MD5 + RSA */ - break; case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: type = EVP_sha1(); /* SHA1 + RSA */ @@ -265,8 +260,7 @@ static void opensslrsa_destroyctx(dst_context_t *dctx) { EVP_MD_CTX *evp_md_ctx = dctx->ctxdata.evp_md_ctx; - REQUIRE(dctx->key->key_alg == DST_ALG_RSAMD5 || - dctx->key->key_alg == DST_ALG_RSASHA1 || + REQUIRE(dctx->key->key_alg == DST_ALG_RSASHA1 || dctx->key->key_alg == DST_ALG_NSEC3RSASHA1 || dctx->key->key_alg == DST_ALG_RSASHA256 || dctx->key->key_alg == DST_ALG_RSASHA512); @@ -281,8 +275,7 @@ static isc_result_t opensslrsa_adddata(dst_context_t *dctx, const isc_region_t *data) { EVP_MD_CTX *evp_md_ctx = dctx->ctxdata.evp_md_ctx; - REQUIRE(dctx->key->key_alg == DST_ALG_RSAMD5 || - dctx->key->key_alg == DST_ALG_RSASHA1 || + REQUIRE(dctx->key->key_alg == DST_ALG_RSASHA1 || dctx->key->key_alg == DST_ALG_NSEC3RSASHA1 || dctx->key->key_alg == DST_ALG_RSASHA256 || dctx->key->key_alg == DST_ALG_RSASHA512); @@ -303,8 +296,7 @@ opensslrsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { EVP_MD_CTX *evp_md_ctx = dctx->ctxdata.evp_md_ctx; EVP_PKEY *pkey = key->keydata.pkey; - REQUIRE(dctx->key->key_alg == DST_ALG_RSAMD5 || - dctx->key->key_alg == DST_ALG_RSASHA1 || + REQUIRE(dctx->key->key_alg == DST_ALG_RSASHA1 || dctx->key->key_alg == DST_ALG_NSEC3RSASHA1 || dctx->key->key_alg == DST_ALG_RSASHA256 || dctx->key->key_alg == DST_ALG_RSASHA512); @@ -335,8 +327,7 @@ opensslrsa_verify2(dst_context_t *dctx, int maxbits, const isc_region_t *sig) { RSA *rsa; int bits; - REQUIRE(dctx->key->key_alg == DST_ALG_RSAMD5 || - dctx->key->key_alg == DST_ALG_RSASHA1 || + REQUIRE(dctx->key->key_alg == DST_ALG_RSASHA1 || dctx->key->key_alg == DST_ALG_NSEC3RSASHA1 || dctx->key->key_alg == DST_ALG_RSASHA256 || dctx->key->key_alg == DST_ALG_RSASHA512); @@ -464,7 +455,6 @@ opensslrsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { * Reject incorrect RSA key lengths. */ switch (key->key_alg) { - case DST_ALG_RSAMD5: case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: /* From RFC 3110 */ diff --git a/external/mpl/bind/dist/lib/dns/pkcs11ecdsa_link.c b/external/mpl/bind/dist/lib/dns/pkcs11ecdsa_link.c index 80021d052e3..a686c0e25a2 100644 --- a/external/mpl/bind/dist/lib/dns/pkcs11ecdsa_link.c +++ b/external/mpl/bind/dist/lib/dns/pkcs11ecdsa_link.c @@ -1,4 +1,4 @@ -/* $NetBSD: pkcs11ecdsa_link.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: pkcs11ecdsa_link.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -839,6 +839,7 @@ pkcs11ecdsa_fetch(dst_key_t *key, const char *engine, const char *label, attr->type = CKA_EC_PARAMS; pubattr = pk11_attribute_bytype(pubec, CKA_EC_PARAMS); + INSIST(pubattr != NULL); attr->pValue = isc_mem_get(key->mctx, pubattr->ulValueLen); if (attr->pValue == NULL) DST_RET(ISC_R_NOMEMORY); @@ -848,6 +849,7 @@ pkcs11ecdsa_fetch(dst_key_t *key, const char *engine, const char *label, attr->type = CKA_EC_POINT; pubattr = pk11_attribute_bytype(pubec, CKA_EC_POINT); + INSIST(pubattr != NULL); attr->pValue = isc_mem_get(key->mctx, pubattr->ulValueLen); if (attr->pValue == NULL) DST_RET(ISC_R_NOMEMORY); diff --git a/external/mpl/bind/dist/lib/dns/pkcs11rsa_link.c b/external/mpl/bind/dist/lib/dns/pkcs11rsa_link.c index 0d432ed0191..c000c31ece8 100644 --- a/external/mpl/bind/dist/lib/dns/pkcs11rsa_link.c +++ b/external/mpl/bind/dist/lib/dns/pkcs11rsa_link.c @@ -1,4 +1,4 @@ -/* $NetBSD: pkcs11rsa_link.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: pkcs11rsa_link.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -83,8 +83,7 @@ pkcs11rsa_createctx_sign(dst_key_t *key, dst_context_t *dctx) { isc_result_t ret; unsigned int i; - REQUIRE(key->key_alg == DST_ALG_RSAMD5 || - key->key_alg == DST_ALG_RSASHA1 || + REQUIRE(key->key_alg == DST_ALG_RSASHA1 || key->key_alg == DST_ALG_NSEC3RSASHA1 || key->key_alg == DST_ALG_RSASHA256 || key->key_alg == DST_ALG_RSASHA512); @@ -93,7 +92,6 @@ pkcs11rsa_createctx_sign(dst_key_t *key, dst_context_t *dctx) { * Reject incorrect RSA key lengths. */ switch (dctx->key->key_alg) { - case DST_ALG_RSAMD5: case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: /* From RFC 3110 */ @@ -235,9 +233,6 @@ pkcs11rsa_createctx_sign(dst_key_t *key, dst_context_t *dctx) { token_key: switch (dctx->key->key_alg) { - case DST_ALG_RSAMD5: - mech.mechanism = CKM_MD5_RSA_PKCS; - break; case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: mech.mechanism = CKM_SHA1_RSA_PKCS; @@ -312,8 +307,7 @@ pkcs11rsa_createctx_verify(dst_key_t *key, unsigned int maxbits, isc_result_t ret; unsigned int i; - REQUIRE(key->key_alg == DST_ALG_RSAMD5 || - key->key_alg == DST_ALG_RSASHA1 || + REQUIRE(key->key_alg == DST_ALG_RSASHA1 || key->key_alg == DST_ALG_NSEC3RSASHA1 || key->key_alg == DST_ALG_RSASHA256 || key->key_alg == DST_ALG_RSASHA512); @@ -322,7 +316,6 @@ pkcs11rsa_createctx_verify(dst_key_t *key, unsigned int maxbits, * Reject incorrect RSA key lengths. */ switch (dctx->key->key_alg) { - case DST_ALG_RSAMD5: case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: /* From RFC 3110 */ @@ -396,9 +389,6 @@ pkcs11rsa_createctx_verify(dst_key_t *key, unsigned int maxbits, ISC_R_FAILURE); switch (dctx->key->key_alg) { - case DST_ALG_RSAMD5: - mech.mechanism = CKM_MD5_RSA_PKCS; - break; case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: mech.mechanism = CKM_SHA1_RSA_PKCS; @@ -579,8 +569,7 @@ pkcs11rsa_createctx(dst_key_t *key, dst_context_t *dctx) { pk11_context_t *pk11_ctx; isc_result_t ret; - REQUIRE(key->key_alg == DST_ALG_RSAMD5 || - key->key_alg == DST_ALG_RSASHA1 || + REQUIRE(key->key_alg == DST_ALG_RSASHA1 || key->key_alg == DST_ALG_NSEC3RSASHA1 || key->key_alg == DST_ALG_RSASHA256 || key->key_alg == DST_ALG_RSASHA512); @@ -590,7 +579,6 @@ pkcs11rsa_createctx(dst_key_t *key, dst_context_t *dctx) { * Reject incorrect RSA key lengths. */ switch (dctx->key->key_alg) { - case DST_ALG_RSAMD5: case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: /* From RFC 3110 */ @@ -615,9 +603,6 @@ pkcs11rsa_createctx(dst_key_t *key, dst_context_t *dctx) { } switch (key->key_alg) { - case DST_ALG_RSAMD5: - mech.mechanism = CKM_MD5; - break; case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: mech.mechanism = CKM_SHA_1; @@ -728,8 +713,7 @@ pkcs11rsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { isc_result_t ret = ISC_R_SUCCESS; unsigned int i; - REQUIRE(key->key_alg == DST_ALG_RSAMD5 || - key->key_alg == DST_ALG_RSASHA1 || + REQUIRE(key->key_alg == DST_ALG_RSASHA1 || key->key_alg == DST_ALG_NSEC3RSASHA1 || key->key_alg == DST_ALG_RSASHA256 || key->key_alg == DST_ALG_RSASHA512); @@ -739,7 +723,6 @@ pkcs11rsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { * Reject incorrect RSA key lengths. */ switch (dctx->key->key_alg) { - case DST_ALG_RSAMD5: case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: /* From RFC 3110 */ @@ -764,11 +747,6 @@ pkcs11rsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { } switch (key->key_alg) { - case DST_ALG_RSAMD5: - der = md5_der; - derlen = sizeof(md5_der); - hashlen = ISC_MD5_DIGESTLENGTH; - break; case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: der = sha1_der; @@ -972,19 +950,13 @@ pkcs11rsa_verify(dst_context_t *dctx, const isc_region_t *sig) { isc_result_t ret = ISC_R_SUCCESS; unsigned int i; - REQUIRE(key->key_alg == DST_ALG_RSAMD5 || - key->key_alg == DST_ALG_RSASHA1 || + REQUIRE(key->key_alg == DST_ALG_RSASHA1 || key->key_alg == DST_ALG_NSEC3RSASHA1 || key->key_alg == DST_ALG_RSASHA256 || key->key_alg == DST_ALG_RSASHA512); REQUIRE(rsa != NULL); switch (key->key_alg) { - case DST_ALG_RSAMD5: - der = md5_der; - derlen = sizeof(md5_der); - hashlen = ISC_MD5_DIGESTLENGTH; - break; case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: der = sha1_der; @@ -1174,7 +1146,6 @@ pkcs11rsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { * Reject incorrect RSA key lengths. */ switch (key->key_alg) { - case DST_ALG_RSAMD5: case DST_ALG_RSASHA1: case DST_ALG_NSEC3RSASHA1: /* From RFC 3110 */ @@ -1704,6 +1675,7 @@ pkcs11rsa_fetch(dst_key_t *key, const char *engine, const char *label, attr->type = CKA_MODULUS; pubattr = pk11_attribute_bytype(pubrsa, CKA_MODULUS); + INSIST(pubattr != NULL); attr->pValue = isc_mem_get(key->mctx, pubattr->ulValueLen); if (attr->pValue == NULL) DST_RET(ISC_R_NOMEMORY); @@ -1713,6 +1685,7 @@ pkcs11rsa_fetch(dst_key_t *key, const char *engine, const char *label, attr->type = CKA_PUBLIC_EXPONENT; pubattr = pk11_attribute_bytype(pubrsa, CKA_PUBLIC_EXPONENT); + INSIST(pubattr != NULL); attr->pValue = isc_mem_get(key->mctx, pubattr->ulValueLen); if (attr->pValue == NULL) DST_RET(ISC_R_NOMEMORY); diff --git a/external/mpl/bind/dist/lib/dns/rbtdb.c b/external/mpl/bind/dist/lib/dns/rbtdb.c index 59a563d5233..a368b87301e 100644 --- a/external/mpl/bind/dist/lib/dns/rbtdb.c +++ b/external/mpl/bind/dist/lib/dns/rbtdb.c @@ -1,4 +1,4 @@ -/* $NetBSD: rbtdb.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: rbtdb.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -1922,6 +1922,7 @@ decrement_reference(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, rbtdb_nodelock_t *nodelock; int bucket = node->locknum; bool no_reference = true; + uint_fast32_t refs; nodelock = &rbtdb->node_locks[bucket]; @@ -1932,7 +1933,8 @@ decrement_reference(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, /* Handle easy and typical case first. */ if (!node->dirty && KEEP_NODE(node, rbtdb)) { if (isc_refcount_decrement(&node->references) == 1) { - isc_refcount_decrement(&nodelock->references); + refs = isc_refcount_decrement(&nodelock->references); + INSIST(refs > 0); return (true); } else { return (false); @@ -1993,7 +1995,8 @@ decrement_reference(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, } else write_locked = true; - INSIST(isc_refcount_decrement(&nodelock->references) > 0); + refs = isc_refcount_decrement(&nodelock->references); + INSIST(refs > 0); if (KEEP_NODE(node, rbtdb)) goto restore_locks; @@ -2978,6 +2981,8 @@ bind_rdataset(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, rdataset->attributes |= DNS_RDATASETATTR_PREFETCH; if (STALE(header)) { rdataset->attributes |= DNS_RDATASETATTR_STALE; + rdataset->stale_ttl = + (rbtdb->serve_stale_ttl + header->rdh_ttl) - now; rdataset->ttl = 0; } rdataset->private1 = rbtdb; diff --git a/external/mpl/bind/dist/lib/dns/rcode.c b/external/mpl/bind/dist/lib/dns/rcode.c index 4e02108c24a..c8d195870db 100644 --- a/external/mpl/bind/dist/lib/dns/rcode.c +++ b/external/mpl/bind/dist/lib/dns/rcode.c @@ -1,4 +1,4 @@ -/* $NetBSD: rcode.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: rcode.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -108,7 +108,6 @@ #define SECALGNAMES \ { DNS_KEYALG_RSAMD5, "RSAMD5", 0 }, \ - { DNS_KEYALG_RSAMD5, "RSA", 0 }, \ { DNS_KEYALG_DH, "DH", 0 }, \ { DNS_KEYALG_DSA, "DSA", 0 }, \ { DNS_KEYALG_RSASHA1, "RSASHA1", 0 }, \ @@ -229,28 +228,36 @@ maybe_numeric(unsigned int *valuep, isc_textregion_t *source, isc_result_t result; uint32_t n; char buffer[NUMBERSIZE]; + int v; if (! isdigit(source->base[0] & 0xff) || source->length > NUMBERSIZE - 1) + { return (ISC_R_BADNUMBER); + } /* * We have a potential number. Try to parse it with * isc_parse_uint32(). isc_parse_uint32() requires * null termination, so we must make a copy. */ - snprintf(buffer, sizeof(buffer), "%.*s", - (int)source->length, source->base); - + v = snprintf(buffer, sizeof(buffer), "%.*s", + (int)source->length, source->base); + if (v < 0 || (unsigned)v != source->length) { + return (ISC_R_BADNUMBER); + } INSIST(buffer[source->length] == '\0'); result = isc_parse_uint32(&n, buffer, 10); - if (result == ISC_R_BADNUMBER && hex_allowed) + if (result == ISC_R_BADNUMBER && hex_allowed) { result = isc_parse_uint32(&n, buffer, 16); - if (result != ISC_R_SUCCESS) + } + if (result != ISC_R_SUCCESS) { return (result); - if (n > max) + } + if (n > max) { return (ISC_R_RANGE); + } *valuep = n; return (ISC_R_SUCCESS); } diff --git a/external/mpl/bind/dist/lib/dns/rdata.c b/external/mpl/bind/dist/lib/dns/rdata.c index e9328b3557b..476a0db93ba 100644 --- a/external/mpl/bind/dist/lib/dns/rdata.c +++ b/external/mpl/bind/dist/lib/dns/rdata.c @@ -1,4 +1,4 @@ -/* $NetBSD: rdata.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: rdata.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -870,13 +870,16 @@ unknown_fromtext(dns_rdataclass_t rdclass, dns_rdatatype_t type, if (result != ISC_R_SUCCESS) return (result); - result = isc_hex_tobuffer(lexer, buf, - (unsigned int)token.value.as_ulong); - if (result != ISC_R_SUCCESS) - goto failure; - if (isc_buffer_usedlength(buf) != token.value.as_ulong) { - result = ISC_R_UNEXPECTEDEND; - goto failure; + if (token.value.as_ulong != 0U) { + result = isc_hex_tobuffer(lexer, buf, + (unsigned int)token.value.as_ulong); + if (result != ISC_R_SUCCESS) { + goto failure; + } + if (isc_buffer_usedlength(buf) != token.value.as_ulong) { + result = ISC_R_UNEXPECTEDEND; + goto failure; + } } if (dns_rdatatype_isknown(type)) { @@ -2286,6 +2289,14 @@ dns_rdatatype_questiononly(dns_rdatatype_t type) { } bool +dns_rdatatype_atcname(dns_rdatatype_t type) { + if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_ATCNAME) != 0) { + return (true); + } + return (false); +} + +bool dns_rdatatype_atparent(dns_rdatatype_t type) { if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_ATPARENT) != 0) return (true); @@ -2312,10 +2323,11 @@ dns_rdatatype_isdnssec(dns_rdatatype_t type) { bool dns_rdatatype_iszonecutauth(dns_rdatatype_t type) { - if ((dns_rdatatype_attributes(type) - & (DNS_RDATATYPEATTR_DNSSEC | DNS_RDATATYPEATTR_ZONECUTAUTH)) + if ((dns_rdatatype_attributes(type) & DNS_RDATATYPEATTR_ZONECUTAUTH) != 0) + { return (true); + } return (false); } diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/cert_37.c b/external/mpl/bind/dist/lib/dns/rdata/generic/cert_37.c index 0c02c5c80d2..0ad8073312a 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/generic/cert_37.c +++ b/external/mpl/bind/dist/lib/dns/rdata/generic/cert_37.c @@ -1,4 +1,4 @@ -/* $NetBSD: cert_37.c,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: cert_37.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -57,7 +57,7 @@ fromtext_cert(ARGS_FROMTEXT) { RETTOK(dns_secalg_fromtext(&secalg, &token.value.as_textregion)); RETERR(mem_tobuffer(target, &secalg, 1)); - return (isc_base64_tobuffer(lexer, target, -1)); + return (isc_base64_tobuffer(lexer, target, -2)); } static inline isc_result_t diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/ds_43.c b/external/mpl/bind/dist/lib/dns/rdata/generic/ds_43.c index 36417a4c099..7698f776c03 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/generic/ds_43.c +++ b/external/mpl/bind/dist/lib/dns/rdata/generic/ds_43.c @@ -1,4 +1,4 @@ -/* $NetBSD: ds_43.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: ds_43.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -18,7 +18,8 @@ #define RDATA_GENERIC_DS_43_C #define RRTYPE_DS_ATTRIBUTES \ - (DNS_RDATATYPEATTR_DNSSEC|DNS_RDATATYPEATTR_ATPARENT) + ( DNS_RDATATYPEATTR_DNSSEC | DNS_RDATATYPEATTR_ZONECUTAUTH | \ + DNS_RDATATYPEATTR_ATPARENT ) #include <isc/md.h> @@ -75,7 +76,7 @@ generic_fromtext_ds(ARGS_FROMTEXT) { length = ISC_SHA384_DIGESTLENGTH; break; default: - length = -1; + length = -2; break; } return (isc_hex_tobuffer(lexer, target, length)); diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/ipseckey_45.c b/external/mpl/bind/dist/lib/dns/rdata/generic/ipseckey_45.c index 8f10bf7cbe5..7f5cbd15790 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/generic/ipseckey_45.c +++ b/external/mpl/bind/dist/lib/dns/rdata/generic/ipseckey_45.c @@ -1,4 +1,4 @@ -/* $NetBSD: ipseckey_45.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: ipseckey_45.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -110,7 +110,7 @@ fromtext_ipseckey(ARGS_FROMTEXT) { /* * Public key. */ - return (isc_base64_tobuffer(lexer, target, -1)); + return (isc_base64_tobuffer(lexer, target, -2)); } static inline isc_result_t diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/key_25.c b/external/mpl/bind/dist/lib/dns/rdata/generic/key_25.c index ae597d98fae..02ac9a1124d 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/generic/key_25.c +++ b/external/mpl/bind/dist/lib/dns/rdata/generic/key_25.c @@ -1,4 +1,4 @@ -/* $NetBSD: key_25.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: key_25.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -18,11 +18,11 @@ #include <dst/dst.h> -#define RRTYPE_KEY_ATTRIBUTES (0) +#define RRTYPE_KEY_ATTRIBUTES \ + ( DNS_RDATATYPEATTR_ATCNAME | DNS_RDATATYPEATTR_ZONECUTAUTH ) static inline isc_result_t generic_fromtext_key(ARGS_FROMTEXT) { - isc_result_t result; isc_token_t token; dns_secalg_t alg; dns_secproto_t proto; @@ -56,15 +56,7 @@ generic_fromtext_key(ARGS_FROMTEXT) { if ((flags & 0xc000) == 0xc000) return (ISC_R_SUCCESS); - result = isc_base64_tobuffer(lexer, target, -1); - if (result != ISC_R_SUCCESS) - return (result); - - /* Ensure there's at least enough data to compute a key ID for MD5 */ - if (alg == DST_ALG_RSAMD5 && isc_buffer_usedlength(target) < 7) - return (ISC_R_UNEXPECTEDEND); - - return (ISC_R_SUCCESS); + return (isc_base64_tobuffer(lexer, target, -2)); } static inline isc_result_t @@ -137,7 +129,7 @@ generic_totext_key(ARGS_TOTEXT) { } else { dns_rdata_toregion(rdata, &tmpr); snprintf(buf, sizeof(buf), "[key id = %u]", - dst_region_computeid(&tmpr, algorithm)); + dst_region_computeid(&tmpr)); RETERR(str_totext(buf, target)); } @@ -161,7 +153,7 @@ generic_totext_key(ARGS_TOTEXT) { RETERR(str_totext(" ; key id = ", target)); dns_rdata_toregion(rdata, &tmpr); snprintf(buf, sizeof(buf), "%u", - dst_region_computeid(&tmpr, algorithm)); + dst_region_computeid(&tmpr)); RETERR(str_totext(buf, target)); } return (ISC_R_SUCCESS); @@ -193,14 +185,6 @@ generic_fromwire_key(ARGS_FROMWIRE) { RETERR(dns_name_fromwire(&name, source, dctx, options, target)); } - /* - * RSAMD5 computes key ID differently from other - * algorithms: we need to ensure there's enough data - * present for the computation - */ - if (algorithm == DST_ALG_RSAMD5 && sr.length < 3) - return (ISC_R_UNEXPECTEDEND); - isc_buffer_activeregion(source, &sr); isc_buffer_forward(source, sr.length); return (mem_tobuffer(target, sr.base, sr.length)); diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/keydata_65533.c b/external/mpl/bind/dist/lib/dns/rdata/generic/keydata_65533.c index 96fc56483bd..9baec94cdb3 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/generic/keydata_65533.c +++ b/external/mpl/bind/dist/lib/dns/rdata/generic/keydata_65533.c @@ -1,4 +1,4 @@ -/* $NetBSD: keydata_65533.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: keydata_65533.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -23,7 +23,6 @@ static inline isc_result_t fromtext_keydata(ARGS_FROMTEXT) { - isc_result_t result; isc_token_t token; dns_secalg_t alg; dns_secproto_t proto; @@ -78,15 +77,7 @@ fromtext_keydata(ARGS_FROMTEXT) { if ((flags & 0xc000) == 0xc000) return (ISC_R_SUCCESS); - result = isc_base64_tobuffer(lexer, target, -1); - if (result != ISC_R_SUCCESS) - return (result); - - /* Ensure there's at least enough data to compute a key ID for MD5 */ - if (alg == DST_ALG_RSAMD5 && isc_buffer_usedlength(target) < 19) - return (ISC_R_UNEXPECTEDEND); - - return (ISC_R_SUCCESS); + return (isc_base64_tobuffer(lexer, target, -2)); } static inline isc_result_t @@ -192,7 +183,7 @@ totext_keydata(ARGS_TOTEXT) { /* Skip over refresh, addhd, and removehd */ isc_region_consume(&tmpr, 12); snprintf(buf, sizeof(buf), "%u", - dst_region_computeid(&tmpr, algorithm)); + dst_region_computeid(&tmpr)); RETERR(str_totext(buf, target)); if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) { diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/nsec_47.c b/external/mpl/bind/dist/lib/dns/rdata/generic/nsec_47.c index e1f99dd34d2..5a793c9ee46 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/generic/nsec_47.c +++ b/external/mpl/bind/dist/lib/dns/rdata/generic/nsec_47.c @@ -1,4 +1,4 @@ -/* $NetBSD: nsec_47.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: nsec_47.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -20,7 +20,9 @@ * The attributes do not include DNS_RDATATYPEATTR_SINGLETON * because we must be able to handle a parent/child NSEC pair. */ -#define RRTYPE_NSEC_ATTRIBUTES (DNS_RDATATYPEATTR_DNSSEC) +#define RRTYPE_NSEC_ATTRIBUTES \ + ( DNS_RDATATYPEATTR_DNSSEC | DNS_RDATATYPEATTR_ZONECUTAUTH | \ + DNS_RDATATYPEATTR_ATCNAME ) static inline isc_result_t fromtext_nsec(ARGS_FROMTEXT) { diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/openpgpkey_61.c b/external/mpl/bind/dist/lib/dns/rdata/generic/openpgpkey_61.c index 4f21ac73ee6..b3e2dae1b30 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/generic/openpgpkey_61.c +++ b/external/mpl/bind/dist/lib/dns/rdata/generic/openpgpkey_61.c @@ -1,4 +1,4 @@ -/* $NetBSD: openpgpkey_61.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: openpgpkey_61.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -30,7 +30,7 @@ fromtext_openpgpkey(ARGS_FROMTEXT) { /* * Keyring. */ - return (isc_base64_tobuffer(lexer, target, -1)); + return (isc_base64_tobuffer(lexer, target, -2)); } static inline isc_result_t diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/rrsig_46.c b/external/mpl/bind/dist/lib/dns/rdata/generic/rrsig_46.c index c230c1e6004..e2cfdcf392d 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/generic/rrsig_46.c +++ b/external/mpl/bind/dist/lib/dns/rdata/generic/rrsig_46.c @@ -1,4 +1,4 @@ -/* $NetBSD: rrsig_46.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: rrsig_46.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -16,7 +16,9 @@ #ifndef RDATA_GENERIC_RRSIG_46_C #define RDATA_GENERIC_RRSIG_46_C -#define RRTYPE_RRSIG_ATTRIBUTES (DNS_RDATATYPEATTR_DNSSEC) +#define RRTYPE_RRSIG_ATTRIBUTES \ + ( DNS_RDATATYPEATTR_DNSSEC | DNS_RDATATYPEATTR_ZONECUTAUTH | \ + DNS_RDATATYPEATTR_ATCNAME ) static inline isc_result_t fromtext_rrsig(ARGS_FROMTEXT) { @@ -140,7 +142,7 @@ fromtext_rrsig(ARGS_FROMTEXT) { /* * Sig. */ - return (isc_base64_tobuffer(lexer, target, -1)); + return (isc_base64_tobuffer(lexer, target, -2)); } static inline isc_result_t diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/sig_24.c b/external/mpl/bind/dist/lib/dns/rdata/generic/sig_24.c index 3eb4ec87751..8e86885da98 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/generic/sig_24.c +++ b/external/mpl/bind/dist/lib/dns/rdata/generic/sig_24.c @@ -1,4 +1,4 @@ -/* $NetBSD: sig_24.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: sig_24.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -114,7 +114,7 @@ fromtext_sig(ARGS_FROMTEXT) { /* * Sig. */ - return (isc_base64_tobuffer(lexer, target, -1)); + return (isc_base64_tobuffer(lexer, target, -2)); } static inline isc_result_t diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/sshfp_44.c b/external/mpl/bind/dist/lib/dns/rdata/generic/sshfp_44.c index 5452c1ed6ab..339a02a70a2 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/generic/sshfp_44.c +++ b/external/mpl/bind/dist/lib/dns/rdata/generic/sshfp_44.c @@ -1,4 +1,4 @@ -/* $NetBSD: sshfp_44.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: sshfp_44.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -52,7 +52,7 @@ fromtext_sshfp(ARGS_FROMTEXT) { /* * Digest. */ - return (isc_hex_tobuffer(lexer, target, -1)); + return (isc_hex_tobuffer(lexer, target, -2)); } static inline isc_result_t diff --git a/external/mpl/bind/dist/lib/dns/rdata/generic/tlsa_52.c b/external/mpl/bind/dist/lib/dns/rdata/generic/tlsa_52.c index 9823b36be66..4d4c4570222 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/generic/tlsa_52.c +++ b/external/mpl/bind/dist/lib/dns/rdata/generic/tlsa_52.c @@ -1,4 +1,4 @@ -/* $NetBSD: tlsa_52.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: tlsa_52.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -58,7 +58,7 @@ generic_fromtext_tlsa(ARGS_FROMTEXT) { /* * Certificate Association Data. */ - return (isc_hex_tobuffer(lexer, target, -1)); + return (isc_hex_tobuffer(lexer, target, -2)); } static inline isc_result_t diff --git a/external/mpl/bind/dist/lib/dns/rdata/in_1/dhcid_49.c b/external/mpl/bind/dist/lib/dns/rdata/in_1/dhcid_49.c index e2738a93ac2..71eaf5bd2ab 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/in_1/dhcid_49.c +++ b/external/mpl/bind/dist/lib/dns/rdata/in_1/dhcid_49.c @@ -1,4 +1,4 @@ -/* $NetBSD: dhcid_49.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: dhcid_49.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -31,7 +31,7 @@ fromtext_in_dhcid(ARGS_FROMTEXT) { UNUSED(options); UNUSED(callbacks); - return (isc_base64_tobuffer(lexer, target, -1)); + return (isc_base64_tobuffer(lexer, target, -2)); } static inline isc_result_t diff --git a/external/mpl/bind/dist/lib/dns/rdata/in_1/eid_31.c b/external/mpl/bind/dist/lib/dns/rdata/in_1/eid_31.c index eb6a19dc74e..74fb6723c85 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/in_1/eid_31.c +++ b/external/mpl/bind/dist/lib/dns/rdata/in_1/eid_31.c @@ -1,4 +1,4 @@ -/* $NetBSD: eid_31.c,v 1.2 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: eid_31.c,v 1.3 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -30,7 +30,7 @@ fromtext_in_eid(ARGS_FROMTEXT) { UNUSED(rdclass); UNUSED(callbacks); - return (isc_hex_tobuffer(lexer, target, -1)); + return (isc_hex_tobuffer(lexer, target, -2)); } static inline isc_result_t diff --git a/external/mpl/bind/dist/lib/dns/rdata/in_1/nimloc_32.c b/external/mpl/bind/dist/lib/dns/rdata/in_1/nimloc_32.c index 0f207d7cc7a..96ff87ae735 100644 --- a/external/mpl/bind/dist/lib/dns/rdata/in_1/nimloc_32.c +++ b/external/mpl/bind/dist/lib/dns/rdata/in_1/nimloc_32.c @@ -1,4 +1,4 @@ -/* $NetBSD: nimloc_32.c,v 1.2 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: nimloc_32.c,v 1.3 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -30,7 +30,7 @@ fromtext_in_nimloc(ARGS_FROMTEXT) { UNUSED(rdclass); UNUSED(callbacks); - return (isc_hex_tobuffer(lexer, target, -1)); + return (isc_hex_tobuffer(lexer, target, -2)); } static inline isc_result_t diff --git a/external/mpl/bind/dist/lib/dns/resolver.c b/external/mpl/bind/dist/lib/dns/resolver.c index e8242deabc0..f67078586ee 100644 --- a/external/mpl/bind/dist/lib/dns/resolver.c +++ b/external/mpl/bind/dist/lib/dns/resolver.c @@ -1,4 +1,4 @@ -/* $NetBSD: resolver.c,v 1.3 2019/01/09 16:55:11 christos Exp $ */ +/* $NetBSD: resolver.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -255,7 +255,8 @@ typedef enum { typedef enum { badns_unreachable = 0, badns_response, - badns_validation + badns_validation, + badns_forwarder, } badnstype_t; struct fetchctx { @@ -1209,6 +1210,18 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp, dns_adb_timeout(fctx->adb, query->addrinfo); /* + * If "forward first;" is used and a forwarder timed + * out, do not attempt to query it again in this fetch + * context. + */ + if (fctx->fwdpolicy == dns_fwdpolicy_first && + ISFORWARDER(query->addrinfo)) + { + add_bad(fctx, query->addrinfo, ISC_R_TIMEDOUT, + badns_forwarder); + } + + /* * We don't have an RTT for this query. Maybe the * packet was lost, or maybe this server is very * slow. We don't know. Increase the RTT. @@ -1909,6 +1922,15 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, srtt = addrinfo->srtt; /* + * Allow an additional second for the kernel to resend the SYN (or + * SYN without ECN in the case of stupid firewalls blocking ECN + * negotiation) over the current RTT estimate. + */ + if ((options & DNS_FETCHOPT_TCP) != 0) { + srtt += 1000000; + } + + /* * A forwarder needs to make multiple queries. Give it at least * a second to do these in. */ @@ -3178,6 +3200,12 @@ add_bad(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, isc_result_t reason, break; case badns_validation: break; /* counted as 'valfail' */ + case badns_forwarder: + /* + * We were called to prevent the given forwarder from + * being used again for this fetch context. + */ + break; } } @@ -3485,6 +3513,18 @@ fctx_getaddresses(fetchctx_t *fctx, bool badcache) { INSIST(ISC_LIST_EMPTY(fctx->altaddrs)); /* + * If we have DNS_FETCHOPT_NOFORWARD set and forwarding policy + * allows us to not forward - skip forwarders and go straight + * to NSes. This is currently used to make sure that priming query + * gets root servers' IP addresses in ADDITIONAL section. + */ + if ((fctx->options & DNS_FETCHOPT_NOFORWARD) != 0 && + (fctx->fwdpolicy != dns_fwdpolicy_only)) + { + goto normal_nses; + } + + /* * If this fctx has forwarders, use them; otherwise use any * selective forwarders specified in the view; otherwise use the * resolver's forwarders (if any). @@ -3569,7 +3609,7 @@ fctx_getaddresses(fetchctx_t *fctx, bool badcache) { /* * Normal nameservers. */ - + normal_nses: stdoptions = DNS_ADBFIND_WANTEVENT | DNS_ADBFIND_EMPTYEVENT; if (fctx->restarts == 1) { /* @@ -4014,9 +4054,11 @@ fctx_try(fetchctx_t *fctx, bool retrying, bool badcache) { options &= ~DNS_FETCHOPT_QMINIMIZE; fctx_increference(fctx); task = res->buckets[bucketnum].task; + fctx_stoptimer(fctx); result = dns_resolver_createfetch(fctx->res, &fctx->qminname, fctx->qmintype, &fctx->domain, - &fctx->nameservers, NULL, NULL, 0, + &fctx->nameservers, + NULL, NULL, 0, options, 0, fctx->qc, task, resume_qmin, fctx, &fctx->qminrrset, NULL, @@ -4345,13 +4387,12 @@ fctx_timeout(isc_task_t *task, isc_event_t *event) { * timer. */ result = fctx_starttimer(fctx); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { fctx_done(fctx, result, __LINE__); - else - /* - * Keep trying. - */ + } else { + /* Keep trying */ fctx_try(fctx, true, false); + } } isc_event_free(&event); @@ -10175,12 +10216,11 @@ dns_resolver_prime(dns_resolver_t *res) { LOCK(&res->primelock); result = dns_resolver_createfetch(res, dns_rootname, dns_rdatatype_ns, - NULL, NULL, NULL, NULL, 0, 0, - 0, NULL, - res->buckets[0].task, - prime_done, - res, rdataset, NULL, - &res->primefetch); + NULL, NULL, NULL, NULL, 0, + DNS_FETCHOPT_NOFORWARD, 0, + NULL, res->buckets[0].task, + prime_done, res, rdataset, + NULL, &res->primefetch); UNLOCK(&res->primelock); if (result != ISC_R_SUCCESS) { isc_mem_put(res->mctx, rdataset, sizeof(*rdataset)); diff --git a/external/mpl/bind/dist/lib/dns/result.c b/external/mpl/bind/dist/lib/dns/result.c index 20e45933f4c..542d3ed67fa 100644 --- a/external/mpl/bind/dist/lib/dns/result.c +++ b/external/mpl/bind/dist/lib/dns/result.c @@ -1,4 +1,4 @@ -/* $NetBSD: result.c,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: result.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -349,22 +349,22 @@ initialize_action(void) { isc_result_t result; result = isc_result_register(ISC_RESULTCLASS_DNS, DNS_R_NRESULTS, - text, dns_msgcat, DNS_RESULT_RESULTSET); + text, DNS_RESULT_RESULTSET); if (result == ISC_R_SUCCESS) result = isc_result_register(ISC_RESULTCLASS_DNSRCODE, DNS_R_NRCODERESULTS, - rcode_text, dns_msgcat, + rcode_text, DNS_RESULT_RCODERESULTSET); if (result != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_result_register() failed: %u", result); result = isc_result_registerids(ISC_RESULTCLASS_DNS, DNS_R_NRESULTS, - ids, dns_msgcat, DNS_RESULT_RESULTSET); + ids, DNS_RESULT_RESULTSET); if (result == ISC_R_SUCCESS) result = isc_result_registerids(ISC_RESULTCLASS_DNSRCODE, DNS_R_NRCODERESULTS, - rcode_ids, dns_msgcat, + rcode_ids, DNS_RESULT_RCODERESULTSET); if (result != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, @@ -373,7 +373,6 @@ initialize_action(void) { static void initialize(void) { - dns_lib_initmsgcat(); RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS); } @@ -409,7 +408,6 @@ dns_result_torcode(isc_result_t result) { rcode = dns_rcode_noerror; break; case ISC_R_BADBASE64: - case ISC_R_NOSPACE: case ISC_R_RANGE: case ISC_R_UNEXPECTEDEND: case DNS_R_BADAAAA: diff --git a/external/mpl/bind/dist/lib/dns/spnego_asn1.c b/external/mpl/bind/dist/lib/dns/spnego_asn1.c index e0fa98ddcbc..389324199c5 100644 --- a/external/mpl/bind/dist/lib/dns/spnego_asn1.c +++ b/external/mpl/bind/dist/lib/dns/spnego_asn1.c @@ -1,4 +1,4 @@ -/* $NetBSD: spnego_asn1.c,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: spnego_asn1.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -469,25 +469,25 @@ decode_NegTokenInit(const unsigned char *p, size_t len, NegTokenInit * data, siz FORW; { int dce_fix; - if ((dce_fix = fix_dce(reallen, &len)) < 0) - return ASN1_BAD_FORMAT; + if ((dce_fix = fix_dce(reallen, &len)) < 0) { + e = ASN1_BAD_FORMAT; + goto fail; + } { size_t newlen, oldlen; e = der_match_tag(p, len, ASN1_C_CONTEXT, CONS, 0, &l); - if (e) - return e; - else { - p += l; - len -= l; - ret += l; + FORW; + { e = der_get_length(p, len, &newlen, &l); FORW; { int mydce_fix; oldlen = len; - if ((mydce_fix = fix_dce(newlen, &len)) < 0) - return ASN1_BAD_FORMAT; + if ((mydce_fix = fix_dce(newlen, &len)) < 0) { + e = ASN1_BAD_FORMAT; + goto fail; + } e = decode_MechTypeList(p, len, &(data)->mechTypes, &l); FORW; if (mydce_fix) { @@ -513,11 +513,15 @@ decode_NegTokenInit(const unsigned char *p, size_t len, NegTokenInit * data, siz { int mydce_fix; oldlen = len; - if ((mydce_fix = fix_dce(newlen, &len)) < 0) - return ASN1_BAD_FORMAT; + if ((mydce_fix = fix_dce(newlen, &len)) < 0) { + e = ASN1_BAD_FORMAT; + goto fail; + } (data)->reqFlags = malloc(sizeof(*(data)->reqFlags)); - if ((data)->reqFlags == NULL) - return ENOMEM; + if ((data)->reqFlags == NULL) { + e = ENOMEM; + goto fail; + } e = decode_ContextFlags(p, len, (data)->reqFlags, &l); FORW; if (mydce_fix) { @@ -543,11 +547,15 @@ decode_NegTokenInit(const unsigned char *p, size_t len, NegTokenInit * data, siz { int mydce_fix; oldlen = len; - if ((mydce_fix = fix_dce(newlen, &len)) < 0) - return ASN1_BAD_FORMAT; + if ((mydce_fix = fix_dce(newlen, &len)) < 0) { + e = ASN1_BAD_FORMAT; + goto fail; + } (data)->mechToken = malloc(sizeof(*(data)->mechToken)); - if ((data)->mechToken == NULL) - return ENOMEM; + if ((data)->mechToken == NULL) { + e = ENOMEM; + goto fail; + } e = decode_octet_string(p, len, (data)->mechToken, &l); FORW; if (mydce_fix) { @@ -573,11 +581,15 @@ decode_NegTokenInit(const unsigned char *p, size_t len, NegTokenInit * data, siz { int mydce_fix; oldlen = len; - if ((mydce_fix = fix_dce(newlen, &len)) < 0) - return ASN1_BAD_FORMAT; + if ((mydce_fix = fix_dce(newlen, &len)) < 0) { + e = ASN1_BAD_FORMAT; + goto fail; + } (data)->mechListMIC = malloc(sizeof(*(data)->mechListMIC)); - if ((data)->mechListMIC == NULL) - return ENOMEM; + if ((data)->mechListMIC == NULL) { + e = ENOMEM; + goto fail; + } e = decode_octet_string(p, len, (data)->mechListMIC, &l); FORW; if (mydce_fix) { diff --git a/external/mpl/bind/dist/lib/dns/tests/dbversion_test.c b/external/mpl/bind/dist/lib/dns/tests/dbversion_test.c index 1bd6fbb243a..a4883aa4c76 100644 --- a/external/mpl/bind/dist/lib/dns/tests/dbversion_test.c +++ b/external/mpl/bind/dist/lib/dns/tests/dbversion_test.c @@ -1,4 +1,4 @@ -/* $NetBSD: dbversion_test.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: dbversion_test.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -30,7 +30,6 @@ #include <isc/result.h> #include <isc/serial.h> #include <isc/stdtime.h> -#include <isc/msgcat.h> #include <isc/string.h> #include <isc/util.h> @@ -46,7 +45,6 @@ static char tempname[11] = "dtXXXXXXXX"; static dns_db_t *db1 = NULL, *db2 = NULL; static dns_dbversion_t *v1 = NULL, *v2 = NULL; -#ifndef ISC_CHECK_NONE /* * The code below enables us to trap assertion failures for testing * purposes. local_callback() is set as the callback function for @@ -75,9 +73,6 @@ local_callback(const char *file, int line, isc_assertiontype_t type, mock_assert(1, cond, file, line); longjmp(assertion, 1); } -#else -#define check_assertion(function_call) -#endif /* ISC_CHECK_NONE */ static int _setup(void **state) { @@ -85,9 +80,7 @@ _setup(void **state) { UNUSED(state); -#ifndef ISC_CHECK_NONE isc_assertion_setcallback(local_callback); -#endif res = dns_test_begin(NULL, false); assert_int_equal(res, ISC_R_SUCCESS); diff --git a/external/mpl/bind/dist/lib/dns/tests/dnstest.c b/external/mpl/bind/dist/lib/dns/tests/dnstest.c index b0b30cd1280..b90964f7d13 100644 --- a/external/mpl/bind/dist/lib/dns/tests/dnstest.c +++ b/external/mpl/bind/dist/lib/dns/tests/dnstest.c @@ -1,4 +1,4 @@ -/* $NetBSD: dnstest.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: dnstest.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -553,6 +553,7 @@ dns_test_namefromstring(const char *namestr, dns_fixedname_t *fname) { name = dns_fixedname_initname(fname); result = isc_buffer_allocate(mctx, &b, length); + assert_int_equal(result, ISC_R_SUCCESS); isc_buffer_putmem(b, (const unsigned char *) namestr, length); result = dns_name_fromtext(name, b, dns_rootname, 0, NULL); diff --git a/external/mpl/bind/dist/lib/dns/tests/dst_test.c b/external/mpl/bind/dist/lib/dns/tests/dst_test.c index fd9c374e16f..746a4cee89e 100644 --- a/external/mpl/bind/dist/lib/dns/tests/dst_test.c +++ b/external/mpl/bind/dist/lib/dns/tests/dst_test.c @@ -1,4 +1,4 @@ -/* $NetBSD: dst_test.c,v 1.4 2019/01/27 02:08:35 pgoyette Exp $ */ +/* $NetBSD: dst_test.c,v 1.5 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -263,7 +263,6 @@ sig_test(void **state) { dns_secalg_t alg; bool expect; } testcases[] = { - /* XXXOND: Why isn't this failing? */ { "testdata/dst/test1.data", "testdata/dst/test1.ecdsa256sig", diff --git a/external/mpl/bind/dist/lib/dns/tests/rdata_test.c b/external/mpl/bind/dist/lib/dns/tests/rdata_test.c index ccb2b7f0f7f..07e567ec16c 100644 --- a/external/mpl/bind/dist/lib/dns/tests/rdata_test.c +++ b/external/mpl/bind/dist/lib/dns/tests/rdata_test.c @@ -1,4 +1,4 @@ -/* $NetBSD: rdata_test.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: rdata_test.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -29,6 +29,7 @@ #include <isc/hex.h> #include <isc/lex.h> +#include <isc/print.h> #include <isc/stdio.h> #include <isc/types.h> #include <isc/util.h> @@ -564,6 +565,99 @@ atma(void **state) { dns_rdatatype_atma, sizeof(dns_rdata_in_atma_t)); } +/* AMTRELAY RDATA manipulations */ +static void +amtrelay(void **state) { + text_ok_t text_ok[] = { + TEXT_INVALID(""), + TEXT_INVALID("0"), + TEXT_INVALID("0 0"), + /* gatway type 0 */ + TEXT_VALID("0 0 0"), + TEXT_VALID("0 1 0"), + TEXT_INVALID("0 2 0"), /* discovery out of range */ + TEXT_VALID("255 1 0"), /* max precendence */ + TEXT_INVALID("256 1 0"), /* precedence out of range */ + + /* IPv4 gateway */ + TEXT_INVALID("0 0 1"), /* no addresss */ + TEXT_VALID("0 0 1 0.0.0.0"), + TEXT_INVALID("0 0 1 0.0.0.0 x"), /* extra */ + TEXT_INVALID("0 0 1 0.0.0.0.0"), /* bad addresss */ + TEXT_INVALID("0 0 1 ::"), /* bad addresss */ + TEXT_INVALID("0 0 1 ."), /* bad addresss */ + + /* IPv6 gateway */ + TEXT_INVALID("0 0 2"), /* no addresss */ + TEXT_VALID("0 0 2 ::"), + TEXT_INVALID("0 0 2 :: xx"), /* extra */ + TEXT_INVALID("0 0 2 0.0.0.0"), /* bad addresss */ + TEXT_INVALID("0 0 2 ."), /* bad addresss */ + + /* hostname gateway */ + TEXT_INVALID("0 0 3"), /* no name */ + /* IPv4 is a valid name */ + TEXT_VALID_CHANGED("0 0 3 0.0.0.0", "0 0 3 0.0.0.0."), + /* IPv6 is a valid name */ + TEXT_VALID_CHANGED("0 0 3 ::", "0 0 3 ::."), + TEXT_VALID_CHANGED("0 0 3 example", "0 0 3 example."), + TEXT_VALID("0 0 3 example."), + TEXT_INVALID("0 0 3 example. x"), /* extra */ + + /* unknown gateway */ + TEXT_VALID("\\# 2 0004"), + TEXT_VALID("\\# 2 0084"), + TEXT_VALID("\\# 2 007F"), + TEXT_VALID("\\# 3 000400"), + TEXT_VALID("\\# 3 008400"), + TEXT_VALID("\\# 3 00FF00"), + + /* + * Sentinel. + */ + TEXT_SENTINEL() + }; + wire_ok_t wire_ok[] = { + WIRE_INVALID(0x00), + WIRE_VALID(0x00, 0x00), + WIRE_VALID(0x00, 0x80), + WIRE_INVALID(0x00, 0x00, 0x00), + WIRE_INVALID(0x00, 0x80, 0x00), + + WIRE_INVALID(0x00, 0x01), + WIRE_INVALID(0x00, 0x01, 0x00), + WIRE_INVALID(0x00, 0x01, 0x00, 0x00), + WIRE_INVALID(0x00, 0x01, 0x00, 0x00, 0x00), + WIRE_VALID(0x00, 0x01, 0x00, 0x00, 0x00, 0x00), + WIRE_INVALID(0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00), + + WIRE_INVALID(0x00, 0x02), + WIRE_INVALID(0x00, 0x02, 0x00), + WIRE_VALID(0x00, 0x02, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, + 0x12, 0x13, 0x14, 0x15), + WIRE_INVALID(0x00, 0x02, 0x00, 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, + 0x12, 0x13, 0x14, 0x15, 0x16), + + WIRE_INVALID(0x00, 0x03), + WIRE_VALID(0x00, 0x03, 0x00), + WIRE_INVALID(0x00, 0x03, 0x00, 0x00), /* extra */ + + WIRE_VALID(0x00, 0x04), + WIRE_VALID(0x00, 0x04, 0x00), + /* + * Sentinel. + */ + WIRE_SENTINEL() + }; + + UNUSED(state); + + check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in, + dns_rdatatype_amtrelay, sizeof(dns_rdata_amtrelay_t)); +} + /* * CSYNC tests. * @@ -1501,9 +1595,221 @@ wks(void **state) { dns_rdatatype_wks, sizeof(dns_rdata_in_wks_t)); } +/* + * ZONEMD tests. + * + * Excerpted from draft-wessels-dns-zone-digest: + * + * The ZONEMD RDATA wire format is encoded as follows: + * + * 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Serial | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Digest Type | Reserved | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | + * | Digest | + * / / + * / / + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + * 2.1.1. The Serial Field + * + * The Serial field is a 32-bit unsigned integer in network order. It + * is equal to the serial number from the zone's SOA record + * + * 2.1.2. The Digest Type Field + * + * The Digest Type field is an 8-bit unsigned integer that identifies + * the algorithm used to construct the digest. + * + * At the time of this writing, SHA384, with value 1, is the only Digest + * Type defined for ZONEMD records. + * + * 2.1.3. The Reserved Field + * + * The Reserved field is an 8-bit unsigned integer, which is always set + * to zero. + * + * 2.1.4. The Digest Field + * + * The Digest field is a variable-length sequence of octets containing + * the message digest. + */ + +static void +zonemd(void **state) { + text_ok_t text_ok[] = { + TEXT_INVALID(""), + TEXT_INVALID("0"), + TEXT_INVALID("0 0"), + TEXT_INVALID("0 0 0"), + TEXT_INVALID("99999999 0 0"), + TEXT_INVALID("2019020700 0 0 "), + TEXT_INVALID("2019020700 1 0 DEADBEEF"), + TEXT_VALID("2019020700 2 0 DEADBEEF"), + TEXT_VALID("2019020700 255 0 DEADBEEF"), + TEXT_INVALID("2019020700 256 0 DEADBEEF"), + TEXT_VALID("2019020700 2 255 DEADBEEF"), + TEXT_INVALID("2019020700 2 256 DEADBEEF"), + TEXT_VALID("2019020700 1 0 7162D2BB75C047A53DE98767C9192BEB" + "14DB01E7E2267135DAF0230A 19BA4A31" + "6AF6BF64AA5C7BAE24B2992850300509"), + TEXT_SENTINEL() + }; + wire_ok_t wire_ok[] = { + /* + * Short. + */ + WIRE_INVALID(0x00), + /* + * Short. + */ + WIRE_INVALID(0x00, 0x00), + /* + * Short. + */ + WIRE_INVALID(0x00, 0x00, 0x00), + /* + * Short. + */ + WIRE_INVALID(0x00, 0x00, 0x00, 0x00), + /* + * Short. + */ + WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x00), + /* + * Serial + type + reserved only - digest type + * undefined, so we accept the missing digest. + */ + WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x00, 0x00), + /* + * SHA-384 is defined, so we insist there be a digest. + */ + WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x00), + /* + * Four octets, too short for SHA-384. + */ + WIRE_INVALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xde, 0xad, 0xbe, 0xef), + /* + * Digest type undefined, so accept the short digest. + */ + WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0xff, 0x00, + 0xde, 0xad, 0xbe, 0xef), + /* + * 48 octets, valid for SHA-384. + */ + WIRE_VALID(0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, + 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, + 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, + 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, + 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, + 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, + 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, + 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce), + /* + * Sentinel. + */ + WIRE_SENTINEL() + }; + + UNUSED(state); + + check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in, + dns_rdatatype_zonemd, sizeof(dns_rdata_zonemd_t)); +} + +static void +atcname(void **state) { + unsigned int i; + UNUSED(state); +#define UNR "# Unexpected result from dns_rdatatype_atcname for type %u\n" + for (i = 0; i < 0xffffU; i++) { + bool tf = dns_rdatatype_atcname((dns_rdatatype_t)i); + switch (i) { + case dns_rdatatype_nsec: + case dns_rdatatype_key: + case dns_rdatatype_rrsig: + if (!tf) { + print_message(UNR, i); + } + assert_true(tf); + break; + default: + if (tf) { + print_message(UNR, i); + } + assert_false(tf); + break; + } + + } +#undef UNR +} + +static void +atparent(void **state) { + unsigned int i; + UNUSED(state); +#define UNR "# Unexpected result from dns_rdatatype_atparent for type %u\n" + for (i = 0; i < 0xffffU; i++) { + bool tf = dns_rdatatype_atparent((dns_rdatatype_t)i); + switch (i) { + case dns_rdatatype_ds: + if (!tf) { + print_message(UNR, i); + } + assert_true(tf); + break; + default: + if (tf) { + print_message(UNR, i); + } + assert_false(tf); + break; + } + + } +#undef UNR +} + +static void +iszonecutauth(void **state) { + unsigned int i; + UNUSED(state); +#define UNR "# Unexpected result from dns_rdatatype_iszonecutauth for type %u\n" + for (i = 0; i < 0xffffU; i++) { + bool tf = dns_rdatatype_iszonecutauth((dns_rdatatype_t)i); + switch (i) { + case dns_rdatatype_ns: + case dns_rdatatype_ds: + case dns_rdatatype_nsec: + case dns_rdatatype_key: + case dns_rdatatype_rrsig: + if (!tf) { + print_message(UNR, i); + } + assert_true(tf); + break; + default: + if (tf) { + print_message(UNR, i); + } + assert_false(tf); + break; + } + + } +#undef UNR +} + int main(void) { const struct CMUnitTest tests[] = { + cmocka_unit_test_setup_teardown(amtrelay, _setup, _teardown), cmocka_unit_test_setup_teardown(apl, _setup, _teardown), cmocka_unit_test_setup_teardown(atma, _setup, _teardown), cmocka_unit_test_setup_teardown(csync, _setup, _teardown), @@ -1518,6 +1824,10 @@ main(void) { cmocka_unit_test_setup_teardown(nsec3, _setup, _teardown), cmocka_unit_test_setup_teardown(nxt, _setup, _teardown), cmocka_unit_test_setup_teardown(wks, _setup, _teardown), + cmocka_unit_test_setup_teardown(zonemd, _setup, _teardown), + cmocka_unit_test_setup_teardown(atcname, NULL, NULL), + cmocka_unit_test_setup_teardown(atparent, NULL, NULL), + cmocka_unit_test_setup_teardown(iszonecutauth, NULL, NULL), }; return (cmocka_run_group_tests(tests, NULL, NULL)); diff --git a/external/mpl/bind/dist/lib/dns/tests/rsa_test.c b/external/mpl/bind/dist/lib/dns/tests/rsa_test.c index 169ac02f790..069910a3681 100644 --- a/external/mpl/bind/dist/lib/dns/tests/rsa_test.c +++ b/external/mpl/bind/dist/lib/dns/tests/rsa_test.c @@ -1,4 +1,4 @@ -/* $NetBSD: rsa_test.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: rsa_test.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -97,41 +97,6 @@ static unsigned char sigsha1[256] = { 0x27, 0x7f, 0xb6, 0xe0, 0x04, 0x12, 0xd2, 0x81 }; -static unsigned char sigmd5[256] = { - 0xc0, 0x99, 0x90, 0xd6, 0xea, 0xc1, 0x5f, 0xc7, - 0x23, 0x60, 0xfc, 0x13, 0x3d, 0xcc, 0xda, 0x93, - 0x19, 0xf7, 0x22, 0xa9, 0x55, 0xbe, 0x70, 0x3c, - 0x87, 0x24, 0x8a, 0x7e, 0xa7, 0x59, 0x58, 0xd3, - 0x0e, 0x7c, 0x50, 0x3c, 0x81, 0x0f, 0x7a, 0x2b, - 0xb1, 0x94, 0x21, 0x87, 0xe4, 0x87, 0xcd, 0x2b, - 0xb9, 0xf1, 0xb8, 0x26, 0xc1, 0x02, 0xf4, 0x30, - 0x83, 0x41, 0x89, 0x61, 0xcc, 0x3d, 0xe3, 0x0f, - 0xec, 0x4a, 0x74, 0x95, 0x10, 0x65, 0xac, 0xd1, - 0xf5, 0x95, 0xe9, 0x99, 0xa8, 0x45, 0x98, 0x99, - 0xb5, 0xfd, 0x7a, 0x78, 0x80, 0xe5, 0x00, 0x33, - 0xa5, 0x54, 0xe5, 0xa3, 0xc0, 0x1b, 0x6c, 0xb9, - 0x77, 0x52, 0x6f, 0xe5, 0x85, 0xa8, 0xfa, 0x45, - 0x78, 0x49, 0x14, 0xa0, 0x10, 0x58, 0x40, 0x80, - 0x90, 0xc6, 0x55, 0x52, 0x6d, 0x46, 0x58, 0x50, - 0x3d, 0x5e, 0x40, 0x25, 0x51, 0x7c, 0xc4, 0x12, - 0x87, 0x2d, 0x7b, 0x10, 0xcd, 0x80, 0xec, 0x5d, - 0x27, 0x15, 0x09, 0x37, 0x1f, 0xa7, 0x86, 0x15, - 0xd1, 0xdd, 0xf1, 0x86, 0x1e, 0x42, 0x3a, 0xf9, - 0x5a, 0xed, 0x33, 0x07, 0xa9, 0x98, 0x08, 0x79, - 0xc5, 0xa4, 0x09, 0x95, 0x6e, 0x12, 0xfe, 0xee, - 0x49, 0x61, 0xe0, 0x99, 0xaa, 0x34, 0xa5, 0xca, - 0x82, 0xd3, 0x9b, 0x1c, 0x5b, 0x79, 0xf5, 0x0e, - 0x2c, 0x6c, 0x3b, 0x48, 0xd1, 0xbc, 0xd0, 0xda, - 0x73, 0xba, 0xe1, 0x81, 0x48, 0x27, 0x39, 0x2f, - 0x98, 0x77, 0x08, 0xb3, 0xf7, 0x38, 0x28, 0x6d, - 0x02, 0x56, 0xfa, 0x31, 0xbb, 0x14, 0x81, 0x6b, - 0x3c, 0x24, 0xa2, 0x68, 0x7a, 0x0a, 0x53, 0xbd, - 0x9d, 0x57, 0xd0, 0x99, 0x10, 0x28, 0x78, 0x69, - 0x31, 0x93, 0xa4, 0x73, 0x8d, 0x1a, 0xe4, 0xdc, - 0x0c, 0x15, 0xb8, 0x51, 0xd8, 0x66, 0x6a, 0x95, - 0x56, 0x17, 0x0a, 0x45, 0x72, 0xb5, 0xb8, 0xc4 -}; - static unsigned char sigsha256[256] = { 0x83, 0x53, 0x15, 0xfc, 0xca, 0xdb, 0xf6, 0x0d, 0x53, 0x24, 0x5b, 0x5a, 0x8e, 0xd0, 0xbe, 0x5e, @@ -243,26 +208,6 @@ isc_rsa_verify_test(void **state) { dst_context_destroy(&ctx); - /* RSAMD5 */ - - key->key_alg = DST_ALG_RSAMD5; - - ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, - false, 0, &ctx); - assert_int_equal(ret, ISC_R_SUCCESS); - - r.base = d; - r.length = 10; - ret = dst_context_adddata(ctx, &r); - assert_int_equal(ret, ISC_R_SUCCESS); - - r.base = sigmd5; - r.length = 256; - ret = dst_context_verify(ctx, &r); - assert_int_equal(ret, ISC_R_SUCCESS); - - dst_context_destroy(&ctx); - /* RSASHA256 */ key->key_alg = DST_ALG_RSASHA256; @@ -327,4 +272,4 @@ main(void) { return (0); } -#endif +#endif /* HAVE_CMOCKA */ diff --git a/external/mpl/bind/dist/lib/dns/tkey.c b/external/mpl/bind/dist/lib/dns/tkey.c index f1161ab5e98..8d8ec13f0be 100644 --- a/external/mpl/bind/dist/lib/dns/tkey.c +++ b/external/mpl/bind/dist/lib/dns/tkey.c @@ -1,4 +1,4 @@ -/* $NetBSD: tkey.c,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: tkey.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -499,7 +499,7 @@ process_dhtkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name, } static isc_result_t -process_gsstkey(dns_name_t *name, dns_rdata_tkey_t *tkeyin, +process_gsstkey(dns_message_t *msg, dns_name_t *name, dns_rdata_tkey_t *tkeyin, dns_tkeyctx_t *tctx, dns_rdata_tkey_t *tkeyout, dns_tsig_keyring_t *ring) { @@ -517,7 +517,7 @@ process_gsstkey(dns_name_t *name, dns_rdata_tkey_t *tkeyin, * You have to define either a gss credential (principal) to * accept with tkey-gssapi-credential, or you have to * configure a specific keytab (with tkey-gssapi-keytab) in - * order to use gsstkey + * order to use gsstkey. */ if (tctx->gsscred == NULL && tctx->gssapi_keytab == NULL) { tkey_log("process_gsstkey(): no tkey-gssapi-credential " @@ -568,8 +568,9 @@ process_gsstkey(dns_name_t *name, dns_rdata_tkey_t *tkeyin, isc_stdtime_get(&now); if (dns_name_countlabels(principal) == 0U) { - if (tsigkey != NULL) + if (tsigkey != NULL) { dns_tsigkey_detach(&tsigkey); + } } else if (tsigkey == NULL) { #ifdef GSSAPI OM_uint32 gret, minor, lifetime; @@ -591,14 +592,13 @@ process_gsstkey(dns_name_t *name, dns_rdata_tkey_t *tkeyin, RETERR(dns_tsigkey_createfromkey(name, &tkeyin->algorithm, dstkey, true, principal, now, expire, ring->mctx, ring, - NULL)); + &tsigkey)); dst_key_free(&dstkey); tkeyout->inception = now; tkeyout->expire = expire; } else { tkeyout->inception = tsigkey->inception; tkeyout->expire = tsigkey->expire; - dns_tsigkey_detach(&tsigkey); } if (outtoken) { @@ -626,6 +626,18 @@ process_gsstkey(dns_name_t *name, dns_rdata_tkey_t *tkeyin, tkey_log("process_gsstkey(): dns_tsigerror_noerror"); /* XXXSRA */ + /* + * We found a TKEY to respond with. If the request is not TSIG signed, + * we need to make sure the response is signed (see RFC 3645, Section + * 2.2). + */ + if (tsigkey != NULL) { + if (msg->tsigkey == NULL && msg->sig0key == NULL) { + dns_message_settsigkey(msg, tsigkey); + } + dns_tsigkey_detach(&tsigkey); + } + return (ISC_R_SUCCESS); failure: @@ -759,9 +771,9 @@ dns_tkey_processquery(dns_message_t *msg, dns_tkeyctx_t *tctx, result = dns_message_signer(msg, &tsigner); if (result != ISC_R_SUCCESS) { if (tkeyin.mode == DNS_TKEYMODE_GSSAPI && - result == ISC_R_NOTFOUND) - signer = NULL; - else { + result == ISC_R_NOTFOUND) { + signer = NULL; + } else { tkey_log("dns_tkey_processquery: query was not " "properly signed - rejecting"); result = DNS_R_FORMERR; @@ -864,7 +876,7 @@ dns_tkey_processquery(dns_message_t *msg, dns_tkeyctx_t *tctx, break; case DNS_TKEYMODE_GSSAPI: tkeyout.error = dns_rcode_noerror; - RETERR(process_gsstkey(keyname, &tkeyin, tctx, + RETERR(process_gsstkey(msg, keyname, &tkeyin, tctx, &tkeyout, ring)); break; case DNS_TKEYMODE_DELETE: @@ -881,6 +893,7 @@ dns_tkey_processquery(dns_message_t *msg, dns_tkeyctx_t *tctx, } failure_with_tkey: + dns_rdata_init(&rdata); isc_buffer_init(&tkeyoutbuf, tkeyoutdata, sizeof(tkeyoutdata)); result = dns_rdata_fromstruct(&rdata, tkeyout.common.rdclass, @@ -914,6 +927,7 @@ dns_tkey_processquery(dns_message_t *msg, dns_tkeyctx_t *tctx, return (ISC_R_SUCCESS); failure: + if (freetkeyin) dns_rdata_freestruct(&tkeyin); if (!ISC_LIST_EMPTY(namelist)) diff --git a/external/mpl/bind/dist/lib/dns/tsig.c b/external/mpl/bind/dist/lib/dns/tsig.c index 62ea65dd738..e2e7252a746 100644 --- a/external/mpl/bind/dist/lib/dns/tsig.c +++ b/external/mpl/bind/dist/lib/dns/tsig.c @@ -1,4 +1,4 @@ -/* $NetBSD: tsig.c,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: tsig.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -758,15 +758,15 @@ dns_tsigkey_setdeleted(dns_tsigkey_t *key) { isc_result_t dns_tsig_sign(dns_message_t *msg) { - dns_tsigkey_t *key; + dns_tsigkey_t *key = NULL; dns_rdata_any_tsig_t tsig, querytsig; unsigned char data[128]; isc_buffer_t databuf, sigbuf; - isc_buffer_t *dynbuf; + isc_buffer_t *dynbuf = NULL; dns_name_t *owner; dns_rdata_t *rdata = NULL; - dns_rdatalist_t *datalist; - dns_rdataset_t *dataset; + dns_rdatalist_t *datalist = NULL; + dns_rdataset_t *dataset = NULL; isc_region_t r; isc_stdtime_t now; isc_mem_t *mctx; @@ -781,13 +781,15 @@ dns_tsig_sign(dns_message_t *msg) { REQUIRE(VALID_TSIG_KEY(key)); /* - * If this is a response, there should be a query tsig. + * If this is a response, there should be a TSIG in the query with the + * the exception if this is a TKEY request (see RFC 3645, Section 2.2). */ response = is_response(msg); - if (response && msg->querytsig == NULL) - return (DNS_R_EXPECTEDTSIG); - - dynbuf = NULL; + if (response && msg->querytsig == NULL) { + if (msg->tkey != 1) { + return (DNS_R_EXPECTEDTSIG); + } + } mctx = msg->mctx; @@ -830,6 +832,7 @@ dns_tsig_sign(dns_message_t *msg) { unsigned char header[DNS_MESSAGE_HEADERLEN]; isc_buffer_t headerbuf; uint16_t digestbits; + bool querytsig_ok = false; /* * If it is a response, we assume that the request MAC @@ -843,9 +846,15 @@ dns_tsig_sign(dns_message_t *msg) { return (ret); /* - * If this is a response, digest the request's MAC. + * If this is a response, and if there was a TSIG in + * the query, digest the request's MAC. + * + * (Note: querytsig should be non-NULL for all + * responses except TKEY responses. Those may be signed + * with the newly-negotiated TSIG key even if the query + * wasn't signed.) */ - if (response) { + if (response && msg->querytsig != NULL) { dns_rdata_t querytsigrdata = DNS_RDATA_INIT; INSIST(msg->verified_sig); @@ -870,14 +879,8 @@ dns_tsig_sign(dns_message_t *msg) { ret = dst_context_adddata(ctx, &r); if (ret != ISC_R_SUCCESS) goto cleanup_context; + querytsig_ok = true; } -#if defined(__clang__) && \ - ( __clang_major__ < 3 || \ - (__clang_major__ == 3 && __clang_minor__ < 2) || \ - (__clang_major__ == 4 && __clang_minor__ < 2)) - /* false positive: http://llvm.org/bugs/show_bug.cgi?id=14461 */ - else memset(&querytsig, 0, sizeof(querytsig)); -#endif /* * Digest the header. @@ -923,8 +926,7 @@ dns_tsig_sign(dns_message_t *msg) { } /* Digest the timesigned and fudge */ isc_buffer_clear(&databuf); - if (tsig.error == dns_tsigerror_badtime) { - INSIST(response); + if (tsig.error == dns_tsigerror_badtime && querytsig_ok) { tsig.timesigned = querytsig.timesigned; } isc_buffer_putuint48(&databuf, tsig.timesigned); @@ -975,19 +977,8 @@ dns_tsig_sign(dns_message_t *msg) { dst_context_destroy(&ctx); digestbits = dst_key_getbits(key->key); if (digestbits != 0) { - /* - * XXXRAY: Is this correct? What is the - * expected behavior when digestbits is not an - * integral multiple of 8? It looks like bytes - * should either be (digestbits/8) or - * (digestbits+7)/8. - * - * In any case, for current algorithms, - * digestbits are an integral multiple of 8, so - * it has the same effect as (digestbits/8). - */ - unsigned int bytes = (digestbits + 1) / 8; - if (response && bytes < querytsig.siglen) + unsigned int bytes = (digestbits + 7) / 8; + if (querytsig_ok && bytes < querytsig.siglen) bytes = querytsig.siglen; if (bytes > isc_buffer_usedlength(&sigbuf)) bytes = isc_buffer_usedlength(&sigbuf); @@ -1366,18 +1357,8 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, if (dns__tsig_algvalid(alg)) { uint16_t digestbits = dst_key_getbits(key); - /* - * XXXRAY: Is this correct? What is the expected - * behavior when digestbits is not an integral multiple - * of 8? It looks like bytes should either be - * (digestbits/8) or (digestbits+7)/8. - * - * In any case, for current algorithms, digestbits are - * an integral multiple of 8, so it has the same effect - * as (digestbits/8). - */ if (tsig.siglen > 0 && digestbits != 0 && - tsig.siglen < ((digestbits + 1) / 8)) + tsig.siglen < ((digestbits + 7) / 8)) { msg->tsigstatus = dns_tsigerror_badtrunc; tsig_log(msg->tsigkey, 2, @@ -1670,19 +1651,8 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) { if (dns__tsig_algvalid(alg)) { uint16_t digestbits = dst_key_getbits(key); - /* - * XXXRAY: Is this correct? What is the - * expected behavior when digestbits is not an - * integral multiple of 8? It looks like bytes - * should either be (digestbits/8) or - * (digestbits+7)/8. - * - * In any case, for current algorithms, - * digestbits are an integral multiple of 8, so - * it has the same effect as (digestbits/8). - */ if (tsig.siglen > 0 && digestbits != 0 && - tsig.siglen < ((digestbits + 1) / 8)) + tsig.siglen < ((digestbits + 7) / 8)) { msg->tsigstatus = dns_tsigerror_badtrunc; tsig_log(msg->tsigkey, 2, diff --git a/external/mpl/bind/dist/lib/dns/validator.c b/external/mpl/bind/dist/lib/dns/validator.c index f4a9e319316..35c0d3df125 100644 --- a/external/mpl/bind/dist/lib/dns/validator.c +++ b/external/mpl/bind/dist/lib/dns/validator.c @@ -1,4 +1,4 @@ -/* $NetBSD: validator.c,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: validator.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -1411,11 +1411,11 @@ get_key(dns_validator_t *val, dns_rdata_rrsig_t *siginfo) { } static dns_keytag_t -compute_keytag(dns_rdata_t *rdata, dns_rdata_dnskey_t *key) { +compute_keytag(dns_rdata_t *rdata) { isc_region_t r; dns_rdata_toregion(rdata, &r); - return (dst_region_computeid(&r, key->algorithm)); + return (dst_region_computeid(&r)); } /*% @@ -1454,7 +1454,7 @@ isselfsigned(dns_validator_t *val) { dns_rdataset_current(rdataset, &rdata); result = dns_rdata_tostruct(&rdata, &key, NULL); RUNTIME_CHECK(result == ISC_R_SUCCESS); - keytag = compute_keytag(&rdata, &key); + keytag = compute_keytag(&rdata); for (result = dns_rdataset_first(sigrdataset); result == ISC_R_SUCCESS; result = dns_rdataset_next(sigrdataset)) @@ -1778,7 +1778,7 @@ keyfromds(dns_validator_t *val, dns_rdataset_t *rdataset, dns_rdata_t *dsrdata, dns_rdataset_current(rdataset, keyrdata); result = dns_rdata_tostruct(keyrdata, &key, NULL); RUNTIME_CHECK(result == ISC_R_SUCCESS); - keytag = compute_keytag(keyrdata, &key); + keytag = compute_keytag(keyrdata); if (keyid != keytag || algorithm != key.algorithm) continue; dns_rdata_reset(&newdsrdata); diff --git a/external/mpl/bind/dist/lib/dns/xfrin.c b/external/mpl/bind/dist/lib/dns/xfrin.c index 7adbc241506..ef8d2807d7d 100644 --- a/external/mpl/bind/dist/lib/dns/xfrin.c +++ b/external/mpl/bind/dist/lib/dns/xfrin.c @@ -1,4 +1,4 @@ -/* $NetBSD: xfrin.c,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: xfrin.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -135,6 +135,13 @@ struct dns_xfrin_ctx { dns_tcpmsg_t tcpmsg; bool tcpmsg_valid; + /*% + * Whether the zone originally had a database attached at the time this + * transfer context was created. Used by maybe_free() when making + * logging decisions. + */ + bool zone_had_db; + dns_db_t *db; dns_dbversion_t *ver; dns_diff_t diff; /*%< Pending database changes */ @@ -659,6 +666,10 @@ dns_xfrin_create(dns_zone_t *zone, dns_rdatatype_t xfrtype, dns_zone_getclass(zone), xfrtype, masteraddr, sourceaddr, dscp, tsigkey, &xfr)); + if (db != NULL) { + xfr->zone_had_db = true; + } + CHECK(xfrin_start(xfr)); xfr->done = done; @@ -823,6 +834,7 @@ xfrin_create(isc_mem_t *mctx, /* tcpmsg */ xfr->tcpmsg_valid = false; + xfr->zone_had_db = false; xfr->db = NULL; if (db != NULL) dns_db_attach(db, &xfr->db); @@ -1515,8 +1527,21 @@ maybe_free(dns_xfrin_ctx_t *xfr) { if (xfr->db != NULL) dns_db_detach(&xfr->db); - if (xfr->zone != NULL) + if (xfr->zone != NULL) { + if (!xfr->zone_had_db && + xfr->shuttingdown && + xfr->shutdown_result == ISC_R_SUCCESS && + dns_zone_gettype(xfr->zone) == dns_zone_mirror) + { + dns_zone_log(xfr->zone, ISC_LOG_INFO, + "mirror zone is now in use"); + } + xfrin_log(xfr, ISC_LOG_DEBUG(99), "freeing transfer context"); + /* + * xfr->zone must not be detached before xfrin_log() is called. + */ dns_zone_idetach(&xfr->zone); + } isc_mem_putanddetach(&xfr->mctx, xfr, sizeof(*xfr)); } diff --git a/external/mpl/bind/dist/lib/dns/zone.c b/external/mpl/bind/dist/lib/dns/zone.c index 8cd27d014e9..5c2e558071f 100644 --- a/external/mpl/bind/dist/lib/dns/zone.c +++ b/external/mpl/bind/dist/lib/dns/zone.c @@ -1,4 +1,4 @@ -/* $NetBSD: zone.c,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: zone.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -738,6 +738,8 @@ static void zone_debuglog(dns_zone_t *zone, const char *, int debuglevel, const char *msg, ...) ISC_FORMAT_PRINTF(4, 5); static void notify_log(dns_zone_t *zone, int level, const char *fmt, ...) ISC_FORMAT_PRINTF(3, 4); +static void dnssec_log(dns_zone_t *zone, int level, const char *fmt, ...) + ISC_FORMAT_PRINTF(3, 4); static void queue_xfrin(dns_zone_t *zone); static isc_result_t update_one_rr(dns_db_t *db, dns_dbversion_t *ver, dns_diff_t *diff, dns_diffop_t op, @@ -3191,19 +3193,21 @@ zone_check_dnskeys(dns_zone_t *zone, dns_db_t *db) { dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdataset_t rdataset; isc_result_t result; - bool logit, foundrsa = false, foundmd5 = false; + bool logit, foundrsa = false; const char *algorithm; result = dns_db_findnode(db, &zone->origin, false, &node); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { goto cleanup; + } dns_db_currentversion(db, &version); dns_rdataset_init(&rdataset); result = dns_db_findrdataset(db, node, version, dns_rdatatype_dnskey, dns_rdatatype_none, 0, &rdataset, NULL); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { goto cleanup; + } for (result = dns_rdataset_first(&rdataset); result == ISC_R_SUCCESS; @@ -3213,37 +3217,49 @@ zone_check_dnskeys(dns_zone_t *zone, dns_db_t *db) { result = dns_rdata_tostruct(&rdata, &dnskey, NULL); INSIST(result == ISC_R_SUCCESS); - if ((dnskey.algorithm == DST_ALG_RSASHA1 || - dnskey.algorithm == DST_ALG_RSAMD5) && - dnskey.datalen > 1 && dnskey.data[0] == 1 && - dnskey.data[1] == 3) + /* RFC 3110, section 4: Performance Considerations: + * + * A public exponent of 3 minimizes the effort needed to verify + * a signature. Use of 3 as the public exponent is weak for + * confidentiality uses since, if the same data can be collected + * encrypted under three different keys with an exponent of 3 + * then, using the Chinese Remainder Theorem [NETSEC], the + * original plain text can be easily recovered. If a key is + * known to be used only for authentication, as is the case with + * DNSSEC, then an exponent of 3 is acceptable. However other + * applications in the future may wish to leverage DNS + * distributed keys for applications that do require + * confidentiality. For keys which might have such other uses, + * a more conservative choice would be 65537 (F4, the fourth + * fermat number). + */ + if (dnskey.algorithm == DST_ALG_RSASHA1 && + dnskey.datalen > 1 && dnskey.data[0] == 1 && + dnskey.data[1] == 3) { if (dnskey.algorithm == DST_ALG_RSASHA1) { logit = !foundrsa; foundrsa = true; algorithm = "RSASHA1"; - } else { - logit = !foundmd5; - foundmd5 = true; - algorithm = "RSAMD5"; } - if (logit) - dns_zone_log(zone, ISC_LOG_WARNING, - "weak %s (%u) key found " - "(exponent=3)", algorithm, - dnskey.algorithm); - if (foundrsa && foundmd5) - break; + if (logit) { + dnssec_log(zone, ISC_LOG_WARNING, + "weak %s (%u) key found " + "(exponent=3)", algorithm, + dnskey.algorithm); + } } dns_rdata_reset(&rdata); } dns_rdataset_disassociate(&rdataset); cleanup: - if (node != NULL) + if (node != NULL) { dns_db_detachnode(db, &node); - if (version != NULL) + } + if (version != NULL) { dns_db_closeversion(db, &version, false); + } } static void @@ -3256,15 +3272,18 @@ resume_signingwithkey(dns_zone_t *zone) { dns_db_t *db = NULL; ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read); - if (zone->db != NULL) + if (zone->db != NULL) { dns_db_attach(zone->db, &db); + } ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read); - if (db == NULL) + if (db == NULL) { goto cleanup; + } result = dns_db_findnode(db, &zone->origin, false, &node); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { goto cleanup; + } dns_db_currentversion(db, &version); dns_rdataset_init(&rdataset); @@ -3283,7 +3302,8 @@ resume_signingwithkey(dns_zone_t *zone) { { dns_rdataset_current(&rdataset, &rdata); if (rdata.length != 5 || - rdata.data[0] == 0 || rdata.data[4] != 0) { + rdata.data[0] == 0 || rdata.data[4] != 0) + { dns_rdata_reset(&rdata); continue; } @@ -3292,9 +3312,9 @@ resume_signingwithkey(dns_zone_t *zone) { (rdata.data[1] << 8) | rdata.data[2], rdata.data[3]); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_signwithkey failed: %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_signwithkey failed: %s", + dns_result_totext(result)); } dns_rdata_reset(&rdata); } @@ -3302,10 +3322,12 @@ resume_signingwithkey(dns_zone_t *zone) { cleanup: if (db != NULL) { - if (node != NULL) + if (node != NULL) { dns_db_detachnode(db, &node); - if (version != NULL) + } + if (version != NULL) { dns_db_closeversion(db, &version, false); + } dns_db_detach(&db); } } @@ -3329,8 +3351,9 @@ zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) { dns_db_t *db = NULL; ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read); - if (zone->db != NULL) + if (zone->db != NULL) { dns_db_attach(zone->db, &db); + } ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read); if (db == NULL) { @@ -3382,45 +3405,47 @@ zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) { /* * Log NSEC3 parameters defined by supplied NSEC3PARAM RDATA. */ - if (nsec3param->flags == 0) + if (nsec3param->flags == 0) { strlcpy(flags, "NONE", sizeof(flags)); - else { + } else { flags[0] = '\0'; if ((nsec3param->flags & DNS_NSEC3FLAG_REMOVE) != 0) { strlcat(flags, "REMOVE", sizeof(flags)); } if ((nsec3param->flags & DNS_NSEC3FLAG_INITIAL) != 0) { - if (flags[0] == '\0') + if (flags[0] == '\0') { strlcpy(flags, "INITIAL", sizeof(flags)); - else + } else { strlcat(flags, "|INITIAL", sizeof(flags)); + } } if ((nsec3param->flags & DNS_NSEC3FLAG_CREATE) != 0) { - if (flags[0] == '\0') + if (flags[0] == '\0') { strlcpy(flags, "CREATE", sizeof(flags)); - else + } else { strlcat(flags, "|CREATE", sizeof(flags)); + } } if ((nsec3param->flags & DNS_NSEC3FLAG_NONSEC) != 0) { - if (flags[0] == '\0') + if (flags[0] == '\0') { strlcpy(flags, "NONSEC", sizeof(flags)); - else + } else { strlcat(flags, "|NONSEC", sizeof(flags)); + } } if ((nsec3param->flags & DNS_NSEC3FLAG_OPTOUT) != 0) { - if (flags[0] == '\0') + if (flags[0] == '\0') { strlcpy(flags, "OPTOUT", sizeof(flags)); - else + } else { strlcat(flags, "|OPTOUT", sizeof(flags)); + } } } result = dns_nsec3param_salttotext(nsec3param, saltbuf, sizeof(saltbuf)); RUNTIME_CHECK(result == ISC_R_SUCCESS); - dns_zone_log(zone, ISC_LOG_INFO, - "zone_addnsec3chain(%u,%s,%u,%s)", - nsec3param->hash, flags, nsec3param->iterations, - saltbuf); + dnssec_log(zone, ISC_LOG_INFO, "zone_addnsec3chain(%u,%s,%u,%s)", + nsec3param->hash, flags, nsec3param->iterations, saltbuf); /* * If the NSEC3 chain defined by the supplied NSEC3PARAM RDATA is @@ -3429,14 +3454,19 @@ zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) { */ for (current = ISC_LIST_HEAD(zone->nsec3chain); current != NULL; - current = ISC_LIST_NEXT(current, link)) { - if (current->db == db && - current->nsec3param.hash == nsec3param->hash && - current->nsec3param.iterations == nsec3param->iterations && - current->nsec3param.salt_length == nsec3param->salt_length - && !memcmp(current->nsec3param.salt, nsec3param->salt, - nsec3param->salt_length)) + current = ISC_LIST_NEXT(current, link)) + { + if ((current->db == db) && + (current->nsec3param.hash == nsec3param->hash) && + (current->nsec3param.iterations == + nsec3param->iterations) && + (current->nsec3param.salt_length == + nsec3param->salt_length) && + memcmp(current->nsec3param.salt, nsec3param->salt, + nsec3param->salt_length) == 0) + { current->done = true; + } } /* @@ -3445,12 +3475,14 @@ zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) { * creating NSEC3 records for NSEC3 records. */ dns_db_attach(db, &nsec3chain->db); - if ((nsec3chain->nsec3param.flags & DNS_NSEC3FLAG_CREATE) != 0) + if ((nsec3chain->nsec3param.flags & DNS_NSEC3FLAG_CREATE) != 0) { options = DNS_DB_NONSEC3; + } result = dns_db_createiterator(nsec3chain->db, options, &nsec3chain->dbiterator); - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS) { result = dns_dbiterator_first(nsec3chain->dbiterator); + } if (result == ISC_R_SUCCESS) { /* * Database iterator initialization succeeded. We are now @@ -3467,22 +3499,26 @@ zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) { if (isc_time_isepoch(&zone->nsec3chaintime)) { TIME_NOW(&now); zone->nsec3chaintime = now; - if (zone->task != NULL) + if (zone->task != NULL) { zone_settimer(zone, &now); + } } } if (nsec3chain != NULL) { - if (nsec3chain->db != NULL) + if (nsec3chain->db != NULL) { dns_db_detach(&nsec3chain->db); - if (nsec3chain->dbiterator != NULL) + } + if (nsec3chain->dbiterator != NULL) { dns_dbiterator_destroy(&nsec3chain->dbiterator); + } isc_mem_put(zone->mctx, nsec3chain, sizeof *nsec3chain); } cleanup: - if (db != NULL) + if (db != NULL) { dns_db_detach(&db); + } return (result); } @@ -3509,15 +3545,18 @@ resume_addnsec3chain(dns_zone_t *zone) { return; ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read); - if (zone->db != NULL) + if (zone->db != NULL) { dns_db_attach(zone->db, &db); + } ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read); - if (db == NULL) + if (db == NULL) { goto cleanup; + } result = dns_db_findnode(db, &zone->origin, false, &node); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { goto cleanup; + } dns_db_currentversion(db, &version); @@ -3556,7 +3595,9 @@ resume_addnsec3chain(dns_zone_t *zone) { */ if (!dns_nsec3param_fromprivate(&private, &rdata, buf, sizeof(buf))) + { continue; + } result = dns_rdata_tostruct(&rdata, &nsec3param, NULL); RUNTIME_CHECK(result == ISC_R_SUCCESS); if (((nsec3param.flags & DNS_NSEC3FLAG_REMOVE) != 0) || @@ -3569,19 +3610,22 @@ resume_addnsec3chain(dns_zone_t *zone) { */ result = zone_addnsec3chain(zone, &nsec3param); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_addnsec3chain failed: %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_addnsec3chain failed: %s", + dns_result_totext(result)); } } } dns_rdataset_disassociate(&rdataset); + cleanup: if (db != NULL) { - if (node != NULL) + if (node != NULL) { dns_db_detachnode(db, &node); - if (version != NULL) + } + if (version != NULL) { dns_db_closeversion(db, &version, false); + } dns_db_detach(&db); } } @@ -3641,8 +3685,8 @@ check_nsec3param(dns_zone_t *zone, dns_db_t *db) { bool ok = false; isc_result_t result; dns_rdata_t rdata = DNS_RDATA_INIT; - bool dynamic = (zone->type == dns_zone_master) ? - dns_zone_isdynamic(zone, false) : false; + bool dynamic = (zone->type == dns_zone_master) + ? dns_zone_isdynamic(zone, false) : false; dns_rdataset_init(&rdataset); result = dns_db_findnode(db, &zone->origin, false, &node); @@ -3704,11 +3748,13 @@ check_nsec3param(dns_zone_t *zone, dns_db_t *db) { dns_zone_log(zone, ISC_LOG_WARNING, "unsupported nsec3 hash algorithm: %u", nsec3param.hash); - } else + } else { ok = true; + } } - if (result == ISC_R_NOMORE) + if (result == ISC_R_NOMORE) { result = ISC_R_SUCCESS; + } if (!ok) { result = DNS_R_BADZONE; @@ -3717,8 +3763,9 @@ check_nsec3param(dns_zone_t *zone, dns_db_t *db) { } cleanup: - if (dns_rdataset_isassociated(&rdataset)) + if (dns_rdataset_isassociated(&rdataset)) { dns_rdataset_disassociate(&rdataset); + } dns_db_closeversion(db, &version, false); dns_db_detachnode(db, &node); return (result); @@ -3886,9 +3933,10 @@ compute_tag(dns_name_t *name, dns_rdata_dnskey_t *dnskey, isc_mem_t *mctx, dns_rdatatype_dnskey, dnskey, &buffer); result = dns_dnssec_keyfromrdata(name, &rdata, mctx, &dstkey); - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS) { *tag = dst_key_id(dstkey); - dst_key_free(&dstkey); + dst_key_free(&dstkey); + } return (result); } @@ -3971,14 +4019,16 @@ load_secroots(dns_zone_t *zone, dns_name_t *name, dns_rdataset_t *rdataset) { /* Now insert all the accepted trust anchors from this keydata set. */ for (result = dns_rdataset_first(rdataset); result == ISC_R_SUCCESS; - result = dns_rdataset_next(rdataset)) { + result = dns_rdataset_next(rdataset)) + { dns_rdata_reset(&rdata); dns_rdataset_current(rdataset, &rdata); /* Convert rdata to keydata. */ result = dns_rdata_tostruct(&rdata, &keydata, NULL); - if (result == ISC_R_UNEXPECTEDEND) + if (result == ISC_R_UNEXPECTEDEND) { continue; + } RUNTIME_CHECK(result == ISC_R_SUCCESS); /* Set the key refresh timer to force a fast refresh. */ @@ -4004,20 +4054,19 @@ load_secroots(dns_zone_t *zone, dns_name_t *name, dns_rdataset_t *rdataset) { /* Add to keytables. */ trusted++; - trust_key(zone, name, &dnskey, - (keydata.addhd == 0), mctx); + trust_key(zone, name, &dnskey, (keydata.addhd == 0), mctx); } if (trusted == 0 && pending != 0) { char namebuf[DNS_NAME_FORMATSIZE]; dns_name_format(name, namebuf, sizeof namebuf); - dns_zone_log(zone, ISC_LOG_ERROR, - "No valid trust anchors for '%s'!", namebuf); - dns_zone_log(zone, ISC_LOG_ERROR, - "%d key(s) revoked, %d still pending", + dnssec_log(zone, ISC_LOG_ERROR, + "No valid trust anchors for '%s'!", namebuf); + dnssec_log(zone, ISC_LOG_ERROR, + "%d key(s) revoked, %d still pending", revoked, pending); - dns_zone_log(zone, ISC_LOG_ERROR, - "All queries to '%s' will fail", namebuf); + dnssec_log(zone, ISC_LOG_ERROR, + "All queries to '%s' will fail", namebuf); fail_secure(zone, name); } } @@ -4261,9 +4310,9 @@ sync_keyzone(dns_zone_t *zone, dns_db_t *db) { result = dns_db_newversion(db, &ver); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "sync_keyzone:dns_db_newversion -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "sync_keyzone:dns_db_newversion -> %s", + dns_result_totext(result)); goto failure; } @@ -4277,7 +4326,8 @@ sync_keyzone(dns_zone_t *zone, dns_db_t *db) { dns_rriterator_init(&rrit, db, ver, 0); for (result = dns_rriterator_first(&rrit); result == ISC_R_SUCCESS; - result = dns_rriterator_nextrrset(&rrit)) { + result = dns_rriterator_nextrrset(&rrit)) + { dns_rdataset_t *rdataset = NULL; dns_name_t *rrname = NULL; uint32_t ttl; @@ -4288,8 +4338,9 @@ sync_keyzone(dns_zone_t *zone, dns_db_t *db) { goto failure; } - if (rdataset->type != dns_rdatatype_keydata) + if (rdataset->type != dns_rdatatype_keydata) { continue; + } result = dns_keytable_find(sr, rrname, &keynode); if ((result != ISC_R_SUCCESS && @@ -4303,8 +4354,9 @@ sync_keyzone(dns_zone_t *zone, dns_db_t *db) { load_secroots(zone, rrname, rdataset); } - if (keynode != NULL) + if (keynode != NULL) { dns_keytable_detachkeynode(sr, &keynode); + } } dns_rriterator_destroy(&rrit); @@ -4333,18 +4385,22 @@ sync_keyzone(dns_zone_t *zone, dns_db_t *db) { failure: if (result != ISC_R_SUCCESS && - !DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED)) { - dns_zone_log(zone, ISC_LOG_ERROR, - "unable to synchronize managed keys: %s", - dns_result_totext(result)); + !DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED)) + { + dnssec_log(zone, ISC_LOG_ERROR, + "unable to synchronize managed keys: %s", + dns_result_totext(result)); isc_time_settoepoch(&zone->refreshkeytime); } - if (keynode != NULL) + if (keynode != NULL) { dns_keytable_detachkeynode(sr, &keynode); - if (sr != NULL) + } + if (sr != NULL) { dns_keytable_detach(&sr); - if (ver != NULL) + } + if (ver != NULL) { dns_db_closeversion(db, &ver, commit); + } dns_diff_clear(&diff); INSIST(ver == NULL); @@ -4357,8 +4413,9 @@ dns_zone_synckeyzone(dns_zone_t *zone) { isc_result_t result; dns_db_t *db = NULL; - if (zone->type != dns_zone_key) + if (zone->type != dns_zone_key) { return (DNS_R_BADZONE); + } CHECK(dns_zone_getdb(zone, &db)); @@ -4367,8 +4424,9 @@ dns_zone_synckeyzone(dns_zone_t *zone) { UNLOCK_ZONE(zone); failure: - if (db != NULL) + if (db != NULL) { dns_db_detach(&db); + } return (result); } @@ -4391,8 +4449,8 @@ maybe_send_secure(dns_zone_t *zone) { unsigned int soacount; result = zone_get_from_db(zone->raw, zone->raw->db, - NULL, &soacount, &serial, NULL, - NULL, NULL, NULL, NULL); + NULL, &soacount, &serial, + NULL, NULL, NULL, NULL, NULL); if (result == ISC_R_SUCCESS && soacount > 0U) zone_send_secureserial(zone->raw, serial); } else @@ -4432,12 +4490,14 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, bool needdump = false; bool hasinclude = DNS_ZONE_FLAG(zone, DNS_ZONEFLG_HASINCLUDE); bool nomaster = false; + bool had_db = false; unsigned int options; dns_include_t *inc; INSIST(LOCKED_ZONE(zone)); - if (inline_raw(zone)) + if (inline_raw(zone)) { INSIST(LOCKED_ZONE(zone->secure)); + } TIME_NOW(&now); @@ -4451,18 +4511,20 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, zone->type == dns_zone_mirror || zone->type == dns_zone_stub || (zone->type == dns_zone_redirect && - zone->masters == NULL)) { - if (result == ISC_R_FILENOTFOUND) + zone->masters == NULL)) + { + if (result == ISC_R_FILENOTFOUND) { dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_DEBUG(1), "no master file"); - else if (result != DNS_R_NOMASTERFILE) + } else if (result != DNS_R_NOMASTERFILE) { dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_ERROR, "loading from master file %s " "failed: %s", zone->masterfile, dns_result_totext(result)); + } } else if (zone->type == dns_zone_master && inline_secure(zone) && result == ISC_R_FILENOTFOUND) { @@ -4482,18 +4544,20 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, nomaster = true; } - if (zone->type != dns_zone_key) + if (zone->type != dns_zone_key) { goto cleanup; + } } dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_DEBUG(2), "number of nodes in database: %u", dns_db_nodecount(db)); - if (result == DNS_R_SEENINCLUDE) + if (result == DNS_R_SEENINCLUDE) { DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_HASINCLUDE); - else + } else { DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_HASINCLUDE); + } /* * If there's no master file for a key zone, then the zone is new: @@ -4503,8 +4567,9 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, */ if (nomaster && zone->type == dns_zone_key) { result = add_soa(zone, db); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { goto cleanup; + } } /* @@ -4546,8 +4611,9 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, "journal rollforward completed " "successfully: %s", dns_result_totext(result)); - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS) { needdump = true; + } } /* @@ -4568,7 +4634,8 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, * updates otherwise. */ if (zone->journal != NULL && dns_zone_isdynamic(zone, true) && - ! DNS_ZONE_OPTION(zone, DNS_ZONEOPT_IXFRFROMDIFFS)) { + ! DNS_ZONE_OPTION(zone, DNS_ZONEOPT_IXFRFROMDIFFS)) + { uint32_t jserial; dns_journal_t *journal = NULL; bool empty = false; @@ -4585,11 +4652,12 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, } if (jserial != serial) { - if (!empty) + if (!empty) { dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_INFO, "journal file is out of date: " "removing journal file"); + } if (remove(zone->journal) < 0 && errno != ENOENT) { char strbuf[ISC_STRERRORSIZE]; strerror_r(errno, strbuf, sizeof(strbuf)); @@ -4631,27 +4699,31 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, "has no NS records"); result = DNS_R_BADZONE; } - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { goto cleanup; + } if (zone->type == dns_zone_master && errors != 0) { result = DNS_R_BADZONE; goto cleanup; } if (zone->type != dns_zone_stub && - zone->type != dns_zone_redirect) { + zone->type != dns_zone_redirect) + { result = check_nsec3param(zone, db); if (result != ISC_R_SUCCESS) goto cleanup; } if (zone->type == dns_zone_master && DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKINTEGRITY) && - !integrity_checks(zone, db)) { + !integrity_checks(zone, db)) + { result = DNS_R_BADZONE; goto cleanup; } if (zone->type == dns_zone_master && DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKDUPRR) && - !zone_check_dup(zone, db)) { + !zone_check_dup(zone, db)) + { result = DNS_R_BADZONE; goto cleanup; } @@ -4703,20 +4775,22 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, serialmax); result = DNS_R_BADZONE; goto cleanup; - } else if (!isc_serial_ge(serial, oldserial)) + } else if (!isc_serial_ge(serial, oldserial)) { dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_ERROR, "zone serial (%u/%u) has gone " "backwards", serial, oldserial); - else if (serial == oldserial && !hasinclude && - strcmp(zone->db_argv[0], "_builtin") != 0) + } else if (serial == oldserial && !hasinclude && + strcmp(zone->db_argv[0], "_builtin") != 0) + { dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_ERROR, "zone serial (%u) unchanged. " "zone may fail to transfer " "to slaves.", serial); + } } if (zone->type == dns_zone_master && @@ -4743,26 +4817,32 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, zone->type == dns_zone_mirror || zone->type == dns_zone_stub || (zone->type == dns_zone_redirect && - zone->masters != NULL)) { + zone->masters != NULL)) + { isc_time_t t; uint32_t delay; result = isc_file_getmodtime(zone->journal, &t); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { result = isc_file_getmodtime(zone->masterfile, &t); - if (result == ISC_R_SUCCESS) + } + if (result == ISC_R_SUCCESS) { DNS_ZONE_TIME_ADD(&t, zone->expire, &zone->expiretime); - else + } else { DNS_ZONE_TIME_ADD(&now, zone->retry, &zone->expiretime); + } - delay = zone->retry - isc_random_uniform((zone->retry * 3) / 4); + delay = (zone->retry - + isc_random_uniform((zone->retry * 3) / 4)); DNS_ZONE_TIME_ADD(&now, delay, &zone->refreshtime); if (isc_time_compare(&zone->refreshtime, &zone->expiretime) >= 0) + { zone->refreshtime = now; + } } break; @@ -4784,22 +4864,27 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, /* * Check for weak DNSKEY's. */ - if (zone->type == dns_zone_master) + if (zone->type == dns_zone_master) { zone_check_dnskeys(zone, db); + } /* * Schedule DNSSEC key refresh. */ if (zone->type == dns_zone_master && DNS_ZONEKEY_OPTION(zone, DNS_ZONEKEY_MAINTAIN)) + { zone->refreshkeytime = now; + } ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_write); if (zone->db != NULL) { + had_db = true; result = zone_replacedb(zone, db, false); ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_write); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { goto cleanup; + } } else { zone_attachdb(zone, db); ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_write); @@ -4809,10 +4894,11 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_SENDSECURE) && inline_raw(zone)) { - if (zone->secure->db == NULL) + if (zone->secure->db == NULL) { zone_send_securedb(zone, db); - else + } else { zone_send_secureserial(zone, serial); + } } } @@ -4820,17 +4906,18 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, * Finished loading inline-signing zone; need to get status * from the raw side now. */ - if (zone->type == dns_zone_master && inline_secure(zone)) + if (zone->type == dns_zone_master && inline_secure(zone)) { maybe_send_secure(zone); - + } result = ISC_R_SUCCESS; if (needdump) { - if (zone->type == dns_zone_key) + if (zone->type == dns_zone_key) { zone_needdump(zone, 30); - else + } else { zone_needdump(zone, DNS_DUMP_DELAY); + } } if (zone->task != NULL) { @@ -4843,7 +4930,8 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, if (zone->type == dns_zone_master && !DNS_ZONEKEY_OPTION(zone, DNS_ZONEKEY_NORESIGN) && dns_zone_isdynamic(zone, false) && - dns_db_issecure(db)) { + dns_db_issecure(db)) + { dns_name_t *name; dns_fixedname_t fixed; dns_rdataset_t next; @@ -4861,18 +4949,17 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, dns_name_format(name, namebuf, sizeof(namebuf)); dns_rdatatype_format(next.covers, typebuf, sizeof(typebuf)); - dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, - ISC_LOG_DEBUG(3), - "next resign: %s/%s " - "in %d seconds", namebuf, typebuf, - next.resign - timenow - - zone->sigresigninginterval); + dnssec_log(zone, ISC_LOG_DEBUG(3), + "next resign: %s/%s " + "in %d seconds", namebuf, typebuf, + next.resign - timenow - + zone->sigresigninginterval); dns_rdataset_disassociate(&next); - } else - dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, - ISC_LOG_WARNING, - "signed dynamic zone has no " - "resign event scheduled"); + } else { + dnssec_log(zone, ISC_LOG_WARNING, + "signed dynamic zone has no " + "resign event scheduled"); + } } zone_settimer(zone, &now); @@ -4883,7 +4970,8 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, */ for (inc = ISC_LIST_HEAD(zone->includes); inc != NULL; - inc = ISC_LIST_HEAD(zone->includes)) { + inc = ISC_LIST_HEAD(zone->includes)) + { ISC_LIST_UNLINK(zone->includes, inc, link); isc_mem_free(zone->mctx, inc->name); isc_mem_put(zone->mctx, inc, sizeof(*inc)); @@ -4895,7 +4983,8 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, */ for (inc = ISC_LIST_HEAD(zone->newincludes); inc != NULL; - inc = ISC_LIST_HEAD(zone->newincludes)) { + inc = ISC_LIST_HEAD(zone->newincludes)) + { ISC_LIST_UNLINK(zone->newincludes, inc, link); ISC_LIST_APPEND(zone->includes, inc, link); zone->nincludes++; @@ -4907,15 +4996,20 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, dns_db_issecure(db) ? " (DNSSEC signed)" : ""); } + if (!had_db && zone->type == dns_zone_mirror) { + dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_INFO, + "mirror zone is now in use"); + } + zone->loadtime = loadtime; goto done; cleanup: if (zone->type == dns_zone_key && result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "failed to initialize managed-keys (%s): " - "DNSSEC validation is at risk", - isc_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "failed to initialize managed-keys (%s): " + "DNSSEC validation is at risk", + isc_result_totext(result)); } for (inc = ISC_LIST_HEAD(zone->newincludes); @@ -4930,29 +5024,35 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, zone->type == dns_zone_mirror || zone->type == dns_zone_stub || zone->type == dns_zone_key || - (zone->type == dns_zone_redirect && zone->masters != NULL)) { + (zone->type == dns_zone_redirect && zone->masters != NULL)) + { if (result != ISC_R_NOMEMORY) { - if (zone->journal != NULL) + if (zone->journal != NULL) { zone_saveunique(zone, zone->journal, "jn-XXXXXXXX"); - if (zone->masterfile != NULL) + } + if (zone->masterfile != NULL) { zone_saveunique(zone, zone->masterfile, "db-XXXXXXXX"); + } } /* Mark the zone for immediate refresh. */ zone->refreshtime = now; - if (zone->task != NULL) + if (zone->task != NULL) { zone_settimer(zone, &now); + } result = ISC_R_SUCCESS; } else if (zone->type == dns_zone_master || - zone->type == dns_zone_redirect) { - if (!(inline_secure(zone) && result == ISC_R_FILENOTFOUND)) + zone->type == dns_zone_redirect) + { + if (! (inline_secure(zone) && result == ISC_R_FILENOTFOUND)) { dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_ERROR, "not loaded due to errors."); - else if (zone->type == dns_zone_master) + } else if (zone->type == dns_zone_master) { result = ISC_R_SUCCESS; + } } done: @@ -4972,6 +5072,8 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, DNS_ZONE_CLRFLAG(zone->secure, DNS_ZONEFLG_LOADPENDING); } + zone_debuglog(zone, "zone_postload", 99, "done"); + return (result); } @@ -6847,8 +6949,7 @@ sign_a_node(dns_db_t *db, dns_name_t *name, dns_dbnode_t *node, dns_rdata_t rdata = DNS_RDATA_INIT; isc_buffer_t buffer; unsigned char data[1024]; - bool seen_soa, seen_ns, seen_rr, seen_dname, seen_nsec, - seen_nsec3, seen_ds; + bool seen_soa, seen_ns, seen_rr, seen_nsec, seen_nsec3, seen_ds; result = dns_db_allrdatasets(db, node, version, 0, &iterator); if (result != ISC_R_SUCCESS) { @@ -6859,8 +6960,7 @@ sign_a_node(dns_db_t *db, dns_name_t *name, dns_dbnode_t *node, dns_rdataset_init(&rdataset); isc_buffer_init(&buffer, data, sizeof(data)); - seen_rr = seen_soa = seen_ns = seen_dname = seen_nsec = - seen_nsec3 = seen_ds = false; + seen_rr = seen_soa = seen_ns = seen_nsec = seen_nsec3 = seen_ds = false; for (result = dns_rdatasetiter_first(iterator); result == ISC_R_SUCCESS; result = dns_rdatasetiter_next(iterator)) { @@ -6871,8 +6971,6 @@ sign_a_node(dns_db_t *db, dns_name_t *name, dns_dbnode_t *node, seen_ns = true; else if (rdataset.type == dns_rdatatype_ds) seen_ds = true; - else if (rdataset.type == dns_rdatatype_dname) - seen_dname = true; else if (rdataset.type == dns_rdatatype_nsec) seen_nsec = true; else if (rdataset.type == dns_rdatatype_nsec3) @@ -7586,9 +7684,9 @@ zone_nsec3chain(dns_zone_t *zone) { result = dns_db_newversion(db, &version); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_nsec3chain:dns_db_newversion -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:dns_db_newversion -> %s", + dns_result_totext(result)); goto failure; } @@ -7597,9 +7695,9 @@ zone_nsec3chain(dns_zone_t *zone) { result = dns__zone_findkeys(zone, db, version, now, zone->mctx, DNS_MAXZONEKEYS, zone_keys, &nkeys); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_nsec3chain:dns__zone_findkeys -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:dns__zone_findkeys -> %s", + dns_result_totext(result)); goto failure; } @@ -7638,8 +7736,9 @@ zone_nsec3chain(dns_zone_t *zone) { UNLOCK_ZONE(zone); first = true; - if (nsec3chain != NULL) + if (nsec3chain != NULL) { nsec3chain->save_delete_nsec = nsec3chain->delete_nsec; + } /* * Generate new NSEC3 chains first. * @@ -7725,40 +7824,47 @@ zone_nsec3chain(dns_zone_t *zone) { * Check to see if this is a bottom of zone node. */ result = dns_db_allrdatasets(db, node, version, 0, &iterator); - if (result == ISC_R_NOTFOUND) /* Empty node? */ + if (result == ISC_R_NOTFOUND) { + /* Empty node? */ goto next_addnode; - if (result != ISC_R_SUCCESS) + } + if (result != ISC_R_SUCCESS) { goto failure; + } - seen_soa = seen_ns = seen_dname = seen_ds = seen_nsec = - false; + seen_soa = seen_ns = seen_dname = seen_ds = seen_nsec = false; for (result = dns_rdatasetiter_first(iterator); result == ISC_R_SUCCESS; - result = dns_rdatasetiter_next(iterator)) { + result = dns_rdatasetiter_next(iterator)) + { dns_rdatasetiter_current(iterator, &rdataset); INSIST(rdataset.type != dns_rdatatype_nsec3); - if (rdataset.type == dns_rdatatype_soa) + if (rdataset.type == dns_rdatatype_soa) { seen_soa = true; - else if (rdataset.type == dns_rdatatype_ns) + } else if (rdataset.type == dns_rdatatype_ns) { seen_ns = true; - else if (rdataset.type == dns_rdatatype_dname) + } else if (rdataset.type == dns_rdatatype_dname) { seen_dname = true; - else if (rdataset.type == dns_rdatatype_ds) + } else if (rdataset.type == dns_rdatatype_ds) { seen_ds = true; - else if (rdataset.type == dns_rdatatype_nsec) + } else if (rdataset.type == dns_rdatatype_nsec) { seen_nsec = true; + } dns_rdataset_disassociate(&rdataset); } dns_rdatasetiter_destroy(&iterator); /* * Is there a NSEC chain than needs to be cleaned up? */ - if (seen_nsec) + if (seen_nsec) { nsec3chain->seen_nsec = true; - if (seen_ns && !seen_soa && !seen_ds) + } + if (seen_ns && !seen_soa && !seen_ds) { unsecure = true; - if ((seen_ns && !seen_soa) || seen_dname) + } + if ((seen_ns && !seen_soa) || seen_dname) { delegation = true; + } /* * Process one node. @@ -7769,9 +7875,9 @@ zone_nsec3chain(dns_zone_t *zone) { zone->minimum, unsecure, &nsec3_diff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_nsec3chain:" - "dns_nsec3_addnsec3 -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, "zone_nsec3chain:" + "dns_nsec3_addnsec3 -> %s", + dns_result_totext(result)); goto failure; } @@ -7827,10 +7933,10 @@ zone_nsec3chain(dns_zone_t *zone) { ISC_LIST_APPEND(cleanup, nsec3chain, link); goto next_addchain; } else if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_nsec3chain:" - "dns_dbiterator_next -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:" + "dns_dbiterator_next -> %s", + dns_result_totext(result)); goto failure; } else if (delegation) { dns_dbiterator_current(nsec3chain->dbiterator, @@ -7838,8 +7944,9 @@ zone_nsec3chain(dns_zone_t *zone) { dns_db_detachnode(db, &node); if (!dns_name_issubdomain(nextname, name)) break; - } else + } else { break; + } } while (1); continue; @@ -7852,12 +7959,14 @@ zone_nsec3chain(dns_zone_t *zone) { dns_dbiterator_pause(nsec3chain->dbiterator); nsec3chain = nextnsec3chain; first = true; - if (nsec3chain != NULL) + if (nsec3chain != NULL) { nsec3chain->save_delete_nsec = nsec3chain->delete_nsec; + } } - if (nsec3chain != NULL) + if (nsec3chain != NULL) { goto skip_removals; + } /* * Process removals. @@ -7882,11 +7991,13 @@ zone_nsec3chain(dns_zone_t *zone) { nextnsec3chain = ISC_LIST_NEXT(nsec3chain, link); UNLOCK_ZONE(zone); - if (nsec3chain->db != db) + if (nsec3chain->db != db) { goto next_removechain; + } - if (!NSEC3REMOVE(nsec3chain->nsec3param.flags)) + if (!NSEC3REMOVE(nsec3chain->nsec3param.flags)) { goto next_removechain; + } /* * Work out if we need to build a NSEC chain as a consequence @@ -7899,17 +8010,19 @@ zone_nsec3chain(dns_zone_t *zone) { &nsec3chain->nsec3param, &buildnsecchain); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_nsec3chain:" - "need_nsec_chain -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:" + "need_nsec_chain -> %s", + dns_result_totext(result)); goto failure; } } - if (first) - dns_zone_log(zone, ISC_LOG_DEBUG(3), "zone_nsec3chain:" - "buildnsecchain = %u\n", buildnsecchain); + if (first) { + dnssec_log(zone, ISC_LOG_DEBUG(3), + "zone_nsec3chain:buildnsecchain = %u\n", + buildnsecchain); + } dns_dbiterator_current(nsec3chain->dbiterator, &node, name); delegation = false; @@ -7924,10 +8037,10 @@ zone_nsec3chain(dns_zone_t *zone) { true, privatetype, ¶m_diff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_nsec3chain:" - "fixup_nsec3param -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:" + "fixup_nsec3param -> %s", + dns_result_totext(result)); goto failure; } } @@ -7939,10 +8052,10 @@ zone_nsec3chain(dns_zone_t *zone) { &nsec3chain->nsec3param, &nsec3_diff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_nsec3chain:" - "deletematchingnsec3 -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:" + "deletematchingnsec3 -> %s", + dns_result_totext(result)); goto failure; } goto next_removenode; @@ -7958,7 +8071,8 @@ zone_nsec3chain(dns_zone_t *zone) { NULL, NULL); if ((result == DNS_R_DELEGATION || result == DNS_R_DNAME) && - !dns_name_equal(name, found)) { + !dns_name_equal(name, found)) + { /* * Remember the obscuring name so that * we skip all obscured names. @@ -7973,37 +8087,44 @@ zone_nsec3chain(dns_zone_t *zone) { * Check to see if this is a bottom of zone node. */ result = dns_db_allrdatasets(db, node, version, 0, &iterator); - if (result == ISC_R_NOTFOUND) /* Empty node? */ + if (result == ISC_R_NOTFOUND) { + /* Empty node? */ goto next_removenode; - if (result != ISC_R_SUCCESS) + } + if (result != ISC_R_SUCCESS) { goto failure; + } - seen_soa = seen_ns = seen_dname = seen_nsec3 = seen_nsec = - seen_rr = false; + seen_soa = seen_ns = seen_dname = seen_nsec3 = + seen_nsec = seen_rr = false; for (result = dns_rdatasetiter_first(iterator); result == ISC_R_SUCCESS; - result = dns_rdatasetiter_next(iterator)) { + result = dns_rdatasetiter_next(iterator)) + { dns_rdatasetiter_current(iterator, &rdataset); - if (rdataset.type == dns_rdatatype_soa) + if (rdataset.type == dns_rdatatype_soa) { seen_soa = true; - else if (rdataset.type == dns_rdatatype_ns) + } else if (rdataset.type == dns_rdatatype_ns) { seen_ns = true; - else if (rdataset.type == dns_rdatatype_dname) + } else if (rdataset.type == dns_rdatatype_dname) { seen_dname = true; - else if (rdataset.type == dns_rdatatype_nsec) + } else if (rdataset.type == dns_rdatatype_nsec) { seen_nsec = true; - else if (rdataset.type == dns_rdatatype_nsec3) + } else if (rdataset.type == dns_rdatatype_nsec3) { seen_nsec3 = true; - if (rdataset.type != dns_rdatatype_rrsig) + } else if (rdataset.type != dns_rdatatype_rrsig) { seen_rr = true; + } dns_rdataset_disassociate(&rdataset); } dns_rdatasetiter_destroy(&iterator); - if (!seen_rr || seen_nsec3 || seen_nsec) + if (!seen_rr || seen_nsec3 || seen_nsec) { goto next_removenode; - if ((seen_ns && !seen_soa) || seen_dname) + } + if ((seen_ns && !seen_soa) || seen_dname) { delegation = true; + } /* * Add a NSEC record except at the origin. @@ -8040,27 +8161,29 @@ zone_nsec3chain(dns_zone_t *zone) { privatetype, ¶m_diff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_nsec3chain:" - "fixup_nsec3param -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:" + "fixup_nsec3param -> %s", + dns_result_totext(result)); goto failure; } goto next_removechain; } else if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_nsec3chain:" - "dns_dbiterator_next -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:" + "dns_dbiterator_next -> %s", + dns_result_totext(result)); goto failure; } else if (delegation) { dns_dbiterator_current(nsec3chain->dbiterator, &node, nextname); dns_db_detachnode(db, &node); - if (!dns_name_issubdomain(nextname, name)) + if (!dns_name_issubdomain(nextname, name)) { break; - } else + } + } else { break; + } } while (1); continue; @@ -8087,53 +8210,56 @@ zone_nsec3chain(dns_zone_t *zone) { RUNTIME_CHECK(result == ISC_R_SUCCESS); result = dns_db_allrdatasets(db, node, version, 0, &iterator); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_nsec3chain:" - "dns_db_allrdatasets -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:dns_db_allrdatasets -> %s", + dns_result_totext(result)); goto failure; } for (result = dns_rdatasetiter_first(iterator); result == ISC_R_SUCCESS; - result = dns_rdatasetiter_next(iterator)) { + result = dns_rdatasetiter_next(iterator)) + { dns_rdatasetiter_current(iterator, &rdataset); - if (rdataset.type == dns_rdatatype_nsec) + if (rdataset.type == dns_rdatatype_nsec) { rebuild_nsec = true; - if (rdataset.type == dns_rdatatype_nsec3param) + } else if (rdataset.type == dns_rdatatype_nsec3param) { rebuild_nsec3 = true; + } dns_rdataset_disassociate(&rdataset); } dns_rdatasetiter_destroy(&iterator); dns_db_detachnode(db, &node); if (rebuild_nsec) { - if (nsec3chain != NULL) + if (nsec3chain != NULL) { dns_dbiterator_pause(nsec3chain->dbiterator); + } result = updatesecure(db, version, &zone->origin, zone->minimum, true, &nsec_diff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_nsec3chain:" - "updatesecure -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:updatesecure -> %s", + dns_result_totext(result)); goto failure; } } if (rebuild_nsec3) { - if (nsec3chain != NULL) + if (nsec3chain != NULL) { dns_dbiterator_pause(nsec3chain->dbiterator); + } result = dns_nsec3_addnsec3s(db, version, dns_db_origin(db), zone->minimum, false, &nsec3_diff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_nsec3chain:" - "dns_nsec3_addnsec3s -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:" + "dns_nsec3_addnsec3s -> %s", + dns_result_totext(result)); goto failure; } } @@ -8142,15 +8268,16 @@ zone_nsec3chain(dns_zone_t *zone) { /* * Add / update signatures for the NSEC3 records. */ - if (nsec3chain != NULL) + if (nsec3chain != NULL) { dns_dbiterator_pause(nsec3chain->dbiterator); + } result = dns__zone_updatesigs(&nsec3_diff, db, version, zone_keys, nkeys, zone, inception, expire, 0, now, check_ksk, keyset_kskonly, &zonediff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_nsec3chain:" - "dns__zone_updatesigs -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:dns__zone_updatesigs -> %s", + dns_result_totext(result)); goto failure; } @@ -8162,9 +8289,9 @@ zone_nsec3chain(dns_zone_t *zone) { nkeys, zone, inception, expire, 0, now, check_ksk, keyset_kskonly, &zonediff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_nsec3chain:" - "dns__zone_updatesigs -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:dns__zone_updatesigs -> %s", + dns_result_totext(result)); goto failure; } @@ -8172,9 +8299,9 @@ zone_nsec3chain(dns_zone_t *zone) { result = updatesecure(db, version, &zone->origin, zone->minimum, false, &nsec_diff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_nsec3chain:" - "updatesecure -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:updatesecure -> %s", + dns_result_totext(result)); goto failure; } } @@ -8183,9 +8310,9 @@ zone_nsec3chain(dns_zone_t *zone) { nkeys, zone, inception, expire, 0, now, check_ksk, keyset_kskonly, &zonediff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_nsec3chain:" - "dns__zone_updatesigs -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:dns__zone_updatesigs -> %s", + dns_result_totext(result)); goto failure; } @@ -8204,17 +8331,18 @@ zone_nsec3chain(dns_zone_t *zone) { result = del_sigs(zone, db, version, &zone->origin, dns_rdatatype_soa, &zonediff, zone_keys, nkeys, now, false); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_nsec3chain:" - "del_sigs -> %s", dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:del_sigs -> %s", + dns_result_totext(result)); goto failure; } result = update_soa_serial(db, version, zonediff.diff, zone->mctx, zone->updatemethod); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_nsec3chain:" - "update_soa_serial -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:update_soa_serial -> %s", + dns_result_totext(result)); goto failure; } @@ -8222,8 +8350,9 @@ zone_nsec3chain(dns_zone_t *zone) { zonediff.diff, zone_keys, nkeys, zone->mctx, inception, soaexpire, check_ksk, keyset_kskonly); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_nsec3chain:" - "add_sigs -> %s", dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_nsec3chain:add_sigs -> %s", + dns_result_totext(result)); goto failure; } @@ -8243,7 +8372,9 @@ zone_nsec3chain(dns_zone_t *zone) { for (nsec3chain = ISC_LIST_HEAD(zone->nsec3chain); nsec3chain != NULL; nsec3chain = ISC_LIST_NEXT(nsec3chain, link)) + { dns_dbiterator_pause(nsec3chain->dbiterator); + } UNLOCK_ZONE(zone); /* @@ -8267,9 +8398,11 @@ zone_nsec3chain(dns_zone_t *zone) { set_resigntime(zone); failure: - if (result != ISC_R_SUCCESS) - dns_zone_log(zone, ISC_LOG_ERROR, "zone_nsec3chain: %s", - dns_result_totext(result)); + if (result != ISC_R_SUCCESS) { + dnssec_log(zone, ISC_LOG_ERROR, "zone_nsec3chain: %s", + dns_result_totext(result)); + } + /* * On error roll back the current nsec3chain. */ @@ -8312,7 +8445,9 @@ zone_nsec3chain(dns_zone_t *zone) { for (nsec3chain = ISC_LIST_HEAD(zone->nsec3chain); nsec3chain != NULL; nsec3chain = ISC_LIST_NEXT(nsec3chain, link)) + { dns_dbiterator_pause(nsec3chain->dbiterator); + } UNLOCK_ZONE(zone); dns_diff_clear(¶m_diff); @@ -8320,30 +8455,36 @@ zone_nsec3chain(dns_zone_t *zone) { dns_diff_clear(&nsec_diff); dns_diff_clear(&_sig_diff); - if (iterator != NULL) + if (iterator != NULL) { dns_rdatasetiter_destroy(&iterator); + } - for (i = 0; i < nkeys; i++) + for (i = 0; i < nkeys; i++) { dst_key_free(&zone_keys[i]); + } - if (node != NULL) + if (node != NULL) { dns_db_detachnode(db, &node); + } if (version != NULL) { dns_db_closeversion(db, &version, false); dns_db_detach(&db); - } else if (db != NULL) + } else if (db != NULL) { dns_db_detach(&db); + } LOCK_ZONE(zone); if (ISC_LIST_HEAD(zone->nsec3chain) != NULL) { isc_interval_t interval; - if (zone->update_disabled || result != ISC_R_SUCCESS) + if (zone->update_disabled || result != ISC_R_SUCCESS) { isc_interval_set(&interval, 60, 0); /* 1 minute */ - else + } else { isc_interval_set(&interval, 0, 10000000); /* 10 ms */ + } isc_time_nowplusinterval(&zone->nsec3chaintime, &interval); - } else + } else { isc_time_settoepoch(&zone->nsec3chaintime); + } UNLOCK_ZONE(zone); INSIST(version == NULL); @@ -8497,28 +8638,29 @@ zone_sign(dns_zone_t *zone) { ISC_LIST_INIT(cleanup); /* - * Updates are disabled. Pause for 5 minutes. + * Updates are disabled. Pause for 1 minute. */ if (zone->update_disabled) { result = ISC_R_FAILURE; - goto failure; + goto cleanup; } ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read); - if (zone->db != NULL) + if (zone->db != NULL) { dns_db_attach(zone->db, &db); + } ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read); if (db == NULL) { result = ISC_R_FAILURE; - goto failure; + goto cleanup; } result = dns_db_newversion(db, &version); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_sign:dns_db_newversion -> %s", - dns_result_totext(result)); - goto failure; + dnssec_log(zone, ISC_LOG_ERROR, + "zone_sign:dns_db_newversion -> %s", + dns_result_totext(result)); + goto cleanup; } isc_stdtime_get(&now); @@ -8526,10 +8668,10 @@ zone_sign(dns_zone_t *zone) { result = dns__zone_findkeys(zone, db, version, now, zone->mctx, DNS_MAXZONEKEYS, zone_keys, &nkeys); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_sign:dns__zone_findkeys -> %s", - dns_result_totext(result)); - goto failure; + dnssec_log(zone, ISC_LOG_ERROR, + "zone_sign:dns__zone_findkeys -> %s", + dns_result_totext(result)); + goto cleanup; } sigvalidityinterval = dns_zone_getsigvalidityinterval(zone); @@ -8576,8 +8718,9 @@ zone_sign(dns_zone_t *zone) { &build_nsec, &build_nsec3)); /* If neither chain is found, default to NSEC */ - if (!build_nsec && !build_nsec3) + if (!build_nsec && !build_nsec3) { build_nsec = true; + } while (signing != NULL && nodes-- > 0 && signatures > 0) { bool has_alg = false; @@ -8597,8 +8740,9 @@ zone_sign(dns_zone_t *zone) { } ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read); - if (signing->db != db) + if (signing->db != db) { goto next_signing; + } is_bottom_of_zone = false; @@ -8649,7 +8793,8 @@ zone_sign(dns_zone_t *zone) { NULL, NULL); if ((result == DNS_R_DELEGATION || result == DNS_R_DNAME) && - !dns_name_equal(name, found)) { + !dns_name_equal(name, found)) + { /* * Remember the obscuring name so that * we skip all obscured names. @@ -8676,13 +8821,15 @@ zone_sign(dns_zone_t *zone) { /* * Find the keys we want to sign with. */ - if (!dst_key_isprivate(zone_keys[i])) + if (!dst_key_isprivate(zone_keys[i])) { continue; + } /* * Should be redundant. */ - if (dst_key_inactive(zone_keys[i])) + if (dst_key_inactive(zone_keys[i])) { continue; + } /* * When adding look for the specific key. @@ -8690,7 +8837,9 @@ zone_sign(dns_zone_t *zone) { if (!signing->deleteit && (dst_key_alg(zone_keys[i]) != signing->algorithm || dst_key_id(zone_keys[i]) != signing->keyid)) + { continue; + } /* * When deleting make sure we are properly signed @@ -8698,7 +8847,9 @@ zone_sign(dns_zone_t *zone) { */ if (signing->deleteit && ALG(zone_keys[i]) != signing->algorithm) + { continue; + } /* * Do we do KSK processing? @@ -8714,31 +8865,39 @@ zone_sign(dns_zone_t *zone) { } for (j = 0; j < nkeys; j++) { if (j == i || - ALG(zone_keys[i]) != - ALG(zone_keys[j])) + (ALG(zone_keys[i]) != + ALG(zone_keys[j]))) + { continue; - if (!dst_key_isprivate(zone_keys[j])) + } + if (!dst_key_isprivate(zone_keys[j])) { continue; + } /* * Should be redundant. */ - if (dst_key_inactive(zone_keys[j])) + if (dst_key_inactive(zone_keys[j])) { continue; - if (REVOKE(zone_keys[j])) + } + if (REVOKE(zone_keys[j])) { continue; - if (KSK(zone_keys[j])) + } + if (KSK(zone_keys[j])) { have_ksk = true; - else + } else { have_nonksk = true; + } both = have_ksk && have_nonksk; - if (both) + if (both) { break; + } } } - if (both || REVOKE(zone_keys[i])) + if (both || REVOKE(zone_keys[i])) { is_ksk = KSK(zone_keys[i]); - else + } else { is_ksk = false; + } /* * If deleting signatures, we need to ensure that @@ -8801,11 +8960,10 @@ zone_sign(dns_zone_t *zone) { false, &post_diff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, - ISC_LOG_ERROR, - "updatesecure -> %s", + dnssec_log(zone, ISC_LOG_ERROR, + "updatesecure -> %s", dns_result_totext(result)); - goto failure; + goto cleanup; } } result = updatesignwithkey(zone, signing, @@ -8814,26 +8972,29 @@ zone_sign(dns_zone_t *zone) { zone->minimum, &post_diff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "updatesignwithkey -> %s", - dns_result_totext(result)); - goto failure; + dnssec_log(zone, ISC_LOG_ERROR, + "updatesignwithkey -> %s", + dns_result_totext(result)); + goto cleanup; } build_nsec = false; goto next_signing; } else if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_sign:dns_dbiterator_next -> %s", - dns_result_totext(result)); - goto failure; + dnssec_log(zone, ISC_LOG_ERROR, + "zone_sign:" + "dns_dbiterator_next -> %s", + dns_result_totext(result)); + goto cleanup; } else if (is_bottom_of_zone) { dns_dbiterator_current(signing->dbiterator, &node, nextname); dns_db_detachnode(db, &node); - if (!dns_name_issubdomain(nextname, name)) + if (!dns_name_issubdomain(nextname, name)) { break; - } else + } + } else { break; + } } while (1); continue; @@ -8850,10 +9011,10 @@ zone_sign(dns_zone_t *zone) { check_ksk, keyset_kskonly, &zonediff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_sign:" - "dns__zone_updatesigs -> %s", - dns_result_totext(result)); - goto failure; + dnssec_log(zone, ISC_LOG_ERROR, + "zone_sign:dns__zone_updatesigs -> %s", + dns_result_totext(result)); + goto cleanup; } } @@ -8861,8 +9022,9 @@ zone_sign(dns_zone_t *zone) { * Have we changed anything? */ if (ISC_LIST_EMPTY(zonediff.diff->tuples)) { - if (zonediff.offline) + if (zonediff.offline) { commit = true; + } result = ISC_R_SUCCESS; goto pauseall; } @@ -8872,19 +9034,18 @@ zone_sign(dns_zone_t *zone) { result = del_sigs(zone, db, version, &zone->origin, dns_rdatatype_soa, &zonediff, zone_keys, nkeys, now, false); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_sign:del_sigs -> %s", - dns_result_totext(result)); - goto failure; + dnssec_log(zone, ISC_LOG_ERROR, "zone_sign:del_sigs -> %s", + dns_result_totext(result)); + goto cleanup; } result = update_soa_serial(db, version, zonediff.diff, zone->mctx, zone->updatemethod); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_sign:update_soa_serial -> %s", - dns_result_totext(result)); - goto failure; + dnssec_log(zone, ISC_LOG_ERROR, + "zone_sign:update_soa_serial -> %s", + dns_result_totext(result)); + goto cleanup; } /* @@ -8895,10 +9056,9 @@ zone_sign(dns_zone_t *zone) { zonediff.diff, zone_keys, nkeys, zone->mctx, inception, soaexpire, check_ksk, keyset_kskonly); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_sign:add_sigs -> %s", - dns_result_totext(result)); - goto failure; + dnssec_log(zone, ISC_LOG_ERROR, "zone_sign:add_sigs -> %s", + dns_result_totext(result)); + goto cleanup; } /* @@ -8913,12 +9073,16 @@ zone_sign(dns_zone_t *zone) { for (signing = ISC_LIST_HEAD(zone->signing); signing != NULL; signing = ISC_LIST_NEXT(signing, link)) + { dns_dbiterator_pause(signing->dbiterator); + } for (signing = ISC_LIST_HEAD(cleanup); signing != NULL; signing = ISC_LIST_NEXT(signing, link)) + { dns_dbiterator_pause(signing->dbiterator); + } /* * Everything has succeeded. Commit the changes. @@ -8947,13 +9111,21 @@ zone_sign(dns_zone_t *zone) { } failure: + if (result != ISC_R_SUCCESS) { + dnssec_log(zone, ISC_LOG_ERROR, "zone_sign: failed: %s", + dns_result_totext(result)); + } + + cleanup: /* * Pause all dbiterators. */ for (signing = ISC_LIST_HEAD(zone->signing); signing != NULL; signing = ISC_LIST_NEXT(signing, link)) + { dns_dbiterator_pause(signing->dbiterator); + } /* * Rollback the cleanup list. @@ -8969,27 +9141,32 @@ zone_sign(dns_zone_t *zone) { dns_diff_clear(&_sig_diff); - for (i = 0; i < nkeys; i++) + for (i = 0; i < nkeys; i++) { dst_key_free(&zone_keys[i]); + } - if (node != NULL) + if (node != NULL) { dns_db_detachnode(db, &node); + } if (version != NULL) { dns_db_closeversion(db, &version, false); dns_db_detach(&db); - } else if (db != NULL) + } else if (db != NULL) { dns_db_detach(&db); + } if (ISC_LIST_HEAD(zone->signing) != NULL) { isc_interval_t interval; - if (zone->update_disabled || result != ISC_R_SUCCESS) + if (zone->update_disabled || result != ISC_R_SUCCESS) { isc_interval_set(&interval, 60, 0); /* 1 minute */ - else + } else { isc_interval_set(&interval, 0, 10000000); /* 10 ms */ + } isc_time_nowplusinterval(&zone->signingtime, &interval); - } else + } else { isc_time_settoepoch(&zone->signingtime); + } INSIST(version == NULL); } @@ -9221,8 +9398,9 @@ revocable(dns_keyfetch_t *kfetch, dns_rdata_keydata_t *keydata) { dns_rdata_fromstruct(&rr, keydata->common.rdclass, dns_rdatatype_dnskey, &dnskey, &keyb); result = dns_dnssec_keyfromrdata(keyname, &rr, mctx, &dstkey); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { return (false); + } /* See if that key generated any of the signatures */ for (result = dns_rdataset_first(&kfetch->dnskeysigset); @@ -9246,9 +9424,9 @@ revocable(dns_keyfetch_t *kfetch, dns_rdata_keydata_t *keydata) { &sigrr, dns_fixedname_name(&fixed)); - dns_zone_log(kfetch->zone, ISC_LOG_DEBUG(3), - "Confirm revoked DNSKEY is self-signed: " - "%s", dns_result_totext(result)); + dnssec_log(kfetch->zone, ISC_LOG_DEBUG(3), + "Confirm revoked DNSKEY is self-signed: %s", + dns_result_totext(result)); if (result == ISC_R_SUCCESS) { answer = true; @@ -9308,16 +9486,19 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { eresult = devent->result; /* Free resources which are not of interest */ - if (devent->node != NULL) + if (devent->node != NULL) { dns_db_detachnode(devent->db, &devent->node); - if (devent->db != NULL) + } + if (devent->db != NULL) { dns_db_detach(&devent->db); + } isc_event_free(&event); dns_resolver_destroyfetch(&kfetch->fetch); LOCK_ZONE(zone); - if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING) || zone->view == NULL) + if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING) || zone->view == NULL) { goto cleanup; + } isc_stdtime_get(&now); dns_name_format(keyname, namebuf, sizeof(namebuf)); @@ -9332,28 +9513,30 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { zone->refreshkeycount--; alldone = (zone->refreshkeycount == 0); - if (alldone) + if (alldone) { DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESHING); + } - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "Returned from key fetch in keyfetch_done() for " - "'%s': %s", namebuf, dns_result_totext(eresult)); + dnssec_log(zone, ISC_LOG_DEBUG(3), + "Returned from key fetch in keyfetch_done() for '%s': %s", + namebuf, dns_result_totext(eresult)); /* Fetch failed */ if (eresult != ISC_R_SUCCESS || - !dns_rdataset_isassociated(&kfetch->dnskeyset)) { - dns_zone_log(zone, ISC_LOG_WARNING, - "Unable to fetch DNSKEY set " - "'%s': %s", namebuf, dns_result_totext(eresult)); + !dns_rdataset_isassociated(&kfetch->dnskeyset)) + { + dnssec_log(zone, ISC_LOG_WARNING, + "Unable to fetch DNSKEY set '%s': %s", + namebuf, dns_result_totext(eresult)); CHECK(minimal_update(kfetch, ver, &diff)); goto done; } /* No RRSIGs found */ if (!dns_rdataset_isassociated(&kfetch->dnskeysigset)) { - dns_zone_log(zone, ISC_LOG_WARNING, - "No DNSKEY RRSIGs found for " - "'%s': %s", namebuf, dns_result_totext(eresult)); + dnssec_log(zone, ISC_LOG_WARNING, + "No DNSKEY RRSIGs found for '%s': %s", + namebuf, dns_result_totext(eresult)); CHECK(minimal_update(kfetch, ver, &diff)); goto done; } @@ -9385,8 +9568,10 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { dns_fixedname_init(&fixed); dstkey = dns_keynode_key(keynode); - if (dstkey == NULL) /* fail_secure() was called */ + if (dstkey == NULL) { + /* fail_secure() was called */ break; + } if (dst_key_alg(dstkey) == sig.algorithm && dst_key_id(dstkey) == sig.keyid) @@ -9400,11 +9585,11 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { dns_fixedname_name( &fixed)); - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "Verifying DNSKEY set for zone " - "'%s' using key %d/%d: %s", - namebuf, sig.keyid, sig.algorithm, - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_DEBUG(3), + "Verifying DNSKEY set for zone " + "'%s' using key %d/%d: %s", + namebuf, sig.keyid, sig.algorithm, + dns_result_totext(result)); if (result == ISC_R_SUCCESS) { kfetch->dnskeyset.trust = @@ -9438,9 +9623,9 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { * trusted keys then all we can do is look at any revoked keys. */ if (!secure) { - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "DNSKEY set for zone '%s' could not be verified " - "with current keys", namebuf); + dnssec_log(zone, ISC_LOG_INFO, + "DNSKEY set for zone '%s' could not be verified " + "with current keys", namebuf); } /* @@ -9470,6 +9655,17 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { dns_keydata_todnskey(&keydata, &dnskey, NULL); result = compute_tag(keyname, &dnskey, mctx, &keytag); + if (result != ISC_R_SUCCESS) { + /* + * Skip if we cannot compute the key tag. + * This may happen if the algorithm is unsupported + */ + dns_zone_log(zone, ISC_LOG_ERROR, + "Cannot compute tag for key in zone %s: %s " + "(skipping)", + namebuf, dns_result_totext(result)); + continue; + } RUNTIME_CHECK(result == ISC_R_SUCCESS); /* @@ -9485,38 +9681,38 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { if (!secure) { if (keydata.removehd != 0 && - keydata.removehd <= now) { + keydata.removehd <= now) + { deletekey = true; } } else if (keydata.addhd == 0) { deletekey = true; } else if (keydata.addhd > now) { - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "Pending key %d for zone %s " - "unexpectedly missing " - "restarting 30-day acceptance " - "timer", keytag, namebuf); - if (keydata.addhd < now + dns_zone_mkey_month) + dnssec_log(zone, ISC_LOG_INFO, + "Pending key %d for zone %s " + "unexpectedly missing " + "restarting 30-day acceptance " + "timer", keytag, namebuf); + if (keydata.addhd < now + dns_zone_mkey_month) { keydata.addhd = now + dns_zone_mkey_month; - keydata.refresh = refresh_time(kfetch, - false); + } + keydata.refresh = refresh_time(kfetch, false); } else if (keydata.removehd == 0) { - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "Active key %d for zone %s " - "unexpectedly missing", - keytag, namebuf); + dnssec_log(zone, ISC_LOG_INFO, + "Active key %d for zone %s " + "unexpectedly missing", + keytag, namebuf); keydata.refresh = now + dns_zone_mkey_hour; } else if (keydata.removehd <= now) { deletekey = true; - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "Revoked key %d for zone %s " - "missing: deleting from " - "managed keys database", - keytag, namebuf); + dnssec_log(zone, ISC_LOG_INFO, + "Revoked key %d for zone %s " + "missing: deleting from " + "managed keys database", + keytag, namebuf); } else { - keydata.refresh = refresh_time(kfetch, - false); + keydata.refresh = refresh_time(kfetch, false); } if (secure || deletekey) { @@ -9526,8 +9722,9 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { &keydatarr)); } - if (!secure || deletekey) + if (!secure || deletekey) { continue; + } dns_rdata_reset(&keydatarr); isc_buffer_init(&keyb, key_buf, sizeof(key_buf)); @@ -9582,6 +9779,17 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { } result = compute_tag(keyname, &dnskey, mctx, &keytag); + if (result != ISC_R_SUCCESS) { + /* + * Skip if we cannot compute the key tag. + * This may happen if the algorithm is unsupported + */ + dns_zone_log(zone, ISC_LOG_ERROR, + "Cannot compute tag for key in zone %s: %s " + "(skipping)", + namebuf, dns_result_totext(result)); + continue; + } RUNTIME_CHECK(result == ISC_R_SUCCESS); revoked = ((dnskey.flags & DNS_KEYFLAG_REVOKE) != 0); @@ -9599,13 +9807,12 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { * it's been revoked? Just remove it */ deletekey = true; - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "Pending key %d " - "for zone %s is now " - "revoked: " - "deleting from the " - "managed keys database", - keytag, namebuf); + dnssec_log(zone, ISC_LOG_INFO, + "Pending key %d for " + "zone %s is now revoked: " + "deleting from the " + "managed keys database", + keytag, namebuf); } else if (keydata.removehd == 0) { /* * Remove key from secroots. @@ -9614,39 +9821,37 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { &dnskey, mctx); /* If initializing, delete now */ - if (keydata.addhd == 0) + if (keydata.addhd == 0) { deletekey = true; - else { + } else { keydata.removehd = now + dns_zone_mkey_month; keydata.flags |= DNS_KEYFLAG_REVOKE; } - dns_zone_log(zone, ISC_LOG_INFO, - "Trusted key %d " - "for zone %s is now " - "revoked", - keytag, namebuf); + dnssec_log(zone, ISC_LOG_INFO, + "Trusted key %d for " + "zone %s is now revoked", + keytag, namebuf); } else if (keydata.removehd < now) { /* Scheduled for removal */ deletekey = true; - dns_zone_log(zone, ISC_LOG_INFO, - "Revoked key %d " - "for zone %s removal " - "timer complete: " - "deleting from the " - "managed keys database", - keytag, namebuf); + dnssec_log(zone, ISC_LOG_INFO, + "Revoked key %d for " + "zone %s removal timer " + "complete: deleting from " + "the managed keys database", + keytag, namebuf); } } else if (revoked && keydata.removehd == 0) { - dns_zone_log(zone, ISC_LOG_WARNING, - "Active key %d for zone " - "%s is revoked but " - "did not self-sign; " - "ignoring", keytag, namebuf); - continue; + dnssec_log(zone, ISC_LOG_WARNING, + "Active key %d for zone " + "%s is revoked but " + "did not self-sign; " + "ignoring", keytag, namebuf); + continue; } else if (secure) { if (keydata.removehd != 0) { /* @@ -9662,28 +9867,29 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { keydata.addhd = now + dns_zone_mkey_month; - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "Revoked key %d " - "for zone %s " - "has returned: starting " - "30-day acceptance timer", - keytag, namebuf); - } else if (keydata.addhd > now) + dnssec_log(zone, ISC_LOG_INFO, + "Revoked key %d for " + "zone %s has returned: " + "starting 30-day " + "acceptance timer", + keytag, namebuf); + } else if (keydata.addhd > now) { pending++; - else if (keydata.addhd == 0) + } else if (keydata.addhd == 0) { keydata.addhd = now; + } if (keydata.addhd <= now) { trustkey = true; - dns_zone_log(zone, ISC_LOG_INFO, - "Key %d for zone %s " - "is now trusted (%s)", - keytag, namebuf, - initial - ? "initializing key " - "verified" - : "acceptance timer " - "complete"); + dnssec_log(zone, ISC_LOG_INFO, + "Key %d for zone %s " + "is now trusted (%s)", + keytag, namebuf, + initial + ? "initializing key " + "verified" + : "acceptance timer " + "complete"); } } else if (keydata.addhd > now) { /* @@ -9692,43 +9898,45 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { */ pending++; keydata.addhd = now + dns_zone_mkey_month; - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "Pending key %d " - "for zone %s was " - "not validated: restarting " - "30-day acceptance timer", - keytag, namebuf); + dnssec_log(zone, ISC_LOG_INFO, + "Pending key %d " + "for zone %s was " + "not validated: restarting " + "30-day acceptance timer", + keytag, namebuf); } - if (!deletekey && !newkey) + if (!deletekey && !newkey) { updatekey = true; + } } else if (secure) { /* * Key wasn't in the key zone but it's * revoked now anyway, so just skip it */ - if (revoked) + if (revoked) { continue; + } /* Key wasn't in the key zone: add it */ newkey = true; if (initializing) { - dns_zone_log(zone, ISC_LOG_WARNING, - "Initializing automatic trust " - "anchor management for zone '%s'; " - "DNSKEY ID %d is now trusted, " - "waiving the normal 30-day " - "waiting period.", - namebuf, keytag); + dnssec_log(zone, ISC_LOG_WARNING, + "Initializing automatic trust " + "anchor management for zone '%s'; " + "DNSKEY ID %d is now trusted, " + "waiving the normal 30-day " + "waiting period.", + namebuf, keytag); trustkey = true; } else { - dns_zone_log(zone, ISC_LOG_INFO, - "New key %d observed " - "for zone '%s': " - "starting 30-day " - "acceptance timer", - keytag, namebuf); + dnssec_log(zone, ISC_LOG_INFO, + "New key %d observed " + "for zone '%s': " + "starting 30-day " + "acceptance timer", + keytag, namebuf); } } else { /* @@ -9739,10 +9947,11 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { } /* Delete old version */ - if (deletekey || !newkey) + if (deletekey || !newkey) { CHECK(update_one_rr(kfetch->db, ver, &diff, DNS_DIFFOP_DEL, keyname, 0, &keydatarr)); + } if (updatekey) { /* Set refresh timer */ @@ -9800,8 +10009,9 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { * see if there's pending keydata. If so, we put a null key in * the security roots; then all queries to the zone will fail. */ - if (pending != 0) + if (pending != 0) { fail_secure(zone, keyname); + } done: if (!ISC_LIST_EMPTY(diff.tuples)) { @@ -9828,14 +10038,15 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { failure: if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "error during managed-keys processing (%s): " - "DNSSEC validation may be at risk", - isc_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "error during managed-keys processing (%s): " + "DNSSEC validation may be at risk", + isc_result_totext(result)); } dns_diff_clear(&diff); - if (ver != NULL) + if (ver != NULL) { dns_db_closeversion(kfetch->db, &ver, commit); + } cleanup: dns_db_detach(&kfetch->db); @@ -9844,24 +10055,29 @@ keyfetch_done(isc_task_t *task, isc_event_t *event) { zone->irefs--; kfetch->zone = NULL; - if (dns_rdataset_isassociated(&kfetch->keydataset)) + if (dns_rdataset_isassociated(&kfetch->keydataset)) { dns_rdataset_disassociate(&kfetch->keydataset); - if (dns_rdataset_isassociated(&kfetch->dnskeyset)) + } + if (dns_rdataset_isassociated(&kfetch->dnskeyset)) { dns_rdataset_disassociate(&kfetch->dnskeyset); - if (dns_rdataset_isassociated(&kfetch->dnskeysigset)) + } + if (dns_rdataset_isassociated(&kfetch->dnskeysigset)) { dns_rdataset_disassociate(&kfetch->dnskeysigset); + } dns_name_free(keyname, mctx); isc_mem_put(mctx, kfetch, sizeof(dns_keyfetch_t)); isc_mem_detach(&mctx); - if (secroots != NULL) + if (secroots != NULL) { dns_keytable_detach(&secroots); + } free_needed = exit_check(zone); UNLOCK_ZONE(zone); - if (free_needed) + if (free_needed) { zone_free(zone); + } INSIST(ver == NULL); } @@ -9883,6 +10099,7 @@ zone_refreshkeys(dns_zone_t *zone) { isc_stdtime_t now; bool commit = false; bool fetching = false, fetch_err = false; + bool timerset = false; ENTER; REQUIRE(zone->db != NULL); @@ -9909,7 +10126,8 @@ zone_refreshkeys(dns_zone_t *zone) { dns_rriterator_init(&rrit, db, ver, 0); for (result = dns_rriterator_first(&rrit); result == ISC_R_SUCCESS; - result = dns_rriterator_nextrrset(&rrit)) { + result = dns_rriterator_nextrrset(&rrit)) + { isc_stdtime_t timer = 0xffffffff; dns_name_t *name = NULL, *kname = NULL; dns_rdataset_t *kdset = NULL; @@ -9919,7 +10137,9 @@ zone_refreshkeys(dns_zone_t *zone) { dns_rriterator_current(&rrit, &name, &ttl, &kdset, NULL); if (kdset == NULL || kdset->type != dns_rdatatype_keydata || !dns_rdataset_isassociated(kdset)) + { continue; + } /* * Scan the stored keys looking for ones that need @@ -9927,7 +10147,8 @@ zone_refreshkeys(dns_zone_t *zone) { */ for (result = dns_rdataset_first(kdset); result == ISC_R_SUCCESS; - result = dns_rdataset_next(kdset)) { + result = dns_rdataset_next(kdset)) + { dns_rdata_reset(&rdata); dns_rdataset_current(kdset, &rdata); result = dns_rdata_tostruct(&rdata, &kd, NULL); @@ -9942,16 +10163,22 @@ zone_refreshkeys(dns_zone_t *zone) { } /* Acceptance timer expired? */ - if (kd.addhd <= now) + if (kd.addhd <= now) { timer = kd.addhd; + } /* Or do we just need to refresh the keyset? */ - if (timer > kd.refresh) + if (timer > kd.refresh) { timer = kd.refresh; + } + + set_refreshkeytimer(zone, &kd, now, false); + timerset = true; } - if (timer > now) + if (timer > now) { continue; + } kfetch = isc_mem_get(zone->mctx, sizeof(dns_keyfetch_t)); if (kfetch == NULL) { @@ -9977,10 +10204,10 @@ zone_refreshkeys(dns_zone_t *zone) { char namebuf[DNS_NAME_FORMATSIZE]; dns_name_format(kname, namebuf, sizeof(namebuf)); - dns_zone_log(zone, ISC_LOG_DEBUG(3), - "Creating key fetch in " - "zone_refreshkeys() for '%s'", - namebuf); + dnssec_log(zone, ISC_LOG_DEBUG(3), + "Creating key fetch in " + "zone_refreshkeys() for '%s'", + namebuf); } /* @@ -10012,18 +10239,17 @@ zone_refreshkeys(dns_zone_t *zone) { result = ISC_R_FAILURE; } #endif - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS) { fetching = true; - else { + } else { zone->refreshkeycount--; zone->irefs--; dns_db_detach(&kfetch->db); dns_rdataset_disassociate(&kfetch->keydataset); dns_name_free(kname, zone->mctx); isc_mem_put(zone->mctx, kfetch, sizeof(dns_keyfetch_t)); - dns_zone_log(zone, ISC_LOG_WARNING, - "Failed to create fetch for " - "DNSKEY update"); + dnssec_log(zone, ISC_LOG_WARNING, + "Failed to create fetch for DNSKEY update"); fetch_err = true; } } @@ -10050,12 +10276,15 @@ zone_refreshkeys(dns_zone_t *zone) { zone_settimer(zone, &timenow); isc_time_formattimestamp(&zone->refreshkeytime, timebuf, 80); - dns_zone_log(zone, ISC_LOG_DEBUG(1), "retry key refresh: %s", - timebuf); + dnssec_log(zone, ISC_LOG_DEBUG(1), "retry key refresh: %s", + timebuf); + } else if (!timerset) { + isc_time_settoepoch(&zone->refreshkeytime); } - if (!fetching) + if (!fetching) { DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_REFRESHING); + } dns_diff_clear(&diff); if (ver != NULL) { @@ -10818,6 +11047,12 @@ zone_unload(dns_zone_t *zone) { ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_write); DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_LOADED); DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDDUMP); + + if (zone->type == dns_zone_mirror) { + dns_zone_log(zone, ISC_LOG_INFO, + "mirror zone is no longer in use; " + "reverting to normal recursion"); + } } void @@ -13975,6 +14210,15 @@ zone_debuglog(dns_zone_t *zone, const char *me, int debuglevel, va_end(ap); } +static void +dnssec_log(dns_zone_t *zone, int level, const char *fmt, ...) { + va_list ap; + + va_start(ap, fmt); + dns_zone_logv(zone, DNS_LOGCATEGORY_DNSSEC, level, NULL, fmt, ap); + va_end(ap); +} + static int message_count(dns_message_t *msg, dns_section_t section, dns_rdatatype_t type) { @@ -14499,7 +14743,6 @@ receive_secure_serial(isc_task_t *task, isc_event_t *event) { if (rjournal != NULL) dns_journal_destroy(&rjournal); isc_task_send(task, &event); - fprintf(stderr, "looping on dns_update_signaturesinc\n"); return; } /* @@ -17484,9 +17727,9 @@ dns_zone_signwithkey(dns_zone_t *zone, dns_secalg_t algorithm, isc_result_t result; REQUIRE(DNS_ZONE_VALID(zone)); - dns_zone_log(zone, ISC_LOG_NOTICE, - "dns_zone_signwithkey(algorithm=%u, keyid=%u)", - algorithm, keyid); + dnssec_log(zone, ISC_LOG_NOTICE, + "dns_zone_signwithkey(algorithm=%u, keyid=%u)", + algorithm, keyid); LOCK_ZONE(zone); result = zone_signwithkey(zone, algorithm, keyid, deleteit); UNLOCK_ZONE(zone); @@ -17509,10 +17752,9 @@ dns_zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) { result = dns_nsec3param_salttotext(nsec3param, salt, sizeof(salt)); RUNTIME_CHECK(result == ISC_R_SUCCESS); - dns_zone_log(zone, ISC_LOG_NOTICE, - "dns_zone_addnsec3chain(hash=%u, iterations=%u, salt=%s)", - nsec3param->hash, nsec3param->iterations, - salt); + dnssec_log(zone, ISC_LOG_NOTICE, + "dns_zone_addnsec3chain(hash=%u, iterations=%u, salt=%s)", + nsec3param->hash, nsec3param->iterations, salt); LOCK_ZONE(zone); result = zone_addnsec3chain(zone, nsec3param); UNLOCK_ZONE(zone); @@ -17641,15 +17883,6 @@ zone_signwithkey(dns_zone_t *zone, dns_secalg_t algorithm, uint16_t keyid, } static void -logmsg(const char *format, ...) { - va_list args; - va_start(args, format); - isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_ZONE, - ISC_LOG_DEBUG(1), format, args); - va_end(args); -} - -static void clear_keylist(dns_dnsseckeylist_t *list, isc_mem_t *mctx) { dns_dnsseckey_t *key; while (!ISC_LIST_EMPTY(*list)) { @@ -17759,7 +17992,7 @@ add_signing_records(dns_db_t *db, dns_rdatatype_t privatetype, dns_rdata_toregion(&tuple->rdata, &r); - keyid = dst_region_computeid(&r, dnskey.algorithm); + keyid = dst_region_computeid(&r); buf[0] = dnskey.algorithm; buf[1] = (keyid & 0xff00) >> 8; @@ -17812,9 +18045,9 @@ sign_apex(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, result = dns__zone_findkeys(zone, db, ver, now, zone->mctx, DNS_MAXZONEKEYS, zone_keys, &nkeys); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "sign_apex:dns__zone_findkeys -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "sign_apex:dns__zone_findkeys -> %s", + dns_result_totext(result)); return (result); } @@ -17837,10 +18070,13 @@ sign_apex(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, */ for (tuple = ISC_LIST_HEAD(diff->tuples); tuple != NULL; - tuple = ISC_LIST_NEXT(tuple, link)) { + tuple = ISC_LIST_NEXT(tuple, link)) + { if (tuple->rdata.type == dns_rdatatype_dnskey && dns_name_equal(&tuple->name, &zone->origin)) + { break; + } } if (tuple == NULL) { @@ -17848,9 +18084,9 @@ sign_apex(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, dns_rdatatype_dnskey, zonediff, zone_keys, nkeys, now, false); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "sign_apex:del_sigs -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "sign_apex:del_sigs -> %s", + dns_result_totext(result)); goto failure; } result = add_sigs(db, ver, &zone->origin, dns_rdatatype_dnskey, @@ -17858,9 +18094,9 @@ sign_apex(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, inception, keyexpire, check_ksk, keyset_kskonly); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "sign_apex:add_sigs -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "sign_apex:add_sigs -> %s", + dns_result_totext(result)); goto failure; } } @@ -17870,15 +18106,16 @@ sign_apex(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, check_ksk, keyset_kskonly, zonediff); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "sign_apex:dns__zone_updatesigs -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "sign_apex:dns__zone_updatesigs -> %s", + dns_result_totext(result)); goto failure; } failure: - for (i = 0; i < nkeys; i++) + for (i = 0; i < nkeys; i++) { dst_key_free(&zone_keys[i]); + } return (result); } @@ -17899,14 +18136,17 @@ dnskey_sane(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, /* Scan the tuples for an NSEC-only DNSKEY */ for (tuple = ISC_LIST_HEAD(diff->tuples); tuple != NULL; - tuple = ISC_LIST_NEXT(tuple, link)) { + tuple = ISC_LIST_NEXT(tuple, link)) + { uint8_t alg; if (tuple->rdata.type != dns_rdatatype_dnskey || tuple->op != DNS_DIFFOP_ADD) + { continue; + } alg = tuple->rdata.data[3]; - if (alg == DST_ALG_RSAMD5 || alg == DST_ALG_RSASHA1) { + if (alg == DST_ALG_RSASHA1) { nseconly = true; break; } @@ -17915,19 +18155,21 @@ dnskey_sane(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, /* Check existing DB for NSEC-only DNSKEY */ if (!nseconly) { result = dns_nsec_nseconly(db, ver, &nseconly); - if (result == ISC_R_NOTFOUND) + if (result == ISC_R_NOTFOUND) { result = ISC_R_SUCCESS; + } CHECK(result); } /* Check existing DB for NSEC3 */ - if (!nsec3) + if (!nsec3) { CHECK(dns_nsec3_activex(db, ver, false, privatetype, &nsec3)); + } /* Refuse to allow NSEC3 with NSEC-only keys */ if (nseconly && nsec3) { - dns_zone_log(zone, ISC_LOG_ERROR, + dnssec_log(zone, ISC_LOG_ERROR, "NSEC only DNSKEYs and NSEC3 chains not allowed"); goto failure; } @@ -18015,6 +18257,15 @@ add_chains(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, } static void +dnssec_report(const char *format, ...) { + va_list args; + va_start(args, format); + isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DNSSEC, DNS_LOGMODULE_ZONE, + ISC_LOG_INFO, format, args); + va_end(args); +} + +static void zone_rekey(dns_zone_t *zone) { isc_result_t result; dns_db_t *db = NULL; @@ -18022,15 +18273,15 @@ zone_rekey(dns_zone_t *zone) { dns_dbversion_t *ver = NULL; dns_rdataset_t cdsset, soaset, soasigs, keyset, keysigs, cdnskeyset; dns_dnsseckeylist_t dnskeys, keys, rmkeys; - dns_dnsseckey_t *key; + dns_dnsseckey_t *key = NULL; dns_diff_t diff, _sig_diff; dns__zonediff_t zonediff; bool commit = false, newactive = false; bool newalg = false; bool fullsign; dns_ttl_t ttl = 3600; - const char *dir; - isc_mem_t *mctx; + const char *dir = NULL; + isc_mem_t *mctx = NULL; isc_stdtime_t now; isc_time_t timenow; isc_interval_t ival; @@ -18060,7 +18311,7 @@ zone_rekey(dns_zone_t *zone) { TIME_NOW(&timenow); now = isc_time_seconds(&timenow); - dns_zone_log(zone, ISC_LOG_INFO, "reconfiguring zone keys"); + dnssec_log(zone, ISC_LOG_INFO, "reconfiguring zone keys"); /* Get the SOA record's TTL */ CHECK(dns_db_findrdataset(db, node, ver, dns_rdatatype_soa, @@ -18078,8 +18329,9 @@ zone_rekey(dns_zone_t *zone) { &keysigs, &soasigs, false, false, &dnskeys)); - } else if (result != ISC_R_NOTFOUND) + } else if (result != ISC_R_NOTFOUND) { goto failure; + } /* Get the CDS rdataset */ @@ -18092,7 +18344,9 @@ zone_rekey(dns_zone_t *zone) { result = dns_db_findrdataset(db, node, ver, dns_rdatatype_cdnskey, dns_rdatatype_none, 0, &cdnskeyset, NULL); if (result != ISC_R_SUCCESS && dns_rdataset_isassociated(&cdnskeyset)) + { dns_rdataset_disassociate(&cdnskeyset); + } /* * True when called from "rndc sign". Indicates the zone should be @@ -18108,16 +18362,16 @@ zone_rekey(dns_zone_t *zone) { result = dns_dnssec_updatekeys(&dnskeys, &keys, &rmkeys, &zone->origin, ttl, &diff, - !check_ksk, - mctx, logmsg); + !check_ksk, mctx, + dnssec_report); /* * Keys couldn't be updated for some reason; * try again later. */ if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_rekey:" - "couldn't update zone keys: %s", - isc_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_rekey:couldn't update zone keys: %s", + isc_result_totext(result)); goto failure; } @@ -18128,9 +18382,9 @@ zone_rekey(dns_zone_t *zone) { &cdnskeyset, now, ttl, &diff, mctx); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, "zone_rekey:" - "couldn't update CDS/CDNSKEY: %s", - isc_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_rekey:couldn't update CDS/CDNSKEY: %s", + isc_result_totext(result)); goto failure; } @@ -18143,9 +18397,11 @@ zone_rekey(dns_zone_t *zone) { */ for (key = ISC_LIST_HEAD(dnskeys); key != NULL; - key = ISC_LIST_NEXT(key, link)) { - if (!key->first_sign) + key = ISC_LIST_NEXT(key, link)) + { + if (!key->first_sign) { continue; + } newactive = true; @@ -18168,7 +18424,8 @@ zone_rekey(dns_zone_t *zone) { } if ((newactive || fullsign || !ISC_LIST_EMPTY(diff.tuples)) && - dnskey_sane(zone, db, ver, &diff)) { + dnskey_sane(zone, db, ver, &diff)) + { CHECK(dns_diff_apply(&diff, db, ver)); CHECK(clean_nsec3param(zone, db, ver, &diff)); CHECK(add_signing_records(db, zone->privatetype, @@ -18200,15 +18457,16 @@ zone_rekey(dns_zone_t *zone) { if (!ISC_LIST_EMPTY(rmkeys)) { for (key = ISC_LIST_HEAD(rmkeys); key != NULL; - key = ISC_LIST_NEXT(key, link)) { + key = ISC_LIST_NEXT(key, link)) + { result = zone_signwithkey(zone, dst_key_alg(key->key), dst_key_id(key->key), true); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_signwithkey failed: %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_signwithkey failed: %s", + dns_result_totext(result)); } } } @@ -18220,18 +18478,20 @@ zone_rekey(dns_zone_t *zone) { */ for (key = ISC_LIST_HEAD(dnskeys); key != NULL; - key = ISC_LIST_NEXT(key, link)) { - if (!key->force_sign && !key->hint_sign) + key = ISC_LIST_NEXT(key, link)) + { + if (!key->force_sign && !key->hint_sign) { continue; + } result = zone_signwithkey(zone, dst_key_alg(key->key), dst_key_id(key->key), false); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_signwithkey failed: %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_signwithkey failed: %s", + dns_result_totext(result)); } } } else if (newalg) { @@ -18243,18 +18503,20 @@ zone_rekey(dns_zone_t *zone) { */ for (key = ISC_LIST_HEAD(dnskeys); key != NULL; - key = ISC_LIST_NEXT(key, link)) { - if (!key->first_sign) + key = ISC_LIST_NEXT(key, link)) + { + if (!key->first_sign) { continue; + } result = zone_signwithkey(zone, dst_key_alg(key->key), dst_key_id(key->key), false); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_signwithkey failed: %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_signwithkey failed: %s", + dns_result_totext(result)); } } } @@ -18271,28 +18533,35 @@ zone_rekey(dns_zone_t *zone) { */ for (tuple = ISC_LIST_HEAD(zonediff.diff->tuples); tuple != NULL; - tuple = ISC_LIST_NEXT(tuple, link)) { + tuple = ISC_LIST_NEXT(tuple, link)) + { unsigned char buf[DNS_NSEC3PARAM_BUFFERSIZE]; dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdata_nsec3param_t nsec3param; if (tuple->rdata.type != zone->privatetype || tuple->op != DNS_DIFFOP_ADD) + { continue; + } if (!dns_nsec3param_fromprivate(&tuple->rdata, &rdata, buf, sizeof(buf))) + { continue; + } + result = dns_rdata_tostruct(&rdata, &nsec3param, NULL); RUNTIME_CHECK(result == ISC_R_SUCCESS); - if (nsec3param.flags == 0) + if (nsec3param.flags == 0) { continue; + } result = zone_addnsec3chain(zone, &nsec3param); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "zone_addnsec3chain failed: %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "zone_addnsec3chain failed: %s", + dns_result_totext(result)); } } @@ -18300,8 +18569,9 @@ zone_rekey(dns_zone_t *zone) { * Activate any NSEC3 chain updates that may have * been scheduled before this rekey. */ - if (fullsign || newalg) + if (fullsign || newalg) { resume_addnsec3chain(zone); + } /* * Schedule the next resigning event @@ -18329,16 +18599,19 @@ zone_rekey(dns_zone_t *zone) { for (key = ISC_LIST_HEAD(dnskeys); key != NULL; - key = ISC_LIST_NEXT(key, link)) { + key = ISC_LIST_NEXT(key, link)) + { then = now; result = next_keyevent(key->key, &then); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { continue; + } DNS_ZONE_TIME_ADD(&timenow, then - now, &timethen); LOCK_ZONE(zone); if (isc_time_compare(&timethen, - &zone->refreshkeytime) < 0) { + &zone->refreshkeytime) < 0) + { zone->refreshkeytime = timethen; } UNLOCK_ZONE(zone); @@ -18347,10 +18620,22 @@ zone_rekey(dns_zone_t *zone) { zone_settimer(zone, &timenow); isc_time_formattimestamp(&zone->refreshkeytime, timebuf, 80); - dns_zone_log(zone, ISC_LOG_INFO, "next key event: %s", timebuf); + dnssec_log(zone, ISC_LOG_INFO, "next key event: %s", timebuf); + } + + result = ISC_R_SUCCESS; + + failure: + if (result != ISC_R_SUCCESS) { + /* + * Something went wrong; try again in ten minutes or + * after a key refresh interval, whichever is shorter. + */ + isc_interval_set(&ival, + ISC_MIN(zone->refreshkeyinterval, 600), 0); + isc_time_nowplusinterval(&zone->refreshkeytime, &ival); } - done: dns_diff_clear(&diff); dns_diff_clear(&_sig_diff); @@ -18358,34 +18643,32 @@ zone_rekey(dns_zone_t *zone) { clear_keylist(&keys, mctx); clear_keylist(&rmkeys, mctx); - if (ver != NULL) + if (ver != NULL) { dns_db_closeversion(db, &ver, false); - if (dns_rdataset_isassociated(&cdsset)) + } + if (dns_rdataset_isassociated(&cdsset)) { dns_rdataset_disassociate(&cdsset); - if (dns_rdataset_isassociated(&keyset)) + } + if (dns_rdataset_isassociated(&keyset)) { dns_rdataset_disassociate(&keyset); - if (dns_rdataset_isassociated(&keysigs)) + } + if (dns_rdataset_isassociated(&keysigs)) { dns_rdataset_disassociate(&keysigs); - if (dns_rdataset_isassociated(&soasigs)) + } + if (dns_rdataset_isassociated(&soasigs)) { dns_rdataset_disassociate(&soasigs); - if (dns_rdataset_isassociated(&cdnskeyset)) + } + if (dns_rdataset_isassociated(&cdnskeyset)) { dns_rdataset_disassociate(&cdnskeyset); - if (node != NULL) + } + if (node != NULL) { dns_db_detachnode(db, &node); - if (db != NULL) + } + if (db != NULL) { dns_db_detach(&db); + } INSIST(ver == NULL); - return; - - failure: - /* - * Something went wrong; try again in ten minutes or - * after a key refresh interval, whichever is shorter. - */ - isc_interval_set(&ival, ISC_MIN(zone->refreshkeyinterval, 600), 0); - isc_time_nowplusinterval(&zone->refreshkeytime, &ival); - goto done; } void @@ -18793,24 +19076,27 @@ keydone(isc_task_t *task, isc_event_t *event) { dns_diff_init(zone->mctx, &diff); ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read); - if (zone->db != NULL) + if (zone->db != NULL) { dns_db_attach(zone->db, &db); + } ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read); - if (db == NULL) + if (db == NULL) { goto failure; + } dns_db_currentversion(db, &oldver); result = dns_db_newversion(db, &newver); if (result != ISC_R_SUCCESS) { - dns_zone_log(zone, ISC_LOG_ERROR, - "keydone:dns_db_newversion -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "keydone:dns_db_newversion -> %s", + dns_result_totext(result)); goto failure; } result = dns_db_getoriginnode(db, &node); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { goto failure; + } result = dns_db_findrdataset(db, node, newver, zone->privatetype, dns_rdatatype_none, 0, &rdataset, NULL); @@ -18825,7 +19111,8 @@ keydone(isc_task_t *task, isc_event_t *event) { for (result = dns_rdataset_first(&rdataset); result == ISC_R_SUCCESS; - result = dns_rdataset_next(&rdataset)) { + result = dns_rdataset_next(&rdataset)) + { bool found = false; dns_rdataset_current(&rdataset, &rdata); @@ -18833,20 +19120,25 @@ keydone(isc_task_t *task, isc_event_t *event) { if (kd->all) { if (rdata.length == 5 && rdata.data[0] != 0 && rdata.data[3] == 0 && rdata.data[4] == 1) + { found = true; - else if (rdata.data[0] == 0 && - (rdata.data[2] & PENDINGFLAGS) != 0) { + } else if (rdata.data[0] == 0 && + (rdata.data[2] & PENDINGFLAGS) != 0) + { found = true; clear_pending = true; } } else if (rdata.length == 5 && memcmp(rdata.data, kd->data, 5) == 0) + { found = true; + } - if (found) + if (found) { CHECK(update_one_rr(db, newver, &diff, DNS_DIFFOP_DEL, &zone->origin, rdataset.ttl, &rdata)); + } dns_rdata_reset(&rdata); } @@ -18858,8 +19150,9 @@ keydone(isc_task_t *task, isc_event_t *event) { result = dns_update_signatures(&log, zone, db, oldver, newver, &diff, zone->sigvalidityinterval); - if (!clear_pending) + if (!clear_pending) { CHECK(result); + } CHECK(zone_journal(zone, &diff, NULL, "keydone")); commit = true; @@ -18871,15 +19164,19 @@ keydone(isc_task_t *task, isc_event_t *event) { } failure: - if (dns_rdataset_isassociated(&rdataset)) + if (dns_rdataset_isassociated(&rdataset)) { dns_rdataset_disassociate(&rdataset); + } if (db != NULL) { - if (node != NULL) + if (node != NULL) { dns_db_detachnode(db, &node); - if (oldver != NULL) + } + if (oldver != NULL) { dns_db_closeversion(db, &oldver, false); - if (newver != NULL) + } + if (newver != NULL) { dns_db_closeversion(db, &newver, commit); + } dns_db_detach(&db); } dns_diff_clear(&diff); @@ -18910,9 +19207,9 @@ dns_zone_keydone(dns_zone_t *zone, const char *keystr) { } kd = (struct keydone *) e; - if (strcasecmp(keystr, "all") == 0) + if (strcasecmp(keystr, "all") == 0) { kd->all = true; - else { + } else { isc_textregion_t r; const char *algstr; dns_keytag_t keyid; @@ -18922,14 +19219,16 @@ dns_zone_keydone(dns_zone_t *zone, const char *keystr) { kd->all = false; n = sscanf(keystr, "%hu/", &keyid); - if (n == 0U) + if (n == 0U) { CHECK(ISC_R_FAILURE); + } algstr = strchr(keystr, '/'); - if (algstr != NULL) + if (algstr != NULL) { algstr++; - else + } else { CHECK(ISC_R_FAILURE); + } n = sscanf(algstr, "%hhu", &alg); if (n == 0U) { @@ -18951,8 +19250,9 @@ dns_zone_keydone(dns_zone_t *zone, const char *keystr) { isc_task_send(zone->task, &e); failure: - if (e != NULL) + if (e != NULL) { isc_event_free(&e); + } UNLOCK_ZONE(zone); return (result); } @@ -18998,19 +19298,21 @@ setnsec3param(isc_task_t *task, isc_event_t *event) { dns_diff_init(zone->mctx, &diff); ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read); - if (zone->db != NULL) + if (zone->db != NULL) { dns_db_attach(zone->db, &db); + } ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read); - if (db == NULL) + if (db == NULL) { goto failure; + } dns_db_currentversion(db, &oldver); result = dns_db_newversion(db, &newver); if (result != ISC_R_SUCCESS) { ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read); - dns_zone_log(zone, ISC_LOG_ERROR, - "setnsec3param:dns_db_newversion -> %s", - dns_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, + "setnsec3param:dns_db_newversion -> %s", + dns_result_totext(result)); goto failure; } @@ -19024,12 +19326,14 @@ setnsec3param(isc_task_t *task, isc_event_t *event) { if (result == ISC_R_SUCCESS) { for (result = dns_rdataset_first(&prdataset); result == ISC_R_SUCCESS; - result = dns_rdataset_next(&prdataset)) { + result = dns_rdataset_next(&prdataset)) + { dns_rdata_init(&rdata); dns_rdataset_current(&prdataset, &rdata); if (np->length == rdata.length && - memcmp(rdata.data, np->data, np->length) == 0) { + memcmp(rdata.data, np->data, np->length) == 0) + { exists = true; break; } @@ -19048,7 +19352,8 @@ setnsec3param(isc_task_t *task, isc_event_t *event) { if (result == ISC_R_SUCCESS) { for (result = dns_rdataset_first(&nrdataset); result == ISC_R_SUCCESS; - result = dns_rdataset_next(&nrdataset)) { + result = dns_rdataset_next(&nrdataset)) + { dns_rdata_init(&rdata); dns_rdataset_current(&nrdataset, &rdata); @@ -19071,9 +19376,10 @@ setnsec3param(isc_task_t *task, isc_event_t *event) { * parameters are supposed to replace the current ones or if we are * switching to NSEC. */ - if (!exists && np->replace && (np->length != 0 || np->nsec)) + if (!exists && np->replace && (np->length != 0 || np->nsec)) { CHECK(dns_nsec3param_deletechains(db, newver, zone, !np->nsec, &diff)); + } if (!exists && np->length != 0) { /* @@ -19090,8 +19396,9 @@ setnsec3param(isc_task_t *task, isc_event_t *event) { np->data[2] |= DNS_NSEC3FLAG_CREATE; result = dns_nsec_nseconly(db, newver, &nseconly); - if (result == ISC_R_NOTFOUND || nseconly) + if (result == ISC_R_NOTFOUND || nseconly) { np->data[2] |= DNS_NSEC3FLAG_INITIAL; + } rdata.length = np->length; rdata.data = np->data; @@ -19113,8 +19420,9 @@ setnsec3param(isc_task_t *task, isc_event_t *event) { result = dns_update_signatures(&log, zone, db, oldver, newver, &diff, zone->sigvalidityinterval); - if (result != ISC_R_NOTFOUND) + if (result != ISC_R_NOTFOUND) { CHECK(result); + } CHECK(zone_journal(zone, &diff, NULL, "setnsec3param")); commit = true; @@ -19125,18 +19433,24 @@ setnsec3param(isc_task_t *task, isc_event_t *event) { } failure: - if (dns_rdataset_isassociated(&prdataset)) + if (dns_rdataset_isassociated(&prdataset)) { dns_rdataset_disassociate(&prdataset); - if (dns_rdataset_isassociated(&nrdataset)) + } + if (dns_rdataset_isassociated(&nrdataset)) { dns_rdataset_disassociate(&nrdataset); - if (node != NULL) + } + if (node != NULL) { dns_db_detachnode(db, &node); - if (oldver != NULL) + } + if (oldver != NULL) { dns_db_closeversion(db, &oldver, false); - if (newver != NULL) + } + if (newver != NULL) { dns_db_closeversion(db, &newver, commit); - if (db != NULL) + } + if (db != NULL) { dns_db_detach(&db); + } if (commit) { LOCK_ZONE(zone); resume_addnsec3chain(zone); @@ -19242,8 +19556,9 @@ dns_zone_setnsec3param(dns_zone_t *zone, uint8_t hash, uint8_t flags, ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read); failure: - if (e != NULL) + if (e != NULL) { isc_event_free(&e); + } UNLOCK_ZONE(zone); return (result); } @@ -19522,7 +19837,7 @@ dns_zone_verifydb(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver) { origin = dns_db_origin(db); result = dns_zoneverify_dnssec(zone, db, version, origin, secroots, - zone->mctx, false, false); + zone->mctx, true, false); done: if (secroots != NULL) { @@ -19534,9 +19849,8 @@ dns_zone_verifydb(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver) { } if (result != ISC_R_SUCCESS) { - dns_zone_logc(zone, DNS_LOGCATEGORY_ZONELOAD, ISC_LOG_ERROR, - "zone verification failed: %s", - isc_result_totext(result)); + dnssec_log(zone, ISC_LOG_ERROR, "zone verification failed: %s", + isc_result_totext(result)); result = DNS_R_VERIFYFAILURE; } diff --git a/external/mpl/bind/dist/lib/dns/zt.c b/external/mpl/bind/dist/lib/dns/zt.c index 94eb3e10951..9f49c7abc61 100644 --- a/external/mpl/bind/dist/lib/dns/zt.c +++ b/external/mpl/bind/dist/lib/dns/zt.c @@ -1,4 +1,4 @@ -/* $NetBSD: zt.c,v 1.3 2019/01/09 16:55:12 christos Exp $ */ +/* $NetBSD: zt.c,v 1.4 2019/02/24 20:01:30 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -181,6 +181,16 @@ dns_zt_find(dns_zt_t *zt, const dns_name_t *name, unsigned int options, * a mirror zone which is expired or not yet loaded, treat it * as non-existent. This will trigger a fallback to recursion * instead of returning a SERVFAIL. + * + * Note that currently only the deepest match in the zone table + * is checked. Consider a server configured with two mirror + * zones: "bar" and its child, "foo.bar". If zone data is + * available for "bar" but not for "foo.bar", a query with + * QNAME equal to or below "foo.bar" will cause ISC_R_NOTFOUND + * to be returned, not DNS_R_PARTIALMATCH, despite zone data + * being available for "bar". This is considered to be an edge + * case, handling which more appropriately is possible, but + * arguably not worth the added complexity. */ if ((options & DNS_ZTFIND_MIRROR) != 0 && dns_zone_gettype(dummy) == dns_zone_mirror && diff --git a/external/mpl/bind/dist/lib/irs/getaddrinfo.c b/external/mpl/bind/dist/lib/irs/getaddrinfo.c index b20959910aa..3713b874b02 100644 --- a/external/mpl/bind/dist/lib/irs/getaddrinfo.c +++ b/external/mpl/bind/dist/lib/irs/getaddrinfo.c @@ -1,4 +1,4 @@ -/* $NetBSD: getaddrinfo.c,v 1.3 2019/01/09 16:55:13 christos Exp $ */ +/* $NetBSD: getaddrinfo.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -128,6 +128,12 @@ #include <string.h> #include <errno.h> +#ifdef _WIN32 +#include <windows.h> +#include <winsock2.h> +#include <ws2tcpip.h> +#endif + #include <isc/app.h> #include <isc/buffer.h> #include <isc/lib.h> @@ -341,25 +347,45 @@ getaddrinfo(const char *hostname, const char *servname, port = strtol(servname, &e, 10); if (*e == '\0') { - if (socktype == 0) + if (socktype == 0) { return (EAI_SOCKTYPE); - if (port < 0 || port > 65535) + } + if (port < 0 || port > 65535) { return (EAI_SERVICE); + } port = htons((unsigned short) port); } else { +#ifdef _WIN32 + WORD wVersionRequested; + WSADATA wsaData; + + wVersionRequested = MAKEWORD(2, 0); + + err = WSAStartup(wVersionRequested, &wsaData ); + if (err != 0) { + return (EAI_FAIL); + } +#endif sp = getservbyname(servname, proto); - if (sp == NULL) + if (sp != NULL) + port = sp->s_port; +#ifdef _WIN32 + WSACleanup(); +#endif + if (sp == NULL) { return (EAI_SERVICE); - port = sp->s_port; + } if (socktype == 0) { - if (strcmp(sp->s_proto, "tcp") == 0) + if (strcmp(sp->s_proto, "tcp") == 0) { socktype = SOCK_STREAM; - else if (strcmp(sp->s_proto, "udp") == 0) + } else if (strcmp(sp->s_proto, "udp") == 0) { socktype = SOCK_DGRAM; + } } } - } else + } else { port = 0; + } /* * Next, deal with just a service name, and no hostname. diff --git a/external/mpl/bind/dist/lib/isc/assertions.c b/external/mpl/bind/dist/lib/isc/assertions.c index 57aff606826..343266dd65d 100644 --- a/external/mpl/bind/dist/lib/isc/assertions.c +++ b/external/mpl/bind/dist/lib/isc/assertions.c @@ -1,4 +1,4 @@ -/* $NetBSD: assertions.c,v 1.2 2018/08/12 13:02:37 christos Exp $ */ +/* $NetBSD: assertions.c,v 1.3 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -21,7 +21,6 @@ #include <isc/assertions.h> #include <isc/backtrace.h> -#include <isc/msgs.h> #include <isc/print.h> #include <isc/result.h> @@ -109,13 +108,13 @@ default_callback(const char *file, int line, isc_assertiontype_t type, isc_result_t result; result = isc_backtrace_gettrace(tracebuf, BACKTRACE_MAXFRAME, &nframes); - if (result == ISC_R_SUCCESS && nframes > 0) - logsuffix = ", back trace"; + if (result == ISC_R_SUCCESS && nframes > 0) { + logsuffix = ", back trace"; + } + + fprintf(stderr, "%s:%d: %s(%s) failed%s\n", + file, line, isc_assertion_typetotext(type), cond, logsuffix); - fprintf(stderr, "%s:%d: %s(%s) %s%s\n", - file, line, isc_assertion_typetotext(type), cond, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), logsuffix); if (result == ISC_R_SUCCESS) { for (i = 0; i < nframes; i++) { unsigned long offset; diff --git a/external/mpl/bind/dist/lib/isc/base32.c b/external/mpl/bind/dist/lib/isc/base32.c index 9f099097b51..7748ae95e6b 100644 --- a/external/mpl/bind/dist/lib/isc/base32.c +++ b/external/mpl/bind/dist/lib/isc/base32.c @@ -1,4 +1,4 @@ -/* $NetBSD: base32.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: base32.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -284,31 +284,43 @@ static isc_result_t base32_tobuffer(isc_lex_t *lexer, const char base[], bool pad, isc_buffer_t *target, int length) { + unsigned int before, after; base32_decode_ctx_t ctx; isc_textregion_t *tr; isc_token_t token; bool eol; + REQUIRE(length >= -2); + base32_decode_init(&ctx, length, base, pad, target); + before = isc_buffer_usedlength(target); while (!ctx.seen_end && (ctx.length != 0)) { unsigned int i; - if (length > 0) + if (length > 0) { eol = false; - else + } else { eol = true; + } RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, eol)); - if (token.type != isc_tokentype_string) + if (token.type != isc_tokentype_string) { break; + } tr = &token.value.as_textregion; - for (i = 0; i < tr->length; i++) + for (i = 0; i < tr->length; i++) { RETERR(base32_decode_char(&ctx, tr->base[i])); + } } - if (ctx.length < 0 && !ctx.seen_end) + after = isc_buffer_usedlength(target); + if (ctx.length < 0 && !ctx.seen_end) { isc_lex_ungettoken(lexer, &token); + } RETERR(base32_decode_finish(&ctx)); + if (length == -2 && before == after) { + return (ISC_R_UNEXPECTEDEND); + } return (ISC_R_SUCCESS); } diff --git a/external/mpl/bind/dist/lib/isc/base64.c b/external/mpl/bind/dist/lib/isc/base64.c index 2d777aa7d75..3801e65ccdf 100644 --- a/external/mpl/bind/dist/lib/isc/base64.c +++ b/external/mpl/bind/dist/lib/isc/base64.c @@ -1,4 +1,4 @@ -/* $NetBSD: base64.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: base64.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -175,31 +175,43 @@ base64_decode_finish(base64_decode_ctx_t *ctx) { isc_result_t isc_base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length) { + unsigned int before, after; base64_decode_ctx_t ctx; isc_textregion_t *tr; isc_token_t token; bool eol; + REQUIRE(length >= -2); + base64_decode_init(&ctx, length, target); + before = isc_buffer_usedlength(target); while (!ctx.seen_end && (ctx.length != 0)) { unsigned int i; - if (length > 0) + if (length > 0) { eol = false; - else + } else { eol = true; + } RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, eol)); - if (token.type != isc_tokentype_string) + if (token.type != isc_tokentype_string) { break; + } tr = &token.value.as_textregion; - for (i = 0; i < tr->length; i++) + for (i = 0; i < tr->length; i++) { RETERR(base64_decode_char(&ctx, tr->base[i])); + } } - if (ctx.length < 0 && !ctx.seen_end) + after = isc_buffer_usedlength(target); + if (ctx.length < 0 && !ctx.seen_end) { isc_lex_ungettoken(lexer, &token); + } RETERR(base64_decode_finish(&ctx)); + if (length == -2 && before == after) { + return (ISC_R_UNEXPECTEDEND); + } return (ISC_R_SUCCESS); } diff --git a/external/mpl/bind/dist/lib/isc/commandline.c b/external/mpl/bind/dist/lib/isc/commandline.c index d337a5ea585..e29b774b3b3 100644 --- a/external/mpl/bind/dist/lib/isc/commandline.c +++ b/external/mpl/bind/dist/lib/isc/commandline.c @@ -1,4 +1,4 @@ -/* $NetBSD: commandline.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: commandline.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -56,7 +56,6 @@ #include <isc/commandline.h> #include <isc/mem.h> -#include <isc/msgs.h> #include <isc/print.h> #include <isc/string.h> #include <isc/util.h> @@ -137,12 +136,8 @@ isc_commandline_parse(int argc, char * const *argv, const char *options) { isc_commandline_index++; if (isc_commandline_errprint && *options != ':') - fprintf(stderr, "%s: %s -- %c\n", + fprintf(stderr, "%s: illegal option -- %c\n", isc_commandline_progname, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_COMMANDLINE, - ISC_MSG_ILLEGALOPT, - "illegal option"), isc_commandline_option); return (BADOPT); @@ -190,13 +185,8 @@ isc_commandline_parse(int argc, char * const *argv, const char *options) { return (BADARG); if (isc_commandline_errprint) - fprintf(stderr, "%s: %s -- %c\n", + fprintf(stderr, "%s: option requires an argument -- %c\n", isc_commandline_progname, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_COMMANDLINE, - ISC_MSG_OPTNEEDARG, - "option requires " - "an argument"), isc_commandline_option); return (BADOPT); diff --git a/external/mpl/bind/dist/lib/isc/counter.c b/external/mpl/bind/dist/lib/isc/counter.c index 2f241bc206e..888b9cdaa6e 100644 --- a/external/mpl/bind/dist/lib/isc/counter.c +++ b/external/mpl/bind/dist/lib/isc/counter.c @@ -1,4 +1,4 @@ -/* $NetBSD: counter.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: counter.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -18,6 +18,7 @@ #include <stdbool.h> #include <stddef.h> +#include <isc/atomic.h> #include <isc/counter.h> #include <isc/magic.h> #include <isc/mem.h> @@ -29,10 +30,9 @@ struct isc_counter { unsigned int magic; isc_mem_t *mctx; - isc_mutex_t lock; - unsigned int references; - unsigned int limit; - unsigned int used; + atomic_uint_fast32_t references; + atomic_uint_fast32_t limit; + atomic_uint_fast32_t used; }; isc_result_t @@ -45,14 +45,12 @@ isc_counter_create(isc_mem_t *mctx, int limit, isc_counter_t **counterp) { if (counter == NULL) return (ISC_R_NOMEMORY); - isc_mutex_init(&counter->lock); - counter->mctx = NULL; isc_mem_attach(mctx, &counter->mctx); - counter->references = 1; - counter->limit = limit; - counter->used = 0; + atomic_store(&counter->references, 1); + atomic_store(&counter->limit, limit); + atomic_store(&counter->used, 0); counter->magic = COUNTER_MAGIC; *counterp = counter; @@ -63,11 +61,11 @@ isc_result_t isc_counter_increment(isc_counter_t *counter) { isc_result_t result = ISC_R_SUCCESS; - LOCK(&counter->lock); - counter->used++; - if (counter->limit != 0 && counter->used >= counter->limit) + uint32_t used = atomic_fetch_add(&counter->used, 1) + 1; + if (atomic_load(&counter->limit) != 0 && + used >= atomic_load(&counter->limit)) { result = ISC_R_QUOTA; - UNLOCK(&counter->lock); + } return (result); } @@ -76,16 +74,14 @@ unsigned int isc_counter_used(isc_counter_t *counter) { REQUIRE(VALID_COUNTER(counter)); - return (counter->used); + return (atomic_load(&counter->used)); } void isc_counter_setlimit(isc_counter_t *counter, int limit) { REQUIRE(VALID_COUNTER(counter)); - LOCK(&counter->lock); - counter->limit = limit; - UNLOCK(&counter->lock); + atomic_store(&counter->limit, limit); } void @@ -93,10 +89,7 @@ isc_counter_attach(isc_counter_t *source, isc_counter_t **targetp) { REQUIRE(VALID_COUNTER(source)); REQUIRE(targetp != NULL && *targetp == NULL); - LOCK(&source->lock); - source->references++; - INSIST(source->references > 0); - UNLOCK(&source->lock); + INSIST(atomic_fetch_add(&source->references, 1) > 0); *targetp = source; } @@ -104,14 +97,13 @@ isc_counter_attach(isc_counter_t *source, isc_counter_t **targetp) { static void destroy(isc_counter_t *counter) { counter->magic = 0; - isc_mutex_destroy(&counter->lock); isc_mem_putanddetach(&counter->mctx, counter, sizeof(*counter)); } void isc_counter_detach(isc_counter_t **counterp) { isc_counter_t *counter; - bool want_destroy = false; + uint32_t oldrefs; REQUIRE(counterp != NULL && *counterp != NULL); counter = *counterp; @@ -119,13 +111,10 @@ isc_counter_detach(isc_counter_t **counterp) { *counterp = NULL; - LOCK(&counter->lock); - INSIST(counter->references > 0); - counter->references--; - if (counter->references == 0) - want_destroy = true; - UNLOCK(&counter->lock); + oldrefs = atomic_fetch_sub(&counter->references, 1); + INSIST(oldrefs > 0); - if (want_destroy) + if (oldrefs == 1) { destroy(counter); + } } diff --git a/external/mpl/bind/dist/lib/isc/error.c b/external/mpl/bind/dist/lib/isc/error.c index 698632b85c0..22af819c764 100644 --- a/external/mpl/bind/dist/lib/isc/error.c +++ b/external/mpl/bind/dist/lib/isc/error.c @@ -1,4 +1,4 @@ -/* $NetBSD: error.c,v 1.2 2018/08/12 13:02:37 christos Exp $ */ +/* $NetBSD: error.c,v 1.3 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -20,7 +20,6 @@ #include <stdlib.h> #include <isc/error.h> -#include <isc/msgs.h> #include <isc/print.h> /*% Default unexpected callback. */ @@ -74,9 +73,7 @@ isc_error_fatal(const char *file, int line, const char *format, ...) { void isc_error_runtimecheck(const char *file, int line, const char *expression) { - isc_error_fatal(file, line, "RUNTIME_CHECK(%s) %s", expression, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed")); + isc_error_fatal(file, line, "RUNTIME_CHECK(%s) failed", expression); } static void @@ -93,9 +90,7 @@ static void default_fatal_callback(const char *file, int line, const char *format, va_list args) { - fprintf(stderr, "%s:%d: %s: ", file, line, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FATALERROR, "fatal error")); + fprintf(stderr, "%s:%d: fatal error: ", file, line); vfprintf(stderr, format, args); fprintf(stderr, "\n"); fflush(stderr); diff --git a/external/mpl/bind/dist/lib/isc/hex.c b/external/mpl/bind/dist/lib/isc/hex.c index fb977d992c2..b95f67c36e9 100644 --- a/external/mpl/bind/dist/lib/isc/hex.c +++ b/external/mpl/bind/dist/lib/isc/hex.c @@ -1,4 +1,4 @@ -/* $NetBSD: hex.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: hex.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -123,31 +123,43 @@ hex_decode_finish(hex_decode_ctx_t *ctx) { isc_result_t isc_hex_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length) { + unsigned int before, after; hex_decode_ctx_t ctx; isc_textregion_t *tr; isc_token_t token; bool eol; + REQUIRE(length >= -2); + hex_decode_init(&ctx, length, target); + before = isc_buffer_usedlength(target); while (ctx.length != 0) { unsigned int i; - if (length > 0) + if (length > 0) { eol = false; - else + } else { eol = true; + } RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, eol)); - if (token.type != isc_tokentype_string) + if (token.type != isc_tokentype_string) { break; + } tr = &token.value.as_textregion; - for (i = 0; i < tr->length; i++) + for (i = 0; i < tr->length; i++) { RETERR(hex_decode_char(&ctx, tr->base[i])); + } } - if (ctx.length < 0) + after = isc_buffer_usedlength(target); + if (ctx.length < 0) { isc_lex_ungettoken(lexer, &token); + } RETERR(hex_decode_finish(&ctx)); + if (length == -2 && before == after) { + return (ISC_R_UNEXPECTEDEND); + } return (ISC_R_SUCCESS); } diff --git a/external/mpl/bind/dist/lib/isc/include/isc/assertions.h b/external/mpl/bind/dist/lib/isc/include/isc/assertions.h index f0fd2fcc350..1310398ac9b 100644 --- a/external/mpl/bind/dist/lib/isc/include/isc/assertions.h +++ b/external/mpl/bind/dist/lib/isc/include/isc/assertions.h @@ -1,4 +1,4 @@ -/* $NetBSD: assertions.h,v 1.3 2019/01/09 16:55:15 christos Exp $ */ +/* $NetBSD: assertions.h,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -45,75 +45,29 @@ isc_assertion_setcallback(isc_assertioncallback_t); const char * isc_assertion_typetotext(isc_assertiontype_t type); -#if defined(ISC_CHECK_ALL) || defined(__COVERITY__) -#define ISC_CHECK_REQUIRE 1 -#define ISC_CHECK_ENSURE 1 -#define ISC_CHECK_INSIST 1 -#define ISC_CHECK_INVARIANT 1 -#endif - -#if defined(ISC_CHECK_NONE) && !defined(__COVERITY__) -#define ISC_CHECK_REQUIRE 0 -#define ISC_CHECK_ENSURE 0 -#define ISC_CHECK_INSIST 0 -#define ISC_CHECK_INVARIANT 0 -#endif - -#ifndef ISC_CHECK_REQUIRE -#define ISC_CHECK_REQUIRE 1 -#endif - -#ifndef ISC_CHECK_ENSURE -#define ISC_CHECK_ENSURE 1 -#endif - -#ifndef ISC_CHECK_INSIST -#define ISC_CHECK_INSIST 1 -#endif - -#ifndef ISC_CHECK_INVARIANT -#define ISC_CHECK_INVARIANT 1 -#endif - -#if ISC_CHECK_REQUIRE != 0 #define ISC_REQUIRE(cond) \ ((void) (/*CONSTCOND*/ISC_LIKELY(cond) || \ ((isc_assertion_failed)(__FILE__, __LINE__, \ isc_assertiontype_require, \ #cond), 0))) -#else -#define ISC_REQUIRE(cond) ((void) ISC_LIKELY(cond)) -#endif /* ISC_CHECK_REQUIRE */ -#if ISC_CHECK_ENSURE != 0 #define ISC_ENSURE(cond) \ ((void) (/*CONSTCOND*/ISC_LIKELY(cond) || \ ((isc_assertion_failed)(__FILE__, __LINE__, \ isc_assertiontype_ensure, \ #cond), 0))) -#else -#define ISC_ENSURE(cond) ((void) ISC_LIKELY(cond)) -#endif /* ISC_CHECK_ENSURE */ -#if ISC_CHECK_INSIST != 0 #define ISC_INSIST(cond) \ ((void) (/*CONSTCOND*/ISC_LIKELY(cond) || \ ((isc_assertion_failed)(__FILE__, __LINE__, \ isc_assertiontype_insist, \ #cond), 0))) -#else -#define ISC_INSIST(cond) ((void) ISC_LIKELY(cond)) -#endif /* ISC_CHECK_INSIST */ -#if ISC_CHECK_INVARIANT != 0 #define ISC_INVARIANT(cond) \ ((void) (/*CONSTCOND*/ISC_LIKELY(cond) || \ ((isc_assertion_failed)(__FILE__, __LINE__, \ isc_assertiontype_invariant, \ #cond), 0))) -#else -#define ISC_INVARIANT(cond) ((void) ISC_LIKELY(cond)) -#endif /* ISC_CHECK_INVARIANT */ ISC_LANG_ENDDECLS diff --git a/external/mpl/bind/dist/lib/isc/include/isc/atomic.h b/external/mpl/bind/dist/lib/isc/include/isc/atomic.h index f260e1eab0a..653a28fded6 100644 --- a/external/mpl/bind/dist/lib/isc/include/isc/atomic.h +++ b/external/mpl/bind/dist/lib/isc/include/isc/atomic.h @@ -1,4 +1,4 @@ -/* $NetBSD: atomic.h,v 1.2 2019/01/09 16:55:15 christos Exp $ */ +/* $NetBSD: atomic.h,v 1.3 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -18,3 +18,12 @@ #else #include <isc/stdatomic.h> #endif + +/* + * We define a few additional macros to make things easier + */ + +#define atomic_store_relaxed(o, v) atomic_store_explicit((o), \ + (v), \ + memory_order_relaxed) +#define atomic_load_relaxed(o) atomic_load_explicit((o), memory_order_relaxed) diff --git a/external/mpl/bind/dist/lib/isc/include/isc/base32.h b/external/mpl/bind/dist/lib/isc/include/isc/base32.h index 8213cd1ab49..e23757068f0 100644 --- a/external/mpl/bind/dist/lib/isc/include/isc/base32.h +++ b/external/mpl/bind/dist/lib/isc/include/isc/base32.h @@ -1,4 +1,4 @@ -/* $NetBSD: base32.h,v 1.2 2018/08/12 13:02:38 christos Exp $ */ +/* $NetBSD: base32.h,v 1.3 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -98,18 +98,27 @@ isc_result_t isc_base32hexnp_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length); /*!< * \brief Convert text encoded in base32, base32hex, or base32hex - * non-padded from a lexer context into data. + * non-padded from a lexer context into `target`. If 'length' is + * non-negative, it is the expected number of encoded octets to convert. + * + * If 'length' is -1 then 0 or more encoded octets are expected. + * If 'length' is -2 then 1 or more encoded octets are expected. + * + * Returns: + *\li #ISC_R_BADBASE32 -- invalid base32 encoding. + *\li #ISC_R_UNEXPECTEDEND: the text does not contain the expected + * number of encoded octets. * * Requires: - *\li 'lex' is a valid lexer context + *\li 'lexer' is a valid lexer context *\li 'target' is a buffer containing binary data - *\li 'length' is an integer + *\li 'length' is -2, -1, or non-negative * * Ensures: *\li target will contain the data represented by the base32 encoded - * string parsed by the lexer. No more than length bytes will be read, - * if length is positive. The 'used' pointer in target will be - * advanced as necessary. + * string parsed by the lexer. No more than `length` octets will + * be read, if `length` is non-negative. The 'used' pointer in + * 'target' will be advanced as necessary. */ isc_result_t diff --git a/external/mpl/bind/dist/lib/isc/include/isc/base64.h b/external/mpl/bind/dist/lib/isc/include/isc/base64.h index dbe683e92ee..9143bb01434 100644 --- a/external/mpl/bind/dist/lib/isc/include/isc/base64.h +++ b/external/mpl/bind/dist/lib/isc/include/isc/base64.h @@ -1,4 +1,4 @@ -/* $NetBSD: base64.h,v 1.2 2018/08/12 13:02:38 christos Exp $ */ +/* $NetBSD: base64.h,v 1.3 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -73,22 +73,30 @@ isc_base64_decodestring(const char *cstr, isc_buffer_t *target); isc_result_t isc_base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length); /*!< - * \brief Convert base64 encoded text from a lexer context into data. + * \brief Convert base64 encoded text from a lexer context into + * `target`. If 'length' is non-negative, it is the expected number of + * encoded octets to convert. + * + * If 'length' is -1 then 0 or more encoded octets are expected. + * If 'length' is -2 then 1 or more encoded octets are expected. + * + * Returns: + *\li #ISC_R_BADBASE64 -- invalid base64 encoding. + *\li #ISC_R_UNEXPECTEDEND: the text does not contain the expected + * number of encoded octets. * * Requires: - *\li 'lex' is a valid lexer context + *\li 'lexer' is a valid lexer context *\li 'target' is a buffer containing binary data - *\li 'length' is an integer + *\li 'length' is -2, -1, or non-negative * * Ensures: *\li target will contain the data represented by the base64 encoded - * string parsed by the lexer. No more than length bytes will be read, - * if length is positive. The 'used' pointer in target will be - * advanced as necessary. + * string parsed by the lexer. No more than `length` octets will + * be read, if `length` is non-negative. The 'used' pointer in + * 'target' will be advanced as necessary. */ - - ISC_LANG_ENDDECLS #endif /* ISC_BASE64_H */ diff --git a/external/mpl/bind/dist/lib/isc/include/isc/hex.h b/external/mpl/bind/dist/lib/isc/include/isc/hex.h index d87d33a3dc1..f5022760750 100644 --- a/external/mpl/bind/dist/lib/isc/include/isc/hex.h +++ b/external/mpl/bind/dist/lib/isc/include/isc/hex.h @@ -1,4 +1,4 @@ -/* $NetBSD: hex.h,v 1.2 2018/08/12 13:02:38 christos Exp $ */ +/* $NetBSD: hex.h,v 1.3 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -73,21 +73,30 @@ isc_hex_decodestring(const char *cstr, isc_buffer_t *target); isc_result_t isc_hex_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length); /*!< - * \brief Convert hex encoded text from a lexer context into data. + * \brief Convert hex-encoded text from a lexer context into + * `target`. If 'length' is non-negative, it is the expected number of + * encoded octets to convert. + * + * If 'length' is -1 then 0 or more encoded octets are expected. + * If 'length' is -2 then 1 or more encoded octets are expected. + * + * Returns: + *\li #ISC_R_BADHEX -- invalid hex encoding + *\li #ISC_R_UNEXPECTEDEND: the text does not contain the expected + * number of encoded octets. * * Requires: - *\li 'lex' is a valid lexer context + *\li 'lexer' is a valid lexer context *\li 'target' is a buffer containing binary data - *\li 'length' is an integer + *\li 'length' is -2, -1, or non-negative * * Ensures: *\li target will contain the data represented by the hex encoded - * string parsed by the lexer. No more than length bytes will be read, - * if length is positive. The 'used' pointer in target will be - * advanced as necessary. + * string parsed by the lexer. No more than `length` octets will + * be read, if `length` is non-negative. The 'used' pointer in + * 'target' will be advanced as necessary. */ - ISC_LANG_ENDDECLS #endif /* ISC_HEX_H */ diff --git a/external/mpl/bind/dist/lib/isc/include/isc/lib.h b/external/mpl/bind/dist/lib/isc/include/isc/lib.h index 63b429c0720..38bfa097836 100644 --- a/external/mpl/bind/dist/lib/isc/include/isc/lib.h +++ b/external/mpl/bind/dist/lib/isc/include/isc/lib.h @@ -1,4 +1,4 @@ -/* $NetBSD: lib.h,v 1.2 2018/08/12 13:02:38 christos Exp $ */ +/* $NetBSD: lib.h,v 1.3 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -22,15 +22,6 @@ ISC_LANG_BEGINDECLS -LIBISC_EXTERNAL_DATA extern isc_msgcat_t *isc_msgcat; - -void -isc_lib_initmsgcat(void); -/*!< - * \brief Initialize the ISC library's message catalog, isc_msgcat, if it - * has not already been initialized. - */ - void isc_lib_register(void); /*!< diff --git a/external/mpl/bind/dist/lib/isc/include/isc/log.h b/external/mpl/bind/dist/lib/isc/include/isc/log.h index 0807c79d38d..89c878e8c90 100644 --- a/external/mpl/bind/dist/lib/isc/include/isc/log.h +++ b/external/mpl/bind/dist/lib/isc/include/isc/log.h @@ -1,4 +1,4 @@ -/* $NetBSD: log.h,v 1.3 2019/01/09 16:55:15 christos Exp $ */ +/* $NetBSD: log.h,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -546,9 +546,6 @@ isc_log_usechannel(isc_logconfig_t *lcfg, const char *name, * Write a message to the log channels. * * Notes: - *\li Log messages containing natural language text should be logged with - * isc_log_iwrite() to allow for localization. - * *\li lctx can be NULL; this is allowed so that programs which use * libraries that use the ISC logging system are not required to * also use it. @@ -646,50 +643,6 @@ isc_log_vwrite1(isc_log_t *lctx, isc_logcategory_t *category, ISC_FORMAT_PRINTF(5, 0); -/*% - * These are four internationalized versions of the isc_log_[v]write[1] - * functions. - * - * The only difference is that they take arguments for a message - * catalog, message set, and message number, all immediately preceding the - * format argument. The format argument becomes the default text, a la - * isc_msgcat_get. If the message catalog is NULL, no lookup is attempted - * for a message -- which makes the message set and message number irrelevant, - * and the non-internationalized call should have probably been used instead. - * - * Yes, that means there are now *eight* interfaces to logging a message. - * Sheesh. Make the madness stop! - */ -/*@{*/ -void -isc_log_iwrite(isc_log_t *lctx, isc_logcategory_t *category, - isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int message, - const char *format, ...) -ISC_FORMAT_PRINTF(8, 9); - -void -isc_log_ivwrite(isc_log_t *lctx, isc_logcategory_t *category, - isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int message, - const char *format, va_list args) -ISC_FORMAT_PRINTF(8, 0); - -void -isc_log_iwrite1(isc_log_t *lctx, isc_logcategory_t *category, - isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int message, - const char *format, ...) -ISC_FORMAT_PRINTF(8, 9); - -void -isc_log_ivwrite1(isc_log_t *lctx, isc_logcategory_t *category, - isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int message, - const char *format, va_list args) -ISC_FORMAT_PRINTF(8, 0); -/*@}*/ - void isc_log_setdebuglevel(isc_log_t *lctx, unsigned int level); /*%< diff --git a/external/mpl/bind/dist/lib/isc/include/isc/msgcat.h b/external/mpl/bind/dist/lib/isc/include/isc/msgcat.h deleted file mode 100644 index 9302e6b9a07..00000000000 --- a/external/mpl/bind/dist/lib/isc/include/isc/msgcat.h +++ /dev/null @@ -1,126 +0,0 @@ -/* $NetBSD: msgcat.h,v 1.2 2018/08/12 13:02:38 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -#ifndef ISC_MSGCAT_H -#define ISC_MSGCAT_H 1 - -/***** - ***** Module Info - *****/ - -/*! \file isc/msgcat.h - * \brief The ISC Message Catalog - * aids internationalization of applications by allowing - * messages to be retrieved from locale-specific files instead of - * hardwiring them into the application. This allows translations of - * messages appropriate to the locale to be supplied without recompiling - * the application. - * - * Notes: - *\li It's very important that message catalogs work, even if only the - * default_text can be used. - * - * MP: - *\li The caller must ensure appropriate synchronization of - * isc_msgcat_open() and isc_msgcat_close(). isc_msgcat_get() - * ensures appropriate synchronization. - * - * Reliability: - *\li No anticipated impact. - * - * Resources: - *\li TBS - * - * \li Security: - * No anticipated impact. - * - * \li Standards: - * None. - */ - -/***** - ***** Imports - *****/ - -#include <isc/lang.h> -#include <isc/types.h> - -ISC_LANG_BEGINDECLS - -/***** - ***** Methods - *****/ - -void -isc_msgcat_open(const char *name, isc_msgcat_t **msgcatp); -/*%< - * Open a message catalog. - * - * Notes: - * - *\li If memory cannot be allocated or other failures occur, *msgcatp - * will be set to NULL. If a NULL msgcat is given to isc_msgcat_get(), - * the default_text will be returned, ensuring that some message text - * will be available, no matter what's going wrong. - * - * Requires: - * - *\li 'name' is a valid string. - * - *\li msgcatp != NULL && *msgcatp == NULL - */ - -void -isc_msgcat_close(isc_msgcat_t **msgcatp); -/*%< - * Close a message catalog. - * - * Notes: - * - *\li Any string pointers returned by prior calls to isc_msgcat_get() are - * invalid after isc_msgcat_close() has been called and must not be - * used. - * - * Requires: - * - *\li *msgcatp is a valid message catalog or is NULL. - * - * Ensures: - * - *\li All resources associated with the message catalog are released. - * - *\li *msgcatp == NULL - */ - -const char * -isc_msgcat_get(isc_msgcat_t *msgcat, int set, int message, - const char *default_text); -/*%< - * Get message 'message' from message set 'set' in 'msgcat'. If it - * is not available, use 'default_text'. - * - * Requires: - * - *\li 'msgcat' is a valid message catalog or is NULL. - * - *\li set > 0 - * - *\li message > 0 - * - *\li 'default_text' is a valid string. - */ - -ISC_LANG_ENDDECLS - -#endif /* ISC_MSGCAT_H */ diff --git a/external/mpl/bind/dist/lib/isc/include/isc/msgs.h b/external/mpl/bind/dist/lib/isc/include/isc/msgs.h deleted file mode 100644 index cfabd6e6fbb..00000000000 --- a/external/mpl/bind/dist/lib/isc/include/isc/msgs.h +++ /dev/null @@ -1,190 +0,0 @@ -/* $NetBSD: msgs.h,v 1.2 2018/08/12 13:02:38 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -#ifndef ISC_MSGS_H -#define ISC_MSGS_H 1 - -/*! \file isc/msgs.h */ - -#include <isc/lib.h> /* Provide isc_msgcat global variable. */ -#include <isc/msgcat.h> /* Provide isc_msgcat_*() functions. */ - -/*@{*/ -/*! - * \brief Message sets, named per source file, excepting "GENERAL". - * - * IMPORTANT: The original list is alphabetical, but any new sets must - * be added to the end. - */ -#define ISC_MSGSET_GENERAL 1 -/* ISC_RESULT_RESULTSET 2 */ /* XXX */ -/* ISC_RESULT_UNAVAILABLESET 3 */ /* XXX */ -#define ISC_MSGSET_APP 4 -#define ISC_MSGSET_COMMANDLINE 5 -#define ISC_MSGSET_ENTROPY 6 -#define ISC_MSGSET_IFITERIOCTL 7 -#define ISC_MSGSET_IFITERSYSCTL 8 -#define ISC_MSGSET_LEX 9 -#define ISC_MSGSET_LOG 10 -#define ISC_MSGSET_MEM 11 -#define ISC_MSGSET_NETADDR 12 -#define ISC_MSGSET_PRINT 13 -#define ISC_MSGSET_RESULT 14 -#define ISC_MSGSET_RWLOCK 15 -#define ISC_MSGSET_SOCKADDR 16 -#define ISC_MSGSET_SOCKET 17 -#define ISC_MSGSET_TASK 18 -#define ISC_MSGSET_TIMER 19 -#define ISC_MSGSET_UTIL 20 -#define ISC_MSGSET_IFITERGETIFADDRS 21 -/*@}*/ - -/*@{*/ -/*! - * Message numbers - * are only required to be unique per message set, - * but are unique throughout the entire catalog to not be as confusing when - * debugging. - * - * The initial numbering was done by multiply by 100 the set number the - * message appears in then adding the incremental message number. - */ -#define ISC_MSG_FAILED 101 /*%< "failed" */ -#define ISC_MSG_SUCCEEDED 102 /*%< Compatible with "failed" */ -#define ISC_MSG_SUCCESS 103 /*%< More usual way to say "success" */ -#define ISC_MSG_STARTING 104 /*%< As in "daemon: starting" */ -#define ISC_MSG_STOPING 105 /*%< As in "daemon: stopping" */ -#define ISC_MSG_ENTERING 106 /*%< As in "some_subr: entering" */ -#define ISC_MSG_EXITING 107 /*%< As in "some_subr: exiting" */ -#define ISC_MSG_CALLING 108 /*%< As in "calling some_subr()" */ -#define ISC_MSG_RETURNED 109 /*%< As in "some_subr: returned <foo>" */ -#define ISC_MSG_FATALERROR 110 /*%< "fatal error" */ -#define ISC_MSG_SHUTTINGDOWN 111 /*%< "shutting down" */ -#define ISC_MSG_RUNNING 112 /*%< "running" */ -#define ISC_MSG_WAIT 113 /*%< "wait" */ -#define ISC_MSG_WAITUNTIL 114 /*%< "waituntil" */ - -#define ISC_MSG_SIGNALSETUP 201 /*%< "handle_signal() %d setup: %s" */ - -#define ISC_MSG_ILLEGALOPT 301 /*%< "illegal option" */ -#define ISC_MSG_OPTNEEDARG 302 /*%< "option requires an argument" */ - -#define ISC_MSG_ENTROPYSTATS 401 /*%< "Entropy pool %p: refcnt %u ..." */ - -#define ISC_MSG_MAKESCANSOCKET 501 /*%< "making interface scan socket: %s" */ -#define ISC_MSG_GETIFCONFIG 502 /*%< "get interface configuration: %s" */ -#define ISC_MSG_BUFFERMAX 503 /*%< "... maximum buffer size exceeded" */ -#define ISC_MSG_GETDESTADDR 504 /*%< "%s: getting destination address: %s" */ -#define ISC_MSG_GETNETMASK 505 /*%< "%s: getting netmask: %s" */ - -#define ISC_MSG_GETIFLISTSIZE 601 /*%< "getting interface list size: ..." */ -#define ISC_MSG_GETIFLIST 602 /*%< "getting interface list: ..." */ -#define ISC_MSG_UNEXPECTEDTYPE 603 /*%< "... unexpected ... message type" */ - -#define ISC_MSG_UNEXPECTEDSTATE 701 /*%< "Unexpected state %d" */ - -#define ISC_MSG_BADTIME 801 /*%< "Bad 00 99:99:99.999 " */ -#define ISC_MSG_LEVEL 802 /*%< "level %d: " */ - -#define ISC_MSG_ADDTRACE 901 /*%< "add %p size %u " */ -#define ISC_MSG_DELTRACE 902 /*%< "del %p size %u " */ -#define ISC_MSG_POOLSTATS 903 /*%< "[Pool statistics]\n" */ -#define ISC_MSG_POOLNAME 904 /*%< "name" */ -#define ISC_MSG_POOLSIZE 905 /*%< "size" */ -#define ISC_MSG_POOLMAXALLOC 906 /*%< "maxalloc" */ -#define ISC_MSG_POOLALLOCATED 907 /*%< "allocated" */ -#define ISC_MSG_POOLFREECOUNT 908 /*%< "freecount" */ -#define ISC_MSG_POOLFREEMAX 909 /*%< "freemax" */ -#define ISC_MSG_POOLFILLCOUNT 910 /*%< "fillcount" */ -#define ISC_MSG_POOLGETS 911 /*%< "gets" */ -#define ISC_MSG_DUMPALLOC 912 /*%< "DUMP OF ALL OUTSTANDING MEMORY ..." */ -#define ISC_MSG_NONE 913 /*%< "\tNone.\n" */ -#define ISC_MSG_PTRFILELINE 914 /*%< "\tptr %p file %s line %u\n" */ - -#define ISC_MSG_UNKNOWNADDR 1001 /*%< "<unknown address, family %u>" */ - -#define ISC_MSG_NOLONGDBL 1104 /*%< "long doubles are not supported" */ - -#define ISC_MSG_PRINTLOCK 1201 /*%< "rwlock %p thread %lu ..." */ -#define ISC_MSG_READ 1202 /*%< "read" */ -#define ISC_MSG_WRITE 1203 /*%< "write" */ -#define ISC_MSG_READING 1204 /*%< "reading" */ -#define ISC_MSG_WRITING 1205 /*%< "writing" */ -#define ISC_MSG_PRELOCK 1206 /*%< "prelock" */ -#define ISC_MSG_POSTLOCK 1207 /*%< "postlock" */ -#define ISC_MSG_PREUNLOCK 1208 /*%< "preunlock" */ -#define ISC_MSG_POSTUNLOCK 1209 /*%< "postunlock" */ -#define ISC_MSG_PRINTLOCK2 1210 /*%< "rwlock %p thread %lu ..." w/ atomic */ - -#define ISC_MSG_UNKNOWNFAMILY 1301 /*%< "unknown address family: %d" */ - -#define ISC_MSG_WRITEFAILED 1401 /*%< "write() failed during watcher ..." */ -#define ISC_MSG_READFAILED 1402 /*%< "read() failed during watcher ... " */ -#define ISC_MSG_PROCESSCMSG 1403 /*%< "processing cmsg %p" */ -#define ISC_MSG_IFRECEIVED 1404 /*%< "interface received on ifindex %u" */ -#define ISC_MSG_SENDTODATA 1405 /*%< "sendto pktinfo data, ifindex %u" */ -#define ISC_MSG_DOIORECV 1406 /*%< "doio_recv: recvmsg(%d) %d bytes ..." */ -#define ISC_MSG_PKTRECV 1407 /*%< "packet received correctly" */ -#define ISC_MSG_DESTROYING 1408 /*%< "destroying" */ -#define ISC_MSG_CREATED 1409 /*%< "created" */ -#define ISC_MSG_ACCEPTLOCK 1410 /*%< "internal_accept called, locked ..." */ -#define ISC_MSG_ACCEPTEDCXN 1411 /*%< "accepted connection, new socket %p" */ -#define ISC_MSG_INTERNALRECV 1412 /*%< "internal_recv: task %p got event %p" */ -#define ISC_MSG_INTERNALSEND 1413 /*%< "internal_send: task %p got event %p" */ -#define ISC_MSG_WATCHERMSG 1414 /*%< "watcher got message %d" */ -#define ISC_MSG_SOCKETSREMAIN 1415 /*%< "sockets exist" */ -#define ISC_MSG_PKTINFOPROVIDED 1416 /*%< "pktinfo structure provided, ..." */ -#define ISC_MSG_BOUND 1417 /*%< "bound" */ -#define ISC_MSG_ACCEPTRETURNED 1418 /*%< accept() returned %d/%s */ -#define ISC_MSG_TOOMANYFDS 1419 /*%< %s: too many open file descriptors */ -#define ISC_MSG_ZEROPORT 1420 /*%< dropping source port zero packet */ -#define ISC_MSG_FILTER 1421 /*%< setsockopt(SO_ACCEPTFILTER): %s */ - -#define ISC_MSG_TOOMANYHANDLES 1422 /*%< %s: too many open WSA event handles: %s */ -#define ISC_MSG_POKED 1423 /*%< "poked flags: %d" */ - -#define ISC_MSG_AWAKE 1502 /*%< "awake" */ -#define ISC_MSG_WORKING 1503 /*%< "working" */ -#define ISC_MSG_EXECUTE 1504 /*%< "execute action" */ -#define ISC_MSG_EMPTY 1505 /*%< "empty" */ -#define ISC_MSG_DONE 1506 /*%< "done" */ -#define ISC_MSG_QUANTUM 1507 /*%< "quantum" */ - -#define ISC_MSG_SCHEDULE 1601 /*%< "schedule" */ -#define ISC_MSG_SIGNALSCHED 1602 /*%< "signal (schedule)" */ -#define ISC_MSG_SIGNALDESCHED 1603 /*%< "signal (deschedule)" */ -#define ISC_MSG_SIGNALDESTROY 1604 /*%< "signal (destroy)" */ -#define ISC_MSG_IDLERESCHED 1605 /*%< "idle reschedule" */ -#define ISC_MSG_EVENTNOTALLOC 1606 /*%< "couldn't allocate event" */ -#define ISC_MSG_SCHEDFAIL 1607 /*%< "couldn't schedule timer: %u" */ -#define ISC_MSG_POSTING 1608 /*%< "posting" */ -#define ISC_MSG_WAKEUP 1609 /*%< "wakeup" */ - -#define ISC_MSG_LOCK 1701 /*%< "LOCK" */ -#define ISC_MSG_LOCKING 1702 /*%< "LOCKING" */ -#define ISC_MSG_LOCKED 1703 /*%< "LOCKED" */ -#define ISC_MSG_UNLOCKED 1704 /*%< "UNLOCKED" */ -#define ISC_MSG_RWLOCK 1705 /*%< "RWLOCK" */ -#define ISC_MSG_RWLOCKED 1706 /*%< "RWLOCKED" */ -#define ISC_MSG_RWUNLOCK 1707 /*%< "RWUNLOCK" */ -#define ISC_MSG_BROADCAST 1708 /*%< "BROADCAST" */ -#define ISC_MSG_SIGNAL 1709 /*%< "SIGNAL" */ -#define ISC_MSG_UTILWAIT 1710 /*%< "WAIT" */ -#define ISC_MSG_WAITED 1711 /*%< "WAITED" */ - -#define ISC_MSG_GETIFADDRS 1801 /*%< "getting interface addresses: ..." */ - -/*@}*/ - -#endif /* ISC_MSGS_H */ diff --git a/external/mpl/bind/dist/lib/isc/include/isc/quota.h b/external/mpl/bind/dist/lib/isc/include/isc/quota.h index 569caa08a01..e3206a046b4 100644 --- a/external/mpl/bind/dist/lib/isc/include/isc/quota.h +++ b/external/mpl/bind/dist/lib/isc/include/isc/quota.h @@ -1,4 +1,4 @@ -/* $NetBSD: quota.h,v 1.3 2019/01/09 16:55:15 christos Exp $ */ +/* $NetBSD: quota.h,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -32,6 +32,7 @@ *** Imports. ***/ +#include <isc/atomic.h> #include <isc/lang.h> #include <isc/mutex.h> #include <isc/types.h> @@ -44,14 +45,14 @@ ISC_LANG_BEGINDECLS /*% isc_quota structure */ struct isc_quota { - isc_mutex_t lock; /*%< Locked by lock. */ - int max; - int used; - int soft; + atomic_uint_fast32_t max; + atomic_uint_fast32_t used; + atomic_uint_fast32_t soft; }; + void -isc_quota_init(isc_quota_t *quota, int max); +isc_quota_init(isc_quota_t *quota, unsigned int max); /*%< * Initialize a quota object. */ @@ -63,17 +64,35 @@ isc_quota_destroy(isc_quota_t *quota); */ void -isc_quota_soft(isc_quota_t *quota, int soft); +isc_quota_soft(isc_quota_t *quota, unsigned int soft); /*%< * Set a soft quota. */ void -isc_quota_max(isc_quota_t *quota, int max); +isc_quota_max(isc_quota_t *quota, unsigned int max); /*%< * Re-set a maximum quota. */ +unsigned int +isc_quota_getmax(isc_quota_t *quota); +/*%< + * Get the maximum quota. + */ + +unsigned int +isc_quota_getsoft(isc_quota_t *quota); +/*%< + * Get the soft quota. + */ + +unsigned int +isc_quota_getused(isc_quota_t *quota); +/*%< + * Get the current usage of quota. + */ + isc_result_t isc_quota_reserve(isc_quota_t *quota); /*%< diff --git a/external/mpl/bind/dist/lib/isc/include/isc/result.h b/external/mpl/bind/dist/lib/isc/include/isc/result.h index 28119fb298d..e914eefeb5f 100644 --- a/external/mpl/bind/dist/lib/isc/include/isc/result.h +++ b/external/mpl/bind/dist/lib/isc/include/isc/result.h @@ -1,4 +1,4 @@ -/* $NetBSD: result.h,v 1.3 2019/01/09 16:55:15 christos Exp $ */ +/* $NetBSD: result.h,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -108,11 +108,11 @@ isc_result_toid(isc_result_t); isc_result_t isc_result_register(unsigned int base, unsigned int nresults, - const char **text, isc_msgcat_t *msgcat, int set); + const char **text, int set); isc_result_t isc_result_registerids(unsigned int base, unsigned int nresults, - const char **ids, isc_msgcat_t *msgcat, int set); + const char **ids, int set); ISC_LANG_ENDDECLS diff --git a/external/mpl/bind/dist/lib/isc/include/isc/stdatomic.h b/external/mpl/bind/dist/lib/isc/include/isc/stdatomic.h deleted file mode 100644 index 4f103302777..00000000000 --- a/external/mpl/bind/dist/lib/isc/include/isc/stdatomic.h +++ /dev/null @@ -1,148 +0,0 @@ -/* $NetBSD: stdatomic.h,v 1.2 2019/01/09 16:55:15 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#pragma once - -#if !defined(__has_feature) -#define __has_feature(x) 0 -#endif - -#if !defined(__has_extension) -#define __has_extension(x) __has_feature(x) -#endif - -#if !defined(__GNUC_PREREQ__) -#if defined(__GNUC__) && defined(__GNUC_MINOR__) -#define __GNUC_PREREQ__(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) -#else -#define __GNUC_PREREQ__(maj, min) 0 -#endif -#endif - -#if !defined(__CLANG_ATOMICS) && !defined(__GNUC_ATOMICS) -#if __has_extension(c_atomic) || __has_extension(cxx_atomic) -#define __CLANG_ATOMICS -#elif __GNUC_PREREQ__(4, 7) -#define __GNUC_ATOMICS -#elif !defined(__GNUC__) -#error "isc/stdatomic.h does not support your compiler" -#endif -#endif - -#ifndef __ATOMIC_RELAXED -#define __ATOMIC_RELAXED 0 -#endif -#ifndef __ATOMIC_CONSUME -#define __ATOMIC_CONSUME 1 -#endif -#ifndef __ATOMIC_ACQUIRE -#define __ATOMIC_ACQUIRE 2 -#endif -#ifndef __ATOMIC_RELEASE -#define __ATOMIC_RELEASE 3 -#endif -#ifndef __ATOMIC_ACQ_REL -#define __ATOMIC_ACQ_REL 4 -#endif -#ifndef __ATOMIC_SEQ_CST -#define __ATOMIC_SEQ_CST 5 -#endif - - -enum memory_order { - memory_order_relaxed = __ATOMIC_RELAXED, - memory_order_consume = __ATOMIC_CONSUME, - memory_order_acquire = __ATOMIC_ACQUIRE, - memory_order_release = __ATOMIC_RELEASE, - memory_order_acq_rel = __ATOMIC_ACQ_REL, - memory_order_seq_cst = __ATOMIC_SEQ_CST -}; - -typedef enum memory_order memory_order; - -typedef int_fast32_t atomic_int_fast32_t; -typedef uint_fast32_t atomic_uint_fast32_t; -typedef int_fast64_t atomic_int_fast64_t; -typedef uint_fast64_t atomic_uint_fast64_t; - -#if defined(__CLANG_ATOMICS) /* __c11_atomic builtins */ -#define atomic_init(obj, desired) \ - __c11_atomic_init(obj, desired) -#define atomic_load_explicit(obj, order) \ - __c11_atomic_load(obj, order) -#define atomic_store_explicit(obj, desired, order) \ - __c11_atomic_store(obj, desired, order) -#define atomic_fetch_add_explicit(obj, arg, order) \ - __c11_atomic_fetch_add(obj, arg, order) -#define atomic_fetch_sub_explicit(obj, arg, order) \ - __c11_atomic_fetch_sub(obj, arg, order) -#define atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) \ - __c11_atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) -#define atomic_compare_exchange_weak_explicit(obj, expected, desired, succ, fail) \ - __c11_atomic_compare_exchange_weak_explicit(obj, expected, desired, succ, fail) -#elif defined(__GNUC_ATOMICS) /* __atomic builtins */ -#define atomic_init(obj, desired) \ - (*obj = desired) -#define atomic_load_explicit(obj, order) \ - __atomic_load_n(obj, order) -#define atomic_store_explicit(obj, desired, order) \ - __atomic_store_n(obj, desired, order) -#define atomic_fetch_add_explicit(obj, arg, order) \ - __atomic_fetch_add(obj, arg, order) -#define atomic_fetch_sub_explicit(obj, arg, order) \ - __atomic_fetch_sub(obj, arg, order) -#define atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) \ - __atomic_compare_exchange_n(obj, expected, desired, 0, succ, fail) -#define atomic_compare_exchange_weak_explicit(obj, expected, desired, succ, fail) \ - __atomic_compare_exchange_n(obj, expected, desired, 1, succ, fail) -#else /* __sync builtins */ -#define atomic_init(obj, desired) \ - (*obj = desired) -#define atomic_load_explicit(obj, order) \ - __sync_fetch_and_add(obj, 0) -#define atomic_store_explicit(obj, desired, order) \ - do { \ - __sync_synchronize(); \ - *obj = desired; \ - __sync_synchronize(); \ - } while (0); -#define atomic_fetch_add_explicit(obj, arg, order) \ - __sync_fetch_and_add(obj, arg) -#define atomic_fetch_sub_explicit(obj, arg, order) \ - __sync_fetch_and_sub(obj, arg, order) -#define atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) \ - ({ \ - __typeof__(obj) __v; \ - _Bool __r; \ - __v = __sync_val_compare_and_swap(obj, *(expected), desired); \ - __r = *(expected) == __v; \ - *(expected) = __v; \ - __r; \ - }) -#define atomic_compare_exchange_weak_explicit(obj, expected, desired, succ, fail) \ - atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) -#endif - -#define atomic_load(obj) \ - atomic_load_explicit(obj, memory_order_seq_cst) -#define atomic_store(obj) \ - atomic_store_explicit(obj, memory_order_seq_cst) -#define atomic_fetch_add(obj) \ - atomic_fetch_add_explicit(obj, arg, memory_order_seq_cst) -#define atomic_fetch_sub(obj) \ - atomic_fetch_sub_explicit(obj, arg, memory_order_seq_cst) -#define atomic_compare_exchange_strong(obj, expected, desired) \ - atomic_compare_exchange_strong_explicit(obj, expected, desired, memory_order_seq_cst, memory_order_seq_cst) -#define atomic_compare_exchange_weak(obj, expected, desired) \ - atomic_compare_exchange_weak_explicit(obj, expected, desired, memory_order_seq_cst, memory_order_seq_cst) diff --git a/external/mpl/bind/dist/lib/isc/include/isc/types.h b/external/mpl/bind/dist/lib/isc/include/isc/types.h index 049fbb82e86..c9893597d27 100644 --- a/external/mpl/bind/dist/lib/isc/include/isc/types.h +++ b/external/mpl/bind/dist/lib/isc/include/isc/types.h @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.3 2019/01/09 16:55:15 christos Exp $ */ +/* $NetBSD: types.h,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -60,7 +60,6 @@ typedef struct isc_logconfig isc_logconfig_t; /*%< Log Configuration */ typedef struct isc_logmodule isc_logmodule_t; /*%< Log Module */ typedef struct isc_mem isc_mem_t; /*%< Memory */ typedef struct isc_mempool isc_mempool_t; /*%< Memory Pool */ -typedef struct isc_msgcat isc_msgcat_t; /*%< Message Catalog */ typedef struct isc_netaddr isc_netaddr_t; /*%< Net Address */ typedef struct isc_portset isc_portset_t; /*%< Port Set */ typedef struct isc_quota isc_quota_t; /*%< Quota */ diff --git a/external/mpl/bind/dist/lib/isc/include/isc/util.h b/external/mpl/bind/dist/lib/isc/include/isc/util.h index 50bdfe22e47..ae11d0d4c31 100644 --- a/external/mpl/bind/dist/lib/isc/include/isc/util.h +++ b/external/mpl/bind/dist/lib/isc/include/isc/util.h @@ -1,4 +1,4 @@ -/* $NetBSD: util.h,v 1.3 2019/01/09 16:55:15 christos Exp $ */ +/* $NetBSD: util.h,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -83,7 +83,6 @@ #ifdef ISC_UTIL_TRACEON #define ISC_UTIL_TRACE(a) a #include <stdio.h> /* Required for fprintf/stderr when tracing. */ -#include <isc/msgs.h> /* Required for isc_msgcat when tracing. */ #else #define ISC_UTIL_TRACE(a) #endif @@ -91,53 +90,35 @@ #include <isc/result.h> /* Contractual promise. */ #define LOCK(lp) do { \ - ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_LOCKING, "LOCKING"), \ + ISC_UTIL_TRACE(fprintf(stderr, "LOCKING %p %s %d\n", \ (lp), __FILE__, __LINE__)); \ RUNTIME_CHECK(isc_mutex_lock((lp)) == ISC_R_SUCCESS); \ - ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_LOCKED, "LOCKED"), \ + ISC_UTIL_TRACE(fprintf(stderr, "LOCKED %p %s %d\n", \ (lp), __FILE__, __LINE__)); \ } while (/*CONSTCOND*/0) #define UNLOCK(lp) do { \ RUNTIME_CHECK(isc_mutex_unlock((lp)) == ISC_R_SUCCESS); \ - ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_UNLOCKED, "UNLOCKED"), \ + ISC_UTIL_TRACE(fprintf(stderr, "UNLOCKED %p %s %d\n", \ (lp), __FILE__, __LINE__)); \ } while (/*CONSTCOND*/0) #define BROADCAST(cvp) do { \ - ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_BROADCAST, "BROADCAST"),\ + ISC_UTIL_TRACE(fprintf(stderr, "BROADCAST %p %s %d\n", \ (cvp), __FILE__, __LINE__)); \ RUNTIME_CHECK(isc_condition_broadcast((cvp)) == ISC_R_SUCCESS); \ } while (/*CONSTCOND*/0) #define SIGNAL(cvp) do { \ - ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_SIGNAL, "SIGNAL"), \ + ISC_UTIL_TRACE(fprintf(stderr, "SIGNAL %p %s %d\n", \ (cvp), __FILE__, __LINE__)); \ RUNTIME_CHECK(isc_condition_signal((cvp)) == ISC_R_SUCCESS); \ } while (/*CONSTCOND*/0) #define WAIT(cvp, lp) do { \ - ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %p %s %d\n", \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_UTILWAIT, "WAIT"), \ + ISC_UTIL_TRACE(fprintf(stderr, "WAIT %p LOCK %p %s %d\n", \ (cvp), \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_LOCK, "LOCK"), \ (lp), __FILE__, __LINE__)); \ RUNTIME_CHECK(isc_condition_wait((cvp), (lp)) == ISC_R_SUCCESS); \ - ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %p %s %d\n", \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_WAITED, "WAITED"), \ + ISC_UTIL_TRACE(fprintf(stderr, "WAITED %p LOCKED %p %s %d\n", \ (cvp), \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_LOCKED, "LOCKED"), \ (lp), __FILE__, __LINE__)); \ } while (/*CONSTCOND*/0) @@ -152,20 +133,14 @@ isc_condition_waituntil((cvp), (lp), (tp)) #define RWLOCK(lp, t) do { \ - ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_RWLOCK, "RWLOCK"), \ + ISC_UTIL_TRACE(fprintf(stderr, "RWLOCK %p, %d %s %d\n", \ (lp), (t), __FILE__, __LINE__)); \ RUNTIME_CHECK(isc_rwlock_lock((lp), (t)) == ISC_R_SUCCESS); \ - ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_RWLOCKED, "RWLOCKED"), \ + ISC_UTIL_TRACE(fprintf(stderr, "RWLOCKED %p, %d %s %d\n", \ (lp), (t), __FILE__, __LINE__)); \ } while (/*CONSTCOND*/0) #define RWUNLOCK(lp, t) do { \ - ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \ - isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \ - ISC_MSG_RWUNLOCK, "RWUNLOCK"), \ + ISC_UTIL_TRACE(fprintf(stderr, "RWUNLOCK %p, %d %s %d\n", \ (lp), (t), __FILE__, __LINE__)); \ RUNTIME_CHECK(isc_rwlock_unlock((lp), (t)) == ISC_R_SUCCESS); \ } while (/*CONSTCOND*/0) @@ -208,6 +183,11 @@ #define __has_feature(x) 0 #endif +/* GCC defines __SANITIZE_ADDRESS__, so reuse the macro for clang */ +#if __has_feature(address_sanitizer) +#define __SANITIZE_ADDRESS__ 1 +#endif + #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR >= 6) #define STATIC_ASSERT(cond, msg) _Static_assert(cond, msg) #elif __has_feature(c_static_assert) diff --git a/external/mpl/bind/dist/lib/isc/include/pk11/result.h b/external/mpl/bind/dist/lib/isc/include/pk11/result.h index 0bc4cbc99c7..59bb0bbf6d2 100644 --- a/external/mpl/bind/dist/lib/isc/include/pk11/result.h +++ b/external/mpl/bind/dist/lib/isc/include/pk11/result.h @@ -1,4 +1,4 @@ -/* $NetBSD: result.h,v 1.2 2018/08/12 13:02:38 christos Exp $ */ +/* $NetBSD: result.h,v 1.3 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -37,11 +37,6 @@ ISC_LANG_BEGINDECLS -LIBISC_EXTERNAL_DATA extern isc_msgcat_t *pk11_msgcat; - -void -pk11_initmsgcat(void); - const char * pk11_result_totext(isc_result_t); diff --git a/external/mpl/bind/dist/lib/isc/lex.c b/external/mpl/bind/dist/lib/isc/lex.c index d82cb4c8c71..e59e87cb5b0 100644 --- a/external/mpl/bind/dist/lib/isc/lex.c +++ b/external/mpl/bind/dist/lib/isc/lex.c @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: lex.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -26,7 +26,6 @@ #include <isc/file.h> #include <isc/lex.h> #include <isc/mem.h> -#include <isc/msgs.h> #include <isc/parseint.h> #include <isc/print.h> #include <isc/stdio.h> @@ -856,11 +855,9 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { break; default: FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_LEX, - ISC_MSG_UNEXPECTEDSTATE, - "Unexpected state %d"), + "Unexpected state %d", state); - /* Does not return. */ + ISC_UNREACHABLE(); } } while (!done); diff --git a/external/mpl/bind/dist/lib/isc/lib.c b/external/mpl/bind/dist/lib/isc/lib.c index 2af2952ed9a..55f2e217189 100644 --- a/external/mpl/bind/dist/lib/isc/lib.c +++ b/external/mpl/bind/dist/lib/isc/lib.c @@ -1,4 +1,4 @@ -/* $NetBSD: lib.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: lib.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -16,71 +16,13 @@ #include <config.h> -#include <stdio.h> -#include <stdlib.h> - -#include <openssl/evp.h> - -#include <isc/app.h> +#include <isc/bind9.h> #include <isc/lib.h> -#include <isc/mem.h> -#include <isc/msgs.h> -#include <isc/once.h> -#include <isc/print.h> -#include <isc/socket.h> -#include <isc/task.h> -#include <isc/timer.h> -#include <isc/util.h> - -/*** - *** Globals - ***/ - -LIBISC_EXTERNAL_DATA isc_msgcat_t * isc_msgcat = NULL; - - -/*** - *** Private - ***/ - -static isc_once_t msgcat_once = ISC_ONCE_INIT; /*** *** Functions ***/ -static void -open_msgcat(void) { - isc_msgcat_open("libisc.cat", &isc_msgcat); -} - -void -isc_lib_initmsgcat(void) { - isc_result_t result; - - /*! - * Initialize the ISC library's message catalog, isc_msgcat, if it - * has not already been initialized. - */ - - result = isc_once_do(&msgcat_once, open_msgcat); - if (result != ISC_R_SUCCESS) { - /* - * Normally we'd use RUNTIME_CHECK() or FATAL_ERROR(), but - * we can't do that here, since they might call us! - * (Note that the catalog might be open anyway, so we might - * as well try to provide an internationalized message.) - */ - fprintf(stderr, "%s:%d: %s: isc_once_do() %s.\n", - __FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FATALERROR, "fatal error"), - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed")); - abort(); - } -} - void isc_lib_register(void) { isc_bind9 = false; diff --git a/external/mpl/bind/dist/lib/isc/log.c b/external/mpl/bind/dist/lib/isc/log.c index 1b2696679ae..2413cd8a683 100644 --- a/external/mpl/bind/dist/lib/isc/log.c +++ b/external/mpl/bind/dist/lib/isc/log.c @@ -1,4 +1,4 @@ -/* $NetBSD: log.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: log.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -29,7 +29,6 @@ #include <isc/log.h> #include <isc/magic.h> #include <isc/mem.h> -#include <isc/msgs.h> #include <isc/print.h> #include <isc/stat.h> #include <isc/stdio.h> @@ -232,9 +231,8 @@ greatest_version(isc_logfile_t *file, int versions, int *greatest); static void isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, isc_logmodule_t *module, int level, bool write_once, - isc_msgcat_t *msgcat, int msgset, int msg, const char *format, va_list args) - ISC_FORMAT_PRINTF(9, 0); + ISC_FORMAT_PRINTF(6, 0); /*@{*/ /*! @@ -835,7 +833,7 @@ isc_log_write(isc_log_t *lctx, isc_logcategory_t *category, va_start(args, format); isc_log_doit(lctx, category, module, level, false, - NULL, 0, 0, format, args); + format, args); va_end(args); } @@ -848,7 +846,7 @@ isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category, * Contract checking is done in isc_log_doit(). */ isc_log_doit(lctx, category, module, level, false, - NULL, 0, 0, format, args); + format, args); } void @@ -863,7 +861,7 @@ isc_log_write1(isc_log_t *lctx, isc_logcategory_t *category, va_start(args, format); isc_log_doit(lctx, category, module, level, true, - NULL, 0, 0, format, args); + format, args); va_end(args); } @@ -876,69 +874,7 @@ isc_log_vwrite1(isc_log_t *lctx, isc_logcategory_t *category, * Contract checking is done in isc_log_doit(). */ isc_log_doit(lctx, category, module, level, true, - NULL, 0, 0, format, args); -} - -void -isc_log_iwrite(isc_log_t *lctx, isc_logcategory_t *category, - isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int msg, - const char *format, ...) -{ - va_list args; - - /* - * Contract checking is done in isc_log_doit(). - */ - - va_start(args, format); - isc_log_doit(lctx, category, module, level, false, - msgcat, msgset, msg, format, args); - va_end(args); -} - -void -isc_log_ivwrite(isc_log_t *lctx, isc_logcategory_t *category, - isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int msg, - const char *format, va_list args) -{ - /* - * Contract checking is done in isc_log_doit(). - */ - isc_log_doit(lctx, category, module, level, false, - msgcat, msgset, msg, format, args); -} - -void -isc_log_iwrite1(isc_log_t *lctx, isc_logcategory_t *category, - isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int msg, - const char *format, ...) -{ - va_list args; - - /* - * Contract checking is done in isc_log_doit(). - */ - - va_start(args, format); - isc_log_doit(lctx, category, module, level, true, - msgcat, msgset, msg, format, args); - va_end(args); -} - -void -isc_log_ivwrite1(isc_log_t *lctx, isc_logcategory_t *category, - isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int msg, - const char *format, va_list args) -{ - /* - * Contract checking is done in isc_log_doit(). - */ - isc_log_doit(lctx, category, module, level, true, - msgcat, msgset, msg, format, args); + format, args); } void @@ -1579,7 +1515,6 @@ isc_log_wouldlog(isc_log_t *lctx, int level) { static void isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, isc_logmodule_t *module, int level, bool write_once, - isc_msgcat_t *msgcat, int msgset, int msg, const char *format, va_list args) { int syslog_level; @@ -1587,8 +1522,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, char local_time[64]; char iso8601z_string[64]; char iso8601l_string[64]; - char level_string[24]; - const char *iformat; + char level_string[24] = { 0 }; struct stat statbuf; bool matched = false; bool printtime, iso8601, utc, printtag, printcolon; @@ -1618,15 +1552,9 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, if (! isc_log_wouldlog(lctx, level)) return; - if (msgcat != NULL) - iformat = isc_msgcat_get(msgcat, msgset, msg, format); - else - iformat = format; - local_time[0] = '\0'; iso8601l_string[0] = '\0'; iso8601z_string[0] = '\0'; - level_string[0] = '\0'; LOCK(&lctx->lock); @@ -1707,20 +1635,17 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, if ((channel->flags & ISC_LOG_PRINTLEVEL) != 0 && level_string[0] == '\0') { - if (level < ISC_LOG_CRITICAL) + if (level < ISC_LOG_CRITICAL) { snprintf(level_string, sizeof(level_string), - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_LOG, - ISC_MSG_LEVEL, - "level %d: "), - level); - else if (level > ISC_LOG_DYNAMIC) + "level %d: ", level); + } else if (level > ISC_LOG_DYNAMIC) { snprintf(level_string, sizeof(level_string), "%s %d: ", log_level_strings[0], level); - else + } else { snprintf(level_string, sizeof(level_string), "%s: ", log_level_strings[-level]); + } } /* @@ -1728,7 +1653,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, */ if (lctx->buffer[0] == '\0') { (void)vsnprintf(lctx->buffer, sizeof(lctx->buffer), - iformat, args); + format, args); /* * Check for duplicates. diff --git a/external/mpl/bind/dist/lib/isc/mem.c b/external/mpl/bind/dist/lib/isc/mem.c index c58dabf1791..e750dec3d00 100644 --- a/external/mpl/bind/dist/lib/isc/mem.c +++ b/external/mpl/bind/dist/lib/isc/mem.c @@ -1,4 +1,4 @@ -/* $NetBSD: mem.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: mem.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -28,7 +28,6 @@ #include <isc/json.h> #include <isc/magic.h> #include <isc/mem.h> -#include <isc/msgs.h> #include <isc/mutex.h> #include <isc/once.h> #include <isc/print.h> @@ -258,12 +257,10 @@ add_trace_entry(isc__mem_t *mctx, const void *ptr, size_t size FLARG) { uint32_t hash; uint32_t idx; - if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) - fprintf(stderr, isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_ADDTRACE, - "add %p size %u " - "file %s line %u mctx %p\n"), + if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) { + fprintf(stderr, "add %p size %zu file %s line %u mctx %p\n", ptr, size, file, line, mctx); + } if (mctx->debuglist == NULL) return; @@ -295,12 +292,10 @@ delete_trace_entry(isc__mem_t *mctx, const void *ptr, size_t size, uint32_t hash; uint32_t idx; - if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) - fprintf(stderr, isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_DELTRACE, - "del %p size %u " - "file %s line %u mctx %p\n"), + if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) { + fprintf(stderr, "del %p size %zu file %s line %u mctx %p\n", ptr, size, file, line, mctx); + } if (mctx->debuglist == NULL) return; @@ -1141,35 +1136,31 @@ print_active(isc__mem_t *mctx, FILE *out) { if (mctx->debuglist != NULL) { debuglink_t *dl; unsigned int i; - const char *format; bool found; - fprintf(out, "%s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_DUMPALLOC, - "Dump of all outstanding " - "memory allocations:\n")); + fputs("Dump of all outstanding memory allocations:\n", out); found = false; - format = isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_PTRFILELINE, - "\tptr %p size %u file %s line %u\n"); for (i = 0; i < DEBUG_TABLE_COUNT; i++) { dl = ISC_LIST_HEAD(mctx->debuglist[i]); - if (dl != NULL) + if (dl != NULL) { found = true; + } while (dl != NULL) { - if (dl->ptr != NULL) - fprintf(out, format, + if (dl->ptr != NULL) { + fprintf(out, + "\tptr %p size %zu file %s line %u\n", dl->ptr, dl->size, dl->file, dl->line); + } dl = ISC_LIST_NEXT(dl, link); } } - if (!found) - fputs(isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_NONE, "\tNone.\n"), out); + if (!found) { + fputs("\tNone.\n", out); + } } } #endif @@ -1211,27 +1202,10 @@ isc_mem_stats(isc_mem_t *ctx0, FILE *out) { */ pool = ISC_LIST_HEAD(ctx->pools); if (pool != NULL) { - fprintf(out, "%s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_POOLSTATS, - "[Pool statistics]\n")); + fputs("[Pool statistics]\n", out); fprintf(out, "%15s %10s %10s %10s %10s %10s %10s %10s %1s\n", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_POOLNAME, "name"), - isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_POOLSIZE, "size"), - isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_POOLMAXALLOC, "maxalloc"), - isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_POOLALLOCATED, "allocated"), - isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_POOLFREECOUNT, "freecount"), - isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_POOLFREEMAX, "freemax"), - isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_POOLFILLCOUNT, "fillcount"), - isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM, - ISC_MSG_POOLGETS, "gets"), - "L"); + "name", "size", "maxalloc", "allocated", "freecount", + "freemax", "fillcount", "gets", "L"); } while (pool != NULL) { fprintf(out, "%15s %10lu %10u %10u %10u %10u %10u %10u %s\n", diff --git a/external/mpl/bind/dist/lib/isc/netaddr.c b/external/mpl/bind/dist/lib/isc/netaddr.c index d3d0aabe4c0..9216927a654 100644 --- a/external/mpl/bind/dist/lib/isc/netaddr.c +++ b/external/mpl/bind/dist/lib/isc/netaddr.c @@ -1,4 +1,4 @@ -/* $NetBSD: netaddr.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: netaddr.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -21,7 +21,6 @@ #include <inttypes.h> #include <isc/buffer.h> -#include <isc/msgs.h> #include <isc/net.h> #include <isc/netaddr.h> #include <isc/print.h> @@ -198,9 +197,7 @@ isc_netaddr_format(const isc_netaddr_t *na, char *array, unsigned int size) { if (result != ISC_R_SUCCESS) { snprintf(array, size, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_NETADDR, - ISC_MSG_UNKNOWNADDR, - "<unknown address, family %u>"), + "<unknown address, family %u>", na->family); array[size - 1] = '\0'; } diff --git a/external/mpl/bind/dist/lib/isc/nls/Makefile.in b/external/mpl/bind/dist/lib/isc/nls/Makefile.in deleted file mode 100644 index 704deadbea5..00000000000 --- a/external/mpl/bind/dist/lib/isc/nls/Makefile.in +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# See the COPYRIGHT file distributed with this work for additional -# information regarding copyright ownership. - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -CINCLUDES = -I../unix/include \ - -I${srcdir}/../unix/include \ - -I../include \ - -I${srcdir}/../include - -CDEFINES = -CWARNINGS = - -OBJS = msgcat.@O@ - -SRCS = msgcat.c - -SUBDIRS = -TARGETS = ${OBJS} - -@BIND9_MAKE_RULES@ diff --git a/external/mpl/bind/dist/lib/isc/nls/msgcat.c b/external/mpl/bind/dist/lib/isc/nls/msgcat.c deleted file mode 100644 index ebfdca259a9..00000000000 --- a/external/mpl/bind/dist/lib/isc/nls/msgcat.c +++ /dev/null @@ -1,123 +0,0 @@ -/* $NetBSD: msgcat.c,v 1.2 2018/08/12 13:02:38 christos Exp $ */ - -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - - -/*! \file msgcat.c */ - -#include <config.h> - -#include <stddef.h> -#include <stdlib.h> - -#include <isc/magic.h> -#include <isc/msgcat.h> -#include <isc/util.h> - -#ifdef HAVE_CATGETS -#include <nl_types.h> /* Required for nl_catd. */ -#endif - -/* - * Implementation Notes: - * - * We use malloc() and free() instead of isc_mem_get() and isc_mem_put() - * because we don't want to require a memory context to be specified - * in order to use a message catalog. - */ - -struct isc_msgcat { - unsigned int magic; -#ifdef HAVE_CATGETS - nl_catd catalog; -#endif -}; - -#define MSGCAT_MAGIC ISC_MAGIC('M', 'C', 'a', 't') -#define VALID_MSGCAT(m) ISC_MAGIC_VALID(m, MSGCAT_MAGIC) - -void -isc_msgcat_open(const char *name, isc_msgcat_t **msgcatp) { - isc_msgcat_t *msgcat; - - /* - * Open a message catalog. - */ - - REQUIRE(name != NULL); - REQUIRE(msgcatp != NULL && *msgcatp == NULL); - - msgcat = malloc(sizeof(*msgcat)); - if (msgcat == NULL) { - *msgcatp = NULL; - return; - } - -#ifdef HAVE_CATGETS - /* - * We don't check if catopen() fails because we don't care. - * If it does fail, then when we call catgets(), it will use - * the default string. - */ - msgcat->catalog = catopen(name, 0); -#endif - msgcat->magic = MSGCAT_MAGIC; - - *msgcatp = msgcat; -} - -void -isc_msgcat_close(isc_msgcat_t **msgcatp) { - isc_msgcat_t *msgcat; - - /* - * Close a message catalog. - */ - - REQUIRE(msgcatp != NULL); - msgcat = *msgcatp; - REQUIRE(VALID_MSGCAT(msgcat) || msgcat == NULL); - - if (msgcat != NULL) { -#ifdef HAVE_CATGETS - if (msgcat->catalog != (nl_catd)(-1)) - (void)catclose(msgcat->catalog); -#endif - msgcat->magic = 0; - free(msgcat); - } - - *msgcatp = NULL; -} - -const char * -isc_msgcat_get(isc_msgcat_t *msgcat, int set, int message, - const char *default_text) -{ - /* - * Get message 'message' from message set 'set' in 'msgcat'. If it - * is not available, use 'default'. - */ - - REQUIRE(VALID_MSGCAT(msgcat) || msgcat == NULL); - REQUIRE(set > 0); - REQUIRE(message > 0); - REQUIRE(default_text != NULL); - -#ifdef HAVE_CATGETS - if (msgcat == NULL) - return (default_text); - return (catgets(msgcat->catalog, set, message, default_text)); -#else - return (default_text); -#endif -} diff --git a/external/mpl/bind/dist/lib/isc/pk11_result.c b/external/mpl/bind/dist/lib/isc/pk11_result.c index 4983bcb3523..b210a0a8f8a 100644 --- a/external/mpl/bind/dist/lib/isc/pk11_result.c +++ b/external/mpl/bind/dist/lib/isc/pk11_result.c @@ -1,4 +1,4 @@ -/* $NetBSD: pk11_result.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: pk11_result.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -15,15 +15,10 @@ #include <stddef.h> #include <isc/once.h> -#include <isc/msgcat.h> #include <isc/util.h> #include <pk11/result.h> -LIBISC_EXTERNAL_DATA isc_msgcat_t * pk11_msgcat = NULL; - -static isc_once_t msgcat_once = ISC_ONCE_INIT; - static const char *text[PK11_R_NRESULTS] = { "PKCS#11 initialization failed", /*%< 0 */ "no PKCS#11 provider", /*%< 1 */ @@ -45,35 +40,18 @@ static const char *ids[PK11_R_NRESULTS] = { static isc_once_t once = ISC_ONCE_INIT; static void -open_msgcat(void) { - isc_msgcat_open("libpk11.cat", &pk11_msgcat); -} - -void -pk11_initmsgcat(void) { - - /* - * Initialize the PKCS#11 support's message catalog, - * pk11_msgcat, if it has not already been initialized. - */ - - RUNTIME_CHECK(isc_once_do(&msgcat_once, open_msgcat) == ISC_R_SUCCESS); -} - -static void initialize_action(void) { isc_result_t result; result = isc_result_register(ISC_RESULTCLASS_PK11, PK11_R_NRESULTS, - text, pk11_msgcat, PK11_RESULT_RESULTSET); + text, PK11_RESULT_RESULTSET); if (result != ISC_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_result_register() failed: %u", result); } result = isc_result_registerids(ISC_RESULTCLASS_PK11, PK11_R_NRESULTS, - ids, pk11_msgcat, - PK11_RESULT_RESULTSET); + ids, PK11_RESULT_RESULTSET); if (result != ISC_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_result_registerids() failed: %u", result); @@ -82,7 +60,6 @@ initialize_action(void) { static void initialize(void) { - pk11_initmsgcat(); RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS); } diff --git a/external/mpl/bind/dist/lib/isc/pthreads/condition.c b/external/mpl/bind/dist/lib/isc/pthreads/condition.c index e3ed39c7626..6c2b3ec3e25 100644 --- a/external/mpl/bind/dist/lib/isc/pthreads/condition.c +++ b/external/mpl/bind/dist/lib/isc/pthreads/condition.c @@ -1,4 +1,4 @@ -/* $NetBSD: condition.c,v 1.3 2019/01/09 16:55:16 christos Exp $ */ +/* $NetBSD: condition.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -19,7 +19,6 @@ #include <errno.h> #include <isc/condition.h> -#include <isc/msgs.h> #include <isc/strerr.h> #include <isc/string.h> #include <isc/time.h> @@ -68,9 +67,7 @@ isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t *t) { strerror_r(presult, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "pthread_cond_timedwait() %s %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_RETURNED, "returned"), + "pthread_cond_timedwait() returned %s", strbuf); return (ISC_R_UNEXPECTED); } diff --git a/external/mpl/bind/dist/lib/isc/quota.c b/external/mpl/bind/dist/lib/isc/quota.c index f57f16d05d9..c6bcb1b7af6 100644 --- a/external/mpl/bind/dist/lib/isc/quota.c +++ b/external/mpl/bind/dist/lib/isc/quota.c @@ -1,4 +1,4 @@ -/* $NetBSD: quota.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: quota.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -18,62 +18,73 @@ #include <stddef.h> +#include <isc/atomic.h> #include <isc/quota.h> #include <isc/util.h> + void -isc_quota_init(isc_quota_t *quota, int max) { - quota->max = max; - quota->used = 0; - quota->soft = 0; - isc_mutex_init("a->lock); +isc_quota_init(isc_quota_t *quota, unsigned int max) { + atomic_store("a->max, max); + atomic_store("a->used, 0); + atomic_store("a->soft, 0); } void isc_quota_destroy(isc_quota_t *quota) { - INSIST(quota->used == 0); - quota->max = 0; - quota->used = 0; - quota->soft = 0; - isc_mutex_destroy("a->lock); + INSIST(atomic_load("a->used) == 0); + atomic_store("a->max, 0); + atomic_store("a->used, 0); + atomic_store("a->soft, 0); } void -isc_quota_soft(isc_quota_t *quota, int soft) { - LOCK("a->lock); - quota->soft = soft; - UNLOCK("a->lock); +isc_quota_soft(isc_quota_t *quota, unsigned int soft) { + atomic_store("a->soft, soft); } void -isc_quota_max(isc_quota_t *quota, int max) { - LOCK("a->lock); - quota->max = max; - UNLOCK("a->lock); +isc_quota_max(isc_quota_t *quota, unsigned int max) { + atomic_store("a->max, max); +} + +unsigned int +isc_quota_getmax(isc_quota_t *quota) { + return (atomic_load_relaxed("a->max)); +} + +unsigned int +isc_quota_getsoft(isc_quota_t *quota) { + return (atomic_load_relaxed("a->soft)); +} + +unsigned int +isc_quota_getused(isc_quota_t *quota) { + return (atomic_load_relaxed("a->used)); } isc_result_t isc_quota_reserve(isc_quota_t *quota) { isc_result_t result; - LOCK("a->lock); - if (quota->max == 0 || quota->used < quota->max) { - if (quota->soft == 0 || quota->used < quota->soft) + uint32_t max = atomic_load("a->max); + uint32_t soft = atomic_load("a->soft); + uint32_t used = atomic_fetch_add("a->used, 1); + if (max == 0 || used < max) { + if (soft == 0 || used < soft) { result = ISC_R_SUCCESS; - else + } else { result = ISC_R_SOFTQUOTA; - quota->used++; - } else + } + } else { + INSIST(atomic_fetch_sub("a->used, 1) > 0); result = ISC_R_QUOTA; - UNLOCK("a->lock); + } return (result); } void isc_quota_release(isc_quota_t *quota) { - LOCK("a->lock); - INSIST(quota->used > 0); - quota->used--; - UNLOCK("a->lock); + INSIST(atomic_fetch_sub("a->used, 1) > 0); } isc_result_t diff --git a/external/mpl/bind/dist/lib/isc/result.c b/external/mpl/bind/dist/lib/isc/result.c index b1750878c2a..3352604b895 100644 --- a/external/mpl/bind/dist/lib/isc/result.c +++ b/external/mpl/bind/dist/lib/isc/result.c @@ -1,4 +1,4 @@ -/* $NetBSD: result.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: result.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -19,7 +19,6 @@ #include <stdlib.h> #include <isc/lib.h> -#include <isc/msgs.h> #include <isc/mutex.h> #include <isc/once.h> #include <isc/resultclass.h> @@ -29,7 +28,6 @@ typedef struct resulttable { unsigned int base; unsigned int last; const char ** text; - isc_msgcat_t * msgcat; int set; ISC_LINK(struct resulttable) link; } resulttable; @@ -185,7 +183,7 @@ static isc_mutex_t lock; static isc_result_t register_table(resulttable_list_t *tables, unsigned int base, unsigned int nresults, const char **text, - isc_msgcat_t *msgcat, int set) + int set) { resulttable *table; @@ -203,7 +201,6 @@ register_table(resulttable_list_t *tables, unsigned int base, table->base = base; table->last = base + nresults - 1; table->text = text; - table->msgcat = msgcat; table->set = set; ISC_LINK_INIT(table, link); @@ -226,35 +223,32 @@ initialize_action(void) { result = register_table(&description_tables, ISC_RESULTCLASS_ISC, ISC_R_NRESULTS, - description, isc_msgcat, ISC_RESULT_RESULTSET); - if (result != ISC_R_SUCCESS) + description, ISC_RESULT_RESULTSET); + if (result != ISC_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, - "register_table() %s: %u", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), + "register_table() failed: %u", result); + } result = register_table(&identifier_tables, ISC_RESULTCLASS_ISC, ISC_R_NRESULTS, - identifier, isc_msgcat, ISC_RESULT_RESULTSET); - if (result != ISC_R_SUCCESS) + identifier, ISC_RESULT_RESULTSET); + if (result != ISC_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, - "register_table() %s: %u", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), + "register_table() failed: %u", result); + } } static void initialize(void) { - isc_lib_initmsgcat(); RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS); } static const char * isc_result_tomany_helper(resulttable_list_t *tables, isc_result_t result) { resulttable *table; - const char *text, *default_text; + const char *text; int index; initialize(); @@ -267,20 +261,13 @@ isc_result_tomany_helper(resulttable_list_t *tables, isc_result_t result) { table = ISC_LIST_NEXT(table, link)) { if (result >= table->base && result <= table->last) { index = (int)(result - table->base); - default_text = table->text[index]; - /* - * Note: we use 'index + 1' as the message number - * instead of index because isc_msgcat_get() requires - * the message number to be > 0. - */ - text = isc_msgcat_get(table->msgcat, table->set, - index + 1, default_text); + text = table->text[index]; break; } } - if (text == NULL) - text = isc_msgcat_get(isc_msgcat, ISC_RESULT_UNAVAILABLESET, - 1, "(result code text not available)"); + if (text == NULL) { + text = "(result code text not available)"; + } UNLOCK(&lock); @@ -299,20 +286,20 @@ isc_result_toid(isc_result_t result) { isc_result_t isc_result_register(unsigned int base, unsigned int nresults, - const char **text, isc_msgcat_t *msgcat, int set) + const char **text, int set) { initialize(); return (register_table(&description_tables, base, nresults, text, - msgcat, set)); + set)); } isc_result_t isc_result_registerids(unsigned int base, unsigned int nresults, - const char **ids, isc_msgcat_t *msgcat, int set) + const char **ids, int set) { initialize(); return (register_table(&identifier_tables, base, nresults, ids, - msgcat, set)); + set)); } diff --git a/external/mpl/bind/dist/lib/isc/rwlock.c b/external/mpl/bind/dist/lib/isc/rwlock.c index 114bfd83bb4..8106c463a44 100644 --- a/external/mpl/bind/dist/lib/isc/rwlock.c +++ b/external/mpl/bind/dist/lib/isc/rwlock.c @@ -1,4 +1,4 @@ -/* $NetBSD: rwlock.c,v 1.5 2019/01/11 02:44:49 christos Exp $ */ +/* $NetBSD: rwlock.c,v 1.6 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -20,9 +20,12 @@ #include <stddef.h> #include <inttypes.h> +#if defined(sun) && (defined(__sparc) || defined(__sparc__)) +#include <synch.h> /* for smt_pause(3c) */ +#endif + #include <isc/atomic.h> #include <isc/magic.h> -#include <isc/msgs.h> #include <isc/platform.h> #include <isc/print.h> #include <isc/rwlock.h> @@ -58,6 +61,8 @@ # define isc_rwlock_pause() __asm__ __volatile__ ("hint @pause") #elif defined(__arm__) && defined(_ARM_ARCH_6) # define isc_rwlock_pause() __asm__ __volatile__ ("yield") +#elif defined(sun) && (defined(__sparc) || defined(__sparc__)) +# define isc_rwlock_pause() smt_pause() // Disable pause, only works on v9 #elif (defined(__sparc) || defined(__sparc__)) && defined(notdef) # define isc_rwlock_pause() __asm__ __volatile__ ("pause") @@ -79,18 +84,12 @@ isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type); static void print_lock(const char *operation, isc_rwlock_t *rwl, isc_rwlocktype_t type) { fprintf(stderr, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_RWLOCK, - ISC_MSG_PRINTLOCK2, - "rwlock %p thread %lu %s(%s): " - "write_requests=%u, write_completions=%u, " - "cnt_and_flag=0x%x, readers_waiting=%u, " - "write_granted=%u, write_quota=%u\n"), + "rwlock %p thread %lu %s(%s): " + "write_requests=%u, write_completions=%u, " + "cnt_and_flag=0x%x, readers_waiting=%u, " + "write_granted=%u, write_quota=%u\n", rwl, isc_thread_self(), operation, - (type == isc_rwlocktype_read ? - isc_msgcat_get(isc_msgcat, ISC_MSGSET_RWLOCK, - ISC_MSG_READ, "read") : - isc_msgcat_get(isc_msgcat, ISC_MSGSET_RWLOCK, - ISC_MSG_WRITE, "write")), + (type == isc_rwlocktype_read ? "read" : "write"), atomic_load_explicit(&rwl->write_requests, memory_order_relaxed), atomic_load_explicit(&rwl->write_completions, memory_order_relaxed), atomic_load_explicit(&rwl->cnt_and_flag, memory_order_relaxed), @@ -221,8 +220,7 @@ isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) { REQUIRE(VALID_RWLOCK(rwl)); #ifdef ISC_RWLOCK_TRACE - print_lock(isc_msgcat_get(isc_msgcat, ISC_MSGSET_RWLOCK, - ISC_MSG_PRELOCK, "prelock"), rwl, type); + print_lock("prelock", rwl, type); #endif if (type == isc_rwlocktype_read) { @@ -328,8 +326,7 @@ isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) { } #ifdef ISC_RWLOCK_TRACE - print_lock(isc_msgcat_get(isc_msgcat, ISC_MSGSET_RWLOCK, - ISC_MSG_POSTLOCK, "postlock"), rwl, type); + print_lock("postlock", rwl, type); #endif return (ISC_R_SUCCESS); @@ -364,8 +361,7 @@ isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type) { REQUIRE(VALID_RWLOCK(rwl)); #ifdef ISC_RWLOCK_TRACE - print_lock(isc_msgcat_get(isc_msgcat, ISC_MSGSET_RWLOCK, - ISC_MSG_PRELOCK, "prelock"), rwl, type); + print_lock("prelock", rwl, type); #endif if (type == isc_rwlocktype_read) { @@ -421,8 +417,7 @@ isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type) { } #ifdef ISC_RWLOCK_TRACE - print_lock(isc_msgcat_get(isc_msgcat, ISC_MSGSET_RWLOCK, - ISC_MSG_POSTLOCK, "postlock"), rwl, type); + print_lock("postlock", rwl, type); #endif return (ISC_R_SUCCESS); @@ -496,8 +491,7 @@ isc_rwlock_unlock(isc_rwlock_t *rwl, isc_rwlocktype_t type) { REQUIRE(VALID_RWLOCK(rwl)); #ifdef ISC_RWLOCK_TRACE - print_lock(isc_msgcat_get(isc_msgcat, ISC_MSGSET_RWLOCK, - ISC_MSG_PREUNLOCK, "preunlock"), rwl, type); + print_lock("preunlock", rwl, type); #endif if (type == isc_rwlocktype_read) { @@ -558,8 +552,7 @@ isc_rwlock_unlock(isc_rwlock_t *rwl, isc_rwlocktype_t type) { } #ifdef ISC_RWLOCK_TRACE - print_lock(isc_msgcat_get(isc_msgcat, ISC_MSGSET_RWLOCK, - ISC_MSG_POSTUNLOCK, "postunlock"), + print_lock("postunlock", rwl, type); #endif diff --git a/external/mpl/bind/dist/lib/isc/sockaddr.c b/external/mpl/bind/dist/lib/isc/sockaddr.c index 902b517e753..39f640117b3 100644 --- a/external/mpl/bind/dist/lib/isc/sockaddr.c +++ b/external/mpl/bind/dist/lib/isc/sockaddr.c @@ -1,4 +1,4 @@ -/* $NetBSD: sockaddr.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: sockaddr.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -21,7 +21,6 @@ #include <isc/buffer.h> #include <isc/hash.h> -#include <isc/msgs.h> #include <isc/netaddr.h> #include <isc/print.h> #include <isc/region.h> @@ -186,9 +185,7 @@ isc_sockaddr_format(const isc_sockaddr_t *sa, char *array, unsigned int size) { * The message is the same as in netaddr.c. */ snprintf(array, size, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_NETADDR, - ISC_MSG_UNKNOWNADDR, - "<unknown address, family %u>"), + "<unknown address, family %u>", sa->type.sa.sa_family); array[size - 1] = '\0'; } @@ -222,11 +219,8 @@ isc_sockaddr_hash(const isc_sockaddr_t *sockaddr, bool address_only) { break; default: UNEXPECTED_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_SOCKADDR, - ISC_MSG_UNKNOWNFAMILY, - "unknown address family: %d"), - (int)sockaddr->type.sa.sa_family); + "unknown address family: %d", + (int)sockaddr->type.sa.sa_family); s = (const unsigned char *)&sockaddr->type; length = sockaddr->length; p = 0; @@ -334,9 +328,7 @@ isc_sockaddr_pf(const isc_sockaddr_t *sockaddr) { return (PF_INET6); default: FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKADDR, - ISC_MSG_UNKNOWNFAMILY, - "unknown address family: %d"), + "unknown address family: %d", (int)sockaddr->type.sa.sa_family); } #endif @@ -378,9 +370,7 @@ isc_sockaddr_setport(isc_sockaddr_t *sockaddr, in_port_t port) { break; default: FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKADDR, - ISC_MSG_UNKNOWNFAMILY, - "unknown address family: %d"), + "unknown address family: %d", (int)sockaddr->type.sa.sa_family); } } @@ -398,9 +388,7 @@ isc_sockaddr_getport(const isc_sockaddr_t *sockaddr) { break; default: FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKADDR, - ISC_MSG_UNKNOWNFAMILY, - "unknown address family: %d"), + "unknown address family: %d", (int)sockaddr->type.sa.sa_family); } diff --git a/external/mpl/bind/dist/lib/isc/task.c b/external/mpl/bind/dist/lib/isc/task.c index 5f514aecab4..4e3b5155c50 100644 --- a/external/mpl/bind/dist/lib/isc/task.c +++ b/external/mpl/bind/dist/lib/isc/task.c @@ -1,4 +1,4 @@ -/* $NetBSD: task.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: task.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -29,7 +29,6 @@ #include <isc/json.h> #include <isc/magic.h> #include <isc/mem.h> -#include <isc/msgs.h> #include <isc/once.h> #include <isc/platform.h> #include <isc/print.h> @@ -150,15 +149,16 @@ struct isc__taskmgr { atomic_uint_fast32_t tasks_running; atomic_uint_fast32_t tasks_ready; atomic_uint_fast32_t curq; + atomic_uint_fast32_t tasks_count; isc__taskqueue_t *queues; /* Locked by task manager lock. */ unsigned int default_quantum; LIST(isc__task_t) tasks; - isc_taskmgrmode_t mode; - bool pause_requested; - bool exclusive_requested; - bool exiting; + atomic_uint_fast32_t mode; + atomic_bool pause_req; + atomic_bool exclusive_req; + atomic_bool exiting; /* Locked by halt_lock */ unsigned int halted; @@ -179,7 +179,8 @@ isc__taskmgr_resume(isc_taskmgr_t *manager0); #define DEFAULT_DEFAULT_QUANTUM 25 -#define FINISHED(m) ((m)->exiting && EMPTY((m)->tasks)) +#define FINISHED(m) (atomic_load_relaxed(&((m)->exiting)) == true && \ + atomic_load(&(m)->tasks_count) == 0) /*% * The following are intended for internal use (indicated by "isc__" @@ -231,6 +232,7 @@ task_finished(isc__task_t *task) { LOCK(&manager->lock); UNLINK(manager->tasks, task, link); + atomic_fetch_sub(&manager->tasks_count, 1); UNLOCK(&manager->lock); if (FINISHED(manager)) { /* @@ -306,8 +308,9 @@ isc_task_create_bound(isc_taskmgr_t *manager0, unsigned int quantum, exiting = false; LOCK(&manager->lock); - if (!manager->exiting) { + if (!atomic_load_relaxed(&manager->exiting)) { APPEND(manager->tasks, task, link); + atomic_fetch_add(&manager->tasks_count, 1); } else { exiting = true; } @@ -358,8 +361,7 @@ task_shutdown(isc__task_t *task) { XTRACE("task_shutdown"); if (! TASK_SHUTTINGDOWN(task)) { - XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_SHUTTINGDOWN, "shutting down")); + XTRACE("shutting down"); task->flags |= TASK_F_SHUTTINGDOWN; if (task->state == task_state_idle) { INSIST(EMPTY(task->events)); @@ -401,7 +403,8 @@ task_ready(isc__task_t *task) { XTRACE("task_ready"); LOCK(&manager->queues[task->threadid].lock); push_readyq(manager, task, task->threadid); - if (manager->mode == isc_taskmgrmode_normal || has_privilege) { + if (atomic_load(&manager->mode) == isc_taskmgrmode_normal || + has_privilege) { SIGNAL(&manager->queues[task->threadid].work_available); } UNLOCK(&manager->queues[task->threadid].lock); @@ -516,6 +519,13 @@ isc_task_sendto(isc_task_t *task0, isc_event_t **eventp, int c) { REQUIRE(VALID_TASK(task)); XTRACE("isc_task_send"); + + /* + * We're trying hard to hold locks for as short a time as possible. + * We're also trying to hold as few locks as possible. This is why + * some processing is deferred until after the lock is released. + */ + LOCK(&task->lock); /* If task is bound ignore provided cpu. */ if (task->bound) { c = task->threadid; @@ -524,13 +534,6 @@ isc_task_sendto(isc_task_t *task0, isc_event_t **eventp, int c) { memory_order_relaxed); } c %= task->manager->workers; - - /* - * We're trying hard to hold locks for as short a time as possible. - * We're also trying to hold as few locks as possible. This is why - * some processing is deferred until after the lock is released. - */ - LOCK(&task->lock); was_idle = task_send(task, eventp, c); UNLOCK(&task->lock); @@ -569,6 +572,7 @@ isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) { REQUIRE(VALID_TASK(task)); XTRACE("isc_task_sendanddetach"); + LOCK(&task->lock); if (task->bound) { c = task->threadid; } else if (c < 0) { @@ -576,8 +580,6 @@ isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) { memory_order_relaxed); } c %= task->manager->workers; - - LOCK(&task->lock); idle1 = task_send(task, eventp, c); idle2 = task_detach(task); UNLOCK(&task->lock); @@ -906,11 +908,11 @@ static inline bool empty_readyq(isc__taskmgr_t *manager, int c) { isc__tasklist_t queue; - if (manager->mode == isc_taskmgrmode_normal) + if (atomic_load_relaxed(&manager->mode) == isc_taskmgrmode_normal) { queue = manager->queues[c].ready_tasks; - else + } else { queue = manager->queues[c].ready_priority_tasks; - + } return (EMPTY(queue)); } @@ -926,7 +928,7 @@ static inline isc__task_t * pop_readyq(isc__taskmgr_t *manager, int c) { isc__task_t *task; - if (manager->mode == isc_taskmgrmode_normal) { + if (atomic_load_relaxed(&manager->mode) == isc_taskmgrmode_normal) { task = HEAD(manager->queues[c].ready_tasks); } else { task = HEAD(manager->queues[c].ready_priority_tasks); @@ -1033,42 +1035,33 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) { * until it's been released. */ while ((empty_readyq(manager, threadid) && - !manager->pause_requested && - !manager->exclusive_requested) && + !atomic_load_relaxed(&manager->pause_req) && + !atomic_load_relaxed(&manager->exclusive_req)) && !FINISHED(manager)) { - XTHREADTRACE(isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_WAIT, "wait")); - XTHREADTRACE(isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_WAIT, - manager->pause_requested - ? "paused" : "notpaused")); - XTHREADTRACE(isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_WAIT, - manager->exclusive_requested - ? "excreq" : "notexcreq")); + XTHREADTRACE("wait"); + XTHREADTRACE(atomic_load_relaxed(&manager->pause_req) + ? "paused" + : "notpaused"); + XTHREADTRACE(atomic_load_relaxed(&manager->exclusive_req) + ? "excreq" + : "notexcreq"); WAIT(&manager->queues[threadid].work_available, &manager->queues[threadid].lock); - XTHREADTRACE(isc_msgcat_get(isc_msgcat, - ISC_MSGSET_TASK, - ISC_MSG_AWAKE, "awake")); + XTHREADTRACE("awake"); } - XTHREADTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TASK, - ISC_MSG_WORKING, "working")); + XTHREADTRACE("working"); - if (manager->pause_requested || manager->exclusive_requested) { + if (atomic_load_relaxed(&manager->pause_req) || + atomic_load_relaxed(&manager->exclusive_req)) { UNLOCK(&manager->queues[threadid].lock); - XTHREADTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TASK, - ISC_MSG_WORKING, "halting")); + XTHREADTRACE("halting"); /* * Switching to exclusive mode is done as a * 2-phase-lock, checking if we have to switch is - * done without any locks on pause_requested and - * exclusive_requested to save time - the worst + * done without any locks on pause_req and + * exclusive_req to save time - the worst * thing that can happen is that we'll launch one * task more and exclusive task will be postponed a * bit. @@ -1080,8 +1073,8 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) { LOCK(&manager->halt_lock); manager->halted++; BROADCAST(&manager->halt_cond); - while (manager->pause_requested || - manager->exclusive_requested) + while (atomic_load_relaxed(&manager->pause_req) || + atomic_load_relaxed(&manager->exclusive_req)) { WAIT(&manager->halt_cond, &manager->halt_lock); } @@ -1119,8 +1112,7 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) { LOCK(&task->lock); INSIST(task->state == task_state_ready); task->state = task_state_running; - XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_RUNNING, "running")); + XTRACE("running"); XTRACE(task->name); TIME_NOW(&task->tnow); task->now = isc_time_seconds(&task->tnow); @@ -1133,10 +1125,7 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) { /* * Execute the event action. */ - XTRACE(isc_msgcat_get(isc_msgcat, - ISC_MSGSET_TASK, - ISC_MSG_EXECUTE, - "execute action")); + XTRACE("execute action"); XTRACE(task->name); if (event->ev_action != NULL) { UNLOCK(&task->lock); @@ -1184,20 +1173,13 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) { * Nothing else to do for this task * right now. */ - XTRACE(isc_msgcat_get(isc_msgcat, - ISC_MSGSET_TASK, - ISC_MSG_EMPTY, - "empty")); + XTRACE("empty"); if (task->references == 0 && TASK_SHUTTINGDOWN(task)) { /* * The task is done. */ - XTRACE(isc_msgcat_get( - isc_msgcat, - ISC_MSGSET_TASK, - ISC_MSG_DONE, - "done")); + XTRACE("done"); finished = true; task->state = task_state_done; } else @@ -1214,10 +1196,7 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) { * dispatching at least one event, * so the minimum quantum is one. */ - XTRACE(isc_msgcat_get(isc_msgcat, - ISC_MSGSET_TASK, - ISC_MSG_QUANTUM, - "quantum")); + XTRACE("quantum"); task->state = task_state_ready; requeue = true; done = true; @@ -1288,7 +1267,8 @@ dispatch(isc__taskmgr_t *manager, unsigned int threadid) { UNLOCK(&manager->queues[i].lock); } if (empty) { - manager->mode = isc_taskmgrmode_normal; + atomic_store(&manager->mode, + isc_taskmgrmode_normal); wake_all_queues(manager); } } @@ -1314,13 +1294,11 @@ run(void *queuep) { int threadid = tq->threadid; isc_thread_setaffinity(threadid); - XTHREADTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_STARTING, "starting")); + XTHREADTRACE("starting"); dispatch(manager, threadid); - XTHREADTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_EXITING, "exiting")); + XTHREADTRACE("exiting"); #ifdef OPENSSL_LEAKS ERR_remove_state(0); @@ -1361,7 +1339,7 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers, RUNTIME_CHECK(manager != NULL); manager->common.impmagic = TASK_MANAGER_MAGIC; manager->common.magic = ISCAPI_TASKMGR_MAGIC; - manager->mode = isc_taskmgrmode_normal; + atomic_store(&manager->mode, isc_taskmgrmode_normal); manager->mctx = NULL; isc_mutex_init(&manager->lock); isc_mutex_init(&manager->excl_lock); @@ -1376,6 +1354,7 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers, } manager->default_quantum = default_quantum; INIT_LIST(manager->tasks); + atomic_store(&manager->tasks_count, 0); manager->queues = isc_mem_get(mctx, workers * sizeof(isc__taskqueue_t)); RUNTIME_CHECK(manager->queues != NULL); @@ -1385,8 +1364,8 @@ isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers, manager->exiting = false; manager->excl = NULL; manager->halted = 0; - manager->exclusive_requested = false; - manager->pause_requested = false; + atomic_store_relaxed(&manager->exclusive_req, false); + atomic_store_relaxed(&manager->pause_req, false); isc_mem_attach(mctx, &manager->mctx); @@ -1423,6 +1402,7 @@ isc_taskmgr_destroy(isc_taskmgr_t **managerp) { isc__taskmgr_t *manager; isc__task_t *task; unsigned int i; + bool exiting; /* * Destroy '*managerp'. @@ -1463,13 +1443,15 @@ isc_taskmgr_destroy(isc_taskmgr_t **managerp) { /* * Make sure we only get called once. */ - INSIST(!manager->exiting); - manager->exiting = true; + exiting = false; + + INSIST(!!atomic_compare_exchange_strong(&manager->exiting, + &exiting, true)); /* * If privileged mode was on, turn it off. */ - manager->mode = isc_taskmgrmode_normal; + atomic_store(&manager->mode, isc_taskmgrmode_normal); /* * Post shutdown event(s) to every task (if they haven't already been @@ -1511,19 +1493,13 @@ void isc_taskmgr_setprivilegedmode(isc_taskmgr_t *manager0) { isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0; - LOCK(&manager->lock); - manager->mode = isc_taskmgrmode_privileged; - UNLOCK(&manager->lock); + atomic_store(&manager->mode, isc_taskmgrmode_privileged); } isc_taskmgrmode_t isc_taskmgr_mode(isc_taskmgr_t *manager0) { isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0; - isc_taskmgrmode_t mode; - LOCK(&manager->lock); - mode = manager->mode; - UNLOCK(&manager->lock); - return (mode); + return (atomic_load(&manager->mode)); } void @@ -1531,14 +1507,15 @@ isc__taskmgr_pause(isc_taskmgr_t *manager0) { isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0; LOCK(&manager->halt_lock); - while (manager->exclusive_requested || manager->pause_requested) { + while (atomic_load_relaxed(&manager->exclusive_req) || + atomic_load_relaxed(&manager->pause_req)) { UNLOCK(&manager->halt_lock); /* This is ugly but pause is used EXCLUSIVELY in tests */ isc_thread_yield(); LOCK(&manager->halt_lock); } - manager->pause_requested = true; + atomic_store_relaxed(&manager->pause_req, true); while (manager->halted < manager->workers) { wake_all_queues(manager); WAIT(&manager->halt_cond, &manager->halt_lock); @@ -1550,8 +1527,8 @@ void isc__taskmgr_resume(isc_taskmgr_t *manager0) { isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0; LOCK(&manager->halt_lock); - if (manager->pause_requested) { - manager->pause_requested = false; + if (manager->pause_req) { + manager->pause_req = false; while (manager->halted > 0) { BROADCAST(&manager->halt_cond); WAIT(&manager->halt_cond, &manager->halt_lock); @@ -1603,16 +1580,19 @@ isc_task_beginexclusive(isc_task_t *task0) { LOCK(&manager->excl_lock); REQUIRE(task == task->manager->excl || - (task->manager->exiting && task->manager->excl == NULL)); + (atomic_load_relaxed(&task->manager->exiting) && + task->manager->excl == NULL)); UNLOCK(&manager->excl_lock); - if (manager->exclusive_requested || manager->pause_requested) { + if (atomic_load_relaxed(&manager->exclusive_req) || + atomic_load_relaxed(&manager->pause_req)) { return (ISC_R_LOCKBUSY); } LOCK(&manager->halt_lock); - INSIST(!manager->exclusive_requested && !manager->pause_requested); - manager->exclusive_requested = true; + INSIST(!atomic_load_relaxed(&manager->exclusive_req) && + !atomic_load_relaxed(&manager->pause_req)); + atomic_store_relaxed(&manager->exclusive_req, true); while (manager->halted + 1 < manager->workers) { wake_all_queues(manager); WAIT(&manager->halt_cond, &manager->halt_lock); @@ -1629,8 +1609,8 @@ isc_task_endexclusive(isc_task_t *task0) { REQUIRE(VALID_TASK(task)); REQUIRE(task->state == task_state_running); LOCK(&manager->halt_lock); - REQUIRE(manager->exclusive_requested); - manager->exclusive_requested = false; + REQUIRE(atomic_load_relaxed(&manager->exclusive_req) == true); + atomic_store_relaxed(&manager->exclusive_req, false); while (manager->halted > 0) { BROADCAST(&manager->halt_cond); WAIT(&manager->halt_cond, &manager->halt_lock); @@ -1715,14 +1695,19 @@ isc_taskmgr_renderxml(isc_taskmgr_t *mgr0, xmlTextWriterPtr writer) { mgr->default_quantum)); TRY0(xmlTextWriterEndElement(writer)); /* default-quantum */ + TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks-count")); + TRY0(xmlTextWriterWriteFormatString(writer, "%d", + (int) atomic_load_relaxed(&mgr->tasks_count))); + TRY0(xmlTextWriterEndElement(writer)); /* tasks-count */ + TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks-running")); TRY0(xmlTextWriterWriteFormatString(writer, "%d", - (int) mgr->tasks_running)); + (int) atomic_load_relaxed(&mgr->tasks_running))); TRY0(xmlTextWriterEndElement(writer)); /* tasks-running */ TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks-ready")); TRY0(xmlTextWriterWriteFormatString(writer, "%d", - (int) mgr->tasks_ready)); + (int) atomic_load_relaxed(&mgr->tasks_ready))); TRY0(xmlTextWriterEndElement(writer)); /* tasks-ready */ TRY0(xmlTextWriterEndElement(writer)); /* thread-model */ @@ -1815,11 +1800,15 @@ isc_taskmgr_renderjson(isc_taskmgr_t *mgr0, json_object *tasks) { CHECKMEM(obj); json_object_object_add(tasks, "default-quantum", obj); - obj = json_object_new_int(mgr->tasks_running); + obj = json_object_new_int(atomic_load_relaxed(&mgr->tasks_count)); + CHECKMEM(obj); + json_object_object_add(tasks, "tasks-count", obj); + + obj = json_object_new_int(atomic_load_relaxed(&mgr->tasks_running)); CHECKMEM(obj); json_object_object_add(tasks, "tasks-running", obj); - obj = json_object_new_int(mgr->tasks_ready); + obj = json_object_new_int(atomic_load_relaxed(&mgr->tasks_ready)); CHECKMEM(obj); json_object_object_add(tasks, "tasks-ready", obj); diff --git a/external/mpl/bind/dist/lib/isc/tests/socket_test.c b/external/mpl/bind/dist/lib/isc/tests/socket_test.c index cb748771502..6da42c5c136 100644 --- a/external/mpl/bind/dist/lib/isc/tests/socket_test.c +++ b/external/mpl/bind/dist/lib/isc/tests/socket_test.c @@ -1,4 +1,4 @@ -/* $NetBSD: socket_test.c,v 1.3 2019/01/09 16:55:17 christos Exp $ */ +/* $NetBSD: socket_test.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -819,6 +819,7 @@ udp_trunc_test(void **state) { completion_init(&completion); recv_trunc = false; result = isc_socket_recv(s2, &r, 1, task, event_done, &completion); + assert_int_equal(result, ISC_R_SUCCESS); waitfor(&completion); assert_true(completion.done); assert_int_equal(completion.result, ISC_R_SUCCESS); diff --git a/external/mpl/bind/dist/lib/isc/timer.c b/external/mpl/bind/dist/lib/isc/timer.c index ba52f852198..89cf17f4765 100644 --- a/external/mpl/bind/dist/lib/isc/timer.c +++ b/external/mpl/bind/dist/lib/isc/timer.c @@ -1,4 +1,4 @@ -/* $NetBSD: timer.c,v 1.3 2019/01/09 16:55:14 christos Exp $ */ +/* $NetBSD: timer.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -24,7 +24,6 @@ #include <isc/log.h> #include <isc/magic.h> #include <isc/mem.h> -#include <isc/msgs.h> #include <isc/once.h> #include <isc/platform.h> #include <isc/print.h> @@ -169,8 +168,7 @@ schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) { manager->nscheduled++; } - XTRACETIMER(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER, - ISC_MSG_SCHEDULE, "schedule"), timer, due); + XTRACETIMER("schedule", timer, due); /* * If this timer is at the head of the queue, we need to ensure @@ -180,9 +178,7 @@ schedule(isc__timer_t *timer, isc_time_t *now, bool signal_ok) { */ if (timer->index == 1 && signal_ok) { - XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER, - ISC_MSG_SIGNALSCHED, - "signal (schedule)")); + XTRACE("signal (schedule)"); SIGNAL(&manager->wakeup); } @@ -207,9 +203,7 @@ deschedule(isc__timer_t *timer) { INSIST(manager->nscheduled > 0); manager->nscheduled--; if (need_wakeup) { - XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER, - ISC_MSG_SIGNALDESCHED, - "signal (deschedule)")); + XTRACE("signal (deschedule)"); SIGNAL(&manager->wakeup); } } @@ -581,21 +575,14 @@ dispatch(isc__timermgr_t *manager, isc_time_t *now) { * Idle timer has been touched; * reschedule. */ - XTRACEID(isc_msgcat_get(isc_msgcat, - ISC_MSGSET_TIMER, - ISC_MSG_IDLERESCHED, - "idle reschedule"), - timer); + XTRACEID("idle reschedule", timer); post_event = false; need_schedule = true; } } if (post_event) { - XTRACEID(isc_msgcat_get(isc_msgcat, - ISC_MSGSET_TIMER, - ISC_MSG_POSTING, - "posting"), timer); + XTRACEID("posting", timer); /* * XXX We could preallocate this event. */ @@ -612,11 +599,7 @@ dispatch(isc__timermgr_t *manager, isc_time_t *now) { ISC_EVENT_PTR(&event)); } else UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_TIMER, - ISC_MSG_EVENTNOTALLOC, - "couldn't " - "allocate event")); + "couldn't allocate event"); } timer->index = 0; @@ -628,11 +611,7 @@ dispatch(isc__timermgr_t *manager, isc_time_t *now) { if (result != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, "%s: %u", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_TIMER, - ISC_MSG_SCHEDFAIL, - "couldn't schedule " - "timer"), + "couldn't schedule timer", result); } } else { @@ -655,28 +634,20 @@ run(void *uap) { while (!manager->done) { TIME_NOW(&now); - XTRACETIME(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_RUNNING, - "running"), now); + XTRACETIME("running", now); dispatch(manager, &now); if (manager->nscheduled > 0) { - XTRACETIME2(isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_WAITUNTIL, - "waituntil"), - manager->due, now); + XTRACETIME2("waituntil", manager->due, now); result = WAITUNTIL(&manager->wakeup, &manager->lock, &manager->due); INSIST(result == ISC_R_SUCCESS || result == ISC_R_TIMEDOUT); } else { - XTRACETIME(isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_WAIT, "wait"), now); + XTRACETIME("wait", now); WAIT(&manager->wakeup, &manager->lock); } - XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER, - ISC_MSG_WAKEUP, "wakeup")); + XTRACE("wakeup"); } UNLOCK(&manager->lock); @@ -750,10 +721,8 @@ isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) { isc_mutex_destroy(&manager->lock); isc_heap_destroy(&manager->heap); isc_mem_put(mctx, manager, sizeof(*manager)); - UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_thread_create() %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed")); + UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", + "isc_thread_create() failed"); return (ISC_R_UNEXPECTED); } isc_thread_setname(manager->thread, "isc-timer"); @@ -790,8 +759,7 @@ isc_timermgr_destroy(isc_timermgr_t **managerp) { REQUIRE(EMPTY(manager->timers)); manager->done = true; - XTRACE(isc_msgcat_get(isc_msgcat, ISC_MSGSET_TIMER, - ISC_MSG_SIGNALDESTROY, "signal (destroy)")); + XTRACE("signal (destroy)"); SIGNAL(&manager->wakeup); UNLOCK(&manager->lock); @@ -800,10 +768,8 @@ isc_timermgr_destroy(isc_timermgr_t **managerp) { * Wait for thread to exit. */ if (isc_thread_join(manager->thread, NULL) != ISC_R_SUCCESS) - UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_thread_join() %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed")); + UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", + "isc_thread_join() failed"); /* * Clean up. diff --git a/external/mpl/bind/dist/lib/isc/unix/app.c b/external/mpl/bind/dist/lib/isc/unix/app.c index 5d0b00e4aa7..3cf7c014c9d 100644 --- a/external/mpl/bind/dist/lib/isc/unix/app.c +++ b/external/mpl/bind/dist/lib/isc/unix/app.c @@ -1,4 +1,4 @@ -/* $NetBSD: app.c,v 1.3 2019/01/09 16:55:17 christos Exp $ */ +/* $NetBSD: app.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -34,7 +34,6 @@ #include <isc/app.h> #include <isc/condition.h> #include <isc/mem.h> -#include <isc/msgs.h> #include <isc/mutex.h> #include <isc/event.h> #include <isc/platform.h> @@ -116,9 +115,7 @@ handle_signal(int sig, void (*handler)(int)) { sigaction(sig, &sa, NULL) < 0) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_APP, - ISC_MSG_SIGNALSETUP, - "handle_signal() %d setup: %s"), + "handle_signal() %d setup: %s", sig, strbuf); return (ISC_R_UNEXPECTED); } diff --git a/external/mpl/bind/dist/lib/isc/unix/ifiter_getifaddrs.c b/external/mpl/bind/dist/lib/isc/unix/ifiter_getifaddrs.c index 8c12b8627b2..03b51e9dc18 100644 --- a/external/mpl/bind/dist/lib/isc/unix/ifiter_getifaddrs.c +++ b/external/mpl/bind/dist/lib/isc/unix/ifiter_getifaddrs.c @@ -1,4 +1,4 @@ -/* $NetBSD: ifiter_getifaddrs.c,v 1.3 2019/01/09 16:55:17 christos Exp $ */ +/* $NetBSD: ifiter_getifaddrs.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -83,11 +83,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { if (getifaddrs(&iter->ifaddrs) < 0) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_IFITERGETIFADDRS, - ISC_MSG_GETIFADDRS, - "getting interface " - "addresses: getifaddrs: %s"), + "getting interface addresses: getifaddrs: %s", strbuf); result = ISC_R_UNEXPECTED; goto failure; diff --git a/external/mpl/bind/dist/lib/isc/unix/interfaceiter.c b/external/mpl/bind/dist/lib/isc/unix/interfaceiter.c index 0d0b1336351..d7f5fd9ad01 100644 --- a/external/mpl/bind/dist/lib/isc/unix/interfaceiter.c +++ b/external/mpl/bind/dist/lib/isc/unix/interfaceiter.c @@ -1,4 +1,4 @@ -/* $NetBSD: interfaceiter.c,v 1.3 2019/01/09 16:55:17 christos Exp $ */ +/* $NetBSD: interfaceiter.c,v 1.4 2019/02/24 20:01:31 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -32,7 +32,6 @@ #include <isc/log.h> #include <isc/magic.h> #include <isc/mem.h> -#include <isc/msgs.h> #include <isc/net.h> #include <isc/print.h> #include <isc/result.h> diff --git a/external/mpl/bind/dist/lib/isc/unix/net.c b/external/mpl/bind/dist/lib/isc/unix/net.c index 504e539fe12..3542f0306c3 100644 --- a/external/mpl/bind/dist/lib/isc/unix/net.c +++ b/external/mpl/bind/dist/lib/isc/unix/net.c @@ -1,4 +1,4 @@ -/* $NetBSD: net.c,v 1.3 2019/01/09 16:55:17 christos Exp $ */ +/* $NetBSD: net.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -30,7 +30,6 @@ #include <fcntl.h> #include <isc/log.h> -#include <isc/msgs.h> #include <isc/net.h> #include <isc/netdb.h> #include <isc/once.h> @@ -141,11 +140,7 @@ try_proto(int domain) { default: strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "socket() %s: %s", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "socket() failed: %s", strbuf); return (ISC_R_UNEXPECTED); } @@ -249,11 +244,7 @@ try_ipv6only(void) { if (s == -1) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "socket() %s: %s", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "socket() failed: %s", strbuf); ipv6only_result = ISC_R_UNEXPECTED; return; @@ -272,11 +263,7 @@ try_ipv6only(void) { if (s == -1) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "socket() %s: %s", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "socket() failed: %s", strbuf); ipv6only_result = ISC_R_UNEXPECTED; return; @@ -320,11 +307,7 @@ try_ipv6pktinfo(void) { if (s == -1) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "socket() %s: %s", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "socket() failed: %s", strbuf); ipv6pktinfo_result = ISC_R_UNEXPECTED; return; @@ -521,7 +504,6 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) { if (sendmsg(s, &msg, 0) < 0) { int debug = ISC_LOG_DEBUG(10); const char *typestr; - const char *msgstr; switch (errno) { #ifdef ENOPROTOOPT case ENOPROTOOPT: @@ -542,11 +524,9 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) { "sendmsg: %s", strbuf); } else { typestr = (type == IP_TOS) ? "IP_TOS" : "IPV6_TCLASS"; - msgstr = isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"); UNEXPECTED_ERROR(__FILE__, __LINE__, "probing " - "sendmsg() with %s=%02x %s: %s", - typestr, dscp, msgstr, strbuf); + "sendmsg() with %s=%02x failed: %s", + typestr, dscp, strbuf); } return (false); } diff --git a/external/mpl/bind/dist/lib/isc/unix/socket.c b/external/mpl/bind/dist/lib/isc/unix/socket.c index 5d0b14b9513..7b816fccf7c 100644 --- a/external/mpl/bind/dist/lib/isc/unix/socket.c +++ b/external/mpl/bind/dist/lib/isc/unix/socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: socket.c,v 1.7 2019/02/13 01:16:30 christos Exp $ */ +/* $NetBSD: socket.c,v 1.8 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -47,7 +47,6 @@ #include <isc/list.h> #include <isc/log.h> #include <isc/mem.h> -#include <isc/msgs.h> #include <isc/mutex.h> #include <isc/net.h> #include <isc/once.h> @@ -636,12 +635,10 @@ thread_log(isc__socketthread_t *thread, static void socket_log(isc__socket_t *sock, const isc_sockaddr_t *address, isc_logcategory_t *category, isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int message, - const char *fmt, ...) ISC_FORMAT_PRINTF(9, 10); + const char *fmt, ...) ISC_FORMAT_PRINTF(6, 7); static void socket_log(isc__socket_t *sock, const isc_sockaddr_t *address, isc_logcategory_t *category, isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int message, const char *fmt, ...) { char msgbuf[2048]; @@ -656,14 +653,12 @@ socket_log(isc__socket_t *sock, const isc_sockaddr_t *address, va_end(ap); if (address == NULL) { - isc_log_iwrite(isc_lctx, category, module, level, - msgcat, msgset, message, - "socket %p: %s", sock, msgbuf); + isc_log_write(isc_lctx, category, module, level, + "socket %p: %s", sock, msgbuf); } else { isc_sockaddr_format(address, peerbuf, sizeof(peerbuf)); - isc_log_iwrite(isc_lctx, category, module, level, - msgcat, msgset, message, - "socket %p %s: %s", sock, peerbuf, msgbuf); + isc_log_write(isc_lctx, category, module, level, + "socket %p %s: %s", sock, peerbuf, msgbuf); } } @@ -971,10 +966,7 @@ select_poke(isc__socketmgr_t *mgr, int threadid, int fd, int msg) { if (cc < 0) { strerror_r(errno, strbuf, sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_WRITEFAILED, - "write() failed " - "during watcher poke: %s"), + "write() failed during watcher poke: %s", strbuf); } @@ -999,10 +991,7 @@ select_readmsg(isc__socketthread_t *thread, int *fd, int *msg) { strerror_r(errno, strbuf, sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_READFAILED, - "read() failed " - "during watcher poke: %s"), + "read() failed during watcher poke: %s", strbuf); } INSIST(cc == sizeof(buf)); @@ -1150,7 +1139,6 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { cmsgp = CMSG_FIRSTHDR(msg); while (cmsgp != NULL) { socket_log(sock, NULL, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_PROCESSCMSG, "processing cmsg %p", cmsgp); if (cmsgp->cmsg_level == IPPROTO_IPV6 @@ -1161,8 +1149,6 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) { sizeof(struct in6_pktinfo)); dev->attributes |= ISC_SOCKEVENTATTR_PKTINFO; socket_log(sock, NULL, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_IFRECEIVED, "interface received on ifindex %u", dev->pktinfo.ipi6_ifindex); if (IN6_IS_ADDR_MULTICAST(&pktinfop->ipi6_addr)) @@ -1242,9 +1228,6 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev, msg->msg_namelen = 0; } - write_count = 0; - iovcount = 0; - write_count = dev->region.length - dev->n; iov[0].iov_base = (void *)(dev->region.base + dev->n); iov[0].iov_len = write_count; @@ -1263,7 +1246,6 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev, struct in6_pktinfo *pktinfop; socket_log(sock, NULL, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_SENDTODATA, "sendto pktinfo data, ifindex %u", dev->pktinfo.ipi6_ifindex); @@ -1333,12 +1315,8 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev, strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, IP_TOS, %.02x)" - " %s: %s", + " failed: %s", sock->fd, dscp >> 2, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), strbuf); } else sock->dscp = dscp; @@ -1363,12 +1341,8 @@ build_msghdr_send(isc__socket_t *sock, char* cmsgbuf, isc_socketevent_t *dev, strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, IPV6_TCLASS, " - "%.02x) %s: %s", + "%.02x) failed: %s", sock->fd, dscp >> 2, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), strbuf); } else sock->dscp = dscp; @@ -1419,8 +1393,6 @@ build_msghdr_recv(isc__socket_t *sock, char *cmsgbuf, isc_socketevent_t *dev, dev->address = sock->peer_address; } - read_count = 0; - read_count = dev->region.length - dev->n; iov[0].iov_base = (void *)(dev->region.base + dev->n); iov[0].iov_len = read_count; @@ -1557,8 +1529,6 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) { if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) { strerror_r(recv_errno, strbuf, sizeof(strbuf)); socket_log(sock, NULL, IOEVENT, - isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_DOIORECV, "doio_recv: recvmsg(%d) %d bytes, err %d/%s", sock->fd, cc, recv_errno, strbuf); } @@ -1626,8 +1596,6 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) { if (isc_sockaddr_getport(&dev->address) == 0) { if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) { socket_log(sock, &dev->address, IOEVENT, - isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_ZEROPORT, "dropping source port zero packet"); } return (DOIO_SOFT); @@ -1641,7 +1609,6 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) { } socket_log(sock, &dev->address, IOEVENT, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_PKTRECV, "packet received correctly"); /* @@ -1788,9 +1755,7 @@ doio_send(isc__socket_t *sock, isc_socketevent_t *dev) { inc_stats(sock->manager->stats, sock->statsindex[STATID_SENDFAIL]); UNEXPECTED_ERROR(__FILE__, __LINE__, - "doio_send: send() %s 0", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_RETURNED, "returned")); + "doio_send: send() returned 0"); } /* @@ -1888,8 +1853,7 @@ destroy(isc__socket_t **sockp) { isc__socketmgr_t *manager = sock->manager; isc__socketthread_t *thread; - socket_log(sock, NULL, CREATION, isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_DESTROYING, "destroying"); + socket_log(sock, NULL, CREATION, "destroying"); INSIST(ISC_LIST_EMPTY(sock->connect_list)); INSIST(ISC_LIST_EMPTY(sock->accept_list)); @@ -2292,12 +2256,10 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, if (sock->fd >= (int)manager->maxsocks) { (void)close(sock->fd); - isc_log_iwrite(isc_lctx, ISC_LOGCATEGORY_GENERAL, - ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR, - isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_TOOMANYFDS, - "socket: file descriptor exceeds limit (%d/%u)", - sock->fd, manager->maxsocks); + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR, + "socket: file descriptor exceeds limit (%d/%u)", + sock->fd, manager->maxsocks); inc_stats(manager->stats, sock->statsindex[STATID_OPENFAIL]); return (ISC_R_NORESOURCES); } @@ -2307,11 +2269,9 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, case EMFILE: case ENFILE: strerror_r(errno, strbuf, sizeof(strbuf)); - isc_log_iwrite(isc_lctx, ISC_LOGCATEGORY_GENERAL, - ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR, - isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_TOOMANYFDS, - "%s: %s", err, strbuf); + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR, + "%s: %s", err, strbuf); /* fallthrough */ case ENOBUFS: inc_stats(manager->stats, @@ -2333,11 +2293,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, default: strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "%s() %s: %s", err, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "%s() failed: %s", err, strbuf); inc_stats(manager->stats, sock->statsindex[STATID_OPENFAIL]); @@ -2363,10 +2319,8 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, (void *)&on, sizeof(on)) < 0) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d, SO_BSDCOMPAT) %s: %s", + "setsockopt(%d, SO_BSDCOMPAT) failed: %s", sock->fd, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), strbuf); /* Press on... */ } @@ -2377,10 +2331,8 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, (void *)&on, sizeof(on)) < 0) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d, SO_NOSIGPIPE) %s: %s", + "setsockopt(%d, SO_NOSIGPIPE) failed: %s", sock->fd, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), strbuf); /* Press on... */ } @@ -2404,12 +2356,8 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, && errno != ENOPROTOOPT) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d, SO_TIMESTAMP) %s: %s", + "setsockopt(%d, SO_TIMESTAMP) failed: %s", sock->fd, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), strbuf); /* Press on... */ } @@ -2423,11 +2371,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, IPV6_RECVPKTINFO) " - "%s: %s", sock->fd, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "failed: %s", sock->fd, strbuf); } #else @@ -2437,12 +2381,8 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, (void *)&on, sizeof(on)) < 0)) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d, IPV6_PKTINFO) %s: %s", + "setsockopt(%d, IPV6_PKTINFO) failed: %s", sock->fd, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), strbuf); } #endif /* IPV6_RECVPKTINFO */ @@ -2503,12 +2443,8 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, (void *)&rcvbuf, sizeof(rcvbuf)) == -1) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d, SO_RCVBUF, %d) %s: %s", + "setsockopt(%d, SO_RCVBUF, %d) failed: %s", sock->fd, rcvbuf, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), strbuf); } } @@ -2524,12 +2460,8 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, (void *)&sndbuf, sizeof(sndbuf)) == -1) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d, SO_SNDBUF, %d) %s: %s", + "setsockopt(%d, SO_SNDBUF, %d) failed: %s", sock->fd, sndbuf, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), strbuf); } } @@ -2542,9 +2474,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, IPV6_RECVTCLASS) " - "%s: %s", sock->fd, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), + "failed: %s", sock->fd, strbuf); } #endif @@ -2555,9 +2485,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, IP_RECVTOS) " - "%s: %s", sock->fd, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), + "failed: %s", sock->fd, strbuf); } #endif @@ -2662,8 +2590,8 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type, #endif UNLOCK(&manager->lock); - socket_log(sock, NULL, CREATION, isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_CREATED, dup_socket != NULL ? "dupped" : "created"); + socket_log(sock, NULL, CREATION, + dup_socket != NULL ? "dupped" : "created"); return (ISC_R_SUCCESS); } @@ -2944,7 +2872,6 @@ internal_accept(isc__socket_t *sock) { LOCK(&sock->lock); socket_log(sock, NULL, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_ACCEPTLOCK, "internal_accept called, locked socket"); manager = sock->manager; @@ -3001,12 +2928,10 @@ internal_accept(isc__socket_t *sock) { switch (errno) { case ENFILE: case EMFILE: - isc_log_iwrite(isc_lctx, ISC_LOGCATEGORY_GENERAL, - ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR, - isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_TOOMANYFDS, - "%s: too many open file descriptors", - err); + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR, + "%s: too many open file descriptors", + err); goto soft_error; case ENOBUFS: @@ -3030,11 +2955,7 @@ internal_accept(isc__socket_t *sock) { } strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "internal_accept: %s() %s: %s", err, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "internal_accept: %s() failed: %s", err, strbuf); fd = -1; result = ISC_R_UNEXPECTED; @@ -3060,13 +2981,10 @@ internal_accept(isc__socket_t *sock) { (void)close(fd); goto soft_error; } else if (fd >= (int)manager->maxsocks) { - isc_log_iwrite(isc_lctx, ISC_LOGCATEGORY_GENERAL, - ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR, - isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_TOOMANYFDS, - "accept: " - "file descriptor exceeds limit (%d/%u)", - fd, manager->maxsocks); + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR, + "accept: file descriptor exceeds limit (%d/%u)", + fd, manager->maxsocks); (void)close(fd); goto soft_error; } @@ -3149,7 +3067,6 @@ internal_accept(isc__socket_t *sock) { #endif socket_log(sock, &NEWCONNSOCK(dev)->peer_address, CREATION, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_ACCEPTEDCXN, "accepted connection, new socket %p", dev->newsocket); @@ -3195,7 +3112,6 @@ internal_recv(isc__socket_t *sock) { } socket_log(sock, NULL, IOEVENT, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_INTERNALRECV, "internal_recv: event %p -> task %p", dev, dev->ev_sender); /* @@ -3248,8 +3164,8 @@ internal_send(isc__socket_t *sock) { if (dev == NULL) { goto finish; } - socket_log(sock, NULL, EVENT, NULL, 0, 0, - "internal_send: event %p -> task %p", + socket_log(sock, NULL, EVENT, + "internal_send: event %p -> task %p", dev, dev->ev_sender); /* @@ -3369,7 +3285,7 @@ process_fd(isc__socketthread_t *thread, int fd, bool readable, /* * Sock is being closed, it will be destroyed, bail. */ - isc_refcount_decrement(&sock->references); + (void)isc_refcount_decrement(&sock->references); UNLOCK(&thread->fdlock[lockid]); return; } @@ -3540,10 +3456,7 @@ process_ctlfd(isc__socketthread_t *thread) { select_readmsg(thread, &fd, &msg); thread_log(thread, IOEVENT, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_WATCHERMSG, - "watcher got message %d " - "for socket %d"), msg, fd); + "watcher got message %d for socket %d", msg, fd); /* * Nothing to read? @@ -3689,11 +3602,7 @@ netthread(void *uap) { if (cc < 0 && !SOFT_ERROR(errno)) { strerror_r(errno, strbuf, sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, - "%s %s: %s", fnname, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), strbuf); + "%s failed: %s", fnname, strbuf); } #if defined(USE_DEVPOLL) && defined(ISC_SOCKET_USE_POLLWATCH) @@ -3739,9 +3648,7 @@ netthread(void *uap) { #endif } - thread_log(thread, TRACE, "%s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_EXITING, "watcher exiting")); + thread_log(thread, TRACE, "watcher exiting"); return ((isc_threadresult_t)0); } @@ -3800,9 +3707,7 @@ setup_thread(isc__socketthread_t *thread) { if (pipe(thread->pipe_fds) != 0) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "pipe() %s: %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), + "pipe() failed: %s", strbuf); return (ISC_R_UNEXPECTED); } @@ -3818,9 +3723,7 @@ setup_thread(isc__socketthread_t *thread) { result = isc__errno2result(errno); strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "kqueue %s: %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), + "kqueue failed: %s", strbuf); isc_mem_put(thread->manager->mctx, thread->events, sizeof(struct kevent) * thread->nevents); @@ -3853,9 +3756,7 @@ setup_thread(isc__socketthread_t *thread) { result = isc__errno2result(errno); strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "epoll_create %s: %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), + "epoll_create failed: %s", strbuf); return (result); @@ -3888,9 +3789,7 @@ setup_thread(isc__socketthread_t *thread) { result = isc__errno2result(errno); strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "open(/dev/poll) %s: %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), + "open(/dev/poll) failed: %s", strbuf); isc_mem_put(thread->manager->mctx, thread->events, sizeof(struct pollfd) * thread->nevents); @@ -3950,9 +3849,7 @@ cleanup_thread(isc_mem_t *mctx, isc__socketthread_t *thread) { result = unwatch_fd(thread, thread->pipe_fds[0], SELECT_POKE_READ); if (result != ISC_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, - "epoll_ctl(DEL) %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed")); + "epoll_ctl(DEL) failed"); } #ifdef USE_KQUEUE close(thread->kqueue_fd); @@ -4113,10 +4010,7 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) { * Wait for all sockets to be destroyed. */ while (!ISC_LIST_EMPTY(manager->socklist)) { - manager_log(manager, CREATION, "%s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_SOCKETSREMAIN, - "sockets exist")); + manager_log(manager, CREATION, "sockets exist"); WAIT(&manager->shutdown_ok, &manager->lock); } @@ -4139,11 +4033,7 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) { result = isc_thread_join(manager->threads[i].thread, NULL); if (result != ISC_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_thread_join() %s", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed")); + "isc_thread_join() failed"); } cleanup_thread(manager->mctx, &manager->threads[i]); } @@ -4220,7 +4110,7 @@ socket_recv(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, SELECT_POKE_READ); } - socket_log(sock, NULL, EVENT, NULL, 0, 0, + socket_log(sock, NULL, EVENT, "socket_recv: event %p -> task %p", dev, ntask); @@ -4321,10 +4211,9 @@ socket_send(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, if (!isc_sockaddr_issitelocal(&dev->address) && !isc_sockaddr_islinklocal(&dev->address)) { - socket_log(sock, NULL, TRACE, isc_msgcat, - ISC_MSGSET_SOCKET, ISC_MSG_PKTINFOPROVIDED, - "pktinfo structure provided, ifindex %u " - "(set to 0)", pktinfo->ipi6_ifindex); + socket_log(sock, NULL, TRACE, + "pktinfo structure provided, ifindex %u (set to 0)", + pktinfo->ipi6_ifindex); /* * Set the pktinfo index to 0 here, to let the @@ -4374,7 +4263,7 @@ socket_send(isc__socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, sock->fd, SELECT_POKE_WRITE); } - socket_log(sock, NULL, EVENT, NULL, 0, 0, + socket_log(sock, NULL, EVENT, "socket_send: event %p -> task %p", dev, ntask); @@ -4684,17 +4573,13 @@ isc_socket_bind(isc_socket_t *sock0, const isc_sockaddr_t *sockaddr, (void *)&on, sizeof(on)) < 0) { UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d) %s", sock->fd, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed")); + "setsockopt(%d) failed", sock->fd); } if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on)) < 0) { UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d) %s", sock->fd, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed")); + "setsockopt(%d) failed", sock->fd); } /* Press on... */ } @@ -4723,8 +4608,7 @@ isc_socket_bind(isc_socket_t *sock0, const isc_sockaddr_t *sockaddr, } } - socket_log(sock, sockaddr, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_BOUND, "bound"); + socket_log(sock, sockaddr, TRACE, "bound"); sock->bound = 1; UNLOCK(&sock->lock); @@ -4757,9 +4641,8 @@ isc_socket_filter(isc_socket_t *sock0, const char *filter) { if (setsockopt(sock->fd, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)) == -1) { strerror_r(errno, strbuf, sizeof(strbuf)); - socket_log(sock, NULL, CREATION, isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_FILTER, "setsockopt(SO_ACCEPTFILTER): %s", - strbuf); + socket_log(sock, NULL, CREATION, + "setsockopt(SO_ACCEPTFILTER): %s", strbuf); return (ISC_R_FAILURE); } return (ISC_R_SUCCESS); @@ -5424,13 +5307,8 @@ isc_socket_ipv6only(isc_socket_t *sock0, bool yes) { char strbuf[ISC_STRERRORSIZE]; strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d, IPV6_V6ONLY) " - "%s: %s", sock->fd, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), - strbuf); + "setsockopt(%d, IPV6_V6ONLY) failed: %s", + sock->fd, strbuf); } } #endif @@ -5451,12 +5329,8 @@ setdscp(isc__socket_t *sock, isc_dscp_t dscp) { char strbuf[ISC_STRERRORSIZE]; strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d, IP_TOS, %.02x) " - "%s: %s", sock->fd, value >> 2, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "setsockopt(%d, IP_TOS, %.02x) failed: %s", + sock->fd, value >> 2, strbuf); } } @@ -5468,13 +5342,8 @@ setdscp(isc__socket_t *sock, isc_dscp_t dscp) { char strbuf[ISC_STRERRORSIZE]; strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d, IPV6_TCLASS, %.02x) " - "%s: %s", sock->fd, dscp >> 2, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), - strbuf); + "setsockopt(%d, IPV6_TCLASS, %.02x) failed: %s", + sock->fd, dscp >> 2, strbuf); } } #endif @@ -5906,8 +5775,7 @@ isc_socket_fdwatchcreate(isc_socketmgr_t *manager0, int fd, int flags, select_poke(sock->manager, sock->threadid, sock->fd, SELECT_POKE_WRITE); - socket_log(sock, NULL, CREATION, isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_CREATED, "fdwatch-created"); + socket_log(sock, NULL, CREATION, "fdwatch-created"); return (ISC_R_SUCCESS); } @@ -5942,8 +5810,7 @@ isc_socket_fdwatchpoke(isc_socket_t *sock0, int flags) UNLOCK(&sock->lock); } - socket_log(sock, NULL, TRACE, isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_POKED, "fdwatch-poked flags: %d", flags); + socket_log(sock, NULL, TRACE, "fdwatch-poked flags: %d", flags); return (ISC_R_SUCCESS); } diff --git a/external/mpl/bind/dist/lib/isc/win32/app.c b/external/mpl/bind/dist/lib/isc/win32/app.c index 1b262927b4e..47ea8f2ab82 100644 --- a/external/mpl/bind/dist/lib/isc/win32/app.c +++ b/external/mpl/bind/dist/lib/isc/win32/app.c @@ -1,4 +1,4 @@ -/* $NetBSD: app.c,v 1.3 2019/01/09 16:55:17 christos Exp $ */ +/* $NetBSD: app.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -26,7 +26,6 @@ #include <isc/app.h> #include <isc/condition.h> #include <isc/mem.h> -#include <isc/msgs.h> #include <isc/mutex.h> #include <isc/event.h> #include <isc/platform.h> diff --git a/external/mpl/bind/dist/lib/isc/win32/include/isc/ntpaths.h b/external/mpl/bind/dist/lib/isc/win32/include/isc/ntpaths.h index 7c16110e78c..70fc2378d0b 100644 --- a/external/mpl/bind/dist/lib/isc/win32/include/isc/ntpaths.h +++ b/external/mpl/bind/dist/lib/isc/win32/include/isc/ntpaths.h @@ -1,4 +1,4 @@ -/* $NetBSD: ntpaths.h,v 1.2 2018/08/12 13:02:40 christos Exp $ */ +/* $NetBSD: ntpaths.h,v 1.3 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -35,7 +35,8 @@ enum NtPaths { LOCAL_STATE_DIR, SYS_CONF_DIR, RNDC_KEY_PATH, - SESSION_KEY_PATH + SESSION_KEY_PATH, + BIND_KEYS_PATH }; /* diff --git a/external/mpl/bind/dist/lib/isc/win32/include/isc/stdatomic.h b/external/mpl/bind/dist/lib/isc/win32/include/isc/stdatomic.h index 6fa7c860bed..04dd12ad9cf 100644 --- a/external/mpl/bind/dist/lib/isc/win32/include/isc/stdatomic.h +++ b/external/mpl/bind/dist/lib/isc/win32/include/isc/stdatomic.h @@ -1,4 +1,4 @@ -/* $NetBSD: stdatomic.h,v 1.2 2019/01/09 16:55:17 christos Exp $ */ +/* $NetBSD: stdatomic.h,v 1.3 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -19,6 +19,13 @@ #include <stdint.h> #include <windows.h> +#include <intrin.h> + +#define InterlockedExchangeAdd8 _InterlockedExchangeAdd8 +#define InterlockedCompareExchange8 _InterlockedCompareExchange8 + +#pragma intrinsic(_InterlockedCompareExchange8, _InterlockedExchangeAdd8) + #include <isc/util.h> #ifndef __ATOMIC_RELAXED @@ -51,6 +58,14 @@ enum memory_order { typedef enum memory_order memory_order; +/* + * If you add a type with different sizeof() length, + * you need to implement atomic_<foo>_explicitNN macros. + */ + +typedef bool volatile atomic_bool; +typedef int_fast8_t volatile atomic_int_fast8_t; +typedef uint_fast8_t volatile atomic_uint_fast8_t; typedef int_fast32_t volatile atomic_int_fast32_t; typedef uint_fast32_t volatile atomic_uint_fast32_t; typedef int_fast64_t volatile atomic_int_fast64_t; @@ -59,23 +74,26 @@ typedef uint_fast64_t volatile atomic_uint_fast64_t; #define atomic_init(obj, desired) \ (*(obj) = (desired)) +#define atomic_store_explicit8(obj, desired, order) \ + (void)InterlockedExchange8((atomic_int_fast8_t *)obj, desired) + #define atomic_store_explicit32(obj, desired, order) \ (order == memory_order_relaxed \ - ? InterlockedExchangeNoFence((atomic_int_fast32_t *)obj, desired) \ + ? (void)InterlockedExchangeNoFence((atomic_int_fast32_t *)obj, desired) \ : (order == memory_order_acquire \ - ? InterlockedExchangeAcquire((atomic_int_fast32_t *)obj, desired) \ - : InterlockedExchange((atomic_int_fast32_t *)obj, desired))) + ? (void)InterlockedExchangeAcquire((atomic_int_fast32_t *)obj, desired) \ + : (void)InterlockedExchange((atomic_int_fast32_t *)obj, desired))) #ifdef _WIN64 #define atomic_store_explicit64(obj, desired, order) \ (order == memory_order_relaxed \ - ? InterlockedExchangeNoFence64((atomic_int_fast64_t *)obj, desired) \ + ? (void)InterlockedExchangeNoFence64((atomic_int_fast64_t *)obj, desired) \ : (order == memory_order_acquire \ - ? InterlockedExchangeAcquire64((atomic_int_fast64_t *)obj, desired) \ - : InterlockedExchange64((atomic_int_fast64_t *)obj, desired))) + ? (void)InterlockedExchangeAcquire64((atomic_int_fast64_t *)obj, desired) \ + : (void)InterlockedExchange64((atomic_int_fast64_t *)obj, desired))) #else #define atomic_store_explicit64(obj, desired, order) \ - InterlockedExchange64((atomic_int_fast64_t *)obj, desired) + (void)InterlockedExchange64((atomic_int_fast64_t *)obj, desired) #endif static inline @@ -86,35 +104,40 @@ atomic_store_abort() { } #define atomic_store_explicit(obj, desired, order) \ - (sizeof(*obj) == 8 \ + (sizeof(*(obj)) == 8 \ ? atomic_store_explicit64(obj, desired, order) \ - : (sizeof(*obj) == 4 \ + : (sizeof(*(obj)) == 4 \ ? atomic_store_explicit32(obj, desired, order) \ - : atomic_store_abort())) + : (sizeof(*(obj)) == 1 \ + ? atomic_store_explicit8(obj, desired, order) \ + : atomic_store_abort()))) #define atomic_store(obj, desired) \ - atomic_store(obj, desider, memory_order_seq_cst) + atomic_store_explicit(obj, desired, memory_order_seq_cst) -#define atomic_load_explicit32(obj, order) \ - (order == memory_order_relaxed \ +#define atomic_load_explicit8(obj, order) \ + (int8_t)InterlockedOr8((atomic_int_fast8_t *)obj, 0) + +#define atomic_load_explicit32(obj, order) \ + (order == memory_order_relaxed \ ? (int32_t)InterlockedOrNoFence((atomic_int_fast32_t *)obj, 0) \ - : (order == memory_order_acquire \ - ? (int32_t)InterlockedOrAcquire((atomic_int_fast32_t *)obj, 0) \ - : (order == memory_order_release \ + : (order == memory_order_acquire \ + ? (int32_t)InterlockedOrAcquire((atomic_int_fast32_t *)obj, 0) \ + : (order == memory_order_release \ ? (int32_t)InterlockedOrRelease((atomic_int_fast32_t *)obj, 0) \ : (int32_t)InterlockedOr((atomic_int_fast32_t *)obj, 0)))) #ifdef _WIN64 -#define atomic_load_explicit64(obj, order) \ - (order == memory_order_relaxed \ +#define atomic_load_explicit64(obj, order) \ + (order == memory_order_relaxed \ ? InterlockedOr64NoFence((atomic_int_fast64_t *)obj, 0) \ - : (order == memory_order_acquire \ + : (order == memory_order_acquire \ ? InterlockedOr64Acquire((atomic_int_fast64_t *)obj, 0) \ - : (order == memory_order_release \ + : (order == memory_order_release \ ? InterlockedOr64Release((atomic_int_fast64_t *)obj, 0) \ : InterlockedOr64((atomic_int_fast64_t *)obj, 0)))) #else -#define atomic_load_explicit64(obj, order) \ +#define atomic_load_explicit64(obj, order) \ InterlockedOr64((atomic_int_fast64_t *)obj, 0) #endif @@ -125,16 +148,25 @@ atomic_load_abort() { ISC_UNREACHABLE(); } -#define atomic_load_explicit(obj, order) \ - (sizeof(*obj) == 8 \ - ? atomic_load_explicit64(obj, order) \ - : (sizeof(*obj == 4) \ - ? atomic_load_explicit32(obj, order) \ - : atomic_load_abort())) +#define atomic_load_explicit(obj, order) \ + ((sizeof(*(obj)) == 8 \ + ? atomic_load_explicit64(obj, order) \ + : (sizeof(*(obj) == 4) \ + ? atomic_load_explicit32(obj, order) \ + : (sizeof(*(obj) == 1) \ + ? atomic_load_explicit8(obj, order) \ + : atomic_load_abort()))) & \ + (sizeof(*(obj)) == 8 ? 0xffffffffffffffffULL : \ + (sizeof(*(obj)) == 4 ? 0xffffffffULL : \ + (sizeof(*(obj)) == 1 ? 0xffULL : atomic_load_abort())))) + #define atomic_load(obj) \ atomic_load_explicit(obj, memory_order_seq_cst) +#define atomic_fetch_add_explicit8(obj, arg, order) \ + InterlockedExchangeAdd8((atomic_int_fast8_t *)obj, arg) + #define atomic_fetch_add_explicit32(obj, arg, order) \ (order == memory_order_relaxed \ ? InterlockedExchangeAddNoFence((atomic_int_fast32_t *)obj, arg) \ @@ -142,7 +174,7 @@ atomic_load_abort() { ? InterlockedExchangeAddAcquire((atomic_int_fast32_t *)obj, arg) \ : (order == memory_order_release \ ? InterlockedExchangeAddRelease((atomic_int_fast32_t *)obj, arg) \ - : InterlockedExchange((atomic_int_fast32_t *)obj, arg)))) + : InterlockedExchangeAdd((atomic_int_fast32_t *)obj, arg)))) #ifdef _WIN64 #define atomic_fetch_add_explicit64(obj, arg, order) \ @@ -152,7 +184,7 @@ atomic_load_abort() { ? InterlockedExchangeAddAcquire64((atomic_int_fast64_t *)obj, arg) \ : (order == memory_order_release \ ? InterlockedExchangeAddRelease64((atomic_int_fast64_t *)obj, arg) \ - : InterlockedExchange64((atomic_int_fast64_t *)obj, arg)))) + : InterlockedExchangeAdd64((atomic_int_fast64_t *)obj, arg)))) #else #define atomic_fetch_add_explicit64(obj, arg, order) \ InterlockedExchange64((atomic_int_fast64_t *)obj, arg) @@ -166,11 +198,13 @@ atomic_add_abort() { } #define atomic_fetch_add_explicit(obj, arg, order) \ - (sizeof(*obj) == 8 \ + (sizeof(*(obj)) == 8 \ ? atomic_fetch_add_explicit64(obj, arg, order) \ - : (sizeof(*obj) == 4 \ + : (sizeof(*(obj)) == 4 \ ? atomic_fetch_add_explicit32(obj, arg, order) \ - : atomic_add_abort())) + : (sizeof(*(obj)) == 1 \ + ? atomic_fetch_add_explicit8(obj, arg, order) \ + : atomic_add_abort()))) #define atomic_fetch_add(obj, arg) \ atomic_fetch_add_explicit(obj, arg, memory_order_seq_cst) @@ -182,6 +216,24 @@ atomic_add_abort() { atomic_fetch_sub_explicit(obj, arg, memory_order_seq_cst) static inline bool +atomic_compare_exchange_strong_explicit8(atomic_int_fast8_t *obj, + int8_t *expected, + int8_t desired, + memory_order succ, + memory_order fail) +{ + bool __r; + int8_t __v; + REQUIRE(succ == fail); + __v = InterlockedCompareExchange8((atomic_int_fast8_t *)obj, desired, *expected); + __r = (*(expected) == __v); + if (!__r) { + *(expected) = __v; + } + return (__r); +} + +static inline bool atomic_compare_exchange_strong_explicit32(atomic_int_fast32_t *obj, int32_t *expected, int32_t desired, @@ -254,21 +306,25 @@ atomic_compare_exchange_abort() { #define atomic_compare_exchange_strong_explicit(obj, expected, desired, \ succ, fail) \ - (sizeof(*obj) == 8 \ + (sizeof(*(obj)) == 8 \ ? atomic_compare_exchange_strong_explicit64(obj, expected, \ desired, \ succ, fail) \ - : (sizeof(*obj) == 4 \ + : (sizeof(*(obj)) == 4 \ ? atomic_compare_exchange_strong_explicit32(obj, expected, \ desired, \ succ, fail) \ - : atomic_compare_exchange_abort())) + : (sizeof(*(obj)) == 1 \ + ? atomic_compare_exchange_strong_explicit8(obj, expected, \ + desired, \ + succ, fail) \ + : atomic_compare_exchange_abort()))) #define atomic_compare_exchange_strong(obj, expected, desired, \ succ, fail) \ atomic_compare_exchange_strong_explicit(obj, expected, desired, \ - memory_order_cst_seq, \ - memory_order_cst_seq) + memory_order_seq_cst, \ + memory_order_seq_cst) #define atomic_compare_exchange_weak_explicit(obj, expected, desired, \ succ, fail) \ @@ -277,5 +333,5 @@ atomic_compare_exchange_abort() { #define atomic_compare_exchange_weak(obj, expected, desired) \ atomic_compare_exchange_weak_explicit(obj, expected, desired, \ - memory_order_cst_seq, \ - memory_order_cst_seq) + memory_order_seq_cst, \ + memory_order_seq_cst) diff --git a/external/mpl/bind/dist/lib/isc/win32/net.c b/external/mpl/bind/dist/lib/isc/win32/net.c index 3393ed0275d..6f8d19ef266 100644 --- a/external/mpl/bind/dist/lib/isc/win32/net.c +++ b/external/mpl/bind/dist/lib/isc/win32/net.c @@ -1,4 +1,4 @@ -/* $NetBSD: net.c,v 1.3 2019/01/09 16:55:17 christos Exp $ */ +/* $NetBSD: net.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -18,7 +18,6 @@ #include <unistd.h> #include <isc/log.h> -#include <isc/msgs.h> #include <isc/net.h> #include <isc/once.h> #include <isc/strerr.h> @@ -69,11 +68,7 @@ try_proto(int domain) { default: strerror_r(errval, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "socket() %s: %s", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "socket() failed: %s", strbuf); return (ISC_R_UNEXPECTED); } @@ -137,11 +132,7 @@ try_ipv6only(void) { if (s == INVALID_SOCKET) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "socket() %s: %s", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "socket() failed: %s", strbuf); ipv6only_result = ISC_R_UNEXPECTED; return; @@ -161,11 +152,7 @@ try_ipv6only(void) { if (s == INVALID_SOCKET) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "socket() %s: %s", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "socket() failed: %s", strbuf); ipv6only_result = ISC_R_UNEXPECTED; return; @@ -217,11 +204,7 @@ try_ipv6pktinfo(void) { if (s == INVALID_SOCKET) { strerror_r(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "socket() %s: %s", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "socket() failed: %s", strbuf); ipv6pktinfo_result = ISC_R_UNEXPECTED; return; diff --git a/external/mpl/bind/dist/lib/isc/win32/ntpaths.c b/external/mpl/bind/dist/lib/isc/win32/ntpaths.c index 58621baab21..96d09d763e9 100644 --- a/external/mpl/bind/dist/lib/isc/win32/ntpaths.c +++ b/external/mpl/bind/dist/lib/isc/win32/ntpaths.c @@ -1,4 +1,4 @@ -/* $NetBSD: ntpaths.c,v 1.2 2018/08/12 13:02:40 christos Exp $ */ +/* $NetBSD: ntpaths.c,v 1.3 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -41,6 +41,7 @@ static char sys_conf_dir[MAX_PATH]; static char rndc_keyFile[MAX_PATH]; static char session_keyFile[MAX_PATH]; static char resolv_confFile[MAX_PATH]; +static char bind_keysFile[MAX_PATH]; static DWORD baseLen = MAX_PATH; static BOOL Initialized = FALSE; @@ -100,6 +101,9 @@ isc_ntpaths_init(void) { strlcat(resolv_confFile, "\\etc\\resolv.conf", sizeof(resolv_confFile)); + strlcpy(bind_keysFile, namedBase, sizeof(bind_keysFile)); + strlcat(bind_keysFile, "\\etc\\bind.keys", sizeof(bind_keysFile)); + Initialized = TRUE; } @@ -136,6 +140,9 @@ isc_ntpaths_get(int ind) { case SESSION_KEY_PATH: return (session_keyFile); break; + case BIND_KEYS_PATH: + return (bind_keysFile); + break; default: return (NULL); } diff --git a/external/mpl/bind/dist/lib/isc/win32/socket.c b/external/mpl/bind/dist/lib/isc/win32/socket.c index ff429404c71..9cf50aa9e0e 100644 --- a/external/mpl/bind/dist/lib/isc/win32/socket.c +++ b/external/mpl/bind/dist/lib/isc/win32/socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: socket.c,v 1.3 2019/01/09 16:55:17 christos Exp $ */ +/* $NetBSD: socket.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -53,7 +53,6 @@ #include <isc/list.h> #include <isc/log.h> #include <isc/mem.h> -#include <isc/msgs.h> #include <isc/mutex.h> #include <isc/net.h> #include <isc/once.h> @@ -428,7 +427,6 @@ sock_dump(isc_socket_t *sock) { static void socket_log(int lineno, isc_socket_t *sock, const isc_sockaddr_t *address, isc_logcategory_t *category, isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int message, const char *fmt, ...) ISC_FORMAT_PRINTF(10, 11); /* This function will add an entry to the I/O completion port @@ -447,10 +445,8 @@ signal_iocompletionport_exit(isc_socketmgr_t *manager) { errval = GetLastError(); strerror_r(errval, strbuf, sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_FAILED, - "Can't request service thread to exit: %s"), - strbuf); + "Can't request service thread to exit: %s", + strbuf); } } } @@ -477,9 +473,7 @@ iocompletionport_createthreads(int total_threads, isc_socketmgr_t *manager) { errval = GetLastError(); strerror_r(errval, strbuf, sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_FAILED, - "Can't create IOCP thread: %s"), + "Can't create IOCP thread: %s", strbuf); } } @@ -503,10 +497,7 @@ iocompletionport_init(isc_socketmgr_t *manager) { errval = GetLastError(); strerror_r(errval, strbuf, sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_FAILED, - "HeapCreate() failed during " - "initialization: %s"), + "HeapCreate() failed during initialization: %s", strbuf); } @@ -518,10 +509,7 @@ iocompletionport_init(isc_socketmgr_t *manager) { errval = GetLastError(); strerror_r(errval, strbuf, sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_FAILED, - "CreateIoCompletionPort() failed " - "during initialization: %s"), + "CreateIoCompletionPort() failed during initialization: %s", strbuf); } @@ -548,25 +536,19 @@ iocompletionport_update(isc_socket_t *sock) { if (hiocp == NULL) { DWORD errval = GetLastError(); strerror_r(errval, strbuf, sizeof(strbuf)); - isc_log_iwrite(isc_lctx, - ISC_LOGCATEGORY_GENERAL, - ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR, - isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_TOOMANYHANDLES, - "iocompletionport_update: failed to open" - " io completion port: %s", - strbuf); + isc_log_write(isc_lctx, + ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR, + "iocompletionport_update: failed to open io completion port: %s", + strbuf); /* XXXMLG temporary hack to make failures detected. * This function should return errors to the caller, not * exit here. */ FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_FAILED, - "CreateIoCompletionPort() failed " - "during initialization: %s"), - strbuf); + "CreateIoCompletionPort() failed during initialization: %s", + strbuf); } InterlockedIncrement(&sock->manager->iocp_total); @@ -614,9 +596,7 @@ initialise(void) { if (err != 0) { char strbuf[ISC_STRERRORSIZE]; strerror_r(err, strbuf, sizeof(strbuf)); - FATAL_ERROR(__FILE__, __LINE__, "WSAStartup() %s: %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed"), + FATAL_ERROR(__FILE__, __LINE__, "WSAStartup() failed: %s", strbuf); } /* @@ -806,8 +786,6 @@ queue_receive_request(isc_socket_t *sock) { } socket_log(__LINE__, sock, NULL, IOEVENT, - isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_DOIORECV, "queue_io_request: fd %d result %d error %d", sock->fd, Result, Error); @@ -838,7 +816,6 @@ manager_log(isc_socketmgr_t *sockmgr, isc_logcategory_t *category, static void socket_log(int lineno, isc_socket_t *sock, const isc_sockaddr_t *address, isc_logcategory_t *category, isc_logmodule_t *module, int level, - isc_msgcat_t *msgcat, int msgset, int message, const char *fmt, ...) { char msgbuf[2048]; @@ -854,15 +831,13 @@ socket_log(int lineno, isc_socket_t *sock, const isc_sockaddr_t *address, va_end(ap); if (address == NULL) { - isc_log_iwrite(isc_lctx, category, module, level, - msgcat, msgset, message, - "socket %p line %d: %s", sock, lineno, msgbuf); + isc_log_write(isc_lctx, category, module, level, + "socket %p line %d: %s", sock, lineno, msgbuf); } else { isc_sockaddr_format(address, peerbuf, sizeof(peerbuf)); - isc_log_iwrite(isc_lctx, category, module, level, - msgcat, msgset, message, - "socket %p line %d %s: %s", sock, lineno, - peerbuf, msgbuf); + isc_log_write(isc_lctx, category, module, level, + "socket %p line %d %s: %s", sock, lineno, + peerbuf, msgbuf); } } @@ -918,9 +893,7 @@ connection_reset_fix(SOCKET fd) { return (ISC_R_SUCCESS); else { UNEXPECTED_ERROR(__FILE__, __LINE__, - "WSAIoctl(SIO_UDP_CONNRESET, oldBehaviour) %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed")); + "WSAIoctl(SIO_UDP_CONNRESET, oldBehaviour) failed"); return (ISC_R_UNEXPECTED); } } @@ -958,8 +931,7 @@ build_msghdr_send(isc_socket_t *sock, isc_socketevent_t *dev, RUNTIME_CHECK(lpo->buf != NULL); socket_log(__LINE__, sock, NULL, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_ACCEPTLOCK, - "alloc_buffer %p %d", lpo->buf, write_count); + "alloc_buffer %p %d", lpo->buf, write_count); memmove(lpo->buf,(dev->region.base + dev->n), write_count); lpo->buflen = (unsigned int)write_count; @@ -1157,8 +1129,6 @@ fill_recv(isc_socket_t *sock, isc_socketevent_t *dev) { if (isc_sockaddr_getport(&dev->address) == 0) { if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) { socket_log(__LINE__, sock, &dev->address, IOEVENT, - isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_ZEROPORT, "dropping source port zero packet"); } sock->recvbuf.remaining = 0; @@ -1306,10 +1276,7 @@ startio_send(isc_socket_t *sock, isc_socketevent_t *dev, int *nbytes, if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) { strerror_r(*send_errno, strbuf, sizeof(strbuf)); socket_log(__LINE__, sock, NULL, IOEVENT, - isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_INTERNALSEND, - "startio_send: internal_sendmsg(%d) %d " - "bytes, err %d/%s", + "startio_send: internal_sendmsg(%d) %d bytes, err %d/%s", sock->fd, *nbytes, *send_errno, strbuf); } status = DOIO_HARD; @@ -1389,7 +1356,7 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type, */ isc_mutex_init(&sock->lock); - socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0, + socket_log(__LINE__, sock, NULL, EVENT, "allocated"); sock->magic = SOCKET_MAGIC; @@ -1443,9 +1410,8 @@ consistent(isc_socket_t *sock) { } if (crash) { - socket_log(__LINE__, sock, NULL, CREATION, isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_DESTROYING, "SOCKET INCONSISTENT: %s", - crash_reason); + socket_log(__LINE__, sock, NULL, CREATION, + "SOCKET INCONSISTENT: %s", crash_reason); sock_dump(sock); INSIST(crash == false); } @@ -1503,8 +1469,7 @@ free_socket(isc_socket_t **sockp, int lineno) { * Seems we can free the socket after all. */ manager = sock->manager; - socket_log(__LINE__, sock, NULL, CREATION, isc_msgcat, - ISC_MSGSET_SOCKET, ISC_MSG_DESTROYING, + socket_log(__LINE__, sock, NULL, CREATION, "freeing socket line %d fd %d lock %p semaphore %p", lineno, sock->fd, &sock->lock, sock->lock.LockSemaphore); @@ -1567,7 +1532,7 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, result = connection_reset_fix(sock->fd); if (result != ISC_R_SUCCESS) { socket_log(__LINE__, sock, - NULL, EVENT, NULL, 0, 0, + NULL, EVENT, "closed %d %d %d " "con_reset_fix_failed", sock->pending_recv, @@ -1612,11 +1577,7 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, default: strerror_r(socket_errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "socket() %s: %s", - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), + "socket() failed: %s", strbuf); return (ISC_R_UNEXPECTED); } @@ -1624,7 +1585,7 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, result = make_nonblock(sock->fd); if (result != ISC_R_SUCCESS) { - socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0, + socket_log(__LINE__, sock, NULL, EVENT, "closed %d %d %d make_nonblock_failed", sock->pending_recv, sock->pending_send, sock->references); @@ -1650,13 +1611,8 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, (char *)&on, sizeof(on)) < 0)) { strerror_r(WSAGetLastError(), strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d, IPV6_RECVPKTINFO) " - "%s: %s", sock->fd, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), - strbuf); + "setsockopt(%d, IPV6_RECVPKTINFO) failed: %s", + sock->fd, strbuf); } #else /* 2292 */ @@ -1666,12 +1622,7 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, strerror_r(WSAGetLastError(), strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, IPV6_PKTINFO) %s: %s", - sock->fd, - isc_msgcat_get(isc_msgcat, - ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, - "failed"), - strbuf); + sock->fd, strbuf); } #endif /* IPV6_RECVPKTINFO */ #endif /* defined(USE_CMSG) */ @@ -1728,8 +1679,7 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, InterlockedIncrement(&manager->totalSockets); UNLOCK(&manager->lock); - socket_log(__LINE__, sock, NULL, CREATION, isc_msgcat, - ISC_MSGSET_SOCKET, ISC_MSG_CREATED, + socket_log(__LINE__, sock, NULL, CREATION, "created %u type %u", sock->fd, type); return (ISC_R_SUCCESS); @@ -1791,7 +1741,7 @@ isc_socket_detach(isc_socket_t **socketp) { REQUIRE(sock->references > 0); sock->references--; - socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0, + socket_log(__LINE__, sock, NULL, EVENT, "detach_socket %d %d %d", sock->pending_recv, sock->pending_send, sock->references); @@ -1930,7 +1880,6 @@ internal_accept(isc_socket_t *sock, IoCompletionInfo *lpo, int accept_errno) { CONSISTENT(sock); socket_log(__LINE__, sock, NULL, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_ACCEPTLOCK, "internal_accept called"); INSIST(sock->listener); @@ -1969,7 +1918,6 @@ internal_accept(isc_socket_t *sock, IoCompletionInfo *lpo, int accept_errno) { nsock->pf = adev->address.type.sa.sa_family; socket_log(__LINE__, nsock, &nsock->address, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_ACCEPTLOCK, "internal_accept parent %p", sock); result = make_nonblock(adev->newsocket->fd); @@ -1996,7 +1944,6 @@ internal_accept(isc_socket_t *sock, IoCompletionInfo *lpo, int accept_errno) { UNLOCK(&nsock->manager->lock); socket_log(__LINE__, sock, &nsock->address, CREATION, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_ACCEPTEDCXN, "accepted_connection new_socket %p fd %d", nsock, nsock->fd); @@ -2093,7 +2040,6 @@ internal_connect(isc_socket_t *sock, IoCompletionInfo *lpo, int connect_errno) { result = ISC_R_SUCCESS; sock->connected = 1; socket_log(__LINE__, sock, &sock->address, IOEVENT, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_ACCEPTEDCXN, "internal_connect: success"); } @@ -2150,7 +2096,6 @@ internal_recv(isc_socket_t *sock, int nbytes) CONSISTENT(sock); socket_log(__LINE__, sock, NULL, IOEVENT, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_INTERNALRECV, "internal_recv: %d bytes received", nbytes); /* @@ -2206,13 +2151,11 @@ internal_send(isc_socket_t *sock, isc_socketevent_t *dev, CONSISTENT(sock); socket_log(__LINE__, sock, NULL, IOEVENT, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_INTERNALSEND, "internal_send: task got socket event %p", dev); if (lpo->buf != NULL) { socket_log(__LINE__, sock, NULL, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_ACCEPTLOCK, - "free_buffer %p", lpo->buf); + "free_buffer %p", lpo->buf); HeapFree(hHeapHandle, 0, lpo->buf); lpo->buf = NULL; @@ -2371,10 +2314,8 @@ SocketIoThread(LPVOID ThreadContext) { errval = GetLastError(); strerror_r(errval, strbuf, sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_FAILED, - "Can't set thread priority: %s"), - strbuf); + "Can't set thread priority: %s", + strbuf); } /* @@ -2437,7 +2378,7 @@ SocketIoThread(LPVOID ThreadContext) { sock->pending_send--; if (senddone_is_active(sock, lpo->dev)) { lpo->dev->result = isc_result; - socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0, + socket_log(__LINE__, sock, NULL, EVENT, "canceled_send"); send_senddone_event(sock, &lpo->dev); } @@ -2447,8 +2388,9 @@ SocketIoThread(LPVOID ThreadContext) { INSIST(sock->pending_iocp > 0); INSIST(sock->pending_accept > 0); - socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0, - "Accept: errstatus=%d isc_result=%d", errstatus, isc_result); + socket_log(__LINE__, sock, NULL, EVENT, + "Accept: errstatus=%d isc_result=%d", + errstatus, isc_result); if (acceptdone_is_active(sock, lpo->adev)) { if (restart_accept(sock, lpo) == ISC_R_SUCCESS) { @@ -2457,7 +2399,7 @@ SocketIoThread(LPVOID ThreadContext) { } else { errstatus = GetLastError(); isc_result = isc__errno2result(errstatus); - socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0, + socket_log(__LINE__, sock, NULL, EVENT, "restart_accept() failed: errstatus=%d isc_result=%d", errstatus, isc_result); } @@ -2471,7 +2413,7 @@ SocketIoThread(LPVOID ThreadContext) { lpo->adev->newsocket->references--; free_socket(&lpo->adev->newsocket, __LINE__); lpo->adev->result = isc_result; - socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0, + socket_log(__LINE__, sock, NULL, EVENT, "canceled_accept"); send_acceptdone_event(sock, &lpo->adev); } @@ -2483,7 +2425,7 @@ SocketIoThread(LPVOID ThreadContext) { INSIST(sock->pending_connect == 1); sock->pending_connect = 0; if (connectdone_is_active(sock, lpo->cdev)) { - socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0, + socket_log(__LINE__, sock, NULL, EVENT, "canceled_connect"); send_connectdone_abort(sock, isc_result); } @@ -2520,9 +2462,7 @@ SocketIoThread(LPVOID ThreadContext) { /* * Exit Completion Port Thread */ - manager_log(manager, TRACE, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_EXITING, "SocketIoThread exiting")); + manager_log(manager, TRACE, "SocketIoThread exiting"); return ((isc_threadresult_t)0); } @@ -2614,10 +2554,7 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) { * Wait for all sockets to be destroyed. */ while (!ISC_LIST_EMPTY(manager->socklist)) { - manager_log(manager, CREATION, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_SOCKETSREMAIN, - "sockets exist")); + manager_log(manager, CREATION, "sockets exist"); WAIT(&manager->shutdown_ok, &manager->lock); } @@ -2637,9 +2574,7 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) { if (isc_thread_join((isc_thread_t) manager->hIOCPThreads[i], NULL) != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_thread_join() for Completion Port %s", - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed")); + "isc_thread_join() for Completion Port failed"); } /* * Clean up. @@ -2675,7 +2610,7 @@ queue_receive_event(isc_socket_t *sock, isc_task_t *task, isc_socketevent_t *dev INSIST(!ISC_LINK_LINKED(dev, ev_link)); ISC_LIST_ENQUEUE(sock->recv_list, dev, ev_link); - socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0, + socket_log(__LINE__, sock, NULL, EVENT, "queue_receive_event: event %p -> task %p", dev, ntask); } @@ -2819,8 +2754,7 @@ socket_send(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, set_dev_address(address, sock, dev); if (pktinfo != NULL) { - socket_log(__LINE__, sock, NULL, TRACE, isc_msgcat, ISC_MSGSET_SOCKET, - ISC_MSG_PKTINFOPROVIDED, + socket_log(__LINE__, sock, NULL, TRACE, "pktinfo structure provided, ifindex %u (set to 0)", pktinfo->ipi6_ifindex); @@ -2852,7 +2786,7 @@ socket_send(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, INSIST(!ISC_LINK_LINKED(dev, ev_link)); ISC_LIST_ENQUEUE(sock->send_list, dev, ev_link); - socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0, + socket_log(__LINE__, sock, NULL, EVENT, "socket_send: event %p -> task %p", dev, ntask); @@ -2988,11 +2922,10 @@ isc_socket_bind(isc_socket_t *sock, const isc_sockaddr_t *sockaddr, if ((options & ISC_SOCKET_REUSEADDRESS) != 0 && isc_sockaddr_getport(sockaddr) != (in_port_t)0 && setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, - sizeof(on)) < 0) { + sizeof(on)) < 0) + { UNEXPECTED_ERROR(__FILE__, __LINE__, - "setsockopt(%d) %s", sock->fd, - isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, - ISC_MSG_FAILED, "failed")); + "setsockopt(%d) failed", sock->fd); /* Press on... */ } if (bind(sock->fd, &sockaddr->type.sa, sockaddr->length) < 0) { @@ -3015,8 +2948,7 @@ isc_socket_bind(isc_socket_t *sock, const isc_sockaddr_t *sockaddr, } } - socket_log(__LINE__, sock, sockaddr, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_BOUND, "bound"); + socket_log(__LINE__, sock, sockaddr, TRACE, "bound"); sock->bound = 1; UNLOCK(&sock->lock); @@ -3089,8 +3021,7 @@ isc_socket_listen(isc_socket_t *sock, unsigned int backlog) { } #endif - socket_log(__LINE__, sock, NULL, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_BOUND, "listening"); + socket_log(__LINE__, sock, NULL, TRACE, "listening"); sock->listener = 1; _set_state(sock, SOCK_LISTEN); @@ -3205,7 +3136,6 @@ isc_socket_accept(isc_socket_t *sock, iocompletionport_update(nsock); socket_log(__LINE__, sock, NULL, TRACE, - isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_BOUND, "accepting for nsock %p fd %d", nsock, nsock->fd); /* diff --git a/external/mpl/bind/dist/lib/isccc/include/isccc/lib.h b/external/mpl/bind/dist/lib/isccc/include/isccc/lib.h deleted file mode 100644 index aa46e86a2d0..00000000000 --- a/external/mpl/bind/dist/lib/isccc/include/isccc/lib.h +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: lib.h,v 1.2 2018/08/12 13:02:40 christos Exp $ */ - -/* - * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - * - * Portions Copyright (C) 2001 Nominum, Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -#ifndef ISCCC_LIB_H -#define ISCCC_LIB_H 1 - -/*! \file isccc/lib.h */ - -#include <isc/types.h> -#include <isc/lang.h> - -ISC_LANG_BEGINDECLS - -LIBISCCC_EXTERNAL_DATA extern isc_msgcat_t *isccc_msgcat; - -void -isccc_lib_initmsgcat(void); -/*% - * Initialize the ISCCC library's message catalog, isccc_msgcat, if it - * has not already been initialized. - */ - -ISC_LANG_ENDDECLS - -#endif /* ISCCC_LIB_H */ diff --git a/external/mpl/bind/dist/lib/isccc/lib.c b/external/mpl/bind/dist/lib/isccc/lib.c deleted file mode 100644 index 4be7c869faf..00000000000 --- a/external/mpl/bind/dist/lib/isccc/lib.c +++ /dev/null @@ -1,73 +0,0 @@ -/* $NetBSD: lib.c,v 1.2 2018/08/12 13:02:40 christos Exp $ */ - -/* - * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - * - * Portions Copyright (C) 2001 Nominum, Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -/*! \file */ - -#include <config.h> - -#include <stddef.h> - -#include <isc/once.h> -#include <isc/msgcat.h> -#include <isc/util.h> - -#include <isccc/lib.h> - -/*** - *** Globals - ***/ - -LIBISCCC_EXTERNAL_DATA isc_msgcat_t * isccc_msgcat = NULL; - - -/*** - *** Private - ***/ - -static isc_once_t msgcat_once = ISC_ONCE_INIT; - - -/*** - *** Functions - ***/ - -static void -open_msgcat(void) { - isc_msgcat_open("libisccc.cat", &isccc_msgcat); -} - -void -isccc_lib_initmsgcat(void) { - - /* - * Initialize the DNS library's message catalog, isccc_msgcat, if it - * has not already been initialized. - */ - - RUNTIME_CHECK(isc_once_do(&msgcat_once, open_msgcat) == ISC_R_SUCCESS); -} diff --git a/external/mpl/bind/dist/lib/isccc/result.c b/external/mpl/bind/dist/lib/isccc/result.c index ae2bc02d8f8..79f189ee3f2 100644 --- a/external/mpl/bind/dist/lib/isccc/result.c +++ b/external/mpl/bind/dist/lib/isccc/result.c @@ -1,4 +1,4 @@ -/* $NetBSD: result.c,v 1.2 2018/08/12 13:02:40 christos Exp $ */ +/* $NetBSD: result.c,v 1.3 2019/02/24 20:01:32 christos Exp $ */ /* * Portions Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -34,7 +34,6 @@ #include <isc/util.h> #include <isccc/result.h> -#include <isccc/lib.h> static const char *text[ISCCC_R_NRESULTS] = { "unknown version", /* 1 */ @@ -63,15 +62,13 @@ initialize_action(void) { isc_result_t result; result = isc_result_register(ISC_RESULTCLASS_ISCCC, ISCCC_R_NRESULTS, - text, isccc_msgcat, - ISCCC_RESULT_RESULTSET); + text, ISCCC_RESULT_RESULTSET); if (result != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_result_register() failed: %u", result); result = isc_result_registerids(ISC_RESULTCLASS_ISCCC, ISCCC_R_NRESULTS, - ids, isccc_msgcat, - ISCCC_RESULT_RESULTSET); + ids, ISCCC_RESULT_RESULTSET); if (result != ISC_R_SUCCESS) UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_result_registerids() failed: %u", result); @@ -79,7 +76,6 @@ initialize_action(void) { static void initialize(void) { - isccc_lib_initmsgcat(); RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS); } diff --git a/external/mpl/bind/dist/lib/isccc/tests/result_test.c b/external/mpl/bind/dist/lib/isccc/tests/result_test.c index e5860e140eb..124200a56ed 100644 --- a/external/mpl/bind/dist/lib/isccc/tests/result_test.c +++ b/external/mpl/bind/dist/lib/isccc/tests/result_test.c @@ -1,4 +1,4 @@ -/* $NetBSD: result_test.c,v 1.2 2019/01/09 16:55:18 christos Exp $ */ +/* $NetBSD: result_test.c,v 1.3 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -26,7 +26,6 @@ #include <isc/result.h> #include <isc/util.h> -#include <isccc/lib.h> #include <isccc/result.h> /* diff --git a/external/mpl/bind/dist/lib/isccfg/include/isccfg/cfg.h b/external/mpl/bind/dist/lib/isccfg/include/isccfg/cfg.h index 418b5c58021..5eec4f7111a 100644 --- a/external/mpl/bind/dist/lib/isccfg/include/isccfg/cfg.h +++ b/external/mpl/bind/dist/lib/isccfg/include/isccfg/cfg.h @@ -1,4 +1,4 @@ -/* $NetBSD: cfg.h,v 1.3 2019/01/09 16:55:19 christos Exp $ */ +/* $NetBSD: cfg.h,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -117,17 +117,6 @@ cfg_parse_file(cfg_parser_t *pctx, const char *file, isc_result_t cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer, - const cfg_type_t *type, cfg_obj_t **ret); -isc_result_t -cfg_parse_buffer2(cfg_parser_t *pctx, isc_buffer_t *buffer, - const char *file, const cfg_type_t *type, - cfg_obj_t **ret); -isc_result_t -cfg_parse_buffer3(cfg_parser_t *pctx, isc_buffer_t *buffer, - const char *file, unsigned int line, - const cfg_type_t *type, cfg_obj_t **ret); -isc_result_t -cfg_parse_buffer4(cfg_parser_t *pctx, isc_buffer_t *buffer, const char *file, unsigned int line, const cfg_type_t *type, unsigned int flags, cfg_obj_t **ret); diff --git a/external/mpl/bind/dist/lib/isccfg/include/isccfg/grammar.h b/external/mpl/bind/dist/lib/isccfg/include/isccfg/grammar.h index e62e2763b62..9d2a1dcf733 100644 --- a/external/mpl/bind/dist/lib/isccfg/include/isccfg/grammar.h +++ b/external/mpl/bind/dist/lib/isccfg/include/isccfg/grammar.h @@ -1,4 +1,4 @@ -/* $NetBSD: grammar.h,v 1.3 2019/01/09 16:55:19 christos Exp $ */ +/* $NetBSD: grammar.h,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -34,7 +34,7 @@ /*% Clause may occur multiple times (e.g., "zone") */ #define CFG_CLAUSEFLAG_MULTI 0x00000001 -/*% Clause is obsolete */ +/*% Clause is obsolete (logs a warning, but is not a fatal error) */ #define CFG_CLAUSEFLAG_OBSOLETE 0x00000002 /*% Clause is not implemented, and may never be */ #define CFG_CLAUSEFLAG_NOTIMP 0x00000004 @@ -57,8 +57,10 @@ /*% A configuration option that is ineffective due to * compile time options, but is harmless. */ #define CFG_CLAUSEFLAG_NOOP 0x00000200 -/*% Clause is obsolete in a future release */ +/*% Clause will be obsolete in a future release (logs a warning) */ #define CFG_CLAUSEFLAG_DEPRECATED 0x00000400 +/*% Clause has been obsolete so long that it's now a fatal error */ +#define CFG_CLAUSEFLAG_ANCIENT 0x00000800 /*% * Zone types for which a clause is valid: diff --git a/external/mpl/bind/dist/lib/isccfg/namedconf.c b/external/mpl/bind/dist/lib/isccfg/namedconf.c index 7d9dc719e11..421eef9bdc1 100644 --- a/external/mpl/bind/dist/lib/isccfg/namedconf.c +++ b/external/mpl/bind/dist/lib/isccfg/namedconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: namedconf.c,v 1.3 2019/01/09 16:55:18 christos Exp $ */ +/* $NetBSD: namedconf.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -234,19 +234,19 @@ static cfg_type_t cfg_type_portiplist = { &cfg_rep_tuple, portiplist_fields }; -/*% - * A public key, as in the "pubkey" statement. +/* + * Obsolete format for the "pubkey" statement. */ static cfg_tuplefielddef_t pubkey_fields[] = { - { "flags", &cfg_type_uint32, 0 }, - { "protocol", &cfg_type_uint32, 0 }, - { "algorithm", &cfg_type_uint32, 0 }, - { "key", &cfg_type_qstring, 0 }, - { NULL, NULL, 0 } + { "flags", &cfg_type_uint32, 0 }, + { "protocol", &cfg_type_uint32, 0 }, + { "algorithm", &cfg_type_uint32, 0 }, + { "key", &cfg_type_qstring, 0 }, + { NULL, NULL, 0 } }; static cfg_type_t cfg_type_pubkey = { - "pubkey", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, - &cfg_rep_tuple, pubkey_fields + "pubkey", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, + &cfg_rep_tuple, pubkey_fields }; /*% @@ -1025,7 +1025,7 @@ options_clauses[] = { { "cookie-secret", &cfg_type_sstring, CFG_CLAUSEFLAG_MULTI }, { "coresize", &cfg_type_size, 0 }, { "datasize", &cfg_type_size, 0 }, - { "deallocate-on-exit", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, + { "deallocate-on-exit", &cfg_type_boolean, CFG_CLAUSEFLAG_ANCIENT }, { "directory", &cfg_type_qstring, CFG_CLAUSEFLAG_CALLBACK }, #ifdef HAVE_DNSTAP { "dnstap-output", &cfg_type_dnstapoutput, 0 }, @@ -1041,7 +1041,7 @@ options_clauses[] = { #endif { "dscp", &cfg_type_uint32, 0 }, { "dump-file", &cfg_type_qstring, 0 }, - { "fake-iquery", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, + { "fake-iquery", &cfg_type_boolean, CFG_CLAUSEFLAG_ANCIENT }, { "files", &cfg_type_size, 0 }, { "flush-zones-on-shutdown", &cfg_type_boolean, 0 }, #ifdef HAVE_DNSTAP @@ -1075,10 +1075,10 @@ options_clauses[] = { CFG_CLAUSEFLAG_NOTCONFIGURED }, #endif /* HAVE_GEOIP */ { "geoip-use-ecs", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, - { "has-old-clients", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, + { "has-old-clients", &cfg_type_boolean, CFG_CLAUSEFLAG_ANCIENT }, { "heartbeat-interval", &cfg_type_uint32, 0 }, - { "host-statistics", &cfg_type_boolean, CFG_CLAUSEFLAG_NOTIMP }, - { "host-statistics-max", &cfg_type_uint32, CFG_CLAUSEFLAG_NOTIMP }, + { "host-statistics", &cfg_type_boolean, CFG_CLAUSEFLAG_ANCIENT }, + { "host-statistics-max", &cfg_type_uint32, CFG_CLAUSEFLAG_ANCIENT }, { "hostname", &cfg_type_qstringornone, 0 }, { "interface-interval", &cfg_type_ttlval, 0 }, { "keep-response-order", &cfg_type_bracketed_aml, 0 }, @@ -1090,8 +1090,8 @@ options_clauses[] = { { "max-rsa-exponent-size", &cfg_type_uint32, 0 }, { "memstatistics", &cfg_type_boolean, 0 }, { "memstatistics-file", &cfg_type_qstring, 0 }, - { "multiple-cnames", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, - { "named-xfer", &cfg_type_qstring, CFG_CLAUSEFLAG_OBSOLETE }, + { "multiple-cnames", &cfg_type_boolean, CFG_CLAUSEFLAG_ANCIENT }, + { "named-xfer", &cfg_type_qstring, CFG_CLAUSEFLAG_ANCIENT }, { "notify-rate", &cfg_type_uint32, 0 }, { "pid-file", &cfg_type_qstringornone, 0 }, { "port", &cfg_type_uint32, 0 }, @@ -1101,7 +1101,7 @@ options_clauses[] = { { "recursive-clients", &cfg_type_uint32, 0 }, { "reserved-sockets", &cfg_type_uint32, 0 }, { "secroots-file", &cfg_type_qstring, 0 }, - { "serial-queries", &cfg_type_uint32, CFG_CLAUSEFLAG_OBSOLETE }, + { "serial-queries", &cfg_type_uint32, CFG_CLAUSEFLAG_ANCIENT }, { "serial-query-rate", &cfg_type_uint32, 0 }, { "server-id", &cfg_type_serverid, 0 }, { "session-keyalg", &cfg_type_astring, 0 }, @@ -1111,7 +1111,7 @@ options_clauses[] = { { "stacksize", &cfg_type_size, 0 }, { "startup-notify-rate", &cfg_type_uint32, 0 }, { "statistics-file", &cfg_type_qstring, 0 }, - { "statistics-interval", &cfg_type_uint32, CFG_CLAUSEFLAG_NYI }, + { "statistics-interval", &cfg_type_uint32, CFG_CLAUSEFLAG_ANCIENT }, { "tcp-advertised-timeout", &cfg_type_uint32, 0 }, { "tcp-clients", &cfg_type_uint32, 0 }, { "tcp-idle-timeout", &cfg_type_uint32, 0 }, @@ -1126,8 +1126,8 @@ options_clauses[] = { { "transfers-in", &cfg_type_uint32, 0 }, { "transfers-out", &cfg_type_uint32, 0 }, { "transfers-per-ns", &cfg_type_uint32, 0 }, - { "treat-cr-as-space", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, - { "use-id-pool", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, + { "treat-cr-as-space", &cfg_type_boolean, CFG_CLAUSEFLAG_ANCIENT }, + { "use-id-pool", &cfg_type_boolean, CFG_CLAUSEFLAG_ANCIENT }, { "use-ixfr", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, { "use-v4-udp-ports", &cfg_type_bracketed_portlist, 0 }, { "use-v6-udp-ports", &cfg_type_bracketed_portlist, 0 }, @@ -1884,7 +1884,7 @@ view_clauses[] = { { "empty-contact", &cfg_type_astring, 0 }, { "empty-server", &cfg_type_astring, 0 }, { "empty-zones-enable", &cfg_type_boolean, 0 }, - { "fetch-glue", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, + { "fetch-glue", &cfg_type_boolean, CFG_CLAUSEFLAG_ANCIENT }, { "fetch-quota-params", &cfg_type_fetchquota, 0 }, { "fetches-per-server", &cfg_type_fetchesper, 0 }, { "fetches-per-zone", &cfg_type_fetchesper, 0 }, @@ -1899,8 +1899,7 @@ view_clauses[] = { #else { "lmdb-mapsize", &cfg_type_sizeval, CFG_CLAUSEFLAG_NOOP }, #endif - { "max-acache-size", &cfg_type_sizenodefault, - CFG_CLAUSEFLAG_OBSOLETE }, + { "max-acache-size", &cfg_type_sizenodefault, CFG_CLAUSEFLAG_OBSOLETE }, { "max-cache-size", &cfg_type_sizeorpercent, 0 }, { "max-cache-ttl", &cfg_type_ttlval, 0 }, { "max-clients-per-query", &cfg_type_uint32, 0 }, @@ -1912,7 +1911,7 @@ view_clauses[] = { { "message-compression", &cfg_type_boolean, 0 }, { "min-cache-ttl", &cfg_type_ttlval, 0 }, { "min-ncache-ttl", &cfg_type_ttlval, 0 }, - { "min-roots", &cfg_type_uint32, CFG_CLAUSEFLAG_NOTIMP }, + { "min-roots", &cfg_type_uint32, CFG_CLAUSEFLAG_ANCIENT }, { "minimal-any", &cfg_type_boolean, 0 }, { "minimal-responses", &cfg_type_minimal, 0 }, { "new-zones-directory", &cfg_type_qstring, 0 }, @@ -1945,7 +1944,7 @@ view_clauses[] = { { "resolver-retry-interval", &cfg_type_uint32, 0 }, { "response-padding", &cfg_type_resppadding, 0 }, { "response-policy", &cfg_type_rpz, 0 }, - { "rfc2308-type1", &cfg_type_boolean, CFG_CLAUSEFLAG_NYI }, + { "rfc2308-type1", &cfg_type_boolean, CFG_CLAUSEFLAG_ANCIENT }, { "root-delegation-only", &cfg_type_optional_exclude, 0 }, { "root-key-sentinel", &cfg_type_boolean, 0 }, { "rrset-order", &cfg_type_rrsetorder, 0 }, @@ -1956,7 +1955,7 @@ view_clauses[] = { { "stale-answer-ttl", &cfg_type_ttlval, 0 }, { "suppress-initial-notify", &cfg_type_boolean, CFG_CLAUSEFLAG_NYI }, { "synth-from-dnssec", &cfg_type_boolean, 0 }, - { "topology", &cfg_type_bracketed_aml, CFG_CLAUSEFLAG_NOTIMP }, + { "topology", &cfg_type_bracketed_aml, CFG_CLAUSEFLAG_ANCIENT }, { "transfer-format", &cfg_type_transferformat, 0 }, { "trust-anchor-telemetry", &cfg_type_boolean, CFG_CLAUSEFLAG_EXPERIMENTAL }, @@ -2088,7 +2087,7 @@ zone_clauses[] = { CFG_ZONE_MASTER | CFG_ZONE_SLAVE }, { "maintain-ixfr-base", &cfg_type_boolean, - CFG_CLAUSEFLAG_OBSOLETE + CFG_CLAUSEFLAG_ANCIENT }, { "masterfile-format", &cfg_type_masterformat, CFG_ZONE_MASTER | CFG_ZONE_SLAVE | CFG_ZONE_MIRROR | @@ -2099,7 +2098,7 @@ zone_clauses[] = { CFG_ZONE_STUB | CFG_ZONE_REDIRECT }, { "max-ixfr-log-size", &cfg_type_size, - CFG_CLAUSEFLAG_OBSOLETE + CFG_CLAUSEFLAG_ANCIENT }, { "max-journal-size", &cfg_type_size, CFG_ZONE_MASTER | CFG_ZONE_SLAVE | CFG_ZONE_MIRROR @@ -2245,13 +2244,13 @@ zone_only_clauses[] = { CFG_ZONE_INVIEW }, { "ixfr-base", &cfg_type_qstring, - CFG_CLAUSEFLAG_OBSOLETE + CFG_CLAUSEFLAG_ANCIENT }, { "ixfr-from-differences", &cfg_type_boolean, CFG_ZONE_MASTER | CFG_ZONE_SLAVE | CFG_ZONE_MIRROR }, { "ixfr-tmp-file", &cfg_type_qstring, - CFG_CLAUSEFLAG_OBSOLETE + CFG_CLAUSEFLAG_ANCIENT }, { "journal", &cfg_type_qstring, CFG_ZONE_MASTER | CFG_ZONE_SLAVE | CFG_ZONE_MIRROR @@ -2261,7 +2260,7 @@ zone_only_clauses[] = { CFG_ZONE_REDIRECT }, { "pubkey", &cfg_type_pubkey, - CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_OBSOLETE + CFG_CLAUSEFLAG_ANCIENT }, { "server-addresses", &cfg_type_bracketed_netaddrlist, CFG_ZONE_STATICSTUB diff --git a/external/mpl/bind/dist/lib/isccfg/parser.c b/external/mpl/bind/dist/lib/isccfg/parser.c index a78702c0f59..0ba1ae78a4d 100644 --- a/external/mpl/bind/dist/lib/isccfg/parser.c +++ b/external/mpl/bind/dist/lib/isccfg/parser.c @@ -1,4 +1,4 @@ -/* $NetBSD: parser.c,v 1.3 2019/01/09 16:55:18 christos Exp $ */ +/* $NetBSD: parser.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -624,32 +624,9 @@ cfg_parse_file(cfg_parser_t *pctx, const char *filename, isc_result_t cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer, - const cfg_type_t *type, cfg_obj_t **ret) -{ - return (cfg_parse_buffer4(pctx, buffer, NULL, 0, type, 0, ret)); -} - -isc_result_t -cfg_parse_buffer2(cfg_parser_t *pctx, isc_buffer_t *buffer, - const char *file, const cfg_type_t *type, - cfg_obj_t **ret) -{ - return (cfg_parse_buffer4(pctx, buffer, file, 0, type, 0, ret)); -} - -isc_result_t -cfg_parse_buffer3(cfg_parser_t *pctx, isc_buffer_t *buffer, - const char *file, unsigned int line, - const cfg_type_t *type, cfg_obj_t **ret) -{ - return (cfg_parse_buffer4(pctx, buffer, file, line, type, 0, ret)); -} - -isc_result_t -cfg_parse_buffer4(cfg_parser_t *pctx, isc_buffer_t *buffer, - const char *file, unsigned int line, - const cfg_type_t *type, unsigned int flags, - cfg_obj_t **ret) + const char *file, unsigned int line, + const cfg_type_t *type, unsigned int flags, + cfg_obj_t **ret) { isc_result_t result; @@ -2017,24 +1994,37 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) /* Clause is known. */ + /* Issue fatal errors if appropriate */ + if ((clause->flags & CFG_CLAUSEFLAG_ANCIENT) != 0) { + cfg_parser_error(pctx, 0, + "option '%s' no longer exists", + clause->name); + CHECK(ISC_R_FAILURE); + } + /* Issue warnings if appropriate */ if ((pctx->flags & CFG_PCTX_NODEPRECATED) == 0 && (clause->flags & CFG_CLAUSEFLAG_DEPRECATED) != 0) { - cfg_parser_warning(pctx, 0, "option '%s' is deprecated", + cfg_parser_warning(pctx, 0, + "option '%s' is deprecated", clause->name); } if ((clause->flags & CFG_CLAUSEFLAG_OBSOLETE) != 0) { - cfg_parser_warning(pctx, 0, "option '%s' is obsolete", + cfg_parser_warning(pctx, 0, + "option '%s' is obsolete and " + "should be removed ", clause->name); } if ((clause->flags & CFG_CLAUSEFLAG_NOTIMP) != 0) { - cfg_parser_warning(pctx, 0, "option '%s' is " - "not implemented", clause->name); + cfg_parser_warning(pctx, 0, + "option '%s' is not implemented", + clause->name); } if ((clause->flags & CFG_CLAUSEFLAG_NYI) != 0) { - cfg_parser_warning(pctx, 0, "option '%s' is " - "not implemented", clause->name); + cfg_parser_warning(pctx, 0, + "option '%s' is not implemented", + clause->name); } if ((clause->flags & CFG_CLAUSEFLAG_NOOP) != 0) { cfg_parser_warning(pctx, 0, "option '%s' was not " @@ -2043,11 +2033,10 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) } if ((clause->flags & CFG_CLAUSEFLAG_NOTCONFIGURED) != 0) { - cfg_parser_warning(pctx, 0, "option '%s' was not " + cfg_parser_error(pctx, 0, "option '%s' was not " "enabled at compile time", clause->name); - result = ISC_R_FAILURE; - goto cleanup; + CHECK(ISC_R_FAILURE); } /* @@ -2103,8 +2092,9 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) callback)); CHECK(parse_semicolon(pctx)); } else if (result == ISC_R_SUCCESS) { - cfg_parser_error(pctx, CFG_LOG_NEAR, "'%s' redefined", - clause->name); + cfg_parser_error(pctx, CFG_LOG_NEAR, + "'%s' redefined", + clause->name); result = ISC_R_EXISTS; goto cleanup; } else { @@ -2301,6 +2291,7 @@ static struct flagtext { { CFG_CLAUSEFLAG_EXPERIMENTAL, "experimental" }, { CFG_CLAUSEFLAG_NOOP, "non-operational" }, { CFG_CLAUSEFLAG_DEPRECATED, "deprecated" }, + { CFG_CLAUSEFLAG_ANCIENT, "ancient" }, { 0, NULL } }; diff --git a/external/mpl/bind/dist/lib/isccfg/tests/parser_test.c b/external/mpl/bind/dist/lib/isccfg/tests/parser_test.c index 3c081424401..11d5042f55f 100644 --- a/external/mpl/bind/dist/lib/isccfg/tests/parser_test.c +++ b/external/mpl/bind/dist/lib/isccfg/tests/parser_test.c @@ -1,4 +1,4 @@ -/* $NetBSD: parser_test.c,v 1.3 2019/01/09 16:55:19 christos Exp $ */ +/* $NetBSD: parser_test.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -120,8 +120,8 @@ parse_buffer_test(void **state) { result = cfg_parser_create(mctx, lctx, &p1); assert_int_equal(result, ISC_R_SUCCESS); - result = cfg_parse_buffer3(p1, &buf1, "text1", 0, - &cfg_type_namedconf, &c1); + result = cfg_parse_buffer(p1, &buf1, "text1", 0, + &cfg_type_namedconf, 0, &c1); assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(p1->line, 5); @@ -132,8 +132,8 @@ parse_buffer_test(void **state) { result = cfg_parser_create(mctx, lctx, &p2); assert_int_equal(result, ISC_R_SUCCESS); - result = cfg_parse_buffer3(p2, &buf2, "text2", 100, - &cfg_type_namedconf, &c2); + result = cfg_parse_buffer(p2, &buf2, "text2", 100, + &cfg_type_namedconf, 0, &c2); assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(p2->line, 104); diff --git a/external/mpl/bind/dist/lib/ns/client.c b/external/mpl/bind/dist/lib/ns/client.c index 1d34bbb92ff..bc7c7ed9cb8 100644 --- a/external/mpl/bind/dist/lib/ns/client.c +++ b/external/mpl/bind/dist/lib/ns/client.c @@ -1,4 +1,4 @@ -/* $NetBSD: client.c,v 1.3 2019/01/09 16:55:19 christos Exp $ */ +/* $NetBSD: client.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -2081,6 +2081,12 @@ process_keytag(ns_client_t *client, isc_buffer_t *buf, size_t optlen) { return (DNS_R_OPTERR); } + /* Silently drop additional keytag options. */ + if (client->keytag != NULL) { + isc_buffer_forward(buf, (unsigned int)optlen); + return (ISC_R_SUCCESS); + } + client->keytag = isc_mem_get(client->mctx, optlen); if (client->keytag != NULL) { client->keytag_len = (uint16_t)optlen; @@ -2447,14 +2453,18 @@ ns__client_request(isc_task_t *task, isc_event_t *event) { * Parsing the request failed. Send a response * (typically FORMERR or SERVFAIL). */ - if (result == DNS_R_OPTERR) + if (result == DNS_R_OPTERR) { (void)ns_client_addopt(client, client->message, &client->opt); + } ns_client_log(client, NS_LOGCATEGORY_CLIENT, NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(1), "message parsing failed: %s", isc_result_totext(result)); + if (result == ISC_R_NOSPACE) { + result = DNS_R_FORMERR; + } ns_client_error(client, result); return; } diff --git a/external/mpl/bind/dist/lib/ns/hooks.c b/external/mpl/bind/dist/lib/ns/hooks.c index e171cf94457..4a1ed7bad8a 100644 --- a/external/mpl/bind/dist/lib/ns/hooks.c +++ b/external/mpl/bind/dist/lib/ns/hooks.c @@ -1,4 +1,4 @@ -/* $NetBSD: hooks.c,v 1.2 2019/01/09 16:55:19 christos Exp $ */ +/* $NetBSD: hooks.c,v 1.3 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -111,7 +111,7 @@ load_plugin(isc_mem_t *mctx, const char *modpath, ns_plugin_t **pluginp) { REQUIRE(pluginp != NULL && *pluginp == NULL); flags = RTLD_LAZY | RTLD_LOCAL; -#ifdef RTLD_DEEPBIND +#if defined(RTLD_DEEPBIND) && !__SANITIZE_ADDRESS__ flags |= RTLD_DEEPBIND; #endif diff --git a/external/mpl/bind/dist/lib/ns/include/ns/client.h b/external/mpl/bind/dist/lib/ns/include/ns/client.h index 60c29e1a9bc..11796da271c 100644 --- a/external/mpl/bind/dist/lib/ns/include/ns/client.h +++ b/external/mpl/bind/dist/lib/ns/include/ns/client.h @@ -1,4 +1,4 @@ -/* $NetBSD: client.h,v 1.3 2019/01/09 16:55:19 christos Exp $ */ +/* $NetBSD: client.h,v 1.4 2019/02/24 20:01:33 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -85,9 +85,9 @@ /*% nameserver client structure */ struct ns_client { unsigned int magic; - isc_mem_t * mctx; - ns_server_t * sctx; - ns_clientmgr_t * manager; + isc_mem_t *mctx; + ns_server_t *sctx; + ns_clientmgr_t *manager; int state; int newstate; int naccepts; @@ -97,7 +97,7 @@ struct ns_client { int nupdates; int nctls; int references; - bool needshutdown; /* + bool needshutdown; /* * Used by clienttest to get * the client to go from * inactive to free state @@ -105,26 +105,26 @@ struct ns_client { * client's task. */ unsigned int attributes; - isc_task_t * task; - dns_view_t * view; - dns_dispatch_t * dispatch; - isc_socket_t * udpsocket; - isc_socket_t * tcplistener; - isc_socket_t * tcpsocket; - unsigned char * tcpbuf; + isc_task_t *task; + dns_view_t *view; + dns_dispatch_t *dispatch; + isc_socket_t *udpsocket; + isc_socket_t *tcplistener; + isc_socket_t *tcpsocket; + unsigned char *tcpbuf; dns_tcpmsg_t tcpmsg; - bool tcpmsg_valid; - isc_timer_t * timer; - isc_timer_t * delaytimer; - bool timerset; - dns_message_t * message; - isc_socketevent_t * sendevent; - isc_socketevent_t * recvevent; - unsigned char * recvbuf; - dns_rdataset_t * opt; + bool tcpmsg_valid; + isc_timer_t *timer; + isc_timer_t *delaytimer; + bool timerset; + dns_message_t *message; + isc_socketevent_t *sendevent; + isc_socketevent_t *recvevent; + unsigned char *recvbuf; + dns_rdataset_t *opt; uint16_t udpsize; uint16_t extflags; - int16_t ednsversion; /* -1 noedns */ + int16_t ednsversion; /* -1 noedns */ void (*next)(ns_client_t *); void (*shutdown)(void *arg, isc_result_t result); void *shutdown_arg; @@ -132,20 +132,20 @@ struct ns_client { isc_time_t requesttime; isc_stdtime_t now; isc_time_t tnow; - dns_name_t signername; /*%< [T]SIG key name */ - dns_name_t * signer; /*%< NULL if not valid sig */ - bool mortal; /*%< Die after handling request */ - bool pipelined; /*%< TCP queries not in sequence */ + dns_name_t signername; /*%< [T]SIG key name */ + dns_name_t *signer; /*%< NULL if not valid sig */ + bool mortal; /*%< Die after handling request */ + bool pipelined; /*%< TCP queries not in sequence */ isc_quota_t *tcpquota; isc_quota_t *recursionquota; ns_interface_t *interface; isc_sockaddr_t peeraddr; - bool peeraddr_valid; + bool peeraddr_valid; isc_netaddr_t destaddr; isc_sockaddr_t destsockaddr; - dns_ecs_t ecs; /*%< EDNS client subnet sent by client */ + dns_ecs_t ecs; /*%< EDNS client subnet sent by client */ struct in6_pktinfo pktinfo; isc_dscp_t dscp; diff --git a/external/mpl/bind/dist/lib/ns/include/ns/hooks.h b/external/mpl/bind/dist/lib/ns/include/ns/hooks.h index d5edd3c95bc..9572ac9b678 100644 --- a/external/mpl/bind/dist/lib/ns/include/ns/hooks.h +++ b/external/mpl/bind/dist/lib/ns/include/ns/hooks.h @@ -1,4 +1,4 @@ -/* $NetBSD: hooks.h,v 1.2 2019/01/09 16:55:19 christos Exp $ */ +/* $NetBSD: hooks.h,v 1.3 2019/02/24 20:01:33 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -87,8 +87,14 @@ * In order for a hook action to be called for a given hook, a pointer to that * action function (along with an optional pointer to action-specific data) has * to be inserted into the relevant hook table entry for that hook using an - * ns_hook_add() call. If multiple actions are set up at a single hook point, - * they are processed in FIFO order. + * ns_hook_add() call. If multiple actions are set up at a single hook point + * (e.g. by multiple plugin modules), they are processed in FIFO order, that is + * they are performed in the same order in which their relevant ns_hook_add() + * calls were issued. Since the configuration is loaded from a single thread, + * this means that multiple actions at a single hook point are determined by + * the order in which the relevant plugin modules were declared in the + * configuration file(s). The hook API currently does not support changing + * this order. * * As an example, consider the following hypothetical function in query.c: * diff --git a/external/mpl/bind/dist/lib/ns/include/ns/lib.h b/external/mpl/bind/dist/lib/ns/include/ns/lib.h index d6ccbebfa2b..0702e780b0b 100644 --- a/external/mpl/bind/dist/lib/ns/include/ns/lib.h +++ b/external/mpl/bind/dist/lib/ns/include/ns/lib.h @@ -1,4 +1,4 @@ -/* $NetBSD: lib.h,v 1.2 2018/08/12 13:02:41 christos Exp $ */ +/* $NetBSD: lib.h,v 1.3 2019/02/24 20:01:33 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -11,8 +11,7 @@ * information regarding copyright ownership. */ -#ifndef NS_LIB_H -#define NS_LIB_H 1 +#pragma once /*! \file include/ns/lib.h */ @@ -22,7 +21,6 @@ ISC_LANG_BEGINDECLS LIBNS_EXTERNAL_DATA extern unsigned int ns_pps; -LIBNS_EXTERNAL_DATA extern isc_msgcat_t *ns_msgcat; isc_result_t ns_lib_init(void); @@ -37,5 +35,3 @@ ns_lib_shutdown(void); */ ISC_LANG_ENDDECLS - -#endif /* NS_LIB_H */ diff --git a/external/mpl/bind/dist/lib/ns/lib.c b/external/mpl/bind/dist/lib/ns/lib.c index ec3956aa17e..7701df52c28 100644 --- a/external/mpl/bind/dist/lib/ns/lib.c +++ b/external/mpl/bind/dist/lib/ns/lib.c @@ -1,4 +1,4 @@ -/* $NetBSD: lib.c,v 1.3 2019/01/09 16:55:19 christos Exp $ */ +/* $NetBSD: lib.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -19,7 +19,6 @@ #include <stddef.h> #include <isc/mem.h> -#include <isc/msgcat.h> #include <isc/mutex.h> #include <isc/once.h> #include <isc/util.h> diff --git a/external/mpl/bind/dist/lib/ns/query.c b/external/mpl/bind/dist/lib/ns/query.c index 4f3dd882dd3..0b766ece5fc 100644 --- a/external/mpl/bind/dist/lib/ns/query.c +++ b/external/mpl/bind/dist/lib/ns/query.c @@ -1,4 +1,4 @@ -/* $NetBSD: query.c,v 1.3 2019/01/09 16:55:19 christos Exp $ */ +/* $NetBSD: query.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -151,7 +151,7 @@ do { \ #define NOQNAME(r) (((r)->attributes & \ DNS_RDATASETATTR_NOQNAME) != 0) -/*% Does the rdataset 'r' contains a stale answer? */ +/*% Does the rdataset 'r' contain a stale answer? */ #define STALE(r) (((r)->attributes & \ DNS_RDATASETATTR_STALE) != 0) @@ -3670,40 +3670,7 @@ rpz_rewrite_name(ns_client_t *client, dns_name_t *trig_name, (st->m.type == rpz_type && 0 >= dns_name_compare(p_name, st->p_name)))) continue; -#if 0 - /* - * This code would block a customer reported information - * leak of rpz rules by rewriting requests in the - * rpz-ip, rpz-nsip, rpz-nsdname,and rpz-passthru TLDs. - * Without this code, a bad guy could request - * 24.0.3.2.10.rpz-ip. to find the policy rule for - * 10.2.3.0/14. It is an insignificant leak and this - * code is not worth its cost, because the bad guy - * could publish "evil.com A 10.2.3.4" and request - * evil.com to get the same information. - * Keep code with "#if 0" in case customer demand - * is irresistible. - * - * We have the less frequent case of a triggered - * policy. Check that we have not trigger on one - * of the pretend RPZ TLDs. - * This test would make it impossible to rewrite - * names in TLDs that start with "rpz-" should - * ICANN ever allow such TLDs. - */ - unsigned int labels; - labels = dns_name_countlabels(trig_name); - if (labels >= 2) { - dns_label_t label; - - dns_name_getlabel(trig_name, labels-2, &label); - if (label.length >= sizeof(DNS_RPZ_PREFIX)-1 && - strncasecmp((const char *)label.base+1, - DNS_RPZ_PREFIX, - sizeof(DNS_RPZ_PREFIX)-1) == 0) - continue; - } -#endif + if (rpz->policy != DNS_RPZ_POLICY_DISABLED) { CTRACE(ISC_LOG_DEBUG(3), "rpz_rewrite_name: rpz_save_p"); @@ -5624,38 +5591,37 @@ ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname, ns_statscounter_recursclients); if (result == ISC_R_SOFTQUOTA) { - static isc_stdtime_t last = 0; + static atomic_uint_fast32_t last = 0; isc_stdtime_t now; isc_stdtime_get(&now); - if (now != last) { - last = now; + if (now != atomic_load_relaxed(&last)) { + atomic_store_relaxed(&last, now); ns_client_log(client, NS_LOGCATEGORY_CLIENT, - NS_LOGMODULE_QUERY, - ISC_LOG_WARNING, - "recursive-clients soft limit " - "exceeded (%d/%d/%d), " - "aborting oldest query", - client->recursionquota->used, - client->recursionquota->soft, - client->recursionquota->max); + NS_LOGMODULE_QUERY, ISC_LOG_WARNING, + "recursive-clients soft limit " + "exceeded (%u/%u/%u), " + "aborting oldest query", + isc_quota_getused(client->recursionquota), + isc_quota_getsoft(client->recursionquota), + isc_quota_getmax(client->recursionquota)); } ns_client_killoldestquery(client); result = ISC_R_SUCCESS; } else if (result == ISC_R_QUOTA) { - static isc_stdtime_t last = 0; + static atomic_uint_fast32_t last = 0; isc_stdtime_t now; isc_stdtime_get(&now); - if (now != last) { - last = now; + if (now != atomic_load_relaxed(&last)) { + ns_server_t *sctx = client->sctx; + atomic_store_relaxed(&last, now); ns_client_log(client, NS_LOGCATEGORY_CLIENT, - NS_LOGMODULE_QUERY, - ISC_LOG_WARNING, - "no more recursive clients " - "(%d/%d/%d): %s", - client->sctx->recursionquota.used, - client->sctx->recursionquota.soft, - client->sctx->recursionquota.max, - isc_result_totext(result)); + NS_LOGMODULE_QUERY, ISC_LOG_WARNING, + "no more recursive clients " + "(%u/%u/%u): %s", + isc_quota_getused(&sctx->recursionquota), + isc_quota_getsoft(&sctx->recursionquota), + isc_quota_getmax(&sctx->recursionquota), + isc_result_totext(result)); } ns_client_killoldestquery(client); } diff --git a/external/mpl/bind/dist/lib/ns/update.c b/external/mpl/bind/dist/lib/ns/update.c index 84cf7e64be9..5b120056920 100644 --- a/external/mpl/bind/dist/lib/ns/update.c +++ b/external/mpl/bind/dist/lib/ns/update.c @@ -1,4 +1,4 @@ -/* $NetBSD: update.c,v 1.3 2019/01/09 16:55:19 christos Exp $ */ +/* $NetBSD: update.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -800,8 +800,10 @@ static isc_result_t cname_compatibility_action(void *data, dns_rdataset_t *rrset) { UNUSED(data); if (rrset->type != dns_rdatatype_cname && - ! dns_rdatatype_isdnssec(rrset->type)) + ! dns_rdatatype_atcname(rrset->type)) + { return (ISC_R_EXISTS); + } return (ISC_R_SUCCESS); } @@ -1962,7 +1964,7 @@ check_dnssec(ns_client_t *client, dns_zone_t *zone, dns_db_t *db, if (tuple->rdata.type == dns_rdatatype_dnskey) { uint8_t alg; alg = tuple->rdata.data[3]; - if (alg == DST_ALG_RSAMD5 || alg == DST_ALG_RSASHA1) { + if (alg == DST_ALG_RSASHA1) { nseconly = true; break; } @@ -2445,7 +2447,7 @@ add_signing_records(dns_db_t *db, dns_rdatatype_t privatetype, dns_rdata_toregion(&tuple->rdata, &r); - keyid = dst_region_computeid(&r, dnskey.algorithm); + keyid = dst_region_computeid(&r); buf[0] = dnskey.algorithm; buf[1] = (keyid & 0xff00) >> 8; @@ -2854,7 +2856,7 @@ update_action(isc_task_t *task, isc_event_t *event) { dns_rdatatype_cname, 0, &flag)); if (flag && - ! dns_rdatatype_isdnssec(rdata.type)) + ! dns_rdatatype_atcname(rdata.type)) { update_log(client, zone, LOGLEVEL_PROTOCOL, @@ -3285,7 +3287,7 @@ update_action(isc_task_t *task, isc_event_t *event) { dns_rdata_toregion(&tuple->rdata, &r); algorithm = dnskey.algorithm; - keyid = dst_region_computeid(&r, algorithm); + keyid = dst_region_computeid(&r); result = dns_zone_signwithkey(zone, algorithm, keyid, (tuple->op == DNS_DIFFOP_DEL)); diff --git a/external/mpl/bind/dist/lib/ns/xfrout.c b/external/mpl/bind/dist/lib/ns/xfrout.c index ecd3213b6ea..a2cf278da9e 100644 --- a/external/mpl/bind/dist/lib/ns/xfrout.c +++ b/external/mpl/bind/dist/lib/ns/xfrout.c @@ -1,4 +1,4 @@ -/* $NetBSD: xfrout.c,v 1.3 2019/01/09 16:55:19 christos Exp $ */ +/* $NetBSD: xfrout.c,v 1.4 2019/02/24 20:01:32 christos Exp $ */ /* * Copyright (C) Internet Systems Consortium, Inc. ("ISC") @@ -647,11 +647,22 @@ static rrstream_methods_t compound_rrstream_methods = { }; /**************************************************************************/ -/* + +/*% + * Structure holding outgoing transfer statistics + */ +struct xfr_stats { + uint64_t nmsg; /*%< Number of messages sent */ + uint64_t nrecs; /*%< Number of records sent */ + uint64_t nbytes; /*%< Number of bytes sent */ + isc_time_t start; /*%< Start time of the transfer */ + isc_time_t end; /*%< End time of the transfer */ +}; + +/*% * An 'xfrout_ctx_t' contains the state of an outgoing AXFR or IXFR * in progress. */ - typedef struct { isc_mem_t *mctx; ns_client_t *client; @@ -664,21 +675,22 @@ typedef struct { dns_dbversion_t *ver; isc_quota_t *quota; rrstream_t *stream; /* The XFR RR stream */ - bool end_of_stream; /* EOS has been reached */ + bool question_added; /* QUESTION section sent? */ + bool end_of_stream; /* EOS has been reached */ isc_buffer_t buf; /* Buffer for message owner names and rdatas */ isc_buffer_t txlenbuf; /* Transmit length buffer */ isc_buffer_t txbuf; /* Transmit message buffer */ void *txmem; unsigned int txmemlen; - unsigned int nmsg; /* Number of messages sent */ dns_tsigkey_t *tsigkey; /* Key used to create TSIG */ isc_buffer_t *lasttsig; /* the last TSIG */ - bool verified_tsig; /* verified request MAC */ - bool many_answers; + bool verified_tsig; /* verified request MAC */ + bool many_answers; int sends; /* Send in progress */ - bool shuttingdown; + bool shuttingdown; const char *mnemonic; /* Style of transfer */ + struct xfr_stats stats; /*%< Transfer statistics */ } xfrout_ctx_t; static isc_result_t @@ -807,12 +819,12 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) { result = dns_zt_find(client->view->zonetable, question_name, 0, NULL, &zone); - if (result != ISC_R_SUCCESS) { + if (result != ISC_R_SUCCESS || dns_zone_gettype(zone) == dns_zone_dlz) { /* - * Normal zone table does not have a match. - * Try the DLZ database + * The normal zone table does not have a match, or this is + * marked in the zone table as a DLZ zone. Check the DLZ + * databases for a match. */ - // Temporary: only searching the first DLZ database if (! ISC_LIST_EMPTY(client->view->dlz_searched)) { result = dns_dlzallowzonexfr(client->view, question_name, @@ -1182,11 +1194,11 @@ xfrout_ctx_create(isc_mem_t *mctx, ns_client_t *client, unsigned int id, dns_zone_attach(zone, &xfr->zone); dns_db_attach(db, &xfr->db); dns_db_attachversion(db, ver, &xfr->ver); + xfr->question_added = false; xfr->end_of_stream = false; xfr->tsigkey = tsigkey; xfr->lasttsig = lasttsig; xfr->verified_tsig = verified_tsig; - xfr->nmsg = 0; xfr->many_answers = many_answers; xfr->sends = 0; xfr->shuttingdown = false; @@ -1198,6 +1210,11 @@ xfrout_ctx_create(isc_mem_t *mctx, ns_client_t *client, unsigned int id, xfr->stream = NULL; xfr->quota = NULL; + xfr->stats.nmsg = 0; + xfr->stats.nrecs = 0; + xfr->stats.nbytes = 0; + isc_time_now(&xfr->stats.start); + /* * Allocate a temporary buffer for the uncompressed response * message data. The size should be no more than 65535 bytes @@ -1346,7 +1363,7 @@ sendstream(xfrout_ctx_t *xfr) { * BIND 8.2.1 will not recognize an IXFR if it does not * have a question section. */ - if (xfr->nmsg == 0) { + if (!xfr->question_added) { dns_name_t *qname = NULL; isc_region_t r; @@ -1378,6 +1395,7 @@ sendstream(xfrout_ctx_t *xfr) { ISC_LIST_APPEND(qname->list, qrdataset, link); dns_message_addname(msg, qname, DNS_SECTION_QUESTION); + xfr->question_added = true; } else { /* * Reserve space for the 12-byte message header @@ -1482,6 +1500,8 @@ sendstream(xfrout_ctx_t *xfr) { dns_message_addname(msg, msgname, DNS_SECTION_ANSWER); msgname = NULL; + xfr->stats.nrecs++; + result = xfr->stream->methods->next(xfr->stream); if (result == ISC_R_NOMORE) { xfr->end_of_stream = true; @@ -1536,8 +1556,6 @@ sendstream(xfrout_ctx_t *xfr) { /* Advance lasttsig to be the last TSIG generated */ CHECK(dns_message_getquerytsig(msg, xfr->mctx, &xfr->lasttsig)); - xfr->nmsg++; - failure: if (msgname != NULL) { if (msgrds != NULL) { @@ -1619,11 +1637,22 @@ xfrout_senddone(isc_task_t *task, isc_event_t *event) { UNUSED(task); INSIST(event->ev_type == ISC_SOCKEVENT_SENDDONE); + INSIST((xfr->client->attributes & NS_CLIENTATTR_TCP) != 0); - isc_event_free(&event); xfr->sends--; INSIST(xfr->sends == 0); + /* + * Update transfer statistics if sending succeeded, accounting for the + * two-byte TCP length prefix included in the number of bytes sent. + */ + if (evresult == ISC_R_SUCCESS) { + xfr->stats.nmsg++; + xfr->stats.nbytes += sev->region.length - 2; + } + + isc_event_free(&event); + (void)isc_timer_touch(xfr->client->timer); if (xfr->shuttingdown == true) { xfrout_maybe_destroy(xfr); @@ -1633,8 +1662,28 @@ xfrout_senddone(isc_task_t *task, isc_event_t *event) { sendstream(xfr); } else { /* End of zone transfer stream. */ + uint64_t msecs, persec; + inc_stats(xfr->client, xfr->zone, ns_statscounter_xfrdone); - xfrout_log(xfr, ISC_LOG_INFO, "%s ended", xfr->mnemonic); + isc_time_now(&xfr->stats.end); + msecs = isc_time_microdiff(&xfr->stats.end, &xfr->stats.start); + msecs /= 1000; + if (msecs == 0) { + msecs = 1; + } + persec = (xfr->stats.nbytes * 1000) / msecs; + xfrout_log(xfr, ISC_LOG_INFO, + "%s ended: " + "%" PRIu64 " messages, %" PRIu64 " records, " + "%" PRIu64 " bytes, " + "%u.%03u secs (%u bytes/sec)", + xfr->mnemonic, + xfr->stats.nmsg, xfr->stats.nrecs, + xfr->stats.nbytes, + (unsigned int) (msecs / 1000), + (unsigned int) (msecs % 1000), + (unsigned int) persec); + ns_client_next(xfr->client, ISC_R_SUCCESS); xfrout_ctx_destroy(&xfr); } diff --git a/external/mpl/bind/include/dns/code.h b/external/mpl/bind/include/dns/code.h index 33b1c0b7814..6114a1d580b 100644 --- a/external/mpl/bind/include/dns/code.h +++ b/external/mpl/bind/include/dns/code.h @@ -86,6 +86,7 @@ #include "rdata/generic/cdnskey_60.c" #include "rdata/generic/openpgpkey_61.c" #include "rdata/generic/csync_62.c" +#include "rdata/generic/zonemd_63.c" #include "rdata/generic/spf_99.c" #include "rdata/generic/unspec_103.c" #include "rdata/generic/nid_104.c" @@ -100,6 +101,7 @@ #include "rdata/generic/caa_257.c" #include "rdata/generic/avc_258.c" #include "rdata/generic/doa_259.c" +#include "rdata/generic/amtrelay_260.c" #include "rdata/generic/ta_32768.c" #include "rdata/generic/dlv_32769.c" #include "rdata/generic/keydata_65533.c" @@ -227,6 +229,7 @@ case 60: result = fromtext_cdnskey(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 61: result = fromtext_openpgpkey(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 62: result = fromtext_csync(rdclass, type, lexer, origin, options, target, callbacks); break; \ + case 63: result = fromtext_zonemd(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 99: result = fromtext_spf(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 103: result = fromtext_unspec(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 104: result = fromtext_nid(rdclass, type, lexer, origin, options, target, callbacks); break; \ @@ -245,6 +248,7 @@ case 257: result = fromtext_caa(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 258: result = fromtext_avc(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 259: result = fromtext_doa(rdclass, type, lexer, origin, options, target, callbacks); break; \ + case 260: result = fromtext_amtrelay(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 32768: result = fromtext_ta(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 32769: result = fromtext_dlv(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 65533: result = fromtext_keydata(rdclass, type, lexer, origin, options, target, callbacks); break; \ @@ -372,6 +376,7 @@ case 60: result = totext_cdnskey(rdata, tctx, target); break; \ case 61: result = totext_openpgpkey(rdata, tctx, target); break; \ case 62: result = totext_csync(rdata, tctx, target); break; \ + case 63: result = totext_zonemd(rdata, tctx, target); break; \ case 99: result = totext_spf(rdata, tctx, target); break; \ case 103: result = totext_unspec(rdata, tctx, target); break; \ case 104: result = totext_nid(rdata, tctx, target); break; \ @@ -390,6 +395,7 @@ case 257: result = totext_caa(rdata, tctx, target); break; \ case 258: result = totext_avc(rdata, tctx, target); break; \ case 259: result = totext_doa(rdata, tctx, target); break; \ + case 260: result = totext_amtrelay(rdata, tctx, target); break; \ case 32768: result = totext_ta(rdata, tctx, target); break; \ case 32769: result = totext_dlv(rdata, tctx, target); break; \ case 65533: result = totext_keydata(rdata, tctx, target); break; \ @@ -517,6 +523,7 @@ case 60: result = fromwire_cdnskey(rdclass, type, source, dctx, options, target); break; \ case 61: result = fromwire_openpgpkey(rdclass, type, source, dctx, options, target); break; \ case 62: result = fromwire_csync(rdclass, type, source, dctx, options, target); break; \ + case 63: result = fromwire_zonemd(rdclass, type, source, dctx, options, target); break; \ case 99: result = fromwire_spf(rdclass, type, source, dctx, options, target); break; \ case 103: result = fromwire_unspec(rdclass, type, source, dctx, options, target); break; \ case 104: result = fromwire_nid(rdclass, type, source, dctx, options, target); break; \ @@ -535,6 +542,7 @@ case 257: result = fromwire_caa(rdclass, type, source, dctx, options, target); break; \ case 258: result = fromwire_avc(rdclass, type, source, dctx, options, target); break; \ case 259: result = fromwire_doa(rdclass, type, source, dctx, options, target); break; \ + case 260: result = fromwire_amtrelay(rdclass, type, source, dctx, options, target); break; \ case 32768: result = fromwire_ta(rdclass, type, source, dctx, options, target); break; \ case 32769: result = fromwire_dlv(rdclass, type, source, dctx, options, target); break; \ case 65533: result = fromwire_keydata(rdclass, type, source, dctx, options, target); break; \ @@ -662,6 +670,7 @@ case 60: result = towire_cdnskey(rdata, cctx, target); break; \ case 61: result = towire_openpgpkey(rdata, cctx, target); break; \ case 62: result = towire_csync(rdata, cctx, target); break; \ + case 63: result = towire_zonemd(rdata, cctx, target); break; \ case 99: result = towire_spf(rdata, cctx, target); break; \ case 103: result = towire_unspec(rdata, cctx, target); break; \ case 104: result = towire_nid(rdata, cctx, target); break; \ @@ -680,6 +689,7 @@ case 257: result = towire_caa(rdata, cctx, target); break; \ case 258: result = towire_avc(rdata, cctx, target); break; \ case 259: result = towire_doa(rdata, cctx, target); break; \ + case 260: result = towire_amtrelay(rdata, cctx, target); break; \ case 32768: result = towire_ta(rdata, cctx, target); break; \ case 32769: result = towire_dlv(rdata, cctx, target); break; \ case 65533: result = towire_keydata(rdata, cctx, target); break; \ @@ -807,6 +817,7 @@ case 60: result = compare_cdnskey(rdata1, rdata2); break; \ case 61: result = compare_openpgpkey(rdata1, rdata2); break; \ case 62: result = compare_csync(rdata1, rdata2); break; \ + case 63: result = compare_zonemd(rdata1, rdata2); break; \ case 99: result = compare_spf(rdata1, rdata2); break; \ case 103: result = compare_unspec(rdata1, rdata2); break; \ case 104: result = compare_nid(rdata1, rdata2); break; \ @@ -825,6 +836,7 @@ case 257: result = compare_caa(rdata1, rdata2); break; \ case 258: result = compare_avc(rdata1, rdata2); break; \ case 259: result = compare_doa(rdata1, rdata2); break; \ + case 260: result = compare_amtrelay(rdata1, rdata2); break; \ case 32768: result = compare_ta(rdata1, rdata2); break; \ case 32769: result = compare_dlv(rdata1, rdata2); break; \ case 65533: result = compare_keydata(rdata1, rdata2); break; \ @@ -952,6 +964,7 @@ case 60: result = casecompare_cdnskey(rdata1, rdata2); break; \ case 61: result = casecompare_openpgpkey(rdata1, rdata2); break; \ case 62: result = casecompare_csync(rdata1, rdata2); break; \ + case 63: result = casecompare_zonemd(rdata1, rdata2); break; \ case 99: result = casecompare_spf(rdata1, rdata2); break; \ case 103: result = casecompare_unspec(rdata1, rdata2); break; \ case 104: result = casecompare_nid(rdata1, rdata2); break; \ @@ -970,6 +983,7 @@ case 257: result = casecompare_caa(rdata1, rdata2); break; \ case 258: result = casecompare_avc(rdata1, rdata2); break; \ case 259: result = casecompare_doa(rdata1, rdata2); break; \ + case 260: result = casecompare_amtrelay(rdata1, rdata2); break; \ case 32768: result = casecompare_ta(rdata1, rdata2); break; \ case 32769: result = casecompare_dlv(rdata1, rdata2); break; \ case 65533: result = casecompare_keydata(rdata1, rdata2); break; \ @@ -1097,6 +1111,7 @@ case 60: result = fromstruct_cdnskey(rdclass, type, source, target); break; \ case 61: result = fromstruct_openpgpkey(rdclass, type, source, target); break; \ case 62: result = fromstruct_csync(rdclass, type, source, target); break; \ + case 63: result = fromstruct_zonemd(rdclass, type, source, target); break; \ case 99: result = fromstruct_spf(rdclass, type, source, target); break; \ case 103: result = fromstruct_unspec(rdclass, type, source, target); break; \ case 104: result = fromstruct_nid(rdclass, type, source, target); break; \ @@ -1115,6 +1130,7 @@ case 257: result = fromstruct_caa(rdclass, type, source, target); break; \ case 258: result = fromstruct_avc(rdclass, type, source, target); break; \ case 259: result = fromstruct_doa(rdclass, type, source, target); break; \ + case 260: result = fromstruct_amtrelay(rdclass, type, source, target); break; \ case 32768: result = fromstruct_ta(rdclass, type, source, target); break; \ case 32769: result = fromstruct_dlv(rdclass, type, source, target); break; \ case 65533: result = fromstruct_keydata(rdclass, type, source, target); break; \ @@ -1242,6 +1258,7 @@ case 60: result = tostruct_cdnskey(rdata, target, mctx); break; \ case 61: result = tostruct_openpgpkey(rdata, target, mctx); break; \ case 62: result = tostruct_csync(rdata, target, mctx); break; \ + case 63: result = tostruct_zonemd(rdata, target, mctx); break; \ case 99: result = tostruct_spf(rdata, target, mctx); break; \ case 103: result = tostruct_unspec(rdata, target, mctx); break; \ case 104: result = tostruct_nid(rdata, target, mctx); break; \ @@ -1260,6 +1277,7 @@ case 257: result = tostruct_caa(rdata, target, mctx); break; \ case 258: result = tostruct_avc(rdata, target, mctx); break; \ case 259: result = tostruct_doa(rdata, target, mctx); break; \ + case 260: result = tostruct_amtrelay(rdata, target, mctx); break; \ case 32768: result = tostruct_ta(rdata, target, mctx); break; \ case 32769: result = tostruct_dlv(rdata, target, mctx); break; \ case 65533: result = tostruct_keydata(rdata, target, mctx); break; \ @@ -1387,6 +1405,7 @@ case 60: freestruct_cdnskey(source); break; \ case 61: freestruct_openpgpkey(source); break; \ case 62: freestruct_csync(source); break; \ + case 63: freestruct_zonemd(source); break; \ case 99: freestruct_spf(source); break; \ case 103: freestruct_unspec(source); break; \ case 104: freestruct_nid(source); break; \ @@ -1405,6 +1424,7 @@ case 257: freestruct_caa(source); break; \ case 258: freestruct_avc(source); break; \ case 259: freestruct_doa(source); break; \ + case 260: freestruct_amtrelay(source); break; \ case 32768: freestruct_ta(source); break; \ case 32769: freestruct_dlv(source); break; \ case 65533: freestruct_keydata(source); break; \ @@ -1532,6 +1552,7 @@ case 60: result = additionaldata_cdnskey(rdata, add, arg); break; \ case 61: result = additionaldata_openpgpkey(rdata, add, arg); break; \ case 62: result = additionaldata_csync(rdata, add, arg); break; \ + case 63: result = additionaldata_zonemd(rdata, add, arg); break; \ case 99: result = additionaldata_spf(rdata, add, arg); break; \ case 103: result = additionaldata_unspec(rdata, add, arg); break; \ case 104: result = additionaldata_nid(rdata, add, arg); break; \ @@ -1550,6 +1571,7 @@ case 257: result = additionaldata_caa(rdata, add, arg); break; \ case 258: result = additionaldata_avc(rdata, add, arg); break; \ case 259: result = additionaldata_doa(rdata, add, arg); break; \ + case 260: result = additionaldata_amtrelay(rdata, add, arg); break; \ case 32768: result = additionaldata_ta(rdata, add, arg); break; \ case 32769: result = additionaldata_dlv(rdata, add, arg); break; \ case 65533: result = additionaldata_keydata(rdata, add, arg); break; \ @@ -1677,6 +1699,7 @@ case 60: result = digest_cdnskey(rdata, digest, arg); break; \ case 61: result = digest_openpgpkey(rdata, digest, arg); break; \ case 62: result = digest_csync(rdata, digest, arg); break; \ + case 63: result = digest_zonemd(rdata, digest, arg); break; \ case 99: result = digest_spf(rdata, digest, arg); break; \ case 103: result = digest_unspec(rdata, digest, arg); break; \ case 104: result = digest_nid(rdata, digest, arg); break; \ @@ -1695,6 +1718,7 @@ case 257: result = digest_caa(rdata, digest, arg); break; \ case 258: result = digest_avc(rdata, digest, arg); break; \ case 259: result = digest_doa(rdata, digest, arg); break; \ + case 260: result = digest_amtrelay(rdata, digest, arg); break; \ case 32768: result = digest_ta(rdata, digest, arg); break; \ case 32769: result = digest_dlv(rdata, digest, arg); break; \ case 65533: result = digest_keydata(rdata, digest, arg); break; \ @@ -1822,6 +1846,7 @@ case 60: result = checkowner_cdnskey(name, rdclass, type, wildcard); break; \ case 61: result = checkowner_openpgpkey(name, rdclass, type, wildcard); break; \ case 62: result = checkowner_csync(name, rdclass, type, wildcard); break; \ + case 63: result = checkowner_zonemd(name, rdclass, type, wildcard); break; \ case 99: result = checkowner_spf(name, rdclass, type, wildcard); break; \ case 103: result = checkowner_unspec(name, rdclass, type, wildcard); break; \ case 104: result = checkowner_nid(name, rdclass, type, wildcard); break; \ @@ -1840,6 +1865,7 @@ case 257: result = checkowner_caa(name, rdclass, type, wildcard); break; \ case 258: result = checkowner_avc(name, rdclass, type, wildcard); break; \ case 259: result = checkowner_doa(name, rdclass, type, wildcard); break; \ + case 260: result = checkowner_amtrelay(name, rdclass, type, wildcard); break; \ case 32768: result = checkowner_ta(name, rdclass, type, wildcard); break; \ case 32769: result = checkowner_dlv(name, rdclass, type, wildcard); break; \ case 65533: result = checkowner_keydata(name, rdclass, type, wildcard); break; \ @@ -1967,6 +1993,7 @@ case 60: result = checknames_cdnskey(rdata, owner, bad); break; \ case 61: result = checknames_openpgpkey(rdata, owner, bad); break; \ case 62: result = checknames_csync(rdata, owner, bad); break; \ + case 63: result = checknames_zonemd(rdata, owner, bad); break; \ case 99: result = checknames_spf(rdata, owner, bad); break; \ case 103: result = checknames_unspec(rdata, owner, bad); break; \ case 104: result = checknames_nid(rdata, owner, bad); break; \ @@ -1985,6 +2012,7 @@ case 257: result = checknames_caa(rdata, owner, bad); break; \ case 258: result = checknames_avc(rdata, owner, bad); break; \ case 259: result = checknames_doa(rdata, owner, bad); break; \ + case 260: result = checknames_amtrelay(rdata, owner, bad); break; \ case 32768: result = checknames_ta(rdata, owner, bad); break; \ case 32769: result = checknames_dlv(rdata, owner, bad); break; \ case 65533: result = checknames_keydata(rdata, owner, bad); break; \ @@ -2179,6 +2207,9 @@ RDATATYPE_COMPARE("csync", 62, _typename, _length, _typep); \ RDATATYPE_COMPARE("uri", 256, _typename, _length, _typep); \ break; \ + case 0: \ + RDATATYPE_COMPARE("zonemd", 63, _typename, _length, _typep); \ + break; \ case 230: \ RDATATYPE_COMPARE("uinfo", 100, _typename, _length, _typep); \ break; \ @@ -2228,6 +2259,9 @@ case 7: \ RDATATYPE_COMPARE("doa", 259, _typename, _length, _typep); \ break; \ + case 161: \ + RDATATYPE_COMPARE("amtrelay", 260, _typename, _length, _typep); \ + break; \ } #define RDATATYPE_ATTRIBUTE_SW \ switch (type) { \ @@ -2293,6 +2327,7 @@ case 60: return (RRTYPE_CDNSKEY_ATTRIBUTES); \ case 61: return (RRTYPE_OPENPGPKEY_ATTRIBUTES); \ case 62: return (RRTYPE_CSYNC_ATTRIBUTES); \ + case 63: return (RRTYPE_ZONEMD_ATTRIBUTES); \ case 99: return (RRTYPE_SPF_ATTRIBUTES); \ case 100: return (0); \ case 101: return (0); \ @@ -2315,6 +2350,7 @@ case 257: return (RRTYPE_CAA_ATTRIBUTES); \ case 258: return (RRTYPE_AVC_ATTRIBUTES); \ case 259: return (RRTYPE_DOA_ATTRIBUTES); \ + case 260: return (RRTYPE_AMTRELAY_ATTRIBUTES); \ case 32768: return (RRTYPE_TA_ATTRIBUTES); \ case 32769: return (RRTYPE_DLV_ATTRIBUTES); \ case 65533: return (RRTYPE_KEYDATA_ATTRIBUTES); \ @@ -2383,6 +2419,7 @@ case 60: return (str_totext("CDNSKEY", target)); \ case 61: return (str_totext("OPENPGPKEY", target)); \ case 62: return (str_totext("CSYNC", target)); \ + case 63: return (str_totext("ZONEMD", target)); \ case 99: return (str_totext("SPF", target)); \ case 100: return (str_totext("UINFO", target)); \ case 101: return (str_totext("UID", target)); \ @@ -2405,6 +2442,7 @@ case 257: return (str_totext("CAA", target)); \ case 258: return (str_totext("AVC", target)); \ case 259: return (str_totext("DOA", target)); \ + case 260: return (str_totext("AMTRELAY", target)); \ case 32768: return (str_totext("TA", target)); \ case 32769: return (str_totext("DLV", target)); \ } diff --git a/external/mpl/bind/include/dns/enumtype.h b/external/mpl/bind/include/dns/enumtype.h index e9cd1ed5b8a..ceb3eabceb8 100644 --- a/external/mpl/bind/include/dns/enumtype.h +++ b/external/mpl/bind/include/dns/enumtype.h @@ -81,6 +81,7 @@ enum { dns_rdatatype_cdnskey = 60, dns_rdatatype_openpgpkey = 61, dns_rdatatype_csync = 62, + dns_rdatatype_zonemd = 63, dns_rdatatype_spf = 99, dns_rdatatype_unspec = 103, dns_rdatatype_nid = 104, @@ -95,6 +96,7 @@ enum { dns_rdatatype_caa = 257, dns_rdatatype_avc = 258, dns_rdatatype_doa = 259, + dns_rdatatype_amtrelay = 260, dns_rdatatype_ta = 32768, dns_rdatatype_dlv = 32769, dns_rdatatype_keydata = 65533, @@ -167,6 +169,7 @@ enum { #define dns_rdatatype_cdnskey ((dns_rdatatype_t)dns_rdatatype_cdnskey) #define dns_rdatatype_openpgpkey ((dns_rdatatype_t)dns_rdatatype_openpgpkey) #define dns_rdatatype_csync ((dns_rdatatype_t)dns_rdatatype_csync) +#define dns_rdatatype_zonemd ((dns_rdatatype_t)dns_rdatatype_zonemd) #define dns_rdatatype_spf ((dns_rdatatype_t)dns_rdatatype_spf) #define dns_rdatatype_unspec ((dns_rdatatype_t)dns_rdatatype_unspec) #define dns_rdatatype_nid ((dns_rdatatype_t)dns_rdatatype_nid) @@ -181,6 +184,7 @@ enum { #define dns_rdatatype_caa ((dns_rdatatype_t)dns_rdatatype_caa) #define dns_rdatatype_avc ((dns_rdatatype_t)dns_rdatatype_avc) #define dns_rdatatype_doa ((dns_rdatatype_t)dns_rdatatype_doa) +#define dns_rdatatype_amtrelay ((dns_rdatatype_t)dns_rdatatype_amtrelay) #define dns_rdatatype_ta ((dns_rdatatype_t)dns_rdatatype_ta) #define dns_rdatatype_dlv ((dns_rdatatype_t)dns_rdatatype_dlv) #define dns_rdatatype_keydata ((dns_rdatatype_t)dns_rdatatype_keydata) diff --git a/external/mpl/bind/include/dns/rdatastruct.h b/external/mpl/bind/include/dns/rdatastruct.h index 0be61b25d73..24bd95c9061 100644 --- a/external/mpl/bind/include/dns/rdatastruct.h +++ b/external/mpl/bind/include/dns/rdatastruct.h @@ -1864,6 +1864,37 @@ typedef struct dns_rdata_csync { * information regarding copyright ownership. */ +#ifndef GENERIC_ZONEMD_63_H +#define GENERIC_ZONEMD_63_H 1 + +/* Digest type(s). Currently only SHA-384 is defined. */ +#define DNS_ZONEMD_DIGEST_SHA384 (1) + +/* + * \brief per draft-wessels-zone-digest-05 + */ +typedef struct dns_rdata_zonemd { + dns_rdatacommon_t common; + isc_mem_t *mctx; + uint32_t serial; + uint8_t digest_type; + uint8_t reserved; + unsigned char *digest; + uint16_t length; +} dns_rdata_zonemd_t; + +#endif /* GENERIC_ZONEMD_63_H */ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + #ifndef GENERIC_SPF_99_H #define GENERIC_SPF_99_H 1 @@ -2226,6 +2257,35 @@ typedef struct dns_rdata_doa { * information regarding copyright ownership. */ + +#ifndef GENERIC_AMTRELAY_260_H +#define GENERIC_AMTRELAY_260_H 1 + +typedef struct dns_rdata_amtrelay { + dns_rdatacommon_t common; + isc_mem_t *mctx; + uint8_t precedence; + bool discovery; + uint8_t gateway_type; + struct in_addr in_addr; /* gateway type 1 */ + struct in6_addr in6_addr; /* gateway type 2 */ + dns_name_t gateway; /* gateway type 3 */ + unsigned char *data; /* gateway type > 3 */ + uint16_t length; +} dns_rdata_amtrelay_t; + +#endif /* GENERIC_AMTRELAY_260_H */ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + #ifndef GENERIC_TA_32768_H #define GENERIC_TA_32768_H 1 diff --git a/external/mpl/bind/include/isc/atomic.h b/external/mpl/bind/include/isc/atomic.h index d6f95de111c..893f5526fd0 100644 --- a/external/mpl/bind/include/isc/atomic.h +++ b/external/mpl/bind/include/isc/atomic.h @@ -16,3 +16,12 @@ #else #include <isc/stdatomic.h> #endif + +/* + * We define a few additional macros to make things easier + */ + +#define atomic_store_relaxed(o, v) atomic_store_explicit((o), \ + (v), \ + memory_order_relaxed) +#define atomic_load_relaxed(o) atomic_load_explicit((o), memory_order_relaxed) diff --git a/external/mpl/bind/include/isc/stdatomic.h b/external/mpl/bind/include/isc/stdatomic.h index c45c0990bbe..9a75bf126c6 100644 --- a/external/mpl/bind/include/isc/stdatomic.h +++ b/external/mpl/bind/include/isc/stdatomic.h @@ -11,6 +11,9 @@ #pragma once +#include <inttypes.h> +#include <stdbool.h> + #if !defined(__has_feature) #define __has_feature(x) 0 #endif @@ -31,9 +34,9 @@ #if !defined(__CLANG_ATOMICS) && !defined(__GNUC_ATOMICS) #if __has_extension(c_atomic) || __has_extension(cxx_atomic) #define __CLANG_ATOMICS -#elif __GNUC_PREREQ__(4, 7) +#elif __GNUC_PREREQ__(4, 7) || defined(__lint__) #define __GNUC_ATOMICS -#elif !defined(__GNUC__) && !defined(__lint__) +#elif !defined(__GNUC__) #error "isc/stdatomic.h does not support your compiler" #endif #endif @@ -73,6 +76,7 @@ typedef int_fast32_t atomic_int_fast32_t; typedef uint_fast32_t atomic_uint_fast32_t; typedef int_fast64_t atomic_int_fast64_t; typedef uint_fast64_t atomic_uint_fast64_t; +typedef bool atomic_bool; #if defined(__CLANG_ATOMICS) /* __c11_atomic builtins */ #define atomic_init(obj, desired) \ @@ -123,8 +127,10 @@ typedef uint_fast64_t atomic_uint_fast64_t; ({ \ __typeof__(obj) __v; \ _Bool __r; \ - __v = __sync_val_compare_and_swap(obj, *(expected), desired); \ - __r = *(expected) == __v; \ + __v = (__typeof__(obj))__sync_val_compare_and_swap(obj, \ + *(expected), \ + desired); \ + __r = ((__typeof__(obj))*(expected) == __v); \ *(expected) = __v; \ __r; \ }) @@ -134,11 +140,11 @@ typedef uint_fast64_t atomic_uint_fast64_t; #define atomic_load(obj) \ atomic_load_explicit(obj, memory_order_seq_cst) -#define atomic_store(obj) \ - atomic_store_explicit(obj, memory_order_seq_cst) -#define atomic_fetch_add(obj) \ +#define atomic_store(obj, arg) \ + atomic_store_explicit(obj, arg, memory_order_seq_cst) +#define atomic_fetch_add(obj, arg) \ atomic_fetch_add_explicit(obj, arg, memory_order_seq_cst) -#define atomic_fetch_sub(obj) \ +#define atomic_fetch_sub(obj, arg) \ atomic_fetch_sub_explicit(obj, arg, memory_order_seq_cst) #define atomic_compare_exchange_strong(obj, expected, desired) \ atomic_compare_exchange_strong_explicit(obj, expected, desired, memory_order_seq_cst, memory_order_seq_cst) diff --git a/external/mpl/bind/lib/libbind9/shlib_version b/external/mpl/bind/lib/libbind9/shlib_version index 0db77faf162..728b7541bfd 100644 --- a/external/mpl/bind/lib/libbind9/shlib_version +++ b/external/mpl/bind/lib/libbind9/shlib_version @@ -1,5 +1,5 @@ -# $NetBSD: shlib_version,v 1.2 2019/01/09 16:55:22 christos Exp $ +# $NetBSD: shlib_version,v 1.3 2019/02/24 20:01:33 christos Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # -major=10 +major=11 minor=0 diff --git a/external/mpl/bind/lib/libdns/Makefile b/external/mpl/bind/lib/libdns/Makefile index c70f2eca690..2fd3164bcb7 100644 --- a/external/mpl/bind/lib/libdns/Makefile +++ b/external/mpl/bind/lib/libdns/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2019/01/09 16:55:22 christos Exp $ +# $NetBSD: Makefile,v 1.3 2019/02/24 20:01:33 christos Exp $ LIB=dns #USE_SHLIBDIR= yes @@ -24,7 +24,7 @@ CWARNFLAGS.clang+= -Wno-tautological-constant-out-of-range-compare COPTS.${f}.c+= -Wno-pointer-sign -fno-strict-aliasing .endfor -DNSSEC_SRCS= dst_api.c dst_lib.c dst_parse.c dst_result.c \ +DNSSEC_SRCS= dst_api.c dst_parse.c dst_result.c \ gssapictx.c hmac_link.c key.c openssl_link.c \ openssldh_link.c opensslrsa_link.c \ opensslecdsa_link.c openssleddsa_link.c diff --git a/external/mpl/bind/lib/libdns/shlib_version b/external/mpl/bind/lib/libdns/shlib_version index 0db77faf162..728b7541bfd 100644 --- a/external/mpl/bind/lib/libdns/shlib_version +++ b/external/mpl/bind/lib/libdns/shlib_version @@ -1,5 +1,5 @@ -# $NetBSD: shlib_version,v 1.2 2019/01/09 16:55:22 christos Exp $ +# $NetBSD: shlib_version,v 1.3 2019/02/24 20:01:33 christos Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # -major=10 +major=11 minor=0 diff --git a/external/mpl/bind/lib/libirs/shlib_version b/external/mpl/bind/lib/libirs/shlib_version index d646602bf3f..728b7541bfd 100644 --- a/external/mpl/bind/lib/libirs/shlib_version +++ b/external/mpl/bind/lib/libirs/shlib_version @@ -1,5 +1,5 @@ -# $NetBSD: shlib_version,v 1.2 2019/01/09 16:55:23 christos Exp $ +# $NetBSD: shlib_version,v 1.3 2019/02/24 20:01:33 christos Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # -major=10 +major=11 minor=0 diff --git a/external/mpl/bind/lib/libisc/Makefile b/external/mpl/bind/lib/libisc/Makefile index 3d12e16b853..ee825b00f66 100644 --- a/external/mpl/bind/lib/libisc/Makefile +++ b/external/mpl/bind/lib/libisc/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.5 2019/02/20 03:50:06 christos Exp $ +# $NetBSD: Makefile,v 1.6 2019/02/24 20:01:33 christos Exp $ LIB=isc #USE_SHLIBDIR= yes @@ -20,7 +20,6 @@ UNIX_SRCS= app.c backtrace.c dir.c entropy.c errno2result.c file.c \ fsaccess.c interfaceiter.c net.c os.c resource.c \ socket.c stdio.c stdtime.c syslog.c time.c \ backtrace-emptytbl.c meminfo.c -NLS_SRCS= msgcat.c PTHREAD_SRCS= condition.c mutex.c thread.c CRYPTO_SRCS= aes.c @@ -35,7 +34,7 @@ SRCS= assertions.c base32.c base64.c bind9.c buffer.c \ region.c result.c rwlock.c serial.c \ sockaddr.c stats.c string.c symtab.c task.c \ taskpool.c timer.c tm.c version.c \ - ${UNIX_SRCS} ${NLS_SRCS} ${PTHREAD_SRCS} ${CRYPTO_SRCS} + ${UNIX_SRCS} ${PTHREAD_SRCS} ${CRYPTO_SRCS} diff --git a/external/mpl/bind/lib/libisc/shlib_version b/external/mpl/bind/lib/libisc/shlib_version index d646602bf3f..728b7541bfd 100644 --- a/external/mpl/bind/lib/libisc/shlib_version +++ b/external/mpl/bind/lib/libisc/shlib_version @@ -1,5 +1,5 @@ -# $NetBSD: shlib_version,v 1.2 2019/01/09 16:55:23 christos Exp $ +# $NetBSD: shlib_version,v 1.3 2019/02/24 20:01:33 christos Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # -major=10 +major=11 minor=0 diff --git a/external/mpl/bind/lib/libisccc/Makefile b/external/mpl/bind/lib/libisccc/Makefile index 6efffbd1514..d521d328c0f 100644 --- a/external/mpl/bind/lib/libisccc/Makefile +++ b/external/mpl/bind/lib/libisccc/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2018/08/12 13:02:43 christos Exp $ +# $NetBSD: Makefile,v 1.2 2019/02/24 20:01:33 christos Exp $ LIB=isccc @@ -13,7 +13,7 @@ DIST= ${IDIST}/lib/isccc .PATH.c: ${DIST} -SRCS= alist.c base64.c cc.c ccmsg.c lib.c result.c sexpr.c symtab.c \ +SRCS= alist.c base64.c cc.c ccmsg.c result.c sexpr.c symtab.c \ version.c .include <bsd.lib.mk> diff --git a/external/mpl/bind/lib/libisccc/shlib_version b/external/mpl/bind/lib/libisccc/shlib_version index d646602bf3f..728b7541bfd 100644 --- a/external/mpl/bind/lib/libisccc/shlib_version +++ b/external/mpl/bind/lib/libisccc/shlib_version @@ -1,5 +1,5 @@ -# $NetBSD: shlib_version,v 1.2 2019/01/09 16:55:23 christos Exp $ +# $NetBSD: shlib_version,v 1.3 2019/02/24 20:01:33 christos Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # -major=10 +major=11 minor=0 diff --git a/external/mpl/bind/lib/libisccfg/shlib_version b/external/mpl/bind/lib/libisccfg/shlib_version index d646602bf3f..728b7541bfd 100644 --- a/external/mpl/bind/lib/libisccfg/shlib_version +++ b/external/mpl/bind/lib/libisccfg/shlib_version @@ -1,5 +1,5 @@ -# $NetBSD: shlib_version,v 1.2 2019/01/09 16:55:23 christos Exp $ +# $NetBSD: shlib_version,v 1.3 2019/02/24 20:01:33 christos Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # -major=10 +major=11 minor=0 diff --git a/external/mpl/bind/lib/libns/shlib_version b/external/mpl/bind/lib/libns/shlib_version index d646602bf3f..728b7541bfd 100644 --- a/external/mpl/bind/lib/libns/shlib_version +++ b/external/mpl/bind/lib/libns/shlib_version @@ -1,5 +1,5 @@ -# $NetBSD: shlib_version,v 1.2 2019/01/09 16:55:23 christos Exp $ +# $NetBSD: shlib_version,v 1.3 2019/02/24 20:01:33 christos Exp $ # Remember to update distrib/sets/lists/base/shl.* when changing # -major=10 +major=11 minor=0 |
