]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add primaries, parental-agents as synonyms
authorMatthijs Mekking <matthijs@isc.org>
Fri, 6 Dec 2024 11:50:09 +0000 (12:50 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Fri, 13 Dec 2024 07:50:02 +0000 (08:50 +0100)
Add back the top blocks 'parental-agents', 'primaries', and 'masters'
to the configuration. Do not document them as so many names for the
same clause is confusing.

This has a slight negative side effect that a top block 'primaries'
can be referred to with a zone statement 'parental-agents' for example,
but that shouldn't be a big issue.

bin/named/config.c
bin/tests/system/checkconf/bad-duplicate-remote-servers-synonyms.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-multiple-remote-servers-synonyms.conf [new file with mode: 0644]
lib/isccfg/check.c
lib/isccfg/namedconf.c

index 558f7d72cf735f9a8e45d04ddd59a3b3c23fd461..23df890193232f17c1a06c8c62cff0c31bc93968 100644 (file)
@@ -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 (file)
index 0000000..f2de15b
--- /dev/null
@@ -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 (file)
index 0000000..891538c
--- /dev/null
@@ -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;
+};
index 4406d044232e1079a02077f93b201904c744afb9..78b51c1c5e48b736cf3405376ddc661ceba3dbe5 100644 (file)
@@ -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;
index ecadfabb28045205e487d05ca3ddb2dcf4b6c160..75ca36332dd6772fefd012b365ecf8e9ebe239d8 100644 (file)
@@ -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,