From 8977ab7ca0ed63a39a8cd0b915ab9cb1254dcd3f Mon Sep 17 00:00:00 2001 From: James Brister Date: Thu, 18 May 2000 23:20:21 +0000 Subject: [PATCH] Zone configuration validation is now done at end of config file parsing, and before loading callbacks. --- CHANGES | 4 ++ lib/dns/config/confparser.y | 12 +++- lib/dns/config/confzone.c | 105 +++++++++++++++++---------------- lib/dns/include/dns/confzone.h | 2 + 4 files changed, 72 insertions(+), 51 deletions(-) diff --git a/CHANGES b/CHANGES index 234a1af739..709d76a006 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ + 192. [bug] Zone configuration validation is now done at end + of config file parsing, and before loading + callbacks. + 191. [func] Patched to compile on UnixWare 7.x. This platform is not directly supported by the ISC. diff --git a/lib/dns/config/confparser.y b/lib/dns/config/confparser.y index 0673e9a8cb..6f7481d68e 100644 --- a/lib/dns/config/confparser.y +++ b/lib/dns/config/confparser.y @@ -16,7 +16,7 @@ * SOFTWARE. */ -/* $Id: confparser.y,v 1.81 2000/05/15 12:36:23 brister Exp $ */ +/* $Id: confparser.y,v 1.82 2000/05/18 23:20:18 brister Exp $ */ #include @@ -3981,6 +3981,11 @@ zone_stmt: L_ZONE domain_name optional_class L_LBRACE L_TYPE zone_type L_EOS if (zone != NULL && callbacks != NULL && callbacks->zonecbk != NULL) { + tmpres = dns_c_zone_validate(zone); + if (tmpres != ISC_R_SUCCESS) { + YYABORT; + } + tmpres = callbacks->zonecbk(currcfg, zone, view, @@ -4582,6 +4587,11 @@ zone_option: L_FILE L_QSTRING "failed to set enable-zone."); YYABORT; } + + if ($2 == ISC_FALSE) { + parser_warning(ISC_FALSE, "zone '%s' is disabled", + zone->name); + } } | L_DATABASE L_QSTRING { diff --git a/lib/dns/config/confzone.c b/lib/dns/config/confzone.c index df64c804fa..5151dc2ffb 100644 --- a/lib/dns/config/confzone.c +++ b/lib/dns/config/confzone.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: confzone.c,v 1.42 2000/05/15 12:36:28 brister Exp $ */ +/* $Id: confzone.c,v 1.43 2000/05/18 23:20:19 brister Exp $ */ #include @@ -195,63 +195,17 @@ dns_c_zonelist_delete(dns_c_zonelist_t **zlist) { isc_result_t dns_c_zonelist_checkzones(dns_c_zonelist_t *list) { dns_c_zone_t *zone; - dns_c_ipmatchlist_t *ipmlist; - dns_c_iplist_t *iplist; - dns_ssutable_t *ssutable = NULL; isc_result_t tmpres; isc_result_t result = ISC_R_SUCCESS; - const char *autherr = "zone '%s': allow-update is ignored when " - "update-policy is also used"; - const char *nomasterserr = "zone '%s': missing 'masters' entry"; - const char *emptymasterserr = "zone '%s': 'masters' value is empty"; - REQUIRE(DNS_C_ZONELIST_VALID(list)); for (zone = dns_c_zonelist_firstzone(list) ; zone != NULL ; zone = dns_c_zonelist_nextzone(list, zone)) { - - ipmlist = NULL; - ssutable = NULL; - - /* - * Check for allow-update and update-policty together - */ - if (zone->ztype == dns_c_zone_master) { - ipmlist = NULL; - tmpres = dns_c_zone_getallowupd(zone, &ipmlist); - if (tmpres == ISC_R_SUCCESS) { - tmpres = dns_c_zone_getssuauth(zone, - &ssutable); - if (tmpres == ISC_R_SUCCESS) { - isc_log_write(dns_lctx, - DNS_LOGCATEGORY_CONFIG, - DNS_LOGMODULE_CONFIG, - ISC_LOG_WARNING, autherr, - zone->name); - dns_c_zone_unsetallowupd(zone); - } - dns_c_ipmatchlist_detach(&ipmlist); - } - } else if (zone->ztype == dns_c_zone_slave) { - iplist = NULL; - tmpres = dns_c_zone_getmasterips(zone, &iplist); - if (tmpres != ISC_R_SUCCESS) { - isc_log_write(dns_lctx, - DNS_LOGCATEGORY_CONFIG, - DNS_LOGMODULE_CONFIG, - ISC_LOG_WARNING, nomasterserr, - zone->name); - result = ISC_R_FAILURE; - } else if (iplist->nextidx == 0) { - isc_log_write(dns_lctx, - DNS_LOGCATEGORY_CONFIG, - DNS_LOGMODULE_CONFIG, - ISC_LOG_WARNING, emptymasterserr, - zone->name); - result = ISC_R_FAILURE; - } + tmpres = dns_c_zone_validate(zone); + if (result == ISC_R_SUCCESS) { + result = tmpres; } } @@ -4068,5 +4022,56 @@ dns_c_zone_unsetenabled(dns_c_zone_t *zone) } +isc_result_t +dns_c_zone_validate(dns_c_zone_t *zone) +{ + dns_c_ipmatchlist_t *ipmlist = NULL; + dns_c_iplist_t *iplist = NULL; + dns_ssutable_t *ssutable = NULL; + isc_result_t tmpres; + isc_result_t result = ISC_R_SUCCESS; + const char *autherr = "zone '%s': allow-update is ignored when " + "update-policy is also used"; + const char *nomasterserr = "zone '%s': missing 'masters' entry"; + const char *emptymasterserr = "zone '%s': 'masters' value is empty"; + /* + * Check for allow-update and update-policty together + */ + if (zone->ztype == dns_c_zone_master) { + tmpres = dns_c_zone_getallowupd(zone, &ipmlist); + if (tmpres == ISC_R_SUCCESS) { + tmpres = dns_c_zone_getssuauth(zone, + &ssutable); + if (tmpres == ISC_R_SUCCESS) { + isc_log_write(dns_lctx, + DNS_LOGCATEGORY_CONFIG, + DNS_LOGMODULE_CONFIG, + ISC_LOG_WARNING, autherr, + zone->name); + dns_c_zone_unsetallowupd(zone); + } + dns_c_ipmatchlist_detach(&ipmlist); + } + } else if (zone->ztype == dns_c_zone_slave) { + iplist = NULL; + tmpres = dns_c_zone_getmasterips(zone, &iplist); + if (tmpres != ISC_R_SUCCESS) { + isc_log_write(dns_lctx, + DNS_LOGCATEGORY_CONFIG, + DNS_LOGMODULE_CONFIG, + ISC_LOG_WARNING, nomasterserr, + zone->name); + result = ISC_R_FAILURE; + } else if (iplist->nextidx == 0) { + isc_log_write(dns_lctx, + DNS_LOGCATEGORY_CONFIG, + DNS_LOGMODULE_CONFIG, + ISC_LOG_WARNING, emptymasterserr, + zone->name); + result = ISC_R_FAILURE; + } + } + return (result); +} diff --git a/lib/dns/include/dns/confzone.h b/lib/dns/include/dns/confzone.h index ce1f9b3ab5..6b804a3c51 100644 --- a/lib/dns/include/dns/confzone.h +++ b/lib/dns/include/dns/confzone.h @@ -468,6 +468,8 @@ isc_result_t dns_c_zone_unsetenabled(dns_c_zone_t *zone); +isc_result_t +dns_c_zone_validate(dns_c_zone_t *zone); ISC_LANG_ENDDECLS