summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c23
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_pack.c6
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c2
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c20
4 files changed, 18 insertions, 33 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 874d047186..8b90604902 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -740,7 +740,7 @@ int ltdb_search_indexed(struct ldb_handle *handle)
ldb_oom(ac->module->ldb);
return -1;
}
- dn_list->dn[0] = ldb_dn_linearize(dn_list, ac->base);
+ dn_list->dn[0] = ldb_dn_alloc_linearized(dn_list, ac->base);
if (dn_list->dn[0] == NULL) {
ldb_oom(ac->module->ldb);
return -1;
@@ -933,19 +933,16 @@ static int ltdb_index_add0(struct ldb_module *module, const char *dn,
*/
int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ltdb_private *ltdb = module->private_data;
- char *dn;
+ const char *dn;
int ret;
- dn = ldb_dn_linearize(ltdb, msg->dn);
+ dn = ldb_dn_get_linearized(msg->dn);
if (dn == NULL) {
return -1;
}
ret = ltdb_index_add0(module, dn, msg->elements, msg->num_elements);
- talloc_free(dn);
-
return ret;
}
@@ -994,7 +991,7 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn,
if (i == -1) {
ldb_debug(ldb, LDB_DEBUG_ERROR,
"ERROR: dn %s not found in %s\n", dn,
- ldb_dn_linearize(dn_key, dn_key));
+ ldb_dn_get_linearized(dn_key));
/* it ain't there. hmmm */
talloc_free(dn_key);
return 0;
@@ -1027,7 +1024,7 @@ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
{
struct ltdb_private *ltdb = module->private_data;
int ret;
- char *dn;
+ const char *dn;
unsigned int i, j;
/* find the list of indexed fields */
@@ -1040,7 +1037,7 @@ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
return 0;
}
- dn = ldb_dn_linearize(ltdb, msg->dn);
+ dn = ldb_dn_get_linearized(msg->dn);
if (dn == NULL) {
return -1;
}
@@ -1054,13 +1051,11 @@ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
for (j = 0; j < msg->elements[i].num_values; j++) {
ret = ltdb_index_del_value(module, dn, &msg->elements[i], j);
if (ret == -1) {
- talloc_free(dn);
return -1;
}
}
}
- talloc_free(dn);
return 0;
}
@@ -1084,7 +1079,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
{
struct ldb_module *module = state;
struct ldb_message *msg;
- char *dn = NULL;
+ const char *dn = NULL;
int ret;
TDB_DATA key2;
@@ -1110,7 +1105,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
if (key2.dptr == NULL) {
/* probably a corrupt record ... darn */
ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s\n",
- ldb_dn_linearize(msg, msg->dn));
+ ldb_dn_get_linearized(msg->dn));
talloc_free(msg);
return 0;
}
@@ -1123,7 +1118,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
if (msg->dn == NULL) {
dn = (char *)key.dptr + 3;
} else {
- dn = ldb_dn_linearize(msg->dn, msg->dn);
+ dn = ldb_dn_get_linearized(msg->dn);
}
ret = ltdb_index_add0(module, dn, msg->elements, msg->num_elements);
diff --git a/source4/lib/ldb/ldb_tdb/ldb_pack.c b/source4/lib/ldb/ldb_tdb/ldb_pack.c
index 258c54356c..6a00fb13c7 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_pack.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_pack.c
@@ -85,11 +85,11 @@ int ltdb_pack_data(struct ldb_module *module,
struct ldb_context *ldb = module->ldb;
unsigned int i, j, real_elements=0;
size_t size;
- char *dn;
+ const char *dn;
uint8_t *p;
size_t len;
- dn = ldb_dn_linearize(ldb, message->dn);
+ dn = ldb_dn_get_linearized(message->dn);
if (dn == NULL) {
errno = ENOMEM;
return -1;
@@ -116,7 +116,6 @@ int ltdb_pack_data(struct ldb_module *module,
/* allocate it */
data->dptr = talloc_array(ldb, uint8_t, size);
if (!data->dptr) {
- talloc_free(dn);
errno = ENOMEM;
return -1;
}
@@ -151,7 +150,6 @@ int ltdb_pack_data(struct ldb_module *module,
}
}
- talloc_free(dn);
return 0;
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 3f04994ce4..5736b7684b 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -101,7 +101,7 @@ static int msg_add_distinguished_name(struct ldb_message *msg)
el.name = "distinguishedName";
el.num_values = 1;
el.values = &val;
- val.data = (uint8_t *)ldb_dn_linearize(msg, msg->dn);
+ val.data = (uint8_t *)ldb_dn_alloc_linearized(msg, msg->dn);
val.length = strlen((char *)val.data);
ret = msg_add_element(msg, &el, 1);
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index d950ab9cf0..9b05d98a66 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -123,7 +123,7 @@ struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn)
struct ldb_context *ldb = module->ldb;
TDB_DATA key;
char *key_str = NULL;
- char *dn_folded = NULL;
+ const char *dn_folded = NULL;
/*
most DNs are case insensitive. The exception is index DNs for
@@ -267,14 +267,7 @@ static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message
ret = ltdb_store(module, msg, TDB_INSERT);
if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
- char *dn;
-
- dn = ldb_dn_linearize(module, msg->dn);
- if (!dn) {
- return ret;
- }
- ldb_asprintf_errstring(module->ldb, "Entry %s already exists", dn);
- talloc_free(dn);
+ ldb_asprintf_errstring(module->ldb, "Entry %s already exists", ldb_dn_get_linearized(msg->dn));
return ret;
}
@@ -504,10 +497,10 @@ static int msg_delete_attribute(struct ldb_module *module,
struct ldb_context *ldb,
struct ldb_message *msg, const char *name)
{
- char *dn;
+ const char *dn;
unsigned int i, j;
- dn = ldb_dn_linearize(ldb, msg->dn);
+ dn = ldb_dn_get_linearized(msg->dn);
if (dn == NULL) {
return -1;
}
@@ -532,7 +525,6 @@ static int msg_delete_attribute(struct ldb_module *module,
}
}
- talloc_free(dn);
return 0;
}
@@ -627,7 +619,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
struct ldb_message_element *el = &msg->elements[i];
struct ldb_message_element *el2;
struct ldb_val *vals;
- char *dn;
+ const char *dn;
switch (msg->elements[i].flags & LDB_FLAG_MOD_MASK) {
@@ -690,7 +682,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
case LDB_FLAG_MOD_DELETE:
- dn = ldb_dn_linearize(msg2, msg->dn);
+ dn = ldb_dn_get_linearized(msg->dn);
if (dn == NULL) {
ret = LDB_ERR_OTHER;
goto failed;