--- a/source4/dns_server/dlz_bind9.c 2015-08-05 08:14:32.000000000 +0200 +++ b/source4/dns_server/dlz_bind9.c 2015-08-05 08:07:08.400000000 +0200 @@ -627,6 +627,7 @@ if (dlz_bind9_state != NULL) { *dbdata = dlz_bind9_state; dlz_bind9_state_ref_count++; + dlz_bind9_state->log(ISC_LOG_INFO, "samba_dlz: dlz_create (%d)", dlz_bind9_state_ref_count); return ISC_R_SUCCESS; } @@ -746,10 +747,11 @@ _PUBLIC_ void dlz_destroy(void *dbdata) { struct dlz_bind9_data *state = talloc_get_type_abort(dbdata, struct dlz_bind9_data); - state->log(ISC_LOG_INFO, "samba_dlz: shutting down"); + state->log(ISC_LOG_INFO, "samba_dlz: dlz_destroy called"); dlz_bind9_state_ref_count--; if (dlz_bind9_state_ref_count == 0) { + state->log(ISC_LOG_INFO, "samba_dlz: dlz_destroy shutting down"); talloc_unlink(state, state->samdb); talloc_free(state); dlz_bind9_state = NULL; @@ -1135,6 +1137,27 @@ return true; } +static bool b9_zone_del(struct dlz_bind9_data *state, const char *name) +{ + struct b9_zone *zone = state->zonelist; + + zone->name = talloc_strdup(zone, name); + if (zone->name == NULL) { + talloc_free(zone); + return false; + } + + while (zone != NULL) { + if (strcasecmp(name, zone->name) == 0) { + DLIST_REMOVE(state->zonelist, zone); + break; + } + zone = zone->next; + } + + return true; +} + static bool b9_zone_exists(struct dlz_bind9_data *state, const char *name) { struct b9_zone *zone = state->zonelist; @@ -1165,6 +1188,7 @@ struct dlz_bind9_data *state = talloc_get_type_abort(dbdata, struct dlz_bind9_data); TALLOC_CTX *tmp_ctx; struct ldb_dn *dn; + struct zone_partition_relation *known_zone; int i; state->log(ISC_LOG_INFO, "samba_dlz: starting configure"); @@ -1173,6 +1197,29 @@ return ISC_R_FAILURE; } + /* Do reload + if (state->zone->next) { + for (known_zone = state->zone; known_zone->next; known_zone = known_zone->next) { +#if DLZ_DLOPEN_VERSION < 3 + state->writeable_zone(view, known_zone->id); +#else + state->writeable_zone(view, dlzdb, known_zone->id); +#endif + } + state->log(ISC_LOG_INFO, "samba_dlz: Done reload"); + return ISC_R_SUCCESS; + } + */ + + /* forget known zones (for reload) */ + while (state->zone->next) { + known_zone = state->zone; + state->zone = state->zone->next; + b9_zone_del(state, known_zone->id); + talloc_free(known_zone); + } + /* */ + tmp_ctx = talloc_new(state); for (i=0; zone_prefixes[i]; i++) { @@ -1197,6 +1244,7 @@ continue; } + state->log(ISC_LOG_INFO, "samba_dlz: dlz_configure: %d zones in partition %s", res->count, zone_prefixes[i]); for (j=0; jcount; j++) { isc_result_t result; const char *zone = ldb_msg_find_attr_as_string(res->msgs[j], "name", NULL); @@ -1205,6 +1253,7 @@ if (zone == NULL) { continue; } + state->log(ISC_LOG_INFO, "samba_dlz: dlz_configure: zone: '%s'", zone); /* Ignore zones that are not handled in BIND */ if ((strcmp(zone, "RootDNSServers") == 0) || (strcmp(zone, "..TrustAnchors") == 0)) { @@ -1269,9 +1318,12 @@ } // skip the application partitions if there is a pre-2k3 zone on the domain partition + /* if (!strcmp(zone_prefixes[i], "CN=MicrosoftDNS,CN=System") && state->zone->next) { + state->log(ISC_LOG_INFO, "samba_dlz: Skipping other partitions"); break; } + */ } talloc_free(tmp_ctx);