summaryrefslogtreecommitdiff
path: root/source4/torture/util_provision.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/torture/util_provision.c')
-rw-r--r--source4/torture/util_provision.c149
1 files changed, 95 insertions, 54 deletions
diff --git a/source4/torture/util_provision.c b/source4/torture/util_provision.c
index 418137cbeb..bc4f3d2b28 100644
--- a/source4/torture/util_provision.c
+++ b/source4/torture/util_provision.c
@@ -23,6 +23,7 @@
#include "lib/appweb/ejs/ejsInternal.h"
#include "scripting/ejs/smbcalls.h"
#include "auth/auth.h"
+#include "lib/ldb_wrap.h"
static EjsId eid;
static int ejs_error;
@@ -88,7 +89,18 @@ static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx,
const struct GUID *invocation_id,
const char *netbios_name,
const char *realm,
- const char *domain)
+ const char *domain,
+ const struct GUID *ntds_guid,
+ const char *ntds_dn_str,
+ const char *machine_password,
+ const char *samdb_ldb,
+ const char *secrets_ldb,
+ const char *secrets_keytab,
+ const char *schemadn_ldb,
+ const char *configdn_ldb,
+ const char *domaindn_ldb,
+ const char *templates_ldb,
+ const char *dns_keytab)
{
char *ejs;
int ret;
@@ -102,25 +114,25 @@ static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx,
DEBUG(0,("DSA Instance [%s]\n"
"\tobjectGUID[%s]\n"
"\tinvocationId[%s]\n",
- p->dest_dsa->ntds_dn_str,
- GUID_string(mem_ctx, &p->dest_dsa->ntds_guid),
+ ntds_dn_str,
+ GUID_string(mem_ctx, ntds_guid),
GUID_string(mem_ctx, invocation_id)));
DEBUG(0,("Pathes under PRIVATEDIR[%s]\n"
"SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n",
lp_private_dir(lp_ctx),
- s->path.samdb_ldb,
- s->path.secrets_ldb,
- s->path.secrets_keytab));
+ samdb_ldb,
+ secrets_ldb,
+ secrets_keytab));
DEBUG(0,("Schema Partition[%s => %s]\n",
- schema_dn_str, s->path.schemadn_ldb));
+ schema_dn_str, schemadn_ldb));
DEBUG(0,("Config Partition[%s => %s]\n",
- config_dn_str, s->path.configdn_ldb));
+ config_dn_str, configdn_ldb));
DEBUG(0,("Domain Partition[%s => %s]\n",
- domain_dn_str, s->path.domaindn_ldb));
+ domain_dn_str, domaindn_ldb));
ejs = talloc_asprintf(mem_ctx,
"libinclude(\"base.js\");\n"
@@ -160,21 +172,21 @@ static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx,
"return 0;\n",
root_dn_str, /* subobj.ROOTDN */
domain_dn_str, /* subobj.DOMAINDN */
- s->path.domaindn_ldb, /* subobj.DOMAINDN_LDB */
+ domaindn_ldb, /* subobj.DOMAINDN_LDB */
config_dn_str, /* subobj.CONFIGDN */
- s->path.configdn_ldb, /* subobj.CONFIGDN_LDB */
+ configdn_ldb, /* subobj.CONFIGDN_LDB */
schema_dn_str, /* subobj.SCHEMADN */
- s->path.schemadn_ldb, /* subobj.SCHEMADN_LDB */
+ schemadn_ldb, /* subobj.SCHEMADN_LDB */
netbios_name, /* subobj.HOSTNAME */
realm,/* subobj.REALM */
domain,/* subobj.DOMAIN */
site_name, /* subobj.DEFAULTSITE */
- cli_credentials_get_password(s->machine_account),/* subobj.MACHINEPASS */
- s->path.samdb_ldb, /* paths.samdb */
- s->path.templates_ldb, /* paths.templates */
- s->path.secrets_ldb, /* paths.secrets */
- s->path.secrets_keytab, /* paths.keytab */
- s->path.dns_keytab); /* paths.dns_keytab */
+ machine_password,/* subobj.MACHINEPASS */
+ samdb_ldb, /* paths.samdb */
+ templates_ldb, /* paths.templates */
+ secrets_ldb, /* paths.secrets */
+ secrets_keytab, /* paths.keytab */
+ dns_keytab); /* paths.dns_keytab */
NT_STATUS_HAVE_NO_MEMORY(ejs);
ret = test_run_ejs(ejs);
@@ -186,17 +198,15 @@ static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx,
}
talloc_free(ejs);
- talloc_free(ldb);
-
DEBUG(0,("Open the SAM LDB with system credentials: %s\n",
- s->path.samdb_ldb));
+ samdb_ldb));
- ldb = ldb_wrap_connect(mem_ctx, lp_ctx, s->path.samdb_ldb,
+ ldb = ldb_wrap_connect(mem_ctx, lp_ctx, samdb_ldb,
system_session(mem_ctx, lp_ctx),
NULL, 0, NULL);
if (!ldb) {
DEBUG(0,("Failed to open '%s'\n",
- s->path.samdb_ldb));
+ samdb_ldb));
return NT_STATUS_INTERNAL_DB_ERROR;
}
@@ -205,7 +215,7 @@ static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx,
DEBUG(0,("Failed to set cached ntds invocationId\n"));
return NT_STATUS_FOOBAR;
}
- ok = samdb_set_ntds_objectGUID(ldb, &p->dest_dsa->ntds_guid);
+ ok = samdb_set_ntds_objectGUID(ldb, ntds_guid);
if (!ok) {
DEBUG(0,("Failed to set cached ntds objectGUID\n"));
return NT_STATUS_FOOBAR;
@@ -227,10 +237,23 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx,
const char *config_dn_str,
const char *schema_dn_str,
const struct GUID *invocation_id,
- const char *domain)
+ const char *netbios_name, const char *realm,
+ const char *domain,
+ const struct GUID *ntds_guid,
+ const char *ntds_dn_str,
+ const char *machine_password,
+ const char *samdb_ldb,
+ const char *secrets_ldb,
+ const char *secrets_keytab,
+ const char *schemadn_ldb,
+ const char *configdn_ldb,
+ const char *domaindn_ldb,
+ const char *templates_ldb,
+ const char *dns_keytab)
{
bool ok;
PyObject *provision_fn, *result, *parameters;
+ struct ldb_context *ldb;
DEBUG(0,("Provision for Become-DC test using PYTHON\n"));
@@ -251,42 +274,42 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx,
DEBUG(0,("DSA Instance [%s]\n"
"\tobjectGUID[%s]\n"
"\tinvocationId[%s]\n",
- p->dest_dsa->ntds_dn_str,
- GUID_string(mem_ctx, &p->dest_dsa->ntds_guid),
+ ntds_dn_str,
+ GUID_string(mem_ctx, ntds_guid),
GUID_string(mem_ctx, invocation_id)));
DEBUG(0,("Pathes under PRIVATEDIR[%s]\n"
"SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n",
lp_private_dir(lp_ctx),
- s->path.samdb_ldb,
- s->path.secrets_ldb,
- s->path.secrets_keytab));
+ samdb_ldb,
+ secrets_ldb,
+ secrets_keytab));
DEBUG(0,("Schema Partition[%s => %s]\n",
- schema_dn_str, s->path.schemadn_ldb));
+ schema_dn_str, schemadn_ldb));
DEBUG(0,("Config Partition[%s => %s]\n",
- config_dn_str, s->path.configdn_ldb));
+ config_dn_str, configdn_ldb));
DEBUG(0,("Domain Partition[%s => %s]\n",
- domain_dn_str, s->path.domaindn_ldb));
+ domain_dn_str, domaindn_ldb));
parameters = PyDict_New();
PyDict_SetItemString(parameters, "rootdn", PyString_FromString(root_dn_str));
PyDict_SetItemString(parameters, "domaindn", PyString_FromString(domain_dn_str));
- PyDict_SetItemString(parameters, "domaindn_ldb", PyString_FromString(s->path.domaindn_ldb));
+ PyDict_SetItemString(parameters, "domaindn_ldb", PyString_FromString(domaindn_ldb));
PyDict_SetItemString(parameters, "configdn", PyString_FromString(config_dn_str));
- PyDict_SetItemString(parameters, "configdn_ldb", PyString_FromString(s->path.configdn_ldb));
+ PyDict_SetItemString(parameters, "configdn_ldb", PyString_FromString(configdn_ldb));
PyDict_SetItemString(parameters, "schema_dn_str", PyString_FromString(schema_dn_str));
- PyDict_SetItemString(parameters, "schemadn_ldb", PyString_FromString(s->path.schemadn_ldb));
+ PyDict_SetItemString(parameters, "schemadn_ldb", PyString_FromString(schemadn_ldb));
PyDict_SetItemString(parameters, "netbios_name", PyString_FromString(netbios_name));
PyDict_SetItemString(parameters, "dnsname", PyString_FromString(dns_name));
PyDict_SetItemString(parameters, "defaultsite", PyString_FromString(site_name));
- PyDict_SetItemString(parameters, "machinepass", PyString_FromString(cli_credentials_get_password(s->machine_account)));
- PyDict_SetItemString(parameters, "samdb", PyString_FromString(s->path.samdb_ldb));
- PyDict_SetItemString(parameters, "secrets_ldb", PyString_FromString(s->path.secrets_ldb));
- PyDict_SetItemString(parameters, "secrets_keytab", PyString_FromString(s->path.secrets_keytab));
+ PyDict_SetItemString(parameters, "machinepass", PyString_FromString(machine_password));
+ PyDict_SetItemString(parameters, "samdb", PyString_FromString(samdb_ldb));
+ PyDict_SetItemString(parameters, "secrets_ldb", PyString_FromString(secrets_ldb));
+ PyDict_SetItemString(parameters, "secrets_keytab", PyString_FromString(secrets_keytab));
result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters);
@@ -298,17 +321,15 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx,
return NT_STATUS_UNSUCCESSFUL;
}
- talloc_free(ldb);
-
DEBUG(0,("Open the SAM LDB with system credentials: %s\n",
- s->path.samdb_ldb));
+ samdb_ldb));
- ldb = ldb_wrap_connect(s, lp_ctx, s->path.samdb_ldb,
- system_session(s, lp_ctx),
+ ldb = ldb_wrap_connect(mem_ctx, lp_ctx, samdb_ldb,
+ system_session(mem_ctx, lp_ctx),
NULL, 0, NULL);
if (!ldb) {
DEBUG(0,("Failed to open '%s'\n",
- s->path.samdb_ldb));
+ samdb_ldb));
return NT_STATUS_INTERNAL_DB_ERROR;
}
@@ -317,7 +338,7 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx,
DEBUG(0,("Failed to set cached ntds invocationId\n"));
return NT_STATUS_FOOBAR;
}
- ok = samdb_set_ntds_objectGUID(ldb, &p->dest_dsa->ntds_guid);
+ ok = samdb_set_ntds_objectGUID(ldb, ntds_guid);
if (!ok) {
DEBUG(0,("Failed to set cached ntds objectGUID\n"));
return NT_STATUS_FOOBAR;
@@ -332,16 +353,36 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
const char *config_dn_str, const char *schema_dn_str,
const struct GUID *invocation_id,
const char *netbios_name, const char *realm,
- const char *domain)
+ const char *domain, const struct GUID *ntds_guid,
+ const char *ntds_dn_str,
+ const char *machine_password,
+ const char *samdb_ldb,
+ const char *secrets_ldb,
+ const char *secrets_keytab,
+ const char *schemadn_ldb,
+ const char *configdn_ldb,
+ const char *domaindn_ldb,
+ const char *templates_ldb,
+ const char *dns_keytab)
{
if (getenv("PROVISION_EJS")) {
- provision_bare_ejs(mem_ctx, lp_ctx, dns_name, site_name, root_dn_str,
- domain_dn_str, config_dn_str, schema_dn_str,
- invocation_id, netbios_name, realm, domain);
+ return provision_bare_ejs(mem_ctx, lp_ctx, dns_name, site_name,
+ root_dn_str, domain_dn_str, config_dn_str,
+ schema_dn_str, invocation_id, netbios_name,
+ realm, domain, ntds_guid, ntds_dn_str,
+ machine_password, samdb_ldb, secrets_ldb,
+ secrets_keytab, schemadn_ldb, configdn_ldb,
+ domaindn_ldb, templates_ldb,
+ dns_keytab);
} else {
- provision_bare_py(mem_ctx, lp_ctx, dns_name, site_name, root_dn_str,
- domain_dn_str, config_dn_str, schema_dn_str,
- invocation_id, netbios_name, realm, domain);
+ return provision_bare_py(mem_ctx, lp_ctx, dns_name, site_name,
+ root_dn_str, domain_dn_str, config_dn_str,
+ schema_dn_str, invocation_id, netbios_name,
+ realm, domain, ntds_guid, ntds_dn_str,
+ machine_password, samdb_ldb, secrets_ldb,
+ secrets_keytab, schemadn_ldb, configdn_ldb,
+ domaindn_ldb, templates_ldb,
+ dns_keytab);
}
}