diff options
-rw-r--r-- | lib/tdb/tdb.i | 5 | ||||
-rw-r--r-- | lib/tdb/tdb.py | 5 | ||||
-rw-r--r-- | lib/tdb/tdb_wrap.c | 59 | ||||
-rw-r--r-- | source4/lib/com/com.h | 2 | ||||
-rw-r--r-- | source4/lib/com/config.mk | 9 | ||||
-rw-r--r-- | source4/lib/com/main.c | 22 | ||||
-rw-r--r-- | source4/lib/com/pycom.c | 81 | ||||
-rw-r--r-- | source4/lib/com/rot.c | 1 | ||||
-rw-r--r-- | source4/lib/ldb/include/ldb_private.h | 1 | ||||
-rw-r--r-- | source4/lib/ldb/ldb.i | 359 | ||||
-rw-r--r-- | source4/lib/ldb/ldb.py | 31 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_wrap.c | 922 | ||||
-rwxr-xr-x | source4/lib/ldb/tests/python/api.py | 31 | ||||
-rw-r--r-- | source4/librpc/config.mk | 2 | ||||
-rwxr-xr-x | source4/librpc/tests/test_ndrdump.sh | 4 | ||||
-rwxr-xr-x | source4/selftest/samba4_tests.sh | 2 | ||||
-rw-r--r-- | testprogs/ejs/samba3sam.js | 8 |
17 files changed, 1466 insertions, 78 deletions
diff --git a/lib/tdb/tdb.i b/lib/tdb/tdb.i index 3d8b697732..4b529913d7 100644 --- a/lib/tdb/tdb.i +++ b/lib/tdb/tdb.i @@ -321,3 +321,8 @@ typedef struct tdb_context { # TODO: any other missing methods for container types } } tdb; + +%pythoncode { +__docformat__ = 'restructuredText' +open = Tdb +} diff --git a/lib/tdb/tdb.py b/lib/tdb/tdb.py index 9f306bab8c..42129d2091 100644 --- a/lib/tdb/tdb.py +++ b/lib/tdb/tdb.py @@ -1,5 +1,5 @@ # This file was automatically generated by SWIG (http://www.swig.org). -# Version 1.3.35 +# Version 1.3.36 # # Don't modify this file, modify the SWIG interface instead. @@ -337,5 +337,8 @@ Tdb.name = new_instancemethod(_tdb.Tdb_name,None,Tdb) Tdb_swigregister = _tdb.Tdb_swigregister Tdb_swigregister(Tdb) +__docformat__ = 'restructuredText' +open = Tdb + diff --git a/lib/tdb/tdb_wrap.c b/lib/tdb/tdb_wrap.c index 32665d79fd..e997e88572 100644 --- a/lib/tdb/tdb_wrap.c +++ b/lib/tdb/tdb_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.35 + * Version 1.3.36 * * 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 @@ -52,6 +52,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) @@ -2518,7 +2524,7 @@ static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0}; #define SWIG_name "_tdb" -#define SWIGVERSION 0x010335 +#define SWIGVERSION 0x010336 #define SWIG_VERSION SWIGVERSION @@ -2818,7 +2824,6 @@ SWIGINTERN PyObject *_wrap_new_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *arg int arg3 ; int arg4 ; mode_t arg5 ; - tdb *result = 0 ; int res1 ; char *buf1 = 0 ; int alloc1 = 0 ; @@ -2838,6 +2843,7 @@ SWIGINTERN PyObject *_wrap_new_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *arg char * kwnames[] = { (char *) "name",(char *) "hash_size",(char *) "tdb_flags",(char *) "flags",(char *) "mode", NULL }; + tdb *result = 0 ; arg2 = 0; arg3 = TDB_DEFAULT; @@ -2895,10 +2901,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - enum TDB_ERROR result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + enum TDB_ERROR result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -2930,7 +2936,6 @@ SWIGINTERN PyObject *_wrap_delete_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject * } arg1 = (tdb *)(argp1); delete_tdb(arg1); - resultobj = SWIG_Py_Void(); return resultobj; fail: @@ -2941,10 +2946,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -2966,7 +2971,6 @@ SWIGINTERN PyObject *_wrap_Tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject * tdb *arg1 = (tdb *) 0 ; TDB_DATA arg2 ; TDB_DATA arg3 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -2975,6 +2979,7 @@ SWIGINTERN PyObject *_wrap_Tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "key",(char *) "new_dbuf", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:Tdb_append",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); @@ -3013,10 +3018,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3037,7 +3042,6 @@ SWIGINTERN PyObject *_wrap_Tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *arg PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; TDB_DATA arg2 ; - TDB_DATA result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -3045,6 +3049,7 @@ SWIGINTERN PyObject *_wrap_Tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *arg char * kwnames[] = { (char *) "self",(char *) "key", NULL }; + TDB_DATA result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_get",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); @@ -3079,7 +3084,6 @@ SWIGINTERN PyObject *_wrap_Tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject * PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; TDB_DATA arg2 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -3087,6 +3091,7 @@ SWIGINTERN PyObject *_wrap_Tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "key", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_delete",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); @@ -3118,7 +3123,6 @@ SWIGINTERN PyObject *_wrap_Tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a TDB_DATA arg2 ; TDB_DATA arg3 ; int arg4 ; - int result; void *argp1 = 0 ; int res1 = 0 ; int val4 ; @@ -3130,6 +3134,7 @@ SWIGINTERN PyObject *_wrap_Tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a char * kwnames[] = { (char *) "self",(char *) "key",(char *) "dbuf",(char *) "flag", NULL }; + int result; arg4 = TDB_REPLACE; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:Tdb_store",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; @@ -3177,7 +3182,6 @@ SWIGINTERN PyObject *_wrap_Tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject * PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; TDB_DATA arg2 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -3185,6 +3189,7 @@ SWIGINTERN PyObject *_wrap_Tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject * char * kwnames[] = { (char *) "self",(char *) "key", NULL }; + int result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_exists",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); @@ -3213,10 +3218,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - TDB_DATA result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + TDB_DATA result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3242,7 +3247,6 @@ SWIGINTERN PyObject *_wrap_Tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; TDB_DATA arg2 ; - TDB_DATA result; void *argp1 = 0 ; int res1 = 0 ; PyObject * obj0 = 0 ; @@ -3250,6 +3254,7 @@ SWIGINTERN PyObject *_wrap_Tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject char * kwnames[] = { (char *) "self",(char *) "key", NULL }; + TDB_DATA result; if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_nextkey",kwnames,&obj0,&obj1)) SWIG_fail; res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 ); @@ -3283,10 +3288,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3306,10 +3311,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3329,10 +3334,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3352,10 +3357,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3375,10 +3380,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3398,10 +3403,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3421,10 +3426,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3444,10 +3449,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3467,10 +3472,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3490,10 +3495,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3513,10 +3518,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - size_t result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + size_t result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3536,10 +3541,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - int result; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + int result; if (!args) SWIG_fail; swig_obj[0] = args; @@ -3592,10 +3597,10 @@ fail: SWIGINTERN PyObject *_wrap_Tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; tdb *arg1 = (tdb *) 0 ; - char *result = 0 ; void *argp1 = 0 ; int res1 = 0 ; PyObject *swig_obj[1] ; + char *result = 0 ; if (!args) SWIG_fail; swig_obj[0] = args; diff --git a/source4/lib/com/com.h b/source4/lib/com/com.h index 2074bd11ca..5d594ad41b 100644 --- a/source4/lib/com/com.h +++ b/source4/lib/com/com.h @@ -47,4 +47,6 @@ WERROR com_create_object(struct com_context *ctx, struct GUID *clsid, int num_if WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct GUID *iid, struct IUnknown **ip); NTSTATUS com_init(void); +typedef struct IUnknown *(*get_class_object_function) (const struct GUID *clsid); + #endif /* __SAMBA_COM_H__ */ diff --git a/source4/lib/com/config.mk b/source4/lib/com/config.mk index 5c8e98dc46..c5c5a35003 100644 --- a/source4/lib/com/config.mk +++ b/source4/lib/com/config.mk @@ -1,9 +1,10 @@ [SUBSYSTEM::COM] +PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG LIBEVENTS LIBNDR COM_OBJ_FILES = $(addprefix lib/com/, tables.o rot.o main.o) [SUBSYSTEM::DCOM] -PUBLIC_DEPENDENCIES = com DCOM_PROXY_DCOM RPC_NDR_REMACT \ +PUBLIC_DEPENDENCIES = COM DCOM_PROXY_DCOM RPC_NDR_REMACT \ RPC_NDR_OXIDRESOLVER DCOM_OBJ_FILES = $(addprefix lib/com/dcom/, main.o tables.o) @@ -13,3 +14,9 @@ SUBSYSTEM = COM INIT_FUNCTION = com_simple_init com_simple_OBJ_FILES = lib/com/classes/simple.o + +[PYTHON::pycom] +LIBRARY_REALNAME = samba/com.$(SHLIBEXT) +PRIVATE_DEPENDENCIES = COM + +pycom_OBJ_FILES = lib/com/pycom.o diff --git a/source4/lib/com/main.c b/source4/lib/com/main.c index 882b479cfe..bcc5fa393a 100644 --- a/source4/lib/com/main.c +++ b/source4/lib/com/main.c @@ -42,7 +42,7 @@ WERROR com_create_object(struct com_context *ctx, struct GUID *clsid, int num_if int i; struct GUID classfact_iid; - GUID_from_string(DCERPC_ICLASSFACTORY_UUID, &classfact_iid); + GUID_from_string(NDR_ICLASSFACTORY_UUID, &classfact_iid); /* Obtain class object */ error = com_get_class_object(ctx, clsid, &classfact_iid, (struct IUnknown **)&factory); @@ -88,23 +88,3 @@ WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct return IUnknown_QueryInterface(iu, ctx, iid, ip); } - -NTSTATUS com_init(void) -{ - static BOOL initialized = False; - - init_module_fn static_init[] = STATIC_com_MODULES; - init_module_fn *shared_init; - - if (initialized) return NT_STATUS_OK; - initialized = True; - - shared_init = load_samba_modules(NULL, "com"); - - run_init_functions(static_init); - run_init_functions(shared_init); - - talloc_free(shared_init); - - return NT_STATUS_OK; -} diff --git a/source4/lib/com/pycom.c b/source4/lib/com/pycom.c new file mode 100644 index 0000000000..9222be438d --- /dev/null +++ b/source4/lib/com/pycom.c @@ -0,0 +1,81 @@ +/* + Unix SMB/CIFS implementation. + Python bindings for COM library. + 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/>. +*/ + +#include "includes.h" +#include <Python.h> +#include "lib/com/com.h" +#include "librpc/ndr/libndr.h" +#include "libcli/util/pyerrors.h" + +static struct com_context *py_com_ctx = NULL; /* FIXME: evil global */ + +static PyObject *py_get_class_object(PyObject *self, PyObject *args) +{ + char *s_clsid, *s_iid; + struct GUID clsid, iid; + struct IUnknown *object; + NTSTATUS status; + WERROR error; + + if (!PyArg_ParseTuple(args, "ss", &s_clsid, &s_iid)) + return NULL; + + status = GUID_from_string(s_clsid, &clsid); + if (!NT_STATUS_IS_OK(status)) { + PyErr_FromNTSTATUS(status); + return NULL; + } + + status = GUID_from_string(s_iid, &iid); + if (!NT_STATUS_IS_OK(status)) { + PyErr_FromNTSTATUS(status); + return NULL; + } + + error = com_get_class_object(py_com_ctx, &clsid, &iid, &object); + if (!W_ERROR_IS_OK(error)) { + PyErr_FromWERROR(error); + return NULL; + } + + /* FIXME: Magic, integrate with stubs generated by pidl. */ + + return Py_None; +} + +static struct PyMethodDef com_methods[] = { + { "get_class_object", (PyCFunction)py_get_class_object, METH_VARARGS, "S.get_class_object(clsid, iid) -> instance" }, + { NULL }, +}; + +void initcom(void) +{ + PyObject *m; + WERROR error; + + error = com_init_ctx(&py_com_ctx, NULL); + if (!W_ERROR_IS_OK(error)) { + PyErr_FromWERROR(error); + return; + } + + m = Py_InitModule3("com", com_methods, "Simple COM implementation"); + if (m == NULL) + return; +} diff --git a/source4/lib/com/rot.c b/source4/lib/com/rot.c index 34a5671f5b..0180a92f1b 100644 --- a/source4/lib/com/rot.c +++ b/source4/lib/com/rot.c @@ -21,6 +21,7 @@ */ #include "includes.h" +#include "lib/com/com.h" struct dcom_interface_p *dcom_get_local_iface_p(struct GUID *ipid) { diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h index e1026ab781..30adadcfdc 100644 --- a/source4/lib/ldb/include/ldb_private.h +++ b/source4/lib/ldb/include/ldb_private.h @@ -70,6 +70,7 @@ struct ldb_module_ops { int (*del_transaction)(struct ldb_module *); int (*wait)(struct ldb_handle *, enum ldb_wait_type); int (*sequence_number)(struct ldb_module *, struct ldb_request *); + void *private_data; }; diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i index 4b61ddba5b..8cd39b5690 100644 --- a/source4/lib/ldb/ldb.i +++ b/source4/lib/ldb/ldb.i @@ -46,6 +46,7 @@ typedef struct ldb_context ldb; typedef struct ldb_dn ldb_dn; typedef struct ldb_ldif ldb_ldif; typedef struct ldb_message_element ldb_message_element; +typedef struct ldb_module ldb_module; typedef int ldb_error; typedef int ldb_int_error; @@ -189,7 +190,7 @@ PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx, #endif -%types(struct ldb_result *); +%types(struct ldb_result *, struct ldb_parse_tree *); /* * Wrap struct ldb_dn @@ -685,6 +686,20 @@ PyObject *PyExc_LdbError; /* Top-level ldb operations */ typedef struct ldb_context { + %rename(firstmodule) modules; + struct ldb_module *modules; + + %pythoncode { + def itermodules(self): + m = self.firstmodule + while m is not None: + yield m + m = m.next + + def modules(self): + return list(self.itermodules()) + } + %extend { ldb(void) { return ldb_init(NULL, event_context_init(NULL)); @@ -915,10 +930,349 @@ static char *timestring(time_t t) "Parse a LDAP time string into a UNIX timestamp."; time_t ldb_string_to_time(const char *s); +typedef struct ldb_module { + struct ldb_module *prev, *next; + + %extend { +#ifdef SWIGPYTHON + const char *__str__() { + return $self->ops->name; + } + char *__repr__() { + char *ret; + asprintf(&ret, "<ldb module '%s'>", $self->ops->name); + return ret; + } +#endif + int search(struct ldb_request *req) { + return $self->ops->search($self, req); + } + ldb_error add(struct ldb_request *req) { + return $self->ops->add($self, req); + } + ldb_error modify(struct ldb_request *req) { + return $self->ops->modify($self, req); + } + ldb_error delete(struct ldb_request *req) { + return $self->ops->del($self, req); + } + ldb_error rename(struct ldb_request *req) { + return $self->ops->rename($self, req); + } + ldb_error start_transaction() { + return $self->ops->start_transaction($self); + } + ldb_error end_transaction() { + return $self->ops->end_transaction($self); + } + ldb_error del_transaction() { + return $self->ops->del_transaction($self); + } + } +} ldb_module; + +%{ +int py_module_search(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_base, *py_attrs, *py_tree; + + py_base = SWIG_NewPointerObj(req->op.search.base, SWIGTYPE_p_ldb_dn, 0); + + if (py_base == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_tree = SWIG_NewPointerObj(req->op.search.tree, SWIGTYPE_p_ldb_parse_tree, 0); + + if (py_tree == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + if (req->op.search.attrs == NULL) { + py_attrs = Py_None; + } else { + int i, len; + for (len = 0; req->op.search.attrs[len]; len++); + py_attrs = PyList_New(len); + for (i = 0; i < len; i++) + PyList_SetItem(py_attrs, i, PyString_FromString(req->op.search.attrs[i])); + } + + py_result = PyObject_CallMethod(py_ldb, "search", "OiOO", py_base, req->op.search.scope, py_tree, py_attrs); + + Py_DECREF(py_attrs); + Py_DECREF(py_tree); + Py_DECREF(py_base); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + if (SWIG_ConvertPtr(py_result, &req->op.search.res, SWIGTYPE_p_ldb_result, 0) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_add(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_msg; + + py_msg = SWIG_NewPointerObj(req->op.add.message, SWIGTYPE_p_ldb_message, 0); + + if (py_msg == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + py_result = PyObject_CallMethod(py_ldb, "add", "O", py_msg); + + Py_DECREF(py_msg); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_modify(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_msg; + + py_msg = SWIG_NewPointerObj(req->op.mod.message, SWIGTYPE_p_ldb_message, 0); + + if (py_msg == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + py_result = PyObject_CallMethod(py_ldb, "modify", "O", py_msg); + + Py_DECREF(py_msg); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_del(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_dn; + + py_dn = SWIG_NewPointerObj(req->op.del.dn, SWIGTYPE_p_ldb_dn, 0); + + if (py_dn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallMethod(py_ldb, "delete", "O", py_dn); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_rename(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_olddn, *py_newdn; + + py_olddn = SWIG_NewPointerObj(req->op.rename.olddn, SWIGTYPE_p_ldb_dn, 0); + + if (py_olddn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_newdn = SWIG_NewPointerObj(req->op.rename.newdn, SWIGTYPE_p_ldb_dn, 0); + + if (py_newdn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallMethod(py_ldb, "rename", "OO", py_olddn, py_newdn); + + Py_DECREF(py_olddn); + Py_DECREF(py_newdn); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_request(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "request", ""); + + return LDB_ERR_OPERATIONS_ERROR; +} + +int py_module_extended(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "extended", ""); + + return LDB_ERR_OPERATIONS_ERROR; +} + +int py_module_start_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "start_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_end_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "end_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_del_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "del_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_wait(struct ldb_handle *mod, enum ldb_wait_type wait_type) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "wait", "i", wait_type); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_sequence_number(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + int ret; + + py_result = PyObject_CallMethod(py_ldb, "sequence_number", "ili", req->op.seq_num.type, req->op.seq_num.seq_num, req->op.seq_num.flags); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = PyInt_AsLong(py_result); + + Py_DECREF(py_result); + + return ret; +} + +static int py_module_destructor(void *_mod) +{ + struct ldb_module *mod = _mod; + Py_DECREF((PyObject *)mod->private_data); + return 0; +} + +int py_module_init (struct ldb_module *mod) +{ + PyObject *py_class = mod->ops->private_data; + PyObject *py_result, *py_next, *py_ldb; + + py_ldb = SWIG_NewPointerObj(mod->ldb, SWIGTYPE_p_ldb_context, 0); + + if (py_ldb == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_next = SWIG_NewPointerObj(mod->next, SWIGTYPE_p_ldb_module, 0); + + if (py_next == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallFunction(py_class, "OO", py_ldb, py_next); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + mod->private_data = py_result; + + talloc_set_destructor (mod, py_module_destructor); + + return ldb_next_init(mod); +} +%} + %typemap(in,noblock=1) const struct ldb_module_ops * { $1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops); - $1->name = (char *)PyObject_GetAttrString($input, (char *)"name"); + $1->name = talloc_strdup($1, PyString_AsString(PyObject_GetAttrString($input, (char *)"name"))); + + Py_INCREF($input); + $1->private_data = $input; + $1->init_context = py_module_init; + $1->search = py_module_search; + $1->add = py_module_add; + $1->modify = py_module_modify; + $1->del = py_module_del; + $1->rename = py_module_rename; + $1->request = py_module_request; + $1->extended = py_module_extended; + $1->start_transaction = py_module_start_transaction; + $1->end_transaction = py_module_end_transaction; + $1->del_transaction = py_module_del_transaction; + $1->wait = py_module_wait; + $1->sequence_number = py_module_sequence_number; } %feature("docstring") ldb_register_module "S.register_module(module) -> None\n" @@ -928,4 +1282,5 @@ ldb_int_error ldb_register_module(const struct ldb_module_ops *); %pythoncode { __docformat__ = "restructuredText" +open = Ldb } diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py index 5826c6b752..4cf36441fd 100644 --- a/source4/lib/ldb/ldb.py +++ b/source4/lib/ldb/ldb.py @@ -281,6 +281,16 @@ LDB_ERR_OTHER = _ldb.LDB_ERR_OTHER class Ldb(object): """Connection to a LDB database.""" thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') + firstmodule = _swig_property(_ldb.Ldb_firstmodule_get, _ldb.Ldb_firstmodule_set) + def itermodules(self): + m = self.firstmodule + while m is not None: + yield m + m = m.next + + def modules(self): + return list(self.itermodules()) + def __init__(self, *args, **kwargs): _ldb.Ldb_swiginit(self,_ldb.new_Ldb(*args, **kwargs)) def connect(*args, **kwargs): @@ -464,6 +474,26 @@ def string_to_time(*args, **kwargs): Parse a LDAP time string into a UNIX timestamp. """ return _ldb.string_to_time(*args, **kwargs) +class ldb_module(object): + thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') + prev = _swig_property(_ldb.ldb_module_prev_get, _ldb.ldb_module_prev_set) + next = _swig_property(_ldb.ldb_module_next_get, _ldb.ldb_module_next_set) + def __init__(self, *args, **kwargs): + _ldb.ldb_module_swiginit(self,_ldb.new_ldb_module(*args, **kwargs)) + __swig_destroy__ = _ldb.delete_ldb_module +ldb_module.__str__ = new_instancemethod(_ldb.ldb_module___str__,None,ldb_module) +ldb_module.__repr__ = new_instancemethod(_ldb.ldb_module___repr__,None,ldb_module) +ldb_module.search = new_instancemethod(_ldb.ldb_module_search,None,ldb_module) +ldb_module.add = new_instancemethod(_ldb.ldb_module_add,None,ldb_module) +ldb_module.modify = new_instancemethod(_ldb.ldb_module_modify,None,ldb_module) +ldb_module.delete = new_instancemethod(_ldb.ldb_module_delete,None,ldb_module) +ldb_module.rename = new_instancemethod(_ldb.ldb_module_rename,None,ldb_module) +ldb_module.start_transaction = new_instancemethod(_ldb.ldb_module_start_transaction,None,ldb_module) +ldb_module.end_transaction = new_instancemethod(_ldb.ldb_module_end_transaction,None,ldb_module) +ldb_module.del_transaction = new_instancemethod(_ldb.ldb_module_del_transaction,None,ldb_module) +ldb_module_swigregister = _ldb.ldb_module_swigregister +ldb_module_swigregister(ldb_module) + def register_module(*args, **kwargs): """ @@ -472,6 +502,7 @@ def register_module(*args, **kwargs): """ return _ldb.register_module(*args, **kwargs) __docformat__ = "restructuredText" +open = Ldb diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c index c9dd9dccd8..7a6d4517ce 100644 --- a/source4/lib/ldb/ldb_wrap.c +++ b/source4/lib/ldb/ldb_wrap.c @@ -2492,23 +2492,26 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) #define SWIGTYPE_p_ldb_ldif swig_types[6] #define SWIGTYPE_p_ldb_message swig_types[7] #define SWIGTYPE_p_ldb_message_element swig_types[8] -#define SWIGTYPE_p_ldb_module_ops swig_types[9] -#define SWIGTYPE_p_ldb_result swig_types[10] -#define SWIGTYPE_p_ldb_val swig_types[11] -#define SWIGTYPE_p_long_long swig_types[12] -#define SWIGTYPE_p_p_char swig_types[13] -#define SWIGTYPE_p_p_ldb_control swig_types[14] -#define SWIGTYPE_p_p_ldb_result swig_types[15] -#define SWIGTYPE_p_short swig_types[16] -#define SWIGTYPE_p_signed_char swig_types[17] -#define SWIGTYPE_p_unsigned_char swig_types[18] -#define SWIGTYPE_p_unsigned_int swig_types[19] -#define SWIGTYPE_p_unsigned_long swig_types[20] -#define SWIGTYPE_p_unsigned_long_long swig_types[21] -#define SWIGTYPE_p_unsigned_short swig_types[22] -#define SWIGTYPE_p_void swig_types[23] -static swig_type_info *swig_types[25]; -static swig_module_info swig_module = {swig_types, 24, 0, 0, 0, 0}; +#define SWIGTYPE_p_ldb_module swig_types[9] +#define SWIGTYPE_p_ldb_module_ops swig_types[10] +#define SWIGTYPE_p_ldb_parse_tree swig_types[11] +#define SWIGTYPE_p_ldb_request swig_types[12] +#define SWIGTYPE_p_ldb_result swig_types[13] +#define SWIGTYPE_p_ldb_val swig_types[14] +#define SWIGTYPE_p_long_long swig_types[15] +#define SWIGTYPE_p_p_char swig_types[16] +#define SWIGTYPE_p_p_ldb_control swig_types[17] +#define SWIGTYPE_p_p_ldb_result swig_types[18] +#define SWIGTYPE_p_short swig_types[19] +#define SWIGTYPE_p_signed_char swig_types[20] +#define SWIGTYPE_p_unsigned_char swig_types[21] +#define SWIGTYPE_p_unsigned_int swig_types[22] +#define SWIGTYPE_p_unsigned_long swig_types[23] +#define SWIGTYPE_p_unsigned_long_long swig_types[24] +#define SWIGTYPE_p_unsigned_short swig_types[25] +#define SWIGTYPE_p_void swig_types[26] +static swig_type_info *swig_types[28]; +static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0}; #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) @@ -2562,6 +2565,7 @@ typedef struct ldb_context ldb; typedef struct ldb_dn ldb_dn; typedef struct ldb_ldif ldb_ldif; typedef struct ldb_message_element ldb_message_element; +typedef struct ldb_module ldb_module; typedef int ldb_error; typedef int ldb_int_error; @@ -3226,6 +3230,319 @@ static char *timestring(time_t t) return result; } +SWIGINTERN char const *ldb_module___str__(ldb_module *self){ + return self->ops->name; + } +SWIGINTERN char *ldb_module___repr__(ldb_module *self){ + char *ret; + asprintf(&ret, "<ldb module '%s'>", self->ops->name); + return ret; + } +SWIGINTERN int ldb_module_search(ldb_module *self,struct ldb_request *req){ + return self->ops->search(self, req); + } +SWIGINTERN ldb_error ldb_module_add(ldb_module *self,struct ldb_request *req){ + return self->ops->add(self, req); + } +SWIGINTERN ldb_error ldb_module_modify(ldb_module *self,struct ldb_request *req){ + return self->ops->modify(self, req); + } +SWIGINTERN ldb_error ldb_module_delete(ldb_module *self,struct ldb_request *req){ + return self->ops->del(self, req); + } +SWIGINTERN ldb_error ldb_module_rename(ldb_module *self,struct ldb_request *req){ + return self->ops->rename(self, req); + } +SWIGINTERN ldb_error ldb_module_start_transaction(ldb_module *self){ + return self->ops->start_transaction(self); + } +SWIGINTERN ldb_error ldb_module_end_transaction(ldb_module *self){ + return self->ops->end_transaction(self); + } +SWIGINTERN ldb_error ldb_module_del_transaction(ldb_module *self){ + return self->ops->del_transaction(self); + } + +int py_module_search(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_base, *py_attrs, *py_tree; + + py_base = SWIG_NewPointerObj(req->op.search.base, SWIGTYPE_p_ldb_dn, 0); + + if (py_base == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_tree = SWIG_NewPointerObj(req->op.search.tree, SWIGTYPE_p_ldb_parse_tree, 0); + + if (py_tree == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + if (req->op.search.attrs == NULL) { + py_attrs = Py_None; + } else { + int i, len; + for (len = 0; req->op.search.attrs[len]; len++); + py_attrs = PyList_New(len); + for (i = 0; i < len; i++) + PyList_SetItem(py_attrs, i, PyString_FromString(req->op.search.attrs[i])); + } + + py_result = PyObject_CallMethod(py_ldb, "search", "OiOO", py_base, req->op.search.scope, py_tree, py_attrs); + + Py_DECREF(py_attrs); + Py_DECREF(py_tree); + Py_DECREF(py_base); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + if (SWIG_ConvertPtr(py_result, &req->op.search.res, SWIGTYPE_p_ldb_result, 0) != 0) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_add(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_msg; + + py_msg = SWIG_NewPointerObj(req->op.add.message, SWIGTYPE_p_ldb_message, 0); + + if (py_msg == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + py_result = PyObject_CallMethod(py_ldb, "add", "O", py_msg); + + Py_DECREF(py_msg); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_modify(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_msg; + + py_msg = SWIG_NewPointerObj(req->op.mod.message, SWIGTYPE_p_ldb_message, 0); + + if (py_msg == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + py_result = PyObject_CallMethod(py_ldb, "modify", "O", py_msg); + + Py_DECREF(py_msg); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_del(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_dn; + + py_dn = SWIG_NewPointerObj(req->op.del.dn, SWIGTYPE_p_ldb_dn, 0); + + if (py_dn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallMethod(py_ldb, "delete", "O", py_dn); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_rename(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result, *py_olddn, *py_newdn; + + py_olddn = SWIG_NewPointerObj(req->op.rename.olddn, SWIGTYPE_p_ldb_dn, 0); + + if (py_olddn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_newdn = SWIG_NewPointerObj(req->op.rename.newdn, SWIGTYPE_p_ldb_dn, 0); + + if (py_newdn == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallMethod(py_ldb, "rename", "OO", py_olddn, py_newdn); + + Py_DECREF(py_olddn); + Py_DECREF(py_newdn); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_request(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "request", ""); + + return LDB_ERR_OPERATIONS_ERROR; +} + +int py_module_extended(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "extended", ""); + + return LDB_ERR_OPERATIONS_ERROR; +} + +int py_module_start_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "start_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_end_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "end_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_del_transaction(struct ldb_module *mod) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "del_transaction", ""); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_wait(struct ldb_handle *mod, enum ldb_wait_type wait_type) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + + py_result = PyObject_CallMethod(py_ldb, "wait", "i", wait_type); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + Py_DECREF(py_result); + + return LDB_SUCCESS; +} + +int py_module_sequence_number(struct ldb_module *mod, struct ldb_request *req) +{ + PyObject *py_ldb = mod->private_data; + PyObject *py_result; + int ret; + + py_result = PyObject_CallMethod(py_ldb, "sequence_number", "ili", req->op.seq_num.type, req->op.seq_num.seq_num, req->op.seq_num.flags); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ret = PyInt_AsLong(py_result); + + Py_DECREF(py_result); + + return ret; +} + +static int py_module_destructor(void *_mod) +{ + struct ldb_module *mod = _mod; + Py_DECREF((PyObject *)mod->private_data); + return 0; +} + +int py_module_init (struct ldb_module *mod) +{ + PyObject *py_class = mod->ops->private_data; + PyObject *py_result, *py_next, *py_ldb; + + py_ldb = SWIG_NewPointerObj(mod->ldb, SWIGTYPE_p_ldb_context, 0); + + if (py_ldb == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_next = SWIG_NewPointerObj(mod->next, SWIGTYPE_p_ldb_module, 0); + + if (py_next == NULL) + return LDB_ERR_OPERATIONS_ERROR; + + py_result = PyObject_CallFunction(py_class, "OO", py_ldb, py_next); + + if (py_result == NULL) { + return LDB_ERR_OPERATIONS_ERROR; + } + + mod->private_data = py_result; + + talloc_set_destructor (mod, py_module_destructor); + + return ldb_next_init(mod); +} + #ifdef __cplusplus extern "C" { #endif @@ -4433,6 +4750,64 @@ fail: } +SWIGINTERN PyObject *_wrap_Ldb_firstmodule_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb *arg1 = (ldb *) 0 ; + struct ldb_module *arg2 = (struct ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args,"Ldb_firstmodule_set",2,2,swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_firstmodule_set" "', argument " "1"" of type '" "ldb *""'"); + } + arg1 = (ldb *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ldb_module, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_firstmodule_set" "', argument " "2"" of type '" "struct ldb_module *""'"); + } + arg2 = (struct ldb_module *)(argp2); + if (arg1 == NULL) + SWIG_exception(SWIG_ValueError, + "ldb context must be non-NULL"); + if (arg1) (arg1)->modules = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_Ldb_firstmodule_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb *arg1 = (ldb *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct ldb_module *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_firstmodule_get" "', argument " "1"" of type '" "ldb *""'"); + } + arg1 = (ldb *)(argp1); + if (arg1 == NULL) + SWIG_exception(SWIG_ValueError, + "ldb context must be non-NULL"); + result = (struct ldb_module *) ((arg1)->modules); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_new_Ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; ldb *result = 0 ; @@ -5707,6 +6082,469 @@ fail: } +SWIGINTERN PyObject *_wrap_ldb_module_prev_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_module *arg2 = (struct ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args,"ldb_module_prev_set",2,2,swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_prev_set" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ldb_module, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_prev_set" "', argument " "2"" of type '" "struct ldb_module *""'"); + } + arg2 = (struct ldb_module *)(argp2); + if (arg1) (arg1)->prev = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_prev_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct ldb_module *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_prev_get" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = (struct ldb_module *) ((arg1)->prev); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_next_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_module *arg2 = (struct ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args,"ldb_module_next_set",2,2,swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_next_set" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ldb_module, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_next_set" "', argument " "2"" of type '" "struct ldb_module *""'"); + } + arg2 = (struct ldb_module *)(argp2); + if (arg1) (arg1)->next = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_next_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct ldb_module *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_next_get" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = (struct ldb_module *) ((arg1)->next); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module___str__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module___str__" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = (char *)ldb_module___str__(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module___repr__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module___repr__" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = (char *)ldb_module___repr__(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_search(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_request *arg2 = (struct ldb_request *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "req", NULL + }; + int result; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_search",kwnames,&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_search" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_request, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_search" "', argument " "2"" of type '" "struct ldb_request *""'"); + } + arg2 = (struct ldb_request *)(argp2); + result = (int)ldb_module_search(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_request *arg2 = (struct ldb_request *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "req", NULL + }; + ldb_error result; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_add",kwnames,&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_add" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_request, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_add" "', argument " "2"" of type '" "struct ldb_request *""'"); + } + arg2 = (struct ldb_request *)(argp2); + result = ldb_module_add(arg1,arg2); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_modify(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_request *arg2 = (struct ldb_request *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "req", NULL + }; + ldb_error result; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_modify",kwnames,&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_modify" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_request, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_modify" "', argument " "2"" of type '" "struct ldb_request *""'"); + } + arg2 = (struct ldb_request *)(argp2); + result = ldb_module_modify(arg1,arg2); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_request *arg2 = (struct ldb_request *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "req", NULL + }; + ldb_error result; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_delete",kwnames,&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_delete" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_request, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_delete" "', argument " "2"" of type '" "struct ldb_request *""'"); + } + arg2 = (struct ldb_request *)(argp2); + result = ldb_module_delete(arg1,arg2); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_rename(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + struct ldb_request *arg2 = (struct ldb_request *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "req", NULL + }; + ldb_error result; + + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_module_rename",kwnames,&obj0,&obj1)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_rename" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_request, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_module_rename" "', argument " "2"" of type '" "struct ldb_request *""'"); + } + arg2 = (struct ldb_request *)(argp2); + result = ldb_module_rename(arg1,arg2); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_start_transaction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + ldb_error result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_start_transaction" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = ldb_module_start_transaction(arg1); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_end_transaction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + ldb_error result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_end_transaction" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = ldb_module_end_transaction(arg1); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ldb_module_del_transaction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + ldb_error result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_module_del_transaction" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + result = ldb_module_del_transaction(arg1); + if (result != 0) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1))); + SWIG_fail; + } + resultobj = Py_None; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_ldb_module(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args,"new_ldb_module",0,0,0)) SWIG_fail; + result = (ldb_module *)calloc(1, sizeof(ldb_module)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_module, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_ldb_module(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + ldb_module *arg1 = (ldb_module *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_module, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ldb_module" "', argument " "1"" of type '" "ldb_module *""'"); + } + arg1 = (ldb_module *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *ldb_module_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_ldb_module, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *ldb_module_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + SWIGINTERN PyObject *_wrap_register_module(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { PyObject *resultobj = 0; struct ldb_module_ops *arg1 = (struct ldb_module_ops *) 0 ; @@ -5719,7 +6557,23 @@ SWIGINTERN PyObject *_wrap_register_module(PyObject *SWIGUNUSEDPARM(self), PyObj if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O:register_module",kwnames,&obj0)) SWIG_fail; arg1 = talloc_zero(talloc_autofree_context(), struct ldb_module_ops); - arg1->name = (char *)PyObject_GetAttrString(obj0, (char *)"name"); + arg1->name = talloc_strdup(arg1, PyString_AsString(PyObject_GetAttrString(obj0, (char *)"name"))); + + Py_INCREF(obj0); + arg1->private_data = obj0; + arg1->init_context = py_module_init; + arg1->search = py_module_search; + arg1->add = py_module_add; + arg1->modify = py_module_modify; + arg1->del = py_module_del; + arg1->rename = py_module_rename; + arg1->request = py_module_request; + arg1->extended = py_module_extended; + arg1->start_transaction = py_module_start_transaction; + arg1->end_transaction = py_module_end_transaction; + arg1->del_transaction = py_module_del_transaction; + arg1->wait = py_module_wait; + arg1->sequence_number = py_module_sequence_number; result = ldb_register_module((struct ldb_module_ops const *)arg1); if (result != 0) { PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_strerror(result))); @@ -5804,6 +6658,8 @@ static PyMethodDef SwigMethods[] = { { (char *)"Message_swigregister", Message_swigregister, METH_VARARGS, NULL}, { (char *)"Message_swiginit", Message_swiginit, METH_VARARGS, NULL}, { (char *)"ldb_ldif_to_pyobject", (PyCFunction) _wrap_ldb_ldif_to_pyobject, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"Ldb_firstmodule_set", _wrap_Ldb_firstmodule_set, METH_VARARGS, NULL}, + { (char *)"Ldb_firstmodule_get", (PyCFunction)_wrap_Ldb_firstmodule_get, METH_O, NULL}, { (char *)"new_Ldb", (PyCFunction)_wrap_new_Ldb, METH_NOARGS, NULL}, { (char *)"Ldb_connect", (PyCFunction) _wrap_Ldb_connect, METH_VARARGS | METH_KEYWORDS, (char *)"\n" "S.connect(url,flags=0,options=None) -> None\n" @@ -5892,6 +6748,24 @@ static PyMethodDef SwigMethods[] = { "S.string_to_time(string) -> int\n" "Parse a LDAP time string into a UNIX timestamp.\n" ""}, + { (char *)"ldb_module_prev_set", _wrap_ldb_module_prev_set, METH_VARARGS, NULL}, + { (char *)"ldb_module_prev_get", (PyCFunction)_wrap_ldb_module_prev_get, METH_O, NULL}, + { (char *)"ldb_module_next_set", _wrap_ldb_module_next_set, METH_VARARGS, NULL}, + { (char *)"ldb_module_next_get", (PyCFunction)_wrap_ldb_module_next_get, METH_O, NULL}, + { (char *)"ldb_module___str__", (PyCFunction)_wrap_ldb_module___str__, METH_O, NULL}, + { (char *)"ldb_module___repr__", (PyCFunction)_wrap_ldb_module___repr__, METH_O, NULL}, + { (char *)"ldb_module_search", (PyCFunction) _wrap_ldb_module_search, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"ldb_module_add", (PyCFunction) _wrap_ldb_module_add, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"ldb_module_modify", (PyCFunction) _wrap_ldb_module_modify, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"ldb_module_delete", (PyCFunction) _wrap_ldb_module_delete, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"ldb_module_rename", (PyCFunction) _wrap_ldb_module_rename, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"ldb_module_start_transaction", (PyCFunction)_wrap_ldb_module_start_transaction, METH_O, NULL}, + { (char *)"ldb_module_end_transaction", (PyCFunction)_wrap_ldb_module_end_transaction, METH_O, NULL}, + { (char *)"ldb_module_del_transaction", (PyCFunction)_wrap_ldb_module_del_transaction, METH_O, NULL}, + { (char *)"new_ldb_module", (PyCFunction)_wrap_new_ldb_module, METH_NOARGS, NULL}, + { (char *)"delete_ldb_module", (PyCFunction)_wrap_delete_ldb_module, METH_O, NULL}, + { (char *)"ldb_module_swigregister", ldb_module_swigregister, METH_VARARGS, NULL}, + { (char *)"ldb_module_swiginit", ldb_module_swiginit, METH_VARARGS, NULL}, { (char *)"register_module", (PyCFunction) _wrap_register_module, METH_VARARGS | METH_KEYWORDS, (char *)"\n" "S.register_module(module) -> None\n" "Register a LDB module.\n" @@ -5911,7 +6785,10 @@ static swig_type_info _swigt__p_ldb_dn = {"_p_ldb_dn", "struct ldb_dn *|ldb_dn * static swig_type_info _swigt__p_ldb_ldif = {"_p_ldb_ldif", "struct ldb_ldif *|ldb_ldif *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_message = {"_p_ldb_message", "ldb_msg *|struct ldb_message *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_message_element *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ldb_module = {"_p_ldb_module", "struct ldb_module *|ldb_module *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_module_ops = {"_p_ldb_module_ops", "struct ldb_module_ops *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ldb_parse_tree = {"_p_ldb_parse_tree", "struct ldb_parse_tree *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ldb_request = {"_p_ldb_request", "struct ldb_request *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_ldb_val = {"_p_ldb_val", "struct ldb_val *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0}; @@ -5937,7 +6814,10 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_ldb_ldif, &_swigt__p_ldb_message, &_swigt__p_ldb_message_element, + &_swigt__p_ldb_module, &_swigt__p_ldb_module_ops, + &_swigt__p_ldb_parse_tree, + &_swigt__p_ldb_request, &_swigt__p_ldb_result, &_swigt__p_ldb_val, &_swigt__p_long_long, @@ -5963,7 +6843,10 @@ static swig_cast_info _swigc__p_ldb_dn[] = { {&_swigt__p_ldb_dn, 0, 0, 0},{0, 0 static swig_cast_info _swigc__p_ldb_ldif[] = { {&_swigt__p_ldb_ldif, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_message[] = { {&_swigt__p_ldb_message, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_message_element[] = { {&_swigt__p_ldb_message_element, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ldb_module[] = { {&_swigt__p_ldb_module, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_module_ops[] = { {&_swigt__p_ldb_module_ops, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ldb_parse_tree[] = { {&_swigt__p_ldb_parse_tree, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ldb_request[] = { {&_swigt__p_ldb_request, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_result[] = { {&_swigt__p_ldb_result, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_ldb_val[] = { {&_swigt__p_ldb_val, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}}; @@ -5989,7 +6872,10 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_ldb_ldif, _swigc__p_ldb_message, _swigc__p_ldb_message_element, + _swigc__p_ldb_module, _swigc__p_ldb_module_ops, + _swigc__p_ldb_parse_tree, + _swigc__p_ldb_request, _swigc__p_ldb_result, _swigc__p_ldb_val, _swigc__p_long_long, diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py index 99ad1a9e66..bc3bbc1c8c 100755 --- a/source4/lib/ldb/tests/python/api.py +++ b/source4/lib/ldb/tests/python/api.py @@ -48,6 +48,14 @@ class SimpleLdb(unittest.TestCase): x = ldb.Ldb() x.set_modules_dir("/tmp") + def test_modules_none(self): + x = ldb.Ldb() + self.assertEquals([], x.modules()) + + def test_modules_tdb(self): + x = ldb.Ldb("bar.ldb") + self.assertEquals("[<ldb module 'tdb'>]", repr(x.modules())) + def test_search(self): l = ldb.Ldb("foo.ldb") self.assertEquals(len(l.search()), 1) @@ -451,12 +459,27 @@ class MessageElementTests(unittest.TestCase): x = ldb.MessageElement(["foo"]) self.assertEquals("foo", x) -class ExampleModule: - name = "example" - class ModuleTests(unittest.TestCase): def test_register_module(self): - ldb.register_module(ExampleModule()) + class ExampleModule: + name = "example" + ldb.register_module(ExampleModule) + + def test_use_module(self): + ops = [] + class ExampleModule: + name = "bla" + + def __init__(self, ldb, next): + ops.append("init") + + ldb.register_module(ExampleModule) + l = ldb.Ldb("usemodule.ldb") + l.add({"dn": "@MODULES", + "@LIST": "bla"}) + self.assertEquals([], ops) + l = ldb.Ldb("usemodule.ldb") + self.assertEquals(["init"], ops) if __name__ == '__main__': import unittest diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk index 8ace68fdb2..cf41f9884a 100644 --- a/source4/librpc/config.mk +++ b/source4/librpc/config.mk @@ -682,7 +682,7 @@ python_atsvc_OBJ_FILES = $(gen_ndrsrcdir)/py_atsvc.o [PYTHON::python_dcerpc_nbt] LIBRARY_REALNAME = samba/nbt.$(SHLIBEXT) -PRIVATE_DEPENDENCIES = NDR_NBT PYTALLOC param swig_credentials python_dcerpc +PRIVATE_DEPENDENCIES = NDR_NBT PYTALLOC param swig_credentials python_dcerpc python_dcerpc_misc python_dcerpc_security python_dcerpc_nbt_OBJ_FILES = $(gen_ndrsrcdir)/py_nbt.o diff --git a/source4/librpc/tests/test_ndrdump.sh b/source4/librpc/tests/test_ndrdump.sh index dddfc0eae1..511856061c 100755 --- a/source4/librpc/tests/test_ndrdump.sh +++ b/source4/librpc/tests/test_ndrdump.sh @@ -8,9 +8,9 @@ failed=0 -samba4bindir=`dirname $0`/../../source4/bin +samba4bindir=`dirname $0`/../../bin ndrdump=$samba4bindir/ndrdump -files=`dirname $0`/ndrdump +files=`dirname $0`/ testit "ndrdump with in" $VALGRIND $ndrdump samr samr_CreateUser in $files/samr-CreateUser-in.dat $@ || failed=`expr $failed + 1` testit "ndrdump with out" $VALGRIND $ndrdump samr samr_CreateUser out $files/samr-CreateUser-out.dat $@ || failed=`expr $failed + 1` diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh index 192f5698e4..bdebddf260 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/samba4_tests.sh @@ -265,7 +265,7 @@ fi bbdir=$incdir/../../testprogs/blackbox -plantest "blackbox.ndrdump" dc $samba4srcdir/librpc/tests/test_ndrdump.sh +plantest "blackbox.ndrdump" none $samba4srcdir/librpc/tests/test_ndrdump.sh plantest "blackbox.net" dc $samba4srcdir/utils/tests/test_net.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" plantest "blackbox.kinit" dc $bbdir/test_kinit.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$REALM" "\$DOMAIN" "$PREFIX" $CONFIGURATION plantest "blackbox.cifsdd" dc $samba4srcdir/client/tests/test_cifsdd.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" diff --git a/testprogs/ejs/samba3sam.js b/testprogs/ejs/samba3sam.js index e5639b8ec8..244074743d 100644 --- a/testprogs/ejs/samba3sam.js +++ b/testprogs/ejs/samba3sam.js @@ -914,6 +914,10 @@ replace: badPwdCount badPwdCount: 4 "; ok = ldb.modify(ldif); + if (ok.error != 0) { + println(ok.errstr); + assert(ok.error == 0); + } /* Check in mapped db */ attrs = new Array("description", "badPwdCount", "nextRid"); res = ldb.search("", dn, ldb.SCOPE_BASE, attrs); @@ -992,6 +996,10 @@ replace: description description: test "; ok = ldb.modify(ldif); + if (ok.error != 0) { + println(ok.errstr); + assert(ok.error == 0); + } /* Check in mapped db */ attrs = new Array("revision", "description"); res = ldb.search("", dn, ldb.SCOPE_BASE, attrs); |