2014-07-30 10:01:11 +04:00
/*
Unix SMB / CIFS implementation .
DNS server utils
Copyright ( C ) 2010 Kai Blin
Copyright ( C ) 2014 Stefan Metzmacher
2015-09-22 03:10:00 +03:00
Copyright ( C ) 2015 Andrew Bartlett
2014-07-30 10:01:11 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# include "includes.h"
# include "libcli/util/ntstatus.h"
# include "libcli/util/werror.h"
# include "librpc/ndr/libndr.h"
# include "librpc/gen_ndr/ndr_dns.h"
# include "librpc/gen_ndr/ndr_dnsp.h"
# include <ldb.h>
# include "dsdb/samdb/samdb.h"
# include "dsdb/common/util.h"
# include "dns_server/dnsserver_common.h"
2018-07-02 04:43:33 +03:00
# include "rpc_server/dnsserver/dnsserver.h"
2015-09-22 03:10:00 +03:00
# include "lib/util/dlinklist.h"
2021-04-12 22:00:41 +03:00
# include "system/network.h"
2014-07-30 10:01:11 +04:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_DNS
2020-08-07 23:27:39 +03:00
# undef strncasecmp
2014-07-30 10:01:11 +04:00
uint8_t werr_to_dns_err ( WERROR werr )
{
if ( W_ERROR_EQUAL ( WERR_OK , werr ) ) {
return DNS_RCODE_OK ;
} else if ( W_ERROR_EQUAL ( DNS_ERR ( FORMAT_ERROR ) , werr ) ) {
return DNS_RCODE_FORMERR ;
} else if ( W_ERROR_EQUAL ( DNS_ERR ( SERVER_FAILURE ) , werr ) ) {
return DNS_RCODE_SERVFAIL ;
} else if ( W_ERROR_EQUAL ( DNS_ERR ( NAME_ERROR ) , werr ) ) {
return DNS_RCODE_NXDOMAIN ;
} else if ( W_ERROR_EQUAL ( WERR_DNS_ERROR_NAME_DOES_NOT_EXIST , werr ) ) {
return DNS_RCODE_NXDOMAIN ;
} else if ( W_ERROR_EQUAL ( DNS_ERR ( NOT_IMPLEMENTED ) , werr ) ) {
return DNS_RCODE_NOTIMP ;
} else if ( W_ERROR_EQUAL ( DNS_ERR ( REFUSED ) , werr ) ) {
return DNS_RCODE_REFUSED ;
} else if ( W_ERROR_EQUAL ( DNS_ERR ( YXDOMAIN ) , werr ) ) {
return DNS_RCODE_YXDOMAIN ;
} else if ( W_ERROR_EQUAL ( DNS_ERR ( YXRRSET ) , werr ) ) {
return DNS_RCODE_YXRRSET ;
} else if ( W_ERROR_EQUAL ( DNS_ERR ( NXRRSET ) , werr ) ) {
return DNS_RCODE_NXRRSET ;
} else if ( W_ERROR_EQUAL ( DNS_ERR ( NOTAUTH ) , werr ) ) {
return DNS_RCODE_NOTAUTH ;
} else if ( W_ERROR_EQUAL ( DNS_ERR ( NOTZONE ) , werr ) ) {
return DNS_RCODE_NOTZONE ;
} else if ( W_ERROR_EQUAL ( DNS_ERR ( BADKEY ) , werr ) ) {
return DNS_RCODE_BADKEY ;
2024-05-31 09:36:40 +03:00
} else if ( W_ERROR_EQUAL ( WERR_ACCESS_DENIED , werr ) ) {
return DNS_RCODE_REFUSED ;
2014-07-30 10:01:11 +04:00
}
DEBUG ( 5 , ( " No mapping exists for %s \n " , win_errstr ( werr ) ) ) ;
return DNS_RCODE_SERVFAIL ;
}
2014-07-30 10:24:10 +04:00
2017-04-11 03:43:22 +03:00
WERROR dns_common_extract ( struct ldb_context * samdb ,
const struct ldb_message_element * el ,
2014-07-30 10:24:10 +04:00
TALLOC_CTX * mem_ctx ,
struct dnsp_DnssrvRpcRecord * * records ,
uint16_t * num_records )
{
uint16_t ri ;
struct dnsp_DnssrvRpcRecord * recs ;
* records = NULL ;
* num_records = 0 ;
recs = talloc_zero_array ( mem_ctx , struct dnsp_DnssrvRpcRecord ,
el - > num_values ) ;
if ( recs = = NULL ) {
2015-12-03 17:24:18 +03:00
return WERR_NOT_ENOUGH_MEMORY ;
2014-07-30 10:24:10 +04:00
}
for ( ri = 0 ; ri < el - > num_values ; ri + + ) {
2017-04-11 03:43:22 +03:00
bool am_rodc ;
int ret ;
2017-06-19 06:01:56 +03:00
const char * dnsHostName = NULL ;
2014-07-30 10:24:10 +04:00
struct ldb_val * v = & el - > values [ ri ] ;
enum ndr_err_code ndr_err ;
ndr_err = ndr_pull_struct_blob ( v , recs , & recs [ ri ] ,
( ndr_pull_flags_fn_t ) ndr_pull_dnsp_DnssrvRpcRecord ) ;
if ( ! NDR_ERR_CODE_IS_SUCCESS ( ndr_err ) ) {
TALLOC_FREE ( recs ) ;
DEBUG ( 0 , ( " Failed to grab dnsp_DnssrvRpcRecord \n " ) ) ;
return DNS_ERR ( SERVER_FAILURE ) ;
}
2017-04-11 03:43:22 +03:00
/*
* In AD , except on an RODC ( where we should list a random RWDC ,
* we should over - stamp the MNAME with our own hostname
*/
if ( recs [ ri ] . wType ! = DNS_TYPE_SOA ) {
continue ;
}
ret = samdb_rodc ( samdb , & am_rodc ) ;
if ( ret ! = LDB_SUCCESS ) {
DEBUG ( 0 , ( " Failed to confirm we are not an RODC: %s \n " ,
ldb_errstring ( samdb ) ) ) ;
return DNS_ERR ( SERVER_FAILURE ) ;
}
if ( am_rodc ) {
continue ;
}
2017-06-19 06:01:56 +03:00
ret = samdb_dns_host_name ( samdb , & dnsHostName ) ;
if ( ret ! = LDB_SUCCESS | | dnsHostName = = NULL ) {
2023-08-07 07:52:33 +03:00
DEBUG ( 0 , ( " Failed to get dnsHostName from rootDSE \n " ) ) ;
2017-04-11 03:43:22 +03:00
return DNS_ERR ( SERVER_FAILURE ) ;
}
2017-06-19 06:01:56 +03:00
recs [ ri ] . data . soa . mname = talloc_strdup ( recs , dnsHostName ) ;
2014-07-30 10:24:10 +04:00
}
2017-04-11 03:43:22 +03:00
2014-07-30 10:24:10 +04:00
* records = recs ;
* num_records = el - > num_values ;
return WERR_OK ;
}
2017-08-03 06:12:02 +03:00
/*
* Lookup a DNS record , performing an exact match .
* i . e . DNS wild card records are not considered .
*/
2014-07-30 10:24:10 +04:00
WERROR dns_common_lookup ( struct ldb_context * samdb ,
TALLOC_CTX * mem_ctx ,
struct ldb_dn * dn ,
struct dnsp_DnssrvRpcRecord * * records ,
2014-07-31 10:54:17 +04:00
uint16_t * num_records ,
bool * tombstoned )
2014-07-30 10:24:10 +04:00
{
2019-04-05 01:13:15 +03:00
const struct timeval start = timeval_current ( ) ;
2014-07-30 10:24:10 +04:00
static const char * const attrs [ ] = {
" dnsRecord " ,
2014-07-31 10:54:17 +04:00
" dNSTombstoned " ,
2014-07-30 10:24:10 +04:00
NULL
} ;
int ret ;
2019-04-05 01:13:15 +03:00
WERROR werr = WERR_OK ;
2014-07-30 10:24:10 +04:00
struct ldb_message * msg = NULL ;
struct ldb_message_element * el ;
* records = NULL ;
* num_records = 0 ;
2014-07-31 10:54:17 +04:00
if ( tombstoned ! = NULL ) {
* tombstoned = false ;
ret = dsdb_search_one ( samdb , mem_ctx , & msg , dn ,
LDB_SCOPE_BASE , attrs , 0 ,
" (objectClass=dnsNode) " ) ;
} else {
ret = dsdb_search_one ( samdb , mem_ctx , & msg , dn ,
LDB_SCOPE_BASE , attrs , 0 ,
" (&(objectClass=dnsNode)(!(dNSTombstoned=TRUE))) " ) ;
}
2014-07-30 10:24:10 +04:00
if ( ret = = LDB_ERR_NO_SUCH_OBJECT ) {
2019-04-05 01:13:15 +03:00
werr = WERR_DNS_ERROR_NAME_DOES_NOT_EXIST ;
goto exit ;
2014-07-30 10:24:10 +04:00
}
if ( ret ! = LDB_SUCCESS ) {
/* TODO: we need to check if there's a glue record we need to
* create a referral to */
2019-04-05 01:13:15 +03:00
werr = DNS_ERR ( NAME_ERROR ) ;
goto exit ;
2014-07-30 10:24:10 +04:00
}
2014-07-31 10:54:17 +04:00
if ( tombstoned ! = NULL ) {
* tombstoned = ldb_msg_find_attr_as_bool ( msg ,
" dNSTombstoned " , false ) ;
}
2014-07-30 10:24:10 +04:00
el = ldb_msg_find_element ( msg , " dnsRecord " ) ;
if ( el = = NULL ) {
TALLOC_FREE ( msg ) ;
2015-10-14 01:59:26 +03:00
/*
* records produced by older Samba releases
* keep dnsNode objects without dnsRecord and
* without setting dNSTombstoned = TRUE .
*
* We just pretend they ' re tombstones .
*/
2014-07-31 10:54:17 +04:00
if ( tombstoned ! = NULL ) {
struct dnsp_DnssrvRpcRecord * recs ;
recs = talloc_array ( mem_ctx ,
struct dnsp_DnssrvRpcRecord ,
1 ) ;
if ( recs = = NULL ) {
2019-04-05 01:13:15 +03:00
werr = WERR_NOT_ENOUGH_MEMORY ;
goto exit ;
2014-07-31 10:54:17 +04:00
}
recs [ 0 ] = ( struct dnsp_DnssrvRpcRecord ) {
. wType = DNS_TYPE_TOMBSTONE ,
/*
* A value of timestamp ! = 0
* indicated that the object was already
* a tombstone , this will be used
* in dns_common_replace ( )
*/
2021-03-24 02:49:22 +03:00
. data . EntombedTime = 1 ,
2014-07-31 10:54:17 +04:00
} ;
* tombstoned = true ;
* records = recs ;
* num_records = 1 ;
2019-04-05 01:13:15 +03:00
werr = WERR_OK ;
goto exit ;
2015-10-14 01:59:26 +03:00
} else {
/*
* Because we are not looking for a tombstone
* in this codepath , we just pretend it does
* not exist at all .
*/
2019-04-05 01:13:15 +03:00
werr = WERR_DNS_ERROR_NAME_DOES_NOT_EXIST ;
goto exit ;
2014-07-31 10:54:17 +04:00
}
2014-07-30 10:24:10 +04:00
}
2017-04-11 03:43:22 +03:00
werr = dns_common_extract ( samdb , el , mem_ctx , records , num_records ) ;
2014-07-30 10:24:10 +04:00
TALLOC_FREE ( msg ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
2019-04-05 01:13:15 +03:00
goto exit ;
2014-07-30 10:24:10 +04:00
}
2019-04-05 01:13:15 +03:00
werr = WERR_OK ;
exit :
DNS_COMMON_LOG_OPERATION (
win_errstr ( werr ) ,
& start ,
NULL ,
dn = = NULL ? NULL : ldb_dn_get_linearized ( dn ) ,
NULL ) ;
return werr ;
2014-07-30 10:24:10 +04:00
}
2014-07-30 20:27:56 +04:00
2017-08-03 06:12:02 +03:00
/*
* Build an ldb_parse_tree node for an equality check
*
* Note : name is assumed to have been validated by dns_name_check
* so will be zero terminated and of a reasonable size .
*/
static struct ldb_parse_tree * build_equality_operation (
TALLOC_CTX * mem_ctx ,
bool add_asterix , /* prepend an '*' to the name */
const uint8_t * name , /* the value being matched */
const char * attr , /* the attribute to check name against */
size_t size ) /* length of name */
{
struct ldb_parse_tree * el = NULL ; /* Equality node being built */
struct ldb_val * value = NULL ; /* Value the attr will be compared
with */
size_t length = 0 ; /* calculated length of the value
including option ' * ' prefix and
' \0 ' string terminator */
el = talloc ( mem_ctx , struct ldb_parse_tree ) ;
if ( el = = NULL ) {
DBG_ERR ( " Unable to allocate ldb_parse_tree \n " ) ;
return NULL ;
}
el - > operation = LDB_OP_EQUALITY ;
el - > u . equality . attr = talloc_strdup ( mem_ctx , attr ) ;
value = & el - > u . equality . value ;
length = ( add_asterix ) ? size + 2 : size + 1 ;
value - > data = talloc_zero_array ( el , uint8_t , length ) ;
2021-09-02 08:14:44 +03:00
if ( value - > data = = NULL ) {
2017-08-03 06:12:02 +03:00
DBG_ERR ( " Unable to allocate value->data \n " ) ;
TALLOC_FREE ( el ) ;
return NULL ;
}
value - > length = length ;
if ( add_asterix ) {
value - > data [ 0 ] = ' * ' ;
2021-07-14 07:09:01 +03:00
if ( name ! = NULL ) {
memcpy ( & value - > data [ 1 ] , name , size ) ;
}
} else if ( name ! = NULL ) {
2017-08-03 06:12:02 +03:00
memcpy ( value - > data , name , size ) ;
}
return el ;
}
/*
* Determine the number of levels in name
* essentially the number of ' . ' s in the name + 1
*
* name is assumed to have been validated by dns_name_check
*/
static unsigned int number_of_labels ( const struct ldb_val * name ) {
int x = 0 ;
unsigned int labels = 1 ;
for ( x = 0 ; x < name - > length ; x + + ) {
if ( name - > data [ x ] = = ' . ' ) {
labels + + ;
}
}
return labels ;
}
/*
* Build a query that matches the target name , and any possible
* DNS wild card entries
*
* Builds a parse tree equivalent to the example query .
*
* x . y . z - > ( | ( name = x . y . z ) ( name = \ 2 a . y . z ) ( name = \ 2 a . z ) ( name = \ 2 a ) )
*
2017-12-18 06:22:23 +03:00
* The attribute ' name ' is used as this is what the LDB index is on
* ( the RDN , being ' dc ' in this use case , does not have an index in
* the AD schema ) .
*
2017-08-03 06:12:02 +03:00
* Returns NULL if unable to build the query .
*
* The first component of the DN is assumed to be the name being looked up
* and also that it has been validated by dns_name_check
*
*/
# define BASE "(&(objectClass=dnsNode)(!(dNSTombstoned=TRUE))(|(a=b)(c=d)))"
static struct ldb_parse_tree * build_wildcard_query (
TALLOC_CTX * mem_ctx ,
struct ldb_dn * dn )
{
const struct ldb_val * name = NULL ; /* The DNS name being
queried */
2017-12-18 06:22:23 +03:00
const char * attr = " name " ; /* The attribute name */
2017-08-03 06:12:02 +03:00
struct ldb_parse_tree * query = NULL ; /* The constructed query
parse tree */
struct ldb_parse_tree * wildcard_query = NULL ; /* The parse tree for the
name and wild card
entries */
int labels = 0 ; /* The number of labels in the name */
name = ldb_dn_get_rdn_val ( dn ) ;
if ( name = = NULL ) {
DBG_ERR ( " Unable to get domain name value \n " ) ;
return NULL ;
}
labels = number_of_labels ( name ) ;
query = ldb_parse_tree ( mem_ctx , BASE ) ;
if ( query = = NULL ) {
DBG_ERR ( " Unable to parse query %s \n " , BASE ) ;
return NULL ;
}
/*
* The 3 rd element of BASE is a place holder which is replaced with
* the actual wild card query
*/
wildcard_query = query - > u . list . elements [ 2 ] ;
TALLOC_FREE ( wildcard_query - > u . list . elements ) ;
wildcard_query - > u . list . num_elements = labels + 1 ;
wildcard_query - > u . list . elements = talloc_array (
wildcard_query ,
struct ldb_parse_tree * ,
labels + 1 ) ;
/*
* Build the wild card query
*/
{
int x = 0 ; /* current character in the name */
int l = 0 ; /* current equality operator index in elements */
struct ldb_parse_tree * el = NULL ; /* Equality operator being
built */
bool add_asterix = true ; /* prepend an '*' to the value */
for ( l = 0 , x = 0 ; l < labels & & x < name - > length ; l + + ) {
unsigned int size = name - > length - x ;
add_asterix = ( name - > data [ x ] = = ' . ' ) ;
el = build_equality_operation (
mem_ctx ,
add_asterix ,
& name - > data [ x ] ,
attr ,
size ) ;
if ( el = = NULL ) {
return NULL ; /* Reason will have been logged */
}
wildcard_query - > u . list . elements [ l ] = el ;
/* skip to the start of the next label */
2018-07-18 06:33:26 +03:00
x + + ;
2017-08-03 06:12:02 +03:00
for ( ; x < name - > length & & name - > data [ x ] ! = ' . ' ; x + + ) ;
}
/* Add the base level "*" only query */
el = build_equality_operation ( mem_ctx , true , NULL , attr , 0 ) ;
if ( el = = NULL ) {
TALLOC_FREE ( query ) ;
return NULL ; /* Reason will have been logged */
}
wildcard_query - > u . list . elements [ l ] = el ;
}
return query ;
}
/*
* Scan the list of records matching a dns wildcard query and return the
* best match .
*
* The best match is either an exact name match , or the longest wild card
* entry returned
*
* i . e . name = a . b . c candidates * . b . c , * . c , - * . b . c would be selected
* name = a . b . c candidates a . b . c , * . b . c , * . c - a . b . c would be selected
*/
static struct ldb_message * get_best_match ( struct ldb_dn * dn ,
struct ldb_result * result )
{
int matched = 0 ; /* Index of the current best match in result */
size_t length = 0 ; /* The length of the current candidate */
const struct ldb_val * target = NULL ; /* value we're looking for */
const struct ldb_val * candidate = NULL ; /* current candidate value */
int x = 0 ;
target = ldb_dn_get_rdn_val ( dn ) ;
for ( x = 0 ; x < result - > count ; x + + ) {
candidate = ldb_dn_get_rdn_val ( result - > msgs [ x ] - > dn ) ;
if ( strncasecmp ( ( char * ) target - > data ,
( char * ) candidate - > data ,
target - > length ) = = 0 ) {
/* Exact match stop searching and return */
return result - > msgs [ x ] ;
}
if ( candidate - > length > length ) {
matched = x ;
length = candidate - > length ;
}
}
return result - > msgs [ matched ] ;
}
/*
* Look up a DNS entry , if an exact match does not exist , return the
* closest matching DNS wildcard entry if available
*
* Returns : LDB_ERR_NO_SUCH_OBJECT If no matching record exists
* LDB_ERR_OPERATIONS_ERROR If the query fails
* LDB_SUCCESS If a matching record was retrieved
*
*/
static int dns_wildcard_lookup ( struct ldb_context * samdb ,
TALLOC_CTX * mem_ctx ,
struct ldb_dn * dn ,
struct ldb_message * * msg )
{
static const char * const attrs [ ] = {
" dnsRecord " ,
" dNSTombstoned " ,
NULL
} ;
struct ldb_dn * parent = NULL ; /* The parent dn */
struct ldb_result * result = NULL ; /* Results of the search */
int ret ; /* Return code */
struct ldb_parse_tree * query = NULL ; /* The query to run */
struct ldb_request * request = NULL ; /* LDB request for the query op */
struct ldb_message * match = NULL ; /* the best matching DNS record */
TALLOC_CTX * frame = talloc_stackframe ( ) ;
parent = ldb_dn_get_parent ( frame , dn ) ;
if ( parent = = NULL ) {
DBG_ERR ( " Unable to extract parent from dn \n " ) ;
TALLOC_FREE ( frame ) ;
return LDB_ERR_OPERATIONS_ERROR ;
}
query = build_wildcard_query ( frame , dn ) ;
if ( query = = NULL ) {
TALLOC_FREE ( frame ) ;
return LDB_ERR_OPERATIONS_ERROR ;
}
result = talloc_zero ( mem_ctx , struct ldb_result ) ;
if ( result = = NULL ) {
TALLOC_FREE ( frame ) ;
DBG_ERR ( " Unable to allocate ldb_result \n " ) ;
return LDB_ERR_OPERATIONS_ERROR ;
}
ret = ldb_build_search_req_ex ( & request ,
samdb ,
frame ,
parent ,
2019-01-09 06:22:40 +03:00
LDB_SCOPE_SUBTREE ,
2017-08-03 06:12:02 +03:00
query ,
attrs ,
NULL ,
result ,
ldb_search_default_callback ,
NULL ) ;
if ( ret ! = LDB_SUCCESS ) {
TALLOC_FREE ( frame ) ;
DBG_ERR ( " ldb_build_search_req_ex returned %d \n " , ret ) ;
return ret ;
}
ret = ldb_request ( samdb , request ) ;
if ( ret ! = LDB_SUCCESS ) {
TALLOC_FREE ( frame ) ;
return ret ;
}
ret = ldb_wait ( request - > handle , LDB_WAIT_ALL ) ;
if ( ret ! = LDB_SUCCESS ) {
TALLOC_FREE ( frame ) ;
return ret ;
}
if ( result - > count = = 0 ) {
TALLOC_FREE ( frame ) ;
return LDB_ERR_NO_SUCH_OBJECT ;
}
match = get_best_match ( dn , result ) ;
if ( match = = NULL ) {
TALLOC_FREE ( frame ) ;
return LDB_ERR_OPERATIONS_ERROR ;
}
* msg = talloc_move ( mem_ctx , & match ) ;
TALLOC_FREE ( frame ) ;
return LDB_SUCCESS ;
}
/*
* Lookup a DNS record , will match DNS wild card records if an exact match
* is not found .
*/
WERROR dns_common_wildcard_lookup ( struct ldb_context * samdb ,
TALLOC_CTX * mem_ctx ,
struct ldb_dn * dn ,
struct dnsp_DnssrvRpcRecord * * records ,
uint16_t * num_records )
{
2019-04-05 01:13:15 +03:00
const struct timeval start = timeval_current ( ) ;
2017-08-03 06:12:02 +03:00
int ret ;
2019-04-05 01:13:15 +03:00
WERROR werr = WERR_OK ;
2017-08-03 06:12:02 +03:00
struct ldb_message * msg = NULL ;
struct ldb_message_element * el = NULL ;
const struct ldb_val * name = NULL ;
* records = NULL ;
* num_records = 0 ;
name = ldb_dn_get_rdn_val ( dn ) ;
if ( name = = NULL ) {
2019-05-08 05:37:06 +03:00
werr = DNS_ERR ( NAME_ERROR ) ;
2019-04-05 01:13:15 +03:00
goto exit ;
2017-08-03 06:12:02 +03:00
}
2017-12-15 01:40:28 +03:00
/* Don't look for a wildcard for @ */
if ( name - > length = = 1 & & name - > data [ 0 ] = = ' @ ' ) {
2019-04-05 01:13:15 +03:00
werr = dns_common_lookup ( samdb ,
2017-12-15 01:40:28 +03:00
mem_ctx ,
dn ,
records ,
num_records ,
NULL ) ;
2019-04-05 01:13:15 +03:00
goto exit ;
2017-12-15 01:40:28 +03:00
}
2017-08-03 06:12:02 +03:00
werr = dns_name_check (
mem_ctx ,
strlen ( ( const char * ) name - > data ) ,
( const char * ) name - > data ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
2019-04-05 01:13:15 +03:00
goto exit ;
2017-08-03 06:12:02 +03:00
}
2017-12-15 02:30:50 +03:00
/*
* Do a point search first , then fall back to a wildcard
* lookup if it does not exist
*/
werr = dns_common_lookup ( samdb ,
mem_ctx ,
dn ,
records ,
num_records ,
NULL ) ;
if ( ! W_ERROR_EQUAL ( werr , WERR_DNS_ERROR_NAME_DOES_NOT_EXIST ) ) {
2019-04-05 01:13:15 +03:00
goto exit ;
2017-12-15 02:30:50 +03:00
}
2017-08-03 06:12:02 +03:00
ret = dns_wildcard_lookup ( samdb , mem_ctx , dn , & msg ) ;
if ( ret = = LDB_ERR_OPERATIONS_ERROR ) {
2019-04-05 01:13:15 +03:00
werr = DNS_ERR ( SERVER_FAILURE ) ;
goto exit ;
2017-08-03 06:12:02 +03:00
}
if ( ret ! = LDB_SUCCESS ) {
2019-04-05 01:13:15 +03:00
werr = DNS_ERR ( NAME_ERROR ) ;
goto exit ;
2017-08-03 06:12:02 +03:00
}
el = ldb_msg_find_element ( msg , " dnsRecord " ) ;
if ( el = = NULL ) {
2019-04-05 01:13:15 +03:00
werr = WERR_DNS_ERROR_NAME_DOES_NOT_EXIST ;
goto exit ;
2017-08-03 06:12:02 +03:00
}
werr = dns_common_extract ( samdb , el , mem_ctx , records , num_records ) ;
TALLOC_FREE ( msg ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
2019-04-05 01:13:15 +03:00
goto exit ;
2017-08-03 06:12:02 +03:00
}
2019-04-05 01:13:15 +03:00
werr = WERR_OK ;
exit :
DNS_COMMON_LOG_OPERATION (
win_errstr ( werr ) ,
& start ,
NULL ,
dn = = NULL ? NULL : ldb_dn_get_linearized ( dn ) ,
NULL ) ;
return werr ;
2017-08-03 06:12:02 +03:00
}
2014-07-31 12:44:41 +04:00
static int rec_cmp ( const struct dnsp_DnssrvRpcRecord * r1 ,
const struct dnsp_DnssrvRpcRecord * r2 )
{
if ( r1 - > wType ! = r2 - > wType ) {
/*
2021-04-01 04:24:23 +03:00
* The records are sorted with higher types first ,
* which puts tombstones ( type 0 ) last .
2014-07-31 12:44:41 +04:00
*/
2024-04-04 04:22:24 +03:00
return NUMERIC_CMP ( r2 - > wType , r1 - > wType ) ;
2014-07-31 12:44:41 +04:00
}
/*
2021-04-01 04:24:23 +03:00
* Then we need to sort from the oldest to newest timestamp .
*
* Note that dwTimeStamp = = 0 ( never expiring ) records come first ,
* then the ones whose expiry is soonest .
2014-07-31 12:44:41 +04:00
*/
2024-04-04 04:22:24 +03:00
return NUMERIC_CMP ( r1 - > dwTimeStamp , r2 - > dwTimeStamp ) ;
2014-07-31 12:44:41 +04:00
}
2016-12-06 05:34:23 +03:00
/*
2017-08-03 06:12:51 +03:00
* Check for valid DNS names . These are names which :
* - are non - empty
* - do not start with a dot
* - do not have any empty labels
* - have no more than 127 labels
* - are no longer than 253 characters
* - none of the labels exceed 63 characters
2016-12-06 05:34:23 +03:00
*/
WERROR dns_name_check ( TALLOC_CTX * mem_ctx , size_t len , const char * name )
{
size_t i ;
2017-08-03 06:12:51 +03:00
unsigned int labels = 0 ;
unsigned int label_len = 0 ;
2016-12-06 05:34:23 +03:00
if ( len = = 0 ) {
return WERR_DS_INVALID_DN_SYNTAX ;
}
2017-08-03 06:12:51 +03:00
if ( len > 1 & & name [ 0 ] = = ' . ' ) {
return WERR_DS_INVALID_DN_SYNTAX ;
}
if ( ( len - 1 ) > DNS_MAX_DOMAIN_LENGTH ) {
return WERR_DS_INVALID_DN_SYNTAX ;
}
2016-12-06 05:34:23 +03:00
for ( i = 0 ; i < len - 1 ; i + + ) {
if ( name [ i ] = = ' . ' & & name [ i + 1 ] = = ' . ' ) {
return WERR_DS_INVALID_DN_SYNTAX ;
}
2017-08-03 06:12:51 +03:00
if ( name [ i ] = = ' . ' ) {
labels + + ;
if ( labels > DNS_MAX_LABELS ) {
return WERR_DS_INVALID_DN_SYNTAX ;
}
label_len = 0 ;
} else {
label_len + + ;
if ( label_len > DNS_MAX_LABEL_LENGTH ) {
return WERR_DS_INVALID_DN_SYNTAX ;
}
}
2016-12-06 05:34:23 +03:00
}
return WERR_OK ;
}
static WERROR check_name_list ( TALLOC_CTX * mem_ctx , uint16_t rec_count ,
struct dnsp_DnssrvRpcRecord * records )
{
WERROR werr ;
uint16_t i ;
size_t len ;
struct dnsp_DnssrvRpcRecord record ;
werr = WERR_OK ;
for ( i = 0 ; i < rec_count ; i + + ) {
record = records [ i ] ;
switch ( record . wType ) {
case DNS_TYPE_NS :
len = strlen ( record . data . ns ) ;
werr = dns_name_check ( mem_ctx , len , record . data . ns ) ;
break ;
case DNS_TYPE_CNAME :
len = strlen ( record . data . cname ) ;
werr = dns_name_check ( mem_ctx , len , record . data . cname ) ;
break ;
case DNS_TYPE_SOA :
len = strlen ( record . data . soa . mname ) ;
werr = dns_name_check ( mem_ctx , len , record . data . soa . mname ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
break ;
}
len = strlen ( record . data . soa . rname ) ;
werr = dns_name_check ( mem_ctx , len , record . data . soa . rname ) ;
break ;
case DNS_TYPE_PTR :
len = strlen ( record . data . ptr ) ;
werr = dns_name_check ( mem_ctx , len , record . data . ptr ) ;
break ;
case DNS_TYPE_MX :
len = strlen ( record . data . mx . nameTarget ) ;
werr = dns_name_check ( mem_ctx , len , record . data . mx . nameTarget ) ;
break ;
case DNS_TYPE_SRV :
len = strlen ( record . data . srv . nameTarget ) ;
werr = dns_name_check ( mem_ctx , len ,
record . data . srv . nameTarget ) ;
break ;
/*
* In the default case , the record doesn ' t have a DN , so it
* must be ok .
*/
default :
break ;
}
if ( ! W_ERROR_IS_OK ( werr ) ) {
return werr ;
}
}
return WERR_OK ;
}
2018-06-07 07:51:37 +03:00
bool dns_name_is_static ( struct dnsp_DnssrvRpcRecord * records ,
uint16_t rec_count )
{
int i = 0 ;
for ( i = 0 ; i < rec_count ; i + + ) {
if ( records [ i ] . wType = = DNS_TYPE_TOMBSTONE ) {
continue ;
}
if ( records [ i ] . wType = = DNS_TYPE_SOA | |
records [ i ] . dwTimeStamp = = 0 ) {
return true ;
}
}
return false ;
}
2016-12-06 05:34:23 +03:00
2018-11-07 05:08:04 +03:00
/*
* Helper function to copy a dnsp_ip4_array struct to an IP4_ARRAY struct .
* The new structure and it ' s data are allocated on the supplied talloc context
*/
static struct IP4_ARRAY * copy_ip4_array ( TALLOC_CTX * ctx ,
const char * name ,
struct dnsp_ip4_array array )
{
struct IP4_ARRAY * ip4_array = NULL ;
unsigned int i ;
ip4_array = talloc_zero ( ctx , struct IP4_ARRAY ) ;
if ( ip4_array = = NULL ) {
DBG_ERR ( " Out of memory copying property [%s] \n " , name ) ;
return NULL ;
}
ip4_array - > AddrCount = array . addrCount ;
if ( ip4_array - > AddrCount = = 0 ) {
return ip4_array ;
}
ip4_array - > AddrArray =
talloc_array ( ip4_array , uint32_t , ip4_array - > AddrCount ) ;
if ( ip4_array - > AddrArray = = NULL ) {
TALLOC_FREE ( ip4_array ) ;
DBG_ERR ( " Out of memory copying property [%s] values \n " , name ) ;
return NULL ;
}
for ( i = 0 ; i < ip4_array - > AddrCount ; i + + ) {
2019-04-30 11:07:51 +03:00
ip4_array - > AddrArray [ i ] = array . addrArray [ i ] ;
2018-11-07 05:08:04 +03:00
}
return ip4_array ;
}
bool dns_zoneinfo_load_zone_property ( struct dnsserver_zoneinfo * zoneinfo ,
struct dnsp_DnsProperty * prop )
{
switch ( prop - > id ) {
case DSPROPERTY_ZONE_TYPE :
zoneinfo - > dwZoneType = prop - > data . zone_type ;
break ;
case DSPROPERTY_ZONE_ALLOW_UPDATE :
zoneinfo - > fAllowUpdate = prop - > data . allow_update_flag ;
break ;
case DSPROPERTY_ZONE_NOREFRESH_INTERVAL :
zoneinfo - > dwNoRefreshInterval = prop - > data . norefresh_hours ;
break ;
case DSPROPERTY_ZONE_REFRESH_INTERVAL :
zoneinfo - > dwRefreshInterval = prop - > data . refresh_hours ;
break ;
case DSPROPERTY_ZONE_AGING_STATE :
zoneinfo - > fAging = prop - > data . aging_enabled ;
break ;
case DSPROPERTY_ZONE_SCAVENGING_SERVERS :
zoneinfo - > aipScavengeServers = copy_ip4_array (
zoneinfo , " ZONE_SCAVENGING_SERVERS " , prop - > data . servers ) ;
if ( zoneinfo - > aipScavengeServers = = NULL ) {
return false ;
}
break ;
case DSPROPERTY_ZONE_AGING_ENABLED_TIME :
zoneinfo - > dwAvailForScavengeTime =
prop - > data . next_scavenging_cycle_hours ;
break ;
case DSPROPERTY_ZONE_MASTER_SERVERS :
zoneinfo - > aipLocalMasters = copy_ip4_array (
zoneinfo , " ZONE_MASTER_SERVERS " , prop - > data . master_servers ) ;
if ( zoneinfo - > aipLocalMasters = = NULL ) {
return false ;
}
break ;
case DSPROPERTY_ZONE_EMPTY :
case DSPROPERTY_ZONE_SECURE_TIME :
case DSPROPERTY_ZONE_DELETED_FROM_HOSTNAME :
case DSPROPERTY_ZONE_AUTO_NS_SERVERS :
case DSPROPERTY_ZONE_DCPROMO_CONVERT :
case DSPROPERTY_ZONE_SCAVENGING_SERVERS_DA :
case DSPROPERTY_ZONE_MASTER_SERVERS_DA :
case DSPROPERTY_ZONE_NS_SERVERS_DA :
case DSPROPERTY_ZONE_NODE_DBFLAGS :
break ;
}
return true ;
}
2018-07-02 04:43:33 +03:00
WERROR dns_get_zone_properties ( struct ldb_context * samdb ,
TALLOC_CTX * mem_ctx ,
struct ldb_dn * zone_dn ,
struct dnsserver_zoneinfo * zoneinfo )
{
int ret , i ;
struct dnsp_DnsProperty * prop = NULL ;
struct ldb_message_element * element = NULL ;
const char * const attrs [ ] = { " dNSProperty " , NULL } ;
struct ldb_result * res = NULL ;
enum ndr_err_code err ;
ret = ldb_search ( samdb ,
mem_ctx ,
& res ,
zone_dn ,
LDB_SCOPE_BASE ,
attrs ,
" (objectClass=dnsZone) " ) ;
if ( ret ! = LDB_SUCCESS ) {
DBG_ERR ( " dnsserver: Failed to find DNS zone: %s \n " ,
ldb_dn_get_linearized ( zone_dn ) ) ;
return DNS_ERR ( SERVER_FAILURE ) ;
}
element = ldb_msg_find_element ( res - > msgs [ 0 ] , " dNSProperty " ) ;
if ( element = = NULL ) {
return DNS_ERR ( NOTZONE ) ;
}
for ( i = 0 ; i < element - > num_values ; i + + ) {
2018-11-07 05:08:04 +03:00
bool valid_property ;
2018-07-02 04:43:33 +03:00
prop = talloc_zero ( mem_ctx , struct dnsp_DnsProperty ) ;
if ( prop = = NULL ) {
return WERR_NOT_ENOUGH_MEMORY ;
}
err = ndr_pull_struct_blob (
& ( element - > values [ i ] ) ,
mem_ctx ,
prop ,
( ndr_pull_flags_fn_t ) ndr_pull_dnsp_DnsProperty ) ;
if ( ! NDR_ERR_CODE_IS_SUCCESS ( err ) ) {
s4/rpc_server/dnsserver: Allow parsing of dnsProperty to fail gracefully
On (eg) the
DC=_msdcs.X.Y,CN=MicrosoftDNS,DC=ForestDnsZones,DC=X,DC=Y
record, in domains that have had a Microsoft Windows DC an attribute:
dNSProperty:: AAAAAAAAAAAAAAAAAQAAAJIAAAAAAAAA
000000 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 >................<
000010 92 00 00 00 00 00 00 00 >........<
000018
We, until samba 4.12, would parse this as:
pull returned Success
dnsp_DnsProperty: struct dnsp_DnsProperty
wDataLength : 0x00000000 (0)
namelength : 0x00000000 (0)
flag : 0x00000000 (0)
version : 0x00000001 (1)
id : DSPROPERTY_ZONE_NS_SERVERS_DA (146)
data : union dnsPropertyData(case 0)
name : 0x00000000 (0)
dump OK
However, the wDataLength is 0. There is not anything in
[MS-DNSP] 2.3.2.1 dnsProperty to describe any special behaviour
for when the id suggests that there is a value, but wDataLength is 0.
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dnsp/445c7843-e4a1-4222-8c0f-630c230a4c80
We now fail to parse it, because we expect an entry with id DSPROPERTY_ZONE_NS_SERVERS_DA
to therefore have a valid DNS_ADDR_ARRAY (section 2.2.3.2.3).
As context we changed it in our commit fee5c6a4247aeac71318186bbff7708d25de5912
because of bug https://bugzilla.samba.org/show_bug.cgi?id=14206
which was due to the artificial environment of the fuzzer.
Microsoft advises that Windows also fails to parse this, but
instead of failing the operation, the value is ignored.
Reported by Alex MacCuish. Many thanks for your assistance in
tracking down the issue.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14310
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri May 15 07:29:17 UTC 2020 on sn-devel-184
2020-05-13 03:01:05 +03:00
/*
* If we can ' t pull it , then there is no valid
* data to load into the zone , so ignore this
2023-08-02 11:37:18 +03:00
* as Microsoft does . Windows can load an
s4/rpc_server/dnsserver: Allow parsing of dnsProperty to fail gracefully
On (eg) the
DC=_msdcs.X.Y,CN=MicrosoftDNS,DC=ForestDnsZones,DC=X,DC=Y
record, in domains that have had a Microsoft Windows DC an attribute:
dNSProperty:: AAAAAAAAAAAAAAAAAQAAAJIAAAAAAAAA
000000 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 >................<
000010 92 00 00 00 00 00 00 00 >........<
000018
We, until samba 4.12, would parse this as:
pull returned Success
dnsp_DnsProperty: struct dnsp_DnsProperty
wDataLength : 0x00000000 (0)
namelength : 0x00000000 (0)
flag : 0x00000000 (0)
version : 0x00000001 (1)
id : DSPROPERTY_ZONE_NS_SERVERS_DA (146)
data : union dnsPropertyData(case 0)
name : 0x00000000 (0)
dump OK
However, the wDataLength is 0. There is not anything in
[MS-DNSP] 2.3.2.1 dnsProperty to describe any special behaviour
for when the id suggests that there is a value, but wDataLength is 0.
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dnsp/445c7843-e4a1-4222-8c0f-630c230a4c80
We now fail to parse it, because we expect an entry with id DSPROPERTY_ZONE_NS_SERVERS_DA
to therefore have a valid DNS_ADDR_ARRAY (section 2.2.3.2.3).
As context we changed it in our commit fee5c6a4247aeac71318186bbff7708d25de5912
because of bug https://bugzilla.samba.org/show_bug.cgi?id=14206
which was due to the artificial environment of the fuzzer.
Microsoft advises that Windows also fails to parse this, but
instead of failing the operation, the value is ignored.
Reported by Alex MacCuish. Many thanks for your assistance in
tracking down the issue.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14310
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri May 15 07:29:17 UTC 2020 on sn-devel-184
2020-05-13 03:01:05 +03:00
* invalid property with a zero length into
* the dnsProperty attribute .
*/
continue ;
2018-07-02 04:43:33 +03:00
}
2018-11-07 05:08:04 +03:00
valid_property =
dns_zoneinfo_load_zone_property ( zoneinfo , prop ) ;
if ( ! valid_property ) {
return DNS_ERR ( SERVER_FAILURE ) ;
2018-07-02 04:43:33 +03:00
}
}
return WERR_OK ;
}
2014-07-30 20:27:56 +04:00
WERROR dns_common_replace ( struct ldb_context * samdb ,
TALLOC_CTX * mem_ctx ,
struct ldb_dn * dn ,
bool needs_add ,
uint32_t serial ,
struct dnsp_DnssrvRpcRecord * records ,
uint16_t rec_count )
{
2019-04-05 01:13:15 +03:00
const struct timeval start = timeval_current ( ) ;
2014-07-30 20:27:56 +04:00
struct ldb_message_element * el ;
uint16_t i ;
int ret ;
2016-12-06 05:34:23 +03:00
WERROR werr ;
2014-07-30 20:27:56 +04:00
struct ldb_message * msg = NULL ;
2014-07-31 12:44:41 +04:00
bool was_tombstoned = false ;
bool become_tombstoned = false ;
2018-07-02 04:43:33 +03:00
struct ldb_dn * zone_dn = NULL ;
struct dnsserver_zoneinfo * zoneinfo = NULL ;
2021-03-11 05:58:37 +03:00
uint32_t t ;
2014-07-30 20:27:56 +04:00
msg = ldb_msg_new ( mem_ctx ) ;
W_ERROR_HAVE_NO_MEMORY ( msg ) ;
msg - > dn = dn ;
2018-07-02 04:43:33 +03:00
zone_dn = ldb_dn_copy ( mem_ctx , dn ) ;
if ( zone_dn = = NULL ) {
2019-04-05 01:13:15 +03:00
werr = WERR_NOT_ENOUGH_MEMORY ;
goto exit ;
2018-07-02 04:43:33 +03:00
}
if ( ! ldb_dn_remove_child_components ( zone_dn , 1 ) ) {
2019-04-05 01:13:15 +03:00
werr = DNS_ERR ( SERVER_FAILURE ) ;
goto exit ;
2018-07-02 04:43:33 +03:00
}
zoneinfo = talloc ( mem_ctx , struct dnsserver_zoneinfo ) ;
if ( zoneinfo = = NULL ) {
2019-04-05 01:13:15 +03:00
werr = WERR_NOT_ENOUGH_MEMORY ;
goto exit ;
2018-07-02 04:43:33 +03:00
}
werr = dns_get_zone_properties ( samdb , mem_ctx , zone_dn , zoneinfo ) ;
if ( W_ERROR_EQUAL ( DNS_ERR ( NOTZONE ) , werr ) ) {
/*
* We only got zoneinfo for aging so if we didn ' t find any
* properties then just disable aging and keep going .
*/
zoneinfo - > fAging = 0 ;
} else if ( ! W_ERROR_IS_OK ( werr ) ) {
2019-04-05 01:13:15 +03:00
goto exit ;
2018-07-02 04:43:33 +03:00
}
2016-12-06 05:34:23 +03:00
werr = check_name_list ( mem_ctx , rec_count , records ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
2019-04-05 01:13:15 +03:00
goto exit ;
2016-12-06 05:34:23 +03:00
}
2014-07-30 20:27:56 +04:00
ret = ldb_msg_add_empty ( msg , " dnsRecord " , LDB_FLAG_MOD_REPLACE , & el ) ;
if ( ret ! = LDB_SUCCESS ) {
2019-04-05 01:13:15 +03:00
werr = DNS_ERR ( SERVER_FAILURE ) ;
goto exit ;
2014-07-30 20:27:56 +04:00
}
2014-07-31 12:44:41 +04:00
/*
* we have at least one value ,
* which might be used for the tombstone marker
*/
el - > values = talloc_zero_array ( el , struct ldb_val , MAX ( 1 , rec_count ) ) ;
2021-03-24 07:38:15 +03:00
if ( el - > values = = NULL ) {
werr = WERR_NOT_ENOUGH_MEMORY ;
goto exit ;
}
2014-07-31 12:44:41 +04:00
2021-03-24 07:38:15 +03:00
if ( rec_count > 1 ) {
2014-07-31 12:44:41 +04:00
/*
* We store a sorted list with the high wType values first
* that ' s what windows does . It also simplifies the
* filtering of DNS_TYPE_TOMBSTONE records
*/
TYPESAFE_QSORT ( records , rec_count , rec_cmp ) ;
2014-07-30 20:27:56 +04:00
}
for ( i = 0 ; i < rec_count ; i + + ) {
struct ldb_val * v = & el - > values [ el - > num_values ] ;
enum ndr_err_code ndr_err ;
2014-07-31 12:44:41 +04:00
if ( records [ i ] . wType = = DNS_TYPE_TOMBSTONE ) {
2021-06-18 06:31:42 +03:00
/*
* There are two things that could be going on here .
*
* 1. We use a tombstone with EntombedTime = = 0 for
* passing deletion messages through the stack , and
* this is the place we filter them out to perform
* that deletion .
*
* 2. This node is tombstoned , with no records except
* for a single tombstone , and it is just waiting to
* disappear . In this case , unless the caller has
* added a record , rec_count should be 1 , and
* el - > num_values will end up at 0 , and we will make
* no changes . But if the caller has added a record ,
* we need to un - tombstone the node .
*
* It is not possible to add an explicit tombstone
* record .
*/
2021-03-24 02:49:22 +03:00
if ( records [ i ] . data . EntombedTime ! = 0 ) {
2024-04-11 02:52:14 +03:00
if ( rec_count ! = 1 & & DEBUGLVL ( DBGLVL_NOTICE ) ) {
DBG_NOTICE ( " tombstone record [%u] has "
" %u neighbour records. \n " ,
i , rec_count - 1 ) ;
NDR_PRINT_DEBUG ( dnsp_DnssrvRpcRecord , & records [ i ] ) ;
2023-05-13 10:29:48 +03:00
}
2014-07-31 12:44:41 +04:00
was_tombstoned = true ;
}
2014-07-30 20:27:56 +04:00
continue ;
}
2018-07-02 04:43:33 +03:00
if ( zoneinfo - > fAging = = 1 & & records [ i ] . dwTimeStamp ! = 0 ) {
2021-03-11 05:58:37 +03:00
t = unix_to_dns_timestamp ( time ( NULL ) ) ;
2018-07-02 04:43:33 +03:00
if ( t - records [ i ] . dwTimeStamp >
zoneinfo - > dwNoRefreshInterval ) {
records [ i ] . dwTimeStamp = t ;
}
}
2014-07-30 20:27:56 +04:00
records [ i ] . dwSerial = serial ;
ndr_err = ndr_push_struct_blob ( v , el - > values , & records [ i ] ,
( ndr_push_flags_fn_t ) ndr_push_dnsp_DnssrvRpcRecord ) ;
if ( ! NDR_ERR_CODE_IS_SUCCESS ( ndr_err ) ) {
DEBUG ( 0 , ( " Failed to push dnsp_DnssrvRpcRecord \n " ) ) ;
2019-04-05 01:13:15 +03:00
werr = DNS_ERR ( SERVER_FAILURE ) ;
goto exit ;
2014-07-30 20:27:56 +04:00
}
el - > num_values + + ;
}
if ( needs_add ) {
2021-04-11 02:58:25 +03:00
/*
* This is a new dnsNode , which simplifies everything as we
* know there is nothing to delete or change . We add the
* records and get out .
*/
2014-07-30 20:27:56 +04:00
if ( el - > num_values = = 0 ) {
2019-04-05 01:13:15 +03:00
werr = WERR_OK ;
goto exit ;
2014-07-30 20:27:56 +04:00
}
ret = ldb_msg_add_string ( msg , " objectClass " , " dnsNode " ) ;
if ( ret ! = LDB_SUCCESS ) {
2019-04-05 01:13:15 +03:00
werr = DNS_ERR ( SERVER_FAILURE ) ;
goto exit ;
2014-07-30 20:27:56 +04:00
}
ret = ldb_add ( samdb , msg ) ;
if ( ret ! = LDB_SUCCESS ) {
2019-04-05 01:13:15 +03:00
werr = DNS_ERR ( SERVER_FAILURE ) ;
goto exit ;
2014-07-30 20:27:56 +04:00
}
2021-04-09 13:50:24 +03:00
werr = WERR_OK ;
2019-04-05 01:13:15 +03:00
goto exit ;
2014-07-30 20:27:56 +04:00
}
if ( el - > num_values = = 0 ) {
2021-06-18 06:31:42 +03:00
/*
* We get here if there are no records or all the records were
* tombstones .
*/
2014-07-31 12:44:41 +04:00
struct dnsp_DnssrvRpcRecord tbs ;
struct ldb_val * v = & el - > values [ el - > num_values ] ;
enum ndr_err_code ndr_err ;
struct timeval tv ;
if ( was_tombstoned ) {
/*
* This is already a tombstoned object .
* Just leave it instead of updating the time stamp .
*/
2019-04-05 01:13:15 +03:00
werr = WERR_OK ;
goto exit ;
2014-07-31 12:44:41 +04:00
}
tv = timeval_current ( ) ;
tbs = ( struct dnsp_DnssrvRpcRecord ) {
. wType = DNS_TYPE_TOMBSTONE ,
. dwSerial = serial ,
2021-03-24 02:49:22 +03:00
. data . EntombedTime = timeval_to_nttime ( & tv ) ,
2014-07-31 12:44:41 +04:00
} ;
ndr_err = ndr_push_struct_blob ( v , el - > values , & tbs ,
( ndr_push_flags_fn_t ) ndr_push_dnsp_DnssrvRpcRecord ) ;
if ( ! NDR_ERR_CODE_IS_SUCCESS ( ndr_err ) ) {
DEBUG ( 0 , ( " Failed to push dnsp_DnssrvRpcRecord \n " ) ) ;
2019-04-05 01:13:15 +03:00
werr = DNS_ERR ( SERVER_FAILURE ) ;
goto exit ;
2014-07-31 12:44:41 +04:00
}
el - > num_values + + ;
become_tombstoned = true ;
}
if ( was_tombstoned | | become_tombstoned ) {
2022-02-21 06:27:37 +03:00
ret = ldb_msg_append_fmt ( msg , LDB_FLAG_MOD_REPLACE ,
" dNSTombstoned " , " %s " ,
become_tombstoned ? " TRUE " : " FALSE " ) ;
2014-07-31 12:44:41 +04:00
if ( ret ! = LDB_SUCCESS ) {
2019-04-05 01:13:15 +03:00
werr = DNS_ERR ( SERVER_FAILURE ) ;
goto exit ;
2014-07-31 12:44:41 +04:00
}
2014-07-30 20:27:56 +04:00
}
ret = ldb_modify ( samdb , msg ) ;
if ( ret ! = LDB_SUCCESS ) {
NTSTATUS nt = dsdb_ldb_err_to_ntstatus ( ret ) ;
2019-04-05 01:13:15 +03:00
werr = ntstatus_to_werror ( nt ) ;
goto exit ;
2014-07-30 20:27:56 +04:00
}
2019-04-05 01:13:15 +03:00
werr = WERR_OK ;
exit :
2021-04-15 07:07:58 +03:00
talloc_free ( msg ) ;
2019-04-05 01:13:15 +03:00
DNS_COMMON_LOG_OPERATION (
win_errstr ( werr ) ,
& start ,
NULL ,
dn = = NULL ? NULL : ldb_dn_get_linearized ( dn ) ,
NULL ) ;
return werr ;
2014-07-30 20:27:56 +04:00
}
2015-09-22 03:10:00 +03:00
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 ;
}
WERROR dns_common_name2dn ( struct ldb_context * samdb ,
struct dns_server_zone * zones ,
TALLOC_CTX * mem_ctx ,
const char * name ,
struct ldb_dn * * _dn )
{
struct ldb_dn * base ;
struct ldb_dn * dn ;
const struct dns_server_zone * z ;
size_t host_part_len = 0 ;
2018-07-02 07:49:37 +03:00
struct ldb_val host_part ;
2016-12-07 05:33:06 +03:00
WERROR werr ;
2018-07-02 07:49:37 +03:00
bool ok ;
const char * casefold = NULL ;
2015-09-22 03:10:00 +03:00
if ( name = = NULL ) {
return DNS_ERR ( FORMAT_ERROR ) ;
}
if ( strcmp ( name , " " ) = = 0 ) {
base = ldb_get_default_basedn ( samdb ) ;
dn = ldb_dn_copy ( mem_ctx , base ) ;
2018-07-02 07:49:37 +03:00
ok = ldb_dn_add_child_fmt ( dn ,
" DC=@,DC=RootDNSServers,CN=MicrosoftDNS,CN=System " ) ;
if ( ok = = false ) {
TALLOC_FREE ( dn ) ;
return WERR_NOT_ENOUGH_MEMORY ;
}
2015-09-22 03:10:00 +03:00
* _dn = dn ;
return WERR_OK ;
}
2016-12-07 05:33:06 +03:00
/* Check non-empty names */
werr = dns_name_check ( mem_ctx , strlen ( name ) , name ) ;
if ( ! W_ERROR_IS_OK ( werr ) ) {
return werr ;
}
2015-09-22 03:10:00 +03:00
for ( z = 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 ) ;
2018-07-02 07:49:37 +03:00
ok = ldb_dn_add_child_fmt ( dn , " DC=@ " ) ;
if ( ! ok ) {
TALLOC_FREE ( dn ) ;
return WERR_NOT_ENOUGH_MEMORY ;
}
2015-09-22 03:10:00 +03:00
* _dn = dn ;
return WERR_OK ;
}
dn = ldb_dn_copy ( mem_ctx , z - > dn ) ;
2018-07-02 07:49:37 +03:00
if ( dn = = NULL ) {
TALLOC_FREE ( dn ) ;
return WERR_NOT_ENOUGH_MEMORY ;
}
host_part = data_blob_const ( name , host_part_len ) ;
2018-08-15 01:44:03 +03:00
ok = ldb_dn_add_child_val ( dn , " DC " , host_part ) ;
if ( ok = = false ) {
2018-07-02 07:49:37 +03:00
TALLOC_FREE ( dn ) ;
return WERR_NOT_ENOUGH_MEMORY ;
}
/*
* Check the new DN here for validity , so as to catch errors
* early
*/
ok = ldb_dn_validate ( dn ) ;
if ( ok = = false ) {
TALLOC_FREE ( dn ) ;
return DNS_ERR ( NAME_ERROR ) ;
}
/*
* The value from this check is saved in the DN , and doing
* this here allows an easy return here .
*/
casefold = ldb_dn_get_casefold ( dn ) ;
if ( casefold = = NULL ) {
TALLOC_FREE ( dn ) ;
return DNS_ERR ( NAME_ERROR ) ;
}
2015-09-22 03:10:00 +03:00
* _dn = dn ;
return WERR_OK ;
}
2021-04-12 22:00:41 +03:00
/*
see if two dns records match
*/
2021-05-29 12:25:29 +03:00
bool dns_record_match ( struct dnsp_DnssrvRpcRecord * rec1 ,
struct dnsp_DnssrvRpcRecord * rec2 )
2021-04-12 22:00:41 +03:00
{
int i ;
struct in6_addr rec1_in_addr6 ;
struct in6_addr rec2_in_addr6 ;
if ( rec1 - > wType ! = rec2 - > wType ) {
return false ;
}
/* see if the data matches */
switch ( rec1 - > wType ) {
case DNS_TYPE_A :
return strcmp ( rec1 - > data . ipv4 , rec2 - > data . ipv4 ) = = 0 ;
case DNS_TYPE_AAAA : {
int ret ;
ret = inet_pton ( AF_INET6 , rec1 - > data . ipv6 , & rec1_in_addr6 ) ;
if ( ret ! = 1 ) {
return false ;
}
ret = inet_pton ( AF_INET6 , rec2 - > data . ipv6 , & rec2_in_addr6 ) ;
if ( ret ! = 1 ) {
return false ;
}
return memcmp ( & rec1_in_addr6 , & rec2_in_addr6 , sizeof ( rec1_in_addr6 ) ) = = 0 ;
}
case DNS_TYPE_CNAME :
s4:dnsserver: Rename dns_name_equal() to samba_dns_name_equal()
This function already exists in bind9 but takes different arguments, so when
the DLZ is loaded and this function is called bind crashes:
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: client @0x7f26caa90f68 192.168.101.118#58223/key DESKTOP-8BUKMBK\$\@AFOREST.AD: updating zone '101.168.192.in-addr.arpa/NONE': deleting rrset at '118.101.168.192.in-addr.ar
named[1523]: name.c:664: REQUIRE(((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))) failed, back trace
Backtrace:
#0 0x00007f2716c957ec in __pthread_kill_implementation () from /lib64/libc.so.6
#1 0x00007f2716c42816 in raise () from /lib64/libc.so.6
#2 0x00007f2716c2b81c in abort () from /lib64/libc.so.6
#3 0x000055d4de847995 in assertion_failed (file=<optimized out>, line=<optimized out>,
type=<optimized out>, cond=<optimized out>) at /usr/src/debug/bind-9.18.10/bin/named/main.c:237
#4 0x00007f27176388fc in isc_assertion_failed (file=file@entry=0x7f27173b0df6 "name.c",
line=line@entry=664, type=type@entry=isc_assertiontype_require,
cond=cond@entry=0x7f27173b0268 "((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))")
at /usr/src/debug/bind-9.18.10/lib/isc/assertions.c:48
#5 0x00007f27172946f9 in dns_name_equal (name1=<optimized out>, name2=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/name.c:664
**** Here bind's dns_name_equal() is called instead of samba's dns_name_equal() ****
#6 0x00007f27077ad6f2 in dns_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dnsserver_common.c:1346
#7 0x00007f271404732c in b9_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dlz_bind9.c:1830
#8 0x00007f2714047daa in dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=0x7f26c9c10000 "118.101.168.192.in-addr.arpa.\t1200\tIN\tPTR\tDESKTOP-8BUKMBK.aforest.ad.",
dbdata=0x7f271003d300, version=0x7f26f8044b20) at ../../source4/dns_server/dlz_bind9.c:2077
#9 0x000055d4de84afb4 in dlopen_dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=<optimized out>, driverarg=<optimized out>, dbdata=0x7f270430f680, version=<optimized out>)
at /usr/src/debug/bind-9.18.10/bin/named/dlz_dlopen_driver.c:483
#10 0x00007f271738e734 in modrdataset.constprop.0 (db=0x7f2704291740, node=0x7f26c9c006e0,
version=0x7f26f8044b20, rdataset=0x7f2706ff8830,
mod_function=0x55d4de84af80 <dlopen_dlz_subrdataset>, options=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/sdlz.c:1107
#11 0x00007f2717251855 in diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, warn=warn@entry=true) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:370
#12 0x00007f2717251c8a in dns_diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:465
#13 0x00007f2717d105aa in do_one_tuple (tuple=tuple@entry=0x7f2706ff8e50, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, diff=diff@entry=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:454
#14 0x00007f2717d10fff in update_one_rr (rdata=0x7f2706ff8ee8, ttl=<optimized out>,
name=<optimized out>, op=DNS_DIFFOP_DEL, diff=0x7f2706ff9400, ver=0x7f26f8044b20, db=0x7f2704291740)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:505
#15 delete_if_action (data=<optimized out>, rr=0x7f2706ff8ee0)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1427
#16 0x00007f2717d10ccd in foreach_rr (db=0x7f2704291740, ver=<optimized out>, name=0x7f26caa61d00,
type=<optimized out>, covers=<optimized out>,
rr_action=rr_action@entry=0x7f2717d10f60 <delete_if_action>, rr_action_data=0x7f2706ff9280)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:736
#17 0x00007f2717d10e76 in delete_if (predicate=predicate@entry=0x7f2717d0fb10 <true_p>,
db=<optimized out>, ver=<optimized out>, name=<optimized out>, type=<optimized out>,
covers=<optimized out>, update_rr=0x7f2706ff94b0, diff=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1454
#18 0x00007f2717d1bccd in update_action (task=<optimized out>, event=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:3299
#19 0x00007f271765eb4c in task_run (task=0x7f27155ccf00)
at /usr/src/debug/bind-9.18.10/lib/isc/task.c:823
#20 isc_task_run (task=0x7f27155ccf00) at /usr/src/debug/bind-9.18.10/lib/isc/task.c:904
#21 0x00007f271762cb12 in isc__nm_async_task (worker=0x7f2716236560, ev0=0x7f26caa07000)
at netmgr/netmgr.c:840
#22 process_netievent (worker=worker@entry=0x7f2716236560, ievent=0x7f26caa07000) at netmgr/netmgr.c:918
#23 0x00007f271762d197 in process_queue (worker=worker@entry=0x7f2716236560,
type=type@entry=NETIEVENT_TASK) at netmgr/netmgr.c:1011
#24 0x00007f271762d3b3 in process_all_queues (worker=0x7f2716236560) at netmgr/netmgr.c:765
#25 async_cb (handle=0x7f27162368c0) at netmgr/netmgr.c:794
#26 0x00007f2717c4cb0d in uv__async_io (loop=0x7f2716236570, w=<optimized out>, events=<optimized out>)
at src/unix/async.c:163
#27 0x00007f2717c6825d in uv__io_poll (loop=0x7f2716236570, timeout=<optimized out>)
at src/unix/epoll.c:374
#28 0x00007f2717c5247a in uv__io_poll (timeout=<optimized out>, loop=0x7f2716236570)
at src/unix/udp.c:122
#29 uv_run (loop=loop@entry=0x7f2716236570, mode=mode@entry=UV_RUN_DEFAULT) at src/unix/core.c:406
#30 0x00007f271762d834 in nm_thread (worker0=0x7f2716236560) at netmgr/netmgr.c:696
#31 0x00007f27176627f5 in isc__trampoline_run (arg=0x55d4dfe3ad70)
at /usr/src/debug/bind-9.18.10/lib/isc/trampoline.c:189
#32 0x00007f2716c9398d in start_thread () from /lib64/libc.so.6
#33 0x00007f2716d19344 in clone () from /lib64/libc.so.6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14030
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Samuel Cabrero <scabrero@samba.org>
Autobuild-Date(master): Thu Jan 19 10:20:27 UTC 2023 on atb-devel-224
2023-01-18 19:25:29 +03:00
return samba_dns_name_equal ( rec1 - > data . cname ,
rec2 - > data . cname ) ;
2021-04-12 22:00:41 +03:00
case DNS_TYPE_TXT :
if ( rec1 - > data . txt . count ! = rec2 - > data . txt . count ) {
return false ;
}
for ( i = 0 ; i < rec1 - > data . txt . count ; i + + ) {
if ( strcmp ( rec1 - > data . txt . str [ i ] , rec2 - > data . txt . str [ i ] ) ! = 0 ) {
return false ;
}
}
return true ;
case DNS_TYPE_PTR :
s4:dnsserver: Rename dns_name_equal() to samba_dns_name_equal()
This function already exists in bind9 but takes different arguments, so when
the DLZ is loaded and this function is called bind crashes:
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: client @0x7f26caa90f68 192.168.101.118#58223/key DESKTOP-8BUKMBK\$\@AFOREST.AD: updating zone '101.168.192.in-addr.arpa/NONE': deleting rrset at '118.101.168.192.in-addr.ar
named[1523]: name.c:664: REQUIRE(((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))) failed, back trace
Backtrace:
#0 0x00007f2716c957ec in __pthread_kill_implementation () from /lib64/libc.so.6
#1 0x00007f2716c42816 in raise () from /lib64/libc.so.6
#2 0x00007f2716c2b81c in abort () from /lib64/libc.so.6
#3 0x000055d4de847995 in assertion_failed (file=<optimized out>, line=<optimized out>,
type=<optimized out>, cond=<optimized out>) at /usr/src/debug/bind-9.18.10/bin/named/main.c:237
#4 0x00007f27176388fc in isc_assertion_failed (file=file@entry=0x7f27173b0df6 "name.c",
line=line@entry=664, type=type@entry=isc_assertiontype_require,
cond=cond@entry=0x7f27173b0268 "((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))")
at /usr/src/debug/bind-9.18.10/lib/isc/assertions.c:48
#5 0x00007f27172946f9 in dns_name_equal (name1=<optimized out>, name2=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/name.c:664
**** Here bind's dns_name_equal() is called instead of samba's dns_name_equal() ****
#6 0x00007f27077ad6f2 in dns_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dnsserver_common.c:1346
#7 0x00007f271404732c in b9_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dlz_bind9.c:1830
#8 0x00007f2714047daa in dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=0x7f26c9c10000 "118.101.168.192.in-addr.arpa.\t1200\tIN\tPTR\tDESKTOP-8BUKMBK.aforest.ad.",
dbdata=0x7f271003d300, version=0x7f26f8044b20) at ../../source4/dns_server/dlz_bind9.c:2077
#9 0x000055d4de84afb4 in dlopen_dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=<optimized out>, driverarg=<optimized out>, dbdata=0x7f270430f680, version=<optimized out>)
at /usr/src/debug/bind-9.18.10/bin/named/dlz_dlopen_driver.c:483
#10 0x00007f271738e734 in modrdataset.constprop.0 (db=0x7f2704291740, node=0x7f26c9c006e0,
version=0x7f26f8044b20, rdataset=0x7f2706ff8830,
mod_function=0x55d4de84af80 <dlopen_dlz_subrdataset>, options=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/sdlz.c:1107
#11 0x00007f2717251855 in diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, warn=warn@entry=true) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:370
#12 0x00007f2717251c8a in dns_diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:465
#13 0x00007f2717d105aa in do_one_tuple (tuple=tuple@entry=0x7f2706ff8e50, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, diff=diff@entry=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:454
#14 0x00007f2717d10fff in update_one_rr (rdata=0x7f2706ff8ee8, ttl=<optimized out>,
name=<optimized out>, op=DNS_DIFFOP_DEL, diff=0x7f2706ff9400, ver=0x7f26f8044b20, db=0x7f2704291740)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:505
#15 delete_if_action (data=<optimized out>, rr=0x7f2706ff8ee0)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1427
#16 0x00007f2717d10ccd in foreach_rr (db=0x7f2704291740, ver=<optimized out>, name=0x7f26caa61d00,
type=<optimized out>, covers=<optimized out>,
rr_action=rr_action@entry=0x7f2717d10f60 <delete_if_action>, rr_action_data=0x7f2706ff9280)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:736
#17 0x00007f2717d10e76 in delete_if (predicate=predicate@entry=0x7f2717d0fb10 <true_p>,
db=<optimized out>, ver=<optimized out>, name=<optimized out>, type=<optimized out>,
covers=<optimized out>, update_rr=0x7f2706ff94b0, diff=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1454
#18 0x00007f2717d1bccd in update_action (task=<optimized out>, event=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:3299
#19 0x00007f271765eb4c in task_run (task=0x7f27155ccf00)
at /usr/src/debug/bind-9.18.10/lib/isc/task.c:823
#20 isc_task_run (task=0x7f27155ccf00) at /usr/src/debug/bind-9.18.10/lib/isc/task.c:904
#21 0x00007f271762cb12 in isc__nm_async_task (worker=0x7f2716236560, ev0=0x7f26caa07000)
at netmgr/netmgr.c:840
#22 process_netievent (worker=worker@entry=0x7f2716236560, ievent=0x7f26caa07000) at netmgr/netmgr.c:918
#23 0x00007f271762d197 in process_queue (worker=worker@entry=0x7f2716236560,
type=type@entry=NETIEVENT_TASK) at netmgr/netmgr.c:1011
#24 0x00007f271762d3b3 in process_all_queues (worker=0x7f2716236560) at netmgr/netmgr.c:765
#25 async_cb (handle=0x7f27162368c0) at netmgr/netmgr.c:794
#26 0x00007f2717c4cb0d in uv__async_io (loop=0x7f2716236570, w=<optimized out>, events=<optimized out>)
at src/unix/async.c:163
#27 0x00007f2717c6825d in uv__io_poll (loop=0x7f2716236570, timeout=<optimized out>)
at src/unix/epoll.c:374
#28 0x00007f2717c5247a in uv__io_poll (timeout=<optimized out>, loop=0x7f2716236570)
at src/unix/udp.c:122
#29 uv_run (loop=loop@entry=0x7f2716236570, mode=mode@entry=UV_RUN_DEFAULT) at src/unix/core.c:406
#30 0x00007f271762d834 in nm_thread (worker0=0x7f2716236560) at netmgr/netmgr.c:696
#31 0x00007f27176627f5 in isc__trampoline_run (arg=0x55d4dfe3ad70)
at /usr/src/debug/bind-9.18.10/lib/isc/trampoline.c:189
#32 0x00007f2716c9398d in start_thread () from /lib64/libc.so.6
#33 0x00007f2716d19344 in clone () from /lib64/libc.so.6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14030
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Samuel Cabrero <scabrero@samba.org>
Autobuild-Date(master): Thu Jan 19 10:20:27 UTC 2023 on atb-devel-224
2023-01-18 19:25:29 +03:00
return samba_dns_name_equal ( rec1 - > data . ptr , rec2 - > data . ptr ) ;
2021-04-12 22:00:41 +03:00
case DNS_TYPE_NS :
s4:dnsserver: Rename dns_name_equal() to samba_dns_name_equal()
This function already exists in bind9 but takes different arguments, so when
the DLZ is loaded and this function is called bind crashes:
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: client @0x7f26caa90f68 192.168.101.118#58223/key DESKTOP-8BUKMBK\$\@AFOREST.AD: updating zone '101.168.192.in-addr.arpa/NONE': deleting rrset at '118.101.168.192.in-addr.ar
named[1523]: name.c:664: REQUIRE(((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))) failed, back trace
Backtrace:
#0 0x00007f2716c957ec in __pthread_kill_implementation () from /lib64/libc.so.6
#1 0x00007f2716c42816 in raise () from /lib64/libc.so.6
#2 0x00007f2716c2b81c in abort () from /lib64/libc.so.6
#3 0x000055d4de847995 in assertion_failed (file=<optimized out>, line=<optimized out>,
type=<optimized out>, cond=<optimized out>) at /usr/src/debug/bind-9.18.10/bin/named/main.c:237
#4 0x00007f27176388fc in isc_assertion_failed (file=file@entry=0x7f27173b0df6 "name.c",
line=line@entry=664, type=type@entry=isc_assertiontype_require,
cond=cond@entry=0x7f27173b0268 "((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))")
at /usr/src/debug/bind-9.18.10/lib/isc/assertions.c:48
#5 0x00007f27172946f9 in dns_name_equal (name1=<optimized out>, name2=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/name.c:664
**** Here bind's dns_name_equal() is called instead of samba's dns_name_equal() ****
#6 0x00007f27077ad6f2 in dns_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dnsserver_common.c:1346
#7 0x00007f271404732c in b9_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dlz_bind9.c:1830
#8 0x00007f2714047daa in dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=0x7f26c9c10000 "118.101.168.192.in-addr.arpa.\t1200\tIN\tPTR\tDESKTOP-8BUKMBK.aforest.ad.",
dbdata=0x7f271003d300, version=0x7f26f8044b20) at ../../source4/dns_server/dlz_bind9.c:2077
#9 0x000055d4de84afb4 in dlopen_dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=<optimized out>, driverarg=<optimized out>, dbdata=0x7f270430f680, version=<optimized out>)
at /usr/src/debug/bind-9.18.10/bin/named/dlz_dlopen_driver.c:483
#10 0x00007f271738e734 in modrdataset.constprop.0 (db=0x7f2704291740, node=0x7f26c9c006e0,
version=0x7f26f8044b20, rdataset=0x7f2706ff8830,
mod_function=0x55d4de84af80 <dlopen_dlz_subrdataset>, options=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/sdlz.c:1107
#11 0x00007f2717251855 in diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, warn=warn@entry=true) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:370
#12 0x00007f2717251c8a in dns_diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:465
#13 0x00007f2717d105aa in do_one_tuple (tuple=tuple@entry=0x7f2706ff8e50, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, diff=diff@entry=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:454
#14 0x00007f2717d10fff in update_one_rr (rdata=0x7f2706ff8ee8, ttl=<optimized out>,
name=<optimized out>, op=DNS_DIFFOP_DEL, diff=0x7f2706ff9400, ver=0x7f26f8044b20, db=0x7f2704291740)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:505
#15 delete_if_action (data=<optimized out>, rr=0x7f2706ff8ee0)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1427
#16 0x00007f2717d10ccd in foreach_rr (db=0x7f2704291740, ver=<optimized out>, name=0x7f26caa61d00,
type=<optimized out>, covers=<optimized out>,
rr_action=rr_action@entry=0x7f2717d10f60 <delete_if_action>, rr_action_data=0x7f2706ff9280)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:736
#17 0x00007f2717d10e76 in delete_if (predicate=predicate@entry=0x7f2717d0fb10 <true_p>,
db=<optimized out>, ver=<optimized out>, name=<optimized out>, type=<optimized out>,
covers=<optimized out>, update_rr=0x7f2706ff94b0, diff=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1454
#18 0x00007f2717d1bccd in update_action (task=<optimized out>, event=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:3299
#19 0x00007f271765eb4c in task_run (task=0x7f27155ccf00)
at /usr/src/debug/bind-9.18.10/lib/isc/task.c:823
#20 isc_task_run (task=0x7f27155ccf00) at /usr/src/debug/bind-9.18.10/lib/isc/task.c:904
#21 0x00007f271762cb12 in isc__nm_async_task (worker=0x7f2716236560, ev0=0x7f26caa07000)
at netmgr/netmgr.c:840
#22 process_netievent (worker=worker@entry=0x7f2716236560, ievent=0x7f26caa07000) at netmgr/netmgr.c:918
#23 0x00007f271762d197 in process_queue (worker=worker@entry=0x7f2716236560,
type=type@entry=NETIEVENT_TASK) at netmgr/netmgr.c:1011
#24 0x00007f271762d3b3 in process_all_queues (worker=0x7f2716236560) at netmgr/netmgr.c:765
#25 async_cb (handle=0x7f27162368c0) at netmgr/netmgr.c:794
#26 0x00007f2717c4cb0d in uv__async_io (loop=0x7f2716236570, w=<optimized out>, events=<optimized out>)
at src/unix/async.c:163
#27 0x00007f2717c6825d in uv__io_poll (loop=0x7f2716236570, timeout=<optimized out>)
at src/unix/epoll.c:374
#28 0x00007f2717c5247a in uv__io_poll (timeout=<optimized out>, loop=0x7f2716236570)
at src/unix/udp.c:122
#29 uv_run (loop=loop@entry=0x7f2716236570, mode=mode@entry=UV_RUN_DEFAULT) at src/unix/core.c:406
#30 0x00007f271762d834 in nm_thread (worker0=0x7f2716236560) at netmgr/netmgr.c:696
#31 0x00007f27176627f5 in isc__trampoline_run (arg=0x55d4dfe3ad70)
at /usr/src/debug/bind-9.18.10/lib/isc/trampoline.c:189
#32 0x00007f2716c9398d in start_thread () from /lib64/libc.so.6
#33 0x00007f2716d19344 in clone () from /lib64/libc.so.6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14030
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Samuel Cabrero <scabrero@samba.org>
Autobuild-Date(master): Thu Jan 19 10:20:27 UTC 2023 on atb-devel-224
2023-01-18 19:25:29 +03:00
return samba_dns_name_equal ( rec1 - > data . ns , rec2 - > data . ns ) ;
2021-04-12 22:00:41 +03:00
case DNS_TYPE_SRV :
return rec1 - > data . srv . wPriority = = rec2 - > data . srv . wPriority & &
rec1 - > data . srv . wWeight = = rec2 - > data . srv . wWeight & &
rec1 - > data . srv . wPort = = rec2 - > data . srv . wPort & &
s4:dnsserver: Rename dns_name_equal() to samba_dns_name_equal()
This function already exists in bind9 but takes different arguments, so when
the DLZ is loaded and this function is called bind crashes:
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: client @0x7f26caa90f68 192.168.101.118#58223/key DESKTOP-8BUKMBK\$\@AFOREST.AD: updating zone '101.168.192.in-addr.arpa/NONE': deleting rrset at '118.101.168.192.in-addr.ar
named[1523]: name.c:664: REQUIRE(((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))) failed, back trace
Backtrace:
#0 0x00007f2716c957ec in __pthread_kill_implementation () from /lib64/libc.so.6
#1 0x00007f2716c42816 in raise () from /lib64/libc.so.6
#2 0x00007f2716c2b81c in abort () from /lib64/libc.so.6
#3 0x000055d4de847995 in assertion_failed (file=<optimized out>, line=<optimized out>,
type=<optimized out>, cond=<optimized out>) at /usr/src/debug/bind-9.18.10/bin/named/main.c:237
#4 0x00007f27176388fc in isc_assertion_failed (file=file@entry=0x7f27173b0df6 "name.c",
line=line@entry=664, type=type@entry=isc_assertiontype_require,
cond=cond@entry=0x7f27173b0268 "((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))")
at /usr/src/debug/bind-9.18.10/lib/isc/assertions.c:48
#5 0x00007f27172946f9 in dns_name_equal (name1=<optimized out>, name2=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/name.c:664
**** Here bind's dns_name_equal() is called instead of samba's dns_name_equal() ****
#6 0x00007f27077ad6f2 in dns_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dnsserver_common.c:1346
#7 0x00007f271404732c in b9_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dlz_bind9.c:1830
#8 0x00007f2714047daa in dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=0x7f26c9c10000 "118.101.168.192.in-addr.arpa.\t1200\tIN\tPTR\tDESKTOP-8BUKMBK.aforest.ad.",
dbdata=0x7f271003d300, version=0x7f26f8044b20) at ../../source4/dns_server/dlz_bind9.c:2077
#9 0x000055d4de84afb4 in dlopen_dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=<optimized out>, driverarg=<optimized out>, dbdata=0x7f270430f680, version=<optimized out>)
at /usr/src/debug/bind-9.18.10/bin/named/dlz_dlopen_driver.c:483
#10 0x00007f271738e734 in modrdataset.constprop.0 (db=0x7f2704291740, node=0x7f26c9c006e0,
version=0x7f26f8044b20, rdataset=0x7f2706ff8830,
mod_function=0x55d4de84af80 <dlopen_dlz_subrdataset>, options=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/sdlz.c:1107
#11 0x00007f2717251855 in diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, warn=warn@entry=true) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:370
#12 0x00007f2717251c8a in dns_diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:465
#13 0x00007f2717d105aa in do_one_tuple (tuple=tuple@entry=0x7f2706ff8e50, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, diff=diff@entry=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:454
#14 0x00007f2717d10fff in update_one_rr (rdata=0x7f2706ff8ee8, ttl=<optimized out>,
name=<optimized out>, op=DNS_DIFFOP_DEL, diff=0x7f2706ff9400, ver=0x7f26f8044b20, db=0x7f2704291740)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:505
#15 delete_if_action (data=<optimized out>, rr=0x7f2706ff8ee0)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1427
#16 0x00007f2717d10ccd in foreach_rr (db=0x7f2704291740, ver=<optimized out>, name=0x7f26caa61d00,
type=<optimized out>, covers=<optimized out>,
rr_action=rr_action@entry=0x7f2717d10f60 <delete_if_action>, rr_action_data=0x7f2706ff9280)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:736
#17 0x00007f2717d10e76 in delete_if (predicate=predicate@entry=0x7f2717d0fb10 <true_p>,
db=<optimized out>, ver=<optimized out>, name=<optimized out>, type=<optimized out>,
covers=<optimized out>, update_rr=0x7f2706ff94b0, diff=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1454
#18 0x00007f2717d1bccd in update_action (task=<optimized out>, event=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:3299
#19 0x00007f271765eb4c in task_run (task=0x7f27155ccf00)
at /usr/src/debug/bind-9.18.10/lib/isc/task.c:823
#20 isc_task_run (task=0x7f27155ccf00) at /usr/src/debug/bind-9.18.10/lib/isc/task.c:904
#21 0x00007f271762cb12 in isc__nm_async_task (worker=0x7f2716236560, ev0=0x7f26caa07000)
at netmgr/netmgr.c:840
#22 process_netievent (worker=worker@entry=0x7f2716236560, ievent=0x7f26caa07000) at netmgr/netmgr.c:918
#23 0x00007f271762d197 in process_queue (worker=worker@entry=0x7f2716236560,
type=type@entry=NETIEVENT_TASK) at netmgr/netmgr.c:1011
#24 0x00007f271762d3b3 in process_all_queues (worker=0x7f2716236560) at netmgr/netmgr.c:765
#25 async_cb (handle=0x7f27162368c0) at netmgr/netmgr.c:794
#26 0x00007f2717c4cb0d in uv__async_io (loop=0x7f2716236570, w=<optimized out>, events=<optimized out>)
at src/unix/async.c:163
#27 0x00007f2717c6825d in uv__io_poll (loop=0x7f2716236570, timeout=<optimized out>)
at src/unix/epoll.c:374
#28 0x00007f2717c5247a in uv__io_poll (timeout=<optimized out>, loop=0x7f2716236570)
at src/unix/udp.c:122
#29 uv_run (loop=loop@entry=0x7f2716236570, mode=mode@entry=UV_RUN_DEFAULT) at src/unix/core.c:406
#30 0x00007f271762d834 in nm_thread (worker0=0x7f2716236560) at netmgr/netmgr.c:696
#31 0x00007f27176627f5 in isc__trampoline_run (arg=0x55d4dfe3ad70)
at /usr/src/debug/bind-9.18.10/lib/isc/trampoline.c:189
#32 0x00007f2716c9398d in start_thread () from /lib64/libc.so.6
#33 0x00007f2716d19344 in clone () from /lib64/libc.so.6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14030
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Samuel Cabrero <scabrero@samba.org>
Autobuild-Date(master): Thu Jan 19 10:20:27 UTC 2023 on atb-devel-224
2023-01-18 19:25:29 +03:00
samba_dns_name_equal ( rec1 - > data . srv . nameTarget ,
rec2 - > data . srv . nameTarget ) ;
2021-04-12 22:00:41 +03:00
case DNS_TYPE_MX :
return rec1 - > data . mx . wPriority = = rec2 - > data . mx . wPriority & &
s4:dnsserver: Rename dns_name_equal() to samba_dns_name_equal()
This function already exists in bind9 but takes different arguments, so when
the DLZ is loaded and this function is called bind crashes:
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: client @0x7f26caa90f68 192.168.101.118#58223/key DESKTOP-8BUKMBK\$\@AFOREST.AD: updating zone '101.168.192.in-addr.arpa/NONE': deleting rrset at '118.101.168.192.in-addr.ar
named[1523]: name.c:664: REQUIRE(((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))) failed, back trace
Backtrace:
#0 0x00007f2716c957ec in __pthread_kill_implementation () from /lib64/libc.so.6
#1 0x00007f2716c42816 in raise () from /lib64/libc.so.6
#2 0x00007f2716c2b81c in abort () from /lib64/libc.so.6
#3 0x000055d4de847995 in assertion_failed (file=<optimized out>, line=<optimized out>,
type=<optimized out>, cond=<optimized out>) at /usr/src/debug/bind-9.18.10/bin/named/main.c:237
#4 0x00007f27176388fc in isc_assertion_failed (file=file@entry=0x7f27173b0df6 "name.c",
line=line@entry=664, type=type@entry=isc_assertiontype_require,
cond=cond@entry=0x7f27173b0268 "((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))")
at /usr/src/debug/bind-9.18.10/lib/isc/assertions.c:48
#5 0x00007f27172946f9 in dns_name_equal (name1=<optimized out>, name2=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/name.c:664
**** Here bind's dns_name_equal() is called instead of samba's dns_name_equal() ****
#6 0x00007f27077ad6f2 in dns_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dnsserver_common.c:1346
#7 0x00007f271404732c in b9_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dlz_bind9.c:1830
#8 0x00007f2714047daa in dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=0x7f26c9c10000 "118.101.168.192.in-addr.arpa.\t1200\tIN\tPTR\tDESKTOP-8BUKMBK.aforest.ad.",
dbdata=0x7f271003d300, version=0x7f26f8044b20) at ../../source4/dns_server/dlz_bind9.c:2077
#9 0x000055d4de84afb4 in dlopen_dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=<optimized out>, driverarg=<optimized out>, dbdata=0x7f270430f680, version=<optimized out>)
at /usr/src/debug/bind-9.18.10/bin/named/dlz_dlopen_driver.c:483
#10 0x00007f271738e734 in modrdataset.constprop.0 (db=0x7f2704291740, node=0x7f26c9c006e0,
version=0x7f26f8044b20, rdataset=0x7f2706ff8830,
mod_function=0x55d4de84af80 <dlopen_dlz_subrdataset>, options=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/sdlz.c:1107
#11 0x00007f2717251855 in diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, warn=warn@entry=true) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:370
#12 0x00007f2717251c8a in dns_diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:465
#13 0x00007f2717d105aa in do_one_tuple (tuple=tuple@entry=0x7f2706ff8e50, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, diff=diff@entry=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:454
#14 0x00007f2717d10fff in update_one_rr (rdata=0x7f2706ff8ee8, ttl=<optimized out>,
name=<optimized out>, op=DNS_DIFFOP_DEL, diff=0x7f2706ff9400, ver=0x7f26f8044b20, db=0x7f2704291740)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:505
#15 delete_if_action (data=<optimized out>, rr=0x7f2706ff8ee0)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1427
#16 0x00007f2717d10ccd in foreach_rr (db=0x7f2704291740, ver=<optimized out>, name=0x7f26caa61d00,
type=<optimized out>, covers=<optimized out>,
rr_action=rr_action@entry=0x7f2717d10f60 <delete_if_action>, rr_action_data=0x7f2706ff9280)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:736
#17 0x00007f2717d10e76 in delete_if (predicate=predicate@entry=0x7f2717d0fb10 <true_p>,
db=<optimized out>, ver=<optimized out>, name=<optimized out>, type=<optimized out>,
covers=<optimized out>, update_rr=0x7f2706ff94b0, diff=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1454
#18 0x00007f2717d1bccd in update_action (task=<optimized out>, event=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:3299
#19 0x00007f271765eb4c in task_run (task=0x7f27155ccf00)
at /usr/src/debug/bind-9.18.10/lib/isc/task.c:823
#20 isc_task_run (task=0x7f27155ccf00) at /usr/src/debug/bind-9.18.10/lib/isc/task.c:904
#21 0x00007f271762cb12 in isc__nm_async_task (worker=0x7f2716236560, ev0=0x7f26caa07000)
at netmgr/netmgr.c:840
#22 process_netievent (worker=worker@entry=0x7f2716236560, ievent=0x7f26caa07000) at netmgr/netmgr.c:918
#23 0x00007f271762d197 in process_queue (worker=worker@entry=0x7f2716236560,
type=type@entry=NETIEVENT_TASK) at netmgr/netmgr.c:1011
#24 0x00007f271762d3b3 in process_all_queues (worker=0x7f2716236560) at netmgr/netmgr.c:765
#25 async_cb (handle=0x7f27162368c0) at netmgr/netmgr.c:794
#26 0x00007f2717c4cb0d in uv__async_io (loop=0x7f2716236570, w=<optimized out>, events=<optimized out>)
at src/unix/async.c:163
#27 0x00007f2717c6825d in uv__io_poll (loop=0x7f2716236570, timeout=<optimized out>)
at src/unix/epoll.c:374
#28 0x00007f2717c5247a in uv__io_poll (timeout=<optimized out>, loop=0x7f2716236570)
at src/unix/udp.c:122
#29 uv_run (loop=loop@entry=0x7f2716236570, mode=mode@entry=UV_RUN_DEFAULT) at src/unix/core.c:406
#30 0x00007f271762d834 in nm_thread (worker0=0x7f2716236560) at netmgr/netmgr.c:696
#31 0x00007f27176627f5 in isc__trampoline_run (arg=0x55d4dfe3ad70)
at /usr/src/debug/bind-9.18.10/lib/isc/trampoline.c:189
#32 0x00007f2716c9398d in start_thread () from /lib64/libc.so.6
#33 0x00007f2716d19344 in clone () from /lib64/libc.so.6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14030
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Samuel Cabrero <scabrero@samba.org>
Autobuild-Date(master): Thu Jan 19 10:20:27 UTC 2023 on atb-devel-224
2023-01-18 19:25:29 +03:00
samba_dns_name_equal ( rec1 - > data . mx . nameTarget ,
rec2 - > data . mx . nameTarget ) ;
2021-04-12 22:00:41 +03:00
case DNS_TYPE_SOA :
s4:dnsserver: Rename dns_name_equal() to samba_dns_name_equal()
This function already exists in bind9 but takes different arguments, so when
the DLZ is loaded and this function is called bind crashes:
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: client @0x7f26caa90f68 192.168.101.118#58223/key DESKTOP-8BUKMBK\$\@AFOREST.AD: updating zone '101.168.192.in-addr.arpa/NONE': deleting rrset at '118.101.168.192.in-addr.ar
named[1523]: name.c:664: REQUIRE(((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))) failed, back trace
Backtrace:
#0 0x00007f2716c957ec in __pthread_kill_implementation () from /lib64/libc.so.6
#1 0x00007f2716c42816 in raise () from /lib64/libc.so.6
#2 0x00007f2716c2b81c in abort () from /lib64/libc.so.6
#3 0x000055d4de847995 in assertion_failed (file=<optimized out>, line=<optimized out>,
type=<optimized out>, cond=<optimized out>) at /usr/src/debug/bind-9.18.10/bin/named/main.c:237
#4 0x00007f27176388fc in isc_assertion_failed (file=file@entry=0x7f27173b0df6 "name.c",
line=line@entry=664, type=type@entry=isc_assertiontype_require,
cond=cond@entry=0x7f27173b0268 "((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))")
at /usr/src/debug/bind-9.18.10/lib/isc/assertions.c:48
#5 0x00007f27172946f9 in dns_name_equal (name1=<optimized out>, name2=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/name.c:664
**** Here bind's dns_name_equal() is called instead of samba's dns_name_equal() ****
#6 0x00007f27077ad6f2 in dns_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dnsserver_common.c:1346
#7 0x00007f271404732c in b9_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dlz_bind9.c:1830
#8 0x00007f2714047daa in dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=0x7f26c9c10000 "118.101.168.192.in-addr.arpa.\t1200\tIN\tPTR\tDESKTOP-8BUKMBK.aforest.ad.",
dbdata=0x7f271003d300, version=0x7f26f8044b20) at ../../source4/dns_server/dlz_bind9.c:2077
#9 0x000055d4de84afb4 in dlopen_dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=<optimized out>, driverarg=<optimized out>, dbdata=0x7f270430f680, version=<optimized out>)
at /usr/src/debug/bind-9.18.10/bin/named/dlz_dlopen_driver.c:483
#10 0x00007f271738e734 in modrdataset.constprop.0 (db=0x7f2704291740, node=0x7f26c9c006e0,
version=0x7f26f8044b20, rdataset=0x7f2706ff8830,
mod_function=0x55d4de84af80 <dlopen_dlz_subrdataset>, options=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/sdlz.c:1107
#11 0x00007f2717251855 in diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, warn=warn@entry=true) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:370
#12 0x00007f2717251c8a in dns_diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:465
#13 0x00007f2717d105aa in do_one_tuple (tuple=tuple@entry=0x7f2706ff8e50, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, diff=diff@entry=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:454
#14 0x00007f2717d10fff in update_one_rr (rdata=0x7f2706ff8ee8, ttl=<optimized out>,
name=<optimized out>, op=DNS_DIFFOP_DEL, diff=0x7f2706ff9400, ver=0x7f26f8044b20, db=0x7f2704291740)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:505
#15 delete_if_action (data=<optimized out>, rr=0x7f2706ff8ee0)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1427
#16 0x00007f2717d10ccd in foreach_rr (db=0x7f2704291740, ver=<optimized out>, name=0x7f26caa61d00,
type=<optimized out>, covers=<optimized out>,
rr_action=rr_action@entry=0x7f2717d10f60 <delete_if_action>, rr_action_data=0x7f2706ff9280)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:736
#17 0x00007f2717d10e76 in delete_if (predicate=predicate@entry=0x7f2717d0fb10 <true_p>,
db=<optimized out>, ver=<optimized out>, name=<optimized out>, type=<optimized out>,
covers=<optimized out>, update_rr=0x7f2706ff94b0, diff=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1454
#18 0x00007f2717d1bccd in update_action (task=<optimized out>, event=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:3299
#19 0x00007f271765eb4c in task_run (task=0x7f27155ccf00)
at /usr/src/debug/bind-9.18.10/lib/isc/task.c:823
#20 isc_task_run (task=0x7f27155ccf00) at /usr/src/debug/bind-9.18.10/lib/isc/task.c:904
#21 0x00007f271762cb12 in isc__nm_async_task (worker=0x7f2716236560, ev0=0x7f26caa07000)
at netmgr/netmgr.c:840
#22 process_netievent (worker=worker@entry=0x7f2716236560, ievent=0x7f26caa07000) at netmgr/netmgr.c:918
#23 0x00007f271762d197 in process_queue (worker=worker@entry=0x7f2716236560,
type=type@entry=NETIEVENT_TASK) at netmgr/netmgr.c:1011
#24 0x00007f271762d3b3 in process_all_queues (worker=0x7f2716236560) at netmgr/netmgr.c:765
#25 async_cb (handle=0x7f27162368c0) at netmgr/netmgr.c:794
#26 0x00007f2717c4cb0d in uv__async_io (loop=0x7f2716236570, w=<optimized out>, events=<optimized out>)
at src/unix/async.c:163
#27 0x00007f2717c6825d in uv__io_poll (loop=0x7f2716236570, timeout=<optimized out>)
at src/unix/epoll.c:374
#28 0x00007f2717c5247a in uv__io_poll (timeout=<optimized out>, loop=0x7f2716236570)
at src/unix/udp.c:122
#29 uv_run (loop=loop@entry=0x7f2716236570, mode=mode@entry=UV_RUN_DEFAULT) at src/unix/core.c:406
#30 0x00007f271762d834 in nm_thread (worker0=0x7f2716236560) at netmgr/netmgr.c:696
#31 0x00007f27176627f5 in isc__trampoline_run (arg=0x55d4dfe3ad70)
at /usr/src/debug/bind-9.18.10/lib/isc/trampoline.c:189
#32 0x00007f2716c9398d in start_thread () from /lib64/libc.so.6
#33 0x00007f2716d19344 in clone () from /lib64/libc.so.6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14030
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Samuel Cabrero <scabrero@samba.org>
Autobuild-Date(master): Thu Jan 19 10:20:27 UTC 2023 on atb-devel-224
2023-01-18 19:25:29 +03:00
return samba_dns_name_equal ( rec1 - > data . soa . mname ,
rec2 - > data . soa . mname ) & &
samba_dns_name_equal ( rec1 - > data . soa . rname ,
rec2 - > data . soa . rname ) & &
2021-04-12 22:00:41 +03:00
rec1 - > data . soa . serial = = rec2 - > data . soa . serial & &
rec1 - > data . soa . refresh = = rec2 - > data . soa . refresh & &
rec1 - > data . soa . retry = = rec2 - > data . soa . retry & &
rec1 - > data . soa . expire = = rec2 - > data . soa . expire & &
rec1 - > data . soa . minimum = = rec2 - > data . soa . minimum ;
2021-04-13 00:57:33 +03:00
case DNS_TYPE_TOMBSTONE :
return true ;
2021-04-12 22:00:41 +03:00
default :
break ;
}
return false ;
}
2015-09-22 03:10:00 +03:00
static int dns_common_sort_zones ( struct ldb_message * * m1 , struct ldb_message * * m2 )
{
const char * n1 , * n2 ;
size_t l1 , l2 ;
n1 = ldb_msg_find_attr_as_string ( * m1 , " name " , NULL ) ;
n2 = ldb_msg_find_attr_as_string ( * m2 , " name " , NULL ) ;
2019-05-08 05:27:05 +03:00
if ( n1 = = NULL | | n2 = = NULL ) {
if ( n1 ! = NULL ) {
return - 1 ;
} else if ( n2 ! = NULL ) {
return 1 ;
} else {
return 0 ;
}
}
2015-09-22 03:10:00 +03:00
l1 = strlen ( n1 ) ;
l2 = strlen ( n2 ) ;
/* If the string lengths are not equal just sort by length */
if ( l1 ! = l2 ) {
/* If m1 is the larger zone name, return it first */
2024-04-03 02:55:54 +03:00
return NUMERIC_CMP ( l2 , l1 ) ;
2015-09-22 03:10:00 +03:00
}
/*TODO: We need to compare DNs here, we want the DomainDNSZones first */
return 0 ;
}
NTSTATUS dns_common_zones ( struct ldb_context * samdb ,
TALLOC_CTX * mem_ctx ,
2017-06-09 07:05:31 +03:00
struct ldb_dn * base_dn ,
2015-09-22 03:10:00 +03:00
struct dns_server_zone * * zones_ret )
{
2019-04-05 01:13:15 +03:00
const struct timeval start = timeval_current ( ) ;
2015-09-22 03:10:00 +03:00
int ret ;
static const char * const attrs [ ] = { " name " , NULL } ;
struct ldb_result * res ;
int i ;
struct dns_server_zone * new_list = NULL ;
TALLOC_CTX * frame = talloc_stackframe ( ) ;
2019-04-05 01:13:15 +03:00
NTSTATUS result = NT_STATUS_OK ;
2015-09-22 03:10:00 +03:00
2017-06-09 07:05:31 +03:00
if ( base_dn ) {
/* This search will work against windows */
ret = dsdb_search ( samdb , frame , & res ,
base_dn , LDB_SCOPE_SUBTREE ,
attrs , 0 , " (objectClass=dnsZone) " ) ;
} else {
/* TODO: this search does not work against windows */
ret = dsdb_search ( samdb , frame , & res , NULL ,
LDB_SCOPE_SUBTREE ,
attrs ,
DSDB_SEARCH_SEARCH_ALL_PARTITIONS ,
" (objectClass=dnsZone) " ) ;
}
2015-09-22 03:10:00 +03:00
if ( ret ! = LDB_SUCCESS ) {
TALLOC_FREE ( frame ) ;
2019-04-05 01:13:15 +03:00
result = NT_STATUS_INTERNAL_DB_CORRUPTION ;
goto exit ;
2015-09-22 03:10:00 +03:00
}
TYPESAFE_QSORT ( res - > msgs , res - > count , dns_common_sort_zones ) ;
for ( i = 0 ; i < res - > count ; i + + ) {
struct dns_server_zone * z ;
z = talloc_zero ( mem_ctx , struct dns_server_zone ) ;
if ( z = = NULL ) {
TALLOC_FREE ( frame ) ;
2019-04-05 01:13:15 +03:00
result = NT_STATUS_NO_MEMORY ;
goto exit ;
2015-09-22 03:10:00 +03:00
}
z - > name = ldb_msg_find_attr_as_string ( res - > msgs [ i ] , " name " , NULL ) ;
talloc_steal ( z , z - > name ) ;
z - > dn = talloc_move ( z , & res - > msgs [ i ] - > dn ) ;
/*
* Ignore the RootDNSServers zone and zones that we don ' t support yet
* RootDNSServers should never be returned ( Windows DNS server don ' t )
* . . TrustAnchors should never be returned as is , ( Windows returns
* TrustAnchors ) and for the moment we don ' t support DNSSEC so we ' d better
* not return this zone .
*/
if ( ( strcmp ( z - > name , " RootDNSServers " ) = = 0 ) | |
( strcmp ( z - > name , " ..TrustAnchors " ) = = 0 ) )
{
DEBUG ( 10 , ( " Ignoring zone %s \n " , z - > name ) ) ;
talloc_free ( z ) ;
continue ;
}
2016-02-05 13:32:18 +03:00
DLIST_ADD_END ( new_list , z ) ;
2015-09-22 03:10:00 +03:00
}
* zones_ret = new_list ;
TALLOC_FREE ( frame ) ;
2019-04-05 01:13:15 +03:00
result = NT_STATUS_OK ;
exit :
DNS_COMMON_LOG_OPERATION (
nt_errstr ( result ) ,
& start ,
NULL ,
base_dn = = NULL ? NULL : ldb_dn_get_linearized ( base_dn ) ,
NULL ) ;
return result ;
2015-09-22 03:10:00 +03:00
}
2018-06-05 08:12:44 +03:00
/*
see if two DNS names are the same
*/
s4:dnsserver: Rename dns_name_equal() to samba_dns_name_equal()
This function already exists in bind9 but takes different arguments, so when
the DLZ is loaded and this function is called bind crashes:
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: samba_dlz: allowing update of signer=DESKTOP-8BUKMBK\$\@AFOREST.AD name=118.101.168.192.in-addr.arpa tcpaddr=192.168.101.118 type=PTR key=1264-ms-7.1-2ac9.9ef238e1-9747-11ed-9f95-525400dc6981/159/0
named[1523]: client @0x7f26caa90f68 192.168.101.118#58223/key DESKTOP-8BUKMBK\$\@AFOREST.AD: updating zone '101.168.192.in-addr.arpa/NONE': deleting rrset at '118.101.168.192.in-addr.ar
named[1523]: name.c:664: REQUIRE(((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))) failed, back trace
Backtrace:
#0 0x00007f2716c957ec in __pthread_kill_implementation () from /lib64/libc.so.6
#1 0x00007f2716c42816 in raise () from /lib64/libc.so.6
#2 0x00007f2716c2b81c in abort () from /lib64/libc.so.6
#3 0x000055d4de847995 in assertion_failed (file=<optimized out>, line=<optimized out>,
type=<optimized out>, cond=<optimized out>) at /usr/src/debug/bind-9.18.10/bin/named/main.c:237
#4 0x00007f27176388fc in isc_assertion_failed (file=file@entry=0x7f27173b0df6 "name.c",
line=line@entry=664, type=type@entry=isc_assertiontype_require,
cond=cond@entry=0x7f27173b0268 "((name1) != ((void *)0) && ((const isc__magic_t *)(name1))->magic == ((('D') << 24 | ('N') << 16 | ('S') << 8 | ('n'))))")
at /usr/src/debug/bind-9.18.10/lib/isc/assertions.c:48
#5 0x00007f27172946f9 in dns_name_equal (name1=<optimized out>, name2=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/name.c:664
**** Here bind's dns_name_equal() is called instead of samba's dns_name_equal() ****
#6 0x00007f27077ad6f2 in dns_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dnsserver_common.c:1346
#7 0x00007f271404732c in b9_record_match (rec1=0x7f26f8042d70, rec2=0x7f26f8044d10)
at ../../source4/dns_server/dlz_bind9.c:1830
#8 0x00007f2714047daa in dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=0x7f26c9c10000 "118.101.168.192.in-addr.arpa.\t1200\tIN\tPTR\tDESKTOP-8BUKMBK.aforest.ad.",
dbdata=0x7f271003d300, version=0x7f26f8044b20) at ../../source4/dns_server/dlz_bind9.c:2077
#9 0x000055d4de84afb4 in dlopen_dlz_subrdataset (name=0x7f2706ff82f0 "118.101.168.192.in-addr.arpa",
rdatastr=<optimized out>, driverarg=<optimized out>, dbdata=0x7f270430f680, version=<optimized out>)
at /usr/src/debug/bind-9.18.10/bin/named/dlz_dlopen_driver.c:483
#10 0x00007f271738e734 in modrdataset.constprop.0 (db=0x7f2704291740, node=0x7f26c9c006e0,
version=0x7f26f8044b20, rdataset=0x7f2706ff8830,
mod_function=0x55d4de84af80 <dlopen_dlz_subrdataset>, options=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/dns/sdlz.c:1107
#11 0x00007f2717251855 in diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, warn=warn@entry=true) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:370
#12 0x00007f2717251c8a in dns_diff_apply (diff=diff@entry=0x7f2706ff8df0, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20) at /usr/src/debug/bind-9.18.10/lib/dns/diff.c:465
#13 0x00007f2717d105aa in do_one_tuple (tuple=tuple@entry=0x7f2706ff8e50, db=db@entry=0x7f2704291740,
ver=ver@entry=0x7f26f8044b20, diff=diff@entry=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:454
#14 0x00007f2717d10fff in update_one_rr (rdata=0x7f2706ff8ee8, ttl=<optimized out>,
name=<optimized out>, op=DNS_DIFFOP_DEL, diff=0x7f2706ff9400, ver=0x7f26f8044b20, db=0x7f2704291740)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:505
#15 delete_if_action (data=<optimized out>, rr=0x7f2706ff8ee0)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1427
#16 0x00007f2717d10ccd in foreach_rr (db=0x7f2704291740, ver=<optimized out>, name=0x7f26caa61d00,
type=<optimized out>, covers=<optimized out>,
rr_action=rr_action@entry=0x7f2717d10f60 <delete_if_action>, rr_action_data=0x7f2706ff9280)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:736
#17 0x00007f2717d10e76 in delete_if (predicate=predicate@entry=0x7f2717d0fb10 <true_p>,
db=<optimized out>, ver=<optimized out>, name=<optimized out>, type=<optimized out>,
covers=<optimized out>, update_rr=0x7f2706ff94b0, diff=0x7f2706ff9400)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:1454
#18 0x00007f2717d1bccd in update_action (task=<optimized out>, event=<optimized out>)
at /usr/src/debug/bind-9.18.10/lib/ns/update.c:3299
#19 0x00007f271765eb4c in task_run (task=0x7f27155ccf00)
at /usr/src/debug/bind-9.18.10/lib/isc/task.c:823
#20 isc_task_run (task=0x7f27155ccf00) at /usr/src/debug/bind-9.18.10/lib/isc/task.c:904
#21 0x00007f271762cb12 in isc__nm_async_task (worker=0x7f2716236560, ev0=0x7f26caa07000)
at netmgr/netmgr.c:840
#22 process_netievent (worker=worker@entry=0x7f2716236560, ievent=0x7f26caa07000) at netmgr/netmgr.c:918
#23 0x00007f271762d197 in process_queue (worker=worker@entry=0x7f2716236560,
type=type@entry=NETIEVENT_TASK) at netmgr/netmgr.c:1011
#24 0x00007f271762d3b3 in process_all_queues (worker=0x7f2716236560) at netmgr/netmgr.c:765
#25 async_cb (handle=0x7f27162368c0) at netmgr/netmgr.c:794
#26 0x00007f2717c4cb0d in uv__async_io (loop=0x7f2716236570, w=<optimized out>, events=<optimized out>)
at src/unix/async.c:163
#27 0x00007f2717c6825d in uv__io_poll (loop=0x7f2716236570, timeout=<optimized out>)
at src/unix/epoll.c:374
#28 0x00007f2717c5247a in uv__io_poll (timeout=<optimized out>, loop=0x7f2716236570)
at src/unix/udp.c:122
#29 uv_run (loop=loop@entry=0x7f2716236570, mode=mode@entry=UV_RUN_DEFAULT) at src/unix/core.c:406
#30 0x00007f271762d834 in nm_thread (worker0=0x7f2716236560) at netmgr/netmgr.c:696
#31 0x00007f27176627f5 in isc__trampoline_run (arg=0x55d4dfe3ad70)
at /usr/src/debug/bind-9.18.10/lib/isc/trampoline.c:189
#32 0x00007f2716c9398d in start_thread () from /lib64/libc.so.6
#33 0x00007f2716d19344 in clone () from /lib64/libc.so.6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14030
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Samuel Cabrero <scabrero@samba.org>
Autobuild-Date(master): Thu Jan 19 10:20:27 UTC 2023 on atb-devel-224
2023-01-18 19:25:29 +03:00
bool samba_dns_name_equal ( const char * name1 , const char * name2 )
2018-06-05 08:12:44 +03:00
{
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 ;
}
2021-03-11 05:17:28 +03:00
/*
* Convert unix time to a DNS timestamp
* uint32 hours in the NTTIME epoch
*
* This uses unix_to_nt_time ( ) which can return special flag NTTIMEs like
* UINT64_MAX ( 0xFFF . . . ) or NTTIME_MAX ( 0x7FF . . . ) , which will convert to
* distant future timestamps ; or 0 as a flag value , meaning a 1601 timestamp ,
* which is used to indicate a record does not expire .
*
* As we don ' t generally check for these special values in NTTIME conversions ,
* we also don ' t check here , but for the benefit of people encountering these
* timestamps and searching for their origin , here is a list :
*
* * TIME_T_MAX
*
* Even if time_t is 32 bit , this will become NTTIME_MAX ( a . k . a INT64_MAX ,
* 0x7fffffffffffffff ) in 100 ns units . That translates to 256204778 hours
* since 1601 , which converts back to 9223372008000000000 or
* 0x7ffffff9481f1000 . It will present as 30828 - 09 - 14 02 : 00 : 00 , around 48
* minutes earlier than NTTIME_MAX .
*
* * 0 , the start of the unix epoch , 1970 - 01 - 01 00 : 00 : 00
*
* This is converted into 0 in the Windows epoch , 1601 - 01 - 01 00 : 00 : 00 which is
* clearly the same whether you count in 100 ns units or hours . In DNS record
* timestamps this is a flag meaning the record will never expire .
*
* * ( time_t ) - 1 , such as what * might * mean 1969 - 12 - 31 23 : 59 : 59
*
* This becomes ( NTTIME ) - 1ULL a . k . a . UINT64_MAX , 0xffffffffffffffff thence
* 512409557 in hours since 1601. That in turn is 0xfffffffaf2028800 or
* 18446744052000000000 in NTTIME ( rounded to the hour ) , which might be
2023-09-06 07:34:33 +03:00
* presented as - 21709551616 or - 0x50dfd7800 , because NTTIME is not completely
2021-03-11 05:17:28 +03:00
* dedicated to being unsigned . If it gets shown as a year , it will be around
* 60055.
*
* * Other negative time_t values ( e . g . 1969 - 05 - 29 ) .
*
* The meaning of these is somewhat undefined , but in any case they will
* translate perfectly well into the same dates in NTTIME .
*
* * Notes
*
* There are dns timestamps that exceed the range of NTTIME ( up to 488356 AD ) ,
* but it is not possible for this function to produce them .
*
* It is plausible that it was at midnight on 1601 - 01 - 01 , in London , that
* Shakespeare wrote :
*
* The time is out of joint . O cursed spite
* That ever I was born to set it right !
*
* and this is why we have this epoch and time zone .
*/
uint32_t unix_to_dns_timestamp ( time_t t )
{
NTTIME nt ;
unix_to_nt_time ( & nt , t ) ;
nt / = NTTIME_TO_HOURS ;
return ( uint32_t ) nt ;
}
/*
* Convert a DNS timestamp into NTTIME .
*
* Because DNS timestamps cover a longer time period than NTTIME , and these
* would wrap to an arbitrary NTTIME , we saturate at NTTIME_MAX and return an
* error in this case .
*/
NTSTATUS dns_timestamp_to_nt_time ( NTTIME * _nt , uint32_t t )
{
NTTIME nt = t ;
if ( nt > NTTIME_MAX / NTTIME_TO_HOURS ) {
* _nt = NTTIME_MAX ;
return NT_STATUS_INTEGER_OVERFLOW ;
}
* _nt = nt * NTTIME_TO_HOURS ;
return NT_STATUS_OK ;
}