From 86f1ec34dc8dd8f547074e1725978abd776ba884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 14 Aug 2024 10:20:47 +0200 Subject: [PATCH] Silence all warnings that stem from the default config As we now setup the logging very early, parsing the default config would always print warnings about experimental (and possibly deprecated) options in the default config. This would even mess with commands like `named -V` and it is also wrong to warn users about using experimental options in the default config, because they can't do anything about this. Add CFG_PCTX_NODEPRECATED and CFG_PCTX_NOEXPERIMENTAL options that we can pass to cfg parser and silence the early warnings caused by using experimental options in the default config. --- bin/named/config.c | 4 +++- lib/isccfg/include/isccfg/grammar.h | 6 ++++-- lib/isccfg/parser.c | 11 ++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/named/config.c b/bin/named/config.c index d0f70bddbc..4900e813cf 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -356,7 +356,9 @@ named_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, __FILE__, 0, &cfg_type_namedconf, - CFG_PCTX_NODEPRECATED, conf)); + CFG_PCTX_NODEPRECATED | CFG_PCTX_NOOBSOLETE | + CFG_PCTX_NOEXPERIMENTAL, + conf)); } const char * diff --git a/lib/isccfg/include/isccfg/grammar.h b/lib/isccfg/include/isccfg/grammar.h index 7cbcf7f470..17c6af3a60 100644 --- a/lib/isccfg/include/isccfg/grammar.h +++ b/lib/isccfg/include/isccfg/grammar.h @@ -258,8 +258,10 @@ struct cfg_parser { }; /* Parser context flags */ -#define CFG_PCTX_SKIP 0x1 -#define CFG_PCTX_NODEPRECATED 0x2 +#define CFG_PCTX_SKIP (1 << 0) +#define CFG_PCTX_NODEPRECATED (1 << 1) +#define CFG_PCTX_NOOBSOLETE (1 << 2) +#define CFG_PCTX_NOEXPERIMENTAL (1 << 3) /*@{*/ /*% diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 0dac6e381c..708e6937c7 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -689,7 +689,8 @@ cfg_parse_buffer(cfg_parser_t *pctx, isc_buffer_t *buffer, const char *file, REQUIRE(type != NULL); REQUIRE(buffer != NULL); REQUIRE(ret != NULL && *ret == NULL); - REQUIRE((flags & ~(CFG_PCTX_NODEPRECATED)) == 0); + REQUIRE((flags & ~(CFG_PCTX_NODEPRECATED | CFG_PCTX_NOOBSOLETE | + CFG_PCTX_NOEXPERIMENTAL)) == 0); CHECK(isc_lex_openbuffer(pctx->lexer, buffer)); @@ -2357,13 +2358,17 @@ cfg_parse_mapbody(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) { cfg_parser_warning(pctx, 0, "option '%s' is deprecated", clause->name); } - if ((clause->flags & CFG_CLAUSEFLAG_OBSOLETE) != 0) { + if ((pctx->flags & CFG_PCTX_NOOBSOLETE) == 0 && + (clause->flags & CFG_CLAUSEFLAG_OBSOLETE) != 0) + { cfg_parser_warning(pctx, 0, "option '%s' is obsolete and " "should be removed ", clause->name); } - if ((clause->flags & CFG_CLAUSEFLAG_EXPERIMENTAL) != 0) { + if ((pctx->flags & CFG_PCTX_NOEXPERIMENTAL) == 0 && + (clause->flags & CFG_CLAUSEFLAG_EXPERIMENTAL) != 0) + { cfg_parser_warning(pctx, 0, "option '%s' is experimental and " "subject to change in the future",