summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-02-15 02:12:37 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-02-15 02:12:37 +0100
commitb5f329602b3cd044cabb9ea0945724a307139eb9 (patch)
treedfda7ae675124376464f66a55fc43bf86d5979e2 /source4/torture
parentd499dfd9388f39d0b45ba586169bd3c4b7138dd7 (diff)
downloadsamba-b5f329602b3cd044cabb9ea0945724a307139eb9.tar.gz
samba-b5f329602b3cd044cabb9ea0945724a307139eb9.tar.bz2
samba-b5f329602b3cd044cabb9ea0945724a307139eb9.zip
Add ability to not specify certain provision options(), fix some other options.
(This used to be commit fe8bfda22d8e1fdbece4209b7489419074565efd)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/util_provision.c66
1 files changed, 47 insertions, 19 deletions
diff --git a/source4/torture/util_provision.c b/source4/torture/util_provision.c
index bc4f3d2b28..5873b9f485 100644
--- a/source4/torture/util_provision.c
+++ b/source4/torture/util_provision.c
@@ -252,22 +252,36 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx,
const char *dns_keytab)
{
bool ok;
- PyObject *provision_fn, *result, *parameters;
+ PyObject *provision_mod, *provision_dict, *provision_fn, *result, *parameters;
struct ldb_context *ldb;
DEBUG(0,("Provision for Become-DC test using PYTHON\n"));
py_load_samba_modules();
Py_Initialize();
+ py_update_path("bin"); /* FIXME: Can't assume this is always the case */
- py_update_path("bin"); /* FIXME: Can't assume this always runs in source/... */
+ provision_mod = PyImport_Import(PyString_FromString("samba.provision"));
- provision_fn = PyImport_Import(PyString_FromString("samba.provision.provision"));
-
- if (provision_fn == NULL) {
+ if (provision_mod == NULL) {
+ PyErr_Print();
DEBUG(0, ("Unable to import provision Python module.\n"));
return NT_STATUS_UNSUCCESSFUL;
}
+
+ provision_dict = PyModule_GetDict(provision_mod);
+
+ if (provision_dict == NULL) {
+ DEBUG(0, ("Unable to get dictionary for provision module\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ provision_fn = PyDict_GetItemString(provision_dict, "provision");
+ if (provision_fn == NULL) {
+ PyErr_Print();
+ DEBUG(0, ("Unable to get provision function\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
DEBUG(0,("New Server[%s] in Site[%s]\n", dns_name, site_name));
@@ -275,8 +289,8 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx,
"\tobjectGUID[%s]\n"
"\tinvocationId[%s]\n",
ntds_dn_str,
- GUID_string(mem_ctx, ntds_guid),
- GUID_string(mem_ctx, invocation_id)));
+ ntds_guid == NULL?"None":GUID_string(mem_ctx, ntds_guid),
+ invocation_id == NULL?"None":GUID_string(mem_ctx, invocation_id)));
DEBUG(0,("Pathes under PRIVATEDIR[%s]\n"
"SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n",
@@ -297,19 +311,33 @@ static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx,
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(domaindn_ldb));
- PyDict_SetItemString(parameters, "configdn", PyString_FromString(config_dn_str));
- 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(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));
+ if (domaindn_ldb != NULL)
+ PyDict_SetItemString(parameters, "domaindn_ldb",
+ PyString_FromString(domaindn_ldb));
+ if (config_dn_str != NULL)
+ PyDict_SetItemString(parameters, "configdn",
+ PyString_FromString(config_dn_str));
+ if (configdn_ldb != NULL)
+ PyDict_SetItemString(parameters, "configdn_ldb",
+ PyString_FromString(configdn_ldb));
+ if (schema_dn_str != NULL)
+ PyDict_SetItemString(parameters, "schema_dn_str",
+ PyString_FromString(schema_dn_str));
+ if (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));
- 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));
+ if (samdb_ldb != NULL)
+ PyDict_SetItemString(parameters, "samdb",
+ PyString_FromString(samdb_ldb));
+ if (secrets_ldb != NULL)
+ PyDict_SetItemString(parameters, "secrets_ldb",
+ PyString_FromString(secrets_ldb));
+ if (secrets_keytab != NULL)
+ PyDict_SetItemString(parameters, "secrets_keytab",
+ PyString_FromString(secrets_keytab));
result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters);