diff --git a/CHANGES b/CHANGES index 34a487bb88..274c2bacbe 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +5259. [func] New option '-i' for 'named-checkconf' to ignore + warnings about deprecated options. [GL #1101] + 5258. [func] Added support for the GeoIP2 API from MaxMind. This will be compiled in by default if the "libmaxminddb" library is found at compile time, but can be diff --git a/bin/check/named-checkconf.c b/bin/check/named-checkconf.c index ea6196363e..2da105e52b 100644 --- a/bin/check/named-checkconf.c +++ b/bin/check/named-checkconf.c @@ -28,6 +28,7 @@ #include #include +#include #include @@ -61,7 +62,7 @@ usage(void) ISC_PLATFORM_NORETURN_POST; static void usage(void) { - fprintf(stderr, "usage: %s [-chjlvz] [-p [-x]] [-t directory] " + fprintf(stderr, "usage: %s [-chijlvz] [-p [-x]] [-t directory] " "[named.conf]\n", program); exit(1); } @@ -555,6 +556,7 @@ main(int argc, char **argv) { bool load_zones = false; bool list_zones = false; bool print = false; + bool nodeprecate = false; unsigned int flags = 0; isc_commandline_errprint = false; @@ -562,7 +564,7 @@ main(int argc, char **argv) { /* * Process memory debugging argument first. */ -#define CMDLINE_FLAGS "cdhjlm:t:pvxz" +#define CMDLINE_FLAGS "cdhijlm:t:pvxz" while ((c = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) { switch (c) { case 'm': @@ -595,6 +597,10 @@ main(int argc, char **argv) { debug++; break; + case 'i': + nodeprecate = true; + break; + case 'j': nomerge = false; break; @@ -675,11 +681,16 @@ main(int argc, char **argv) { RUNTIME_CHECK(cfg_parser_create(mctx, logc, &parser) == ISC_R_SUCCESS); + if (nodeprecate) { + cfg_parser_setflags(parser, CFG_PCTX_NODEPRECATED, true); + } cfg_parser_setcallback(parser, directory_callback, NULL); if (cfg_parse_file(parser, conffile, &cfg_type_namedconf, &config) != ISC_R_SUCCESS) + { exit(1); + } result = bind9_check_namedconf(config, loadplugins, logc, mctx); if (result != ISC_R_SUCCESS) { diff --git a/bin/check/named-checkconf.docbook b/bin/check/named-checkconf.docbook index c494c9fa31..0e3f73750c 100644 --- a/bin/check/named-checkconf.docbook +++ b/bin/check/named-checkconf.docbook @@ -126,6 +126,15 @@ + + -i + + + Ignore warnings on deprecated options. + + + + -p diff --git a/bin/tests/system/checkconf/deprecated.conf b/bin/tests/system/checkconf/deprecated.conf new file mode 100644 index 0000000000..d4f30a0b0c --- /dev/null +++ b/bin/tests/system/checkconf/deprecated.conf @@ -0,0 +1,36 @@ +/* + * 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 http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +options { + dnssec-validation yes; +}; + +trusted-keys { + fake.trusted. 257 3 8 + "AwEAAagAIKlVZrpC6Ia7gEzahOR+9W29euxhJhVVLOyQbSEW0O8gcCjF + FVQUTf6v58fLjwBd0YI0EzrAcQqBGCzh/RStIoO8g0NfnfL2MTJRkxoX + bfDaUeVPQuYEhg37NZWAJQ9VnMVDxP/VHL496M/QZxkjf5/Efucp2gaD + X6RS6CXpoY68LsvPVjR0ZSwzz1apAzvN9dlzEheX7ICJBBtuA6G3LQpz + W5hOA2hzCTMjJPJ8LbqF6dsV6DoBQzgul0sGIcGOYl7OyQdXfZ57relS + Qageu+ipAdTTJ25AsRTAoub8ONGcLmqrAmRLKBP1dfwhYB4N7knNnulq + QxA+Uk1ihz0="; +}; + +managed-keys { + fake.managed. initial-key 257 3 8 + "AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3 + +/4RgWOq7HrxRixHlFlExOLAJr5emLvN7SWXgnLh4+B5xQlNVz8Og8kv + ArMtNROxVQuCaSnIDdD5LKyWbRd2n9WGe2R8PzgCmr3EgVLrjyBxWezF + 0jLHwVN8efS3rCj/EWgvIWgb9tarpVUDK/b58Da+sqqls3eNbuv7pr+e + oZG+SrDK6nWeL3c6H5Apxz7LjVc1uTIdsIXxuOLYA4/ilBmSVIzuDWfd + RUfhHdY6+cn8HFRm+2hM8AnXGXws9555KrUB5qihylGa8subX2Nn6UwN + R1AkUTV74bU="; +}; diff --git a/bin/tests/system/checkconf/tests.sh b/bin/tests/system/checkconf/tests.sh index 1cfbe7665b..bd6576e9ad 100644 --- a/bin/tests/system/checkconf/tests.sh +++ b/bin/tests/system/checkconf/tests.sh @@ -126,6 +126,20 @@ grep '.*' < checkconf.out$n.3 > /dev/null && ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi status=`expr $status + $ret` +n=`expr $n + 1` +echo_i "checking named-checkconf deprecate warnings ($n)" +ret=0 +$CHECKCONF deprecated.conf > checkconf.out$n.1 2>&1 +grep "option 'managed-keys' is deprecated" < checkconf.out$n.1 > /dev/null || ret=1 +grep "option 'trusted-keys' is deprecated" < checkconf.out$n.1 > /dev/null || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` +# set -i to ignore deprecate warnings +$CHECKCONF -i deprecated.conf > checkconf.out$n.2 2>&1 +grep '.*' < checkconf.out$n.2 > /dev/null && ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + n=`expr $n + 1` echo_i "range checking fields that do not allow zero ($n)" ret=0 diff --git a/lib/isccfg/include/isccfg/cfg.h b/lib/isccfg/include/isccfg/cfg.h index 56dffb167f..c8b3a08ad0 100644 --- a/lib/isccfg/include/isccfg/cfg.h +++ b/lib/isccfg/include/isccfg/cfg.h @@ -95,6 +95,17 @@ cfg_parser_create(isc_mem_t *mctx, isc_log_t *lctx, cfg_parser_t **ret); * be reused for parsing multiple files or buffers. */ +void +cfg_parser_setflags(cfg_parser_t *pctx, unsigned int flags, bool turn_on); +/*%< + * Set parser context flags. The flags are not checked for sensibility. + * If 'turn_on' is 'true' the flags will be set, otherwise the flags will + * be cleared. + * + * Requires: + *\li "pctx" is not NULL. + */ + void cfg_parser_setcallback(cfg_parser_t *pctx, cfg_parsecallback_t callback, diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 215d954eac..7d7cff4cd5 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -507,6 +507,18 @@ cfg_parser_create(isc_mem_t *mctx, isc_log_t *lctx, cfg_parser_t **ret) { return (result); } +void +cfg_parser_setflags(cfg_parser_t *pctx, unsigned int flags, bool turn_on) +{ + REQUIRE(pctx != NULL); + + if (turn_on) { + pctx->flags |= flags; + } else { + pctx->flags &= ~flags; + } +} + static isc_result_t parser_openfile(cfg_parser_t *pctx, const char *filename) { isc_result_t result; diff --git a/lib/isccfg/win32/libisccfg.def b/lib/isccfg/win32/libisccfg.def index 9d1af2cedf..96039fbf04 100644 --- a/lib/isccfg/win32/libisccfg.def +++ b/lib/isccfg/win32/libisccfg.def @@ -97,6 +97,7 @@ cfg_parser_error cfg_parser_mapadd cfg_parser_reset cfg_parser_setcallback +cfg_parser_setflags cfg_parser_warning cfg_peektoken cfg_pluginlist_foreach