diff --git a/bin/named/config.c b/bin/named/config.c index 558f7d72cf..23df890193 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -580,6 +580,9 @@ named_config_getname(isc_mem_t *mctx, const cfg_obj_t *obj, oldlen = newlen; \ } +static const char *remotesnames[4] = { "remote-servers", "parental-agents", + "primaries", "masters" }; + isc_result_t named_config_getipandkeylist(const cfg_obj_t *config, const cfg_obj_t *list, isc_mem_t *mctx, dns_ipkeylist_t *ipkl) { @@ -695,17 +698,22 @@ resume: continue; } list = NULL; - tresult = named_config_getremotesdef( - config, "remote-servers", listname, &list); + tresult = ISC_R_NOTFOUND; + for (size_t n = 0; n < ARRAY_SIZE(remotesnames); n++) { + tresult = named_config_getremotesdef( + config, remotesnames[n], listname, + &list); + if (tresult == ISC_R_SUCCESS) { + break; + } + } if (tresult == ISC_R_NOTFOUND) { cfg_obj_log(addr, ISC_LOG_ERROR, "remote-servers \"%s\" not found", listname); - - result = tresult; - goto cleanup; } if (tresult != ISC_R_SUCCESS) { + result = tresult; goto cleanup; } lists[l++].name = listname; diff --git a/bin/tests/system/checkconf/bad-duplicate-remote-servers-synonyms.conf b/bin/tests/system/checkconf/bad-duplicate-remote-servers-synonyms.conf new file mode 100644 index 0000000000..f2de15ba98 --- /dev/null +++ b/bin/tests/system/checkconf/bad-duplicate-remote-servers-synonyms.conf @@ -0,0 +1,15 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * 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 https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +remote-servers duplicate { 1.2.3.4; }; +primaries duplicate { 4.3.2.1; }; diff --git a/bin/tests/system/checkconf/good-multiple-remote-servers-synonyms.conf b/bin/tests/system/checkconf/good-multiple-remote-servers-synonyms.conf new file mode 100644 index 0000000000..891538c131 --- /dev/null +++ b/bin/tests/system/checkconf/good-multiple-remote-servers-synonyms.conf @@ -0,0 +1,28 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * 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 https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +remote-servers "one" { + 1.2.3.4; +}; + +parental-agents "two" { + 1.2.3.5; +}; + +primaries "three" { + 1.2.3.6; +}; + +masters "four" { + 1.2.3.7; +}; diff --git a/lib/isccfg/check.c b/lib/isccfg/check.c index 4406d04423..78b51c1c5e 100644 --- a/lib/isccfg/check.c +++ b/lib/isccfg/check.c @@ -2113,6 +2113,19 @@ check_remoteserverlists(const cfg_obj_t *cctx, isc_mem_t *mctx) { if (tresult != ISC_R_SUCCESS) { result = tresult; } + /* parental-agents, primaries, masters are treated as synonyms */ + tresult = check_remoteserverlist(cctx, "parental-agents", symtab, mctx); + if (tresult != ISC_R_SUCCESS) { + result = tresult; + } + tresult = check_remoteserverlist(cctx, "primaries", symtab, mctx); + if (tresult != ISC_R_SUCCESS) { + result = tresult; + } + tresult = check_remoteserverlist(cctx, "masters", symtab, mctx); + if (tresult != ISC_R_SUCCESS) { + result = tresult; + } isc_symtab_destroy(&symtab); return result; } @@ -2381,8 +2394,8 @@ check_tls_definitions(const cfg_obj_t *config, isc_mem_t *mctx) { } static isc_result_t -get_remoteservers_def(const char *list, const char *name, const cfg_obj_t *cctx, - const cfg_obj_t **ret) { +get_remotes(const cfg_obj_t *cctx, const char *list, const char *name, + const cfg_obj_t **ret) { isc_result_t result; const cfg_obj_t *obj = NULL; const cfg_listelt_t *elt = NULL; @@ -2410,6 +2423,26 @@ get_remoteservers_def(const char *list, const char *name, const cfg_obj_t *cctx, return ISC_R_NOTFOUND; } +static isc_result_t +get_remoteservers_def(const char *name, const cfg_obj_t *cctx, + const cfg_obj_t **ret) { + isc_result_t result; + + result = get_remotes(cctx, "remote-servers", name, ret); + if (result == ISC_R_SUCCESS) { + return result; + } + result = get_remotes(cctx, "primaries", name, ret); + if (result == ISC_R_SUCCESS) { + return result; + } + result = get_remotes(cctx, "parental-agents", name, ret); + if (result == ISC_R_SUCCESS) { + return result; + } + return get_remotes(cctx, "masters", name, ret); +} + static isc_result_t validate_remotes(const cfg_obj_t *obj, const cfg_obj_t *config, uint32_t *countp, isc_mem_t *mctx) { @@ -2515,8 +2548,7 @@ resume: if (tresult == ISC_R_EXISTS) { continue; } - tresult = get_remoteservers_def("remote-servers", listname, - config, &obj); + tresult = get_remoteservers_def(listname, config, &obj); if (tresult != ISC_R_SUCCESS) { if (result == ISC_R_SUCCESS) { result = tresult; diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index ecadfabb28..75ca36332d 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -1143,6 +1143,10 @@ static cfg_clausedef_t namedconf_clauses[] = { { "masters", &cfg_type_remoteservers, CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_NODOC }, { "options", &cfg_type_options, 0 }, + { "parental-agents", &cfg_type_remoteservers, + CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_NODOC }, + { "primaries", &cfg_type_remoteservers, + CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_NODOC }, { "remote-servers", &cfg_type_remoteservers, CFG_CLAUSEFLAG_MULTI }, #if defined(HAVE_LIBXML2) || defined(HAVE_JSON_C) { "statistics-channels", &cfg_type_statschannels,