diff --git a/bin/tests/system/checkconf/bad-doh-default.conf b/bin/tests/system/checkconf/bad-doh-default.conf new file mode 100644 index 0000000000..9e4fa7ba6e --- /dev/null +++ b/bin/tests/system/checkconf/bad-doh-default.conf @@ -0,0 +1,18 @@ +/* + * 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. + */ + +# 'default' is a built-in configuration intended to be used in +# 'listen-on' statements +http default { + endpoints { "/dns-query"; }; + listener-clients 100; + streams-per-connection 100; +}; diff --git a/lib/bind9/check.c b/lib/bind9/check.c index 84b899953a..ac1ab2f4a9 100644 --- a/lib/bind9/check.c +++ b/lib/bind9/check.c @@ -2040,27 +2040,35 @@ bind9_check_httpserver(const cfg_obj_t *http, isc_log_t *logctx, const cfg_listelt_t *elt = NULL; isc_symvalue_t symvalue; - /* Check for duplicates */ - symvalue.as_cpointer = http; - result = isc_symtab_define(symtab, name, 1, symvalue, - isc_symexists_reject); - if (result == ISC_R_EXISTS) { - const char *file = NULL; - unsigned int line; - - tresult = isc_symtab_lookup(symtab, name, 1, &symvalue); - RUNTIME_CHECK(tresult == ISC_R_SUCCESS); - - line = cfg_obj_line(symvalue.as_cpointer); - file = cfg_obj_file(symvalue.as_cpointer); - if (file == NULL) { - file = ""; - } - + if (strcasecmp(name, "default") == 0) { cfg_obj_log(http, logctx, ISC_LOG_ERROR, - "http '%s' is duplicated: " - "also defined at %s:%u", - name, file, line); + "'http' name cannot be '%s' (which is a " + "built-in configuration)", + name); + result = ISC_R_FAILURE; + } else { + /* Check for duplicates */ + symvalue.as_cpointer = http; + result = isc_symtab_define(symtab, name, 1, symvalue, + isc_symexists_reject); + if (result == ISC_R_EXISTS) { + const char *file = NULL; + unsigned int line; + + tresult = isc_symtab_lookup(symtab, name, 1, &symvalue); + RUNTIME_CHECK(tresult == ISC_R_SUCCESS); + + line = cfg_obj_line(symvalue.as_cpointer); + file = cfg_obj_file(symvalue.as_cpointer); + if (file == NULL) { + file = ""; + } + + cfg_obj_log(http, logctx, ISC_LOG_ERROR, + "http '%s' is duplicated: " + "also defined at %s:%u", + name, file, line); + } } /* Check endpoints are valid */