]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Move bind9/check to isccfg/check
authorTony Finch <fanf@isc.org>
Fri, 16 Dec 2022 10:39:15 +0000 (10:39 +0000)
committerTony Finch <fanf@isc.org>
Fri, 17 Feb 2023 12:13:37 +0000 (12:13 +0000)
Since it is part of the configuration machinery

CHANGES
bin/check/named-checkconf.c
bin/named/controlconf.c
bin/named/server.c
lib/bind9/Makefile.am
lib/isccfg/Makefile.am
lib/isccfg/check.c [moved from lib/bind9/check.c with 98% similarity]
lib/isccfg/include/isccfg/check.h [moved from lib/bind9/include/bind9/check.h with 81% similarity]
lib/isccfg/namedconf.c

diff --git a/CHANGES b/CHANGES
index 121b111af293c72af88776de657820ecb63559b9..cb3c764c134210d556c0664348717995baa446d8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+6104.  [cleanup]       Move libbind9's configuration checking code into
+                       libisccfg alongside the other configuration code.
+                       [GL !7461]
+
 6103.  [func]          All uses of the isc_task and isc_event APIs have
                        been refactored to use isc_loop instead, and the
                        original APIs have been removed. [GL #3797]
index 807c2c2592720ed3e77abb25155f52c60bdcc522..a24435f03eba27526304517f8167478786e26966 100644 (file)
 #include <dns/rootns.h>
 #include <dns/zone.h>
 
+#include <isccfg/check.h>
 #include <isccfg/grammar.h>
 #include <isccfg/namedconf.h>
 
-#include <bind9/check.h>
-
 #include "check-tool.h"
 
 static const char *program = "named-checkconf";
@@ -734,7 +733,7 @@ main(int argc, char **argv) {
                exit(1);
        }
 
-       result = bind9_check_namedconf(config, loadplugins, logc, mctx);
+       result = isccfg_check_namedconf(config, loadplugins, logc, mctx);
        if (result != ISC_R_SUCCESS) {
                exit_status = 1;
        }
index 384ed0fa298c0279680c29614ea8ad76dd035a80..8e1ecd08d40b8e366d718605631f6868c0dfc467 100644 (file)
 #include <isccc/symtab.h>
 #include <isccc/util.h>
 
+#include <isccfg/check.h>
 #include <isccfg/namedconf.h>
 
-#include <bind9/check.h>
-
 #include <named/config.h>
 #include <named/control.h>
 #include <named/log.h>
@@ -839,7 +838,7 @@ get_rndckey(isc_mem_t *mctx, controlkeylist_t *keyids) {
                CHECK(ISC_R_NOMEMORY);
        }
 
-       CHECK(bind9_check_key(key, named_g_lctx));
+       CHECK(isccfg_check_key(key, named_g_lctx));
 
        (void)cfg_map_get(key, "algorithm", &algobj);
        (void)cfg_map_get(key, "secret", &secretobj);
index bf4b3e10c7a8e73510eab8f2347fd56c92249c98..c2299675318ee76c227f5c36ccfc8058f899a460 100644 (file)
 
 #include <dst/dst.h>
 
+#include <isccfg/check.h>
 #include <isccfg/grammar.h>
 #include <isccfg/kaspconf.h>
 #include <isccfg/namedconf.h>
 #include <ns/interfacemgr.h>
 #include <ns/listenlist.h>
 
-#include <bind9/check.h>
-
 #include <named/config.h>
 #include <named/control.h>
 #if defined(HAVE_GEOIP2)
@@ -8423,8 +8422,8 @@ load_configuration(const char *filename, named_server_t *server,
         * checked later when the modules are actually loaded and
         * registered.)
         */
-       result = bind9_check_namedconf(config, false, named_g_lctx,
-                                      named_g_mctx);
+       result = isccfg_check_namedconf(config, false, named_g_lctx,
+                                       named_g_mctx);
        if (result != ISC_R_SUCCESS) {
                goto cleanup_config;
        }
index 7ec5bdd3bc115c297c5dbbff56b73d46abd2af46..c48018a906262a078605d28059cb82dee7d18c2b 100644 (file)
@@ -3,13 +3,12 @@ include $(top_srcdir)/Makefile.top
 lib_LTLIBRARIES = libbind9.la
 
 libbind9_ladir = $(includedir)/bind9
+
 libbind9_la_HEADERS =                  \
-       include/bind9/check.h           \
        include/bind9/getaddresses.h
 
 libbind9_la_SOURCES =          \
        $(libbind9_la_HEADERS)  \
-       check.c                 \
        getaddresses.c
 
 libbind9_la_CPPFLAGS =         \
index 0c95c4f0d432011942ae01f99d203dc2f06f43df..2b1f27e3dd32e3f0b2f6d94868d5cedaa92bbd83 100644 (file)
@@ -6,6 +6,7 @@ libisccfg_ladir = $(includedir)/isccfg
 libisccfg_la_HEADERS =                 \
        include/isccfg/aclconf.h        \
        include/isccfg/cfg.h            \
+       include/isccfg/check.h          \
        include/isccfg/duration.h       \
        include/isccfg/grammar.h        \
        include/isccfg/kaspconf.h       \
@@ -15,6 +16,7 @@ libisccfg_la_HEADERS =                        \
 libisccfg_la_SOURCES =                 \
        $(libisccfg_la_HEADERS)         \
        aclconf.c                       \
+       check.c                         \
        dnsconf.c                       \
        duration.c                      \
        kaspconf.c                      \
@@ -26,12 +28,20 @@ libisccfg_la_CPPFLAGS =                     \
        $(AM_CPPFLAGS)                  \
        $(LIBISCCFG_CFLAGS)             \
        $(LIBISC_CFLAGS)                \
-       $(LIBDNS_CFLAGS)
+       $(LIBDNS_CFLAGS)                \
+       $(LIBNS_CFLAGS)                 \
+       $(OPENSSL_CFLAGS)
 
 libisccfg_la_LIBADD =  \
        $(LIBDNS_LIBS)  \
-       $(LIBISC_LIBS)
+       $(LIBISC_LIBS)  \
+       $(LIBNS_LIBS)   \
+       $(OPENSSL_LIBS)
 
 libisccfg_la_LDFLAGS =         \
        $(AM_LDFLAGS)           \
        -release "$(PACKAGE_VERSION)"
+
+if HAVE_DNSTAP
+libisccfg_la_CPPFLAGS += $(DNSTAP_CFLAGS)
+endif
similarity index 98%
rename from lib/bind9/check.c
rename to lib/isccfg/check.c
index 1482de1310b747cb75470122201e483ee55567a9..1846ee5df7375cf26bef92e837001f76ccef863f 100644 (file)
 
 #include <isccfg/aclconf.h>
 #include <isccfg/cfg.h>
+#include <isccfg/check.h>
 #include <isccfg/grammar.h>
 #include <isccfg/kaspconf.h>
 #include <isccfg/namedconf.h>
 
 #include <ns/hooks.h>
 
-#include <bind9/check.h>
-
 static in_port_t dnsport = 53;
 
 static isc_result_t
@@ -2012,9 +2011,9 @@ check_options(const cfg_obj_t *options, const cfg_obj_t *config,
  * Check "remote-servers" style list.
  */
 static isc_result_t
-bind9_check_remoteserverlist(const cfg_obj_t *cctx, const char *list,
-                            isc_log_t *logctx, isc_symtab_t *symtab,
-                            isc_mem_t *mctx) {
+check_remoteserverlist(const cfg_obj_t *cctx, const char *list,
+                      isc_log_t *logctx, isc_symtab_t *symtab,
+                      isc_mem_t *mctx) {
        isc_symvalue_t symvalue;
        isc_result_t result, tresult;
        const cfg_obj_t *obj = NULL;
@@ -2072,8 +2071,7 @@ bind9_check_remoteserverlist(const cfg_obj_t *cctx, const char *list,
  * Check primaries lists for duplicates.
  */
 static isc_result_t
-bind9_check_primarylists(const cfg_obj_t *cctx, isc_log_t *logctx,
-                        isc_mem_t *mctx) {
+check_primarylists(const cfg_obj_t *cctx, isc_log_t *logctx, isc_mem_t *mctx) {
        isc_result_t result, tresult;
        isc_symtab_t *symtab = NULL;
 
@@ -2081,13 +2079,12 @@ bind9_check_primarylists(const cfg_obj_t *cctx, isc_log_t *logctx,
        if (result != ISC_R_SUCCESS) {
                return (result);
        }
-       tresult = bind9_check_remoteserverlist(cctx, "primaries", logctx,
-                                              symtab, mctx);
+       tresult = check_remoteserverlist(cctx, "primaries", logctx, symtab,
+                                        mctx);
        if (tresult != ISC_R_SUCCESS) {
                result = tresult;
        }
-       tresult = bind9_check_remoteserverlist(cctx, "masters", logctx, symtab,
-                                              mctx);
+       tresult = check_remoteserverlist(cctx, "masters", logctx, symtab, mctx);
        if (tresult != ISC_R_SUCCESS) {
                result = tresult;
        }
@@ -2099,8 +2096,8 @@ bind9_check_primarylists(const cfg_obj_t *cctx, isc_log_t *logctx,
  * Check parental-agents lists for duplicates.
  */
 static isc_result_t
-bind9_check_parentalagentlists(const cfg_obj_t *cctx, isc_log_t *logctx,
-                              isc_mem_t *mctx) {
+check_parentalagentlists(const cfg_obj_t *cctx, isc_log_t *logctx,
+                        isc_mem_t *mctx) {
        isc_result_t result, tresult;
        isc_symtab_t *symtab = NULL;
 
@@ -2108,8 +2105,8 @@ bind9_check_parentalagentlists(const cfg_obj_t *cctx, isc_log_t *logctx,
        if (result != ISC_R_SUCCESS) {
                return (result);
        }
-       tresult = bind9_check_remoteserverlist(cctx, "parental-agents", logctx,
-                                              symtab, mctx);
+       tresult = check_remoteserverlist(cctx, "parental-agents", logctx,
+                                        symtab, mctx);
        if (tresult != ISC_R_SUCCESS) {
                result = tresult;
        }
@@ -2119,8 +2116,8 @@ bind9_check_parentalagentlists(const cfg_obj_t *cctx, isc_log_t *logctx,
 
 #if HAVE_LIBNGHTTP2
 static isc_result_t
-bind9_check_httpserver(const cfg_obj_t *http, isc_log_t *logctx,
-                      isc_symtab_t *symtab) {
+check_httpserver(const cfg_obj_t *http, isc_log_t *logctx,
+                isc_symtab_t *symtab) {
        isc_result_t result, tresult;
        const char *name = cfg_obj_asstring(cfg_map_getname(http));
        const cfg_obj_t *eps = NULL;
@@ -2182,8 +2179,7 @@ bind9_check_httpserver(const cfg_obj_t *http, isc_log_t *logctx,
 }
 
 static isc_result_t
-bind9_check_httpservers(const cfg_obj_t *config, isc_log_t *logctx,
-                       isc_mem_t *mctx) {
+check_httpservers(const cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
        isc_result_t result, tresult;
        const cfg_obj_t *obj = NULL;
        const cfg_listelt_t *elt = NULL;
@@ -2202,7 +2198,7 @@ bind9_check_httpservers(const cfg_obj_t *config, isc_log_t *logctx,
 
        for (elt = cfg_list_first(obj); elt != NULL; elt = cfg_list_next(elt)) {
                obj = cfg_listelt_value(elt);
-               tresult = bind9_check_httpserver(obj, logctx, symtab);
+               tresult = check_httpserver(obj, logctx, symtab);
                if (result == ISC_R_SUCCESS) {
                        result = tresult;
                }
@@ -2215,8 +2211,8 @@ done:
 #endif /* HAVE_LIBNGHTTP2 */
 
 static isc_result_t
-bind9_check_tls_defintion(const cfg_obj_t *tlsobj, const char *name,
-                         isc_log_t *logctx, isc_symtab_t *symtab) {
+check_tls_defintion(const cfg_obj_t *tlsobj, const char *name,
+                   isc_log_t *logctx, isc_symtab_t *symtab) {
        isc_result_t result, tresult;
        const cfg_obj_t *tls_proto_list = NULL, *tls_key = NULL,
                        *tls_cert = NULL, *tls_ciphers = NULL;
@@ -2338,8 +2334,8 @@ bind9_check_tls_defintion(const cfg_obj_t *tlsobj, const char *name,
 }
 
 static isc_result_t
-bind9_check_tls_definitions(const cfg_obj_t *config, isc_log_t *logctx,
-                           isc_mem_t *mctx) {
+check_tls_definitions(const cfg_obj_t *config, isc_log_t *logctx,
+                     isc_mem_t *mctx) {
        isc_result_t result, tresult;
        const cfg_obj_t *obj = NULL;
        const cfg_listelt_t *elt = NULL;
@@ -2360,7 +2356,7 @@ bind9_check_tls_definitions(const cfg_obj_t *config, isc_log_t *logctx,
                const char *name;
                obj = cfg_listelt_value(elt);
                name = cfg_obj_asstring(cfg_map_getname(obj));
-               tresult = bind9_check_tls_defintion(obj, name, logctx, symtab);
+               tresult = check_tls_defintion(obj, name, logctx, symtab);
                if (result == ISC_R_SUCCESS) {
                        result = tresult;
                }
@@ -3889,7 +3885,7 @@ typedef struct keyalgorithms {
 } algorithmtable;
 
 isc_result_t
-bind9_check_key(const cfg_obj_t *key, isc_log_t *logctx) {
+isccfg_check_key(const cfg_obj_t *key, isc_log_t *logctx) {
        const cfg_obj_t *algobj = NULL;
        const cfg_obj_t *secretobj = NULL;
        const char *keyname = cfg_obj_asstring(cfg_map_getname(key));
@@ -4111,7 +4107,7 @@ check_keylist(const cfg_obj_t *keys, isc_symtab_t *symtab, isc_mem_t *mctx,
                        result = tresult;
                        continue;
                }
-               tresult = bind9_check_key(key, logctx);
+               tresult = isccfg_check_key(key, logctx);
                if (tresult != ISC_R_SUCCESS) {
                        return (tresult);
                }
@@ -5662,8 +5658,7 @@ static const char *default_channels[] = { "default_syslog", "default_stderr",
                                          "default_debug", "null", NULL };
 
 static isc_result_t
-bind9_check_logging(const cfg_obj_t *config, isc_log_t *logctx,
-                   isc_mem_t *mctx) {
+check_logging(const cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
        const cfg_obj_t *categories = NULL;
        const cfg_obj_t *category;
        const cfg_obj_t *channels = NULL;
@@ -5775,8 +5770,8 @@ bind9_check_logging(const cfg_obj_t *config, isc_log_t *logctx,
 }
 
 static isc_result_t
-bind9_check_controlskeys(const cfg_obj_t *control, const cfg_obj_t *keylist,
-                        isc_log_t *logctx) {
+check_controlskeys(const cfg_obj_t *control, const cfg_obj_t *keylist,
+                  isc_log_t *logctx) {
        isc_result_t result = ISC_R_SUCCESS;
        const cfg_obj_t *control_keylist;
        const cfg_listelt_t *element;
@@ -5804,8 +5799,7 @@ bind9_check_controlskeys(const cfg_obj_t *control, const cfg_obj_t *keylist,
 }
 
 static isc_result_t
-bind9_check_controls(const cfg_obj_t *config, isc_log_t *logctx,
-                    isc_mem_t *mctx) {
+check_controls(const cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
        isc_result_t result = ISC_R_SUCCESS, tresult;
        cfg_aclconfctx_t *actx = NULL;
        const cfg_listelt_t *element, *element2;
@@ -5856,8 +5850,7 @@ bind9_check_controls(const cfg_obj_t *config, isc_log_t *logctx,
                        if (tresult != ISC_R_SUCCESS) {
                                result = tresult;
                        }
-                       tresult = bind9_check_controlskeys(control, keylist,
-                                                          logctx);
+                       tresult = check_controlskeys(control, keylist, logctx);
                        if (tresult != ISC_R_SUCCESS) {
                                result = tresult;
                        }
@@ -5896,8 +5889,7 @@ bind9_check_controls(const cfg_obj_t *config, isc_log_t *logctx,
                                            "to nobody",
                                            path);
                        }
-                       tresult = bind9_check_controlskeys(control, keylist,
-                                                          logctx);
+                       tresult = check_controlskeys(control, keylist, logctx);
                        if (tresult != ISC_R_SUCCESS) {
                                result = tresult;
                        }
@@ -5908,8 +5900,8 @@ bind9_check_controls(const cfg_obj_t *config, isc_log_t *logctx,
 }
 
 isc_result_t
-bind9_check_namedconf(const cfg_obj_t *config, bool check_plugins,
-                     isc_log_t *logctx, isc_mem_t *mctx) {
+isccfg_check_namedconf(const cfg_obj_t *config, bool check_plugins,
+                      isc_log_t *logctx, isc_mem_t *mctx) {
        const cfg_obj_t *options = NULL;
        const cfg_obj_t *views = NULL;
        const cfg_obj_t *acls = NULL;
@@ -5932,32 +5924,29 @@ bind9_check_namedconf(const cfg_obj_t *config, bool check_plugins,
                result = ISC_R_FAILURE;
        }
 
-       if (bind9_check_logging(config, logctx, mctx) != ISC_R_SUCCESS) {
+       if (check_logging(config, logctx, mctx) != ISC_R_SUCCESS) {
                result = ISC_R_FAILURE;
        }
 
-       if (bind9_check_controls(config, logctx, mctx) != ISC_R_SUCCESS) {
+       if (check_controls(config, logctx, mctx) != ISC_R_SUCCESS) {
                result = ISC_R_FAILURE;
        }
 
-       if (bind9_check_primarylists(config, logctx, mctx) != ISC_R_SUCCESS) {
+       if (check_primarylists(config, logctx, mctx) != ISC_R_SUCCESS) {
                result = ISC_R_FAILURE;
        }
 
-       if (bind9_check_parentalagentlists(config, logctx, mctx) !=
-           ISC_R_SUCCESS)
-       {
+       if (check_parentalagentlists(config, logctx, mctx) != ISC_R_SUCCESS) {
                result = ISC_R_FAILURE;
        }
 
 #if HAVE_LIBNGHTTP2
-       if (bind9_check_httpservers(config, logctx, mctx) != ISC_R_SUCCESS) {
+       if (check_httpservers(config, logctx, mctx) != ISC_R_SUCCESS) {
                result = ISC_R_FAILURE;
        }
 #endif /* HAVE_LIBNGHTTP2 */
 
-       if (bind9_check_tls_definitions(config, logctx, mctx) != ISC_R_SUCCESS)
-       {
+       if (check_tls_definitions(config, logctx, mctx) != ISC_R_SUCCESS) {
                result = ISC_R_FAILURE;
        }
 
similarity index 81%
rename from lib/bind9/include/bind9/check.h
rename to lib/isccfg/include/isccfg/check.h
index 26d60fcadfb6b14fd75e463e5d83a0e24ecd92ed..b96e9f50e50d947a4247e59fdd75ad1b7b2f0c4b 100644 (file)
@@ -13,7 +13,7 @@
 
 #pragma once
 
-/*! \file bind9/check.h */
+/*! \file isccfg/check.h */
 
 #include <isc/lang.h>
 #include <isc/types.h>
@@ -35,8 +35,8 @@
 ISC_LANG_BEGINDECLS
 
 isc_result_t
-bind9_check_namedconf(const cfg_obj_t *config, bool check_plugins,
-                     isc_log_t *logctx, isc_mem_t *mctx);
+isccfg_check_namedconf(const cfg_obj_t *config, bool check_plugins,
+                      isc_log_t *logctx, isc_mem_t *mctx);
 /*%<
  * Check the syntactic validity of a configuration parse tree generated from
  * a named.conf file.
@@ -55,9 +55,9 @@ bind9_check_namedconf(const cfg_obj_t *config, bool check_plugins,
  */
 
 isc_result_t
-bind9_check_key(const cfg_obj_t *config, isc_log_t *logctx);
+isccfg_check_key(const cfg_obj_t *config, isc_log_t *logctx);
 /*%<
- * Same as bind9_check_namedconf(), but for a single 'key' statement.
+ * Same as isccfg_check_namedconf(), but for a single 'key' statement.
  */
 
 ISC_LANG_ENDDECLS
index d060d7cdc76db8759b152b30db68ff4c8142ae67..80df843cc1df132b2a6b0e95baec6a9380572fb7 100644 (file)
@@ -2524,7 +2524,7 @@ static cfg_type_t cfg_type_key = { "key",   cfg_parse_named_map,
 /*%
  * Clauses that can be found in a 'server' statement.
  *
- * Please update lib/bind9/check.c and
+ * Please update lib/isccfg/check.c and
  * bin/tests/system/checkconf/good-server-christmas-tree.conf.in to
  * exercise the new clause when adding new clauses.
  */