]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add flag to named-checkconf to ignore "not configured" errors
authorMark Andrews <marka@isc.org>
Mon, 2 Sep 2024 06:03:17 +0000 (16:03 +1000)
committerMark Andrews <marka@isc.org>
Mon, 9 Sep 2024 23:32:16 +0000 (23:32 +0000)
named-checkconf now takes "-n" to ignore "not configured" errors.
This allows named-checkconf to check the syntax of configurations
from other builds which have support for more options.

bin/check/named-checkconf.c
bin/check/named-checkconf.rst
lib/isccfg/include/isccfg/grammar.h
lib/isccfg/parser.c

index 37a827cba62e0a6f49ea2677f6a928a9ec97e82b..5a987a46a036ebb960ab823c7f6633a4b6578ff9 100644 (file)
@@ -594,6 +594,7 @@ main(int argc, char **argv) {
        bool list_zones = false;
        bool print = false;
        bool nodeprecate = false;
+       bool allconfigs = false;
        unsigned int flags = 0;
        unsigned int checkflags = BIND_CHECK_PLUGINS | BIND_CHECK_ALGORITHMS;
 
@@ -602,7 +603,7 @@ main(int argc, char **argv) {
        /*
         * Process memory debugging argument first.
         */
-#define CMDLINE_FLAGS "acdhijlm:t:pvxz"
+#define CMDLINE_FLAGS "acdhijlm:nt:pvxz"
        while ((c = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
                switch (c) {
                case 'm':
@@ -656,6 +657,10 @@ main(int argc, char **argv) {
                case 'm':
                        break;
 
+               case 'n':
+                       allconfigs = true;
+                       break;
+
                case 't':
                        result = isc_dir_chroot(isc_commandline_argument);
                        if (result != ISC_R_SUCCESS) {
@@ -729,6 +734,9 @@ main(int argc, char **argv) {
        if (nodeprecate) {
                cfg_parser_setflags(parser, CFG_PCTX_NODEPRECATED, true);
        }
+       if (allconfigs) {
+               cfg_parser_setflags(parser, CFG_PCTX_ALLCONFIGS, true);
+       }
        cfg_parser_setcallback(parser, directory_callback, NULL);
 
        CHECK(cfg_parse_file(parser, conffile, &cfg_type_namedconf, &config));
index 41dad390fadd03a3b74c1a19d93319ca419227b7..c474169ea663e969114430e6710a2fd3fafbde96 100644 (file)
@@ -21,7 +21,7 @@ named-checkconf - named configuration file syntax checking tool
 Synopsis
 ~~~~~~~~
 
-:program:`named-checkconf` [**-achjlvz**] [**-p** [**-x** ]] [**-t** directory] {filename}
+:program:`named-checkconf` [**-achjlnvz**] [**-p** [**-x** ]] [**-t** directory] {filename}
 
 Description
 ~~~~~~~~~~~
@@ -71,6 +71,10 @@ Options
 
    This option ignores warnings on deprecated options.
 
+.. option:: -n
+
+   Do not error on options that are disabled in this build.
+
 .. option:: -p
 
    This option prints out the :iscman:`named.conf` and included files in canonical form if
index 8734977966fced6ec5d6b66673328618c7a473cc..e80912afd428fa4c03be69fa01c2d52b61eb7a9b 100644 (file)
@@ -261,6 +261,7 @@ struct cfg_parser {
 #define CFG_PCTX_NODEPRECATED  (1 << 1)
 #define CFG_PCTX_NOOBSOLETE    (1 << 2)
 #define CFG_PCTX_NOEXPERIMENTAL (1 << 3)
+#define CFG_PCTX_ALLCONFIGS    (1 << 4)
 
 /*@{*/
 /*%
index e882eb9b8f03167df3f69868e65cc387b2bc5977..08502510d72d025872b0793b66a8f39c32cd31e7 100644 (file)
@@ -2341,7 +2341,9 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
                                         clause->name);
                        CHECK(ISC_R_FAILURE);
                }
-               if ((clause->flags & CFG_CLAUSEFLAG_NOTCONFIGURED) != 0) {
+               if ((pctx->flags & CFG_PCTX_ALLCONFIGS) == 0 &&
+                   (clause->flags & CFG_CLAUSEFLAG_NOTCONFIGURED) != 0)
+               {
                        cfg_parser_error(pctx, 0,
                                         "option '%s' was not "
                                         "enabled at compile time",