Do not allow defining "http" clauses named "default"

This name is reserved for being used in 'listen-on' statements only.
This commit is contained in:
Artem Boldariev
2021-09-30 12:40:03 +03:00
parent d27d20e6d4
commit d45df0d923
2 changed files with 46 additions and 20 deletions

View File

@@ -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;
};

View File

@@ -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 = "<unknown 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 = "<unknown 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 */