Commit fcb2ecdb authored by Mark Andrews's avatar Mark Andrews
Browse files

1216. [bug] Multiple server clauses for the same server were not

                        reported.  [RT #2514]
parent 3561e645
1216. [bug] Multiple server clauses for the same server were not
reported. [RT #2514]
1215. [port] solaris: add support to ifconfig.sh for x86 2.5.1
1214. [bug] Win32: isc_file_renameunique() could leave zero length
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: check.c,v 1.25 2002/02/20 03:34:09 marka Exp $ */
/* $Id: check.c,v 1.26 2002/03/04 05:07:06 marka Exp $ */
#include <config.h>
......@@ -25,8 +25,10 @@
#include <isc/buffer.h>
#include <isc/log.h>
#include <isc/mem.h>
#include <isc/netaddr.h>
#include <isc/region.h>
#include <isc/result.h>
#include <isc/sockaddr.h>
#include <isc/symtab.h>
#include <isc/util.h>
......@@ -440,11 +442,53 @@ freekey(char *key, unsigned int type, isc_symvalue_t value, void *userarg) {
UNUSED(value);
isc_mem_free(userarg, key);
}
static isc_result_t
check_servers(cfg_obj_t *servers, isc_log_t *logctx) {
isc_result_t result = ISC_R_SUCCESS;
cfg_listelt_t *e1, *e2;
cfg_obj_t *v1, *v2;
isc_sockaddr_t *s1, *s2;
isc_netaddr_t na;
for (e1 = cfg_list_first(servers); e1 != NULL; e1 = cfg_list_next(e1)) {
v1 = cfg_listelt_value(e1);
s1 = cfg_obj_assockaddr(cfg_map_getname(v1));
e2 = e1;
while ((e2 = cfg_list_next(e2)) != NULL) {
v2 = cfg_listelt_value(e2);
s2 = cfg_obj_assockaddr(cfg_map_getname(v2));
if (isc_sockaddr_eqaddr(s1, s2)) {
const char *file = cfg_obj_file(v1);
unsigned int line = cfg_obj_line(v1);
isc_buffer_t target;
char buf[128];
if (file == NULL)
file = "<unknown file>";
isc_netaddr_fromsockaddr(&na, s2);
isc_buffer_init(&target, buf, sizeof(buf) - 1);
INSIST(isc_netaddr_totext(&na, &target)
== ISC_R_SUCCESS);
buf[isc_buffer_usedlength(&target)] = '\0';
cfg_obj_log(v2, logctx, ISC_LOG_ERROR,
"server '%s': already exists "
"previous definition: %s:%u",
buf, file, line);
result = ISC_R_FAILURE;
}
}
}
return (result);
}
static isc_result_t
check_viewconf(cfg_obj_t *config, cfg_obj_t *vconfig, dns_rdataclass_t vclass,
isc_log_t *logctx, isc_mem_t *mctx)
{
cfg_obj_t *servers = NULL;
cfg_obj_t *zones = NULL;
cfg_obj_t *keys = NULL;
cfg_listelt_t *element;
......@@ -525,6 +569,14 @@ check_viewconf(cfg_obj_t *config, cfg_obj_t *vconfig, dns_rdataclass_t vclass,
result = ISC_R_FAILURE;
}
if (vconfig != NULL) {
(void)cfg_map_get(vconfig, "server", &servers);
if (servers != NULL &&
check_servers(servers, logctx) != ISC_R_SUCCESS)
result = ISC_R_FAILURE;
}
if (vconfig != NULL)
tresult = check_options(vconfig, logctx);
else
......@@ -539,6 +591,7 @@ check_viewconf(cfg_obj_t *config, cfg_obj_t *vconfig, dns_rdataclass_t vclass,
isc_result_t
bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
cfg_obj_t *options = NULL;
cfg_obj_t *servers = NULL;
cfg_obj_t *views = NULL;
cfg_obj_t *acls = NULL;
cfg_obj_t *obj;
......@@ -555,6 +608,11 @@ bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) {
check_options(options, logctx) != ISC_R_SUCCESS)
result = ISC_R_FAILURE;
(void)cfg_map_get(config, "server", &servers);
if (servers != NULL &&
check_servers(servers, logctx) != ISC_R_SUCCESS)
result = ISC_R_FAILURE;
(void)cfg_map_get(config, "view", &views);
if (views == NULL) {
......
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