summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/common/ldb.c64
-rw-r--r--source4/lib/ldb/common/ldb_debug.c1
-rw-r--r--source4/lib/ldb/common/ldb_modules.c2
-rw-r--r--source4/lib/ldb/common/ldb_msg.c10
-rw-r--r--source4/lib/ldb/include/ldb_private.h3
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c22
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c20
-rw-r--r--source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c24
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c2
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c31
-rw-r--r--source4/lib/ldb/modules/asq.c12
-rw-r--r--source4/lib/ldb/modules/ldb_map.c2
-rw-r--r--source4/lib/ldb/modules/objectclass.c28
-rw-r--r--source4/lib/ldb/modules/operational.c2
-rw-r--r--source4/lib/ldb/modules/paged_results.c10
-rw-r--r--source4/lib/ldb/modules/sort.c9
16 files changed, 123 insertions, 119 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 9420318fa9..ce42a36a59 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -174,12 +174,25 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co
return LDB_SUCCESS;
}
-void ldb_set_errstring(struct ldb_context *ldb, char *err_string)
+void ldb_set_errstring(struct ldb_context *ldb, const char *err_string)
{
if (ldb->err_string) {
talloc_free(ldb->err_string);
}
- ldb->err_string = talloc_steal(ldb, err_string);
+ ldb->err_string = talloc_strdup(ldb, err_string);
+}
+
+void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...)
+{
+ va_list ap;
+
+ if (ldb->err_string) {
+ talloc_free(ldb->err_string);
+ }
+
+ va_start(ap, format);
+ ldb->err_string = talloc_vasprintf(ldb, format, ap);
+ va_end(ap);
}
void ldb_reset_err_string(struct ldb_context *ldb)
@@ -194,8 +207,7 @@ void ldb_reset_err_string(struct ldb_context *ldb)
module = ldb->modules; \
while (module && module->ops->op == NULL) module = module->next; \
if (module == NULL) { \
- ldb_set_errstring(ldb, \
- talloc_asprintf(ldb, "unable to find module or backend to handle operation: " #op)); \
+ ldb_asprintf_errstring(ldb, "unable to find module or backend to handle operation: " #op); \
return LDB_ERR_OPERATIONS_ERROR; \
} \
} while (0)
@@ -215,10 +227,10 @@ static int ldb_transaction_start_internal(struct ldb_context *ldb)
if (status != LDB_SUCCESS) {
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb,
- talloc_asprintf(ldb, "ldb transaction start: %s (%d)",
- ldb_strerror(status),
- status));
+ ldb_asprintf_errstring(ldb,
+ "ldb transaction start: %s (%d)",
+ ldb_strerror(status),
+ status);
}
}
return status;
@@ -239,10 +251,10 @@ static int ldb_transaction_commit_internal(struct ldb_context *ldb)
if (status != LDB_SUCCESS) {
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb,
- talloc_asprintf(ldb, "ldb transaction commit: %s (%d)",
- ldb_strerror(status),
- status));
+ ldb_asprintf_errstring(ldb,
+ "ldb transaction commit: %s (%d)",
+ ldb_strerror(status),
+ status);
}
}
return status;
@@ -261,10 +273,10 @@ static int ldb_transaction_cancel_internal(struct ldb_context *ldb)
if (status != LDB_SUCCESS) {
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb,
- talloc_asprintf(ldb, "ldb transaction cancel: %s (%d)",
- ldb_strerror(status),
- status));
+ ldb_asprintf_errstring(ldb,
+ "ldb transaction cancel: %s (%d)",
+ ldb_strerror(status),
+ status);
}
}
return status;
@@ -345,9 +357,7 @@ static int ldb_autotransaction_request(struct ldb_context *ldb, struct ldb_reque
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb,
- talloc_asprintf(ldb, "%s (%d)",
- ldb_strerror(ret), ret));
+ ldb_asprintf_errstring(ldb, "%s (%d)", ldb_strerror(ret), ret);
}
return ret;
@@ -460,7 +470,7 @@ static int ldb_search_callback(struct ldb_context *ldb, void *context, struct ld
int n;
if (!context) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context in callback"));
+ ldb_set_errstring(ldb, "NULL Context in callback");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -533,7 +543,7 @@ int ldb_search(struct ldb_context *ldb,
req = talloc(ldb, struct ldb_request);
if (req == NULL) {
- ldb_set_errstring(ldb, talloc_strdup(ldb, "Out of memory!"));
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -543,7 +553,7 @@ int ldb_search(struct ldb_context *ldb,
req->op.search.tree = ldb_parse_tree(req, expression);
if (req->op.search.tree == NULL) {
- ldb_set_errstring(ldb, talloc_strdup(ldb, "Unable to parse search expression"));
+ ldb_set_errstring(ldb, "Unable to parse search expression");
talloc_free(req);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -593,7 +603,7 @@ int ldb_add(struct ldb_context *ldb,
req = talloc(ldb, struct ldb_request);
if (req == NULL) {
- ldb_set_errstring(ldb, talloc_strdup(ldb, "Out of memory!"));
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -625,7 +635,7 @@ int ldb_modify(struct ldb_context *ldb,
req = talloc(ldb, struct ldb_request);
if (req == NULL) {
- ldb_set_errstring(ldb, talloc_strdup(ldb, "Out of memory!"));
+ ldb_set_errstring(ldb, "Out of Memory!");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -654,7 +664,7 @@ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn)
req = talloc(ldb, struct ldb_request);
if (req == NULL) {
- ldb_set_errstring(ldb, talloc_strdup(ldb, "Out of memory!"));
+ ldb_set_errstring(ldb, "Out of Memory!");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -682,7 +692,7 @@ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct
req = talloc(ldb, struct ldb_request);
if (req == NULL) {
- ldb_set_errstring(ldb, talloc_strdup(ldb, "Out of memory!"));
+ ldb_set_errstring(ldb, "Out of Memory!");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -712,7 +722,7 @@ int ldb_sequence_number(struct ldb_context *ldb, uint64_t *seq_num)
req = talloc(ldb, struct ldb_request);
if (req == NULL) {
- ldb_set_errstring(ldb, talloc_strdup(ldb, "Out of memory!"));
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
diff --git a/source4/lib/ldb/common/ldb_debug.c b/source4/lib/ldb/common/ldb_debug.c
index c4718c7f52..2548a5495a 100644
--- a/source4/lib/ldb/common/ldb_debug.c
+++ b/source4/lib/ldb/common/ldb_debug.c
@@ -100,5 +100,6 @@ void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
ldb_set_errstring(ldb, msg);
ldb_debug(ldb, level, "%s", msg);
}
+ talloc_free(msg);
}
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index d38c873c3b..e863a2beb5 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -369,7 +369,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
module = module->next; \
while (module && module->ops->op == NULL) module = module->next; \
if (module == NULL) { \
- ldb_set_errstring(ldb, talloc_strdup(ldb, "Unable to find backend operation for " #op )); \
+ ldb_asprintf_errstring(ldb, "Unable to find backend operation for " #op ); \
return LDB_ERR_OPERATIONS_ERROR; \
} \
} while (0)
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index 2fe9e39e68..b0dc74bdb5 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -571,12 +571,12 @@ int ldb_msg_sanity_check(struct ldb_context *ldb,
/* basic check on DN */
if (msg->dn == NULL) {
/* TODO: return also an error string */
- ldb_set_errstring(ldb, talloc_strdup(ldb, "ldb message lacks a DN!"));
+ ldb_set_errstring(ldb, "ldb message lacks a DN!");
return LDB_ERR_INVALID_DN_SYNTAX;
}
if (msg->dn->comp_num == 0) {
/* root dse has empty dn */
- ldb_set_errstring(ldb, talloc_strdup(ldb, "DN on new ldb message is '' (not permitted)!"));
+ ldb_set_errstring(ldb, "DN on new ldb message is '' (not permitted)!");
return LDB_ERR_ENTRY_ALREADY_EXISTS;
}
@@ -587,9 +587,9 @@ int ldb_msg_sanity_check(struct ldb_context *ldb,
TALLOC_CTX *mem_ctx = talloc_new(ldb);
/* an attribute cannot be empty */
/* TODO: return also an error string */
- ldb_set_errstring(ldb, talloc_asprintf(mem_ctx, "Element %s has empty attribute in ldb message (%s)!",
- msg->elements[i].name,
- ldb_dn_linearize(mem_ctx, msg->dn)));
+ ldb_asprintf_errstring(ldb, "Element %s has empty attribute in ldb message (%s)!",
+ msg->elements[i].name,
+ ldb_dn_linearize(mem_ctx, msg->dn));
talloc_free(mem_ctx);
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index 97e2828371..99b9f99fb3 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -147,7 +147,8 @@ int ldb_next_end_trans(struct ldb_module *module);
int ldb_next_del_trans(struct ldb_module *module);
int ldb_next_init(struct ldb_module *module);
-void ldb_set_errstring(struct ldb_context *ldb, char *err_string);
+void ldb_set_errstring(struct ldb_context *ldb, const char *err_string);
+void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...);
void ldb_reset_err_string(struct ldb_context *ldb);
int ldb_register_module(const struct ldb_module_ops *);
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index f6ddbf4931..c71f1be9ba 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -257,7 +257,7 @@ static void ildb_callback(struct ldap_request *req)
}
if (msg->r.SearchResultDone.resultcode) {
if (msg->r.SearchResultDone.errormessage) {
- ldb_set_errstring(ac->module->ldb, talloc_strdup(ac->module, msg->r.SearchResultDone.errormessage));
+ ldb_set_errstring(ac->module->ldb, msg->r.SearchResultDone.errormessage);
}
}
@@ -333,7 +333,7 @@ static struct ldb_handle *init_ildb_handle(struct ldb_module *module,
h = talloc_zero(ildb->ldap, struct ldb_handle);
if (h == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
return NULL;
}
@@ -341,7 +341,7 @@ static struct ldb_handle *init_ildb_handle(struct ldb_module *module,
ildb_ac = talloc(h, struct ildb_context);
if (ildb_ac == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
talloc_free(h);
return NULL;
}
@@ -377,12 +377,12 @@ static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg
req = ldap_request_send(ildb->ldap, msg);
if (req == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "async send request failed"));
+ ldb_set_errstring(module->ldb, "async send request failed");
return LDB_ERR_OPERATIONS_ERROR;
}
if (!req->conn) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "connection to remote LDAP server dropped?"));
+ ldb_set_errstring(module->ldb, "connection to remote LDAP server dropped?");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -435,18 +435,18 @@ static int ildb_search(struct ldb_module *module, struct ldb_request *req)
req->handle = NULL;
if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Async interface called with NULL callback function or NULL context"));
+ ldb_set_errstring(module->ldb, "Async interface called with NULL callback function or NULL context");
return LDB_ERR_OPERATIONS_ERROR;
}
if (req->op.search.tree == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Invalid expression parse tree"));
+ ldb_set_errstring(module->ldb, "Invalid expression parse tree");
return LDB_ERR_OPERATIONS_ERROR;
}
msg = new_ldap_message(ildb);
if (msg == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -463,7 +463,7 @@ static int ildb_search(struct ldb_module *module, struct ldb_request *req)
msg->r.SearchRequest.basedn = ldb_dn_linearize(msg, req->op.search.base);
}
if (msg->r.SearchRequest.basedn == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Unable to determine baseDN"));
+ ldb_set_errstring(module->ldb, "Unable to determine baseDN");
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -733,7 +733,7 @@ static int ildb_rootdse_callback(struct ldb_context *ldb, void *context, struct
struct ildb_private *ildb;
if (!context || !ares) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
+ ldb_set_errstring(ldb, "NULL Context or Result in callback");
goto error;
}
@@ -783,7 +783,7 @@ static int ildb_init(struct ldb_module *module)
req->operation = LDB_SEARCH;
req->op.search.base = ldb_dn_new(req);
req->op.search.scope = LDB_SCOPE_BASE;
- req->op.search.tree = ldb_parse_tree(req, "dn=dc=rootDSE");
+ req->op.search.tree = ldb_parse_tree(req, "(objectClass=*)");
req->op.search.attrs = NULL;
req->controls = NULL;
req->context = ildb;
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index 1a20a28590..74ef1fcb47 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -73,7 +73,7 @@ static struct ldb_handle *init_handle(struct lldb_private *lldb, struct ldb_modu
h = talloc_zero(lldb, struct ldb_handle);
if (h == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
return NULL;
}
@@ -81,7 +81,7 @@ static struct ldb_handle *init_handle(struct lldb_private *lldb, struct ldb_modu
ac = talloc(h, struct lldb_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
talloc_free(h);
return NULL;
}
@@ -237,12 +237,12 @@ static int lldb_search(struct ldb_module *module, struct ldb_request *req)
int ret;
if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Async interface called with NULL callback function or NULL context"));
+ ldb_set_errstring(module->ldb, "Async interface called with NULL callback function or NULL context");
return LDB_ERR_OPERATIONS_ERROR;
}
if (req->op.search.tree == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Invalid expression parse tree"));
+ ldb_set_errstring(module->ldb, "Invalid expression parse tree");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -296,7 +296,7 @@ static int lldb_search(struct ldb_module *module, struct ldb_request *req)
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(ret)));
+ ldb_set_errstring(module->ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
@@ -341,7 +341,7 @@ static int lldb_add(struct ldb_module *module, struct ldb_request *req)
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(ret)));
+ ldb_set_errstring(module->ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
@@ -386,7 +386,7 @@ static int lldb_modify(struct ldb_module *module, struct ldb_request *req)
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(ret)));
+ ldb_set_errstring(module->ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
@@ -422,7 +422,7 @@ static int lldb_delete(struct ldb_module *module, struct ldb_request *req)
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(ret)));
+ ldb_set_errstring(module->ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
@@ -474,7 +474,7 @@ static int lldb_rename(struct ldb_module *module, struct ldb_request *req)
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(ret)));
+ ldb_set_errstring(module->ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
@@ -627,7 +627,7 @@ static int lldb_parse_result(struct ldb_handle *handle, LDAPMessage *result)
if (matcheddnp) ldap_memfree(matcheddnp);
if (errmsgp) {
- ldb_set_errstring(ac->module->ldb, talloc_strdup(ac->module, errmsgp));
+ ldb_set_errstring(ac->module->ldb, errmsgp);
ldap_memfree(errmsgp);
}
if (referralsp) ldap_value_free(referralsp);
diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
index 153a6d27d4..dcac88a6b9 100644
--- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
+++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
@@ -66,7 +66,7 @@ static struct ldb_handle *init_handle(struct lsqlite3_private *lsqlite3, struct
h = talloc_zero(lsqlite3, struct ldb_handle);
if (h == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
return NULL;
}
@@ -74,7 +74,7 @@ static struct ldb_handle *init_handle(struct lsqlite3_private *lsqlite3, struct
ac = talloc(h, struct lsql_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
talloc_free(h);
return NULL;
}
@@ -847,7 +847,7 @@ static int lsql_search_sync_callback(struct ldb_context *ldb, void *context, str
struct ldb_result *res = NULL;
if (!context) {
- ldb_set_errstring(ldb, talloc_strdup(ldb, "NULL Context in callback"));
+ ldb_set_errstring(ldb, "NULL Context in callback");
goto error;
}
@@ -1045,7 +1045,7 @@ int lsql_search_async(struct ldb_module *module, const struct ldb_dn *base,
ret = sqlite3_exec(lsqlite3->sqlite, query, lsqlite3_search_callback, *handle, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, errmsg);
free(errmsg);
}
goto failed;
@@ -1166,7 +1166,7 @@ static int lsql_add_async(struct ldb_module *module, struct ldb_message *msg,
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, errmsg);
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1221,7 +1221,7 @@ static int lsql_add_async(struct ldb_module *module, struct ldb_message *msg,
ret = sqlite3_exec(lsqlite3->sqlite, insert, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, errmsg);
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1334,7 +1334,7 @@ static int lsql_modify_async(struct ldb_module *module, const struct ldb_message
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, errmsg);
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1372,7 +1372,7 @@ static int lsql_modify_async(struct ldb_module *module, const struct ldb_message
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, errmsg);
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1398,7 +1398,7 @@ static int lsql_modify_async(struct ldb_module *module, const struct ldb_message
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, errmsg);
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1432,7 +1432,7 @@ static int lsql_modify_async(struct ldb_module *module, const struct ldb_message
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, errmsg);
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1511,7 +1511,7 @@ static int lsql_delete_async(struct ldb_module *module, const struct ldb_dn *dn,
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, errmsg);
free(errmsg);
}
ret = LDB_ERR_OPERATIONS_ERROR;
@@ -1591,7 +1591,7 @@ static int lsql_rename_async(struct ldb_module *module, const struct ldb_dn *old
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, errmsg);
free(errmsg);
}
ret = LDB_ERR_OPERATIONS_ERROR;
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 2a3781b2f0..6a35595d52 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -517,7 +517,7 @@ int ltdb_search(struct ldb_module *module, struct ldb_request *req)
ret = ltdb_search_full(req->handle);
}
if (ret != LDB_SUCCESS) {
- ldb_set_errstring(module->ldb, talloc_strdup(module->ldb, "Indexed and full searches both failed!\n"));
+ ldb_set_errstring(module->ldb, "Indexed and full searches both failed!\n");
req->handle->state = LDB_ASYNC_DONE;
req->handle->status = ret;
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 7ee715f561..8f8cb68d98 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -87,7 +87,7 @@ struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module
h = talloc_zero(ltdb, struct ldb_handle);
if (h == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
return NULL;
}
@@ -95,7 +95,7 @@ struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module
ac = talloc_zero(h, struct ltdb_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
talloc_free(h);
return NULL;
}
@@ -181,10 +181,7 @@ int ltdb_check_special_dn(struct ldb_module *module, const struct ldb_message *m
for (i = 0; i < msg->num_elements; i++) {
for (j = 0; j < msg->elements[i].num_values; j++) {
if (ltdb_check_at_attributes_values(&msg->elements[i].values[j]) != 0) {
- char *err_string = talloc_strdup(module, "Invalid attribute value in an @ATTRIBUTES entry");
- if (err_string) {
- ldb_set_errstring(module->ldb, err_string);
- }
+ ldb_set_errstring(module->ldb, "Invalid attribute value in an @ATTRIBUTES entry");
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
}
@@ -258,6 +255,7 @@ done:
static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message *msg)
{
+ char *err;
int ret;
ret = ltdb_check_special_dn(module, msg);
@@ -278,7 +276,7 @@ static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message
if (!dn) {
return ret;
}
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Entry %s already exists", dn));
+ ldb_asprintf_errstring(module->ldb, "Entry %s already exists", dn);
talloc_free(dn);
return ret;
}
@@ -629,7 +627,6 @@ 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 *err_string;
char *dn;
switch (msg->elements[i].flags & LDB_FLAG_MOD_MASK) {
@@ -654,8 +651,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
for (j=0;j<el->num_values;j++) {
if (ldb_msg_find_val(el2, &el->values[j])) {
- err_string = talloc_strdup(module, "Type or value exists");
- if (err_string) ldb_set_errstring(module->ldb, err_string);
+ ldb_set_errstring(module->ldb, "Type or value exists");
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto failed;
}
@@ -705,9 +701,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
if (msg->elements[i].num_values == 0) {
if (msg_delete_attribute(module, ldb, msg2,
msg->elements[i].name) != 0) {
- err_string = talloc_asprintf(module, "No such attribute: %s for delete on %s",
- msg->elements[i].name, dn);
- if (err_string) ldb_set_errstring(module->ldb, err_string);
+ ldb_asprintf_errstring(module->ldb, "No such attribute: %s for delete on %s", msg->elements[i].name, dn);
ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
@@ -718,9 +712,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
msg2,
msg->elements[i].name,
&msg->elements[i].values[j]) != 0) {
- err_string = talloc_asprintf(module, "No matching attribute value when deleting attribute: %s on %s",
- msg->elements[i].name, dn);
- if (err_string) ldb_set_errstring(module->ldb, err_string);
+ ldb_asprintf_errstring(module->ldb, "No matching attribute value when deleting attribute: %s on %s", msg->elements[i].name, dn);
ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
@@ -731,10 +723,9 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
}
break;
default:
- err_string = talloc_asprintf(module, "Invalid ldb_modify flags on %s: 0x%x",
- msg->elements[i].name,
- msg->elements[i].flags & LDB_FLAG_MOD_MASK);
- if (err_string) ldb_set_errstring(module->ldb, err_string);
+ ldb_asprintf_errstring(module->ldb, "Invalid ldb_modify flags on %s: 0x%x",
+ msg->elements[i].name,
+ msg->elements[i].flags & LDB_FLAG_MOD_MASK);
ret = LDB_ERR_PROTOCOL_ERROR;
goto failed;
}
diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c
index 110470c8bb..1185cd8dac 100644
--- a/source4/lib/ldb/modules/asq.c
+++ b/source4/lib/ldb/modules/asq.c
@@ -72,7 +72,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
h = talloc_zero(mem_ctx, struct ldb_handle);
if (h == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
return NULL;
}
@@ -80,7 +80,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
ac = talloc_zero(h, struct asq_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
talloc_free(h);
return NULL;
}
@@ -154,7 +154,7 @@ static int asq_base_callback(struct ldb_context *ldb, void *context, struct ldb_
struct asq_context *ac;
if (!context || !ares) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
+ ldb_set_errstring(ldb, "NULL Context or Result in callback");
goto error;
}
@@ -178,7 +178,7 @@ static int asq_reqs_callback(struct ldb_context *ldb, void *context, struct ldb_
struct asq_context *ac;
if (!context || !ares) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
+ ldb_set_errstring(ldb, "NULL Context or Result in callback");
goto error;
}
@@ -220,8 +220,8 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req)
req->handle = NULL;
if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module,
- "Async interface called with NULL callback function or NULL context"));
+ ldb_set_errstring(module->ldb,
+ "Async interface called with NULL callback function or NULL context");
return LDB_ERR_OPERATIONS_ERROR;
}
diff --git a/source4/lib/ldb/modules/ldb_map.c b/source4/lib/ldb/modules/ldb_map.c
index 4a21defc2b..33d8fe0e4d 100644
--- a/source4/lib/ldb/modules/ldb_map.c
+++ b/source4/lib/ldb/modules/ldb_map.c
@@ -827,7 +827,7 @@ static int map_search_mp(struct ldb_module *module, struct ldb_request *req)
talloc_free(newattrs);
if (mpret != LDB_SUCCESS) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, ldb_errstring(privdat->mapped_ldb)));
+ ldb_set_errstring(module->ldb, ldb_errstring(privdat->mapped_ldb));
return mpret;
}
diff --git a/source4/lib/ldb/modules/objectclass.c b/source4/lib/ldb/modules/objectclass.c
index a8c99226cd..9f9e8dadae 100644
--- a/source4/lib/ldb/modules/objectclass.c
+++ b/source4/lib/ldb/modules/objectclass.c
@@ -63,7 +63,7 @@ static struct ldb_handle *oc_init_handle(struct ldb_request *req, struct ldb_mod
h = talloc_zero(req, struct ldb_handle);
if (h == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
return NULL;
}
@@ -71,7 +71,7 @@ static struct ldb_handle *oc_init_handle(struct ldb_request *req, struct ldb_mod
ac = talloc_zero(h, struct oc_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
talloc_free(h);
return NULL;
}
@@ -129,7 +129,7 @@ static int objectclass_sort(struct ldb_module *module,
for (i=0; i < objectclass_element->num_values; i++) {
current = talloc(mem_ctx, struct class_list);
if (!current) {
- ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "objectclass: out of memory allocating objectclass list"));
+ ldb_set_errstring(module->ldb, "objectclass: out of memory allocating objectclass list");
talloc_free(mem_ctx);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -235,7 +235,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req)
/* prepare the first operation */
down_req = talloc(req, struct ldb_request);
if (down_req == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module->ldb, "Out of memory!"));
+ ldb_set_errstring(module->ldb, "Out of memory!");
talloc_free(mem_ctx);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -264,7 +264,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req)
for (current = sorted; current; current = current->next) {
ret = ldb_msg_add_string(msg, "objectClass", current->objectclass);
if (ret != LDB_SUCCESS) {
- ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "objectclass: could not re-add sorted objectclass to modify msg"));
+ ldb_set_errstring(module->ldb, "objectclass: could not re-add sorted objectclass to modify msg");
talloc_free(mem_ctx);
return ret;
}
@@ -328,7 +328,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req
/* prepare the first operation */
down_req = talloc(req, struct ldb_request);
if (down_req == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module->ldb, "Out of memory!"));
+ ldb_set_errstring(module->ldb, "Out of memory!");
talloc_free(mem_ctx);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -362,7 +362,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req
for (current = sorted; current; current = current->next) {
ret = ldb_msg_add_string(msg, "objectClass", current->objectclass);
if (ret != LDB_SUCCESS) {
- ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "objectclass: could not re-add sorted objectclass to modify msg"));
+ ldb_set_errstring(module->ldb, "objectclass: could not re-add sorted objectclass to modify msg");
talloc_free(mem_ctx);
return ret;
}
@@ -404,7 +404,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req
/* prepare the first operation */
ac->down_req = talloc(ac, struct ldb_request);
if (ac->down_req == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module->ldb, "Out of memory!"));
+ ldb_set_errstring(module->ldb, "Out of memory!");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -425,7 +425,7 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_
struct oc_context *ac;
if (!context || !ares) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
+ ldb_set_errstring(ldb, "NULL Context or Result in callback");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -434,7 +434,7 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_
/* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) {
if (ac->search_res != NULL) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "Too many results"));
+ ldb_set_errstring(ldb, "Too many results");
talloc_free(ares);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -466,7 +466,7 @@ static int objectclass_search_self(struct ldb_handle *h) {
ac->search_req->op.search.scope = LDB_SCOPE_BASE;
ac->search_req->op.search.tree = ldb_parse_tree(ac->module->ldb, NULL);
if (ac->search_req->op.search.tree == NULL) {
- ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: Internal error producing null search"));
+ ldb_set_errstring(ac->module->ldb, "objectclass: Internal error producing null search");
return LDB_ERR_OPERATIONS_ERROR;
}
ac->search_req->op.search.attrs = attrs;
@@ -511,7 +511,7 @@ static int objectclass_do_mod(struct ldb_handle *h) {
/* use a new message structure */
ac->mod_req->op.mod.message = msg = ldb_msg_new(ac->mod_req);
if (msg == NULL) {
- ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: could not create new modify msg"));
+ ldb_set_errstring(ac->module->ldb, "objectclass: could not create new modify msg");
talloc_free(mem_ctx);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -539,7 +539,7 @@ static int objectclass_do_mod(struct ldb_handle *h) {
ret = ldb_msg_add_empty(msg, "objectClass", LDB_FLAG_MOD_REPLACE);
if (ret != LDB_SUCCESS) {
- ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: could not clear objectclass in modify msg"));
+ ldb_set_errstring(ac->module->ldb, "objectclass: could not clear objectclass in modify msg");
talloc_free(mem_ctx);
return ret;
}
@@ -548,7 +548,7 @@ static int objectclass_do_mod(struct ldb_handle *h) {
for (current = sorted; current; current = current->next) {
ret = ldb_msg_add_string(msg, "objectClass", current->objectclass);
if (ret != LDB_SUCCESS) {
- ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: could not re-add sorted objectclass to modify msg"));
+ ldb_set_errstring(ac->module->ldb, "objectclass: could not re-add sorted objectclass to modify msg");
talloc_free(mem_ctx);
return ret;
}
diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c
index 7e7c8d83ad..934622eccd 100644
--- a/source4/lib/ldb/modules/operational.c
+++ b/source4/lib/ldb/modules/operational.c
@@ -240,7 +240,7 @@ static int operational_callback(struct ldb_context *ldb, void *context, struct l
struct operational_context *ac;
if (!context || !ares) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
+ ldb_set_errstring(ldb, "NULL Context or Result in callback");
goto error;
}
diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c
index 2d972b7316..ddaed38fe9 100644
--- a/source4/lib/ldb/modules/paged_results.c
+++ b/source4/lib/ldb/modules/paged_results.c
@@ -141,7 +141,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
h = talloc_zero(mem_ctx, struct ldb_handle);
if (h == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
return NULL;
}
@@ -149,7 +149,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
ac = talloc_zero(h, struct paged_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
talloc_free(h);
return NULL;
}
@@ -171,7 +171,7 @@ static int paged_search_callback(struct ldb_context *ldb, void *context, struct
struct paged_context *ac = NULL;
if (!context || !ares) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
+ ldb_set_errstring(ldb, "NULL Context or Result in callback");
goto error;
}
@@ -254,8 +254,8 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
req->handle = NULL;
if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module,
- "Async interface called with NULL callback function or NULL context"));
+ ldb_set_errstring(module->ldb,
+ "Async interface called with NULL callback function or NULL context");
return LDB_ERR_OPERATIONS_ERROR;
}
diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c
index 1ab034f4fb..0ae16d08ab 100644
--- a/source4/lib/ldb/modules/sort.c
+++ b/source4/lib/ldb/modules/sort.c
@@ -72,7 +72,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
h = talloc_zero(mem_ctx, struct ldb_handle);
if (h == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
return NULL;
}
@@ -80,7 +80,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
ac = talloc_zero(h, struct sort_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, "Out of Memory");
talloc_free(h);
return NULL;
}
@@ -171,7 +171,7 @@ static int server_sort_search_callback(struct ldb_context *ldb, void *context, s
struct sort_context *ac = NULL;
if (!context || !ares) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
+ ldb_set_errstring(ldb, "NULL Context or Result in callback");
goto error;
}
@@ -245,7 +245,8 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
req->handle = NULL;
if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Async interface called with NULL callback function or NULL context"));
+ ldb_set_errstring(module->ldb,
+ "Async interface called with NULL callback function or NULL context");
return LDB_ERR_OPERATIONS_ERROR;
}