mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
r20575: apply records to the test_samdb.ldb (my birthday present to myself...:-)
we need to modify some modules to only handle originating changes...
metze
(This used to be commit 0f387d58e6
)
This commit is contained in:
parent
33009ef6ad
commit
b31875ba75
@ -470,6 +470,9 @@ function provision_become_dc(subobj, message, paths, session_info)
|
||||
message("Setting up " + paths.samdb + " rootDSE\n");
|
||||
setup_add_ldif("provision_rootdse_add.ldif", info, samdb, false);
|
||||
|
||||
message("Erasing data from partitions\n");
|
||||
ldb_erase_partitions(info, samdb, undefined);
|
||||
|
||||
ok = samdb.transaction_commit();
|
||||
assert(ok);
|
||||
|
||||
|
@ -35,7 +35,8 @@
|
||||
#include "librpc/gen_ndr/ndr_drsblobs.h"
|
||||
#include "librpc/gen_ndr/ndr_misc.h"
|
||||
#include "system/time.h"
|
||||
|
||||
#include "auth/auth.h"
|
||||
#include "lib/db_wrap.h"
|
||||
#include "lib/appweb/ejs/ejs.h"
|
||||
#include "lib/appweb/ejs/ejsInternal.h"
|
||||
#include "scripting/ejs/smbcalls.h"
|
||||
@ -94,6 +95,7 @@ failed:
|
||||
}
|
||||
|
||||
#define TORTURE_NETBIOS_NAME "smbtorturedc"
|
||||
#define TORTURE_SAMDB_LDB "test_samdb.ldb"
|
||||
|
||||
struct test_become_dc_state {
|
||||
struct libnet_context *ctx;
|
||||
@ -174,8 +176,25 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data,
|
||||
"subobj.DNSNAME = \"%s\";\n"
|
||||
"subobj.DEFAULTSITE = \"%s\";\n"
|
||||
"\n"
|
||||
"modules_list = new Array(\"rootdse\",\n"
|
||||
" \"kludge_acl\",\n"
|
||||
" \"paged_results\",\n"
|
||||
" \"server_sort\",\n"
|
||||
" \"extended_dn\",\n"
|
||||
" \"asq\",\n"
|
||||
" //\"samldb\",should only handle originating changes...\n"
|
||||
" \"password_hash\",\n"
|
||||
" \"operational\",\n"
|
||||
" \"objectclass\",\n"
|
||||
" \"rdn_name\",\n"
|
||||
" \"partition\");\n"
|
||||
"subobj.MODULES_LIST = join(\",\", modules_list);\n"
|
||||
"subobj.DOMAINDN_MOD = \"objectguid\";\n"
|
||||
"subobj.CONFIGDN_MOD = \"objectguid\";\n"
|
||||
"subobj.SCHEMADN_MOD = \"objectguid\";\n"
|
||||
"\n"
|
||||
"var paths = provision_default_paths(subobj);\n"
|
||||
"paths.samdb = \"test_samdb.ldb\";\n"
|
||||
"paths.samdb = \"%s\";\n"
|
||||
"\n"
|
||||
"var system_session = system_session();\n"
|
||||
"\n"
|
||||
@ -189,7 +208,8 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data,
|
||||
p->forest->schema_dn_str,
|
||||
p->dest_dsa->netbios_name,
|
||||
p->dest_dsa->dns_name,
|
||||
p->dest_dsa->site_name);
|
||||
p->dest_dsa->site_name,
|
||||
TORTURE_SAMDB_LDB);
|
||||
NT_STATUS_HAVE_NO_MEMORY(ejs);
|
||||
|
||||
ret = test_run_ejs(ejs);
|
||||
@ -199,9 +219,24 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data,
|
||||
talloc_free(ejs);
|
||||
return NT_STATUS_FOOBAR;
|
||||
}
|
||||
|
||||
talloc_free(ejs);
|
||||
|
||||
talloc_free(s->ldb);
|
||||
|
||||
s->ldb = ldb_wrap_connect(s, TORTURE_SAMDB_LDB,
|
||||
system_session(s),
|
||||
NULL, 0, NULL);
|
||||
if (!s->ldb) {
|
||||
DEBUG(0,("Failed to open '%s'\n",
|
||||
TORTURE_SAMDB_LDB));
|
||||
return NT_STATUS_INTERNAL_DB_ERROR;
|
||||
}
|
||||
|
||||
ret = ldb_transaction_start(s->ldb);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||
}
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
@ -232,6 +267,14 @@ static WERROR test_object_to_ldb(struct test_become_dc_state *s,
|
||||
struct drsuapi_DsReplicaObjMetaData *rdn_mc;
|
||||
int ret;
|
||||
|
||||
if (!obj->object.identifier) {
|
||||
return WERR_FOOBAR;
|
||||
}
|
||||
|
||||
if (!obj->object.identifier->dn || !obj->object.identifier->dn[0]) {
|
||||
return WERR_FOOBAR;
|
||||
}
|
||||
|
||||
msg = ldb_msg_new(mem_ctx);
|
||||
W_ERROR_HAVE_NO_MEMORY(msg);
|
||||
|
||||
@ -381,6 +424,18 @@ static WERROR test_object_to_ldb(struct test_become_dc_state *s,
|
||||
NDR_PRINT_DEBUG(drsuapi_DsReplicaObjMetaDataCtr, &mdc);
|
||||
}
|
||||
|
||||
ret = ldb_add(s->ldb, msg);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
|
||||
DEBUG(0,("record exists (ignored): %s: %d\n",
|
||||
obj->object.identifier->dn, ret));
|
||||
} else {
|
||||
DEBUG(0,("Failed to add record: %s: %d\n",
|
||||
obj->object.identifier->dn, ret));
|
||||
return WERR_FOOBAR;
|
||||
}
|
||||
}
|
||||
|
||||
*_msg = msg;
|
||||
return WERR_OK;
|
||||
}
|
||||
@ -390,6 +445,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
|
||||
{
|
||||
WERROR status;
|
||||
struct drsuapi_DsReplicaObjectListItemEx *cur;
|
||||
int ret;
|
||||
|
||||
for (cur = s->schema_part.first_object; cur; cur = cur->next_object) {
|
||||
uint32_t i;
|
||||
@ -468,6 +524,17 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
|
||||
}
|
||||
}
|
||||
|
||||
ret = ldb_transaction_commit(s->ldb);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
DEBUG(0,("Failed to commit the schema changes: %d\n", ret));
|
||||
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||
}
|
||||
|
||||
ret = ldb_transaction_start(s->ldb);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||
}
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
@ -551,6 +618,7 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data,
|
||||
uint32_t linked_attributes_count;
|
||||
struct drsuapi_DsReplicaLinkedAttribute *linked_attributes;
|
||||
uint32_t i;
|
||||
int ret;
|
||||
|
||||
switch (c->ctr_level) {
|
||||
case 1:
|
||||
@ -620,6 +688,17 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data,
|
||||
}
|
||||
}
|
||||
|
||||
ret = ldb_transaction_commit(s->ldb);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
DEBUG(0,("Failed to commit the changes: %d\n", ret));
|
||||
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||
}
|
||||
|
||||
ret = ldb_transaction_start(s->ldb);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||
}
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user