summaryrefslogtreecommitdiffstats
path: root/lib/ldb/pyldb.c
Commit message (Collapse)AuthorAgeFilesLines
* pyldb: Report errors converting controls list to char**Petr Viktorin2015-03-031-0/+20
| | | | | | | | | With this change, passing an unexpected type to the CRUD methods will result in an informative TypeError. Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pyldb: Better error reportingPetr Viktorin2015-03-031-2/+2
| | | | | | | | Provide more useful error messages for some type errors Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pyldb: Type-check arguments parsed with PyArg_ParseTuple*Petr Viktorin2015-03-031-8/+8
| | | | | | | | | PyObject* arguments need to be type-checked before they're cast to subtypes. Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pyldb: Fix reference leaksPetr Viktorin2015-03-031-6/+12
| | | | | | | | | | | | | The parse_ldif and MessageElement.__iter__ functions leaked references to intermediate lists whose iterators they return. The MessageElement repr used the undocumented macro PyObject_REPR, which leaks references. (It was used internally in CPython before fatal errors, and will be removed in Python 3.5.) Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pyldb: Remove use of staticforward macroPetr Viktorin2015-03-031-1/+1
| | | | | | Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pyldb: Properly preallocate result control listPetr Viktorin2015-03-031-1/+5
| | | | | | | | | | | The list was always allocated with size 1, so if there is more than 1 result control, the additional items would not be added in the list, and would become leaked references. Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pyldb: Use the Py_TYPE macroPetr Viktorin2015-03-031-3/+3
| | | | | | | | | | The "ob_type" member of Python objects is going away in Python 3 for compliance with C's strict aliasing rules. The Py_TYPE macro should be used instead. Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pyldb: Correct reference counting when returning boolsPetr Viktorin2015-03-031-4/+4
| | | | | | | | | Simply returning Py_True/PyFalse doesn't increment the bool object's reference count. Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* Remove use of the "staticforward" macroPetr Viktorin2015-01-221-7/+7
| | | | | | | | | | This macro was used for compatibility with broken compilers. Since Python 2.3, it is always defined as `static`, and only exists "for source compatibility with old C extensions". Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib-pyldb: Block elements should be surrounded by {} in py_msg.setitem()Kamen Mazdrashki2014-11-251-1/+2
| | | | | | | | | Change-Id: I0d09374b27708fcaad3523d985a2db7983dbd81a Signed-off-by: Kamen Mazdrashki <kamenim@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Tue Nov 25 07:24:12 CET 2014 on sn-devel-104
* lib-pyldb: Fix docstring for msg.add() method - it was "S.append()"Kamen Mazdrashki2014-11-251-1/+1
| | | | | | Change-Id: I9492d3c3993fc3d68d7bf24405db6e8cd746eaac Signed-off-by: Kamen Mazdrashki <kamenim@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib-pyldb: Avoid crash when copying MessageElements between Python Message ↵Kamen Mazdrashki2014-11-251-4/+22
| | | | | | | | | | | | | | | | | | | | objects This patch allows for following snipets in Python: res = ldb.search(...) m_from = res[0] m_to = Message() m_to.add(m_from["attrName"]) The problem previously is that we are trying to reference a ldb_message_element that may not be a memory context on its own. For instance, when search request from above example returns Messages with more than one attribute, this leads immediately to "Bad talloc magic value" crash, every message element beside the first one is not a memory context Signed-off-by: Kamen Mazdrashki <kamenim@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib-pyldb: Throw exception when we can't create MessageElement objectKamen Mazdrashki2014-11-251-0/+2
| | | | | | | | At the moment we return an error, but no exception and it is hard to instantly see what the problem is from Python Signed-off-by: Kamen Mazdrashki <kamenim@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib-pyldb: Avoid leaking memory in error casesKamen Mazdrashki2014-11-251-2/+6
| | | | | Signed-off-by: Kamen Mazdrashki <kamenim@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib-pyldb: Avoid SEGFAULT in case we can't convert passed value to py_StringKamen Mazdrashki2014-11-251-0/+5
| | | | | Signed-off-by: Kamen Mazdrashki <kamenim@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb:pyldb: add some more helper functions for LdbDnStefan Metzmacher2014-05-021-0/+112
| | | | | | | | This adds [g|s]et_component[|_name|_value]() and get_rdn_[name|value](). Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb:pyldb: fix doc string for set_extended_component()Stefan Metzmacher2014-05-021-1/+1
| | | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb:pyldb: add some const to PyObject_FromLdbValue()Stefan Metzmacher2014-05-021-1/+1
| | | | | | | | PyString_FromStringAndSize() makes a copy of the value... Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* samba:python - Py_RETURN_NONE remove compatibility code for releases < 2.4Matthias Dieter Wallnöfer2014-01-091-4/+0
| | | | | | | | | http://www.python.org/doc//current/c-api/none.html Reviewed-By: Jelmer Vernooij <jelmer@samba.org> Autobuild-User(master): Matthias Dieter Wallnöfer <mdw@samba.org> Autobuild-Date(master): Thu Jan 9 16:27:47 CET 2014 on sn-devel-104
* pyldb: Fix CID 1034792 Dereference null return valueVolker Lendecke2013-08-191-0/+4
| | | | | | | | Add a NULL check Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* pyldb: decrement ref counters on py_results and quiet warningsMatthieu Patou2013-08-061-0/+4
| | | | | | | | Signed-off-by: Matthieu Patou <mat@matws.net> Reviewed-by: Jelmer Vernooij <jelmer@samba.org> Autobuild-User(master): Matthieu Patou <mat@samba.org> Autobuild-Date(master): Tue Aug 6 00:32:46 CEST 2013 on sn-devel-104
* pyldb: Add bindings for ldb_dn_remove_base_componentsAndrew Bartlett2012-07-061-0/+15
|
* pyldb: Fix dn concat operation to be the other way aroundAndrew Bartlett2012-07-061-1/+1
| | | | | | This now concatonates Dn(ldb, "cn=config") + Dn(ldb, "dc=samba,dc=org") as "cn=config,dc=samba,dc=org" Andrew Bartlett
* pyldb: Ensure that the ldb argument is really an ldb before we dereferenceAndrew Bartlett2012-06-111-0/+10
|
* pyldb: Fix some more long lines, fix formatting.Jelmer Vernooij2012-03-021-14/+37
| | | | | Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Fri Mar 2 05:26:56 CET 2012 on sn-devel-104
* pyldb: Avoid using PyErr_LDB_ERROR_IS_ERR_RAISE where PyErr_SetLdbError ↵Jelmer Vernooij2012-03-011-13/+16
| | | | | | | suffices. Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Thu Mar 1 23:06:55 CET 2012 on sn-devel-104
* LDB:pyldb.c - use always the case insensitive comparison for attribute namesMatthias Dieter Wallnöfer2012-02-131-2/+2
| | | | | | We can make no assumptions about our users Signed-off-by: Andrew Bartlett <abartlet@samba.org>
* pyldb: raise an exception if we can't add the attributeMatthieu Patou2012-01-031-1/+6
|
* pyldb: Add more docstrings.Jelmer Vernooij2011-12-081-7/+12
| | | | | Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Thu Dec 8 22:08:49 CET 2011 on sn-devel-104
* pyldb: enhanced get() method on msg objectAndrew Tridgell2011-11-101-14/+33
| | | | | | | get() now takes a default value and an idx, allowing for much easier usage Pair-Programmed-With: Amitay Isaacs <amitay@gmail.com>
* pyldb: Remove duplicate definition of SYNTAX_DN.Jelmer Vernooij2011-11-021-1/+0
|
* ldb:pyldb.c - py_ldb_* modification calls - error string shouldn't be set hereMatthias Dieter Wallnöfer2011-10-111-17/+1
| | | | | | | | As discussed with Jelmer, we shouldn't be setting a generic LDB error string only for the Python bindings alone. This should be done in "ldb_request" and "ldb_wait" - the common place for all possible LDB access mechanisms. Signed-off-by: Andrew Tridgell <tridge@samba.org>
* pyldb: Drop unnecessary dependency on pytalloc-util.Jelmer Vernooij2011-09-181-1/+0
| | | | | Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Sun Sep 18 17:23:40 CEST 2011 on sn-devel-104
* ldb:pyldb.c - "py_ldb_rename" remove superflous "ldb" pointerMatthias Dieter Wallnöfer2011-09-131-4/+2
| | | | | | | Reviewed-by: Jelmer Autobuild-User: Matthias Dieter Wallnöfer <mdw@samba.org> Autobuild-Date: Tue Sep 13 18:11:18 CEST 2011 on sn-devel-104
* ldb:pyldb.c - point out that "PyLdbResult_AsResult" does not convert everythingMatthias Dieter Wallnöfer2011-09-111-1/+4
| | | | Reviewed-by: Jelmer
* pyldb: added OID_COMPARATOR constantsAndrew Tridgell2011-09-011-9/+11
| | | | | | | This also changes the other constants to remove the LDB_ prefix, which is redundent Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
* pyldb: fixed a warningAndrew Tridgell2011-08-251-2/+2
| | | | Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
* ldb - two cosmetic fixesMatthias Dieter Wallnöfer2011-08-191-2/+2
| | | | | @ldb.h: Removes an invalid comment line @pyldb.c: Fixes indentation
* pyldb: fix uninitialized memory bug in PyArg_ParseTuple() argumentStefan Metzmacher2011-08-081-1/+1
| | | | | | | | "s#", &str, &len) required 'len' as 'int' not as 'Py_ssize_t'. With Py_ssize_t the 2nd half of a 64bit Py_ssize_t, will be uninitialized as 'int' is only 32bit. metze
* pyldb: Consistently use pyldb_ prefix.Jelmer Vernooij2011-08-071-110/+118
|
* pyldb: return a copy of key constant DNs via python interfaceAndrew Tridgell2011-08-031-4/+21
| | | | | | | | | | this prevents an easy coding error where the caller modifies one of the key DNs for the database, by using an add_child function or similar Pair-Programmed-With: Amitay Isaacs <amitay@gmail.com> Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Andrew Bartlett <abartlet@samba.org>
* pyldb: added binary_encode() and binary_decode() methodsAndrew Tridgell2011-07-291-0/+53
| | | | | | | this gives access to RFC2254 encoding from python Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org> Pair-Programmed-With: Amitay Isaacs <amitay@gmail.com>
* pyldb: use dn.is_child_of() instead of dn.compare_base()Andrew Tridgell2011-07-211-4/+4
| | | | | | | | the compare_base() C API doesn't really fit well in python, as it returns 0 for true. Better to have a boolean function for the python interface. Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
* ldb-python: add a function to Dn object to compare the Dn with a base DNMatthieu Patou2011-07-211-0/+17
|
* ldb: make ldb a top level library for Samba 4.0Andrew Bartlett2011-07-051-0/+3302
Signed-off-by: Andrew Tridgell <tridge@samba.org>