From bbc95fb1a866e8aa822b70a7f5cdf74f1446b1f0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 04:18:31 +0100 Subject: ldb: Fix linking against tevent library (rather than events) replace: Fix copyright for dlfcn.c. --- source4/lib/ldb/Makefile.in | 12 ++++++------ source4/lib/ldb/external/libevents.m4 | 12 ++++++------ source4/lib/ldb/ldb.mk | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source4') diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in index d97ca8bde3..5f59def4af 100644 --- a/source4/lib/ldb/Makefile.in +++ b/source4/lib/ldb/Makefile.in @@ -32,9 +32,9 @@ TDB_LIBS = @TDB_LIBS@ TDB_CFLAGS = @TDB_CFLAGS@ TDB_OBJ = @TDB_OBJ@ -EVENTS_LIBS = @EVENTS_LIBS@ -EVENTS_CFLAGS = @EVENTS_CFLAGS@ -EVENTS_OBJ = @EVENTS_OBJ@ +TEVENT_LIBS = @TEVENT_LIBS@ +TEVENT_CFLAGS = @TEVENT_CFLAGS@ +TEVENT_OBJ = @TEVENT_OBJ@ POPT_LIBS = @POPT_LIBS@ POPT_CFLAGS = @POPT_CFLAGS@ @@ -55,13 +55,13 @@ LIBS = @LIBS@ PICFLAG = @PICFLAG@ CFLAGS=-g -I$(srcdir)/include -Iinclude -I$(srcdir) -I$(srcdir)/.. \ - $(POPT_CFLAGS) $(TALLOC_CFLAGS) $(TDB_CFLAGS) $(EVENTS_CFLAGS) \ + $(POPT_CFLAGS) $(TALLOC_CFLAGS) $(TDB_CFLAGS) $(TEVENT_CFLAGS) \ -DLIBDIR=\"$(libdir)\" -DSHLIBEXT=\"$(SHLIBEXT)\" -DUSE_MMAP=1 @CFLAGS@ MDLD = @MDLD@ MDLD_FLAGS = @MDLD_FLAGS@ -OBJS = $(MODULES_OBJ) $(COMMON_OBJ) $(LDB_TDB_OBJ) $(TDB_OBJ) $(EVENTS_OBJ) $(TALLOC_OBJ) $(POPT_OBJ) $(LDB_MAP_OBJ) @LIBREPLACEOBJ@ $(EXTRA_OBJ) +OBJS = $(MODULES_OBJ) $(COMMON_OBJ) $(LDB_TDB_OBJ) $(TDB_OBJ) $(TEVENT_OBJ) $(TALLOC_OBJ) $(POPT_OBJ) $(LDB_MAP_OBJ) @LIBREPLACEOBJ@ $(EXTRA_OBJ) headers = $(srcdir)/include/ldb.h $(srcdir)/include/ldb_errors.h $(srcdir)/include/ldb_handlers.h @@ -95,7 +95,7 @@ lib/libnss_ldb.$(SHLIBEXT).2: $(NSS_OBJ) $(LIBSOLIB) $(SHLD) $(SHLD_FLAGS) -o $@ $(NSS_OBJ) $(LDFLAGS) $(LIBSOLIB) @SONAMEFLAG@libnss_ldb.$(SHLIBEXT).2 $(LIBSOLIB): $(OBJS) - $(SHLD) $(SHLD_FLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) $(TALLOC_LIBS) $(TDB_LIBS) $(EVENTS_LIBS) $(LIBDL) $(LDAP_LIBS) @SONAMEFLAG@$(SONAME) + $(SHLD) $(SHLD_FLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) $(TALLOC_LIBS) $(TDB_LIBS) $(TEVENT_LIBS) $(LIBDL) $(LDAP_LIBS) @SONAMEFLAG@$(SONAME) ln -sf libldb.$(SHLIBEXT).$(PACKAGE_VERSION) lib/libldb.$(SHLIBEXT) all: showflags dirs $(OBJS) $(STATICLIB) $(LIBSOLIB) $(BINS) $(EXAMPLES) manpages \ diff --git a/source4/lib/ldb/external/libevents.m4 b/source4/lib/ldb/external/libevents.m4 index 4fd2e71ec2..24534f2c21 100644 --- a/source4/lib/ldb/external/libevents.m4 +++ b/source4/lib/ldb/external/libevents.m4 @@ -1,7 +1,7 @@ -AC_SUBST(EVENTS_OBJ) -AC_SUBST(EVENTS_CFLAGS) -AC_SUBST(EVENTS_LIBS) +AC_SUBST(TEVENT_OBJ) +AC_SUBST(TEVENT_CFLAGS) +AC_SUBST(TEVENT_LIBS) -AC_CHECK_HEADER(events.h, - [AC_CHECK_LIB(events, event_context_init, [EVENTS_LIBS="-levents"]) ], - [PKG_CHECK_MODULES(EVENTS, events)]) +AC_CHECK_HEADER(tevent.h, + [AC_CHECK_LIB(tevent, event_context_init, [TEVENT_LIBS="-ltevent"]) ], + [PKG_CHECK_MODULES(TEVENT, tevent)]) diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk index 66cdea15c2..ff8c1f3baf 100644 --- a/source4/lib/ldb/ldb.mk +++ b/source4/lib/ldb/ldb.mk @@ -1,7 +1,7 @@ LDB_LIB = -Llib -lldb LIB_FLAGS=$(LDFLAGS) $(LIBS) $(LDB_LIB) $(POPT_LIBS) $(TALLOC_LIBS) \ - $(TDB_LIBS) $(EVENTS_LIBS) $(LDAP_LIBS) $(LIBDL) + $(TDB_LIBS) $(TEVENT_LIBS) $(LDAP_LIBS) $(LIBDL) LDB_TDB_DIR=ldb_tdb LDB_TDB_OBJ=$(LDB_TDB_DIR)/ldb_tdb.o \ -- cgit From a7f64ba2f1d49b65cd96ba862f6b80b28c3e6dd2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 04:21:35 +0100 Subject: ldb: Include tevent.h rather than events.h. --- source4/lib/ldb/include/ldb_includes.h | 2 +- source4/lib/ldb/ldb_ildap/ldb_ildap.c | 2 +- source4/lib/ldb/pyldb.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source4') diff --git a/source4/lib/ldb/include/ldb_includes.h b/source4/lib/ldb/include/ldb_includes.h index 29c7b2dc5a..b55350a9d4 100644 --- a/source4/lib/ldb/include/ldb_includes.h +++ b/source4/lib/ldb/include/ldb_includes.h @@ -20,7 +20,7 @@ #include "system/filesys.h" #include "system/time.h" #include "talloc.h" -#include "events.h" +#include "tevent.h" #include "ldb.h" #include "ldb_errors.h" #include "ldb_private.h" diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c index b17d063c0c..a95859276f 100644 --- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c +++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c @@ -44,7 +44,7 @@ #include "includes.h" #include "ldb_includes.h" -#include "lib/events/events.h" +#include "tevent.h" #include "libcli/ldap/ldap.h" #include "libcli/ldap/ldap_client.h" #include "auth/auth.h" diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index dfabed54e3..7254772327 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -28,7 +28,7 @@ #include #include #include "pyldb.h" -#include "events.h" +#include "tevent.h" #include "ldb.h" #include "ldb_errors.h" #include "ldb_private.h" -- cgit From 112feeaa35ace32da7620289c676c068dd9585e5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 05:07:29 +0100 Subject: pyldb: Avoid use of pytalloc, as it may not be available. --- source4/lib/ldb/pyldb.c | 234 ++++++++++++++++++++++++++++++++++++------------ source4/lib/ldb/pyldb.h | 56 ++++++++---- 2 files changed, 213 insertions(+), 77 deletions(-) (limited to 'source4') diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index 7254772327..4d4550eb72 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -25,19 +25,14 @@ License along with this library; if not, see . */ -#include -#include +#include "ldb_includes.h" #include "pyldb.h" -#include "tevent.h" -#include "ldb.h" -#include "ldb_errors.h" -#include "ldb_private.h" /* Picked out of thin air. To do this properly, we should probably have some part of the * errors in LDB be allocated to bindings ? */ #define LDB_ERR_PYTHON_EXCEPTION 142 -PyObject *PyExc_LdbError; +static PyObject *PyExc_LdbError; void PyErr_SetLdbError(int ret, struct ldb_context *ldb_ctx) { @@ -45,7 +40,7 @@ void PyErr_SetLdbError(int ret, struct ldb_context *ldb_ctx) return; /* Python exception should already be set, just keep that */ PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", ret, ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx))); } -PyObject *PyObject_FromLdbValue(struct ldb_context *ldb_ctx, +static PyObject *PyObject_FromLdbValue(struct ldb_context *ldb_ctx, struct ldb_message_element *el, struct ldb_val *val) { @@ -129,47 +124,47 @@ static struct ldb_result *PyLdbResult_AsResult(TALLOC_CTX *mem_ctx, PyObject *ob static PyObject *py_ldb_dn_validate(PyLdbDnObject *self) { - return PyBool_FromLong(ldb_dn_validate(self->ptr)); + return PyBool_FromLong(ldb_dn_validate(self->dn)); } static PyObject *py_ldb_dn_is_valid(PyLdbDnObject *self) { - return PyBool_FromLong(ldb_dn_is_valid(self->ptr)); + return PyBool_FromLong(ldb_dn_is_valid(self->dn)); } static PyObject *py_ldb_dn_is_special(PyLdbDnObject *self) { - return PyBool_FromLong(ldb_dn_is_special(self->ptr)); + return PyBool_FromLong(ldb_dn_is_special(self->dn)); } static PyObject *py_ldb_dn_is_null(PyLdbDnObject *self) { - return PyBool_FromLong(ldb_dn_is_null(self->ptr)); + return PyBool_FromLong(ldb_dn_is_null(self->dn)); } static PyObject *py_ldb_dn_get_casefold(PyLdbDnObject *self) { - return PyString_FromString(ldb_dn_get_casefold(self->ptr)); + return PyString_FromString(ldb_dn_get_casefold(self->dn)); } static PyObject *py_ldb_dn_get_linearized(PyLdbDnObject *self) { - return PyString_FromString(ldb_dn_get_linearized(self->ptr)); + return PyString_FromString(ldb_dn_get_linearized(self->dn)); } static PyObject *py_ldb_dn_canonical_str(PyLdbDnObject *self) { - return PyString_FromString(ldb_dn_canonical_string(self->ptr, self->ptr)); + return PyString_FromString(ldb_dn_canonical_string(self->dn, self->dn)); } static PyObject *py_ldb_dn_canonical_ex_str(PyLdbDnObject *self) { - return PyString_FromString(ldb_dn_canonical_ex_string(self->ptr, self->ptr)); + return PyString_FromString(ldb_dn_canonical_ex_string(self->dn, self->dn)); } static PyObject *py_ldb_dn_repr(PyLdbDnObject *self) { - return PyString_FromFormat("Dn(%s)", PyObject_REPR(PyString_FromString(ldb_dn_get_linearized(self->ptr)))); + return PyString_FromFormat("Dn(%s)", PyObject_REPR(PyString_FromString(ldb_dn_get_linearized(self->dn)))); } static PyObject *py_ldb_dn_check_special(PyLdbDnObject *self, PyObject *args) @@ -179,12 +174,12 @@ static PyObject *py_ldb_dn_check_special(PyLdbDnObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "s", &name)) return NULL; - return ldb_dn_check_special(self->ptr, name)?Py_True:Py_False; + return ldb_dn_check_special(self->dn, name)?Py_True:Py_False; } static int py_ldb_dn_compare(PyLdbDnObject *dn1, PyLdbDnObject *dn2) { - return ldb_dn_compare(dn1->ptr, dn2->ptr); + return ldb_dn_compare(dn1->dn, dn2->dn); } static PyObject *py_ldb_dn_get_parent(PyLdbDnObject *self) @@ -289,6 +284,7 @@ static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwa char *str; PyObject *py_ldb; struct ldb_context *ldb_ctx; + PyLdbDnObject *py_ret; const char *kwnames[] = { "ldb", "dn", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Os", (char **)kwnames, &py_ldb, &str)) @@ -306,12 +302,32 @@ static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwa return NULL; } - return py_talloc_import(&PyLdbDn, ret); + py_ret = (PyLdbDnObject *)type->tp_alloc(type, 0); + if (ret == NULL) { + PyErr_NoMemory(); + return NULL; + } + py_ret->dn = ret; + return (PyObject *)py_ret; } PyObject *PyLdbDn_FromDn(struct ldb_dn *dn) { - return py_talloc_import(&PyLdbDn, dn); + PyLdbDnObject *py_ret; + py_ret = (PyLdbDnObject *)PyLdbDn.tp_alloc(&PyLdbDn, 0); + if (py_ret == NULL) { + PyErr_NoMemory(); + return NULL; + } + py_ret->mem_ctx = talloc_new(NULL); + py_ret->dn = talloc_reference(py_ret->mem_ctx, dn); + return (PyObject *)py_ret; +} + +static void py_ldb_dn_dealloc(PyLdbDnObject *self) +{ + talloc_free(self->mem_ctx); + self->ob_type->tp_free(self); } PyTypeObject PyLdbDn = { @@ -323,7 +339,7 @@ PyTypeObject PyLdbDn = { .tp_as_sequence = &py_ldb_dn_seq, .tp_doc = "A LDB distinguished name.", .tp_new = py_ldb_dn_new, - .tp_dealloc = py_talloc_dealloc, + .tp_dealloc = (destructor)py_ldb_dn_dealloc, .tp_basicsize = sizeof(PyLdbObject), .tp_flags = Py_TPFLAGS_DEFAULT, }; @@ -345,7 +361,7 @@ static PyObject *py_ldb_set_debug(PyLdbObject *self, PyObject *args) Py_INCREF(cb); /* FIXME: Where do we DECREF cb ? */ - PyErr_LDB_ERROR_IS_ERR_RAISE(ldb_set_debug(self->ptr, py_ldb_debug, cb), PyLdb_AsLdbContext(self)); + PyErr_LDB_ERROR_IS_ERR_RAISE(ldb_set_debug(self->ldb_ctx, py_ldb_debug, cb), PyLdb_AsLdbContext(self)); return Py_None; } @@ -495,6 +511,7 @@ static int py_ldb_init(PyLdbObject *self, PyObject *args, PyObject *kwargs) static PyObject *py_ldb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { + PyLdbObject *ret; struct ldb_context *ldb; ldb = ldb_init(NULL, event_context_init(NULL)); if (ldb == NULL) { @@ -502,7 +519,13 @@ static PyObject *py_ldb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs return NULL; } - return py_talloc_import(type, ldb); + ret = (PyLdbObject *)type->tp_alloc(type, 0); + if (ret == NULL) { + PyErr_NoMemory(); + return NULL; + } + ret->ldb_ctx = ldb; + return (PyObject *)ret; } static PyObject *py_ldb_connect(PyLdbObject *self, PyObject *args, PyObject *kwargs) @@ -701,7 +724,7 @@ static PyObject *py_ldb_parse_ldif(PyLdbObject *self, PyObject *args) return NULL; list = PyList_New(0); - while ((ldif = ldb_ldif_read_string(self->ptr, &s)) != NULL) { + while ((ldif = ldb_ldif_read_string(self->ldb_ctx, &s)) != NULL) { PyList_Append(list, ldb_ldif_to_pyobject(ldif)); } return PyObject_GetIter(list); @@ -949,7 +972,16 @@ static PyMethodDef py_ldb_methods[] = { PyObject *PyLdbModule_FromModule(struct ldb_module *mod) { - return py_talloc_import(&PyLdbModule, mod); + PyLdbModuleObject *ret; + + ret = (PyLdbModuleObject *)PyLdbModule.tp_alloc(&PyLdbModule, 0); + if (ret == NULL) { + PyErr_NoMemory(); + return NULL; + } + ret->mem_ctx = talloc_new(NULL); + ret->mod = talloc_reference(ret->mem_ctx, mod); + return (PyObject *)ret; } static PyObject *py_ldb_get_firstmodule(PyLdbObject *self, void *closure) @@ -992,7 +1024,22 @@ static PySequenceMethods py_ldb_seq = { PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx) { - return py_talloc_import(&PyLdb, ldb_ctx); + PyLdbObject *ret; + + ret = (PyLdbObject *)PyLdb.tp_alloc(&PyLdb, 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; +} + +static void py_ldb_dealloc(PyLdbObject *self) +{ + talloc_free(self->mem_ctx); + self->ob_type->tp_free(self); } PyTypeObject PyLdb = { @@ -1001,7 +1048,7 @@ PyTypeObject PyLdb = { .tp_repr = (reprfunc)py_ldb_repr, .tp_new = py_ldb_new, .tp_init = (initproc)py_ldb_init, - .tp_dealloc = py_talloc_dealloc, + .tp_dealloc = (destructor)py_ldb_dealloc, .tp_getset = py_ldb_getset, .tp_getattro = PyObject_GenericGetAttr, .tp_basicsize = sizeof(PyLdbObject), @@ -1049,7 +1096,7 @@ static PyObject *py_ldb_module_search(PyLdbModuleObject *self, PyObject *args, P &py_base, &scope, &py_tree, &py_attrs)) return NULL; - mod = self->ptr; + mod = self->mod; ret = ldb_build_search_req(&req, mod->ldb, NULL, PyLdbDn_AsDn(py_base), scope, NULL /* expr */, py_attrs == Py_None?NULL:PyList_AsStringList(req, py_attrs), @@ -1163,13 +1210,19 @@ static PyMethodDef py_ldb_module_methods[] = { { NULL }, }; +static void py_ldb_module_dealloc(PyLdbModuleObject *self) +{ + talloc_free(self->mem_ctx); + self->ob_type->tp_free(self); +} + PyTypeObject PyLdbModule = { .tp_name = "LdbModule", .tp_methods = py_ldb_module_methods, .tp_repr = (reprfunc)py_ldb_module_repr, .tp_str = (reprfunc)py_ldb_module_str, - .tp_basicsize = sizeof(py_talloc_Object), - .tp_dealloc = py_talloc_dealloc, + .tp_basicsize = sizeof(PyLdbModuleObject), + .tp_dealloc = (destructor)py_ldb_module_dealloc, .tp_flags = Py_TPFLAGS_DEFAULT, }; @@ -1210,7 +1263,7 @@ struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx, } -PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx, +static PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx, struct ldb_message_element *me) { int i; @@ -1227,7 +1280,7 @@ PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx, return result; } -PyObject *py_ldb_msg_element_get(PyLdbMessageElementObject *self, PyObject *args) +static PyObject *py_ldb_msg_element_get(PyLdbMessageElementObject *self, PyObject *args) { int i; if (!PyArg_ParseTuple(args, "i", &i)) @@ -1277,7 +1330,15 @@ static PyObject *py_ldb_msg_element_iter(PyLdbMessageElementObject *self) PyObject *PyLdbMessageElement_FromMessageElement(struct ldb_message_element *el, TALLOC_CTX *mem_ctx) { - return py_talloc_import_ex(&PyLdbMessageElement, mem_ctx, el); + PyLdbMessageElementObject *ret; + ret = (PyLdbMessageElementObject *)PyLdbMessageElement.tp_alloc(&PyLdbMessageElement, 0); + if (ret == NULL) { + PyErr_NoMemory(); + return NULL; + } + ret->mem_ctx = talloc_reference(mem_ctx, el); + ret->el = el; + return (PyObject *)ret; } static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) @@ -1287,6 +1348,7 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb int flags = 0; char *name = NULL; const char *kwnames[] = { "elements", "flags", "name", NULL }; + PyLdbMessageElementObject *ret; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Ois", (char **)kwnames, &py_elements, &flags, &name)) return NULL; @@ -1313,7 +1375,15 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb el->flags = flags; el->name = talloc_strdup(el, name); - return py_talloc_import(&PyLdbMessageElement, el); + ret = (PyLdbMessageElementObject *)PyLdbMessageElement.tp_alloc(&PyLdbMessageElement, 0); + if (ret == NULL) { + PyErr_NoMemory(); + talloc_free(el); + return NULL; + } + + ret->mem_ctx = ret->el = el; + return (PyObject *)ret; } static PyObject *py_ldb_msg_element_repr(PyLdbMessageElementObject *self) @@ -1348,10 +1418,16 @@ static PyObject *py_ldb_msg_element_str(PyLdbMessageElementObject *self) return Py_None; } +static void py_ldb_msg_element_dealloc(PyLdbMessageElementObject *self) +{ + talloc_free(self->mem_ctx); + self->ob_type->tp_free(self); +} + PyTypeObject PyLdbMessageElement = { .tp_name = "MessageElement", .tp_basicsize = sizeof(PyLdbMessageElementObject), - .tp_dealloc = py_talloc_dealloc, + .tp_dealloc = (destructor)py_ldb_msg_element_dealloc, .tp_repr = (reprfunc)py_ldb_msg_element_repr, .tp_str = (reprfunc)py_ldb_msg_element_str, .tp_methods = py_ldb_msg_element_methods, @@ -1368,7 +1444,7 @@ static PyObject *py_ldb_msg_remove_attr(PyLdbMessageObject *self, PyObject *args if (!PyArg_ParseTuple(args, "s", &name)) return NULL; - ldb_msg_remove_attr(self->ptr, name); + ldb_msg_remove_attr(self->msg, name); return Py_None; } @@ -1393,13 +1469,14 @@ static PyObject *py_ldb_msg_getitem_helper(PyLdbMessageObject *self, PyObject *p { struct ldb_message_element *el; char *name = PyString_AsString(py_name); + struct ldb_message *msg = PyLdbMessage_AsMessage(self); if (!strcmp(name, "dn")) - return PyLdbDn_FromDn(PyLdbMessage_AsMessage(self)->dn); - el = ldb_msg_find_element(PyLdbMessage_AsMessage(self), name); + return PyLdbDn_FromDn(msg->dn); + el = ldb_msg_find_element(msg, name); if (el == NULL) { return NULL; } - return (PyObject *)PyLdbMessageElement_FromMessageElement(el, self->talloc_ctx); + return (PyObject *)PyLdbMessageElement_FromMessageElement(el, msg); } static PyObject *py_ldb_msg_getitem(PyLdbMessageObject *self, PyObject *py_name) @@ -1435,7 +1512,7 @@ static PyObject *py_ldb_msg_items(PyLdbMessageObject *self) j++; } for (i = 0; i < msg->num_elements; i++, j++) { - PyList_SetItem(l, j, Py_BuildValue("(sO)", msg->elements[i].name, PyLdbMessageElement_FromMessageElement(&msg->elements[i], self->talloc_ctx))); + PyList_SetItem(l, j, Py_BuildValue("(sO)", msg->elements[i].name, PyLdbMessageElement_FromMessageElement(&msg->elements[i], self->msg))); } return l; } @@ -1462,13 +1539,13 @@ static int py_ldb_msg_setitem(PyLdbMessageObject *self, PyObject *name, PyObject { char *attr_name = PyString_AsString(name); if (value == NULL) { - ldb_msg_remove_attr(self->ptr, attr_name); + ldb_msg_remove_attr(self->msg, attr_name); } else { struct ldb_message_element *el = PyObject_AsMessageElement(NULL, value, 0, attr_name); if (el == NULL) return -1; - talloc_steal(self->ptr, el); + talloc_steal(self->msg, el); ldb_msg_remove_attr(PyLdbMessage_AsMessage(self), attr_name); ldb_msg_add(PyLdbMessage_AsMessage(self), el, el->flags); } @@ -1491,6 +1568,7 @@ static PyObject *py_ldb_msg_new(PyTypeObject *type, PyObject *args, PyObject *kw const char *kwnames[] = { "dn", NULL }; struct ldb_message *ret; PyObject *pydn = NULL; + PyLdbMessageObject *py_ret; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O", (char **)kwnames, &pydn)) return NULL; @@ -1504,12 +1582,28 @@ static PyObject *py_ldb_msg_new(PyTypeObject *type, PyObject *args, PyObject *kw if (!PyObject_AsDn(NULL, pydn, NULL, &ret->dn)) return NULL; - return py_talloc_import(type, ret); + py_ret = (PyLdbMessageObject *)type->tp_alloc(type, 0); + if (py_ret == NULL) { + PyErr_NoMemory(); + return NULL; + } + + py_ret->mem_ctx = py_ret->msg = ret; + return (PyObject *)py_ret; } PyObject *PyLdbMessage_FromMessage(struct ldb_message *msg) { - return py_talloc_import(&PyLdbMessage, msg); + PyLdbMessageObject *ret; + + ret = (PyLdbMessageObject *)PyLdbMessage.tp_alloc(&PyLdbMessage, 0); + if (ret == NULL) { + PyErr_NoMemory(); + return NULL; + } + ret->mem_ctx = talloc_new(NULL); + ret->msg = talloc_reference(ret->mem_ctx, msg); + return (PyObject *)ret; } static PyObject *py_ldb_msg_get_dn(PyLdbMessageObject *self, void *closure) @@ -1538,13 +1632,19 @@ static PyObject *py_ldb_msg_repr(PyLdbMessageObject *self) return ret; } +static void py_ldb_msg_dealloc(PyLdbMessageObject *self) +{ + talloc_free(self->mem_ctx); + self->ob_type->tp_free(self); +} + PyTypeObject PyLdbMessage = { .tp_name = "Message", .tp_methods = py_ldb_msg_methods, .tp_getset = py_ldb_msg_getset, .tp_as_mapping = &py_ldb_msg_mapping, .tp_basicsize = sizeof(PyLdbMessageObject), - .tp_dealloc = py_talloc_dealloc, + .tp_dealloc = (destructor)py_ldb_msg_dealloc, .tp_new = py_ldb_msg_new, .tp_repr = (reprfunc)py_ldb_msg_repr, .tp_flags = Py_TPFLAGS_DEFAULT, @@ -1553,18 +1653,34 @@ PyTypeObject PyLdbMessage = { PyObject *PyLdbTree_FromTree(struct ldb_parse_tree *tree) { - return py_talloc_import(&PyLdbTree, tree); + PyLdbTreeObject *ret; + + ret = (PyLdbTreeObject *)PyLdbTree.tp_alloc(&PyLdbTree, 0); + if (ret == NULL) { + PyErr_NoMemory(); + return NULL; + } + + ret->mem_ctx = talloc_new(NULL); + ret->tree = talloc_reference(ret->mem_ctx, tree); + return (PyObject *)ret; +} + +static void py_ldb_tree_dealloc(PyLdbTreeObject *self) +{ + talloc_free(self->mem_ctx); + self->ob_type->tp_free(self); } PyTypeObject PyLdbTree = { .tp_name = "Tree", .tp_basicsize = sizeof(PyLdbTreeObject), - .tp_dealloc = py_talloc_dealloc, + .tp_dealloc = (destructor)py_ldb_tree_dealloc, .tp_flags = Py_TPFLAGS_DEFAULT, }; /* Ldb_module */ -int py_module_search(struct ldb_module *mod, struct ldb_request *req) +static 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; @@ -1609,7 +1725,7 @@ int py_module_search(struct ldb_module *mod, struct ldb_request *req) return LDB_SUCCESS; } -int py_module_add(struct ldb_module *mod, struct ldb_request *req) +static int py_module_add(struct ldb_module *mod, struct ldb_request *req) { PyObject *py_ldb = mod->private_data; PyObject *py_result, *py_msg; @@ -1633,7 +1749,7 @@ int py_module_add(struct ldb_module *mod, struct ldb_request *req) return LDB_SUCCESS; } -int py_module_modify(struct ldb_module *mod, struct ldb_request *req) +static int py_module_modify(struct ldb_module *mod, struct ldb_request *req) { PyObject *py_ldb = mod->private_data; PyObject *py_result, *py_msg; @@ -1657,7 +1773,7 @@ int py_module_modify(struct ldb_module *mod, struct ldb_request *req) return LDB_SUCCESS; } -int py_module_del(struct ldb_module *mod, struct ldb_request *req) +static int py_module_del(struct ldb_module *mod, struct ldb_request *req) { PyObject *py_ldb = mod->private_data; PyObject *py_result, *py_dn; @@ -1678,7 +1794,7 @@ int py_module_del(struct ldb_module *mod, struct ldb_request *req) return LDB_SUCCESS; } -int py_module_rename(struct ldb_module *mod, struct ldb_request *req) +static 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; @@ -1707,7 +1823,7 @@ int py_module_rename(struct ldb_module *mod, struct ldb_request *req) return LDB_SUCCESS; } -int py_module_request(struct ldb_module *mod, struct ldb_request *req) +static int py_module_request(struct ldb_module *mod, struct ldb_request *req) { PyObject *py_ldb = mod->private_data; PyObject *py_result; @@ -1717,7 +1833,7 @@ int py_module_request(struct ldb_module *mod, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } -int py_module_extended(struct ldb_module *mod, struct ldb_request *req) +static int py_module_extended(struct ldb_module *mod, struct ldb_request *req) { PyObject *py_ldb = mod->private_data; PyObject *py_result; @@ -1727,7 +1843,7 @@ int py_module_extended(struct ldb_module *mod, struct ldb_request *req) return LDB_ERR_OPERATIONS_ERROR; } -int py_module_start_transaction(struct ldb_module *mod) +static int py_module_start_transaction(struct ldb_module *mod) { PyObject *py_ldb = mod->private_data; PyObject *py_result; @@ -1743,7 +1859,7 @@ int py_module_start_transaction(struct ldb_module *mod) return LDB_SUCCESS; } -int py_module_end_transaction(struct ldb_module *mod) +static int py_module_end_transaction(struct ldb_module *mod) { PyObject *py_ldb = mod->private_data; PyObject *py_result; @@ -1759,7 +1875,7 @@ int py_module_end_transaction(struct ldb_module *mod) return LDB_SUCCESS; } -int py_module_del_transaction(struct ldb_module *mod) +static int py_module_del_transaction(struct ldb_module *mod) { PyObject *py_ldb = mod->private_data; PyObject *py_result; @@ -1781,7 +1897,7 @@ static int py_module_destructor(struct ldb_module *mod) return 0; } -int py_module_init (struct ldb_module *mod) +static int py_module_init (struct ldb_module *mod) { PyObject *py_class = mod->ops->private_data; PyObject *py_result, *py_next, *py_ldb; diff --git a/source4/lib/ldb/pyldb.h b/source4/lib/ldb/pyldb.h index b55bb68401..731911a387 100644 --- a/source4/lib/ldb/pyldb.h +++ b/source4/lib/ldb/pyldb.h @@ -27,48 +27,68 @@ #define _PYLDB_H_ #include -#include -#include -#include -#include -typedef py_talloc_Object PyLdbObject; +typedef struct { + PyObject_HEAD + struct ldb_context *ldb_ctx; + TALLOC_CTX *mem_ctx; +} PyLdbObject; + PyAPI_DATA(PyTypeObject) PyLdb; PyObject *PyLdb_FromLdbContext(struct ldb_context *ldb_ctx); -#define PyLdb_AsLdbContext(pyobj) py_talloc_get_type(pyobj, struct ldb_context) +#define PyLdb_AsLdbContext(pyobj) ((PyLdbObject *)pyobj)->ldb_ctx #define PyLdb_Check(ob) PyObject_TypeCheck(ob, &PyLdb) -typedef py_talloc_Object PyLdbDnObject; +typedef struct { + PyObject_HEAD + struct ldb_dn *dn; + TALLOC_CTX *mem_ctx; +} PyLdbDnObject; + PyAPI_DATA(PyTypeObject) PyLdbDn; -struct ldb_dn *PyLdbDn_AsDn(PyObject *); PyObject *PyLdbDn_FromDn(struct ldb_dn *); bool PyObject_AsDn(TALLOC_CTX *mem_ctx, PyObject *object, struct ldb_context *ldb_ctx, struct ldb_dn **dn); -#define PyLdbDn_AsDn(pyobj) py_talloc_get_type(pyobj, struct ldb_dn) +#define PyLdbDn_AsDn(pyobj) ((PyLdbDnObject *)pyobj)->dn #define PyLdbDn_Check(ob) PyObject_TypeCheck(ob, &PyLdbDn) -typedef py_talloc_Object PyLdbMessageObject; +typedef struct { + PyObject_HEAD + struct ldb_message *msg; + TALLOC_CTX *mem_ctx; +} PyLdbMessageObject; PyAPI_DATA(PyTypeObject) PyLdbMessage; PyObject *PyLdbMessage_FromMessage(struct ldb_message *message); -struct ldb_message *PyLdbMessage_AsMessage(PyObject *obj); #define PyLdbMessage_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessage) -#define PyLdbMessage_AsMessage(pyobj) py_talloc_get_type(pyobj, struct ldb_message) +#define PyLdbMessage_AsMessage(pyobj) ((PyLdbMessageObject *)pyobj)->msg -typedef py_talloc_Object PyLdbModuleObject; +typedef struct { + PyObject_HEAD + struct ldb_module *mod; + TALLOC_CTX *mem_ctx; +} PyLdbModuleObject; PyAPI_DATA(PyTypeObject) PyLdbModule; PyObject *PyLdbModule_FromModule(struct ldb_module *mod); -#define PyLdbModule_AsModule(pyobj) ((struct ldb_module *)py_talloc_get_ptr(pyobj)) +#define PyLdbModule_AsModule(pyobj) ((PyLdbModuleObject *)pyobj)->mod -typedef py_talloc_Object PyLdbMessageElementObject; +typedef struct { + PyObject_HEAD + struct ldb_message_element *el; + TALLOC_CTX *mem_ctx; +} PyLdbMessageElementObject; PyAPI_DATA(PyTypeObject) PyLdbMessageElement; struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx, PyObject *obj, int flags, const char *name); PyObject *PyLdbMessageElement_FromMessageElement(struct ldb_message_element *, TALLOC_CTX *mem_ctx); -#define PyLdbMessageElement_AsMessageElement(pyobj) ((struct ldb_message_element *)py_talloc_get_ptr(pyobj)) +#define PyLdbMessageElement_AsMessageElement(pyobj) ((PyLdbMessageElementObject *)pyobj)->el #define PyLdbMessageElement_Check(ob) PyObject_TypeCheck(ob, &PyLdbMessageElement) -typedef py_talloc_Object PyLdbTreeObject; +typedef struct { + PyObject_HEAD + struct ldb_parse_tree *tree; + TALLOC_CTX *mem_ctx; +} PyLdbTreeObject; PyAPI_DATA(PyTypeObject) PyLdbTree; PyObject *PyLdbTree_FromTree(struct ldb_parse_tree *); -#define PyLdbTree_AsTree(pyobj) py_talloc_get_type(pyobj, struct ldb_parse_tree) +#define PyLdbTree_AsTree(pyobj) ((PyLdbTreeObject *)pyobj)->tree void PyErr_SetLdbError(int ret, struct ldb_context *ldb_ctx); #define PyErr_LDB_ERROR_IS_ERR_RAISE(ret,ldb) \ -- cgit From 8ce77a57ccc4d5ff4a216d74c4fc58782fc9098c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 05:34:21 +0100 Subject: pyldb: Fix segfault because of incorrect reference counting. --- source4/lib/ldb/Makefile.in | 2 +- source4/lib/ldb/pyldb.c | 27 ++++++++++++++++++++------- source4/scripting/python/pyglue.c | 1 + 3 files changed, 22 insertions(+), 8 deletions(-) (limited to 'source4') diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in index 5f59def4af..6155f6e49c 100644 --- a/source4/lib/ldb/Makefile.in +++ b/source4/lib/ldb/Makefile.in @@ -88,7 +88,7 @@ STATICLIB = lib/libldb.a lib/$(SONAME): $(LIBSOLIB) ln -fs libldb.$(SHLIBEXT).$(PACKAGE_VERSION) $@ -lib/libldb.$(SHLIBEXT): $(LIBSOLIB) +lib/libldb.$(SHLIBEXT): $(LIBSOLIB) lib/$(SONAME) ln -fs libldb.$(SHLIBEXT).$(PACKAGE_VERSION) $@ lib/libnss_ldb.$(SHLIBEXT).2: $(NSS_OBJ) $(LIBSOLIB) diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index 4d4550eb72..a60307c9eb 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -1243,14 +1243,16 @@ struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx, me->num_values = 1; me->values = talloc_array(me, struct ldb_val, me->num_values); me->values[0].length = PyString_Size(set_obj); - me->values[0].data = (uint8_t *)talloc_strdup(me->values, - PyString_AsString(set_obj)); + me->values[0].data = (uint8_t *)talloc_strndup(me->values, + PyString_AsString(set_obj), + me->values[0].length); } else if (PySequence_Check(set_obj)) { int i; me->num_values = PySequence_Size(set_obj); me->values = talloc_array(me, struct ldb_val, me->num_values); for (i = 0; i < me->num_values; i++) { PyObject *obj = PySequence_GetItem(set_obj, i); + me->values[i].length = PyString_Size(obj); me->values[i].data = (uint8_t *)PyString_AsString(obj); } @@ -1336,7 +1338,11 @@ PyObject *PyLdbMessageElement_FromMessageElement(struct ldb_message_element *el, PyErr_NoMemory(); return NULL; } - ret->mem_ctx = talloc_reference(mem_ctx, el); + ret->mem_ctx = talloc_new(NULL); + if (talloc_reference(ret->mem_ctx, mem_ctx) == NULL) { + PyErr_NoMemory(); + return NULL; + } ret->el = el; return (PyObject *)ret; } @@ -1356,12 +1362,12 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb if (py_elements != NULL) { int i; - if (!PySequence_Check(py_elements)) { + if (PyString_Check(py_elements)) { el->num_values = 1; el->values = talloc_array(el, struct ldb_val, 1); el->values[0].data = (uint8_t *)PyString_AsString(py_elements); el->values[0].length = PyString_Size(py_elements); - } else { + } else if (PySequence_Check(py_elements)) { el->num_values = PySequence_Size(py_elements); el->values = talloc_array(el, struct ldb_val, el->num_values); for (i = 0; i < el->num_values; i++) { @@ -1369,6 +1375,11 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb el->values[i].data = (uint8_t *)PyString_AsString(item); el->values[i].length = PyString_Size(item); } + } else { + PyErr_SetString(PyExc_TypeError, + "Expected string or list"); + talloc_free(el); + return NULL; } } @@ -1382,7 +1393,8 @@ static PyObject *py_ldb_msg_element_new(PyTypeObject *type, PyObject *args, PyOb return NULL; } - ret->mem_ctx = ret->el = el; + ret->mem_ctx = talloc_new(NULL); + ret->el = talloc_reference(ret->mem_ctx, el); return (PyObject *)ret; } @@ -1588,7 +1600,8 @@ static PyObject *py_ldb_msg_new(PyTypeObject *type, PyObject *args, PyObject *kw return NULL; } - py_ret->mem_ctx = py_ret->msg = ret; + py_ret->mem_ctx = talloc_new(NULL); + py_ret->msg = talloc_reference(py_ret->mem_ctx, ret); return (PyObject *)py_ret; } diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c index 1b59978477..c882240b63 100644 --- a/source4/scripting/python/pyglue.c +++ b/source4/scripting/python/pyglue.c @@ -18,6 +18,7 @@ #include "includes.h" #include "ldb.h" +#include "ldb_errors.h" #include "param/param.h" #include "auth/credentials/credentials.h" #include "dsdb/samdb/samdb.h" -- cgit From 58cfb1a9e1470b86f664e489e20cde7af294d07b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 11:25:06 +0100 Subject: python: Define Py_ssize_t if the Python library doesn't. --- source4/lib/ldb/pyldb.c | 6 ++++++ source4/param/pyparam.c | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'source4') diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index a60307c9eb..f4f43a3d0b 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -28,6 +28,12 @@ #include "ldb_includes.h" #include "pyldb.h" +/* There's no Py_ssize_t in 2.4, apparently */ +#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5 +typedef int Py_ssize_t; +typedef inquiry lenfunc; +#endif + /* Picked out of thin air. To do this properly, we should probably have some part of the * errors in LDB be allocated to bindings ? */ #define LDB_ERR_PYTHON_EXCEPTION 142 diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index acadcc08b0..69c2613a09 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -25,6 +25,12 @@ #include "param/loadparm.h" #include "pytalloc.h" +/* There's no Py_ssize_t in 2.4, apparently */ +#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5 +typedef int Py_ssize_t; +typedef inquiry lenfunc; +#endif + #define PyLoadparmContext_AsLoadparmContext(obj) py_talloc_get_ptr(obj) PyAPI_DATA(PyTypeObject) PyLoadparmContext; -- cgit From 00b61ff2cfa145f9c0bcf74a7a2672e1172fb9c1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 11:44:10 +0100 Subject: samba.tests.samdb: Fix test after merger of samba.security and samba.dcerpc.security --- source4/scripting/python/samba/tests/samdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index 97be5672ce..cce6ea84d3 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -22,7 +22,7 @@ import os from samba.provision import setup_samdb, guess_names, setup_templatesdb, make_smbconf from samba.samdb import SamDB from samba.tests import cmdline_loadparm, TestCaseInTempDir -from samba import security +from samba.dcerpc import security from unittest import TestCase import uuid from samba import param -- cgit From 4bbd2cbab73d46d0f8e8ba3fe164b6802b379b06 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 11:48:14 +0100 Subject: pyldb: Provide replacement for sizeargfunc, not available before Python2.5. --- source4/lib/ldb/pyldb.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4') diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index f4f43a3d0b..ed77added5 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -32,6 +32,7 @@ #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5 typedef int Py_ssize_t; typedef inquiry lenfunc; +typedef intargfunc sizeargfunc; #endif /* Picked out of thin air. To do this properly, we should probably have some part of the -- cgit From 227c8000dfee4248fc2d13104382542e449a1897 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 12:14:25 +0100 Subject: Fix silly typo. --- source4/lib/ldb/pyldb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index ed77added5..10b9691ae0 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -32,7 +32,7 @@ #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5 typedef int Py_ssize_t; typedef inquiry lenfunc; -typedef intargfunc sizeargfunc; +typedef intargfunc ssizeargfunc; #endif /* Picked out of thin air. To do this properly, we should probably have some part of the -- cgit From 465f78021e609719bf25b7d2933c47b7ab1b6940 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 19:28:22 +0100 Subject: Move Samba4-specific file out of common libtevent. --- source4/lib/basic.mk | 1 + source4/lib/events/config.mk | 2 +- source4/lib/events/events_dummy.c | 4 --- source4/lib/events/tevent_s4.c | 72 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 5 deletions(-) delete mode 100644 source4/lib/events/events_dummy.c create mode 100644 source4/lib/events/tevent_s4.c (limited to 'source4') diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk index 4d076684cd..4b40ed41d4 100644 --- a/source4/lib/basic.mk +++ b/source4/lib/basic.mk @@ -23,3 +23,4 @@ TDB_WRAP_OBJ_FILES = $(libsrcdir)/tdb_wrap.o PUBLIC_HEADERS += $(libsrcdir)/tdb_wrap.h SMBREADLINE_OBJ_LIST = $(SMBREADLINE_OBJ_FILES) + diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk index b9d6879b3c..a1b2cd218a 100644 --- a/source4/lib/events/config.mk +++ b/source4/lib/events/config.mk @@ -2,6 +2,6 @@ PUBLIC_DEPENDENCIES = LIBTEVENT CFLAGS = -Ilib/events -LIBEVENTS_OBJ_FILES = $(addprefix $(libeventssrcdir)/, events_dummy.o) +LIBEVENTS_OBJ_FILES = $(addprefix $(libeventssrcdir)/, tevent_s4.o) PUBLIC_HEADERS += $(addprefix $(libeventssrcdir)/, events.h events_internal.h) diff --git a/source4/lib/events/events_dummy.c b/source4/lib/events/events_dummy.c deleted file mode 100644 index 15bb25e953..0000000000 --- a/source4/lib/events/events_dummy.c +++ /dev/null @@ -1,4 +0,0 @@ -void __events_dummy(void) -{ -} - diff --git a/source4/lib/events/tevent_s4.c b/source4/lib/events/tevent_s4.c new file mode 100644 index 0000000000..80267fdd22 --- /dev/null +++ b/source4/lib/events/tevent_s4.c @@ -0,0 +1,72 @@ +/* + Unix SMB/CIFS implementation. + Copyright (C) Andrew Tridgell 2003 + + 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 "tevent.h" +#include "tevent_internal.h" + +/* + this is used to catch debug messages from events +*/ +static void ev_wrap_debug(void *context, enum ev_debug_level level, + const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0); + +static void ev_wrap_debug(void *context, enum ev_debug_level level, + const char *fmt, va_list ap) +{ + int samba_level = -1; + char *s = NULL; + switch (level) { + case EV_DEBUG_FATAL: + samba_level = 0; + break; + case EV_DEBUG_ERROR: + samba_level = 1; + break; + case EV_DEBUG_WARNING: + samba_level = 2; + break; + case EV_DEBUG_TRACE: + samba_level = 5; + break; + + }; + vasprintf(&s, fmt, ap); + if (!s) return; + DEBUG(samba_level, ("events: %s\n", s)); + free(s); +} + +/* + create a event_context structure. This must be the first events + call, and all subsequent calls pass this event_context as the first + element. Event handlers also receive this as their first argument. + + This samba4 specific call sets the samba4 debug handler. +*/ +struct event_context *s4_event_context_init(TALLOC_CTX *mem_ctx) +{ + struct event_context *ev; + + ev = event_context_init_byname(mem_ctx, NULL); + if (ev) { + ev_set_debug(ev, ev_wrap_debug, NULL); + } + return ev; +} + -- cgit From 8b24da201b78ddda3738564f2d69c96ab4ed9919 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 19:59:57 +0100 Subject: Allow using external libtevent. --- source4/build/smb_build/summary.pm | 1 + source4/configure.ac | 13 +++++++++++-- source4/main.mk | 1 - 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'source4') diff --git a/source4/build/smb_build/summary.pm b/source4/build/smb_build/summary.pm index f6c1c50550..c7916216ab 100644 --- a/source4/build/smb_build/summary.pm +++ b/source4/build/smb_build/summary.pm @@ -57,6 +57,7 @@ sub show($$) showisexternal($output, "popt", "LIBPOPT"); showisexternal($output, "talloc", "LIBTALLOC"); showisexternal($output, "tdb", "LIBTDB"); + showisexternal($output, "tevent", "LIBTEVENT"); showisexternal($output, "ldb", "LIBLDB"); print "Developer mode: ".(enabled($config->{developer})?"yes":"no")."\n"; print "Automatic dependencies: ". diff --git a/source4/configure.ac b/source4/configure.ac index aa5a3f3b3e..45154c8c88 100644 --- a/source4/configure.ac +++ b/source4/configure.ac @@ -34,7 +34,6 @@ m4_include(../nsswitch/nsstest.m4) m4_include(../pidl/config.m4) AC_CONFIG_FILES(lib/registry/registry.pc) -AC_CONFIG_FILES(../lib/tevent/tevent.pc) AC_CONFIG_FILES(librpc/dcerpc.pc) AC_CONFIG_FILES(../librpc/ndr.pc) AC_CONFIG_FILES(../lib/torture/torture.pc) @@ -61,6 +60,17 @@ SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.3, SMB_INCLUDE_MK(../lib/tdb/python.mk) +SMB_EXT_LIB_FROM_PKGCONFIG(LIBTEVENT, tevent >= 1.0.0, + [], + [ + m4_include(../lib/tevent/libtevent.m4) + SMB_INCLUDE_MK(../lib/tevent/config.mk) + AC_CONFIG_FILES(../lib/tevent/tevent.pc) + ] +) + +SMB_INCLUDE_MK(../lib/tevent/python.mk) + SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb = 0.9.1, [ SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk) @@ -96,7 +106,6 @@ SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb = 0.9.1, SMB_INCLUDE_MK(lib/ldb/python.mk) m4_include(lib/tls/config.m4) -m4_include(../lib/tevent/libtevent.m4) dnl m4_include(auth/kerberos/config.m4) m4_include(auth/gensec/config.m4) diff --git a/source4/main.mk b/source4/main.mk index e54196a2f9..1d4ffc5d44 100644 --- a/source4/main.mk +++ b/source4/main.mk @@ -14,7 +14,6 @@ mkinclude lib/ldb-samba/config.mk mkinclude lib/tls/config.mk mkinclude lib/registry/config.mk mkinclude lib/messaging/config.mk -mkinclude ../lib/tevent/config.mk mkinclude lib/events/config.mk mkinclude lib/cmdline/config.mk mkinclude ../lib/socket_wrapper/config.mk -- cgit From 7c6a20a439e5e6e9b4149df77896eea57d931e73 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Tue, 23 Dec 2008 20:17:59 +0100 Subject: Add missing includes, required for use of gensec by 3rd-party applications. --- source4/auth/gensec/gensec.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4') diff --git a/source4/auth/gensec/gensec.h b/source4/auth/gensec/gensec.h index 235d2008fb..87c9b4d169 100644 --- a/source4/auth/gensec/gensec.h +++ b/source4/auth/gensec/gensec.h @@ -23,6 +23,9 @@ #ifndef __GENSEC_H__ #define __GENSEC_H__ +#include "../lib/util/data_blob.h" +#include "libcli/util/ntstatus.h" + #define GENSEC_OID_NTLMSSP "1.3.6.1.4.1.311.2.2.10" #define GENSEC_OID_SPNEGO "1.3.6.1.5.5.2" #define GENSEC_OID_KERBEROS5 "1.2.840.113554.1.2.2" -- cgit From ff26cb4b1c1d0292231e1cfc0490f4be6040d3e3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 23 Dec 2008 22:11:21 +0100 Subject: Fix compiler warnings in libnet. --- source4/libnet/groupinfo.c | 5 +---- source4/libnet/groupman.c | 4 +--- source4/libnet/libnet_become_dc.c | 4 ++-- source4/libnet/libnet_join.c | 2 ++ source4/libnet/userinfo.c | 5 +---- source4/libnet/userman.c | 7 ++----- 6 files changed, 9 insertions(+), 18 deletions(-) (limited to 'source4') diff --git a/source4/libnet/groupinfo.c b/source4/libnet/groupinfo.c index 5c94c34b1d..1779c2816e 100644 --- a/source4/libnet/groupinfo.c +++ b/source4/libnet/groupinfo.c @@ -24,13 +24,10 @@ #include "includes.h" #include "libcli/composite/composite.h" -#include "libnet/composite.h" #include "librpc/gen_ndr/security.h" #include "libcli/security/security.h" -#include "libnet/userman.h" -#include "libnet/groupinfo.h" +#include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr_c.h" -#include "libnet/libnet_proto.h" struct groupinfo_state { diff --git a/source4/libnet/groupman.c b/source4/libnet/groupman.c index 4dfb2d8aab..0f54db9705 100644 --- a/source4/libnet/groupman.c +++ b/source4/libnet/groupman.c @@ -23,10 +23,8 @@ #include "includes.h" #include "libcli/composite/composite.h" -#include "libnet/composite.h" -#include "libnet/groupman.h" +#include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr_c.h" -#include "libnet/libnet_proto.h" struct groupadd_state { diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c index 6e7924248c..294ea4b79c 100644 --- a/source4/libnet/libnet_become_dc.c +++ b/source4/libnet/libnet_become_dc.c @@ -1511,8 +1511,8 @@ static void becomeDC_drsuapi_connect_send(struct libnet_BecomeDC_state *s, drsuapi->s = s; if (!drsuapi->binding) { - char *krb5_str = ""; - char *print_str = ""; + const char *krb5_str = ""; + const char *print_str = ""; /* * Note: Replication only works with Windows 2000 when 'krb5' is * passed as auth_type here. If NTLMSSP is used, Windows diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c index 70fcb4a894..0a4e357925 100644 --- a/source4/libnet/libnet_join.c +++ b/source4/libnet/libnet_join.c @@ -1223,6 +1223,8 @@ NTSTATUS libnet_Join(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct lib case SEC_CHAN_BDC: return libnet_Join_primary_domain(ctx, mem_ctx, r); case SEC_CHAN_DOMAIN: + case SEC_CHAN_DNS_DOMAIN: + case SEC_CHAN_NULL: break; } diff --git a/source4/libnet/userinfo.c b/source4/libnet/userinfo.c index 710154d41e..a718ab9e85 100644 --- a/source4/libnet/userinfo.c +++ b/source4/libnet/userinfo.c @@ -23,13 +23,10 @@ #include "includes.h" #include "libcli/composite/composite.h" -#include "libnet/composite.h" #include "librpc/gen_ndr/security.h" #include "libcli/security/security.h" -#include "libnet/userman.h" -#include "libnet/userinfo.h" +#include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr_c.h" -#include "libnet/libnet_proto.h" struct userinfo_state { diff --git a/source4/libnet/userman.c b/source4/libnet/userman.c index c638d8af32..62d4e0edd2 100644 --- a/source4/libnet/userman.c +++ b/source4/libnet/userman.c @@ -23,11 +23,8 @@ #include "includes.h" #include "libcli/composite/composite.h" -#include "libnet/composite.h" -#include "libnet/userman.h" -#include "libnet/userinfo.h" +#include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr_c.h" -#include "libnet/libnet_proto.h" /* * Composite USER ADD functionality @@ -684,7 +681,7 @@ static NTSTATUS usermod_change(struct composite_context *c, s->queryuser.in.user_handle = &s->user_handle; s->queryuser.in.level = level; s->queryuser.out.info = talloc(s, union samr_UserInfo *); - if (composite_nomem(s->queryuser.out.info, c)) return; + if (composite_nomem(s->queryuser.out.info, c)) return NT_STATUS_NO_MEMORY; /* send query user info request to retrieve complete data of -- cgit