From 82c7872639d48a2791e409f8cd014978c4aa352f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 9 Apr 2008 03:23:13 +0200 Subject: Move provision C bindings to param/. (This used to be commit 7d45ed0c3ebc57f7131603f768f8e022d7139530) --- source4/param/config.mk | 4 ++ source4/param/provision.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++ source4/param/provision.h | 45 ++++++++++++++++ 3 files changed, 178 insertions(+) create mode 100644 source4/param/provision.c create mode 100644 source4/param/provision.h (limited to 'source4/param') diff --git a/source4/param/config.mk b/source4/param/config.mk index eee22cf1b81..064c293fa44 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -12,6 +12,10 @@ PRIVATE_PROTO_HEADER = proto.h PUBLIC_HEADERS += param/param.h +[SUBSYSTEM::PROVISION] +OBJ_FILES = provision.o +PRIVATE_DEPENDENCIES = LIBPYTHON + ################################# # Start SUBSYSTEM share [SUBSYSTEM::share] diff --git a/source4/param/provision.c b/source4/param/provision.c new file mode 100644 index 00000000000..5d1f01c59a7 --- /dev/null +++ b/source4/param/provision.c @@ -0,0 +1,129 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij 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 . +*/ + +#include "includes.h" +#include "auth/auth.h" +#include "lib/ldb_wrap.h" +#include "libcli/raw/libcliraw.h" +#include "librpc/ndr/libndr.h" + +#include "param/param.h" +#include "param/provision.h" +#include +#include "scripting/python/modules.h" + +NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, + struct provision_settings *settings) +{ + PyObject *provision_mod, *provision_dict, *provision_fn, *result, *parameters; + + 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 */ + + provision_mod = PyImport_Import(PyString_FromString("samba.provision")); + + 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_become_dc"); + if (provision_fn == NULL) { + PyErr_Print(); + DEBUG(0, ("Unable to get provision_become_dc function\n")); + return NT_STATUS_UNSUCCESSFUL; + } + + 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", + 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 targetdir[%s]\n", + settings->targetdir)); + parameters = PyDict_New(); + + PyDict_SetItemString(parameters, "rootdn", + PyString_FromString(settings->root_dn_str)); + if (settings->targetdir != NULL) + PyDict_SetItemString(parameters, "targetdir", + PyString_FromString(settings->targetdir)); + PyDict_SetItemString(parameters, "setup_dir", + PyString_FromString("setup")); + PyDict_SetItemString(parameters, "hostname", + PyString_FromString(settings->netbios_name)); + PyDict_SetItemString(parameters, "domain", + PyString_FromString(settings->domain)); + PyDict_SetItemString(parameters, "realm", + PyString_FromString(settings->realm)); + if (settings->root_dn_str) + PyDict_SetItemString(parameters, "rootdn", + PyString_FromString(settings->root_dn_str)); + + if (settings->domain_dn_str) + PyDict_SetItemString(parameters, "domaindn", + PyString_FromString(settings->domain_dn_str)); + + if (settings->schema_dn_str) + PyDict_SetItemString(parameters, "schemadn", + PyString_FromString(settings->schema_dn_str)); + + if (settings->config_dn_str) + PyDict_SetItemString(parameters, "configdn", + PyString_FromString(settings->config_dn_str)); + + if (settings->server_dn_str) + PyDict_SetItemString(parameters, "serverdn", + PyString_FromString(settings->server_dn_str)); + + if (settings->site_name) + PyDict_SetItemString(parameters, "sitename", + PyString_FromString(settings->site_name)); + + PyDict_SetItemString(parameters, "machinepass", + PyString_FromString(settings->machine_password)); + + result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters); + + Py_DECREF(parameters); + + if (result == NULL) { + PyErr_Print(); + PyErr_Clear(); + return NT_STATUS_UNSUCCESSFUL; + } + + return NT_STATUS_OK; +} diff --git a/source4/param/provision.h b/source4/param/provision.h new file mode 100644 index 00000000000..323159d417c --- /dev/null +++ b/source4/param/provision.h @@ -0,0 +1,45 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij 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 . +*/ + +#ifndef _PROVISION_H_ +#define _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 char *server_dn_str; + const struct GUID *invocation_id; + const char *netbios_name; + const char *host_ip; + const char *realm; + const char *domain; + const struct GUID *ntds_guid; + const char *ntds_dn_str; + const char *machine_password; + const char *targetdir; +}; + +NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, + struct provision_settings *settings); + +#endif /* _PROVISION_H_ */ -- cgit From 3f990fdf7c8735d3cf34d7407bd844b1c268e23f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 9 Apr 2008 14:55:01 +1000 Subject: Remove dns_name element This is only used in the DEBUG() message, so let's remove it. Andrew Bartlett (This used to be commit 5ebb64bdad7e80ee81d6b9d84d77c03fb9237eee) --- source4/param/provision.c | 4 ++-- source4/param/provision.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/param') diff --git a/source4/param/provision.c b/source4/param/provision.c index 5d1f01c59a7..a15993ffc8c 100644 --- a/source4/param/provision.c +++ b/source4/param/provision.c @@ -61,8 +61,8 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, return NT_STATUS_UNSUCCESSFUL; } - DEBUG(0,("New Server[%s] in Site[%s]\n", settings->dns_name, - settings->site_name)); + DEBUG(0,("New Server in Site[%s]\n", + settings->site_name)); DEBUG(0,("DSA Instance [%s]\n" "\tobjectGUID[%s]\n" diff --git a/source4/param/provision.h b/source4/param/provision.h index 323159d417c..38a66966c8e 100644 --- a/source4/param/provision.h +++ b/source4/param/provision.h @@ -21,7 +21,6 @@ #define _PROVISION_H_ struct provision_settings { - const char *dns_name; const char *site_name; const char *root_dn_str; const char *domain_dn_str; -- cgit From a45f33f277e4fa1288808c75a5fbb5e50c835b60 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 9 Apr 2008 17:14:01 +0200 Subject: Fix so version of hostconfig library. (This used to be commit 62322f302fc92703cce1142bad17349987341cb6) --- source4/param/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/param') diff --git a/source4/param/config.mk b/source4/param/config.mk index 064c293fa44..b4182480a95 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -1,6 +1,6 @@ [LIBRARY::LIBSAMBA-HOSTCONFIG] VERSION = 0.0.1 -SO_VERSION = 1 +SO_VERSION = 0 OBJ_FILES = loadparm.o \ generic.o \ util.o \ -- cgit From ad8e3e41923e20d401294eccd4da028e0f40c904 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 10 Apr 2008 05:23:17 +0200 Subject: Add infrastructure for returning ProvisionResult in C provision code. (This used to be commit 98c3d34eb233be284e8c8994cca337be25c72968) --- source4/param/provision.c | 11 +++++++---- source4/param/provision.h | 8 +++++++- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'source4/param') diff --git a/source4/param/provision.c b/source4/param/provision.c index 5d1f01c59a7..41b062883c3 100644 --- a/source4/param/provision.c +++ b/source4/param/provision.c @@ -29,9 +29,10 @@ #include "scripting/python/modules.h" NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, - struct provision_settings *settings) + struct provision_settings *settings, + struct provision_result *result) { - PyObject *provision_mod, *provision_dict, *provision_fn, *result, *parameters; + PyObject *provision_mod, *provision_dict, *provision_fn, *py_result, *parameters; DEBUG(0,("Provision for Become-DC test using python\n")); @@ -115,15 +116,17 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, PyDict_SetItemString(parameters, "machinepass", PyString_FromString(settings->machine_password)); - result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters); + py_result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters); Py_DECREF(parameters); - if (result == NULL) { + if (py_result == NULL) { PyErr_Print(); PyErr_Clear(); return NT_STATUS_UNSUCCESSFUL; } + result->domaindn = talloc_strdup(mem_ctx, PyString_AsString(PyObject_GetAttrString(py_result, "domaindn"))); + return NT_STATUS_OK; } diff --git a/source4/param/provision.h b/source4/param/provision.h index 323159d417c..e739053d50e 100644 --- a/source4/param/provision.h +++ b/source4/param/provision.h @@ -39,7 +39,13 @@ struct provision_settings { const char *targetdir; }; +/* FIXME: Rename this to hostconfig ? */ +struct provision_result { + const char *domaindn; +}; + NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, - struct provision_settings *settings); + struct provision_settings *settings, + struct provision_result *result); #endif /* _PROVISION_H_ */ -- cgit From 8ed6f6d5a825c8b0e8d66d30877a91a96fe6e7a4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 11 Apr 2008 00:43:23 +0200 Subject: Return SAM ldb context and loadparm context as part of C provision result. (This used to be commit a3e1b835656470f1a80f0fa69f53a9df849baee3) --- source4/param/provision.c | 7 +++++++ source4/param/provision.h | 2 ++ 2 files changed, 9 insertions(+) (limited to 'source4/param') diff --git a/source4/param/provision.c b/source4/param/provision.c index 41b062883c3..e55d984e55d 100644 --- a/source4/param/provision.c +++ b/source4/param/provision.c @@ -32,6 +32,8 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, struct provision_settings *settings, struct provision_result *result) { + extern struct loadparm_context *lp_from_py_object(PyObject *py_obj); + struct ldb_context *ldb_context_from_py_object(PyObject *py_obj); PyObject *provision_mod, *provision_dict, *provision_fn, *py_result, *parameters; DEBUG(0,("Provision for Become-DC test using python\n")); @@ -128,5 +130,10 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, result->domaindn = talloc_strdup(mem_ctx, PyString_AsString(PyObject_GetAttrString(py_result, "domaindn"))); + /* FIXME paths */ + /* FIXME samdb */ + result->lp_ctx = lp_from_py_object(PyObject_GetAttrString(py_result, "lp")); + result->samdb = ldb_context_from_py_object(PyObject_GetAttrString(py_result, "samdb")); + return NT_STATUS_OK; } diff --git a/source4/param/provision.h b/source4/param/provision.h index e739053d50e..6b5bc798df0 100644 --- a/source4/param/provision.h +++ b/source4/param/provision.h @@ -42,6 +42,8 @@ struct provision_settings { /* FIXME: Rename this to hostconfig ? */ struct provision_result { const char *domaindn; + struct ldb_context *samdb; + struct loadparm_context *lp_ctx; }; NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, -- cgit From c82e9c9f6dce7968d807a2b58527a86134026168 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 11 Apr 2008 19:35:15 +1000 Subject: Don't specify the ntds_guid to the C -> python provision interface This paramter was not used anyway. Andrew Bartlett (This used to be commit 6875e6823f7a1fe9066bff4dffcab658a17d3b8c) --- source4/param/provision.c | 2 -- source4/param/provision.h | 1 - 2 files changed, 3 deletions(-) (limited to 'source4/param') diff --git a/source4/param/provision.c b/source4/param/provision.c index d9b2dd899de..70ef618b6eb 100644 --- a/source4/param/provision.c +++ b/source4/param/provision.c @@ -68,10 +68,8 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, settings->site_name)); DEBUG(0,("DSA Instance [%s]\n" - "\tobjectGUID[%s]\n" "\tinvocationId[%s]\n", 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 targetdir[%s]\n", diff --git a/source4/param/provision.h b/source4/param/provision.h index df955492728..af9685d292f 100644 --- a/source4/param/provision.h +++ b/source4/param/provision.h @@ -32,7 +32,6 @@ struct provision_settings { const char *host_ip; const char *realm; const char *domain; - const struct GUID *ntds_guid; const char *ntds_dn_str; const char *machine_password; const char *targetdir; -- cgit From f78bc8c489b02b521e9ecbdbdc72d160c6911b6b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 11:54:50 +0200 Subject: Remove prototypes from build.h in preparation of removing build.h altogether. (This used to be commit dbeab2a9cdee4e5f69afeb2603ba29cbed56debd) --- source4/param/share.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/param') diff --git a/source4/param/share.c b/source4/param/share.c index bc2999b03d1..51134d89703 100644 --- a/source4/param/share.c +++ b/source4/param/share.c @@ -146,6 +146,8 @@ NTSTATUS share_get_context_by_name(TALLOC_CTX *mem_ctx, const char *backend_name */ NTSTATUS share_init(void) { + extern NTSTATUS share_ldb_init(void); + extern NTSTATUS share_classic_init(void); init_module_fn static_init[] = { STATIC_share_MODULES }; run_init_functions(static_init); -- cgit From 0fa62eb2751805bb60d4cfc55b539770aa3471a4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 14 Apr 2008 16:01:15 +0200 Subject: Include the smbconf parameter to the provision Otherwise this fails, if the targetdir is not specified Andrew Bartlett (This used to be commit cd2d3d1c7a0aad7beb167459276c012c7a6d2e88) --- source4/param/provision.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/param') diff --git a/source4/param/provision.c b/source4/param/provision.c index 70ef618b6eb..0e54acf9e42 100644 --- a/source4/param/provision.c +++ b/source4/param/provision.c @@ -76,6 +76,9 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, settings->targetdir)); parameters = PyDict_New(); + PyDict_SetItemString(parameters, "smbconf", + PyString_FromString(lp_configfile(lp_ctx))); + PyDict_SetItemString(parameters, "rootdn", PyString_FromString(settings->root_dn_str)); if (settings->targetdir != NULL) @@ -129,7 +132,6 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, result->domaindn = talloc_strdup(mem_ctx, PyString_AsString(PyObject_GetAttrString(py_result, "domaindn"))); /* FIXME paths */ - /* FIXME samdb */ result->lp_ctx = lp_from_py_object(PyObject_GetAttrString(py_result, "lp")); result->samdb = ldb_context_from_py_object(PyObject_GetAttrString(py_result, "samdb")); -- cgit From e9017ba418202b4b191c5a9ad4a96857558ce606 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 17:22:58 +0200 Subject: Use _OBJ_FILES variables in a couple more places. (This used to be commit 92856d5054106894b65cd1a1b5119c0facfc4cff) --- source4/param/config.mk | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'source4/param') diff --git a/source4/param/config.mk b/source4/param/config.mk index b4182480a95..fcec88fc272 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -1,30 +1,32 @@ [LIBRARY::LIBSAMBA-HOSTCONFIG] VERSION = 0.0.1 SO_VERSION = 0 -OBJ_FILES = loadparm.o \ - generic.o \ - util.o \ - ../lib/version.o PC_FILE = samba-hostconfig.pc PUBLIC_DEPENDENCIES = LIBSAMBA-UTIL PRIVATE_DEPENDENCIES = DYNCONFIG LIBREPLACE_EXT CHARSET -PRIVATE_PROTO_HEADER = proto.h + +LIBSAMBA-HOSTCONFIG_OBJ_FILES = param/loadparm.o \ + param/generic.o \ + param/util.o \ + lib/version.o PUBLIC_HEADERS += param/param.h [SUBSYSTEM::PROVISION] -OBJ_FILES = provision.o PRIVATE_DEPENDENCIES = LIBPYTHON +PROVISION_OBJ_FILES = param/provision.o + ################################# # Start SUBSYSTEM share [SUBSYSTEM::share] PRIVATE_PROTO_HEADER = share_proto.h -OBJ_FILES = share.o PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL # End SUBSYSTEM share ################################# +share_OBJ_FILES = param/share.o + PUBLIC_HEADERS += param/share.h ################################################ @@ -32,25 +34,30 @@ PUBLIC_HEADERS += param/share.h [MODULE::share_classic] SUBSYSTEM = share INIT_FUNCTION = share_classic_init -OBJ_FILES = share_classic.o PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL # End MODULE share_classic ################################################ +share_classic_OBJ_FILES = param/share_classic.o + ################################################ # Start MODULE share_ldb [MODULE::share_ldb] SUBSYSTEM = share INIT_FUNCTION = share_ldb_init -OBJ_FILES = share_ldb.o PRIVATE_DEPENDENCIES = LIBLDB LDB_WRAP # End MODULE share_ldb ################################################ +share_ldb_OBJ_FILES = param/share_ldb.o + [SUBSYSTEM::SECRETS] -OBJ_FILES = secrets.o PRIVATE_DEPENDENCIES = LIBLDB TDB_WRAP UTIL_TDB NDR_SECURITY +SECRETS_OBJ_FILES = param/secrets.o + [PYTHON::param] SWIG_FILE = param.i PRIVATE_DEPENDENCIES = LIBSAMBA-HOSTCONFIG + +param_OBJ_FILES = param/param_wrap.o -- cgit From 08baea013b73607df0c86f24506912c7e6af6f7e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 15 Apr 2008 02:25:16 +0200 Subject: Move SOVERSION, VERSION and PC_FILE out of smb_build but use make variables directly instead. (This used to be commit 9d0ae012b0b463278cd054d06788aa998acc2da2) --- source4/param/config.mk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source4/param') diff --git a/source4/param/config.mk b/source4/param/config.mk index fcec88fc272..42cb6f3c1c6 100644 --- a/source4/param/config.mk +++ b/source4/param/config.mk @@ -1,10 +1,10 @@ [LIBRARY::LIBSAMBA-HOSTCONFIG] -VERSION = 0.0.1 -SO_VERSION = 0 -PC_FILE = samba-hostconfig.pc PUBLIC_DEPENDENCIES = LIBSAMBA-UTIL PRIVATE_DEPENDENCIES = DYNCONFIG LIBREPLACE_EXT CHARSET +LIBSAMBA-HOSTCONFIG_VERSION = 0.0.1 +LIBSAMBA-HOSTCONFIG-SOVERSION = 0 + LIBSAMBA-HOSTCONFIG_OBJ_FILES = param/loadparm.o \ param/generic.o \ param/util.o \ @@ -12,6 +12,8 @@ LIBSAMBA-HOSTCONFIG_OBJ_FILES = param/loadparm.o \ PUBLIC_HEADERS += param/param.h +PC_FILES += param/samba-hostconfig.pc + [SUBSYSTEM::PROVISION] PRIVATE_DEPENDENCIES = LIBPYTHON -- cgit From 21fc7673780aa1d7c0caab7b17ff9171238913ba Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Apr 2008 12:23:44 +0200 Subject: Specify event_context to ldb_wrap_connect explicitly. (This used to be commit b4e1ae07a284c044704322446c94351c2decff91) --- source4/param/share.c | 3 ++- source4/param/share.h | 5 ++++- source4/param/share_classic.c | 1 + source4/param/share_ldb.c | 6 ++++-- source4/param/tests/share.c | 4 ++-- 5 files changed, 13 insertions(+), 6 deletions(-) (limited to 'source4/param') diff --git a/source4/param/share.c b/source4/param/share.c index 51134d89703..f8ee4680547 100644 --- a/source4/param/share.c +++ b/source4/param/share.c @@ -127,6 +127,7 @@ NTSTATUS share_register(const struct share_ops *ops) } NTSTATUS share_get_context_by_name(TALLOC_CTX *mem_ctx, const char *backend_name, + struct event_context *event_ctx, struct loadparm_context *lp_ctx, struct share_context **ctx) { @@ -138,7 +139,7 @@ NTSTATUS share_get_context_by_name(TALLOC_CTX *mem_ctx, const char *backend_name return NT_STATUS_INTERNAL_ERROR; } - return ops->init(mem_ctx, ops, lp_ctx, ctx); + return ops->init(mem_ctx, ops, event_ctx, lp_ctx, ctx); } /* diff --git a/source4/param/share.h b/source4/param/share.h index 9f9cbdce5be..2a85fd4fbbf 100644 --- a/source4/param/share.h +++ b/source4/param/share.h @@ -47,9 +47,12 @@ struct share_info { void *value; }; +struct event_context; + struct share_ops { const char *name; - NTSTATUS (*init)(TALLOC_CTX *, const struct share_ops*, struct loadparm_context *lp_ctx, + NTSTATUS (*init)(TALLOC_CTX *, const struct share_ops*, struct event_context *ev_ctx, + struct loadparm_context *lp_ctx, struct share_context **); const char *(*string_option)(struct share_config *, const char *, const char *); int (*int_option)(struct share_config *, const char *, int); diff --git a/source4/param/share_classic.c b/source4/param/share_classic.c index c3adc4473c7..bac1aac2d78 100644 --- a/source4/param/share_classic.c +++ b/source4/param/share_classic.c @@ -25,6 +25,7 @@ static NTSTATUS sclassic_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, + struct event_context *event_ctx, struct loadparm_context *lp_ctx, struct share_context **ctx) { diff --git a/source4/param/share_ldb.c b/source4/param/share_ldb.c index fb40f1e9bfe..eba1665cc9f 100644 --- a/source4/param/share_ldb.c +++ b/source4/param/share_ldb.c @@ -27,7 +27,9 @@ #include "param/share.h" #include "param/param.h" -static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, struct loadparm_context *lp_ctx, +static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, + struct event_context *ev_ctx, + struct loadparm_context *lp_ctx, struct share_context **ctx) { struct ldb_context *sdb; @@ -38,7 +40,7 @@ static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, stru return NT_STATUS_NO_MEMORY; } - sdb = ldb_wrap_connect(*ctx, lp_ctx, + sdb = ldb_wrap_connect(*ctx, ev_ctx, lp_ctx, private_path(*ctx, lp_ctx, "share.ldb"), system_session(*ctx, lp_ctx), NULL, 0, NULL); diff --git a/source4/param/tests/share.c b/source4/param/tests/share.c index 6d03b4e0492..c64b5c607a5 100644 --- a/source4/param/tests/share.c +++ b/source4/param/tests/share.c @@ -182,12 +182,12 @@ static void tcase_add_share_tests(struct torture_tcase *tcase) static bool setup_ldb(struct torture_context *tctx, void **data) { - return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "ldb", tctx->lp_ctx, (struct share_context **)data)); + return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "ldb", tctx->ev, tctx->lp_ctx, (struct share_context **)data)); } static bool setup_classic(struct torture_context *tctx, void **data) { - return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "classic", tctx->lp_ctx, (struct share_context **)data)); + return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "classic", tctx->ev, tctx->lp_ctx, (struct share_context **)data)); } static bool teardown(struct torture_context *tctx, void *data) -- cgit From db30ff4bea11f6612bd68c934ba31387ad99cefc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Apr 2008 17:59:08 +0200 Subject: Load default smb.conf file if none was specified explicitly. (This used to be commit 8fa23fac516dbf4c8245c1d009e81f02a6341775) --- source4/param/param.i | 9 ++++++ source4/param/param.py | 6 ++-- source4/param/param_wrap.c | 76 ++++++++++++++++++++++++++++++++++------------ 3 files changed, 68 insertions(+), 23 deletions(-) (limited to 'source4/param') diff --git a/source4/param/param.i b/source4/param/param.i index 77d781d6ffe..2f62cb2f16a 100644 --- a/source4/param/param.i +++ b/source4/param/param.i @@ -307,6 +307,15 @@ struct loadparm_context *lp_from_py_object(PyObject *py_obj) return lp_ctx; } + if (py_obj == Py_None) { + lp_ctx = loadparm_init(NULL); + if (!lp_load_default(lp_ctx)) { + talloc_free(lp_ctx); + return NULL; + } + return lp_ctx; + } + if (SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 | 0 ) < 0) return NULL; return lp_ctx; diff --git a/source4/param/param.py b/source4/param/param.py index 025acc6be1e..0419c75bfa4 100644 --- a/source4/param/param.py +++ b/source4/param/param.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.33 +# Version 1.3.35 # # Don't modify this file, modify the SWIG interface instead. @@ -79,7 +79,7 @@ LoadParm_swigregister(LoadParm) class loadparm_service(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') - def __init__(self): raise AttributeError, "No constructor defined" + def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined" __repr__ = _swig_repr loadparm_service.volume_label = new_instancemethod(_param.loadparm_service_volume_label,None,loadparm_service) loadparm_service.printername = new_instancemethod(_param.loadparm_service_printername,None,loadparm_service) @@ -137,7 +137,7 @@ ParamFile_swigregister(ParamFile) class param_opt(object): thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') - def __init__(self): raise AttributeError, "No constructor defined" + def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined" __repr__ = _swig_repr key = _swig_property(_param.param_opt_key_get) value = _swig_property(_param.param_opt_value_get) diff --git a/source4/param/param_wrap.c b/source4/param/param_wrap.c index e74f9026453..d07be04a669 100644 --- a/source4/param/param_wrap.c +++ b/source4/param/param_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.33 + * Version 1.3.35 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make @@ -126,7 +126,7 @@ /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "3" +#define SWIG_RUNTIME_VERSION "4" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE @@ -161,6 +161,7 @@ /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 @@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) { extern "C" { #endif -typedef void *(*swig_converter_func)(void *); +typedef void *(*swig_converter_func)(void *, int *); typedef struct swig_type_info *(*swig_dycast_func)(void **); -/* Structure to store inforomation on one type */ +/* Structure to store information on one type */ typedef struct swig_type_info { const char *name; /* mangled name of this type */ const char *str; /* human readable name of this type */ @@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { Cast a pointer up an inheritance hierarchy */ SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } /* @@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg) Py_DECREF(old_str); Py_DECREF(value); } else { - PyErr_Format(PyExc_RuntimeError, mesg); + PyErr_SetString(PyExc_RuntimeError, mesg); } } @@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v) { PySwigObject *sobj = (PySwigObject *) v; PyObject *next = sobj->next; - if (sobj->own) { + if (sobj->own == SWIG_POINTER_OWN) { swig_type_info *ty = sobj->ty; PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; PyObject *destroy = data ? data->destroy : 0; @@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v) res = ((*meth)(mself, v)); } Py_XDECREF(res); - } else { - const char *name = SWIG_TypePrettyName(ty); + } #if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name); -#endif + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); } +#endif } Py_XDECREF(next); PyObject_DEL(v); @@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own) { + if (own == SWIG_POINTER_OWN) { PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); if (sobj) { int oldown = sobj->own; @@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int return SWIG_OK; } else { PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; while (sobj) { void *vptr = sobj->ptr; if (ty) { @@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int if (!tc) { sobj = (PySwigObject *)sobj->next; } else { - if (ptr) *ptr = SWIG_TypeCast(tc,vptr); + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } break; } } @@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } } if (sobj) { - if (own) *own = sobj->own; + if (own) + *own = *own | sobj->own; if (flags & SWIG_POINTER_DISOWN) { sobj->own = 0; } @@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { } if (ty) { swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (!tc) return SWIG_ERROR; - *ptr = SWIG_TypeCast(tc,vptr); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } } else { *ptr = vptr; } @@ -2504,7 +2522,7 @@ static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0}; #define SWIG_name "_param" -#define SWIGVERSION 0x010333 +#define SWIGVERSION 0x010335 #define SWIG_VERSION SWIGVERSION @@ -2776,6 +2794,15 @@ struct loadparm_context *lp_from_py_object(PyObject *py_obj) return lp_ctx; } + if (py_obj == Py_None) { + lp_ctx = loadparm_init(NULL); + if (!lp_load_default(lp_ctx)) { + talloc_free(lp_ctx); + return NULL; + } + return lp_ctx; + } + if (SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 | 0 ) < 0) return NULL; return lp_ctx; @@ -4073,7 +4100,7 @@ SWIGINTERN PyObject *_wrap_new_param_section(PyObject *SWIGUNUSEDPARM(self), PyO param_section *result = 0 ; if (!SWIG_Python_UnpackTuple(args,"new_param_section",0,0,0)) SWIG_fail; - result = (param_section *)(param_section *) calloc(1, sizeof(param_section)); + result = (param_section *)calloc(1, sizeof(param_section)); resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_section, SWIG_POINTER_NEW | 0 ); return resultobj; fail: @@ -4325,7 +4352,7 @@ SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) { size_t i; swig_module_info *module_head, *iter; - int found; + int found, init; clientdata = clientdata; @@ -4335,6 +4362,9 @@ SWIG_InitializeModule(void *clientdata) { swig_module.type_initial = swig_type_initial; swig_module.cast_initial = swig_cast_initial; swig_module.next = &swig_module; + init = 1; + } else { + init = 0; } /* Try and load any already created modules */ @@ -4363,6 +4393,12 @@ SWIG_InitializeModule(void *clientdata) { module_head->next = &swig_module; } + /* When multiple interpeters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: size %d\n", swig_module.size); -- cgit