diff options
-rw-r--r-- | src/ldap_helper.c | 15 | ||||
-rw-r--r-- | src/zone_manager.c | 9 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/ldap_helper.c b/src/ldap_helper.c index cbf6c25..efd49da 100644 --- a/src/ldap_helper.c +++ b/src/ldap_helper.c @@ -580,12 +580,16 @@ modify_zone(dns_zone_t *zone, const char *update_str) * we assume that we are past the configuration phase and no new zones can be * added. In that case, only modify the zone's properties, like the update * policy. + * + * Returns ISC_R_SUCCESS if we found and successfully added at least one zone. + * Returns ISC_R_FAILURE otherwise. */ isc_result_t refresh_zones_from_ldap(ldap_instance_t *ldap_inst, isc_boolean_t create) { isc_result_t result = ISC_R_SUCCESS; ldap_connection_t *ldap_conn; + int zone_count = 0; ldap_entry_t *entry; char *attrs[] = { "idnsName", "idnsUpdatePolicy", NULL @@ -634,10 +638,11 @@ refresh_zones_from_ldap(ldap_instance_t *ldap_inst, isc_boolean_t create) /* Get the update policy and update the zone with it. */ result = get_values(entry, "idnsUpdatePolicy", &values); if (result == ISC_R_SUCCESS) - modify_zone(zone, HEAD(values)->value); + CHECK_NEXT(modify_zone(zone, HEAD(values)->value)); else - modify_zone(zone, NULL); + CHECK_NEXT(modify_zone(zone, NULL)); + zone_count++; next: if (dns_name_dynamic(&name)) dns_name_free(&name, ldap_inst->mctx); @@ -646,12 +651,14 @@ next: } cleanup: - /* XXX: Cleanup here */ put_connection(ldap_conn); log_debug(2, "finished refreshing list of zones"); - return result; + if (zone_count > 0) + return ISC_R_SUCCESS; + else + return ISC_R_FAILURE; } static const char * diff --git a/src/zone_manager.c b/src/zone_manager.c index ab9e740..d8a82a8 100644 --- a/src/zone_manager.c +++ b/src/zone_manager.c @@ -147,7 +147,14 @@ manager_create_db_instance(isc_mem_t *mctx, const char *name, CHECK(new_ldap_instance(mctx, db_inst->name, argv, dyndb_args, &db_inst->ldap_inst)); CHECK(new_ldap_cache(mctx, argv, &db_inst->ldap_cache)); - refresh_zones_from_ldap(db_inst->ldap_inst, ISC_TRUE); + result = refresh_zones_from_ldap(db_inst->ldap_inst, ISC_TRUE); + if (result != ISC_R_SUCCESS) { + /* In case we don't find any zones, we at least return + * ISC_R_SUCCESS so BIND won't exit because of this. */ + result = ISC_R_SUCCESS; + log_error("no valid zones found"); + goto cleanup; + } /* Add a timer to periodically refresh the zones. */ if (zone_refresh) { |