summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/common/attrib_handlers.c2
-rw-r--r--source4/lib/ldb/common/ldb_dn.c4
-rw-r--r--source4/lib/ldb/common/ldb_ldif.c2
-rw-r--r--source4/lib/ldb/common/ldb_msg.c2
-rw-r--r--source4/lib/ldb/include/ldb.h4
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c13
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c12
-rw-r--r--source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c18
-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
-rw-r--r--source4/lib/ldb/modules/ldb_map.c10
-rw-r--r--source4/lib/ldb/modules/ldb_map_inbound.c4
-rw-r--r--source4/lib/ldb/modules/ldb_map_outbound.c2
-rw-r--r--source4/lib/ldb/modules/rdn_name.c2
-rw-r--r--source4/lib/ldb/tools/ldbadd.c2
-rw-r--r--source4/lib/ldb/tools/ldbdel.c2
-rw-r--r--source4/lib/ldb/tools/ldbedit.c6
-rw-r--r--source4/lib/ldb/tools/ldbmodify.c2
-rw-r--r--source4/lib/ldb/tools/ldbtest.c4
21 files changed, 63 insertions, 79 deletions
diff --git a/source4/lib/ldb/common/attrib_handlers.c b/source4/lib/ldb/common/attrib_handlers.c
index 372793a103..c50f7ed7b1 100644
--- a/source4/lib/ldb/common/attrib_handlers.c
+++ b/source4/lib/ldb/common/attrib_handlers.c
@@ -239,7 +239,7 @@ static int ldb_canonicalise_dn(struct ldb_context *ldb, void *mem_ctx,
return -1;
}
- out->data = (uint8_t *)ldb_dn_linearize(mem_ctx, dn);
+ out->data = (uint8_t *)ldb_dn_alloc_linearized(mem_ctx, dn);
if (out->data == NULL) {
goto done;
}
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 0a10ed6f2e..8ee78ca06a 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -561,7 +561,7 @@ const char *ldb_dn_get_linearized(struct ldb_dn *dn)
return dn->linearized;
}
-char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *dn)
+char *ldb_dn_alloc_linearized(void *mem_ctx, struct ldb_dn *dn)
{
return talloc_strdup(mem_ctx, ldb_dn_get_linearized(dn));
}
@@ -664,7 +664,7 @@ const char *ldb_dn_get_casefold(struct ldb_dn *dn)
return dn->casefold;
}
-char *ldb_dn_casefold(void *mem_ctx, struct ldb_dn *dn)
+char *ldb_dn_alloc_casefold(void *mem_ctx, struct ldb_dn *dn)
{
return talloc_strdup(mem_ctx, ldb_dn_get_casefold(dn));
}
diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c
index 50e9f5e590..86041a8b78 100644
--- a/source4/lib/ldb/common/ldb_ldif.c
+++ b/source4/lib/ldb/common/ldb_ldif.c
@@ -286,7 +286,7 @@ int ldb_ldif_write(struct ldb_context *ldb,
msg = ldif->msg;
- ret = fprintf_fn(private_data, "dn: %s\n", ldb_dn_linearize(msg->dn, msg->dn));
+ ret = fprintf_fn(private_data, "dn: %s\n", ldb_dn_get_linearized(msg->dn));
CHECK_RET;
if (ldif->changetype != LDB_CHANGETYPE_NONE) {
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index 2768786b83..e9ba66aff5 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -626,7 +626,7 @@ int ldb_msg_sanity_check(struct ldb_context *ldb,
/* TODO: return also an error string */
ldb_asprintf_errstring(ldb, "Element %s has empty attribute in ldb message (%s)!",
msg->elements[i].name,
- ldb_dn_linearize(mem_ctx, msg->dn));
+ ldb_dn_get_linearized(msg->dn));
talloc_free(mem_ctx);
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 46894cd3c0..c44c1d6ee7 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -1274,10 +1274,10 @@ struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char
bool ldb_dn_validate(struct ldb_dn *dn);
char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value);
-char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *dn);
-char *ldb_dn_casefold(void *mem_ctx, struct ldb_dn *dn);
const char *ldb_dn_get_linearized(struct ldb_dn *dn);
const char *ldb_dn_get_casefold(struct ldb_dn *dn);
+char *ldb_dn_alloc_linearized(void *mem_ctx, struct ldb_dn *dn);
+char *ldb_dn_alloc_casefold(void *mem_ctx, struct ldb_dn *dn);
int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn);
int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1);
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index a4abd4d151..567fe4bd5f 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -452,7 +452,7 @@ static int ildb_search(struct ldb_module *module, struct ldb_request *req)
if (req->op.search.base == NULL) {
msg->r.SearchRequest.basedn = talloc_strdup(msg, "");
} else {
- msg->r.SearchRequest.basedn = ldb_dn_linearize(msg, req->op.search.base);
+ msg->r.SearchRequest.basedn = ldb_dn_alloc_linearized(msg, req->op.search.base);
}
if (msg->r.SearchRequest.basedn == NULL) {
ldb_set_errstring(module->ldb, "Unable to determine baseDN");
@@ -504,7 +504,7 @@ static int ildb_add(struct ldb_module *module, struct ldb_request *req)
msg->type = LDAP_TAG_AddRequest;
- msg->r.AddRequest.dn = ldb_dn_linearize(msg, req->op.add.message->dn);
+ msg->r.AddRequest.dn = ldb_dn_alloc_linearized(msg, req->op.add.message->dn);
if (msg->r.AddRequest.dn == NULL) {
talloc_free(msg);
return LDB_ERR_INVALID_DN_SYNTAX;
@@ -554,7 +554,7 @@ static int ildb_modify(struct ldb_module *module, struct ldb_request *req)
msg->type = LDAP_TAG_ModifyRequest;
- msg->r.ModifyRequest.dn = ldb_dn_linearize(msg, req->op.mod.message->dn);
+ msg->r.ModifyRequest.dn = ldb_dn_alloc_linearized(msg, req->op.mod.message->dn);
if (msg->r.ModifyRequest.dn == NULL) {
talloc_free(msg);
return LDB_ERR_INVALID_DN_SYNTAX;
@@ -602,7 +602,7 @@ static int ildb_delete(struct ldb_module *module, struct ldb_request *req)
msg->type = LDAP_TAG_DelRequest;
- msg->r.DelRequest.dn = ldb_dn_linearize(msg, req->op.del.dn);
+ msg->r.DelRequest.dn = ldb_dn_alloc_linearized(msg, req->op.del.dn);
if (msg->r.DelRequest.dn == NULL) {
talloc_free(msg);
return LDB_ERR_INVALID_DN_SYNTAX;
@@ -632,7 +632,7 @@ static int ildb_rename(struct ldb_module *module, struct ldb_request *req)
}
msg->type = LDAP_TAG_ModifyDNRequest;
- msg->r.ModifyDNRequest.dn = ldb_dn_linearize(msg, req->op.rename.olddn);
+ msg->r.ModifyDNRequest.dn = ldb_dn_alloc_linearized(msg, req->op.rename.olddn);
if (msg->r.ModifyDNRequest.dn == NULL) {
talloc_free(msg);
return LDB_ERR_INVALID_DN_SYNTAX;
@@ -648,8 +648,7 @@ static int ildb_rename(struct ldb_module *module, struct ldb_request *req)
}
msg->r.ModifyDNRequest.newsuperior =
- ldb_dn_linearize(msg,
- ldb_dn_get_parent(msg, req->op.rename.newdn));
+ ldb_dn_alloc_linearized(msg, ldb_dn_get_parent(msg, req->op.rename.newdn));
if (msg->r.ModifyDNRequest.newsuperior == NULL) {
talloc_free(msg);
return LDB_ERR_INVALID_DN_SYNTAX;
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index ee2d818935..bfae566e3e 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -262,7 +262,7 @@ static int lldb_search(struct ldb_module *module, struct ldb_request *req)
lldb_ac = talloc_get_type(req->handle->private_data, struct lldb_context);
- search_base = ldb_dn_linearize(lldb_ac, req->op.search.base);
+ search_base = ldb_dn_alloc_linearized(lldb_ac, req->op.search.base);
if (req->op.search.base == NULL) {
search_base = talloc_strdup(lldb_ac, "");
}
@@ -335,7 +335,7 @@ static int lldb_add(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR;
}
- dn = ldb_dn_linearize(lldb_ac, req->op.add.message->dn);
+ dn = ldb_dn_alloc_linearized(lldb_ac, req->op.add.message->dn);
if (dn == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -380,7 +380,7 @@ static int lldb_modify(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR;
}
- dn = ldb_dn_linearize(lldb_ac, req->op.mod.message->dn);
+ dn = ldb_dn_alloc_linearized(lldb_ac, req->op.mod.message->dn);
if (dn == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -419,7 +419,7 @@ static int lldb_delete(struct ldb_module *module, struct ldb_request *req)
lldb_ac = talloc_get_type(req->handle->private_data, struct lldb_context);
- dnstr = ldb_dn_linearize(lldb_ac, req->op.del.dn);
+ dnstr = ldb_dn_alloc_linearized(lldb_ac, req->op.del.dn);
ret = ldap_delete_ext(lldb->ldap, dnstr,
NULL,
@@ -457,7 +457,7 @@ static int lldb_rename(struct ldb_module *module, struct ldb_request *req)
lldb_ac = talloc_get_type(req->handle->private_data, struct lldb_context);
- old_dn = ldb_dn_linearize(lldb_ac, req->op.rename.olddn);
+ old_dn = ldb_dn_alloc_linearized(lldb_ac, req->op.rename.olddn);
if (old_dn == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -469,7 +469,7 @@ static int lldb_rename(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR;
}
- parentdn = ldb_dn_linearize(lldb_ac, ldb_dn_get_parent(lldb_ac, req->op.rename.newdn));
+ parentdn = ldb_dn_alloc_linearized(lldb_ac, ldb_dn_get_parent(lldb_ac, req->op.rename.newdn));
if (!parentdn) {
return LDB_ERR_OPERATIONS_ERROR;
}
diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
index 7671b0d954..4ea2eccded 100644
--- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
+++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
@@ -369,8 +369,8 @@ static char *parsetree_to_sql(struct ldb_module *module,
} else if (strcasecmp(t->u.equality.attr, "dn") == 0) {
/* DN query is a special ldb case */
- char *cdn = ldb_dn_casefold(mem_ctx,
- ldb_dn_new(mem_ctx, module->ldb,
+ const char *cdn = ldb_dn_get_casefold(
+ ldb_dn_new(mem_ctx, module->ldb,
(const char *)value.data));
return lsqlite3_tprintf(mem_ctx,
@@ -828,7 +828,7 @@ static long long lsqlite3_get_eid(struct ldb_module *module, struct ldb_dn *dn)
return -1;
}
- cdn = ldb_dn_linearize(local_ctx, ldb_dn_casefold(module->ldb, local_ctx, dn));
+ cdn = ldb_dn_alloc_casefold(local_ctx, dn);
if (!cdn) goto done;
eid = lsqlite3_get_eid_ndn(lsqlite3->sqlite, local_ctx, cdn);
@@ -865,7 +865,7 @@ int lsql_search(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR;
if (req->op.search.base) {
- norm_basedn = ldb_dn_linearize(lsql_ac, ldb_dn_casefold(module->ldb, lsql_ac, req->op.search.base));
+ norm_basedn = ldb_dn_alloc_casefold(lsql_ac, req->op.search.base);
if (norm_basedn == NULL) {
ret = LDB_ERR_INVALID_DN_SYNTAX;
goto failed;
@@ -1064,8 +1064,8 @@ static int lsql_add(struct ldb_module *module, struct ldb_request *req)
}
/* create linearized and normalized dns */
- dn = ldb_dn_linearize(lsql_ac, msg->dn);
- ndn = ldb_dn_linearize(lsql_ac, ldb_dn_casefold(module->ldb, lsql_ac, msg->dn));
+ dn = ldb_dn_alloc_linearized(lsql_ac, msg->dn);
+ ndn = ldb_dn_alloc_casefold(lsql_ac, msg->dn);
if (dn == NULL || ndn == NULL) {
ret = LDB_ERR_OTHER;
goto done;
@@ -1426,9 +1426,9 @@ static int lsql_rename(struct ldb_module *module, struct ldb_request *req)
req->handle->status = LDB_SUCCESS;
/* create linearized and normalized dns */
- old_cdn = ldb_dn_linearize(lsql_ac, ldb_dn_casefold(module->ldb, lsql_ac, req->op.rename.olddn));
- new_cdn = ldb_dn_linearize(lsql_ac, ldb_dn_casefold(module->ldb, lsql_ac, req->op.rename.newdn));
- new_dn = ldb_dn_linearize(lsql_ac, req->op.rename.newdn);
+ old_cdn = ldb_dn_alloc_casefold(lsql_ac, req->op.rename.olddn);
+ new_cdn = ldb_dn_alloc_casefold(lsql_ac, req->op.rename.newdn);
+ new_dn = ldb_dn_alloc_linearized(lsql_ac, req->op.rename.newdn);
if (old_cdn == NULL || new_cdn == NULL || new_dn == NULL) {
goto done;
}
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;
diff --git a/source4/lib/ldb/modules/ldb_map.c b/source4/lib/ldb/modules/ldb_map.c
index 05a0459b4a..6387ffc5b7 100644
--- a/source4/lib/ldb/modules/ldb_map.c
+++ b/source4/lib/ldb/modules/ldb_map.c
@@ -679,7 +679,7 @@ static struct ldb_val ldb_dn_convert_local(struct ldb_module *module, void *mem_
talloc_free(dn);
newval.length = 0;
- newval.data = (uint8_t *)ldb_dn_linearize(mem_ctx, newdn);
+ newval.data = (uint8_t *)ldb_dn_alloc_linearized(mem_ctx, newdn);
if (newval.data) {
newval.length = strlen((char *)newval.data);
}
@@ -705,7 +705,7 @@ static struct ldb_val ldb_dn_convert_remote(struct ldb_module *module, void *mem
talloc_free(dn);
newval.length = 0;
- newval.data = (uint8_t *)ldb_dn_linearize(mem_ctx, newdn);
+ newval.data = (uint8_t *)ldb_dn_alloc_linearized(mem_ctx, newdn);
if (newval.data) {
newval.length = strlen((char *)newval.data);
}
@@ -992,9 +992,9 @@ struct ldb_request *map_build_fixup_req(struct map_context *ac, struct ldb_dn *o
}
/* Update local 'IS_MAPPED' to the new remote DN */
- msg->dn = discard_const_p(struct ldb_dn, olddn);
- dn = ldb_dn_linearize(msg, newdn);
- if (dn == NULL) {
+ msg->dn = ldb_dn_copy(msg, olddn);
+ dn = ldb_dn_alloc_linearized(msg, newdn);
+ if ( ! dn || ! ldb_dn_validate(msg->dn)) {
goto failed;
}
if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_REPLACE, NULL) != 0) {
diff --git a/source4/lib/ldb/modules/ldb_map_inbound.c b/source4/lib/ldb/modules/ldb_map_inbound.c
index 38454b2b11..7e5583c9e2 100644
--- a/source4/lib/ldb/modules/ldb_map_inbound.c
+++ b/source4/lib/ldb/modules/ldb_map_inbound.c
@@ -297,7 +297,7 @@ int map_add(struct ldb_module *module, struct ldb_request *req)
/* Store remote DN in 'IS_MAPPED' */
/* TODO: use GUIDs here instead */
- dn = ldb_dn_linearize(local, remote->dn);
+ dn = ldb_dn_alloc_linearized(local, remote->dn);
if (ldb_msg_add_string(local, IS_MAPPED, dn) != 0) {
goto failed;
}
@@ -344,10 +344,10 @@ int map_modify_do_local(struct ldb_handle *handle)
/* Add local 'IS_MAPPED' */
/* TODO: use GUIDs here instead */
- dn = ldb_dn_linearize(msg, ac->remote_req->op.mod.message->dn);
if (ldb_msg_add_empty(msg, IS_MAPPED, LDB_FLAG_MOD_ADD, NULL) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
+ dn = ldb_dn_alloc_linearized(msg, ac->remote_req->op.mod.message->dn);
if (ldb_msg_add_string(msg, IS_MAPPED, dn) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
diff --git a/source4/lib/ldb/modules/ldb_map_outbound.c b/source4/lib/ldb/modules/ldb_map_outbound.c
index 6305e6666f..b1eb313060 100644
--- a/source4/lib/ldb/modules/ldb_map_outbound.c
+++ b/source4/lib/ldb/modules/ldb_map_outbound.c
@@ -1028,7 +1028,7 @@ int map_up_callback(struct ldb_context *ldb, const struct ldb_request *req, stru
ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_map: "
"Skipping record '%s': "
"doesn't match original search\n",
- ldb_dn_linearize(ldb, ares->message->dn));
+ ldb_dn_get_linearized(ares->message->dn));
return LDB_SUCCESS;
}
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index bab5f6a014..0da8b8f573 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -119,7 +119,7 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
if (i == attribute->num_values) {
ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
"RDN mismatch on %s: %s (%s)",
- ldb_dn_linearize(msg, msg->dn), rdn_name, rdn_val.data);
+ ldb_dn_get_linearized(msg->dn), rdn_name, rdn_val.data);
talloc_free(down_req);
return LDB_ERR_OPERATIONS_ERROR;
}
diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c
index 9595703e92..8e75bccacc 100644
--- a/source4/lib/ldb/tools/ldbadd.c
+++ b/source4/lib/ldb/tools/ldbadd.c
@@ -71,7 +71,7 @@ static int process_file(struct ldb_context *ldb, FILE *f, int *count)
ret = ldb_add(ldb, ldif->msg);
if (ret != LDB_SUCCESS) {
fprintf(stderr, "ERR: \"%s\" on DN %s\n",
- ldb_errstring(ldb), ldb_dn_linearize(ldb, ldif->msg->dn));
+ ldb_errstring(ldb), ldb_dn_get_linearized(ldif->msg->dn));
failures++;
} else {
(*count)++;
diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c
index b4da806b51..c6c691d875 100644
--- a/source4/lib/ldb/tools/ldbdel.c
+++ b/source4/lib/ldb/tools/ldbdel.c
@@ -108,7 +108,7 @@ int main(int argc, const char **argv)
}
if (ret != 0) {
printf("delete of '%s' failed - %s\n",
- ldb_dn_linearize(ldb, dn),
+ ldb_dn_get_linearized(dn),
ldb_errstring(ldb));
}
}
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index 429febb75b..2edbe34b6f 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -78,7 +78,7 @@ static int modify_record(struct ldb_context *ldb,
if (ldb_modify(ldb, mod) != 0) {
fprintf(stderr, "failed to modify %s - %s\n",
- ldb_dn_linearize(ldb, msg1->dn), ldb_errstring(ldb));
+ ldb_dn_get_linearized(msg1->dn), ldb_errstring(ldb));
return -1;
}
@@ -123,7 +123,7 @@ static int merge_edits(struct ldb_context *ldb,
}
if (ldb_add(ldb, msgs2[i]) != 0) {
fprintf(stderr, "failed to add %s - %s\n",
- ldb_dn_linearize(ldb, msgs2[i]->dn),
+ ldb_dn_get_linearized(msgs2[i]->dn),
ldb_errstring(ldb));
return -1;
}
@@ -144,7 +144,7 @@ static int merge_edits(struct ldb_context *ldb,
}
if (ldb_delete(ldb, msgs1[i]->dn) != 0) {
fprintf(stderr, "failed to delete %s - %s\n",
- ldb_dn_linearize(ldb, msgs1[i]->dn),
+ ldb_dn_get_linearized(msgs1[i]->dn),
ldb_errstring(ldb));
return -1;
}
diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c
index 962045ef7d..cc7219a156 100644
--- a/source4/lib/ldb/tools/ldbmodify.c
+++ b/source4/lib/ldb/tools/ldbmodify.c
@@ -73,7 +73,7 @@ static int process_file(struct ldb_context *ldb, FILE *f, int *count)
}
if (ret != LDB_SUCCESS) {
fprintf(stderr, "ERR: \"%s\" on DN %s\n",
- ldb_errstring(ldb), ldb_dn_linearize(ldb, ldif->msg->dn));
+ ldb_errstring(ldb), ldb_dn_get_linearized(ldif->msg->dn));
failures++;
} else {
(*count)++;
diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c
index 70b2b0148a..fbabd56878 100644
--- a/source4/lib/ldb/tools/ldbtest.c
+++ b/source4/lib/ldb/tools/ldbtest.c
@@ -322,7 +322,7 @@ static void start_test_index(struct ldb_context **ldb)
ldb_msg_add_string(msg, "@IDXATTR", strdup("uid"));
if (ldb_add(*ldb, msg) != 0) {
- printf("Add of %s failed - %s\n", ldb_dn_linearize(*ldb, msg->dn), ldb_errstring(*ldb));
+ printf("Add of %s failed - %s\n", ldb_dn_get_linearized(msg->dn), ldb_errstring(*ldb));
exit(1);
}
@@ -337,7 +337,7 @@ static void start_test_index(struct ldb_context **ldb)
ldb_msg_add_string(msg, "objectClass", strdup("OpenLDAPperson"));
if (ldb_add(*ldb, msg) != 0) {
- printf("Add of %s failed - %s\n", ldb_dn_linearize(*ldb, msg->dn), ldb_errstring(*ldb));
+ printf("Add of %s failed - %s\n", ldb_dn_get_linearized(msg->dn), ldb_errstring(*ldb));
exit(1);
}