]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
named-checkconf -i: ignore deprecate warnings
authorMatthijs Mekking <github@pletterpet.nl>
Tue, 25 Jun 2019 07:41:51 +0000 (09:41 +0200)
committerMatthijs Mekking <github@pletterpet.nl>
Fri, 28 Jun 2019 09:02:59 +0000 (11:02 +0200)
Adds a new option to named-checkconf, -i.  If set, named-checkconf
will not warn you about deprecated options.  This allows people
to use named-checkconf in automated deployment precoesses where an
operator only cares if their conf is valid, even if it is not optimal.

This was added as a request as part of introducing a policy on
removing named.conf options.

CHANGES
bin/check/named-checkconf.c
bin/check/named-checkconf.docbook
bin/tests/system/checkconf/deprecated.conf [new file with mode: 0644]
bin/tests/system/checkconf/tests.sh
lib/isccfg/include/isccfg/cfg.h
lib/isccfg/parser.c
lib/isccfg/win32/libisccfg.def

diff --git a/CHANGES b/CHANGES
index 34a487bb88115b1674f9f2543e250ba9276fded4..274c2bacbe482de4a9b5d9bf02187d776769ce4c 100644 (file)
--- 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
index ea6196363e9517bf05cfdae5660a51f18a9334f9..2da105e52bf5c206f05ad36d633d4de6fbcf3690 100644 (file)
@@ -28,6 +28,7 @@
 #include <isc/util.h>
 
 #include <isccfg/namedconf.h>
+#include <isccfg/grammar.h>
 
 #include <bind9/check.h>
 
@@ -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) {
index c494c9fa31b61797977aa0e797f10541a9f858b1..0e3f73750cd50924fa721adb9bc6a3ce7bbd5050 100644 (file)
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term>-i</term>
+        <listitem>
+          <para>
+           Ignore warnings on deprecated options.
+          </para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term>-p</term>
         <listitem>
diff --git a/bin/tests/system/checkconf/deprecated.conf b/bin/tests/system/checkconf/deprecated.conf
new file mode 100644 (file)
index 0000000..d4f30a0
--- /dev/null
@@ -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=";
+};
index 1cfbe7665bc01487ddb4db69651d39383c5b00b1..bd6576e9ad0f907a724b5ffd4956f6b4679a5aca 100644 (file)
@@ -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
index 56dffb167fdc2478f43438c2d158183ea92a2e62..c8b3a08ad0eb463c289e2510fff462e21f0f6751 100644 (file)
@@ -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,
index 215d954eac149f427773ccf3b76770859d4832e2..7d7cff4cd5707a6fbc6d2975c94cb526ebc656eb 100644 (file)
@@ -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;
index 9d1af2cedf3ded7a9706adfd1e383954df732ee0..96039fbf04587febba884fa756180de31d04de7f 100644 (file)
@@ -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