]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1634. [bug] named didn't supply a useful error message when it
authorMark Andrews <marka@isc.org>
Mon, 17 May 2004 05:37:41 +0000 (05:37 +0000)
committerMark Andrews <marka@isc.org>
Mon, 17 May 2004 05:37:41 +0000 (05:37 +0000)
                        detected duplicate views.  [RT #11208]

CHANGES
lib/bind9/check.c

diff --git a/CHANGES b/CHANGES
index 9cdf77afcd575d420b9865263bfda508aa7af518..81bb8b799fa9fae06d7b6828bc9d54ab97d79c39 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -14,7 +14,8 @@
 
 1635.  [bug]           Memory leak on error in query_addds().
 
-1634.  [placeholder]   rt11208
+1634.  [bug]           named didn't supply a useful error message when it
+                       detected duplicate views.  [RT #11208]
 
 1633.  [bug]           named should return NOTIMP to update requests to a
                        slaves without a allow-update-forwarding acl specified.
index db90d6c7a64f64e549f3d33767aa592fe27d9da5..b4b205c507c83f475920f622e84f545c00493470 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: check.c,v 1.45 2004/04/15 23:40:24 marka Exp $ */
+/* $Id: check.c,v 1.46 2004/05/17 05:37:41 marka Exp $ */
 
 #include <config.h>
 
@@ -1175,6 +1175,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"};
@@ -1216,6 +1217,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))
@@ -1226,6 +1230,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;
@@ -1238,12 +1244,34 @@ 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;
+               }
                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;