summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c6
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c17
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.h4
3 files changed, 19 insertions, 8 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index df0a436172..b0a1b0f89f 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -746,8 +746,8 @@ int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg)
/*
delete an index entry for one message element
*/
-static int ltdb_index_del1(struct ldb_module *module, const char *dn,
- struct ldb_message_element *el, int v_idx)
+int ltdb_index_del_value(struct ldb_module *module, const char *dn,
+ struct ldb_message_element *el, int v_idx)
{
struct ldb_context *ldb = module->ldb;
struct ldb_message msg;
@@ -826,7 +826,7 @@ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
continue;
}
for (j=0;j<msg->elements[i].num_values;j++) {
- ret = ltdb_index_del1(module, msg->dn, &msg->elements[i], j);
+ ret = ltdb_index_del_value(module, msg->dn, &msg->elements[i], j);
if (ret == -1) {
return -1;
}
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;
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
index 2cc25b3152..05311346f4 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
@@ -112,3 +112,7 @@ int ltdb_message_match(struct ldb_module *module,
struct ldb_parse_tree *tree,
const char *base,
enum ldb_scope scope);
+
+int ltdb_index_del_value(struct ldb_module *module, const char *dn,
+ struct ldb_message_element *el, int v_idx);
+