s4-rpc:dnsserver: DNS names are case insensitive
authorAmitay Isaacs <amitay@gmail.com>
Thu, 12 Jan 2012 04:10:42 +0000 (15:10 +1100)
committerAmitay Isaacs <amitay@samba.org>
Thu, 12 Jan 2012 04:10:08 +0000 (05:10 +0100)
source4/rpc_server/dnsserver/dcerpc_dnsserver.c
source4/rpc_server/dnsserver/dnsdata.c
source4/rpc_server/dnsserver/dnsutils.c

index fac99e1cb6fba061b42d9293676a05a6db520eea..5733a51177ae3a824272198880ce6abaa1285ba2 100644 (file)
@@ -1433,7 +1433,7 @@ static WERROR dnsserver_complex_operate_server(struct dnsserver_state *dsstate,
                *typeid_out = DNSSRV_TYPEID_DP_INFO;
 
                for (p = dsstate->partitions; p; p = p->next) {
-                       if (strcmp(p->pszDpFqdn, rin->String) == 0) {
+                       if (strcasecmp(p->pszDpFqdn, rin->String) == 0) {
                                dpinfo = talloc_zero(mem_ctx, struct DNS_RPC_DP_INFO);
                                W_ERROR_HAVE_NO_MEMORY(dpinfo);
 
@@ -1720,7 +1720,7 @@ static WERROR dnsserver_enumerate_records(struct dnsserver_state *dsstate,
        W_ERROR_HAVE_NO_MEMORY_AND_FREE(name, tmp_ctx);
 
        /* search all records under parent tree */
-       if (strcmp(name, z->name) == 0) {
+       if (strcasecmp(name, z->name) == 0) {
                ret = ldb_search(dsstate->samdb, tmp_ctx, &res, z->zone_dn,
                                LDB_SCOPE_ONELEVEL, attrs, "(objectClass=dnsNode)");
        } else {
@@ -1746,7 +1746,7 @@ static WERROR dnsserver_enumerate_records(struct dnsserver_state *dsstate,
                        (ldb_qsort_cmp_fn_t)dns_name_compare);
 
        /* Build a tree of name components from dns name */
-       if (strcmp(name, z->name) == 0) {
+       if (strcasecmp(name, z->name) == 0) {
                tree = dns_build_tree(tmp_ctx, "@", res);
        } else {
                tree = dns_build_tree(tmp_ctx, name, res);
@@ -1853,7 +1853,7 @@ static WERROR dnsserver_update_record(struct dnsserver_state *dsstate,
        W_ERROR_HAVE_NO_MEMORY(tmp_ctx);
 
        /* If node_name is @ or zone name, dns record is @ */
-       if (strcmp(node_name, "@") == 0 || strcmp(node_name, z->name) == 0) {
+       if (strcmp(node_name, "@") == 0 || strcasecmp(node_name, z->name) == 0) {
                name = talloc_strdup(tmp_ctx, "@");
        } else {
                name = dns_split_node_name(tmp_ctx, node_name, z->name);
index b2ab2d9ff510d695499a4b5224925c462eddbaee..50be4bcbf19f6305ed23d26299b823c06f18ccd0 100644 (file)
@@ -204,7 +204,7 @@ char *dns_split_node_name(TALLOC_CTX *tmp_ctx, const char *node_name, const char
                } else {
                        match = 0;
                        for (i=1; i<=zcount; i++) {
-                               if (strcmp(nlist[ncount-i], zlist[zcount-i]) != 0) {
+                               if (strcasecmp(nlist[ncount-i], zlist[zcount-i]) != 0) {
                                        break;
                                }
                                match++;
@@ -535,7 +535,7 @@ static struct dns_tree *dns_tree_find(struct dns_tree *tree, int ncount, char **
        if (strcmp(tree->name, "@") == 0) {
                start = 0;
        } else {
-               if (strcmp(tree->name, nlist[ncount-1]) != 0) {
+               if (strcasecmp(tree->name, nlist[ncount-1]) != 0) {
                        return NULL;
                }
                start = 1;
@@ -549,7 +549,7 @@ static struct dns_tree *dns_tree_find(struct dns_tree *tree, int ncount, char **
                }
                next = NULL;
                for (j=0; j<node->num_children; j++) {
-                       if (strcmp(nlist[(ncount-1)-i], node->children[j]->name) == 0) {
+                       if (strcasecmp(nlist[(ncount-1)-i], node->children[j]->name) == 0) {
                                next = node->children[j];
                                *match_count = i;
                                break;
@@ -601,7 +601,7 @@ struct dns_tree *dns_build_tree(TALLOC_CTX *mem_ctx, const char *name, struct ld
                if (strcmp(ptr, "@") == 0) {
                        base->data = res->msgs[i];
                        continue;
-               } else if (strcmp(ptr, name) == 0) {
+               } else if (strcasecmp(ptr, name) == 0) {
                        base->data = res->msgs[i];
                        continue;
                }
@@ -659,7 +659,7 @@ static void _dns_add_name(TALLOC_CTX *mem_ctx, const char *name, char ***add_nam
        int count = *add_count;
 
        for (i=0; i<count; i++) {
-               if (strcmp(ptr[i], name) == 0) {
+               if (strcasecmp(ptr[i], name) == 0) {
                        return;
                }
        }
@@ -860,14 +860,14 @@ int dns_name_compare(const struct ldb_message **m1, const struct ldb_message **m
        if (name1[0] == '@') {
                return -1;
        }
-       if (search_name && strcmp(name1, search_name) == 0) {
+       if (search_name && strcasecmp(name1, search_name) == 0) {
                return -1;
        }
 
        if (name2[0] == '@') {
                return 1;
        }
-       if (search_name && strcmp(name2, search_name) == 0) {
+       if (search_name && strcasecmp(name2, search_name) == 0) {
                return 1;
        }
 
@@ -877,7 +877,7 @@ int dns_name_compare(const struct ldb_message **m1, const struct ldb_message **m
        if (ptr1 == NULL) {
                ptr1 = name1;
        } else {
-               if (search_name && strcmp(ptr1+1, search_name) == 0) {
+               if (search_name && strcasecmp(ptr1+1, search_name) == 0) {
                        ptr1--;
                        while (ptr1 != name1) {
                                ptr1--;
@@ -895,7 +895,7 @@ int dns_name_compare(const struct ldb_message **m1, const struct ldb_message **m
        if (ptr2 == NULL) {
                ptr2 = name2;
        } else {
-               if (search_name && strcmp(ptr2+1, search_name) == 0) {
+               if (search_name && strcasecmp(ptr2+1, search_name) == 0) {
                        ptr2--;
                        while (ptr2 != name2) {
                                ptr2--;
index 5390384e57e4e912cecdf32557529d0eff60d34d..52a8bdde29d25c5c680d8d1ed243e21aaf964586 100644 (file)
@@ -170,7 +170,7 @@ struct dnsserver_zoneinfo *dnsserver_init_zoneinfo(struct dnsserver_zone *zone,
        fReverse = 0;
        len1 = strlen(zone->name);
        len2 = strlen(revzone);
-       if (len1 > len2 && strcmp(&zone->name[len1-len2], revzone) == 0) {
+       if (len1 > len2 && strcasecmp(&zone->name[len1-len2], revzone) == 0) {
                fReverse = 1;
        }
 
@@ -229,7 +229,7 @@ struct dnsserver_partition *dnsserver_find_partition(struct dnsserver_partition
        struct dnsserver_partition *p = NULL;
 
        for (p = partitions; p; p = p->next) {
-               if (strcmp(dp_fqdn, p->pszDpFqdn) == 0) {
+               if (strcasecmp(dp_fqdn, p->pszDpFqdn) == 0) {
                        break;
                }
        }
@@ -242,7 +242,7 @@ struct dnsserver_zone *dnsserver_find_zone(struct dnsserver_zone *zones, const c
        struct dnsserver_zone *z = NULL;
 
        for (z = zones; z; z = z->next) {
-               if (strcmp(zone_name, z->name) == 0) {
+               if (strcasecmp(zone_name, z->name) == 0) {
                        break;
                }
        }
@@ -259,7 +259,7 @@ struct ldb_dn *dnsserver_name_to_dn(TALLOC_CTX *mem_ctx, struct dnsserver_zone *
        if (dn == NULL) {
                return NULL;
        }
-       if (strcmp(name, z->name) == 0) {
+       if (strcasecmp(name, z->name) == 0) {
                ret = ldb_dn_add_child_fmt(dn, "DC=@");
        } else {
                ret = ldb_dn_add_child_fmt(dn, "DC=%s", name);