summaryrefslogtreecommitdiff
path: root/source4/dns_server/dns_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/dns_server/dns_utils.c')
-rw-r--r--source4/dns_server/dns_utils.c88
1 files changed, 3 insertions, 85 deletions
diff --git a/source4/dns_server/dns_utils.c b/source4/dns_server/dns_utils.c
index 28412eb7681..3092633346e 100644
--- a/source4/dns_server/dns_utils.c
+++ b/source4/dns_server/dns_utils.c
@@ -33,47 +33,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_DNS
-bool dns_name_match(const char *zone, const char *name, size_t *host_part_len)
-{
- size_t zl = strlen(zone);
- size_t nl = strlen(name);
- ssize_t zi, ni;
- static const size_t fixup = 'a' - 'A';
-
- if (zl > nl) {
- return false;
- }
-
- for (zi = zl, ni = nl; zi >= 0; zi--, ni--) {
- char zc = zone[zi];
- char nc = name[ni];
-
- /* convert to lower case */
- if (zc >= 'A' && zc <= 'Z') {
- zc += fixup;
- }
- if (nc >= 'A' && nc <= 'Z') {
- nc += fixup;
- }
-
- if (zc != nc) {
- return false;
- }
- }
-
- if (ni >= 0) {
- if (name[ni] != '.') {
- return false;
- }
-
- ni--;
- }
-
- *host_part_len = ni+1;
-
- return true;
-}
-
/* Names are equal if they match and there's nothing left over */
bool dns_name_equal(const char *name1, const char *name2)
{
@@ -218,51 +177,10 @@ const char *dns_get_authoritative_zone(struct dns_server *dns,
WERROR dns_name2dn(struct dns_server *dns,
TALLOC_CTX *mem_ctx,
const char *name,
- struct ldb_dn **_dn)
+ struct ldb_dn **dn)
{
- struct ldb_dn *base;
- struct ldb_dn *dn;
- const struct dns_server_zone *z;
- size_t host_part_len = 0;
-
- if (name == NULL) {
- return DNS_ERR(FORMAT_ERROR);
- }
-
- /*TODO: Check if 'name' is a valid DNS name */
-
- if (strcmp(name, "") == 0) {
- base = ldb_get_default_basedn(dns->samdb);
- dn = ldb_dn_copy(mem_ctx, base);
- ldb_dn_add_child_fmt(dn, "DC=@,DC=RootDNSServers,CN=MicrosoftDNS,CN=System");
- *_dn = dn;
- return WERR_OK;
- }
-
- for (z = dns->zones; z != NULL; z = z->next) {
- bool match;
-
- match = dns_name_match(z->name, name, &host_part_len);
- if (match) {
- break;
- }
- }
-
- if (z == NULL) {
- return DNS_ERR(NAME_ERROR);
- }
-
- if (host_part_len == 0) {
- dn = ldb_dn_copy(mem_ctx, z->dn);
- ldb_dn_add_child_fmt(dn, "DC=@");
- *_dn = dn;
- return WERR_OK;
- }
-
- dn = ldb_dn_copy(mem_ctx, z->dn);
- ldb_dn_add_child_fmt(dn, "DC=%*.*s", (int)host_part_len, (int)host_part_len, name);
- *_dn = dn;
- return WERR_OK;
+ return dns_common_name2dn(dns->samdb, dns->zones,
+ mem_ctx, name, dn);
}
WERROR dns_generate_options(struct dns_server *dns,