diff options
author | Andrew Bartlett <abartlet@samba.org> | 2015-09-22 12:10:00 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2015-10-26 05:11:21 +0100 |
commit | 0504065948eec9bd65296d5956b5863d9af06e41 (patch) | |
tree | 466e6b232c24256df68f03b4173c5ba4b41f28d0 /source4/dns_server/dns_server.c | |
parent | 2715805f4c617b9a5d9ae7d2252c6adb30ab6490 (diff) | |
download | samba-0504065948eec9bd65296d5956b5863d9af06e41.tar.gz |
dns_server: Put more code in common
This will allow a python module to be written to modify DNS entries in sam.ldb directly
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'source4/dns_server/dns_server.c')
-rw-r--r-- | source4/dns_server/dns_server.c | 66 |
1 files changed, 4 insertions, 62 deletions
diff --git a/source4/dns_server/dns_server.c b/source4/dns_server/dns_server.c index 66ab738eb43..45d28a77e6b 100644 --- a/source4/dns_server/dns_server.c +++ b/source4/dns_server/dns_server.c @@ -725,27 +725,6 @@ static NTSTATUS dns_startup_interfaces(struct dns_server *dns, return NT_STATUS_OK; } -static int dns_server_sort_zones(struct ldb_message **m1, struct ldb_message **m2) -{ - const char *n1, *n2; - size_t l1, l2; - - n1 = ldb_msg_find_attr_as_string(*m1, "name", NULL); - n2 = ldb_msg_find_attr_as_string(*m2, "name", NULL); - - l1 = strlen(n1); - l2 = strlen(n2); - - /* If the string lengths are not equal just sort by length */ - if (l1 != l2) { - /* If m1 is the larger zone name, return it first */ - return l2 - l1; - } - - /*TODO: We need to compare DNs here, we want the DomainDNSZones first */ - return 0; -} - static struct dns_server_tkey_store *tkey_store_init(TALLOC_CTX *mem_ctx, uint16_t size) { @@ -769,51 +748,14 @@ static struct dns_server_tkey_store *tkey_store_init(TALLOC_CTX *mem_ctx, static NTSTATUS dns_server_reload_zones(struct dns_server *dns) { - int ret; - static const char * const attrs[] = { "name", NULL}; - struct ldb_result *res; - int i; + NTSTATUS status; struct dns_server_zone *new_list = NULL; struct dns_server_zone *old_list = NULL; struct dns_server_zone *old_zone; - - // TODO: this search does not work against windows - ret = dsdb_search(dns->samdb, dns, &res, NULL, LDB_SCOPE_SUBTREE, - attrs, DSDB_SEARCH_SEARCH_ALL_PARTITIONS, "(objectClass=dnsZone)"); - if (ret != LDB_SUCCESS) { - return NT_STATUS_INTERNAL_DB_CORRUPTION; - } - - TYPESAFE_QSORT(res->msgs, res->count, dns_server_sort_zones); - - for (i=0; i < res->count; i++) { - struct dns_server_zone *z; - - z = talloc_zero(dns, struct dns_server_zone); - if (z == NULL) { - return NT_STATUS_NO_MEMORY; - } - - z->name = ldb_msg_find_attr_as_string(res->msgs[i], "name", NULL); - z->dn = talloc_move(z, &res->msgs[i]->dn); - /* - * Ignore the RootDNSServers zone and zones that we don't support yet - * RootDNSServers should never be returned (Windows DNS server don't) - * ..TrustAnchors should never be returned as is, (Windows returns - * TrustAnchors) and for the moment we don't support DNSSEC so we'd better - * not return this zone. - */ - if ((strcmp(z->name, "RootDNSServers") == 0) || - (strcmp(z->name, "..TrustAnchors") == 0)) - { - DEBUG(10, ("Ignoring zone %s\n", z->name)); - talloc_free(z); - continue; - } - DLIST_ADD_END(new_list, z, NULL); + status = dns_common_zones(dns->samdb, dns, &new_list); + if (!NT_STATUS_IS_OK(status)) { + return status; } - - old_list = dns->zones; dns->zones = new_list; while ((old_zone = DLIST_TAIL(old_list)) != NULL) { DLIST_REMOVE(old_list, old_zone); |