Re: [SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha8-1154-gbe9441a

2009-09-22 Thread Jelmer Vernooij
Hi Andrew,

Andrew Bartlett wrote:
 diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
 index d55e0aa..67e1d5c 100644
 --- a/source4/lib/ldb/pyldb.c
 +++ b/source4/lib/ldb/pyldb.c
 @@ -845,6 +845,35 @@ static PyObject *py_ldb_parse_ldif(PyLdbObject *self, 
 PyObject *args)
   return PyObject_GetIter(list);
  }
  
 +static PyObject *py_ldb_msg_diff(PyLdbObject *self, PyObject *args)
 +{
 + PyObject *py_msg_old;
 + PyObject *py_msg_new;
 + struct ldb_message *diff;
 + PyObject *py_ret;
 +
 + if (!PyArg_ParseTuple(args, OO, py_msg_old, py_msg_new))
 + return NULL;
 +
 + if (!PyLdbMessage_Check(py_msg_old)) {
 + PyErr_SetString(PyExc_TypeError, Expected Ldb Message for old 
 message);
 + return NULL;
 + }
 +
 + if (!PyLdbMessage_Check(py_msg_new)) {
 + PyErr_SetString(PyExc_TypeError, Expected Ldb Message for new 
 message);
 + return NULL;
 + }
 +
 + diff = ldb_msg_diff(PyLdb_AsLdbContext(self), 
 PyLdbMessage_AsMessage(py_msg_old), PyLdbMessage_AsMessage(py_msg_new));
 + if (diff == NULL) 
 + return NULL;
^^^ There seems to be a PyErr_Set...() call missing in the if (diff
== NULL) case.

Cheers,

Jelmer



Re: [SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha8-1154-gbe9441a

2009-09-22 Thread Matthias Dieter Wallnöfer

Fixed in my personal branch.

Jelmer Vernooij schrieb:

Hi Andrew,

Andrew Bartlett wrote:
  

diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index d55e0aa..67e1d5c 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -845,6 +845,35 @@ static PyObject *py_ldb_parse_ldif(PyLdbObject *self, 
PyObject *args)
return PyObject_GetIter(list);
 }
 
+static PyObject *py_ldb_msg_diff(PyLdbObject *self, PyObject *args)

+{
+   PyObject *py_msg_old;
+   PyObject *py_msg_new;
+   struct ldb_message *diff;
+   PyObject *py_ret;
+
+   if (!PyArg_ParseTuple(args, OO, py_msg_old, py_msg_new))
+   return NULL;
+
+   if (!PyLdbMessage_Check(py_msg_old)) {
+   PyErr_SetString(PyExc_TypeError, Expected Ldb Message for old 
message);
+   return NULL;
+   }
+
+   if (!PyLdbMessage_Check(py_msg_new)) {
+   PyErr_SetString(PyExc_TypeError, Expected Ldb Message for new 
message);
+   return NULL;
+   }
+
+   diff = ldb_msg_diff(PyLdb_AsLdbContext(self), 
PyLdbMessage_AsMessage(py_msg_old), PyLdbMessage_AsMessage(py_msg_new));
+	if (diff == NULL) 
+		return NULL;


^^^ There seems to be a PyErr_Set...() call missing in the if (diff
== NULL) case.

Cheers,

Jelmer


  





[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha8-1154-gbe9441a

2009-08-24 Thread Andrew Bartlett
The branch, master has been updated
   via  be9441ac3fa167f97f54700e52dec9995b170fa3 (commit)
   via  7234a24f821743c60075d1e2868fba7b0f2a8f8b (commit)
   via  b4e8d927cd91b2fc1221d9834715153c7487b715 (commit)
   via  bf54b419ae4f2f87afba1ba1e83c97b05b18c9b0 (commit)
   via  cc330f93625290dc5f67c9c0f2f17e566ddbf1f1 (commit)
  from  0f98d539e2edc8f1d57271fb20051189699222a7 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit be9441ac3fa167f97f54700e52dec9995b170fa3
Author: Andrew Bartlett abart...@samba.org
Date:   Mon Aug 24 20:22:18 2009 +1000

s4:dsdb Use talloc_strndup() to ensure OIDs are null terminated

The OIDs are not NULL terminated by the python caller, in line with
the LDB API, but we need them to be here, as we were casting them to a
string.

Andrew Bartlett

commit 7234a24f821743c60075d1e2868fba7b0f2a8f8b
Author: Andrew Bartlett abart...@samba.org
Date:   Mon Aug 24 20:11:43 2009 +1000

s4:ldb Add python binding and test for ldb_msg_diff()

commit b4e8d927cd91b2fc1221d9834715153c7487b715
Author: Andrew Bartlett abart...@samba.org
Date:   Mon Aug 24 13:15:31 2009 +1000

s4:dsdb Add const

commit bf54b419ae4f2f87afba1ba1e83c97b05b18c9b0
Author: Andrew Bartlett abart...@samba.org
Date:   Mon Aug 24 13:15:17 2009 +1000

s4:dsdb remove unused variable

commit cc330f93625290dc5f67c9c0f2f17e566ddbf1f1
Author: Andrew Bartlett abart...@samba.org
Date:   Mon Aug 24 13:09:10 2009 +1000

s4:dsdb use talloc_strndup() in GET_STRING_LDB() rather than walk off the 
end

The problem is that samdb_result_string() and
ldb_msg_find_attr_as_string() both simply cast the string, rather than
ensuring the return value is NULL terminated.  This may be best
regarded as a flaw in LDB, but fixing it there is going to be more
difficult.

Andrew Bartlett

---

Summary of changes:
 source4/dsdb/samdb/ldb_modules/schema_fsmo.c |   20 +---
 source4/dsdb/schema/schema_init.c|   24 +-
 source4/dsdb/schema/schema_query.c   |4 +-
 source4/lib/ldb/pyldb.c  |   32 ++
 source4/lib/ldb/tests/python/api.py  |   11 +
 5 files changed, 73 insertions(+), 18 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c 
b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
index 290232b..c482ab5 100644
--- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
@@ -172,8 +172,8 @@ static int schema_fsmo_add(struct ldb_module *module, 
struct ldb_request *req)
 {
struct ldb_context *ldb;
struct dsdb_schema *schema;
-   const char *attributeID = NULL;
-   const char *governsID = NULL;
+   const struct ldb_val *attributeID = NULL;
+   const struct ldb_val *governsID = NULL;
const char *oid_attr = NULL;
const char *oid = NULL;
uint32_t id32;
@@ -202,21 +202,24 @@ static int schema_fsmo_add(struct ldb_module *module, 
struct ldb_request *req)
return LDB_ERR_UNWILLING_TO_PERFORM;
}
 
-   attributeID = samdb_result_string(req-op.add.message, attributeID, 
NULL);
-   governsID = samdb_result_string(req-op.add.message, governsID, NULL);
+   attributeID = ldb_msg_find_ldb_val(req-op.add.message, attributeID);
+   governsID = ldb_msg_find_ldb_val(req-op.add.message, governsID);
 
if (attributeID) {
oid_attr = attributeID;
-   oid = attributeID;
+   oid = talloc_strndup(req, (const char *)attributeID-data, 
attributeID-length);
} else if (governsID) {
oid_attr = governsID;
-   oid = governsID;
+   oid = talloc_strndup(req, (const char *)governsID-data, 
governsID-length);
+   } else {
+   return ldb_next_request(module, req);
}
 
if (!oid) {
-   return ldb_next_request(module, req);
+   ldb_oom(ldb);
+   return LDB_ERR_OPERATIONS_ERROR;
}
-
+   
status = dsdb_map_oid2int(schema, oid, id32);
if (W_ERROR_IS_OK(status)) {
return ldb_next_request(module, req);
@@ -408,7 +411,6 @@ static int generate_possibleInferiors(struct ldb_context 
*ldb, struct ldb_messag
int ret, i;
const char *first_component_name = ldb_dn_get_component_name(dn, 0);
const struct ldb_val *first_component_val;
-   const char *class_name;
const struct dsdb_class *schema_class;
const char **possibleInferiors;
 
diff --git a/source4/dsdb/schema/schema_init.c 
b/source4/dsdb/schema/schema_init.c
index 170d5a1..c2d4597 100644
--- a/source4/dsdb/schema/schema_init.c
+++