From: Kai Blin Date: Wed, 29 Oct 2014 12:35:36 +0000 (+0100) Subject: dns: Add dns_get_authoritative_zone helper function X-Git-Tag: talloc-2.1.4~443 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7a54f33ef5d4f45127c9264f0c4f16a2a8a6541;p=thirdparty%2Fsamba.git dns: Add dns_get_authoritative_zone helper function Signed-off-by: Kai Blin Reviewed-by: Andreas Schneider --- diff --git a/source4/dns_server/dns_server.h b/source4/dns_server/dns_server.h index 3423ee03593..64b716a2542 100644 --- a/source4/dns_server/dns_server.h +++ b/source4/dns_server/dns_server.h @@ -93,6 +93,8 @@ bool dns_records_match(struct dnsp_DnssrvRpcRecord *rec1, struct dnsp_DnssrvRpcRecord *rec2); bool dns_authorative_for_zone(struct dns_server *dns, const char *name); +const char *dns_get_authoritative_zone(struct dns_server *dns, + const char *name); WERROR dns_lookup_records(struct dns_server *dns, TALLOC_CTX *mem_ctx, struct ldb_dn *dn, diff --git a/source4/dns_server/dns_utils.c b/source4/dns_server/dns_utils.c index c757c157626..28412eb7681 100644 --- a/source4/dns_server/dns_utils.c +++ b/source4/dns_server/dns_utils.c @@ -199,6 +199,22 @@ bool dns_authorative_for_zone(struct dns_server *dns, return true; } +const char *dns_get_authoritative_zone(struct dns_server *dns, + const char *name) +{ + const struct dns_server_zone *z; + size_t host_part_len = 0; + + for (z = dns->zones; z != NULL; z = z->next) { + bool match; + match = dns_name_match(z->name, name, &host_part_len); + if (match) { + return z->name; + } + } + return NULL; +} + WERROR dns_name2dn(struct dns_server *dns, TALLOC_CTX *mem_ctx, const char *name,