summaryrefslogtreecommitdiff
path: root/dist/bind/lib/bind9
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2004-11-06 23:53:21 +0000
committerchristos <christos@NetBSD.org>2004-11-06 23:53:21 +0000
commitdfd98c8a16d53dff0d1bdca29bcddc6571054129 (patch)
tree24f3891f470a8e79f037a71c4b43266f23767859 /dist/bind/lib/bind9
parentaefec4290d9fd9e83eaf8b2b4ada33ff37ecaedb (diff)
Import bind-9.3.0
Diffstat (limited to 'dist/bind/lib/bind9')
-rw-r--r--dist/bind/lib/bind9/Makefile.in4
-rw-r--r--dist/bind/lib/bind9/api2
-rw-r--r--dist/bind/lib/bind9/check.c232
-rw-r--r--dist/bind/lib/bind9/getaddresses.c67
4 files changed, 209 insertions, 96 deletions
diff --git a/dist/bind/lib/bind9/Makefile.in b/dist/bind/lib/bind9/Makefile.in
index a179b1e5713..368f06a5a7f 100644
--- a/dist/bind/lib/bind9/Makefile.in
+++ b/dist/bind/lib/bind9/Makefile.in
@@ -13,7 +13,7 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
-# Id: Makefile.in,v 1.2.200.5 2004/03/08 09:04:26 marka Exp
+# Id: Makefile.in,v 1.2.200.6 2004/07/20 07:01:57 marka Exp
srcdir = @srcdir@
VPATH = @srcdir@
@@ -59,7 +59,7 @@ libbind9.@SA@: ${OBJS}
libbind9.la: ${OBJS}
${LIBTOOL_MODE_LINK} \
- ${CC} ${ALL_CFLAGS} -o libbind9.la -rpath ${libdir} \
+ ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libbind9.la -rpath ${libdir} \
-version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \
${OBJS} ${LIBS}
diff --git a/dist/bind/lib/bind9/api b/dist/bind/lib/bind9/api
index 06977fcb711..dbaaf58cca8 100644
--- a/dist/bind/lib/bind9/api
+++ b/dist/bind/lib/bind9/api
@@ -1,3 +1,3 @@
LIBINTERFACE = 0
-LIBREVISION = 1
+LIBREVISION = 4
LIBAGE = 0
diff --git a/dist/bind/lib/bind9/check.c b/dist/bind/lib/bind9/check.c
index 4e70b5f0797..53c79b3468f 100644
--- a/dist/bind/lib/bind9/check.c
+++ b/dist/bind/lib/bind9/check.c
@@ -1,4 +1,4 @@
-/* $NetBSD: check.c,v 1.1.1.1 2004/05/17 23:44:48 christos Exp $ */
+/* $NetBSD: check.c,v 1.1.1.2 2004/11/06 23:55:34 christos Exp $ */
/*
* Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* Id: check.c,v 1.37.6.25 2004/04/15 23:56:28 marka Exp */
+/* Id: check.c,v 1.37.6.28 2004/07/29 00:08:08 marka Exp */
#include <config.h>
@@ -282,6 +282,39 @@ disabled_algorithms(cfg_obj_t *disabled, isc_log_t *logctx) {
}
static isc_result_t
+nameexist(cfg_obj_t *obj, const char *name, int value, isc_symtab_t *symtab,
+ const char *fmt, isc_log_t *logctx, isc_mem_t *mctx)
+{
+ char *key;
+ const char *file;
+ unsigned int line;
+ isc_result_t result;
+ isc_symvalue_t symvalue;
+
+ key = isc_mem_strdup(mctx, name);
+ if (key == NULL)
+ return (ISC_R_NOMEMORY);
+ symvalue.as_pointer = obj;
+ result = isc_symtab_define(symtab, key, value, symvalue,
+ isc_symexists_reject);
+ if (result == ISC_R_EXISTS) {
+ RUNTIME_CHECK(isc_symtab_lookup(symtab, key, value,
+ &symvalue) == ISC_R_SUCCESS);
+ file = cfg_obj_file(symvalue.as_pointer);
+ line = cfg_obj_line(symvalue.as_pointer);
+
+ if (file == NULL)
+ file = "<unknown file>";
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR, fmt, key, file, line);
+ isc_mem_free(mctx, key);
+ result = ISC_R_EXISTS;
+ } else if (result != ISC_R_SUCCESS) {
+ isc_mem_free(mctx, key);
+ }
+ return (result);
+}
+
+static isc_result_t
mustbesecure(cfg_obj_t *secure, isc_symtab_t *symtab, isc_log_t *logctx,
isc_mem_t *mctx)
{
@@ -292,9 +325,6 @@ mustbesecure(cfg_obj_t *secure, isc_symtab_t *symtab, isc_log_t *logctx,
dns_name_t *name;
isc_buffer_t b;
isc_result_t result = ISC_R_SUCCESS;
- isc_result_t tresult;
- isc_symvalue_t symvalue;
- char *key;
dns_fixedname_init(&fixed);
name = dns_fixedname_name(&fixed);
@@ -302,42 +332,16 @@ mustbesecure(cfg_obj_t *secure, isc_symtab_t *symtab, isc_log_t *logctx,
str = cfg_obj_asstring(obj);
isc_buffer_init(&b, str, strlen(str));
isc_buffer_add(&b, strlen(str));
- tresult = dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL);
- if (tresult != ISC_R_SUCCESS) {
+ result = dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL);
+ if (result != ISC_R_SUCCESS) {
cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
"bad domain name '%s'", str);
- result = tresult;
} else {
-
dns_name_format(name, namebuf, sizeof(namebuf));
- key = isc_mem_strdup(mctx, namebuf);
- if (key == NULL)
- return (ISC_R_NOMEMORY);
- symvalue.as_pointer = secure;
- tresult = isc_symtab_define(symtab, key, 1, symvalue,
- isc_symexists_reject);
- if (tresult == ISC_R_EXISTS) {
- const char *file;
- unsigned int line;
-
- RUNTIME_CHECK(isc_symtab_lookup(symtab, key, 1,
- &symvalue) == ISC_R_SUCCESS);
- isc_mem_free(mctx, key);
- file = cfg_obj_file(symvalue.as_pointer);
- line = cfg_obj_line(symvalue.as_pointer);
-
- if (file == NULL)
- file = "<unknown file>";
-
- cfg_obj_log(secure, logctx, ISC_LOG_ERROR,
- "dnssec-must-be-secure '%s': already "
- "exists previous definition: %s:%u",
- namebuf, file, line);
- result = tresult;
- } else if (tresult != ISC_R_SUCCESS) {
- isc_mem_free(mctx, key);
- result = tresult;
- }
+ result = nameexist(secure, namebuf, 1, symtab,
+ "dnssec-must-be-secure '%s': already "
+ "exists previous definition: %s:%u",
+ logctx, mctx);
}
return (result);
}
@@ -355,6 +359,7 @@ check_options(cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx) {
unsigned int i;
cfg_obj_t *obj = NULL;
cfg_listelt_t *element;
+ isc_symtab_t *symtab = NULL;
static intervaltable intervals[] = {
{ "cleaning-interval", 60, 28 * 24 * 60 }, /* 28 days */
@@ -460,21 +465,70 @@ check_options(cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx) {
obj = NULL;
(void)cfg_map_get(options, "dnssec-lookaside", &obj);
if (obj != NULL) {
- dns_fixedname_t fixedname;
- const char *dlv;
- isc_buffer_t b;
-
- dlv = cfg_obj_asstring(obj);
- dns_fixedname_init(&fixedname);
- isc_buffer_init(&b, dlv, strlen(dlv));
- isc_buffer_add(&b, strlen(dlv));
- tresult = dns_name_fromtext(dns_fixedname_name(&fixedname), &b,
- dns_rootname, ISC_TRUE, NULL);
- if (tresult != ISC_R_SUCCESS) {
- cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
- "bad domain name '%s'", dlv);
+ tresult = isc_symtab_create(mctx, 100, freekey, mctx,
+ ISC_TRUE, &symtab);
+ if (tresult != ISC_R_SUCCESS)
result = tresult;
+ for (element = cfg_list_first(obj);
+ element != NULL;
+ element = cfg_list_next(element))
+ {
+ dns_fixedname_t fixedname;
+ dns_name_t *name;
+ const char *dlv;
+ isc_buffer_t b;
+
+ obj = cfg_listelt_value(element);
+
+ dlv = cfg_obj_asstring(cfg_tuple_get(obj, "domain"));
+ dns_fixedname_init(&fixedname);
+ name = dns_fixedname_name(&fixedname);
+ isc_buffer_init(&b, dlv, strlen(dlv));
+ isc_buffer_add(&b, strlen(dlv));
+ tresult = dns_name_fromtext(name, &b, dns_rootname,
+ ISC_TRUE, NULL);
+ if (tresult != ISC_R_SUCCESS) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "bad domain name '%s'", dlv);
+ result = tresult;
+ }
+ if (symtab != NULL) {
+ tresult = nameexist(obj, dlv, 1, symtab,
+ "dnssec-lookaside '%s': "
+ "already exists previous "
+ "definition: %s:%u",
+ logctx, mctx);
+ if (tresult != ISC_R_SUCCESS &&
+ result == ISC_R_SUCCESS)
+ result = tresult;
+ }
+ /*
+ * XXXMPA to be removed when multiple lookaside
+ * namespaces are supported.
+ */
+ if (!dns_name_equal(dns_rootname, name)) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "dnssec-lookaside '%s': "
+ "non-root not yet supported", dlv);
+ if (result == ISC_R_SUCCESS)
+ result = ISC_R_FAILURE;
+ }
+ dlv = cfg_obj_asstring(cfg_tuple_get(obj,
+ "trust-anchor"));
+ dns_fixedname_init(&fixedname);
+ isc_buffer_init(&b, dlv, strlen(dlv));
+ isc_buffer_add(&b, strlen(dlv));
+ tresult = dns_name_fromtext(name, &b, dns_rootname,
+ ISC_TRUE, NULL);
+ if (tresult != ISC_R_SUCCESS) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "bad domain name '%s'", dlv);
+ if (result == ISC_R_SUCCESS)
+ result = tresult;
+ }
}
+ if (symtab != NULL)
+ isc_symtab_destroy(&symtab);
}
/*
@@ -645,7 +699,6 @@ check_zoneconf(cfg_obj_t *zconfig, cfg_obj_t *config, isc_symtab_t *symtab,
unsigned int ztype;
cfg_obj_t *zoptions;
cfg_obj_t *obj = NULL;
- isc_symvalue_t symvalue;
isc_result_t result = ISC_R_SUCCESS;
isc_result_t tresult;
unsigned int i;
@@ -760,48 +813,22 @@ check_zoneconf(cfg_obj_t *zconfig, cfg_obj_t *config, isc_symtab_t *symtab,
dns_fixedname_init(&fixedname);
isc_buffer_init(&b, zname, strlen(zname));
isc_buffer_add(&b, strlen(zname));
- result = dns_name_fromtext(dns_fixedname_name(&fixedname), &b,
+ tresult = dns_name_fromtext(dns_fixedname_name(&fixedname), &b,
dns_rootname, ISC_TRUE, NULL);
if (result != ISC_R_SUCCESS) {
cfg_obj_log(zconfig, logctx, ISC_LOG_ERROR,
"zone '%s': is not a valid name", zname);
- result = ISC_R_FAILURE;
+ tresult = ISC_R_FAILURE;
} else {
char namebuf[DNS_NAME_FORMATSIZE];
- char *key;
dns_name_format(dns_fixedname_name(&fixedname),
namebuf, sizeof(namebuf));
- key = isc_mem_strdup(mctx, namebuf);
- if (key == NULL)
- return (ISC_R_NOMEMORY);
- symvalue.as_pointer = zconfig;
- tresult = isc_symtab_define(symtab, key,
- ztype == HINTZONE ? 1 : 2,
- symvalue, isc_symexists_reject);
- if (tresult == ISC_R_EXISTS) {
- const char *file;
- unsigned int line;
-
- RUNTIME_CHECK(isc_symtab_lookup(symtab, key,
- ztype == HINTZONE ? 1 : 2,
- &symvalue) == ISC_R_SUCCESS);
- isc_mem_free(mctx, key);
- file = cfg_obj_file(symvalue.as_pointer);
- line = cfg_obj_line(symvalue.as_pointer);
-
- if (file == NULL)
- file = "<unknown file>";
- cfg_obj_log(zconfig, logctx, ISC_LOG_ERROR,
- "zone '%s': already exists "
- "previous definition: %s:%u",
- zname, file, line);
- result = ISC_R_FAILURE;
- } else if (tresult != ISC_R_SUCCESS) {
- isc_mem_free(mctx, key);
-
- return (tresult);
- }
+ tresult = nameexist(zconfig, namebuf, ztype == HINTZONE ? 1 : 2,
+ symtab, "zone '%s': already exists "
+ "previous definition: %s:%u", logctx, mctx);
+ if (tresult != ISC_R_SUCCESS)
+ result = tresult;
}
/*
@@ -1177,6 +1204,7 @@ bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
cfg_listelt_t *velement;
isc_result_t result = ISC_R_SUCCESS;
isc_result_t tresult;
+ isc_symtab_t *symtab = NULL;
static const char *builtin[] = { "localhost", "localnets",
"any", "none"};
@@ -1218,6 +1246,9 @@ bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
}
}
+ tresult = isc_symtab_create(mctx, 100, NULL, NULL, ISC_TRUE, &symtab);
+ if (tresult != ISC_R_SUCCESS)
+ result = tresult;
for (velement = cfg_list_first(views);
velement != NULL;
velement = cfg_list_next(velement))
@@ -1228,6 +1259,8 @@ bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
cfg_obj_t *vclassobj = cfg_tuple_get(view, "class");
dns_rdataclass_t vclass = dns_rdataclass_in;
isc_result_t tresult = ISC_R_SUCCESS;
+ const char *key = cfg_obj_asstring(vname);
+ isc_symvalue_t symvalue;
if (cfg_obj_isstring(vclassobj)) {
isc_textregion_t r;
@@ -1240,12 +1273,43 @@ bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
"view '%s': invalid class %s",
cfg_obj_asstring(vname), r.base);
}
+ if (tresult == ISC_R_SUCCESS && symtab != NULL) {
+ symvalue.as_pointer = view;
+ tresult = isc_symtab_define(symtab, key, vclass,
+ symvalue,
+ isc_symexists_reject);
+ if (tresult == ISC_R_EXISTS) {
+ const char *file;
+ unsigned int line;
+ RUNTIME_CHECK(isc_symtab_lookup(symtab, key,
+ vclass, &symvalue) == ISC_R_SUCCESS);
+ file = cfg_obj_file(symvalue.as_pointer);
+ line = cfg_obj_line(symvalue.as_pointer);
+ cfg_obj_log(view, logctx, ISC_LOG_ERROR,
+ "view '%s': already exists "
+ "previous definition: %s:%u",
+ key, file, line);
+ result = tresult;
+ } else if (result != ISC_R_SUCCESS) {
+ result = tresult;
+ } else if ((strcasecmp(key, "_bind") == 0 &&
+ vclass == dns_rdataclass_ch) ||
+ (strcasecmp(key, "_default") == 0 &&
+ vclass == dns_rdataclass_in)) {
+ cfg_obj_log(view, logctx, ISC_LOG_ERROR,
+ "attempt to redefine builtin view "
+ "'%s'", key);
+ result = ISC_R_EXISTS;
+ }
+ }
if (tresult == ISC_R_SUCCESS)
tresult = check_viewconf(config, voptions,
vclass, logctx, mctx);
if (tresult != ISC_R_SUCCESS)
result = ISC_R_FAILURE;
}
+ if (symtab != NULL)
+ isc_symtab_destroy(&symtab);
if (views != NULL && options != NULL) {
obj = NULL;
diff --git a/dist/bind/lib/bind9/getaddresses.c b/dist/bind/lib/bind9/getaddresses.c
index 2b379b102f5..58745eb4d7e 100644
--- a/dist/bind/lib/bind9/getaddresses.c
+++ b/dist/bind/lib/bind9/getaddresses.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getaddresses.c,v 1.1.1.1 2004/05/17 23:44:48 christos Exp $ */
+/* $NetBSD: getaddresses.c,v 1.1.1.2 2004/11/06 23:55:34 christos Exp $ */
/*
* Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* Id: getaddresses.c,v 1.13.126.4 2004/03/08 09:04:27 marka Exp */
+/* Id: getaddresses.c,v 1.13.126.5 2004/05/15 03:46:12 jinmei Exp */
#include <config.h>
#include <string.h>
@@ -25,6 +25,7 @@
#include <isc/net.h>
#include <isc/netaddr.h>
#include <isc/netdb.h>
+#include <isc/netscope.h>
#include <isc/result.h>
#include <isc/sockaddr.h>
#include <isc/util.h>
@@ -69,19 +70,67 @@ bind9_getaddresses(const char *hostname, in_port_t port,
have_ipv4 = (isc_net_probeipv4() == ISC_R_SUCCESS);
have_ipv6 = (isc_net_probeipv6() == ISC_R_SUCCESS);
- if (inet_pton(AF_INET6, hostname, &in6) == 1) {
- if (!have_ipv6)
- return (ISC_R_FAMILYNOSUPPORT);
- isc_sockaddr_fromin6(&addrs[0], &in6, port);
- *addrcount = 1;
- return (ISC_R_SUCCESS);
- } else if (inet_pton(AF_INET, hostname, &in4) == 1) {
+ /*
+ * Try IPv4, then IPv6. In order to handle the extended format
+ * for IPv6 scoped addresses (address%scope_ID), we'll use a local
+ * working buffer of 128 bytes. The length is an ad-hoc value, but
+ * should be enough for this purpose; the buffer can contain a string
+ * of at least 80 bytes for scope_ID in addition to any IPv6 numeric
+ * addresses (up to 46 bytes), the delimiter character and the
+ * terminating NULL character.
+ */
+ if (inet_pton(AF_INET, hostname, &in4) == 1) {
if (have_ipv4)
isc_sockaddr_fromin(&addrs[0], &in4, port);
else
isc_sockaddr_v6fromin(&addrs[0], &in4, port);
*addrcount = 1;
return (ISC_R_SUCCESS);
+ } else if (strlen(hostname) <= 127) {
+ char tmpbuf[128], *d;
+ isc_uint32_t zone = 0;
+
+ strcpy(tmpbuf, hostname);
+ d = strchr(tmpbuf, '%');
+ if (d != NULL)
+ *d = '\0';
+
+ if (inet_pton(AF_INET6, tmpbuf, &in6) == 1) {
+ isc_netaddr_t na;
+
+ if (!have_ipv6)
+ return (ISC_R_FAMILYNOSUPPORT);
+
+ if (d != NULL) {
+#ifdef ISC_PLATFORM_HAVESCOPEID
+ isc_result_t result;
+
+ result = isc_netscope_pton(AF_INET6, d + 1,
+ &in6, &zone);
+
+ if (result != ISC_R_SUCCESS)
+ return (result);
+#else
+ /*
+ * The extended format is specified while the
+ * system does not provide the ability to use
+ * it. Throw an explicit error instead of
+ * ignoring the specified value.
+ */
+ return (ISC_R_BADADDRESSFORM);
+#endif
+ }
+
+ isc_netaddr_fromin6(&na, &in6);
+ isc_netaddr_setzone(&na, zone);
+ isc_sockaddr_fromnetaddr(&addrs[0],
+ (const isc_netaddr_t *)&na,
+ port);
+
+ *addrcount = 1;
+ return (ISC_R_SUCCESS);
+
+ }
}
#ifdef USE_GETADDRINFO
memset(&hints, 0, sizeof(hints));