diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-12-19 10:56:29 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:07:31 -0500 |
commit | cf4298874c01644eaedb8f80eec131ec5a220e08 (patch) | |
tree | a724565830c9bae132ffa5edd5fd287326c951ff /source4/lib/ldb/ldb_tdb/ldb_tdb.c | |
parent | 134769f9ad58c3431ddb2924e1231be3b16acdbe (diff) | |
download | samba-cf4298874c01644eaedb8f80eec131ec5a220e08.tar.gz samba-cf4298874c01644eaedb8f80eec131ec5a220e08.tar.bz2 samba-cf4298874c01644eaedb8f80eec131ec5a220e08.zip |
r4281: fixed an ldb indexing bug in ldb found by volker.
index entries were not always being removed on modify
(This used to be commit 9c668e7b43dc2d82d3d639b64c53e887723ccba7)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_tdb.c')
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_tdb.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 6623fd0052..5bceab0f13 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -403,10 +403,11 @@ static int msg_add_element(struct ldb_context *ldb, /* delete all elements having a specified attribute name */ -static int msg_delete_attribute(struct ldb_context *ldb, +static int msg_delete_attribute(struct ldb_module *module, + struct ldb_context *ldb, struct ldb_message *msg, const char *name) { - unsigned int i, count=0; + unsigned int i, j, count=0; struct ldb_message_element *el2; el2 = ldb_malloc_array_p(ldb, struct ldb_message_element, msg->num_elements); @@ -419,6 +420,9 @@ static int msg_delete_attribute(struct ldb_context *ldb, if (ldb_attr_cmp(msg->elements[i].name, name) != 0) { el2[count++] = msg->elements[i]; } else { + for (j=0;j<msg->elements[i].num_values;j++) { + ltdb_index_del_value(module, msg->dn, &msg->elements[i], j); + } ldb_free(ldb, msg->elements[i].values); } } @@ -460,7 +464,7 @@ static int msg_delete_element(struct ldb_module *module, } el->num_values--; if (el->num_values == 0) { - return msg_delete_attribute(ldb, msg, name); + return msg_delete_attribute(module, ldb, msg, name); } return 0; } @@ -532,7 +536,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms case LDB_FLAG_MOD_REPLACE: /* replace all elements of this attribute name with the elements listed. The attribute not existing is not an error */ - msg_delete_attribute(ldb, &msg2, msg->elements[i].name); + msg_delete_attribute(module, ldb, &msg2, msg->elements[i].name); /* add the replacement element, if not empty */ if (msg->elements[i].num_values != 0 && @@ -545,7 +549,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms /* we could be being asked to delete all values or just some values */ if (msg->elements[i].num_values == 0) { - if (msg_delete_attribute(ldb, &msg2, + if (msg_delete_attribute(module, ldb, &msg2, msg->elements[i].name) != 0) { ltdb->last_err_string = "No such attribute"; goto failed; @@ -560,6 +564,9 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms ltdb->last_err_string = "No such attribute"; goto failed; } + if (ltdb_index_del_value(module, msg->dn, &msg->elements[i], j) != 0) { + goto failed; + } } break; } |