From 07f1075d469833e10c2f0b0d4578221c6a189b04 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 20 Dec 2006 21:14:44 +0000 Subject: [PATCH] r20291: implement prepare_db hook of libnet_BecomeDC() metze --- source/libnet/libnet_become_dc.c | 8 ++++++- source/libnet/libnet_become_dc.h | 12 ++++++++-- source/torture/libnet/libnet_BecomeDC.c | 31 ++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/source/libnet/libnet_become_dc.c b/source/libnet/libnet_become_dc.c index 7d1341e1728..3f3bfe16b64 100644 --- a/source/libnet/libnet_become_dc.c +++ b/source/libnet/libnet_become_dc.c @@ -90,6 +90,7 @@ struct libnet_BecomeDC_state { struct becomeDC_fsmo rid_manager_fsmo; struct libnet_BecomeDC_CheckOptions _co; + struct libnet_BecomeDC_PrepareDB _pp; struct libnet_BecomeDC_Callbacks callbacks; }; @@ -1481,7 +1482,12 @@ static NTSTATUS becomeDC_prepare_db(struct libnet_BecomeDC_state *s) { if (!s->callbacks.prepare_db) return NT_STATUS_OK; - return s->callbacks.prepare_db(s->callbacks.private_data, NULL); + s->_pp.domain = &s->domain; + s->_pp.forest = &s->forest; + s->_pp.source_dsa = &s->source_dsa; + s->_pp.dest_dsa = &s->dest_dsa; + + return s->callbacks.prepare_db(s->callbacks.private_data, &s->_pp); } static void becomeDC_drsuapi2_bind_recv(struct rpc_request *req); diff --git a/source/libnet/libnet_become_dc.h b/source/libnet/libnet_become_dc.h index cffa0fd1296..7549e369e4f 100644 --- a/source/libnet/libnet_become_dc.h +++ b/source/libnet/libnet_become_dc.h @@ -75,11 +75,19 @@ struct libnet_BecomeDC_DestDSA { uint32_t user_account_control; }; +struct libnet_BecomeDC_PrepareDB { + 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; +}; + struct libnet_BecomeDC_Callbacks { void *private_data; NTSTATUS (*check_options)(void *private_data, - const struct libnet_BecomeDC_CheckOptions *options); - NTSTATUS (*prepare_db)(void *private_data, void *todo); + 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); diff --git a/source/torture/libnet/libnet_BecomeDC.c b/source/torture/libnet/libnet_BecomeDC.c index 8db3b8d4480..561ad622bbe 100644 --- a/source/torture/libnet/libnet_BecomeDC.c +++ b/source/torture/libnet/libnet_BecomeDC.c @@ -30,7 +30,7 @@ #define TORTURE_NETBIOS_NAME "smbtorturedc" static NTSTATUS test_become_dc_check_options(void *private_data, - const struct libnet_BecomeDC_CheckOptions *o) + const struct libnet_BecomeDC_CheckOptions *o) { DEBUG(0,("Become DC of Domain[%s]/[%s]\n", o->domain->netbios_name, o->domain->dns_name)); @@ -50,6 +50,33 @@ static NTSTATUS test_become_dc_check_options(void *private_data, return NT_STATUS_OK; } +static NTSTATUS test_become_dc_prepare_db(void *private_data, + const struct libnet_BecomeDC_PrepareDB *p) +{ + struct test_join *tj = talloc_get_type(private_data, struct test_join); + + DEBUG(0,("New Server[%s] in Site[%s]\n", + p->dest_dsa->dns_name, p->dest_dsa->site_name)); + + DEBUG(0,("DSA Instance [%s]\n" + "\tobjectGUID[%s]\n" + "\tinvocationId[%s]\n", + p->dest_dsa->ntds_dn_str, + GUID_string(tj, &p->dest_dsa->ntds_guid), + GUID_string(tj, &p->dest_dsa->invocation_id))); + + DEBUG(0,("Schema Partition[%s]\n", + p->forest->schema_dn_str)); + + DEBUG(0,("Config Partition[%s]\n", + p->forest->config_dn_str)); + + DEBUG(0,("Domain Partition[%s]\n", + p->domain->dn_str)); + + return NT_STATUS_OK; +} + BOOL torture_net_become_dc(struct torture_context *torture) { BOOL ret = True; @@ -80,7 +107,9 @@ BOOL torture_net_become_dc(struct torture_context *torture) b.in.source_dsa_address = lp_parm_string(-1, "torture", "host"); b.in.dest_dsa_netbios_name = TORTURE_NETBIOS_NAME; + 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; status = libnet_BecomeDC(ctx, ctx, &b); if (!NT_STATUS_IS_OK(status)) {