diff options
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/libnet/libnet_BecomeDC.c | 39 | ||||
-rw-r--r-- | source4/torture/local/torture.c | 36 | ||||
-rw-r--r-- | source4/torture/util_provision.c | 222 | ||||
-rw-r--r-- | source4/torture/util_provision.h | 51 |
4 files changed, 180 insertions, 168 deletions
diff --git a/source4/torture/libnet/libnet_BecomeDC.c b/source4/torture/libnet/libnet_BecomeDC.c index 83d7426dfb..13e1aec6d0 100644 --- a/source4/torture/libnet/libnet_BecomeDC.c +++ b/source4/torture/libnet/libnet_BecomeDC.c @@ -37,7 +37,7 @@ #include "lib/ldb_wrap.h" #include "auth/auth.h" #include "param/param.h" -#include "torture/util.h" +#include "torture/util_provision.h" struct test_become_dc_state { struct libnet_context *ctx; @@ -72,20 +72,29 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data, const struct libnet_BecomeDC_PrepareDB *p) { struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state); - return provision_bare(s, s->tctx->lp_ctx, p->dest_dsa->dns_name, - p->dest_dsa->site_name, p->forest->root_dn_str, - p->domain->dn_str, p->forest->config_dn_str, - p->forest->schema_dn_str, - &p->dest_dsa->invocation_id, - p->dest_dsa->netbios_name, - torture_join_dom_dns_name(s->tj), - torture_join_dom_netbios_name(s->tj), - &p->dest_dsa->ntds_guid, - p->dest_dsa->ntds_dn_str, - cli_credentials_get_password(s->machine_account), - s->path.samdb_ldb, s->path.secrets_ldb, - s->path.secrets_keytab, s->path.schemadn_ldb, - s->path.configdn_ldb, s->path.domaindn_ldb); + struct provision_settings settings; + + settings.dns_name = p->dest_dsa->dns_name; + settings.site_name = p->dest_dsa->site_name; + settings.root_dn_str = p->forest->root_dn_str; + settings.domain_dn_str = p->domain->dn_str; + settings.config_dn_str = p->forest->config_dn_str; + settings.schema_dn_str = p->forest->schema_dn_str; + settings.invocation_id = &p->dest_dsa->invocation_id; + settings.netbios_name = p->dest_dsa->netbios_name; + settings.realm = torture_join_dom_dns_name(s->tj); + settings.domain = torture_join_dom_netbios_name(s->tj); + settings.ntds_guid = &p->dest_dsa->ntds_guid; + settings.ntds_dn_str = p->dest_dsa->ntds_dn_str; + settings.machine_password = cli_credentials_get_password(s->machine_account); + settings.samdb_ldb = s->path.samdb_ldb; + settings.secrets_ldb = s->path.secrets_ldb; + settings.secrets_keytab = s->path.secrets_keytab; + settings.schemadn_ldb = s->path.schemadn_ldb; + settings.configdn_ldb = s->path.configdn_ldb; + settings.domaindn_ldb = s->path.domaindn_ldb; + + return provision_bare(s, s->tctx->lp_ctx, &settings); } static NTSTATUS test_become_dc_check_options(void *private_data, diff --git a/source4/torture/local/torture.c b/source4/torture/local/torture.c index 7d12c467df..0c9931be03 100644 --- a/source4/torture/local/torture.c +++ b/source4/torture/local/torture.c @@ -24,7 +24,7 @@ #include "system/wait.h" #include "lib/events/events.h" #include "libcli/raw/libcliraw.h" -#include "torture/util.h" +#include "torture/util_provision.h" static bool test_tempdir(struct torture_context *tctx) { @@ -42,18 +42,32 @@ static bool test_tempdir(struct torture_context *tctx) static bool test_provision(struct torture_context *tctx) { NTSTATUS status; + struct provision_settings settings; - status = provision_bare(tctx, tctx->lp_ctx, - "example.com", "SOME-SITE-NAME", - "DC=EXAMPLE,DC=COM", - "DC=EXAMPLE,DC=COM", - NULL, NULL, NULL, - "FOO", "EXAMPLE.COM", - "EXAMPLE", NULL, - NULL, "geheim", - NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL); + settings.dns_name = "example.com"; + settings.site_name = "SOME-SITE-NAME"; + settings.root_dn_str = "DC=EXAMPLE,DC=COM"; + settings.domain_dn_str = "DC=EXAMPLE,DC=COM"; + settings.config_dn_str = NULL; + settings.schema_dn_str = NULL; + settings.invocation_id = NULL; + settings.netbios_name = "FOO"; + settings.realm = "EXAMPLE.COM"; + settings.domain = "EXAMPLE"; + settings.ntds_guid = NULL; + settings.ntds_dn_str = NULL; + settings.machine_password = "geheim"; + settings.samdb_ldb = NULL; + settings.secrets_ldb = NULL; + settings.secrets_keytab = NULL; + settings.schemadn_ldb = NULL; + settings.configdn_ldb = NULL; + settings.domaindn_ldb = NULL; + settings.templates_ldb = NULL; + settings.dns_keytab = NULL; + status = provision_bare(tctx, tctx->lp_ctx, &settings); + torture_assert_ntstatus_ok(tctx, status, "provision"); return true; diff --git a/source4/torture/util_provision.c b/source4/torture/util_provision.c index 5873b9f485..a5c564b05c 100644 --- a/source4/torture/util_provision.c +++ b/source4/torture/util_provision.c @@ -24,6 +24,7 @@ #include "scripting/ejs/smbcalls.h" #include "auth/auth.h" #include "lib/ldb_wrap.h" +#include "torture/util_provision.h" static EjsId eid; static int ejs_error; @@ -80,27 +81,7 @@ failed: static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, - const char *dns_name, - const char *site_name, - const char *root_dn_str, - const char *domain_dn_str, - 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 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) + struct provision_settings *settings) { char *ejs; int ret; @@ -109,30 +90,31 @@ static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx, DEBUG(0,("Provision for Become-DC test using EJS\n")); - DEBUG(0,("New Server[%s] in Site[%s]\n", dns_name, site_name)); + DEBUG(0,("New Server[%s] in Site[%s]\n", settings->dns_name, + settings->site_name)); DEBUG(0,("DSA Instance [%s]\n" "\tobjectGUID[%s]\n" "\tinvocationId[%s]\n", - ntds_dn_str, - GUID_string(mem_ctx, ntds_guid), - GUID_string(mem_ctx, invocation_id))); + settings->ntds_dn_str, + GUID_string(mem_ctx, settings->ntds_guid), + GUID_string(mem_ctx, settings->invocation_id))); DEBUG(0,("Pathes under PRIVATEDIR[%s]\n" "SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n", lp_private_dir(lp_ctx), - samdb_ldb, - secrets_ldb, - secrets_keytab)); + settings->samdb_ldb, + settings->secrets_ldb, + settings->secrets_keytab)); DEBUG(0,("Schema Partition[%s => %s]\n", - schema_dn_str, schemadn_ldb)); + settings->schema_dn_str, settings->schemadn_ldb)); DEBUG(0,("Config Partition[%s => %s]\n", - config_dn_str, configdn_ldb)); + settings->config_dn_str, settings->configdn_ldb)); DEBUG(0,("Domain Partition[%s => %s]\n", - domain_dn_str, domaindn_ldb)); + settings->domain_dn_str, settings->domaindn_ldb)); ejs = talloc_asprintf(mem_ctx, "libinclude(\"base.js\");\n" @@ -170,23 +152,23 @@ static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx, "assert(ok);\n" "\n" "return 0;\n", - root_dn_str, /* subobj.ROOTDN */ - domain_dn_str, /* subobj.DOMAINDN */ - domaindn_ldb, /* subobj.DOMAINDN_LDB */ - config_dn_str, /* subobj.CONFIGDN */ - configdn_ldb, /* subobj.CONFIGDN_LDB */ - schema_dn_str, /* subobj.SCHEMADN */ - schemadn_ldb, /* subobj.SCHEMADN_LDB */ - netbios_name, /* subobj.HOSTNAME */ - realm,/* subobj.REALM */ - domain,/* subobj.DOMAIN */ - site_name, /* subobj.DEFAULTSITE */ - 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 */ + settings->root_dn_str, /* subobj.ROOTDN */ + settings->domain_dn_str, /* subobj.DOMAINDN */ + settings->domaindn_ldb, /* subobj.DOMAINDN_LDB */ + settings->config_dn_str, /* subobj.CONFIGDN */ + settings->configdn_ldb, /* subobj.CONFIGDN_LDB */ + settings->schema_dn_str, /* subobj.SCHEMADN */ + settings->schemadn_ldb, /* subobj.SCHEMADN_LDB */ + settings->netbios_name, /* subobj.HOSTNAME */ + settings->realm,/* subobj.REALM */ + settings->domain,/* subobj.DOMAIN */ + settings->site_name, /* subobj.DEFAULTSITE */ + settings->machine_password,/* subobj.MACHINEPASS */ + settings->samdb_ldb, /* paths.samdb */ + settings->templates_ldb, /* paths.templates */ + settings->secrets_ldb, /* paths.secrets */ + settings->secrets_keytab, /* paths.keytab */ + settings->dns_keytab); /* paths.dns_keytab */ NT_STATUS_HAVE_NO_MEMORY(ejs); ret = test_run_ejs(ejs); @@ -199,23 +181,23 @@ static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx, talloc_free(ejs); DEBUG(0,("Open the SAM LDB with system credentials: %s\n", - samdb_ldb)); + settings->samdb_ldb)); - ldb = ldb_wrap_connect(mem_ctx, lp_ctx, samdb_ldb, + ldb = ldb_wrap_connect(mem_ctx, lp_ctx, settings->samdb_ldb, system_session(mem_ctx, lp_ctx), NULL, 0, NULL); if (!ldb) { DEBUG(0,("Failed to open '%s'\n", - samdb_ldb)); + settings->samdb_ldb)); return NT_STATUS_INTERNAL_DB_ERROR; } - ok = samdb_set_ntds_invocation_id(ldb, invocation_id); + ok = samdb_set_ntds_invocation_id(ldb, settings->invocation_id); if (!ok) { DEBUG(0,("Failed to set cached ntds invocationId\n")); return NT_STATUS_FOOBAR; } - ok = samdb_set_ntds_objectGUID(ldb, ntds_guid); + ok = samdb_set_ntds_objectGUID(ldb, settings->ntds_guid); if (!ok) { DEBUG(0,("Failed to set cached ntds objectGUID\n")); return NT_STATUS_FOOBAR; @@ -230,32 +212,13 @@ static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx, static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, - const char *dns_name, - const char *site_name, - const char *root_dn_str, - const char *domain_dn_str, - 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 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) + struct provision_settings *settings) { bool ok; PyObject *provision_mod, *provision_dict, *provision_fn, *result, *parameters; struct ldb_context *ldb; - DEBUG(0,("Provision for Become-DC test using PYTHON\n")); + DEBUG(0,("Provision for Become-DC test using python\n")); py_load_samba_modules(); Py_Initialize(); @@ -283,61 +246,66 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx, return NT_STATUS_UNSUCCESSFUL; } - DEBUG(0,("New Server[%s] in Site[%s]\n", dns_name, site_name)); + DEBUG(0,("New Server[%s] in Site[%s]\n", settings->dns_name, + settings->site_name)); DEBUG(0,("DSA Instance [%s]\n" "\tobjectGUID[%s]\n" "\tinvocationId[%s]\n", - ntds_dn_str, - ntds_guid == NULL?"None":GUID_string(mem_ctx, ntds_guid), - invocation_id == NULL?"None":GUID_string(mem_ctx, invocation_id))); + settings->ntds_dn_str, + settings->ntds_guid == NULL?"None":GUID_string(mem_ctx, settings->ntds_guid), + settings->invocation_id == NULL?"None":GUID_string(mem_ctx, settings->invocation_id))); DEBUG(0,("Pathes under PRIVATEDIR[%s]\n" "SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n", lp_private_dir(lp_ctx), - samdb_ldb, - secrets_ldb, - secrets_keytab)); + settings->samdb_ldb, + settings->secrets_ldb, + settings->secrets_keytab)); DEBUG(0,("Schema Partition[%s => %s]\n", - schema_dn_str, schemadn_ldb)); + settings->schema_dn_str, settings->schemadn_ldb)); DEBUG(0,("Config Partition[%s => %s]\n", - config_dn_str, configdn_ldb)); + settings->config_dn_str, settings->configdn_ldb)); DEBUG(0,("Domain Partition[%s => %s]\n", - domain_dn_str, domaindn_ldb)); + settings->domain_dn_str, settings->domaindn_ldb)); parameters = PyDict_New(); - PyDict_SetItemString(parameters, "rootdn", PyString_FromString(root_dn_str)); - if (domaindn_ldb != NULL) + PyDict_SetItemString(parameters, "rootdn", + PyString_FromString(settings->root_dn_str)); + if (settings->domaindn_ldb != NULL) PyDict_SetItemString(parameters, "domaindn_ldb", - PyString_FromString(domaindn_ldb)); - if (config_dn_str != NULL) + PyString_FromString(settings->domaindn_ldb)); + if (settings->config_dn_str != NULL) PyDict_SetItemString(parameters, "configdn", - PyString_FromString(config_dn_str)); - if (configdn_ldb != NULL) + PyString_FromString(settings->config_dn_str)); + if (settings->configdn_ldb != NULL) PyDict_SetItemString(parameters, "configdn_ldb", - PyString_FromString(configdn_ldb)); - if (schema_dn_str != NULL) + PyString_FromString(settings->configdn_ldb)); + if (settings->schema_dn_str != NULL) PyDict_SetItemString(parameters, "schema_dn_str", - PyString_FromString(schema_dn_str)); - if (schemadn_ldb != NULL) + PyString_FromString(settings->schema_dn_str)); + if (settings->schemadn_ldb != NULL) PyDict_SetItemString(parameters, "schemadn_ldb", - PyString_FromString(schemadn_ldb)); - PyDict_SetItemString(parameters, "hostname", PyString_FromString(netbios_name)); - PyDict_SetItemString(parameters, "sitename", PyString_FromString(site_name)); - PyDict_SetItemString(parameters, "machinepass", PyString_FromString(machine_password)); - if (samdb_ldb != NULL) + PyString_FromString(settings->schemadn_ldb)); + PyDict_SetItemString(parameters, "hostname", + PyString_FromString(settings->netbios_name)); + PyDict_SetItemString(parameters, "sitename", + PyString_FromString(settings->site_name)); + PyDict_SetItemString(parameters, "machinepass", + PyString_FromString(settings->machine_password)); + if (settings->samdb_ldb != NULL) PyDict_SetItemString(parameters, "samdb", - PyString_FromString(samdb_ldb)); - if (secrets_ldb != NULL) + PyString_FromString(settings->samdb_ldb)); + if (settings->secrets_ldb != NULL) PyDict_SetItemString(parameters, "secrets_ldb", - PyString_FromString(secrets_ldb)); - if (secrets_keytab != NULL) + PyString_FromString(settings->secrets_ldb)); + if (settings->secrets_keytab != NULL) PyDict_SetItemString(parameters, "secrets_keytab", - PyString_FromString(secrets_keytab)); + PyString_FromString(settings->secrets_keytab)); result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters); @@ -350,23 +318,22 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx, } DEBUG(0,("Open the SAM LDB with system credentials: %s\n", - samdb_ldb)); + settings->samdb_ldb)); - ldb = ldb_wrap_connect(mem_ctx, lp_ctx, samdb_ldb, + ldb = ldb_wrap_connect(mem_ctx, lp_ctx, settings->samdb_ldb, system_session(mem_ctx, lp_ctx), NULL, 0, NULL); if (!ldb) { - DEBUG(0,("Failed to open '%s'\n", - samdb_ldb)); + DEBUG(0,("Failed to open '%s'\n", settings->samdb_ldb)); return NT_STATUS_INTERNAL_DB_ERROR; } - ok = samdb_set_ntds_invocation_id(ldb, invocation_id); + ok = samdb_set_ntds_invocation_id(ldb, settings->invocation_id); if (!ok) { DEBUG(0,("Failed to set cached ntds invocationId\n")); return NT_STATUS_FOOBAR; } - ok = samdb_set_ntds_objectGUID(ldb, ntds_guid); + ok = samdb_set_ntds_objectGUID(ldb, settings->ntds_guid); if (!ok) { DEBUG(0,("Failed to set cached ntds objectGUID\n")); return NT_STATUS_FOOBAR; @@ -376,41 +343,12 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx, } NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, - const char *dns_name, const char *site_name, - const char *root_dn_str, const char *domain_dn_str, - 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 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) + struct provision_settings *settings) { if (getenv("PROVISION_EJS")) { - 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); + return provision_bare_ejs(mem_ctx, lp_ctx, settings); } else { - 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); + return provision_bare_py(mem_ctx, lp_ctx, settings); } } diff --git a/source4/torture/util_provision.h b/source4/torture/util_provision.h new file mode 100644 index 0000000000..28467080b1 --- /dev/null +++ b/source4/torture/util_provision.h @@ -0,0 +1,51 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _TORTURE_PROVISION_H_ +#define _TORTURE_PROVISION_H_ + +struct provision_settings { + const char *dns_name; + const char *site_name; + const char *root_dn_str; + const char *domain_dn_str; + 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 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; +}; + +NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, + struct provision_settings *settings); + + +#endif /* _TORTURE_PROVISION_H_ */ |