[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Thu Dec 22 23:57:01 MST 2011


The branch, master has been updated
       via  271c7d9 s4:rpc-dnsserver: Set the rank for the new DNS record correctly
       via  809092a test:dnsserver: Add zone creation and deletion test
       via  8a7cdfc samba-tool:dns: Fix a typo
       via  d340c2c samba-tool:dns: Add zone create/delete commands
       via  20e425f ldif-handler: Fix the case for attribute dnsproperty
       via  56bf8e2 s4:rpc-dnsserver: Add comments
       via  9586860 s4:rpc-dnsserver: Make sure that zone information is filled in
       via  10860d5 s4:rpc-dnsserver: Implement zone management RPC operations
       via  e398bdb s4:rpc-dnsserver: Add multiple DNS records in a single operation
       via  f14ddcc s4:rpc-dnsserver: Use handy macros for error checking
       via  3d139b4 s4:rpc-dnsserver: Implement DirectoryPartitionInfo RPC operation
       via  07639b5 s4:rpc-dnsserver: Fix the enumeration of DNS records
       via  fe0e08a s4:rpc-dnsserver: Use cached zone information to get rootservers
       via  dbf5df5 idl:dnsserver: Add DNS_DP_STATE enumeration for diretory partition state
       via  6a5352d s4:rpc-dnsserver: Implement EnumDirectoryPartition operation
       via  5673e2c s4:rpc-dnsserver: Cache DNS partition information
       via  9f76e07 s4:rpc-dnsserver: If a zone is reverse zone, set the fReverse flag
       via  0120a39 s4:rpc-dnsserver: For PTR records, use dns_name_equal instead of strcmp to compare
       via  ecbc747 samba-tool:dns: Add support for reverse names (PTR records)
       via  1eef73e s4-provision: Set dNSProperty attribute for dns zones
      from  21fb9a4 s3-librpc Use gensec_sig_size() instead of a fixed NTLMSSP_SIG_SIZE

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 271c7d9251059c38a815ad47034bc478752a0167
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Dec 23 16:15:26 2011 +1100

    s4:rpc-dnsserver: Set the rank for the new DNS record correctly
    
    Autobuild-User: Amitay Isaacs <amitay at samba.org>
    Autobuild-Date: Fri Dec 23 07:56:34 CET 2011 on sn-devel-104

commit 809092a7adcb884492dda12796f270f9bec7ab89
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Dec 20 14:41:43 2011 +1100

    test:dnsserver: Add zone creation and deletion test

commit 8a7cdfcccd87f4a439304b95718d121bebecde70
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Dec 20 12:07:11 2011 +1100

    samba-tool:dns: Fix a typo

commit d340c2cae89d50d13acf450ce76520d686e5f522
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Dec 20 12:06:47 2011 +1100

    samba-tool:dns: Add zone create/delete commands

commit 20e425f7a8027b14ed7d3eedd4bb315010d4e942
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Dec 20 12:05:49 2011 +1100

    ldif-handler: Fix the case for attribute dnsproperty

commit 56bf8e250a2886fce1157b92c876c623eea01fba
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Dec 19 12:16:45 2011 +1100

    s4:rpc-dnsserver: Add comments

commit 95868605e2caf4c8a66b10be7911762d587a2388
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Dec 16 17:59:59 2011 +1100

    s4:rpc-dnsserver: Make sure that zone information is filled in
    
    This fixes the problem of NULL zone in zone operations when specific
    zone is specified and no zone filter is specified.

commit 10860d58d77e9769c70d07678baddc09f73d3c52
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Dec 16 15:41:15 2011 +1100

    s4:rpc-dnsserver: Implement zone management RPC operations
    
    - ZoneCreate operation to create zone.
    - DeleteZoneFromDs operation to delete zone
    
    When a zone is deleted, all the records in that zone are also deleted.

commit e398bdb76bf6a85c757d3152be77d02fd0febac4
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Dec 19 12:13:46 2011 +1100

    s4:rpc-dnsserver: Add multiple DNS records in a single operation
    
    This allows to add dnsNode objectclass with multiple DNS records in a
    single operation. Useful for creating @ record which has NS and SOA
    records.

commit f14ddcc2e13cae85545e516bdd44e93d2a7301c5
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Dec 16 12:20:43 2011 +1100

    s4:rpc-dnsserver: Use handy macros for error checking

commit 3d139b49cbf2d036bc59bf34f657643c1069ebc0
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Dec 16 12:11:42 2011 +1100

    s4:rpc-dnsserver: Implement DirectoryPartitionInfo RPC operation

commit 07639b502382a3c708350bdf4ca19d9437e0beaa
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Dec 15 19:45:22 2011 +1100

    s4:rpc-dnsserver: Fix the enumeration of DNS records
    
    If a node has data and children, do not return the children unless
    the node is the top level node.

commit fe0e08acfb1f183178c1277491778c8f0a6219d8
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Dec 15 19:45:10 2011 +1100

    s4:rpc-dnsserver: Use cached zone information to get rootservers
    
    This removes the hardcoded search for DC=RootDNSServers, and uses
    the cached zone information.

commit dbf5df5f8ff0868ac0346ab8a489a789c00c680e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Dec 15 18:52:21 2011 +1100

    idl:dnsserver: Add DNS_DP_STATE enumeration for diretory partition state

commit 6a5352da594bcd6c109c883f3db7e307f171f228
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Dec 15 18:27:39 2011 +1100

    s4:rpc-dnsserver: Implement EnumDirectoryPartition operation

commit 5673e2cec946502da84956f866658718e7632a3e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Dec 15 17:44:32 2011 +1100

    s4:rpc-dnsserver: Cache DNS partition information
    
    This information will be used for the RPC calls for partition
    information.

commit 9f76e076fa2593fdc67c3b82fb262670154bad09
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Dec 14 16:17:31 2011 +1100

    s4:rpc-dnsserver: If a zone is reverse zone, set the fReverse flag
    
    And use fReverse flag in the enumeration of zones.

commit 0120a397a73a8752c8eac4d2046c43beffe14672
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Dec 14 16:16:23 2011 +1100

    s4:rpc-dnsserver: For PTR records, use dns_name_equal instead of strcmp to compare

commit ecbc747ca57e11538c872dfc977eebec8aa8807e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Dec 14 15:54:31 2011 +1100

    samba-tool:dns: Add support for reverse names (PTR records)

commit 1eef73e7763a7b2ff6b12e0a7e55c18362c9ae23
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Dec 14 14:47:05 2011 +1100

    s4-provision: Set dNSProperty attribute for dns zones

-----------------------------------------------------------------------

Summary of changes:
 lib/ldb-samba/ldif_handlers.c                      |    2 +-
 librpc/idl/dnsserver.idl                           |    9 +-
 source4/rpc_server/dnsserver/dcerpc_dnsserver.c    |  302 +++++++++--
 source4/rpc_server/dnsserver/dnsdata.c             |   12 +-
 source4/rpc_server/dnsserver/dnsdb.c               |  550 ++++++++++++++++++--
 source4/rpc_server/dnsserver/dnsserver.h           |   41 ++-
 source4/rpc_server/dnsserver/dnsutils.c            |   62 ++-
 source4/scripting/python/samba/netcmd/dns.py       |  125 +++++-
 .../scripting/python/samba/provision/sambadns.py   |   73 +++-
 .../python/samba/tests/dcerpc/dnsserver.py         |   51 ++
 10 files changed, 1094 insertions(+), 133 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ldb-samba/ldif_handlers.c b/lib/ldb-samba/ldif_handlers.c
index 9c49f75..af66623 100644
--- a/lib/ldb-samba/ldif_handlers.c
+++ b/lib/ldb-samba/ldif_handlers.c
@@ -1500,7 +1500,7 @@ static const struct {
 
 	/* These NDR encoded things we want to be able to read with --show-binary */
 	{ "dnsRecord",				LDB_SYNTAX_SAMBA_DNSRECORD },
-	{ "dnsProperty",			LDB_SYNTAX_SAMBA_DNSPROPERTY },
+	{ "dNSProperty",			LDB_SYNTAX_SAMBA_DNSPROPERTY },
 	{ "supplementalCredentials",		LDB_SYNTAX_SAMBA_SUPPLEMENTALCREDENTIALS},
 	{ "partialAttributeSet",		LDB_SYNTAX_SAMBA_PARTIALATTRIBUTESET}
 };
diff --git a/librpc/idl/dnsserver.idl b/librpc/idl/dnsserver.idl
index 0502270..5e29511 100644
--- a/librpc/idl/dnsserver.idl
+++ b/librpc/idl/dnsserver.idl
@@ -601,6 +601,13 @@ import "misc.idl", "dnsp.idl";
 	DNS_RPC_DP_REPLICA;
 #define PDNS_RPC_DP_REPLICA DNS_RPC_DP_REPLICA*
 
+	typedef [v1_enum] enum {
+		DNS_DP_OKAY                = 0x00,
+		DNS_DP_STATE_REPL_INCOMING = 0x01,
+		DNS_DP_STATE_REPL_OUTGOING = 0x02,
+		DNS_DP_STATE_UNKNOWN       = 0x03
+	} DNS_DP_STATE;
+
 	typedef struct {
 		DWORD           dwRpcStructureVersion;
 		DWORD           dwReserved0;
@@ -610,7 +617,7 @@ import "misc.idl", "dnsp.idl";
 		[string, charset(UTF16)] wchar_t *       pszCrDn;
 		DWORD           dwFlags;
 		DWORD           dwZoneCount;
-		DWORD           dwState;
+		DNS_DP_STATE    dwState;
 
 		DWORD           dwReserved[    3 ];
 		DNS_EXTENSION   pwszReserved[ 3 ];
diff --git a/source4/rpc_server/dnsserver/dcerpc_dnsserver.c b/source4/rpc_server/dnsserver/dcerpc_dnsserver.c
index e1966fa..5f4009b 100644
--- a/source4/rpc_server/dnsserver/dcerpc_dnsserver.c
+++ b/source4/rpc_server/dnsserver/dcerpc_dnsserver.c
@@ -31,6 +31,7 @@
 struct dnsserver_state {
 	struct loadparm_context *lp_ctx;
 	struct ldb_context *samdb;
+	struct dnsserver_partition *partitions;
 	struct dnsserver_zone *zones;
 	int zones_count;
 	struct dnsserver_serverinfo *serverinfo;
@@ -39,10 +40,64 @@ struct dnsserver_state {
 
 /* Utility functions */
 
+static void dnsserver_reload_zones(struct dnsserver_state *dsstate)
+{
+	struct dnsserver_partition *p;
+	struct dnsserver_zone *zones, *z, *znext, *zmatch;
+	struct dnsserver_zone *old_list, *new_list;
+
+	old_list = dsstate->zones;
+	new_list = NULL;
+
+	for (p = dsstate->partitions; p; p = p->next) {
+		zones = dnsserver_db_enumerate_zones(dsstate, dsstate->samdb, p);
+		if (zones == NULL) {
+			continue;
+		}
+		for (z = zones; z; ) {
+			znext = z->next;
+			zmatch = dnsserver_find_zone(old_list, z->name);
+			if (zmatch == NULL) {
+				/* Missing zone */
+				z->zoneinfo = dnsserver_init_zoneinfo(z, dsstate->serverinfo);
+				if (z->zoneinfo == NULL) {
+					continue;
+				}
+				DLIST_ADD_END(new_list, z, NULL);
+				p->zones_count++;
+				dsstate->zones_count++;
+			} else {
+				/* Existing zone */
+				talloc_free(z);
+				DLIST_REMOVE(old_list, zmatch);
+				DLIST_ADD_END(new_list, zmatch, NULL);
+			}
+			z = znext;
+		}
+	}
+
+	if (new_list == NULL) {
+		return;
+	}
+
+	/* Deleted zones */
+	for (z = old_list; z; ) {
+		znext = z->next;
+		z->partition->zones_count--;
+		dsstate->zones_count--;
+		talloc_free(z);
+		z = znext;
+	}
+
+	dsstate->zones = new_list;
+}
+
+
 static struct dnsserver_state *dnsserver_connect(struct dcesrv_call_state *dce_call)
 {
 	struct dnsserver_state *dsstate;
-	struct dnsserver_zone *zones, *z;
+	struct dnsserver_zone *zones, *z, *znext;
+	struct dnsserver_partition *partitions, *p;
 
 	dsstate = talloc_get_type(dce_call->context->private_data, struct dnsserver_state);
 	if (dsstate != NULL) {
@@ -72,31 +127,30 @@ static struct dnsserver_state *dnsserver_connect(struct dcesrv_call_state *dce_c
 		goto failed;
 	}
 
-	/* Search for DNS zones */
-	zones = dnsserver_db_enumerate_zones(dsstate, dsstate->samdb, true);
-	if (zones == NULL) {
+	/* Search for DNS partitions */
+	partitions = dnsserver_db_enumerate_partitions(dsstate, dsstate->serverinfo, dsstate->samdb);
+	if (partitions == NULL) {
 		goto failed;
 	}
-	for (z = zones; z; z = z->next) {
-		z->zoneinfo = dnsserver_init_zoneinfo(z, dsstate->serverinfo, true);
-		if (z->zoneinfo == NULL) {
-			goto failed;
-		}
-		DLIST_ADD_END(dsstate->zones, z, NULL);
-		dsstate->zones_count++;
-	}
+	dsstate->partitions = partitions;
 
-	zones = dnsserver_db_enumerate_zones(dsstate, dsstate->samdb, false);
-	if (zones == NULL) {
-		goto failed;
-	}
-	for (z = zones; z; z = z->next) {
-		z->zoneinfo = dnsserver_init_zoneinfo(z, dsstate->serverinfo, false);
-		if (z->zoneinfo == NULL) {
+	/* Search for DNS zones */
+	for (p = partitions; p; p = p->next) {
+		zones = dnsserver_db_enumerate_zones(dsstate, dsstate->samdb, p);
+		if (zones == NULL) {
 			goto failed;
 		}
-		DLIST_ADD_END(dsstate->zones, z, NULL);
-		dsstate->zones_count++;
+		for (z = zones; z; ) {
+			znext = z->next;
+			z->zoneinfo = dnsserver_init_zoneinfo(z, dsstate->serverinfo);
+			if (z->zoneinfo == NULL) {
+				goto failed;
+			}
+			DLIST_ADD_END(dsstate->zones, z, NULL);
+			p->zones_count++;
+			dsstate->zones_count++;
+			z = znext;
+		}
 	}
 
 	dce_call->context->private_data = dsstate;
@@ -773,8 +827,8 @@ static WERROR dnsserver_query_zone(struct dnsserver_state *dsstate,
 			r->Zone->Flags = zoneinfo->Flags;
 			r->Zone->ZoneType = zoneinfo->dwZoneType;
 			r->Zone->Version = zoneinfo->Version;
-			r->Zone->dwDpFlags = zoneinfo->dwDpFlags;
-			r->Zone->pszDpFqdn = talloc_strdup(mem_ctx, zoneinfo->pszDpFqdn);
+			r->Zone->dwDpFlags = z->partition->dwDpFlags;
+			r->Zone->pszDpFqdn = talloc_strdup(mem_ctx, z->partition->pszDpFqdn);
 		}
 		return WERR_OK;
 	}
@@ -835,8 +889,8 @@ static WERROR dnsserver_query_zone(struct dnsserver_state *dsstate,
 			r->ZoneInfoDotNet->dwForwarderTimeout = zoneinfo->dwForwarderTimeout;
 			r->ZoneInfoDotNet->fForwarderSlave = zoneinfo->fForwarderSlave;
 			r->ZoneInfoDotNet->aipLocalMasters = ip4_array_copy(mem_ctx, zoneinfo->aipLocalMasters);
-			r->ZoneInfoDotNet->dwDpFlags = zoneinfo->dwDpFlags;
-			r->ZoneInfoDotNet->pszDpFqdn = talloc_strdup(mem_ctx, zoneinfo->pszDpFqdn);
+			r->ZoneInfoDotNet->dwDpFlags = z->partition->dwDpFlags;
+			r->ZoneInfoDotNet->pszDpFqdn = talloc_strdup(mem_ctx, z->partition->pszDpFqdn);
 			r->ZoneInfoDotNet->pwszZoneDn = talloc_strdup(mem_ctx, zoneinfo->pwszZoneDn);
 			r->ZoneInfoDotNet->dwLastSuccessfulSoaCheck = zoneinfo->dwLastSuccessfulSoaCheck;
 			r->ZoneInfoDotNet->dwLastSuccessfulXfr = zoneinfo->dwLastSuccessfulXfr;
@@ -870,8 +924,8 @@ static WERROR dnsserver_query_zone(struct dnsserver_state *dsstate,
 			r->ZoneInfo->dwForwarderTimeout = zoneinfo->dwForwarderTimeout;
 			r->ZoneInfo->fForwarderSlave = zoneinfo->fForwarderSlave;
 			r->ZoneInfo->aipLocalMasters = ip4_array_to_dns_addr_array(mem_ctx, zoneinfo->aipLocalMasters);
-			r->ZoneInfo->dwDpFlags = zoneinfo->dwDpFlags;
-			r->ZoneInfo->pszDpFqdn = talloc_strdup(mem_ctx, zoneinfo->pszDpFqdn);
+			r->ZoneInfo->dwDpFlags = z->partition->dwDpFlags;
+			r->ZoneInfo->pszDpFqdn = talloc_strdup(mem_ctx, z->partition->pszDpFqdn);
 			r->ZoneInfo->pwszZoneDn = talloc_strdup(mem_ctx, zoneinfo->pwszZoneDn);
 			r->ZoneInfo->dwLastSuccessfulSoaCheck = zoneinfo->dwLastSuccessfulSoaCheck;
 			r->ZoneInfo->dwLastSuccessfulXfr = zoneinfo->dwLastSuccessfulXfr;
@@ -998,7 +1052,7 @@ static WERROR dnsserver_query_zone(struct dnsserver_state *dsstate,
 		answer_string = talloc_strdup(mem_ctx, zoneinfo->pszDataFile);
 		is_string = 1;
 	} else if (strcasecmp(operation, "ApplicationDirectoryPartition") == 0) {
-		answer_string = talloc_strdup(mem_ctx, zoneinfo->pszDpFqdn);
+		answer_string = talloc_strdup(mem_ctx, z->partition->pszDpFqdn);
 		is_string = 1;
 	} else if (strcasecmp(operation, "BreakOnNameUpdate") == 0) {
 		answer_string = NULL;
@@ -1039,7 +1093,55 @@ static WERROR dnsserver_operate_server(struct dnsserver_state *dsstate,
 	} else if (strcasecmp(operation, "WriteDirtyZones") == 0) {
 		valid_operation = true;
 	} else if (strcasecmp(operation, "ZoneCreate") == 0) {
-		valid_operation = true;
+		struct dnsserver_zone *z, *z2;
+		WERROR status;
+
+		z = talloc_zero(mem_ctx, struct dnsserver_zone);
+		W_ERROR_HAVE_NO_MEMORY(z);
+		z->partition = talloc_zero(z, struct dnsserver_partition);
+		W_ERROR_HAVE_NO_MEMORY_AND_FREE(z->partition, z);
+		z->zoneinfo = talloc_zero(z, struct dnsserver_zoneinfo);
+		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);
+			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);
+			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);
+			z->zoneinfo->dwZoneType = r->ZoneCreate->dwZoneType;
+			z->zoneinfo->fAllowUpdate = r->ZoneCreate->fAllowUpdate;
+			z->zoneinfo->fAging = r->ZoneCreate->fAging;
+			z->zoneinfo->Flags = r->ZoneCreate->dwFlags;
+			z->partition->dwDpFlags = r->ZoneCreate->dwDpFlags;
+		} else {
+			talloc_free(z);
+			return WERR_DNS_ERROR_INVALID_PROPERTY;
+		}
+
+		z2 = dnsserver_find_zone(dsstate->zones, z->name);
+		if (z2 != NULL) {
+			talloc_free(z);
+			return WERR_DNS_ERROR_ZONE_ALREADY_EXISTS;
+		}
+
+		status = dnsserver_db_create_zone(dsstate->samdb, dsstate->partitions, z,
+						  dsstate->lp_ctx);
+		talloc_free(z);
+
+		if (W_ERROR_IS_OK(status)) {
+			dnsserver_reload_zones(dsstate);
+		}
+		return status;
 	} else if (strcasecmp(operation, "ClearStatistics") == 0) {
 		valid_operation = true;
 	} else if (strcasecmp(operation, "EnlistDirectoryPartition") == 0) {
@@ -1153,7 +1255,7 @@ static WERROR dnsserver_complex_operate_server(struct dnsserver_state *dsstate,
 				}
 				if (rin->Dword & DNS_ZONE_REQUEST_AUTO) {
 					if (z->zoneinfo->fAutoCreated 
-						|| z->zoneinfo->dwDpFlags & DNS_DP_AUTOCREATED) {
+						|| z->partition->dwDpFlags & DNS_DP_AUTOCREATED) {
 						found1 = true;
 					}
 				}
@@ -1165,12 +1267,12 @@ static WERROR dnsserver_complex_operate_server(struct dnsserver_state *dsstate,
 			found2 = false;
 			if (rin->Dword & 0x000000f0) {
 				if (rin->Dword & DNS_ZONE_REQUEST_FORWARD) {
-					if (!(z->zoneinfo->Flags & DNS_RPC_ZONE_REVERSE)) {
+					if (!(z->zoneinfo->fReverse)) {
 						found2 = true;
 					}
 				}
 				if (rin->Dword & DNS_ZONE_REQUEST_REVERSE) {
-					if (z->zoneinfo->Flags & DNS_RPC_ZONE_REVERSE) {
+					if (z->zoneinfo->fReverse) {
 						found2 = true;
 					}
 				}
@@ -1202,12 +1304,12 @@ static WERROR dnsserver_complex_operate_server(struct dnsserver_state *dsstate,
 					}
 				}
 				if (rin->Dword & DNS_ZONE_REQUEST_DOMAIN_DP) {
-					if (!(z->zoneinfo->dwDpFlags & DNS_DP_DOMAIN_DEFAULT)) {
+					if (!(z->partition->dwDpFlags & DNS_DP_DOMAIN_DEFAULT)) {
 						found3 = true;
 					}
 				}
 				if (rin->Dword & DNS_ZONE_REQUEST_FOREST_DP) {
-					if (!(z->zoneinfo->dwDpFlags & DNS_DP_FOREST_DEFAULT)) {
+					if (!(z->partition->dwDpFlags & DNS_DP_FOREST_DEFAULT)) {
 						found3 = true;
 					}
 				}
@@ -1241,10 +1343,7 @@ static WERROR dnsserver_complex_operate_server(struct dnsserver_state *dsstate,
 			}
 
 			rout->ZoneListW2K->ZoneArray = talloc_zero_array(mem_ctx, struct DNS_RPC_ZONE_W2K *, zcount);
-			if (rout->ZoneListW2K->ZoneArray == NULL) {
-				talloc_free(zlist);
-				return WERR_NOMEM;
-			}
+			W_ERROR_HAVE_NO_MEMORY_AND_FREE(rout->ZoneListW2K->ZoneArray, zlist);
 
 			for (i=0; i<zcount; i++) {
 				rout->ZoneListW2K->ZoneArray[i] = talloc_zero(mem_ctx, struct DNS_RPC_ZONE_W2K);
@@ -1269,10 +1368,7 @@ static WERROR dnsserver_complex_operate_server(struct dnsserver_state *dsstate,
 			}
 
 			rout->ZoneList->ZoneArray = talloc_zero_array(mem_ctx, struct DNS_RPC_ZONE_DOTNET *, zcount);
-			if (rout->ZoneList->ZoneArray == NULL) {
-				talloc_free(zlist);
-				return WERR_NOMEM;
-			}
+			W_ERROR_HAVE_NO_MEMORY_AND_FREE(rout->ZoneList->ZoneArray, zlist);
 
 			for (i=0; i<zcount; i++) {
 				rout->ZoneList->ZoneArray[i] = talloc_zero(mem_ctx, struct DNS_RPC_ZONE_DOTNET);
@@ -1282,8 +1378,8 @@ static WERROR dnsserver_complex_operate_server(struct dnsserver_state *dsstate,
 				rout->ZoneList->ZoneArray[i]->Flags = zlist[i]->zoneinfo->Flags;
 				rout->ZoneList->ZoneArray[i]->ZoneType = zlist[i]->zoneinfo->dwZoneType;
 				rout->ZoneList->ZoneArray[i]->Version = zlist[i]->zoneinfo->Version;
-				rout->ZoneList->ZoneArray[i]->dwDpFlags = zlist[i]->zoneinfo->dwDpFlags;
-				rout->ZoneList->ZoneArray[i]->pszDpFqdn = talloc_strdup(mem_ctx, zlist[i]->zoneinfo->pszDpFqdn);
+				rout->ZoneList->ZoneArray[i]->dwDpFlags = zlist[i]->partition->dwDpFlags;
+				rout->ZoneList->ZoneArray[i]->pszDpFqdn = talloc_strdup(mem_ctx, zlist[i]->partition->pszDpFqdn);
 			}
 			rout->ZoneList->dwRpcStructureVersion = 1;
 			rout->ZoneList->dwZoneCount = zcount;
@@ -1293,9 +1389,80 @@ static WERROR dnsserver_complex_operate_server(struct dnsserver_state *dsstate,
 	} else if (strcasecmp(operation, "EnumZones2") == 0) {
 		valid_operation = true;
 	} else if (strcasecmp(operation, "EnumDirectoryPartitions") == 0) {
-		valid_operation = true;
+		if (typeid_in != DNSSRV_TYPEID_DWORD) {
+			return WERR_DNS_ERROR_INVALID_PROPERTY;
+		}
+
+		*typeid_out = DNSSRV_TYPEID_DP_LIST;
+		rout->DirectoryPartitionList = talloc_zero(mem_ctx, struct DNS_RPC_DP_LIST);
+
+		if (rin->Dword != 0) {
+			rout->DirectoryPartitionList->dwDpCount = 0;
+			rout->DirectoryPartitionList->DpArray = NULL;
+		} else {
+			struct DNS_RPC_DP_ENUM **dplist;
+			struct dnsserver_partition *p;
+			int pcount = 2;
+
+			dplist = talloc_zero_array(mem_ctx, struct DNS_RPC_DP_ENUM *, pcount);
+			W_ERROR_HAVE_NO_MEMORY(dplist);
+
+			p = dsstate->partitions;
+			for (i=0; i<pcount; i++) {
+				dplist[i] = talloc_zero(dplist, struct DNS_RPC_DP_ENUM);
+
+				dplist[i]->pszDpFqdn = talloc_strdup(mem_ctx, p->pszDpFqdn);
+				dplist[i]->dwFlags = p->dwDpFlags;
+				dplist[i]->dwZoneCount = p->zones_count;
+				p = p->next;
+			}
+
+			rout->DirectoryPartitionList->dwDpCount = pcount;
+			rout->DirectoryPartitionList->DpArray = dplist;
+		}
+		return WERR_OK;
 	} else if (strcasecmp(operation, "DirectoryPartitionInfo") == 0) {
-		valid_operation = true;
+		struct dnsserver_partition *p;
+		struct dnsserver_partition_info *partinfo;
+		struct DNS_RPC_DP_INFO *dpinfo = NULL;
+
+		if (typeid_in != DNSSRV_TYPEID_LPSTR) {
+			return WERR_DNS_ERROR_INVALID_PROPERTY;
+		}
+
+		*typeid_out = DNSSRV_TYPEID_DP_INFO;
+
+		for (p = dsstate->partitions; p; p = p->next) {
+			if (strcmp(p->pszDpFqdn, rin->String) == 0) {
+				dpinfo = talloc_zero(mem_ctx, struct DNS_RPC_DP_INFO);
+				W_ERROR_HAVE_NO_MEMORY(dpinfo);
+
+				partinfo = dnsserver_db_partition_info(mem_ctx, dsstate->samdb, p);
+				W_ERROR_HAVE_NO_MEMORY(partinfo);
+
+				dpinfo->pszDpFqdn = talloc_strdup(dpinfo, p->pszDpFqdn);
+				dpinfo->pszDpDn = talloc_strdup(dpinfo, ldb_dn_get_linearized(p->partition_dn));
+				dpinfo->pszCrDn = talloc_steal(dpinfo, partinfo->pszCrDn);
+				dpinfo->dwFlags = p->dwDpFlags;
+				dpinfo->dwZoneCount = p->zones_count;
+				dpinfo->dwState = partinfo->dwState;
+				dpinfo->dwReplicaCount = partinfo->dwReplicaCount;
+				if (partinfo->dwReplicaCount > 0) {
+					dpinfo->ReplicaArray = talloc_steal(dpinfo,
+									    partinfo->ReplicaArray);
+				} else {
+					dpinfo->ReplicaArray = NULL;
+				}
+				break;
+			}
+		}
+
+		if (dpinfo == NULL) {
+			return WERR_DNS_ERROR_DP_DOES_NOT_EXIST;
+		}
+
+		rout->DirectoryPartition = dpinfo;
+		return WERR_OK;
 	} else if (strcasecmp(operation, "Statistics") == 0) {
 		valid_operation = true;
 	} else if (strcasecmp(operation, "IpValidate") == 0) {
@@ -1324,6 +1491,14 @@ static WERROR dnsserver_operate_zone(struct dnsserver_state *dsstate,
 	bool valid_operation = false;
 
 	if (strcasecmp(operation, "ResetDwordProperty") == 0) {
+		if (typeid != DNSSRV_TYPEID_NAME_AND_PARAM) {
+			return WERR_DNS_ERROR_INVALID_PROPERTY;
+		}
+
+		/* Ignore property resets */
+		if (strcasecmp(r->NameAndParam->pszNodeName, "AllowUpdate") == 0) {
+			return WERR_OK;
+		}
 		valid_operation = true;
 	} else if (strcasecmp(operation, "ZoneTypeReset") == 0) {
 		valid_operation = true;
@@ -1344,7 +1519,15 @@ static WERROR dnsserver_operate_zone(struct dnsserver_state *dsstate,
 	} else if (strcasecmp(operation, "WriteBackFile") == 0) {
 		valid_operation = true;
 	} else if (strcasecmp(operation, "DeleteZoneFromDs") == 0) {
-		valid_operation = true;
+		WERROR status;
+		if (z == NULL) {
+			return WERR_DNS_ERROR_ZONE_DOES_NOT_EXIST;
+		}
+		status =  dnsserver_db_delete_zone(dsstate->samdb, z);
+		if (W_ERROR_IS_OK(status)) {
+			dnsserver_reload_zones(dsstate);
+		}
+		return status;
 	} else if (strcasecmp(operation, "UpdateZoneFromDs") == 0) {
 		valid_operation = true;
 	} else if (strcasecmp(operation, "ZoneExport") == 0) {
@@ -1423,9 +1606,9 @@ static WERROR dnsserver_enumerate_root_records(struct dnsserver_state *dsstate,
 					struct DNS_RPC_RECORDS_ARRAY **buffer)
 {
 	TALLOC_CTX *tmp_ctx;
+	struct dnsserver_zone *z;
 	const char * const attrs[] = { "name", "dnsRecord", NULL };
 	struct ldb_result *res;
-	struct ldb_dn *dn;
 	struct DNS_RPC_RECORDS_ARRAY *recs;
 	char **add_names;
 	char *rname;
@@ -1436,15 +1619,12 @@ static WERROR dnsserver_enumerate_root_records(struct dnsserver_state *dsstate,
 	tmp_ctx = talloc_new(mem_ctx);
 	W_ERROR_HAVE_NO_MEMORY(tmp_ctx);
 
-	dn = ldb_dn_copy(tmp_ctx, ldb_get_default_basedn(dsstate->samdb));
-	W_ERROR_HAVE_NO_MEMORY_AND_FREE(dn, tmp_ctx);
-
-	if (!ldb_dn_add_child_fmt(dn, "DC=RootDNSServers,CN=MicrosoftDNS,DC=DomainDnsZones")) {
-		talloc_free(tmp_ctx);
-		return WERR_NOMEM;
+	z = dnsserver_find_zone(dsstate->zones, ".");
+	if (z == NULL) {
+		return WERR_DNS_ERROR_NAME_DOES_NOT_EXIST;
 	}
 
-	ret = ldb_search(dsstate->samdb, tmp_ctx, &res, dn,
+	ret = ldb_search(dsstate->samdb, tmp_ctx, &res, z->zone_dn,
 				LDB_SCOPE_ONELEVEL, attrs, "(&(objectClass=dnsNode)(name=@))");
 	if (ret != LDB_SUCCESS) {
 		talloc_free(tmp_ctx);
@@ -1476,7 +1656,7 @@ static WERROR dnsserver_enumerate_root_records(struct dnsserver_state *dsstate,
 	/* Add any additional records */
 	if (select_flag & DNS_RPC_VIEW_ADDITIONAL_DATA) {
 		for (i=0; i<add_count; i++) {
-			ret = ldb_search(dsstate->samdb, tmp_ctx, &res, dn,
+			ret = ldb_search(dsstate->samdb, tmp_ctx, &res, z->zone_dn,
 					LDB_SCOPE_ONELEVEL, attrs,
 					"(&(objectClass=dnsNode)(name=%s))", add_names[i]);
 			if (ret != LDB_SUCCESS || res->count == 0) {
@@ -1734,6 +1914,11 @@ static WERROR dcesrv_DnssrvOperation(struct dcesrv_call_state *dce_call, TALLOC_
 						r->in.dwTypeId,
 						&r->in.pData);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list