dns: treating fully qualified and unqualified zone as identical.
authorAaron Haslett <aaronhaslett@catalyst.net.nz>
Fri, 17 Aug 2018 05:30:20 +0000 (17:30 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 20 Dec 2018 22:40:26 +0000 (23:40 +0100)
"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 <aaronhaslett@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/knownfail.d/dns
source4/rpc_server/dnsserver/dcerpc_dnsserver.c
source4/rpc_server/dnsserver/dnsutils.c

index 10a6c03e0e106552da754d66e03e58435d4513b2..70a719a818a947142009bae0205cfbbd37e593fb 100644 (file)
@@ -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\)
index edea2b33f2d2fdb0354f6aa6ee2574e467a08b41..ce01c9c258fa08e1b6601477d033a366f9ddbfff 100644 (file)
@@ -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;
index ea1eca596a13f3f5f68edbbf63dbd997dc3906f4..173988ab318b47f3a18fd1463e3bb8c93b400459 100644 (file)
@@ -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;
                }
        }