]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add support for marking a option as deprecated.
authorMark Andrews <marka@isc.org>
Fri, 8 Jun 2018 01:04:21 +0000 (11:04 +1000)
committerMark Andrews <marka@isc.org>
Fri, 8 Jun 2018 06:06:17 +0000 (16:06 +1000)
(cherry picked from commit befff9452ce89d0039d4534a572f92d9efd47522)

CHANGES
bin/named/config.c
lib/isccfg/include/isccfg/cfg.h
lib/isccfg/include/isccfg/grammar.h
lib/isccfg/parser.c

diff --git a/CHANGES b/CHANGES
index 104a13134c31980131fa5613c2a52345e04b5259..69e96d7a77836d6914d930025370993050e16c96 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4965.  [func]          Add support for marking options as deprecated.
+                       [GL #322]
+
 4964.  [bug]           Reduce the probabilty of double signature when deleting
                        a DNSKEY by checking if the node is otherwise signed
                        by the algorithm of the key to be deleted. [GL #240]
index 22fc82cc3a93bc58d8bc5559352f0707a018c624..5aeb6a9d42e508dbe39a4ca4e497903fe95fddc3 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <pk11/site.h>
 
+#include <isccfg/grammar.h>
 #include <isccfg/namedconf.h>
 
 #include <dns/fixedname.h>
@@ -289,7 +290,9 @@ ns_config_parsedefaults(cfg_parser_t *parser, cfg_obj_t **conf) {
 
        isc_buffer_init(&b, defaultconf, sizeof(defaultconf) - 1);
        isc_buffer_add(&b, sizeof(defaultconf) - 1);
-       return (cfg_parse_buffer(parser, &b, &cfg_type_namedconf, conf));
+       return (cfg_parse_buffer4(parser, &b, __FILE__, 0,
+                                 &cfg_type_namedconf,
+                                 CFG_PCTX_NODEPRECATED, conf));
 }
 
 isc_result_t
index a13d5f433ad633e5e6ff17679671cf6c82f944ee..3b2f39c0cd628cbf87e6a5702e54282d30f07ad7 100644 (file)
@@ -14,8 +14,6 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: cfg.h,v 1.46 2010/08/13 23:47:04 tbox Exp $ */
-
 #ifndef ISCCFG_CFG_H
 #define ISCCFG_CFG_H 1
 
@@ -120,6 +118,11 @@ cfg_parse_file(cfg_parser_t *pctx, const char *filename,
 isc_result_t
 cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer,
                 const cfg_type_t *type, cfg_obj_t **ret);
+isc_result_t
+cfg_parse_buffer4(cfg_parser_t *pctx, isc_buffer_t *buffer,
+                 const char *file, unsigned int line,
+                 const cfg_type_t *type, unsigned int flags,
+                 cfg_obj_t **ret);
 /*%<
  * Read a configuration containing data of type 'type'
  * and make '*ret' point to its parse tree.
@@ -135,6 +138,7 @@ cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer,
  *\li  "mem" is valid.
  *\li  "type" is valid.
  *\li  "cfg" is non-NULL and "*cfg" is NULL.
+ *\li   "flags" be one or more of CFG_PCTX_NODEPRECATED or zero.
  *
  * Returns:
  *     \li #ISC_R_SUCCESS                 - success
index 333ae47cad04d79a15f512786c72452d316bba6a..524e50fb23504a217b308efa4d9d0823d719d151 100644 (file)
@@ -14,8 +14,6 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: grammar.h,v 1.24 2011/01/04 23:47:14 tbox Exp $ */
-
 #ifndef ISCCFG_GRAMMAR_H
 #define ISCCFG_GRAMMAR_H 1
 
@@ -56,6 +54,8 @@
 #define CFG_CLAUSEFLAG_NOTCONFIGURED   0x00000080
 /*% A option for a experimental feature. */
 #define CFG_CLAUSEFLAG_EXPERIMENTAL    0x00000100
+/*% Clause is obsolete in a future release */
+#define CFG_CLAUSEFLAG_DEPRECATED      0x00000400
 
 typedef struct cfg_clausedef cfg_clausedef_t;
 typedef struct cfg_tuplefielddef cfg_tuplefielddef_t;
@@ -234,6 +234,7 @@ struct cfg_parser {
 
 /* Parser context flags */
 #define CFG_PCTX_SKIP          0x1
+#define CFG_PCTX_NODEPRECATED  0x2
 
 /*@{*/
 /*%
index 45f8fc0f0f0df489f94be5312fd729ba2b2bc58d..249344bac046b78539ec7c90d7939eebbaa8b64f 100644 (file)
@@ -581,14 +581,30 @@ cfg_parse_file(cfg_parser_t *pctx, const char *filename,
 isc_result_t
 cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer,
        const cfg_type_t *type, cfg_obj_t **ret)
+{
+       return (cfg_parse_buffer4(pctx, buffer, NULL, 0, type, 0, ret));
+}
+
+isc_result_t
+cfg_parse_buffer4(cfg_parser_t *pctx, isc_buffer_t *buffer,
+                  const char *file, unsigned int line,
+                  const cfg_type_t *type, unsigned int flags,
+                 cfg_obj_t **ret)
 {
        isc_result_t result;
        REQUIRE(pctx != NULL);
        REQUIRE(type != NULL);
        REQUIRE(buffer != NULL);
        REQUIRE(ret != NULL && *ret == NULL);
+       REQUIRE((flags & ~(CFG_PCTX_NODEPRECATED)) == 0);
+
+       UNUSED(file);
+       UNUSED(line);
 
        CHECK(isc_lex_openbuffer(pctx->lexer, buffer));
+
+       pctx->flags = flags;
+
        CHECK(parse2(pctx, type, ret));
  cleanup:
        return (result);
@@ -1501,12 +1517,14 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
                }
        done:
                if (clause == NULL || clause->name == NULL) {
-                       cfg_parser_error(pctx, CFG_LOG_NOPREP, "unknown option");
+                       cfg_parser_error(pctx, CFG_LOG_NOPREP,
+                                        "unknown option");
                        /*
                         * Try to recover by parsing this option as an unknown
                         * option and discarding it.
                         */
-                       CHECK(cfg_parse_obj(pctx, &cfg_type_unsupported, &eltobj));
+                       CHECK(cfg_parse_obj(pctx, &cfg_type_unsupported,
+                                           &eltobj));
                        cfg_obj_destroy(pctx, &eltobj);
                        CHECK(parse_semicolon(pctx));
                        continue;
@@ -1515,15 +1533,24 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret)
                /* Clause is known. */
 
                /* Issue warnings if appropriate */
-               if ((clause->flags & CFG_CLAUSEFLAG_OBSOLETE) != 0)
+               if ((pctx->flags & CFG_PCTX_NODEPRECATED) == 0 &&
+                   (clause->flags & CFG_CLAUSEFLAG_DEPRECATED) != 0)
+               {
+                       cfg_parser_warning(pctx, 0, "option '%s' is deprecated",
+                                          clause->name);
+               }
+               if ((clause->flags & CFG_CLAUSEFLAG_OBSOLETE) != 0) {
                        cfg_parser_warning(pctx, 0, "option '%s' is obsolete",
-                                      clause->name);
-               if ((clause->flags & CFG_CLAUSEFLAG_NOTIMP) != 0)
+                                          clause->name);
+               }
+               if ((clause->flags & CFG_CLAUSEFLAG_NOTIMP) != 0) {
                        cfg_parser_warning(pctx, 0, "option '%s' is "
-                                      "not implemented", clause->name);
-               if ((clause->flags & CFG_CLAUSEFLAG_NYI) != 0)
+                                          "not implemented", clause->name);
+               }
+               if ((clause->flags & CFG_CLAUSEFLAG_NYI) != 0) {
                        cfg_parser_warning(pctx, 0, "option '%s' is "
-                                      "not implemented", clause->name);
+                                          "not implemented", clause->name);
+               }
 
                if ((clause->flags & CFG_CLAUSEFLAG_NOTCONFIGURED) != 0) {
                        cfg_parser_warning(pctx, 0, "option '%s' was not "