Merge branch 'fanf-libbind9-libisccfg' into 'main'

Move bind9/check to isccfg/check

See merge request isc-projects/bind9!7461
This commit is contained in:
Tony Finch 2023-02-17 12:50:39 +00:00
commit 000f885614
9 changed files with 67 additions and 68 deletions

View file

@ -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]

View file

@ -36,11 +36,10 @@
#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;
}

View file

@ -39,10 +39,9 @@
#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);

View file

@ -108,6 +108,7 @@
#include <dst/dst.h>
#include <isccfg/check.h>
#include <isccfg/grammar.h>
#include <isccfg/kaspconf.h>
#include <isccfg/namedconf.h>
@ -117,8 +118,6 @@
#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;
}

View 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 = \

View 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

View file

@ -62,14 +62,13 @@
#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;
}

View 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

View 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.
*/