The branch, master has been updated via 4c373d2 s4:scripting/python/pyglue.c - add a OOM handling via 13da83b s4:scripting/python/pyglue.c - optimise includes via c5deda5 s4:param/provision.c - optimise includes via 34c5bdc s4:libcli/finddc.h - fix header dependancies via 721c3b1 s4:libcli/finddcs_nbt.c - optimise headers via f9b8735 s4:libnet/py_net.c - add checks for OOM conditions via c8d8887 s4:dsdb/pydsdb.c and web_server/wsgi.c - remove accidentally introduced Py_RETURN_NONE via 65bcde2 s4:lib/ldb-samba/pyldb.c - optimise includes via b974966 s4:dsdb/pydsdb.c - clean up memory handling via b56a6f2 ldb:pyldb - optimise includes from 93ea5cb change searched name from _ss_family to __ss_family
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 4c373d20131fecf09a3e8c053597f68d772b8d55 Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Sun Dec 12 19:23:53 2010 +0100 s4:scripting/python/pyglue.c - add a OOM handling Autobuild-User: Matthias Dieter Wallnöfer <m...@samba.org> Autobuild-Date: Sun Dec 12 20:50:55 CET 2010 on sn-devel-104 commit 13da83be60ef79d1ba75455f9b96f7dfb80bd43a Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Sun Dec 12 19:23:34 2010 +0100 s4:scripting/python/pyglue.c - optimise includes commit c5deda5d85707cf12b491e4887ca2871be742128 Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Sun Dec 12 19:19:43 2010 +0100 s4:param/provision.c - optimise includes commit 34c5bdc1c329a2f3b4ab3a4dfff4c747f2910379 Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Sun Dec 12 19:13:51 2010 +0100 s4:libcli/finddc.h - fix header dependancies And optimise includes commit 721c3b1c4ba75f9fc846483af325615e0d0420f0 Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Sun Dec 12 19:01:23 2010 +0100 s4:libcli/finddcs_nbt.c - optimise headers commit f9b87352f40c04446bd2456064088df2510e8f70 Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Sun Dec 12 18:54:56 2010 +0100 s4:libnet/py_net.c - add checks for OOM conditions commit c8d888772a855b6f9b7f4b06412b1b4c84174ef8 Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Sun Dec 12 18:45:07 2010 +0100 s4:dsdb/pydsdb.c and web_server/wsgi.c - remove accidentally introduced Py_RETURN_NONE This was only thought for Python 2.3 which we generally no longer support (only pyldb in the LDB library is an exception). commit 65bcde23346c16e044e7587de1e7a6fc130b276f Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Sun Dec 12 18:42:58 2010 +0100 s4:lib/ldb-samba/pyldb.c - optimise includes commit b974966cc2b4d0b5b0d83206070b5f7c5c6495d1 Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Sun Dec 12 18:31:37 2010 +0100 s4:dsdb/pydsdb.c - clean up memory handling - Remove memory contexts when not really useful (if only one allocation) - Try to find out OOM conditions and return correct error codes - Move the parameter parsing always to the beginning (to prevent unneeded allocations in case of errors) commit b56a6f2eda228698a2433ea2365fda5967bd904c Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Sun Dec 12 17:44:04 2010 +0100 ldb:pyldb - optimise includes ----------------------------------------------------------------------- Summary of changes: source4/dsdb/pydsdb.c | 128 ++++++++++++++++++++----------------- source4/lib/ldb-samba/pyldb.c | 4 +- source4/lib/ldb/pyldb.c | 3 - source4/lib/ldb/pyldb.h | 3 +- source4/lib/ldb/pyldb_util.c | 3 - source4/libcli/finddc.h | 2 + source4/libcli/finddcs_cldap.c | 2 - source4/libcli/finddcs_nbt.c | 2 - source4/libnet/libnet_lookup.c | 6 -- source4/libnet/py_net.c | 19 ++++-- source4/param/provision.c | 10 +--- source4/scripting/python/pyglue.c | 8 +- source4/web_server/wsgi.c | 4 - source4/winbind/wb_dom_info.c | 2 - 14 files changed, 94 insertions(+), 102 deletions(-) Changeset truncated at 500 lines: diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c index f5832d1..64b7266 100644 --- a/source4/dsdb/pydsdb.c +++ b/source4/dsdb/pydsdb.c @@ -17,11 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <Python.h> +#include "lib/ldb/pyldb.h" #include "includes.h" -#include "libcli/util/pyerrors.h" #include "dsdb/samdb/samdb.h" -#include "lib/ldb/pyldb.h" #include "libcli/security/security.h" #include "librpc/ndr/libndr.h" #include "system/kerberos.h" @@ -36,10 +34,6 @@ typedef inquiry lenfunc; typedef intargfunc ssizeargfunc; #endif -#ifndef Py_RETURN_NONE -#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None -#endif - /* FIXME: These should be in a header file somewhere, once we finish moving * away from SWIG .. */ #define PyErr_LDB_OR_RAISE(py_ldb, ldb) \ @@ -81,6 +75,10 @@ static PyObject *py_samdb_server_site_name(PyObject *self, PyObject *args) PyErr_LDB_OR_RAISE(py_ldb, ldb); mem_ctx = talloc_new(NULL); + if (mem_ctx == NULL) { + PyErr_NoMemory(); + return NULL; + } site = samdb_server_site_name(ldb, mem_ctx); if (site == NULL) { @@ -133,6 +131,10 @@ static PyObject *py_samdb_set_domain_sid(PyLdbObject *self, PyObject *args) PyErr_LDB_OR_RAISE(py_ldb, ldb); sid = dom_sid_parse_talloc(NULL, PyString_AsString(py_sid)); + if (sid == NULL) { + PyErr_NoMemory(); + return NULL; + } ret = samdb_set_domain_sid(ldb, sid); talloc_free(sid); @@ -153,7 +155,7 @@ static PyObject *py_samdb_set_ntds_settings_dn(PyLdbObject *self, PyObject *args if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_ntds_settings_dn)) return NULL; - + PyErr_LDB_OR_RAISE(py_ldb, ldb); tmp_ctx = talloc_new(NULL); @@ -163,6 +165,8 @@ static PyObject *py_samdb_set_ntds_settings_dn(PyLdbObject *self, PyObject *args } if (!PyObject_AsDn(tmp_ctx, py_ntds_settings_dn, ldb, &ntds_settings_dn)) { + PyErr_NoMemory(); + talloc_free(tmp_ctx); return NULL; } @@ -185,15 +189,20 @@ static PyObject *py_samdb_get_domain_sid(PyLdbObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "O", &py_ldb)) return NULL; - + PyErr_LDB_OR_RAISE(py_ldb, ldb); sid = samdb_domain_sid(ldb); if (!sid) { PyErr_SetString(PyExc_RuntimeError, "samdb_domain_sid failed"); return NULL; - } + } + retstr = dom_sid_string(NULL, sid); + if (retstr == NULL) { + PyErr_NoMemory(); + return NULL; + } ret = PyString_FromString(retstr); talloc_free(retstr); return ret; @@ -203,17 +212,10 @@ static PyObject *py_samdb_ntds_invocation_id(PyObject *self, PyObject *args) { PyObject *py_ldb, *result; struct ldb_context *ldb; - TALLOC_CTX *mem_ctx; const struct GUID *guid; - - mem_ctx = talloc_new(NULL); - if (mem_ctx == NULL) { - PyErr_NoMemory(); - return NULL; - } + char *retstr; if (!PyArg_ParseTuple(args, "O", &py_ldb)) { - talloc_free(mem_ctx); return NULL; } @@ -223,12 +225,16 @@ static PyObject *py_samdb_ntds_invocation_id(PyObject *self, PyObject *args) if (guid == NULL) { PyErr_SetString(PyExc_RuntimeError, "Failed to find NTDS invocation ID"); - talloc_free(mem_ctx); return NULL; } - result = PyString_FromString(GUID_string(mem_ctx, guid)); - talloc_free(mem_ctx); + retstr = GUID_string(NULL, guid); + if (retstr == NULL) { + PyErr_NoMemory(); + return NULL; + } + result = PyString_FromString(retstr); + talloc_free(retstr); return result; } @@ -240,7 +246,6 @@ static PyObject *py_dsdb_get_oid_from_attid(PyObject *self, PyObject *args) struct dsdb_schema *schema; const char *oid; PyObject *ret; - TALLOC_CTX *mem_ctx; WERROR status; if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &attid)) @@ -248,27 +253,19 @@ static PyObject *py_dsdb_get_oid_from_attid(PyObject *self, PyObject *args) PyErr_LDB_OR_RAISE(py_ldb, ldb); - mem_ctx = talloc_new(NULL); - if (mem_ctx == NULL) { - PyErr_NoMemory(); - return NULL; - } - schema = dsdb_get_schema(ldb, NULL); if (!schema) { PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb \n"); - talloc_free(mem_ctx); return NULL; } status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, attid, - mem_ctx, &oid); + NULL, &oid); PyErr_WERROR_IS_ERR_RAISE(status); ret = PyString_FromString(oid); - - talloc_free(mem_ctx); + talloc_free(discard_const_p(char, oid)); return ret; } @@ -361,11 +358,28 @@ static PyObject *py_dsdb_DsReplicaAttribute(PyObject *self, PyObject *args) syntax_ctx.is_schema_nc = false; tmp_ctx = talloc_new(ldb); + if (tmp_ctx == NULL) { + PyErr_NoMemory(); + return NULL; + } el = talloc_zero(tmp_ctx, struct ldb_message_element); + if (el == NULL) { + PyErr_NoMemory(); + talloc_free(tmp_ctx); + return NULL; + } + el->name = ldap_display_name; el->num_values = PyList_Size(el_list); + el->values = talloc_array(el, struct ldb_val, el->num_values); + if (el->values == NULL) { + PyErr_NoMemory(); + talloc_free(tmp_ctx); + return NULL; + } + for (i = 0; i < el->num_values; i++) { PyObject *item = PyList_GetItem(el_list, i); if (!PyString_Check(item)) { @@ -377,13 +391,18 @@ static PyObject *py_dsdb_DsReplicaAttribute(PyObject *self, PyObject *args) } attr = talloc_zero(tmp_ctx, struct drsuapi_DsReplicaAttribute); + if (attr == NULL) { + PyErr_NoMemory(); + talloc_free(tmp_ctx); + return NULL; + } werr = a->syntax->ldb_to_drsuapi(&syntax_ctx, a, el, attr, attr); PyErr_WERROR_IS_ERR_RAISE(werr); ret = py_return_ndr_struct("samba.dcerpc.drsuapi", "DsReplicaAttribute", attr, attr); - talloc_unlink(ldb, tmp_ctx); + talloc_free(tmp_ctx); return ret; } @@ -412,8 +431,8 @@ static PyObject *py_samdb_ntds_objectGUID(PyObject *self, PyObject *args) { PyObject *py_ldb, *result; struct ldb_context *ldb; - TALLOC_CTX *mem_ctx; const struct GUID *guid; + char *retstr; if (!PyArg_ParseTuple(args, "O", &py_ldb)) { return NULL; @@ -421,21 +440,19 @@ static PyObject *py_samdb_ntds_objectGUID(PyObject *self, PyObject *args) PyErr_LDB_OR_RAISE(py_ldb, ldb); - mem_ctx = talloc_new(NULL); - if (mem_ctx == NULL) { - PyErr_NoMemory(); - return NULL; - } - guid = samdb_ntds_objectGUID(ldb); if (guid == NULL) { PyErr_SetString(PyExc_RuntimeError, "Failed to find NTDS GUID"); - talloc_free(mem_ctx); return NULL; } - result = PyString_FromString(GUID_string(mem_ctx, guid)); - talloc_free(mem_ctx); + retstr = GUID_string(NULL, guid); + if (retstr == NULL) { + PyErr_NoMemory(); + return NULL; + } + result = PyString_FromString(retstr); + talloc_free(retstr); return result; } @@ -464,19 +481,18 @@ static PyObject *py_dsdb_load_partition_usn(PyObject *self, PyObject *args) TALLOC_CTX *mem_ctx; int ret; + if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_dn)) { + return NULL; + } + + PyErr_LDB_OR_RAISE(py_ldb, ldb); + mem_ctx = talloc_new(NULL); if (mem_ctx == NULL) { PyErr_NoMemory(); return NULL; } - if (!PyArg_ParseTuple(args, "OO", &py_ldb, &py_dn)) { - talloc_free(mem_ctx); - return NULL; - } - - PyErr_LDB_OR_RAISE(py_ldb, ldb); - if (!PyObject_AsDn(mem_ctx, py_dn, ldb, &dn)) { talloc_free(mem_ctx); return NULL; @@ -597,7 +613,6 @@ static PyObject *py_dsdb_get_partitions_dn(PyObject *self, PyObject *args) struct ldb_context *ldb; struct ldb_dn *dn; PyObject *py_ldb, *ret; - TALLOC_CTX *tmp_ctx; PyObject *mod; mod = PyImport_ImportModule("ldb"); @@ -607,16 +622,13 @@ static PyObject *py_dsdb_get_partitions_dn(PyObject *self, PyObject *args) PyErr_LDB_OR_RAISE(py_ldb, ldb); - tmp_ctx = talloc_new(NULL); - - dn = samdb_partitions_dn(ldb, tmp_ctx); - + dn = samdb_partitions_dn(ldb, NULL); if (dn == NULL) { - talloc_free(tmp_ctx); - Py_RETURN_NONE; + PyErr_NoMemory(); + return NULL; } ret = PyLdbDn_FromDn(dn); - talloc_free(tmp_ctx); + talloc_free(dn); return ret; } diff --git a/source4/lib/ldb-samba/pyldb.c b/source4/lib/ldb-samba/pyldb.c index e8cdb90..f198d74 100644 --- a/source4/lib/ldb-samba/pyldb.c +++ b/source4/lib/ldb-samba/pyldb.c @@ -19,10 +19,8 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include <Python.h> -#include "includes.h" -#include <ldb.h> #include "lib/ldb/pyldb.h" +#include "includes.h" #include "param/pyparam.h" #include "auth/credentials/pycredentials.h" #include "ldb_wrap.h" diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index 3bee9ab..44a006f 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -26,9 +26,6 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include <Python.h> -#include "replace.h" -#include "ldb_private.h" #include "pyldb.h" /* There's no Py_ssize_t in 2.4, apparently */ diff --git a/source4/lib/ldb/pyldb.h b/source4/lib/ldb/pyldb.h index 1f4bdf7..afc8c51 100644 --- a/source4/lib/ldb/pyldb.h +++ b/source4/lib/ldb/pyldb.h @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. - Swig interface to ldb. + Python interface to ldb. Copyright (C) 2007-2008 Jelmer Vernooij <jel...@samba.org> @@ -28,6 +28,7 @@ #include <Python.h> #include <talloc.h> +#include "ldb_private.h" typedef struct { PyObject_HEAD diff --git a/source4/lib/ldb/pyldb_util.c b/source4/lib/ldb/pyldb_util.c index 3e015d0..35071f3 100644 --- a/source4/lib/ldb/pyldb_util.c +++ b/source4/lib/ldb/pyldb_util.c @@ -23,10 +23,7 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include <Python.h> -#include "replace.h" #include "pyldb.h" -#include <ldb.h> static PyObject *ldb_module = NULL; diff --git a/source4/libcli/finddc.h b/source4/libcli/finddc.h index 86e2f2c..9ff1723 100644 --- a/source4/libcli/finddc.h +++ b/source4/libcli/finddc.h @@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "lib/messaging/messaging.h" +#include "libcli/libcli.h" #include "libcli/netlogon.h" struct finddcs { diff --git a/source4/libcli/finddcs_cldap.c b/source4/libcli/finddcs_cldap.c index 1928243..293641b 100644 --- a/source4/libcli/finddcs_cldap.c +++ b/source4/libcli/finddcs_cldap.c @@ -23,8 +23,6 @@ #include "include/includes.h" #include <tevent.h> #include "libcli/resolve/resolve.h" -#include "lib/messaging/messaging.h" -#include "libcli/libcli.h" #include "libcli/cldap/cldap.h" #include "libcli/finddc.h" #include "libcli/security/security.h" diff --git a/source4/libcli/finddcs_nbt.c b/source4/libcli/finddcs_nbt.c index 5309900..c7e8989 100644 --- a/source4/libcli/finddcs_nbt.c +++ b/source4/libcli/finddcs_nbt.c @@ -24,11 +24,9 @@ #include <tevent.h> #include "lib/messaging/irpc.h" #include "librpc/gen_ndr/ndr_irpc_c.h" -#include "librpc/gen_ndr/samr.h" #include "libcli/composite/composite.h" #include "libcli/libcli.h" #include "libcli/resolve/resolve.h" -#include "libcli/finddc.h" #include "lib/util/tevent_ntstatus.h" struct finddcs_nbt_state { diff --git a/source4/libnet/libnet_lookup.c b/source4/libnet/libnet_lookup.c index 272a3fa..f937940 100644 --- a/source4/libnet/libnet_lookup.c +++ b/source4/libnet/libnet_lookup.c @@ -22,19 +22,13 @@ */ #include "includes.h" -#include "lib/events/events.h" #include "libnet/libnet.h" #include "libcli/composite/composite.h" #include "auth/credentials/credentials.h" -#include "lib/messaging/messaging.h" -#include "lib/messaging/irpc.h" #include "libcli/resolve/resolve.h" -#include "libcli/libcli.h" #include "libcli/finddc.h" #include "libcli/security/security.h" -#include "librpc/gen_ndr/lsa.h" #include "librpc/gen_ndr/ndr_lsa_c.h" - #include "param/param.h" struct lookup_state { diff --git a/source4/libnet/py_net.c b/source4/libnet/py_net.c index 9775e24..28dee59 100644 --- a/source4/libnet/py_net.c +++ b/source4/libnet/py_net.c @@ -18,19 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <Python.h> +#include "lib/ldb/pyldb.h" #include "includes.h" #include "libnet.h" #include "auth/credentials/pycredentials.h" #include "libcli/security/security.h" #include "lib/events/events.h" -#include "param/param.h" #include "param/pyparam.h" -#include "lib/ldb/pyldb.h" #include "auth/gensec/gensec.h" -#include "librpc/rpc/pyrpc.h" #include "librpc/rpc/pyrpc_util.h" -#include "lib/messaging/messaging.h" #include "libcli/finddc.h" #include "libcli/resolve/resolve.h" @@ -55,6 +51,10 @@ static PyObject *py_net_join(py_net_Object *self, PyObject *args, PyObject *kwar return NULL; mem_ctx = talloc_new(self->mem_ctx); + if (mem_ctx == NULL) { + PyErr_NoMemory(); + return NULL; + } status = libnet_Join(self->libnet_ctx, mem_ctx, &r); if (NT_STATUS_IS_ERR(status)) { @@ -95,7 +95,12 @@ static PyObject *py_net_set_password(py_net_Object *self, PyObject *args, PyObje /* FIXME: we really need to get a context from the caller or we may end * up with 2 event contexts */ ev = s4_event_context_init(NULL); + mem_ctx = talloc_new(ev); + if (mem_ctx == NULL) { + PyErr_NoMemory(); + return NULL; + } status = libnet_SetPassword(self->libnet_ctx, mem_ctx, &r); if (NT_STATUS_IS_ERR(status)) { @@ -131,6 +136,10 @@ static PyObject *py_net_export_keytab(py_net_Object *self, PyObject *args, PyObj } mem_ctx = talloc_new(self->mem_ctx); + if (mem_ctx == NULL) { + PyErr_NoMemory(); + return NULL; + } -- Samba Shared Repository