Commit 0b879096 authored by Matthijs Mekking's avatar Matthijs Mekking
Browse files

named-checkconf -i: ignore deprecate warnings

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.
parent 2890c98d
Pipeline #16582 passed with stages
in 13 minutes and 35 seconds
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
......
......@@ -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) {
......
......@@ -126,6 +126,15 @@
</listitem>
</varlistentry>
<varlistentry>
<term>-i</term>
<listitem>
<para>
Ignore warnings on deprecated options.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-p</term>
<listitem>
......
/*
* 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=";
};
......@@ -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
......
......@@ -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,
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment