summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/config.mk2
-rw-r--r--source4/param/provision.c31
-rw-r--r--source4/param/pyparam.c3
-rw-r--r--source4/param/tests/bindings.py10
4 files changed, 39 insertions, 7 deletions
diff --git a/source4/param/config.mk b/source4/param/config.mk
index 6e5290b64d..a5bcea691b 100644
--- a/source4/param/config.mk
+++ b/source4/param/config.mk
@@ -13,7 +13,7 @@ PUBLIC_HEADERS += param/param.h
PC_FILES += $(paramsrcdir)/samba-hostconfig.pc
[SUBSYSTEM::PROVISION]
-PRIVATE_DEPENDENCIES = LIBPYTHON pyldb pyparam_util
+PRIVATE_DEPENDENCIES = LIBPYTHON pyparam_util LIBLDB
PROVISION_OBJ_FILES = $(paramsrcdir)/provision.o $(param_OBJ_FILES)
diff --git a/source4/param/provision.c b/source4/param/provision.c
index 8c6e1c0f68..7bd10ca522 100644
--- a/source4/param/provision.c
+++ b/source4/param/provision.c
@@ -52,6 +52,34 @@ static PyObject *schema_module(void)
return PyImport_Import(name);
}
+static PyObject *ldb_module(void)
+{
+ PyObject *name = PyString_FromString("ldb");
+ if (name == NULL)
+ return NULL;
+ return PyImport_Import(name);
+}
+
+static PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx)
+{
+ PyLdbObject *ret;
+ PyObject *ldb_mod = ldb_module();
+ PyTypeObject *ldb_ctx_type;
+ if (ldb_mod == NULL)
+ return NULL;
+
+ ldb_ctx_type = PyObject_GetAttrString(ldb_mod, "Ldb");
+
+ ret = (PyLdbObject *)ldb_ctx_type->tp_alloc(ldb_ctx_type, 0);
+ if (ret == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+ ret->mem_ctx = talloc_new(NULL);
+ ret->ldb_ctx = talloc_reference(ret->mem_ctx, ldb_ctx);
+ return (PyObject *)ret;
+}
+
NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
struct provision_settings *settings,
struct provision_result *result)
@@ -167,8 +195,6 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
return NT_STATUS_OK;
}
-extern void initldb(void);
-
static PyObject *py_dom_sid_FromSid(struct dom_sid *sid)
{
PyObject *mod_security, *dom_sid_Type;
@@ -220,7 +246,6 @@ NTSTATUS provision_store_self_join(TALLOC_CTX *mem_ctx, struct loadparm_context
py_load_samba_modules();
Py_Initialize();
py_update_path("bin"); /* FIXME: Can't assume this is always the case */
- initldb();
provision_mod = provision_module();
if (provision_mod == NULL) {
diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c
index eb2da11bb0..b4255002d2 100644
--- a/source4/param/pyparam.c
+++ b/source4/param/pyparam.c
@@ -374,6 +374,9 @@ void initparam(void)
if (PyType_Ready(&PyLoadparmContext) < 0)
return;
+ if (PyType_Ready(&PyLoadparmService) < 0)
+ return;
+
m = Py_InitModule3("param", pyparam_methods, "Parsing and writing Samba configuration files.");
if (m == NULL)
return;
diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py
index 41a67f93fc..1915e79223 100644
--- a/source4/param/tests/bindings.py
+++ b/source4/param/tests/bindings.py
@@ -2,17 +2,17 @@
# Unix SMB/CIFS implementation.
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
-#
+#
# 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/>.
#
@@ -50,3 +50,7 @@ class LoadParmTestCase(unittest.TestCase):
file = param.LoadParm()
file.load_default()
+ def test_section_nonexistant(self):
+ samba_lp = param.LoadParm()
+ samba_lp.load_default()
+ self.assertRaises(KeyError, samba_lp.__getitem__, "nonexistant")