static void
checknames(dns_zonetype_t ztype, const cfg_obj_t **maps,
const cfg_obj_t **objp) {
- const char *zone = NULL;
isc_result_t result;
switch (ztype) {
case dns_zone_slave:
case dns_zone_mirror:
- zone = "slave";
+ result = named_checknames_get(maps, "secondary", objp);
+ if (result != ISC_R_SUCCESS) {
+ result = named_checknames_get(maps, "slave", objp);
+ }
break;
case dns_zone_master:
- zone = "master";
+ result = named_checknames_get(maps, "primary", objp);
+ if (result != ISC_R_SUCCESS) {
+ result = named_checknames_get(maps, "master", objp);
+ }
break;
default:
INSIST(0);
ISC_UNREACHABLE();
}
- result = named_checknames_get(maps, zone, objp);
+
INSIST(result == ISC_R_SUCCESS && objp != NULL && *objp != NULL);
}
}
}
+ obj = NULL;
+ (void)cfg_map_get(options, "check-names", &obj);
+ if (obj != NULL && !cfg_obj_islist(obj)) {
+ obj = NULL;
+ }
+ if (obj != NULL) {
+ enum { MAS = 1, PRI = 2, SLA = 4, SEC = 8 } values = 0;
+ for (const cfg_listelt_t *el = cfg_list_first(obj); el != NULL;
+ el = cfg_list_next(el))
+ {
+ const cfg_obj_t *tuple = cfg_listelt_value(el);
+ const cfg_obj_t *type = cfg_tuple_get(tuple, "type");
+ const char *keyword = cfg_obj_asstring(type);
+ if (strcasecmp(keyword, "primary") == 0) {
+ if ((values & PRI) == PRI) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "'check-names primary' "
+ "duplicated");
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_FAILURE;
+ }
+ }
+ values |= PRI;
+ } else if (strcasecmp(keyword, "master") == 0) {
+ if ((values & MAS) == MAS) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "'check-names master' "
+ "duplicated");
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_FAILURE;
+ }
+ }
+ values |= MAS;
+ } else if (strcasecmp(keyword, "secondary") == 0) {
+ if ((values & SEC) == SEC) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "'check-names secondary' "
+ "duplicated");
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_FAILURE;
+ }
+ }
+ values |= SEC;
+ } else if (strcasecmp(keyword, "slave") == 0) {
+ if ((values & SLA) == SLA) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "'check-names slave' "
+ "duplicated");
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_FAILURE;
+ }
+ }
+ values |= SLA;
+ }
+ }
+
+ if ((values & (PRI | MAS)) == (PRI | MAS)) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "'check-names' cannot take both "
+ "'primary' and 'master'");
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_FAILURE;
+ }
+ }
+
+ if ((values & (SEC | SLA)) == (SEC | SLA)) {
+ cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+ "'check-names' cannot take both "
+ "'secondary' and 'slave'");
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_FAILURE;
+ }
+ }
+ }
+
return (result);
}