summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-12-20 21:54:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:29:33 -0500
commit7cb96a785f6362eb3df820cfdee73bbbc9d06960 (patch)
treec76e4bb195f45e1c82d44ee010d64cbabf8943de
parentce38e5368ef842768ff9655cb071270ec78aac84 (diff)
downloadsamba-7cb96a785f6362eb3df820cfdee73bbbc9d06960.tar.gz
samba-7cb96a785f6362eb3df820cfdee73bbbc9d06960.tar.bz2
samba-7cb96a785f6362eb3df820cfdee73bbbc9d06960.zip
r20293: implement store chunk hook for libnet_BecomeDC()
metze (This used to be commit aba497f2fdb79e4a61c028501d4d33a3f678ba73)
-rw-r--r--source4/libnet/libnet_become_dc.c84
-rw-r--r--source4/libnet/libnet_become_dc.h41
-rw-r--r--source4/torture/libnet/libnet_BecomeDC.c12
3 files changed, 79 insertions, 58 deletions
diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c
index b906f312df..bc50317594 100644
--- a/source4/libnet/libnet_become_dc.c
+++ b/source4/libnet/libnet_become_dc.c
@@ -65,20 +65,7 @@ struct libnet_BecomeDC_state {
struct libnet_BecomeDC_SourceDSA source_dsa;
struct libnet_BecomeDC_DestDSA dest_dsa;
- struct becomeDC_partition {
- struct drsuapi_DsReplicaObjectIdentifier nc;
- struct GUID destination_dsa_guid;
- struct GUID source_dsa_guid;
- struct GUID source_dsa_invocation_id;
- struct drsuapi_DsReplicaHighWaterMark highwatermark;
- struct drsuapi_DsReplicaCoursorCtrEx *uptodateness_vector;
- uint32_t replica_flags;
-
- struct drsuapi_DsReplicaObjectListItemEx *first_object;
- struct drsuapi_DsReplicaObjectListItemEx *last_object;
-
- NTSTATUS (*store_chunk)(void *private_data, void *todo);
- } schema_part, config_part, domain_part;
+ struct libnet_BecomeDC_Partition schema_part, config_part, domain_part;
struct becomeDC_fsmo {
const char *dns_name;
@@ -91,6 +78,7 @@ struct libnet_BecomeDC_state {
struct libnet_BecomeDC_CheckOptions _co;
struct libnet_BecomeDC_PrepareDB _pp;
+ struct libnet_BecomeDC_StoreChunk _sc;
struct libnet_BecomeDC_Callbacks callbacks;
};
@@ -1555,7 +1543,7 @@ static void becomeDC_drsuapi3_connect_recv(struct composite_context *req)
static void becomeDC_drsuapi_pull_partition_send(struct libnet_BecomeDC_state *s,
struct becomeDC_drsuapi *drsuapi_h,
struct becomeDC_drsuapi *drsuapi_p,
- struct becomeDC_partition *partition,
+ struct libnet_BecomeDC_Partition *partition,
void (*recv_fn)(struct rpc_request *req))
{
struct composite_context *c = s->creq;
@@ -1572,7 +1560,7 @@ static void becomeDC_drsuapi_pull_partition_send(struct libnet_BecomeDC_state *s
r->in.req.req8.source_dsa_invocation_id = partition->source_dsa_invocation_id;
r->in.req.req8.naming_context = &partition->nc;
r->in.req.req8.highwatermark = partition->highwatermark;
- r->in.req.req8.uptodateness_vector = partition->uptodateness_vector;
+ r->in.req.req8.uptodateness_vector = NULL;
r->in.req.req8.replica_flags = partition->replica_flags;
r->in.req.req8.max_object_count = 133;
r->in.req.req8.max_ndr_size = 1336811;
@@ -1588,7 +1576,7 @@ static void becomeDC_drsuapi_pull_partition_send(struct libnet_BecomeDC_state *s
r->in.req.req5.source_dsa_invocation_id = partition->source_dsa_invocation_id;
r->in.req.req5.naming_context = &partition->nc;
r->in.req.req5.highwatermark = partition->highwatermark;
- r->in.req.req5.uptodateness_vector = partition->uptodateness_vector;
+ r->in.req.req5.uptodateness_vector = NULL;
r->in.req.req5.replica_flags = partition->replica_flags;
r->in.req.req5.max_object_count = 133;
r->in.req.req5.max_ndr_size = 1336770;
@@ -1596,11 +1584,6 @@ static void becomeDC_drsuapi_pull_partition_send(struct libnet_BecomeDC_state *s
r->in.req.req5.h1 = 0;
}
-DEBUG(0,("start NC[%s] tmp_highest_usn[%llu] highest_usn[%llu]\n",
- partition->nc.dn,
- partition->highwatermark.tmp_highest_usn,
- partition->highwatermark.highest_usn));
-
/*
* we should try to use the drsuapi_p->pipe here, as w2k3 does
* but it seems that some extra flags in the DCERPC Bind call
@@ -1612,52 +1595,49 @@ DEBUG(0,("start NC[%s] tmp_highest_usn[%llu] highest_usn[%llu]\n",
}
static WERROR becomeDC_drsuapi_pull_partition_recv(struct libnet_BecomeDC_state *s,
- struct becomeDC_partition *partition,
+ struct libnet_BecomeDC_Partition *partition,
struct drsuapi_DsGetNCChanges *r)
{
+ uint32_t ctr_level = 0;
struct drsuapi_DsGetNCChangesCtr1 *ctr1 = NULL;
struct drsuapi_DsGetNCChangesCtr6 *ctr6 = NULL;
- uint32_t out_level = 0;
struct GUID *source_dsa_guid;
struct GUID *source_dsa_invocation_id;
struct drsuapi_DsReplicaHighWaterMark *new_highwatermark;
- struct drsuapi_DsReplicaObjectListItemEx *first_object;
- struct drsuapi_DsReplicaObjectListItemEx *cur;
+ NTSTATUS nt_status;
if (!W_ERROR_IS_OK(r->out.result)) {
return r->out.result;
}
if (r->out.level == 1) {
- out_level = 1;
+ ctr_level = 1;
ctr1 = &r->out.ctr.ctr1;
} else if (r->out.level == 2) {
- out_level = 1;
+ ctr_level = 1;
ctr1 = r->out.ctr.ctr2.ctr.mszip1.ctr1;
} else if (r->out.level == 6) {
- out_level = 6;
+ ctr_level = 6;
ctr6 = &r->out.ctr.ctr6;
} else if (r->out.level == 7 &&
r->out.ctr.ctr7.level == 6 &&
r->out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) {
- out_level = 6;
+ ctr_level = 6;
ctr6 = r->out.ctr.ctr7.ctr.mszip6.ctr6;
} else {
return WERR_BAD_NET_RESP;
}
- switch (out_level) {
+ switch (ctr_level) {
case 1:
source_dsa_guid = &ctr1->source_dsa_guid;
source_dsa_invocation_id = &ctr1->source_dsa_invocation_id;
new_highwatermark = &ctr1->new_highwatermark;
- first_object = ctr1->first_object;
break;
case 6:
source_dsa_guid = &ctr6->source_dsa_guid;
source_dsa_invocation_id = &ctr6->source_dsa_invocation_id;
new_highwatermark = &ctr6->new_highwatermark;
- first_object = ctr6->first_object;
break;
}
@@ -1665,26 +1645,20 @@ static WERROR becomeDC_drsuapi_pull_partition_recv(struct libnet_BecomeDC_state
partition->source_dsa_guid = *source_dsa_guid;
partition->source_dsa_invocation_id = *source_dsa_invocation_id;
- if (!partition->first_object) {
- partition->first_object = talloc_steal(s, first_object);
- } else {
- partition->last_object->next_object = talloc_steal(partition->last_object,
- first_object);
- }
- for (cur = first_object; cur->next_object; cur = cur->next_object) {}
- partition->last_object = cur;
-
-DEBUG(0,("end NC[%s] tmp_highest_usn[%llu] highest_usn[%llu]\n",
- partition->nc.dn,
- partition->highwatermark.tmp_highest_usn,
- partition->highwatermark.highest_usn));
-
- if (partition->store_chunk) {
- NTSTATUS nt_status;
- nt_status = partition->store_chunk(s->callbacks.private_data, NULL);
- if (!NT_STATUS_IS_OK(nt_status)) {
- return ntstatus_to_werror(nt_status);
- }
+ if (!partition->store_chunk) return WERR_OK;
+
+ s->_sc.domain = &s->domain;
+ s->_sc.forest = &s->forest;
+ s->_sc.source_dsa = &s->source_dsa;
+ s->_sc.dest_dsa = &s->dest_dsa;
+ s->_sc.partition = partition;
+ s->_sc.ctr_level = ctr_level;
+ s->_sc.ctr1 = ctr1;
+ s->_sc.ctr6 = ctr6;
+
+ nt_status = partition->store_chunk(s->callbacks.private_data, &s->_sc);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ return ntstatus_to_werror(nt_status);
}
return WERR_OK;
@@ -1821,7 +1795,7 @@ static void becomeDC_drsuapi3_pull_domain_send(struct libnet_BecomeDC_state *s)
static void becomeDC_drsuapi_update_refs_send(struct libnet_BecomeDC_state *s,
struct becomeDC_drsuapi *drsuapi,
- struct becomeDC_partition *partition,
+ struct libnet_BecomeDC_Partition *partition,
void (*recv_fn)(struct rpc_request *req));
static void becomeDC_drsuapi2_update_refs_schema_recv(struct rpc_request *req);
@@ -1857,7 +1831,7 @@ static void becomeDC_drsuapi3_pull_domain_recv(struct rpc_request *req)
static void becomeDC_drsuapi_update_refs_send(struct libnet_BecomeDC_state *s,
struct becomeDC_drsuapi *drsuapi,
- struct becomeDC_partition *partition,
+ struct libnet_BecomeDC_Partition *partition,
void (*recv_fn)(struct rpc_request *req))
{
struct composite_context *c = s->creq;
diff --git a/source4/libnet/libnet_become_dc.h b/source4/libnet/libnet_become_dc.h
index 7549e369e4..1ddf2a3073 100644
--- a/source4/libnet/libnet_become_dc.h
+++ b/source4/libnet/libnet_become_dc.h
@@ -18,6 +18,11 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#ifndef _LIBNET_BECOME_DC_H
+#define _LIBNET_BECOME_DC_H
+
+#include "librpc/gen_ndr/drsuapi.h"
+
struct libnet_BecomeDC_Domain {
/* input */
const char *dns_name;
@@ -82,15 +87,43 @@ struct libnet_BecomeDC_PrepareDB {
const struct libnet_BecomeDC_DestDSA *dest_dsa;
};
+struct libnet_BecomeDC_StoreChunk;
+
+struct libnet_BecomeDC_Partition {
+ struct drsuapi_DsReplicaObjectIdentifier nc;
+ struct GUID destination_dsa_guid;
+ struct GUID source_dsa_guid;
+ struct GUID source_dsa_invocation_id;
+ struct drsuapi_DsReplicaHighWaterMark highwatermark;
+ uint32_t replica_flags;
+
+ NTSTATUS (*store_chunk)(void *private_data,
+ const struct libnet_BecomeDC_StoreChunk *info);
+};
+
+struct libnet_BecomeDC_StoreChunk {
+ const struct libnet_BecomeDC_Domain *domain;
+ const struct libnet_BecomeDC_Forest *forest;
+ const struct libnet_BecomeDC_SourceDSA *source_dsa;
+ const struct libnet_BecomeDC_DestDSA *dest_dsa;
+ const struct libnet_BecomeDC_Partition *partition;
+ uint32_t ctr_level;
+ const struct drsuapi_DsGetNCChangesCtr1 *ctr1;
+ const struct drsuapi_DsGetNCChangesCtr6 *ctr6;
+};
+
struct libnet_BecomeDC_Callbacks {
void *private_data;
NTSTATUS (*check_options)(void *private_data,
const struct libnet_BecomeDC_CheckOptions *info);
NTSTATUS (*prepare_db)(void *private_data,
const struct libnet_BecomeDC_PrepareDB *info);
- NTSTATUS (*schema_chunk)(void *private_data, void *todo);
- NTSTATUS (*config_chunk)(void *private_data, void *todo);
- NTSTATUS (*domain_chunk)(void *private_data, void *todo);
+ NTSTATUS (*schema_chunk)(void *private_data,
+ const struct libnet_BecomeDC_StoreChunk *info);
+ NTSTATUS (*config_chunk)(void *private_data,
+ const struct libnet_BecomeDC_StoreChunk *info);
+ NTSTATUS (*domain_chunk)(void *private_data,
+ const struct libnet_BecomeDC_StoreChunk *info);
};
struct libnet_BecomeDC {
@@ -108,3 +141,5 @@ struct libnet_BecomeDC {
const char *error_string;
} out;
};
+
+#endif /* _LIBNET_BECOME_DC_H */
diff --git a/source4/torture/libnet/libnet_BecomeDC.c b/source4/torture/libnet/libnet_BecomeDC.c
index 561ad622bb..fdb2cc3214 100644
--- a/source4/torture/libnet/libnet_BecomeDC.c
+++ b/source4/torture/libnet/libnet_BecomeDC.c
@@ -77,6 +77,15 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data,
return NT_STATUS_OK;
}
+static NTSTATUS test_become_dc_store_chunk(void *private_data,
+ const struct libnet_BecomeDC_StoreChunk *c)
+{
+ DEBUG(0,("Partition[%s]\n",
+ c->partition->nc.dn));
+
+ return NT_STATUS_OK;
+}
+
BOOL torture_net_become_dc(struct torture_context *torture)
{
BOOL ret = True;
@@ -110,6 +119,9 @@ BOOL torture_net_become_dc(struct torture_context *torture)
b.in.callbacks.private_data = tj;
b.in.callbacks.check_options = test_become_dc_check_options;
b.in.callbacks.prepare_db = test_become_dc_prepare_db;
+ b.in.callbacks.schema_chunk = test_become_dc_store_chunk;
+ b.in.callbacks.config_chunk = test_become_dc_store_chunk;
+ b.in.callbacks.domain_chunk = test_become_dc_store_chunk;
status = libnet_BecomeDC(ctx, ctx, &b);
if (!NT_STATUS_IS_OK(status)) {