]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
9.2.2 patches -- may not be fully complete yet, and html needs to be built
authorMichael Graff <mgraff@isc.org>
Wed, 17 Sep 2003 05:40:40 +0000 (05:40 +0000)
committerMichael Graff <mgraff@isc.org>
Wed, 17 Sep 2003 05:40:40 +0000 (05:40 +0000)
bin/named/server.c
doc/arm/Bv9ARM-book.xml
lib/dns/include/dns/log.h
lib/dns/include/dns/view.h
lib/dns/log.c
lib/dns/ncache.c
lib/dns/resolver.c
lib/dns/view.c
lib/isccfg/check.c
lib/isccfg/parser.c

index 3cf2ce4b59aaa9a624faf822459704d1874488e6..08164a22fec1ff1a61877ef60b10be623eb5723b 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: server.c,v 1.339.2.8.4.3 2003/02/18 03:27:58 marka Exp $ */
+/* $Id: server.c,v 1.339.2.8.4.3.2.1 2003/09/17 05:40:36 explorer Exp $ */
 
 #include <config.h>
 
@@ -1248,6 +1248,7 @@ configure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig,
        cfg_obj_t *typeobj = NULL;
        cfg_obj_t *forwarders = NULL;
        cfg_obj_t *forwardtype = NULL;
+       cfg_obj_t *only = NULL;
        isc_result_t result;
        isc_buffer_t buffer;
        dns_fixedname_t fixorigin;
@@ -1348,6 +1349,14 @@ configure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig,
                goto cleanup;
        }
 
+       /*
+        * "delegation-only zones" aren't zones either.
+        */
+       if (strcasecmp(ztypestr, "delegation-only") == 0) {
+               result = dns_view_adddelegationonly(view, origin);
+               goto cleanup;
+       }
+
        /*
         * Check for duplicates in the new zone table.
         */
@@ -1415,6 +1424,16 @@ configure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig,
                                        forwardtype));
        }
 
+       /*
+        * Stub and forward zones may also refer to delegation only points.
+        */
+       only = NULL;
+       if (cfg_map_get(zoptions, "delegation-only", &only) == ISC_R_SUCCESS)
+       {
+               if (cfg_obj_asboolean(only))
+                       CHECK(dns_view_adddelegationonly(view, origin));
+       }
+
        /*
         * Configure the zone.
         */
index 04fda852fc72dc685292154142b53623cebc3f4c..414eef60fd8c9a7e616c460202c86b4b9e2ff651 100644 (file)
@@ -2,7 +2,7 @@
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
                "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
 
-<!-- File: $Id: Bv9ARM-book.xml,v 1.155.2.22.4.1 2003/02/17 01:29:29 marka Exp $ -->
+<!-- File: $Id: Bv9ARM-book.xml,v 1.155.2.22.4.1.2.1 2003/09/17 05:40:37 explorer Exp $ -->
 
 <book>
 <title>BIND 9 Administrator Reference Manual</title>
@@ -2706,6 +2706,14 @@ in remote servers, discovered by BIND 9 when trying to query
 those servers during resolution.
 </para></entry>
 </row>
+<row rowsep = "0">
+<entry colname = "1"><para><command>delegation-only</command></para></entry>
+<entry colname = "2"><para>Delegation only.  Logs queries that have have
+been forced to NXDOMAIN as the result of a delegation-only zone or
+a <command>delegation-only</command> in a stub or forward
+zone declartation.
+</para></entry>
+</row>
 </tbody>
 </tgroup></informaltable>
 </sect3>
@@ -4217,7 +4225,7 @@ view "external" {
 <sect2 id="zone_statement_grammar"><title><command>zone</command>
 Statement Grammar</title>
       <programlisting>zone <replaceable>zone_name</replaceable> <optional><replaceable>class</replaceable></optional> <optional>{ 
-    type ( master | slave | hint | stub | forward ) ;
+    type ( master | slave | hint | stub | forward /| delegation-only ) ;
     <optional> allow-notify { <replaceable>address_match_list</replaceable> } ; </optional>
     <optional> allow-query { <replaceable>address_match_list</replaceable> } ; </optional>
     <optional> allow-transfer { <replaceable>address_match_list</replaceable> } ; </optional>
@@ -4227,6 +4235,7 @@ Statement Grammar</title>
     <optional> also-notify { <replaceable>ip_addr</replaceable> <optional>port <replaceable>ip_port</replaceable></optional> ; <optional> <replaceable>ip_addr</replaceable> <optional>port <replaceable>ip_port</replaceable></optional> ; ... </optional> }; </optional>
     <optional> check-names (<constant>warn</constant>|<constant>fail</constant>|<constant>ignore</constant>) ; </optional>
     <optional> dialup <replaceable>dialup_option</replaceable> ; </optional>
+    <optional> delegation-only <replaceable>yes_or_no</replaceable> ; </optional>
     <optional> file <replaceable>string</replaceable> ; </optional>
     <optional> forward (<constant>only</constant>|<constant>first</constant>) ; </optional>
     <optional> forwarders { <replaceable>ip_addr</replaceable> <optional>port <replaceable>ip_port</replaceable></optional> ; <optional> <replaceable>ip_addr</replaceable> <optional>port <replaceable>ip_port</replaceable></optional> ; ... </optional> }; </optional>
@@ -4349,6 +4358,14 @@ list of root nameservers. If no hint zone is specified for class
 IN, the server uses a compiled-in default set of root servers hints.
 Classes other than IN have no built-in defaults hints.</para></entry>
 </row>
+<row rowsep = "0">
+<entry colname = "1"><para><varname>delegation-only</varname></para></entry>
+<entry colname = "2"><para>This is used to enforce the delegation only
+status of infrastructure zones (e.g. COM, NET, ORG).  Any answer that
+is received without a explicit or implict delegation in the authority
+section will be treated as NXDOMAIN.  This does not apply to the zone
+apex.  This SHOULD NOT be applied to leaf zones.</para></entry>
+</row>
 </tbody>
 </tgroup></informaltable></sect3>
 
@@ -4454,6 +4471,13 @@ with the distribution but none are linked in by default.</para>
 <command>dialup</command> in <xref linkend="boolean_options"/>.</para>
 </listitem></varlistentry>
 
+<varlistentry><term><command>delegation-only</command></term>
+<listitem><para>The flag only applies to forward and stub zones.  If set
+to <userinput>yes</userinput> then the zone will also be treated as if it
+is also a delegation-only type zone.
+</para>
+</listitem></varlistentry>
+
 <varlistentry><term><command>forward</command></term>
 <listitem><para>Only meaningful if the zone has a forwarders
 list. The <command>only</command> value causes the lookup to fail
index b65259d17274492f6e2c08d22a181420d3b73a59..eeaa5b775f178087fe313c6ba2ef8e4001274c07 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: log.h,v 1.30.2.1 2001/10/11 02:03:23 marka Exp $ */
+/* $Id: log.h,v 1.30.2.1.12.1 2003/09/17 05:40:40 explorer Exp $ */
 
 /* Principal Authors: DCL */
 
@@ -39,6 +39,7 @@ LIBDNS_EXTERNAL_DATA extern isc_logmodule_t dns_modules[];
 #define DNS_LOGCATEGORY_XFER_OUT       (&dns_categories[7])
 #define DNS_LOGCATEGORY_DISPATCH       (&dns_categories[8])
 #define DNS_LOGCATEGORY_LAME_SERVERS   (&dns_categories[9])
+#define DNS_LOGCATEGORY_DELEGATION_ONLY        (&dns_categories[10])
 
 /* Backwards compatibility. */
 #define DNS_LOGCATEGORY_GENERAL                ISC_LOGCATEGORY_GENERAL
index 4d45665eadd02f22bfa0f023bbdf6b51b518a365..07674f528eb869272001922efab92febf95321c3 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: view.h,v 1.73.2.2 2002/08/05 06:57:13 marka Exp $ */
+/* $Id: view.h,v 1.73.2.2.6.1 2003/09/17 05:40:40 explorer Exp $ */
 
 #ifndef DNS_VIEW_H
 #define DNS_VIEW_H 1
@@ -118,6 +118,7 @@ struct dns_view {
        in_port_t                       dstport;
        dns_aclenv_t                    aclenv;
        isc_boolean_t                   flush;
+       dns_namelist_t *                delonly;
 
        /*
         * Configurable data for server use only,
@@ -691,6 +692,35 @@ dns_view_flushcache(dns_view_t *view);
  *     ISC_R_NOMEMORY
  */
 
+isc_result_t
+dns_view_adddelegationonly(dns_view_t *view, dns_name_t *name);
+/*
+ * Add the given name to the delegation only table.
+ *
+ * Requires:
+ *     'view' is valid.
+ *     'name' is valid.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS
+ *     ISC_R_NOMEMORY
+ */
+
+isc_boolean_t
+dns_view_isdelegationonly(dns_view_t *view, dns_name_t *name);
+/*
+ * Check if 'name' is in the delegation only table.
+ *
+ * Requires:
+ *     'view' is valid.
+ *     'name' is valid.
+ *
+ * Returns:
+ *     ISC_TRUE if the name is is the table.
+ *     ISC_FALSE othewise.
+ */
+
+
 ISC_LANG_ENDDECLS
 
 #endif /* DNS_VIEW_H */
index 7f4fe1eb548a97da780b348c25d6e21dc555d839..85b182ad5aafe6a8819b505bb96ae6866a483f97 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: log.c,v 1.33.2.2 2001/10/11 23:07:00 gson Exp $ */
+/* $Id: log.c,v 1.33.2.2.12.1 2003/09/17 05:40:39 explorer Exp $ */
 
 /* Principal Authors: DCL */
 
@@ -40,6 +40,7 @@ LIBDNS_EXTERNAL_DATA isc_logcategory_t dns_categories[] = {
        { "xfer-out",   0 },
        { "dispatch",   0 },
        { "lame-servers", 0 },
+       { "delegation-only", 0 },
        { NULL,         0 }
 };
 
index 841f6d02bb3255fc39314f17aa1f2dcefc5cf9ae..5ed81d9718c7e35cd28bf4aa47934d33d576324a 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: ncache.c,v 1.24.2.2 2002/02/08 03:57:29 marka Exp $ */
+/* $Id: ncache.c,v 1.24.2.2.6.1 2003/09/17 05:40:39 explorer Exp $ */
 
 #include <config.h>
 
@@ -121,7 +121,10 @@ dns_ncache_add(dns_message_t *message, dns_db_t *cache, dns_dbnode_t *node,
        ttl = maxttl;
        trust = 0xffff;
        isc_buffer_init(&buffer, data, sizeof(data));
-       result = dns_message_firstname(message, DNS_SECTION_AUTHORITY);
+       if (message->counts[DNS_SECTION_AUTHORITY])
+               result = dns_message_firstname(message, DNS_SECTION_AUTHORITY);
+       else
+               result = ISC_R_NOMORE;
        while (result == ISC_R_SUCCESS) {
                name = NULL;
                dns_message_currentname(message, DNS_SECTION_AUTHORITY,
index e008b9d54b44710ae50eeaff0eae8c50310bf00d..8e0ba110056be1a6f8164d3c722a60e0aaa848e2 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resolver.c,v 1.218.2.12.4.4 2003/02/18 03:32:01 marka Exp $ */
+/* $Id: resolver.c,v 1.218.2.12.4.4.2.1 2003/09/17 05:40:39 explorer Exp $ */
 
 #include <config.h>
 
@@ -291,6 +291,53 @@ static isc_result_t ncache_adderesult(dns_message_t *message,
                                      dns_rdataset_t *ardataset,
                                      isc_result_t *eresultp);
 
+static isc_boolean_t
+fix_mustbedelegationornxdomain(dns_message_t *message, dns_name_t *domain) {
+
+       dns_name_t *name;
+       dns_rdataset_t *rdataset;
+       dns_rdatatype_t type;
+       isc_result_t result;
+       isc_boolean_t keep_auth = ISC_FALSE;
+
+       if (message->rcode == dns_rcode_nxdomain)
+               return (ISC_FALSE);
+
+       /* Look for referral. */
+       if (message->counts[DNS_SECTION_AUTHORITY] == 0)
+               goto munge;
+
+       result = dns_message_firstname(message, DNS_SECTION_AUTHORITY);
+       while (result == ISC_R_SUCCESS) {
+               name = NULL;
+               dns_message_currentname(message, DNS_SECTION_AUTHORITY,
+                                       &name);
+               for (rdataset = ISC_LIST_HEAD(name->list);
+                    rdataset != NULL;
+                    rdataset = ISC_LIST_NEXT(rdataset, link)) {
+                       type = rdataset->type;
+                       if (type == dns_rdatatype_soa &&
+                           dns_name_equal(name, domain))
+                               keep_auth = ISC_TRUE;
+                       if (type != dns_rdatatype_ns)
+                               continue;
+                       if (dns_name_equal(name, domain))
+                               goto munge;
+                       if (dns_name_issubdomain(name, domain))
+                               return (ISC_FALSE);
+               }
+               result = dns_message_nextname(message, DNS_SECTION_AUTHORITY);
+       }
+
+ munge:
+       message->rcode = dns_rcode_nxdomain;
+       message->counts[DNS_SECTION_ANSWER] = 0;
+       if (!keep_auth)
+               message->counts[DNS_SECTION_AUTHORITY] = 0;
+       message->counts[DNS_SECTION_ADDITIONAL] = 0;
+       return (ISC_TRUE);
+}
+
 static inline isc_result_t
 fctx_starttimer(fetchctx_t *fctx) {
        /*
@@ -4428,6 +4475,24 @@ resquery_response(isc_task_t *task, isc_event_t *event) {
                goto done;
        }
 
+       /*
+        * Enforce delegations only zones like NET and COM.
+        */
+       if (dns_view_isdelegationonly(fctx->res->view, &fctx->domain) &&
+           !dns_name_equal(&fctx->domain, &fctx->name) &&
+           fix_mustbedelegationornxdomain(message, &fctx->domain)) {
+               char namebuf[DNS_NAME_FORMATSIZE];
+               char domainbuf[DNS_NAME_FORMATSIZE];
+
+               dns_name_format(&fctx->name, namebuf, sizeof(namebuf));
+               dns_name_format(&fctx->domain, domainbuf, sizeof(domainbuf));
+
+               isc_log_write(dns_lctx, DNS_LOGCATEGORY_DELEGATION_ONLY,
+                            DNS_LOGMODULE_RESOLVER, ISC_LOG_NOTICE,
+                            "enforced delegation-only for '%s' (%s)",
+                            domainbuf, namebuf);
+       }
+
        /*
         * Follow A6 and other additional section data chains.
         */
index 4076010ecd8bfc6696083c8f429486253e37a963..1db2a5e7861babe4a8886882e992561747e2f303 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: view.c,v 1.103.2.2 2002/08/05 06:57:12 marka Exp $ */
+/* $Id: view.c,v 1.103.2.2.6.1 2003/09/17 05:40:40 explorer Exp $ */
 
 #include <config.h>
 
@@ -45,6 +45,8 @@
 #define ADBSHUTDOWN(v) (((v)->attributes & DNS_VIEWATTR_ADBSHUTDOWN) != 0)
 #define REQSHUTDOWN(v) (((v)->attributes & DNS_VIEWATTR_REQSHUTDOWN) != 0)
 
+#define DNS_VIEW_DELONLYHASH 111
+
 static void resolver_shutdown(isc_task_t *task, isc_event_t *event);
 static void adb_shutdown(isc_task_t *task, isc_event_t *event);
 static void req_shutdown(isc_task_t *task, isc_event_t *event);
@@ -139,6 +141,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
        if (result != ISC_R_SUCCESS)
                goto cleanup_fwdtable;
        view->peers = NULL;
+       view->delonly = NULL;
 
        /*
         * Initialize configuration data with default values.
@@ -255,6 +258,23 @@ destroy(dns_view_t *view) {
                dns_acl_detach(&view->v6synthesisacl);
        if (view->sortlist != NULL)
                dns_acl_detach(&view->sortlist);
+       if (view->delonly != NULL) {
+               dns_name_t *name;
+               int i;
+
+               for (i = 0; i < DNS_VIEW_DELONLYHASH; i++) {
+                       name = ISC_LIST_HEAD(view->delonly[i]);
+                       while (name != NULL) {
+                               ISC_LIST_UNLINK(view->delonly[i], name, link);
+                               dns_name_free(name, view->mctx);
+                               isc_mem_put(view->mctx, name, sizeof(*name));
+                               name = ISC_LIST_HEAD(view->delonly[i]);
+                       }
+               }
+               isc_mem_put(view->mctx, view->delonly, sizeof(dns_namelist_t) *
+                           DNS_VIEW_DELONLYHASH);
+               view->delonly = NULL;
+       }
        dns_keytable_detach(&view->trustedkeys);
        dns_keytable_detach(&view->secroots);
        dns_fwdtable_destroy(&view->fwdtable);
@@ -1135,3 +1155,57 @@ dns_view_flushcache(dns_view_t *view) {
        dns_adb_flush(view->adb);
        return (ISC_R_SUCCESS);
 }
+
+isc_result_t
+dns_view_adddelegationonly(dns_view_t *view, dns_name_t *name) {
+       isc_result_t result;
+       dns_name_t *new;
+       isc_uint32_t hash;
+
+       REQUIRE(DNS_VIEW_VALID(view));
+
+       if (view->delonly == NULL) {
+               view->delonly = isc_mem_get(view->mctx,
+                                           sizeof(dns_namelist_t) *
+                                           DNS_VIEW_DELONLYHASH);
+               if (view->delonly == NULL)
+                       return (ISC_R_NOMEMORY);
+               for (hash = 0; hash < DNS_VIEW_DELONLYHASH; hash++)
+                       ISC_LIST_INIT(view->delonly[hash]);
+       }
+       hash = dns_name_hash(name, ISC_FALSE) % DNS_VIEW_DELONLYHASH;
+       new = ISC_LIST_HEAD(view->delonly[hash]);
+       while (new != NULL && !dns_name_equal(new, name))
+               new = ISC_LIST_NEXT(new, link);
+       if (new != NULL)
+               return (ISC_R_SUCCESS);
+       new = isc_mem_get(view->mctx, sizeof(*new));
+       if (new == NULL)
+               return (ISC_R_NOMEMORY);
+       dns_name_init(new, NULL);
+       result = dns_name_dup(name, view->mctx, new);
+       if (result == ISC_R_SUCCESS)
+               ISC_LIST_APPEND(view->delonly[hash], new, link);
+       else
+               isc_mem_put(view->mctx, new, sizeof(*new));
+       return (result);
+}
+
+isc_result_t
+dns_view_isdelegationonly(dns_view_t *view, dns_name_t *name) {
+       dns_name_t *new;
+       isc_uint32_t hash;
+
+       REQUIRE(DNS_VIEW_VALID(view));
+
+       if (view->delonly == NULL)
+               return (ISC_FALSE);
+
+       hash = dns_name_hash(name, ISC_FALSE) % DNS_VIEW_DELONLYHASH;
+       new = ISC_LIST_HEAD(view->delonly[hash]);
+       while (new != NULL && !dns_name_equal(new, name))
+               new = ISC_LIST_NEXT(new, link);
+       if (new == NULL)
+               return (ISC_FALSE);
+       return (ISC_TRUE);
+}
index b762c73bb5eb1dd1fcc86c930d1434bf49032d62..d2be9733c47a8c4b8d94ee92ac05518e08b8bf19 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: check.c,v 1.14.2.16 2002/04/23 02:00:03 marka Exp $ */
+/* $Id: check.c,v 1.14.2.16.6.1 2003/09/17 05:40:40 explorer Exp $ */
 
 #include <config.h>
 
@@ -100,6 +100,7 @@ check_options(cfg_obj_t *options, isc_log_t *logctx) {
 #define STUBZONE       4
 #define HINTZONE       8
 #define FORWARDZONE    16
+#define DELEGATIONZONE 32
 
 typedef struct {
        const char *name;
@@ -130,6 +131,7 @@ check_zoneconf(cfg_obj_t *zconfig, isc_symtab_t *symtab, isc_log_t *logctx,
        { "notify", MASTERZONE | SLAVEZONE },
        { "also-notify", MASTERZONE | SLAVEZONE },
        { "dialup", MASTERZONE | SLAVEZONE | STUBZONE },
+       { "delegation-only", STUBZONE | FORWARDZONE},
        { "forward", MASTERZONE | SLAVEZONE | STUBZONE | FORWARDZONE},
        { "forwarders", MASTERZONE | SLAVEZONE | STUBZONE | FORWARDZONE},
        { "maintain-ixfr-base", MASTERZONE | SLAVEZONE },
@@ -189,6 +191,8 @@ check_zoneconf(cfg_obj_t *zconfig, isc_symtab_t *symtab, isc_log_t *logctx,
                ztype = FORWARDZONE;
        else if (strcasecmp(typestr, "hint") == 0)
                ztype = HINTZONE;
+       else if (strcasecmp(typestr, "delegation-only") == 0)
+               ztype = DELEGATIONZONE;
        else {
                cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
                            "zone '%s': invalid type %s",
index dc87923187cfa6d4cd7c9b33475e7b41b2991d3b..aee9b37cadd8979ee26cadfaa2c3e36b02c75194 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: parser.c,v 1.70.2.14.4.2 2003/02/17 07:05:10 marka Exp $ */
+/* $Id: parser.c,v 1.70.2.14.4.2.2.1 2003/09/17 05:40:40 explorer Exp $ */
 
 #include <config.h>
 
@@ -755,7 +755,7 @@ static cfg_type_t cfg_type_forwardtype = {
 };
 
 static const char *zonetype_enums[] = {
-       "master", "slave", "stub", "hint", "forward", NULL };
+       "master", "slave", "stub", "hint", "forward", "delegation-only", NULL };
 static cfg_type_t cfg_type_zonetype = {
        "zonetype", parse_enum, print_ustring, &cfg_rep_string,
        &zonetype_enums
@@ -955,6 +955,7 @@ zone_only_clauses[] = {
          CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_OBSOLETE },
        { "update-policy", &cfg_type_updatepolicy, 0 },
        { "database", &cfg_type_astring, 0 },
+       { "delegation-only", &cfg_type_boolean, 0 },
        /*
         * Note that the format of the check-names option is different between
         * the zone options and the global/view options.  Ugh.