mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
dns: moving name_equal func into common
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>
This commit is contained in:
parent
d6e111ff42
commit
350029bdd8
@ -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
|
||||
*/
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user