dns: moving name_equal func into common
authorAaron Haslett <aaronhaslett@catalyst.net.nz>
Tue, 5 Jun 2018 05:12:44 +0000 (17:12 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 Jul 2018 02:31:54 +0000 (04:31 +0200)
This function is duplicated in the BIND9 and RPC DNS servers.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=10812

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dns_server/dlz_bind9.c
source4/dns_server/dns_server.h
source4/dns_server/dnsserver_common.c
source4/dns_server/dnsserver_common.h
source4/rpc_server/dnsserver/dnsdata.c
source4/rpc_server/dnsserver/dnsserver.h

index 0463c6e47a6fff57aca72e3585c7a2d36883a4f9..e55d73ba50f494adb1adba7f6865d0ded494d334 100644 (file)
@@ -38,7 +38,7 @@
 #include <popt.h>
 #include "lib/util/dlinklist.h"
 #include "dlz_minimal.h"
-#include "dns_server/dnsserver_common.h"
+#include "dnsserver_common.h"
 
 struct b9_options {
        const char *url;
@@ -1481,25 +1481,6 @@ _PUBLIC_ isc_boolean_t dlz_ssumatch(const char *signer, const char *name, const
        return ISC_TRUE;
 }
 
-/*
-  see if two DNS names are the same
- */
-static bool dns_name_equal(const char *name1, const char *name2)
-{
-       size_t len1 = strlen(name1);
-       size_t len2 = strlen(name2);
-       if (name1[len1 - 1] == '.') {
-               len1--;
-       }
-       if (name2[len2 - 1] == '.') {
-               len2--;
-       }
-       if (len1 != len2) {
-               return false;
-       }
-       return strncasecmp_m(name1, name2, len1) == 0;
-}
-
 /*
   see if two dns records match
  */
index 05ef302680fa871cc2eb0817896f9e59e8288de3..48dd5ff81859b57fa621a4d277367b65ae520760 100644 (file)
@@ -82,7 +82,6 @@ WERROR dns_server_process_update(struct dns_server *dns,
                                 struct dns_res_rec **updates,    uint16_t *update_count,
                                 struct dns_res_rec **additional, uint16_t *arcount);
 
-bool dns_name_equal(const char *name1, const char *name2);
 bool dns_records_match(struct dnsp_DnssrvRpcRecord *rec1,
                       struct dnsp_DnssrvRpcRecord *rec2);
 bool dns_authoritative_for_zone(struct dns_server *dns,
index 6c7ab8025754e10d84ad4078824ffecb42a06702..20eaf125ada7e42e9b9be7d5d1b489b8ae67d4d9 100644 (file)
@@ -1047,3 +1047,23 @@ NTSTATUS dns_common_zones(struct ldb_context *samdb,
        TALLOC_FREE(frame);
        return NT_STATUS_OK;
 }
+
+/*
+  see if two DNS names are the same
+ */
+bool dns_name_equal(const char *name1, const char *name2)
+{
+       size_t len1 = strlen(name1);
+       size_t len2 = strlen(name2);
+
+       if (len1 > 0 && name1[len1 - 1] == '.') {
+               len1--;
+       }
+       if (len2 > 0 && name2[len2 - 1] == '.') {
+               len2--;
+       }
+       if (len1 != len2) {
+               return false;
+       }
+       return strncasecmp(name1, name2, len1) == 0;
+}
index f2be44ff0d63af1001efe89bf2f039ca7308536c..e37c7b8f9ab39f94488ce8279e6f8cc22d88f7c9 100644 (file)
@@ -68,6 +68,7 @@ WERROR dns_common_name2dn(struct ldb_context *samdb,
                          TALLOC_CTX *mem_ctx,
                          const char *name,
                          struct ldb_dn **_dn);
+bool dns_name_equal(const char *name1, const char *name2);
 
 /*
  * For this routine, base_dn is generally NULL.  The exception comes
index 6889cc306ceb8ecf924acc9cf5fa8282b368ddd8..59e29f029a675dafa018d9eaec59a4dd4e84e16a 100644 (file)
@@ -1119,23 +1119,6 @@ int dns_name_compare(const struct ldb_message **m1, const struct ldb_message **m
        return strcasecmp(ptr1, ptr2);
 }
 
-bool dns_name_equal(const char *name1, const char *name2)
-{
-       size_t len1 = strlen(name1);
-       size_t len2 = strlen(name2);
-
-       if (len1 > 0 && name1[len1 - 1] == '.') {
-               len1--;
-       }
-       if (len2 > 0 && name2[len2 - 1] == '.') {
-               len2--;
-       }
-       if (len1 != len2) {
-               return false;
-       }
-       return strncasecmp(name1, name2, len1) == 0;
-}
-
 bool dns_record_match(struct dnsp_DnssrvRpcRecord *rec1, struct dnsp_DnssrvRpcRecord *rec2)
 {
        bool status;
index 6948fb5d42d9d016176082fea229c7120d5efb3b..93f1d72f2ef5c4dc9751aed4984b6710b2c43198 100644 (file)
@@ -190,7 +190,6 @@ char *dns_split_node_name(TALLOC_CTX *mem_ctx, const char *node_name, const char
 
 int dns_name_compare(const struct ldb_message **m1, const struct ldb_message **m2,
                        char *search_name);
-bool dns_name_equal(const char *name1, const char *name2);
 bool dns_record_match(struct dnsp_DnssrvRpcRecord *rec1, struct dnsp_DnssrvRpcRecord *rec2);
 
 void dnsp_to_dns_copy(TALLOC_CTX *mem_ctx, struct dnsp_DnssrvRpcRecord *dnsp,