diff --git a/bin/tests/system/checkconf/clean.sh b/bin/tests/system/checkconf/clean.sh index aed6231e46..b8ed80b08e 100644 --- a/bin/tests/system/checkconf/clean.sh +++ b/bin/tests/system/checkconf/clean.sh @@ -15,3 +15,4 @@ rm -rf test.keydir rm -f checkconf.out* rm -f diff.out* rm -f ns*/named.lock +rm -f good-server-christmas-tree.conf diff --git a/bin/tests/system/checkconf/good-server-christmas-tree.conf.in b/bin/tests/system/checkconf/good-server-christmas-tree.conf.in new file mode 100644 index 0000000000..1b0c0d3071 --- /dev/null +++ b/bin/tests/system/checkconf/good-server-christmas-tree.conf.in @@ -0,0 +1,50 @@ +key example { + algorithm hmac-sha256; + secret "aaaaaaaaaaaaaaaaaaaaaaaa"; +}; + +server 0.0.0.0 { + bogus no; + edns no; + edns-udp-size 512; + edns-version 0; + keys example; + max-udp-size 512; + notify-source 0.0.0.0; + padding 512; + provide-ixfr no; + query-source 0.0.0.0; + request-expire no; + request-ixfr no; + request-nsid no; + send-cookie no; + tcp-keepalive no; + tcp-on-no-cookie no; + tcp-only no; + transfer-format one-answer; + transfer-source 0.0.0.0; + transfers 1; +}; + +server :: { + bogus no; + edns no; + edns-udp-size 512; + edns-version 0; + keys example; + max-udp-size 512; + notify-source-v6 ::; + padding 512; + provide-ixfr no; + query-source-v6 ::; + request-expire no; + request-ixfr no; + request-nsid no; + send-cookie no; + tcp-keepalive no; + tcp-on-no-cookie no; + tcp-only no; + transfer-format one-answer; + transfer-source-v6 ::; + transfers 1; +}; diff --git a/bin/tests/system/checkconf/setup.sh b/bin/tests/system/checkconf/setup.sh new file mode 100644 index 0000000000..a424eef33c --- /dev/null +++ b/bin/tests/system/checkconf/setup.sh @@ -0,0 +1,10 @@ +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +cp -f good-server-christmas-tree.conf.in good-server-christmas-tree.conf diff --git a/lib/bind9/check.c b/lib/bind9/check.c index c27de55476..1902cfbefb 100644 --- a/lib/bind9/check.c +++ b/lib/bind9/check.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -3640,6 +3641,21 @@ static struct { { "parental-source", "parental-source-v6" }, { "query-source", "query-source-v6" }, { NULL, NULL } }; +static struct { + const char *name; + isc_result_t (*set)(dns_peer_t *peer, bool newval); +} bools[] = { + { "bogus", dns_peer_setbogus }, + { "edns", dns_peer_setsupportedns }, + { "provide-ixfr", dns_peer_setprovideixfr }, + { "request-expire", dns_peer_setrequestexpire }, + { "request-ixfr", dns_peer_setrequestixfr }, + { "request-nsid", dns_peer_setrequestnsid }, + { "send-cookie", dns_peer_setsendcookie }, + { "tcp-keepalive", dns_peer_settcpkeepalive }, + { "tcp-on-no-cookie", dns_peer_settcponnocookie }, + { "tcp-only", dns_peer_setforcetcp }, +}; /* * RNDC keys are not normalised unlike TSIG keys. @@ -3670,7 +3686,7 @@ rndckey_exists(const cfg_obj_t *keylist, const char *keyname) { static isc_result_t check_servers(const cfg_obj_t *config, const cfg_obj_t *voptions, - isc_symtab_t *symtab, isc_log_t *logctx) { + isc_symtab_t *symtab, isc_mem_t *mctx, isc_log_t *logctx) { dns_fixedname_t fname; isc_result_t result = ISC_R_SUCCESS; isc_result_t tresult; @@ -3700,6 +3716,8 @@ check_servers(const cfg_obj_t *config, const cfg_obj_t *voptions, } for (e1 = cfg_list_first(servers); e1 != NULL; e1 = cfg_list_next(e1)) { + dns_peer_t *peer = NULL; + size_t i; v1 = cfg_listelt_value(e1); cfg_obj_asnetprefix(cfg_map_getname(v1), &n1, &p1); /* @@ -3778,6 +3796,24 @@ check_servers(const cfg_obj_t *config, const cfg_obj_t *voptions, result = ISC_R_FAILURE; } } + (void)dns_peer_newprefix(mctx, &n1, p1, &peer); + for (i = 0; i < ARRAY_SIZE(bools); i++) { + const cfg_obj_t *opt = NULL; + cfg_map_get(v1, bools[i].name, &opt); + if (opt != NULL) { + tresult = (bools[i].set)( + peer, cfg_obj_asboolean(opt)); + if (tresult != ISC_R_SUCCESS) { + cfg_obj_log(opt, logctx, ISC_LOG_ERROR, + "setting server option " + "'%s' failed: %s", + bools[i].name, + isc_result_totext(tresult)); + result = ISC_R_FAILURE; + } + } + } + dns_peer_detach(&peer); } return (result); } @@ -4680,7 +4716,8 @@ check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions, /* * Global servers can refer to keys in views. */ - if (check_servers(config, voptions, symtab, logctx) != ISC_R_SUCCESS) { + if (check_servers(config, voptions, symtab, mctx, logctx) != + ISC_R_SUCCESS) { result = ISC_R_FAILURE; } diff --git a/util/copyrights b/util/copyrights index 68aede72b4..da0de9f63f 100644 --- a/util/copyrights +++ b/util/copyrights @@ -187,6 +187,7 @@ ./bin/tests/system/checkconf/dnssec.1 X 2011,2016,2018,2019,2020,2021 ./bin/tests/system/checkconf/dnssec.2 X 2011,2016,2018,2019,2020,2021 ./bin/tests/system/checkconf/good.zonelist X 2016,2017,2018,2019,2020,2021 +./bin/tests/system/checkconf/setup.sh SH 2021 ./bin/tests/system/checkconf/tests.sh SH 2005,2007,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021 ./bin/tests/system/checkds/README TXT.BRIEF 2021 ./bin/tests/system/checkds/clean.sh SH 2021