From: Aaron Haslett Date: Fri, 17 Aug 2018 05:30:20 +0000 (+1200) Subject: dns: treating fully qualified and unqualified zone as identical. X-Git-Tag: tdb-1.3.17~161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebc42cb140ca7477428798678f8552ef76a04dec;p=thirdparty%2Fsamba.git dns: treating fully qualified and unqualified zone as identical. "zone.com." and "zone.com" should be treated as the same zone. This patch picks the unqualified representation as standard and enforces it, in order to match BIND9 behaviour. Note: This fixes the failing test added previously, but that test still fails on the rodc test target so we modify the expected failure but don't remove it. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13442 Signed-off-by: Aaron Haslett Reviewed-by: Gary Lockyer Reviewed-by: Andrew Bartlett --- diff --git a/selftest/knownfail.d/dns b/selftest/knownfail.d/dns index 10a6c03e0e1..70a719a818a 100644 --- a/selftest/knownfail.d/dns +++ b/selftest/knownfail.d/dns @@ -50,7 +50,7 @@ samba.tests.dns.__main__.TestZones.test_dns_tombstone_custom_match_rule_no_recor samba.tests.dns.__main__.TestZones.test_dns_tombstone_custom_match_rule_fail\(rodc:local\) samba.tests.dns.__main__.TestZones.test_dynamic_record_static_update\(rodc:local\) samba.tests.dns.__main__.TestZones.test_static_record_dynamic_update\(rodc:local\) -samba.tests.dns.__main__.TestZones.test_fully_qualified_zone +samba.tests.dns.__main__.TestZones.test_fully_qualified_zone\(rodc:local\) samba.tests.dns.__main__.TestZones.test_set_aging\(vampire_dc:local\) samba.tests.dns.__main__.TestZones.test_aging_update\(vampire_dc:local\) diff --git a/source4/rpc_server/dnsserver/dcerpc_dnsserver.c b/source4/rpc_server/dnsserver/dcerpc_dnsserver.c index edea2b33f2d..ce01c9c258f 100644 --- a/source4/rpc_server/dnsserver/dcerpc_dnsserver.c +++ b/source4/rpc_server/dnsserver/dcerpc_dnsserver.c @@ -1117,6 +1117,7 @@ static WERROR dnsserver_operate_server(struct dnsserver_state *dsstate, } else if (strcasecmp(operation, "ZoneCreate") == 0) { struct dnsserver_zone *z, *z2; WERROR status; + int len; z = talloc_zero(mem_ctx, struct dnsserver_zone); W_ERROR_HAVE_NO_MEMORY(z); @@ -1126,20 +1127,32 @@ static WERROR dnsserver_operate_server(struct dnsserver_state *dsstate, W_ERROR_HAVE_NO_MEMORY_AND_FREE(z->zoneinfo, z); if (typeid == DNSSRV_TYPEID_ZONE_CREATE_W2K) { - z->name = talloc_strdup(z, r->ZoneCreateW2K->pszZoneName); + len = strlen(r->ZoneCreateW2K->pszZoneName); + if (r->ZoneCreateW2K->pszZoneName[len-1] == '.') { + len -= 1; + } + z->name = talloc_strndup(z, r->ZoneCreateW2K->pszZoneName, len); z->zoneinfo->dwZoneType = r->ZoneCreateW2K->dwZoneType; z->zoneinfo->fAllowUpdate = r->ZoneCreateW2K->fAllowUpdate; z->zoneinfo->fAging = r->ZoneCreateW2K->fAging; z->zoneinfo->Flags = r->ZoneCreateW2K->dwFlags; } else if (typeid == DNSSRV_TYPEID_ZONE_CREATE_DOTNET) { - z->name = talloc_strdup(z, r->ZoneCreateDotNet->pszZoneName); + len = strlen(r->ZoneCreateDotNet->pszZoneName); + if (r->ZoneCreateDotNet->pszZoneName[len-1] == '.') { + len -= 1; + } + z->name = talloc_strndup(z, r->ZoneCreateDotNet->pszZoneName, len); z->zoneinfo->dwZoneType = r->ZoneCreateDotNet->dwZoneType; z->zoneinfo->fAllowUpdate = r->ZoneCreateDotNet->fAllowUpdate; z->zoneinfo->fAging = r->ZoneCreateDotNet->fAging; z->zoneinfo->Flags = r->ZoneCreateDotNet->dwFlags; z->partition->dwDpFlags = r->ZoneCreateDotNet->dwDpFlags; } else if (typeid == DNSSRV_TYPEID_ZONE_CREATE) { - z->name = talloc_strdup(z, r->ZoneCreate->pszZoneName); + len = strlen(r->ZoneCreate->pszZoneName); + if (r->ZoneCreate->pszZoneName[len-1] == '.') { + len -= 1; + } + z->name = talloc_strndup(z, r->ZoneCreate->pszZoneName, len); z->zoneinfo->dwZoneType = r->ZoneCreate->dwZoneType; z->zoneinfo->fAllowUpdate = r->ZoneCreate->fAllowUpdate; z->zoneinfo->fAging = r->ZoneCreate->fAging; diff --git a/source4/rpc_server/dnsserver/dnsutils.c b/source4/rpc_server/dnsserver/dnsutils.c index ea1eca596a1..173988ab318 100644 --- a/source4/rpc_server/dnsserver/dnsutils.c +++ b/source4/rpc_server/dnsserver/dnsutils.c @@ -22,6 +22,7 @@ #include "includes.h" #include "dnsserver.h" #include "rpc_server/common/common.h" +#include "dns_server/dnsserver_common.h" #include "dsdb/samdb/samdb.h" #include "lib/socket/netif.h" #include "lib/util/util_net.h" @@ -316,7 +317,7 @@ struct dnsserver_zone *dnsserver_find_zone(struct dnsserver_zone *zones, const c struct dnsserver_zone *z = NULL; for (z = zones; z; z = z->next) { - if (strcasecmp(zone_name, z->name) == 0) { + if (dns_name_equal(zone_name, z->name)) { break; } }