}
/*
- * Check "primaries" style list.
+ * Check "remote-servers" style list.
*/
static isc_result_t
-bind9_check_primarylist(const cfg_obj_t *cctx, const char *list,
- isc_log_t *logctx, isc_symtab_t *symtab,
- isc_mem_t *mctx) {
+bind9_check_remoteserverlist(const cfg_obj_t *cctx, const char *list,
+ isc_log_t *logctx, isc_symtab_t *symtab,
+ isc_mem_t *mctx) {
isc_symvalue_t symvalue;
isc_result_t result, tresult;
const cfg_obj_t *obj = NULL;
file = "<unknown file>";
}
cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
- "primaries list '%s' is duplicated: "
+ "%s list '%s' is duplicated: "
"also defined at %s:%u",
- name, file, line);
+ list, name, file, line);
isc_mem_free(mctx, tmp);
result = tresult;
break;
if (result != ISC_R_SUCCESS) {
return (result);
}
- tresult = bind9_check_primarylist(cctx, "primaries", logctx, symtab,
- mctx);
+ tresult = bind9_check_remoteserverlist(cctx, "primaries", logctx,
+ symtab, mctx);
if (tresult != ISC_R_SUCCESS) {
result = tresult;
}
- tresult = bind9_check_primarylist(cctx, "masters", logctx, symtab,
- mctx);
+ tresult = bind9_check_remoteserverlist(cctx, "masters", logctx, symtab,
+ mctx);
+ if (tresult != ISC_R_SUCCESS) {
+ result = tresult;
+ }
+ isc_symtab_destroy(&symtab);
+ return (result);
+}
+
+/*
+ * Check parental-agents lists for duplicates.
+ */
+static isc_result_t
+bind9_check_parentalagentlists(const cfg_obj_t *cctx, isc_log_t *logctx,
+ isc_mem_t *mctx) {
+ isc_result_t result, tresult;
+ isc_symtab_t *symtab = NULL;
+
+ result = isc_symtab_create(mctx, 100, freekey, mctx, false, &symtab);
+ if (result != ISC_R_SUCCESS) {
+ return (result);
+ }
+ tresult = bind9_check_remoteserverlist(cctx, "parental-agents", logctx,
+ symtab, mctx);
if (tresult != ISC_R_SUCCESS) {
result = tresult;
}
}
static isc_result_t
-get_primaries(const cfg_obj_t *cctx, const char *list, const char *name,
- 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;
}
static isc_result_t
-get_primaries_def(const cfg_obj_t *cctx, const char *name,
- const cfg_obj_t **ret) {
- isc_result_t result;
+get_remoteservers_def(const char *list, const char *name, const cfg_obj_t *cctx,
+ const cfg_obj_t **ret) {
+ isc_result_t result = ISC_R_NOTFOUND;
- result = get_primaries(cctx, "primaries", name, ret);
- if (result != ISC_R_SUCCESS) {
- result = get_primaries(cctx, "masters", name, ret);
+ if (strcmp(list, "primaries") == 0) {
+ result = get_remotes(cctx, "primaries", name, ret);
+ if (result != ISC_R_SUCCESS) {
+ result = get_remotes(cctx, "masters", name, ret);
+ }
+ } else if (strcmp(list, "parental-agents") == 0) {
+ result = get_remotes(cctx, "parental-agents", name, ret);
}
return (result);
}
static isc_result_t
-validate_primaries(const cfg_obj_t *obj, const cfg_obj_t *config,
- uint32_t *countp, isc_log_t *logctx, isc_mem_t *mctx) {
+validate_remotes(const char *list, const cfg_obj_t *obj,
+ const cfg_obj_t *config, uint32_t *countp, isc_log_t *logctx,
+ isc_mem_t *mctx) {
isc_result_t result = ISC_R_SUCCESS;
isc_result_t tresult;
uint32_t count = 0;
const cfg_listelt_t *element;
const cfg_listelt_t **stack = NULL;
uint32_t stackcount = 0, pushed = 0;
- const cfg_obj_t *list;
+ const cfg_obj_t *listobj;
REQUIRE(countp != NULL);
result = isc_symtab_create(mctx, 100, NULL, NULL, false, &symtab);
}
newlist:
- list = cfg_tuple_get(obj, "addresses");
- element = cfg_list_first(list);
+ listobj = cfg_tuple_get(obj, "addresses");
+ element = cfg_list_first(listobj);
resume:
for (; element != NULL; element = cfg_list_next(element)) {
const char *listname;
if (tresult == ISC_R_EXISTS) {
continue;
}
- tresult = get_primaries_def(config, listname, &obj);
+ tresult = get_remoteservers_def(list, listname, config, &obj);
if (tresult != ISC_R_SUCCESS) {
if (result == ISC_R_SUCCESS) {
result = tresult;
}
cfg_obj_log(addr, logctx, ISC_LOG_ERROR,
- "unable to find primaries list '%s'",
+ "unable to find %s list '%s'", list,
listname);
continue;
}
}
if (tresult == ISC_R_SUCCESS && donotify) {
uint32_t count;
- tresult = validate_primaries(obj, config, &count,
- logctx, mctx);
+ tresult = validate_remotes("primaries", obj, config,
+ &count, logctx, mctx);
if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS)
{
result = tresult;
result = ISC_R_FAILURE;
} else {
uint32_t count;
- tresult = validate_primaries(obj, config, &count,
- logctx, mctx);
+ tresult = validate_remotes("primaries", obj, config,
+ &count, logctx, mctx);
if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS)
{
result = tresult;
}
}
+ /*
+ * Primary and secondary zones that have a "parental-agents" field,
+ * must have a corresponding "parental-agents" clause.
+ */
+ if (ztype == CFG_ZONE_MASTER || ztype == CFG_ZONE_SLAVE) {
+ obj = NULL;
+ (void)cfg_map_get(zoptions, "parental-agents", &obj);
+ if (obj != NULL) {
+ uint32_t count;
+ tresult = validate_remotes("parental-agents", obj,
+ config, &count, logctx,
+ mctx);
+ if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS)
+ {
+ result = tresult;
+ }
+ if (tresult == ISC_R_SUCCESS && count == 0) {
+ cfg_obj_log(zoptions, logctx, ISC_LOG_ERROR,
+ "zone '%s': "
+ "empty 'parental-agents' entry",
+ znamestr);
+ result = ISC_R_FAILURE;
+ }
+ }
+ }
+
/*
* Configuring a mirror zone and disabling recursion at the same time
* contradicts the purpose of the former.
result = ISC_R_FAILURE;
}
+ if (bind9_check_parentalagentlists(config, logctx, mctx) !=
+ ISC_R_SUCCESS) {
+ result = ISC_R_FAILURE;
+ }
+
(void)cfg_map_get(config, "view", &views);
if (views != NULL && options != NULL) {