summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-08-13 07:33:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:15:31 -0500
commitfaed8175063b16df94d5332581baf1af0562bb09 (patch)
treeeb7c5b5fee25bf0e004f76ba40dad3785ef3ef9f
parenta9ad616a6820cb98f85e2543f65a2b711e080da7 (diff)
downloadsamba-faed8175063b16df94d5332581baf1af0562bb09.tar.gz
samba-faed8175063b16df94d5332581baf1af0562bb09.tar.xz
samba-faed8175063b16df94d5332581baf1af0562bb09.zip
r17514: Simplify the way to set ldb errors and add another
helper function to set them. (This used to be commit 260868bae56194fcb98d55afc22fc66d96a303df)
-rw-r--r--source4/dsdb/samdb/ldb_modules/extended_dn.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/kludge_acl.c11
-rw-r--r--source4/dsdb/samdb/ldb_modules/local_password.c41
-rw-r--r--source4/dsdb/samdb/ldb_modules/partition.c61
-rw-r--r--source4/dsdb/samdb/ldb_modules/password_hash.c68
-rw-r--r--source4/dsdb/samdb/ldb_modules/proxy.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/rootdse.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c68
-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
-rw-r--r--source4/nbt_server/wins/wins_ldb.c8
25 files changed, 250 insertions, 255 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn.c b/source4/dsdb/samdb/ldb_modules/extended_dn.c
index e79af570427..64600fff8bd 100644
--- a/source4/dsdb/samdb/ldb_modules/extended_dn.c
+++ b/source4/dsdb/samdb/ldb_modules/extended_dn.c
@@ -184,7 +184,7 @@ static int extended_callback(struct ldb_context *ldb, void *context, struct ldb_
struct extended_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/dsdb/samdb/ldb_modules/kludge_acl.c b/source4/dsdb/samdb/ldb_modules/kludge_acl.c
index ecb3e00f956..088f2657cca 100644
--- a/source4/dsdb/samdb/ldb_modules/kludge_acl.c
+++ b/source4/dsdb/samdb/ldb_modules/kludge_acl.c
@@ -114,7 +114,7 @@ static int kludge_acl_callback(struct ldb_context *ldb, void *context, struct ld
int i;
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;
}
@@ -199,10 +199,11 @@ static int kludge_acl_change(struct ldb_module *module, struct ldb_request *req)
case ADMINISTRATOR:
return ldb_next_request(module, req);
default:
- ldb_set_errstring(module->ldb,
- talloc_asprintf(req, "kludge_acl_change: "
- "attempted database modify not permitted. User %s is not SYSTEM or an administrator",
- user_name(req, module)));
+ ldb_asprintf_errstring(module->ldb,
+ "kludge_acl_change: "
+ "attempted database modify not permitted. "
+ "User %s is not SYSTEM or an administrator",
+ user_name(req, module));
return LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS;
}
}
diff --git a/source4/dsdb/samdb/ldb_modules/local_password.c b/source4/dsdb/samdb/ldb_modules/local_password.c
index 90fb3ae23bb..85e43186938 100644
--- a/source4/dsdb/samdb/ldb_modules/local_password.c
+++ b/source4/dsdb/samdb/ldb_modules/local_password.c
@@ -96,7 +96,7 @@ static struct ldb_handle *lpdb_init_handle(struct ldb_request *req, struct ldb_m
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;
}
@@ -104,7 +104,7 @@ static struct ldb_handle *lpdb_init_handle(struct ldb_request *req, struct ldb_m
ac = talloc_zero(h, struct lpdb_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;
}
@@ -159,8 +159,9 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req
/* TODO: remove this when sambaPassword will be in schema */
if (!ldb_msg_check_string_attribute(req->op.add.message, "objectClass", "person")) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Cannot relocate a password on entry: %s, does not have objectClass 'person'",
- ldb_dn_linearize(req, req->op.add.message->dn)));
+ ldb_asprintf_errstring(module->ldb,
+ "Cannot relocate a password on entry: %s, does not have objectClass 'person'",
+ ldb_dn_linearize(req, req->op.add.message->dn));
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
@@ -217,8 +218,7 @@ static int local_password_add(struct ldb_module *module, struct ldb_request *req
* search', to allow the directory to create the objectGUID */
if (ldb_msg_find_ldb_val(ac->orig_req->op.add.message, "objectGUID") == NULL) {
ldb_set_errstring(module->ldb,
- talloc_asprintf(req,
- "no objectGUID found in search: local_password module must be configured below objectGUID module!\n"));
+ "no objectGUID found in search: local_password module must be configured below objectGUID module!\n");
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -361,7 +361,7 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_
struct lpdb_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;
}
@@ -370,7 +370,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;
}
@@ -404,7 +404,7 @@ static int local_password_mod_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, "Invalid search filter"));
+ ldb_set_errstring(ac->module->ldb, "Invalid search filter");
return LDB_ERR_OPERATIONS_ERROR;
}
ac->search_req->op.search.attrs = attrs;
@@ -429,10 +429,9 @@ static int local_password_mod_local(struct ldb_handle *h) {
/* if it is not an entry of type person this is an error */
/* TODO: remove this when sambaPassword will be in schema */
if (!ac->search_res) {
- ldb_set_errstring(ac->module->ldb,
- talloc_asprintf(ac,
- "entry just modified (%s) not found!",
- ldb_dn_linearize(ac, ac->remote_req->op.mod.message->dn)));
+ ldb_asprintf_errstring(ac->module->ldb,
+ "entry just modified (%s) not found!",
+ ldb_dn_linearize(ac, ac->remote_req->op.mod.message->dn));
return LDB_ERR_OPERATIONS_ERROR;
}
if (!ldb_msg_check_string_attribute(ac->search_res->message, "objectClass", "person")) {
@@ -442,8 +441,7 @@ static int local_password_mod_local(struct ldb_handle *h) {
if (ldb_msg_find_ldb_val(ac->search_res->message, "objectGUID") == NULL) {
ldb_set_errstring(ac->module->ldb,
- talloc_asprintf(ac,
- "no objectGUID found in search: local_password module must be configured below objectGUID module!\n"));
+ "no objectGUID found in search: local_password module must be configured below objectGUID module!\n");
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
@@ -470,7 +468,7 @@ static int lpdb_local_search_callback(struct ldb_context *ldb, void *context, st
struct lpdb_local_search_context *local_context;
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;
}
@@ -482,7 +480,7 @@ static int lpdb_local_search_callback(struct ldb_context *ldb, void *context, st
{
int i;
if (local_context->local_res != NULL) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "Too many results to base search for password entry!"));
+ ldb_set_errstring(ldb, "Too many results to base search for password entry!");
talloc_free(ares);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -527,7 +525,7 @@ static int lpdb_local_search_callback(struct ldb_context *ldb, void *context, st
default:
{
talloc_free(ares);
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "Unexpected result type in base search for password entry!"));
+ ldb_set_errstring(ldb, "Unexpected result type in base search for password entry!");
return LDB_ERR_OPERATIONS_ERROR;
}
}
@@ -540,7 +538,7 @@ static int lpdb_remote_search_callback(struct ldb_context *ldb, void *context, s
struct lpdb_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;
}
@@ -568,8 +566,7 @@ static int lpdb_remote_search_callback(struct ldb_context *ldb, void *context, s
if (ldb_msg_find_ldb_val(ares->message, "objectGUID") == NULL) {
ldb_set_errstring(ac->module->ldb,
- talloc_asprintf(ac,
- "no objectGUID found in search: local_password module must be configured below objectGUID module!\n"));
+ "no objectGUID found in search: local_password module must be configured below objectGUID module!\n");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -606,7 +603,7 @@ static int lpdb_remote_search_callback(struct ldb_context *ldb, void *context, s
req->op.search.scope = LDB_SCOPE_BASE;
req->op.search.tree = ldb_parse_tree(ac->module->ldb, NULL);
if (req->op.search.tree == NULL) {
- ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "out of memory"));
+ ldb_set_errstring(ac->module->ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
req->op.search.attrs = ac->orig_req->op.search.attrs;
diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index af8fa475d1d..ba0c2bc9f40 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -61,7 +61,7 @@ static struct ldb_handle *partition_init_handle(struct ldb_request *req, struct
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;
}
@@ -69,7 +69,7 @@ static struct ldb_handle *partition_init_handle(struct ldb_request *req, struct
ac = talloc_zero(h, struct partition_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;
}
@@ -128,7 +128,7 @@ static int partition_search_callback(struct ldb_context *ldb, void *context, str
struct partition_context *ac;
if (!context || !ares) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "partition_search_callback: NULL Context or Result in 'search' callback"));
+ ldb_set_errstring(ldb, "partition_search_callback: NULL Context or Result in 'search' callback");
goto error;
}
@@ -158,7 +158,7 @@ static int partition_other_callback(struct ldb_context *ldb, void *context, stru
struct partition_context *ac;
if (!context) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "partition_other_callback: NULL Context in 'other' callback"));
+ ldb_set_errstring(ldb, "partition_other_callback: NULL Context in 'other' callback");
goto error;
}
@@ -179,7 +179,7 @@ static int partition_other_callback(struct ldb_context *ldb, void *context, stru
talloc_free(ares);
return LDB_SUCCESS;
}
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "partition_other_callback: Unknown reply type, only supports START_TLS"));
+ ldb_set_errstring(ldb, "partition_other_callback: Unknown reply type, only supports START_TLS");
error:
talloc_free(ares);
return LDB_ERR_OPERATIONS_ERROR;
@@ -194,12 +194,12 @@ static int partition_send_request(struct partition_context *ac, struct ldb_modul
ac->down_req = talloc_realloc(ac, ac->down_req,
struct ldb_request *, ac->num_requests + 1);
if (!ac->down_req) {
- ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac->module->ldb, "Out of memory!"));
+ ldb_set_errstring(ac->module->ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
ac->down_req[ac->num_requests] = talloc(ac, struct ldb_request);
if (ac->down_req[ac->num_requests] == NULL) {
- ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac->module->ldb, "Out of memory!"));
+ ldb_set_errstring(ac->module->ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -543,9 +543,7 @@ static int partition_init(struct ldb_module *module)
partition_attributes = ldb_msg_find_element(msg, "partition");
if (!partition_attributes) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(module, "partition_init: "
- "no partitions specified"));
+ ldb_set_errstring(module->ldb, "partition_init: no partitions specified");
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -558,18 +556,18 @@ static int partition_init(struct ldb_module *module)
char *base = talloc_strdup(data->partitions, (char *)partition_attributes->values[i].data);
char *p = strchr(base, ':');
if (!p) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(module, "partition_init: "
- "invalid form for partition record (missing ':'): %s", base));
+ ldb_asprintf_errstring(module->ldb,
+ "partition_init: "
+ "invalid form for partition record (missing ':'): %s", base);
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
p[0] = '\0';
p++;
if (!p[0]) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(module, "partition_init: "
- "invalid form for partition record (missing backend database): %s", base));
+ ldb_asprintf_errstring(module->ldb,
+ "partition_init: "
+ "invalid form for partition record (missing backend database): %s", base);
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -581,9 +579,8 @@ static int partition_init(struct ldb_module *module)
data->partitions[i]->dn = ldb_dn_explode(data->partitions[i], base);
if (!data->partitions[i]->dn) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(module, "partition_init: "
- "invalid DN in partition record: %s", base));
+ ldb_asprintf_errstring(module->ldb,
+ "partition_init: invalid DN in partition record: %s", base);
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -635,10 +632,10 @@ static int partition_init(struct ldb_module *module)
for (i=0; i < replicate_attributes->num_values; i++) {
data->replicate[i] = ldb_dn_explode(data->replicate, replicate_attributes->values[i].data);
if (!data->replicate[i]) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(module, "partition_init: "
- "invalid DN in partition replicate record: %s",
- replicate_attributes->values[i].data));
+ ldb_asprintf_errstring(module->ldb,
+ "partition_init: "
+ "invalid DN in partition replicate record: %s",
+ replicate_attributes->values[i].data);
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -657,18 +654,18 @@ static int partition_init(struct ldb_module *module)
char *base = talloc_strdup(data->partitions, (char *)modules_attributes->values[i].data);
char *p = strchr(base, ':');
if (!p) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(mem_ctx, "partition_init: "
- "invalid form for partition module record (missing ':'): %s", base));
+ ldb_asprintf_errstring(module->ldb,
+ "partition_init: "
+ "invalid form for partition module record (missing ':'): %s", base);
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
p[0] = '\0';
p++;
if (!p[0]) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(mem_ctx, "partition_init: "
- "invalid form for partition module record (missing backend database): %s", base));
+ ldb_asprintf_errstring(module->ldb,
+ "partition_init: "
+ "invalid form for partition module record (missing backend database): %s", base);
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -691,9 +688,9 @@ static int partition_init(struct ldb_module *module)
}
if (!partition) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(mem_ctx, "partition_init: "
- "invalid form for partition module record (no such partition): %s", base));
+ ldb_asprintf_errstring(module->ldb,
+ "partition_init: "
+ "invalid form for partition module record (no such partition): %s", base);
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c
index 804235258f5..93af3ae2600 100644
--- a/source4/dsdb/samdb/ldb_modules/password_hash.c
+++ b/source4/dsdb/samdb/ldb_modules/password_hash.c
@@ -156,10 +156,10 @@ static int add_krb5_keys_from_password(struct ldb_module *module, struct ldb_mes
char *name = talloc_strdup(msg, samAccountName);
char *saltbody;
if (name == NULL) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(msg, "password_hash_handle: "
- "generation of new kerberos keys failed: %s is a computer without a samAccountName",
- ldb_dn_linearize(msg, msg->dn)));
+ ldb_asprintf_errstring(module->ldb,
+ "password_hash_handle: "
+ "generation of new kerberos keys failed: %s is a computer without a samAccountName",
+ ldb_dn_linearize(msg, msg->dn));
return LDB_ERR_OPERATIONS_ERROR;
}
if (name[strlen(name)-1] == '$') {
@@ -187,10 +187,10 @@ static int add_krb5_keys_from_password(struct ldb_module *module, struct ldb_mes
}
} else {
if (!samAccountName) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(msg, "password_hash_handle: "
- "generation of new kerberos keys failed: %s has no samAccountName",
- ldb_dn_linearize(msg, msg->dn)));
+ ldb_asprintf_errstring(module->ldb,
+ "password_hash_handle: "
+ "generation of new kerberos keys failed: %s has no samAccountName",
+ ldb_dn_linearize(msg, msg->dn));
return LDB_ERR_OPERATIONS_ERROR;
}
krb5_ret = krb5_make_principal(smb_krb5_context->krb5_context,
@@ -200,11 +200,10 @@ static int add_krb5_keys_from_password(struct ldb_module *module, struct ldb_mes
}
if (krb5_ret) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(msg, "password_hash_handle: "
- "generation of a saltking principal failed: %s",
- smb_get_krb5_error_message(smb_krb5_context->krb5_context,
- krb5_ret, msg)));
+ ldb_asprintf_errstring(module->ldb,
+ "password_hash_handle: "
+ "generation of a saltking principal failed: %s",
+ smb_get_krb5_error_message(smb_krb5_context->krb5_context, krb5_ret, msg));
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -214,11 +213,10 @@ static int add_krb5_keys_from_password(struct ldb_module *module, struct ldb_mes
krb5_free_principal(smb_krb5_context->krb5_context, salt_principal);
if (krb5_ret) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(msg, "password_hash_handle: "
- "generation of new kerberos keys failed: %s",
- smb_get_krb5_error_message(smb_krb5_context->krb5_context,
- krb5_ret, msg)));
+ ldb_asprintf_errstring(module->ldb,
+ "password_hash_handle: "
+ "generation of new kerberos keys failed: %s",
+ smb_get_krb5_error_message(smb_krb5_context->krb5_context, krb5_ret, msg));
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -426,7 +424,7 @@ static struct ldb_handle *ph_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;
}
@@ -434,7 +432,7 @@ static struct ldb_handle *ph_init_handle(struct ldb_request *req, struct ldb_mod
ac = talloc_zero(h, struct ph_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;
}
@@ -456,7 +454,7 @@ static int get_domain_data_callback(struct ldb_context *ldb, void *context, stru
struct ph_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;
}
@@ -465,7 +463,7 @@ static int get_domain_data_callback(struct ldb_context *ldb, void *context, stru
/* we are interested only in the single reply (base search) we receive here */
if (ares->type == LDB_REPLY_ENTRY) {
if (ac->dom_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;
}
@@ -504,7 +502,7 @@ static int build_domain_data_request(struct ph_context *ac)
ac->dom_req->op.search.tree = ldb_parse_tree(ac->module->ldb, filter);
if (ac->dom_req->op.search.tree == NULL) {
- ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "Invalid search filter"));
+ ldb_set_errstring(ac->module->ldb, "Invalid search filter");
talloc_free(ac->dom_req);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -598,29 +596,23 @@ static int password_hash_add(struct ldb_module *module, struct ldb_request *req)
/* if it is not an entry of type person its an error */
/* TODO: remove this when sambaPassword will be in schema */
if (!ldb_msg_check_string_attribute(req->op.add.message, "objectClass", "person")) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Cannot set a password on entry that does not have objectClass 'person'"));
+ ldb_set_errstring(module->ldb, "Cannot set a password on entry that does not have objectClass 'person'");
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
/* check sambaPassword is single valued here */
/* TODO: remove this when sambaPassword will be single valued in schema */
if (sambaAttr && sambaAttr->num_values > 1) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(req,
- "mupltiple values for sambaPassword not allowed!\n"));
+ ldb_set_errstring(module->ldb, "mupltiple values for sambaPassword not allowed!\n");
return LDB_ERR_CONSTRAINT_VIOLATION;
}
if (ntAttr && (ntAttr->num_values > 1)) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(req,
- "mupltiple values for lmPwdHash not allowed!\n"));
+ ldb_set_errstring(module->ldb, "mupltiple values for lmPwdHash not allowed!\n");
return LDB_ERR_CONSTRAINT_VIOLATION;
}
if (lmAttr && (lmAttr->num_values > 1)) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(req,
- "mupltiple values for lmPwdHash not allowed!\n"));
+ ldb_set_errstring(module->ldb, "mupltiple values for lmPwdHash not allowed!\n");
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -807,7 +799,7 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r
/* prepare the first operation */
ac->down_req = talloc_zero(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;
}
@@ -844,7 +836,7 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_
struct ph_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;
}
@@ -853,7 +845,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;
}
@@ -861,7 +853,7 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_
/* if it is not an entry of type person this is an error */
/* TODO: remove this when sambaPassword will be in schema */
if (!ldb_msg_check_string_attribute(ares->message, "objectClass", "person")) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "Object class violation"));
+ ldb_set_errstring(ldb, "Object class violation");
talloc_free(ares);
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
@@ -899,7 +891,7 @@ static int password_hash_mod_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, "Invalid search filter"));
+ ldb_set_errstring(ac->module->ldb, "Invalid search filter");
return LDB_ERR_OPERATIONS_ERROR;
}
ac->search_req->op.search.attrs = attrs;
diff --git a/source4/dsdb/samdb/ldb_modules/proxy.c b/source4/dsdb/samdb/ldb_modules/proxy.c
index 6a7d04d3312..c8e5a91e587 100644
--- a/source4/dsdb/samdb/ldb_modules/proxy.c
+++ b/source4/dsdb/samdb/ldb_modules/proxy.c
@@ -298,7 +298,7 @@ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *re
newreq->controls = req->controls;
ret = ldb_request(proxy->upstream, newreq);
if (ret != LDB_SUCCESS) {
- ldb_set_errstring(module->ldb, talloc_strdup(module, ldb_errstring(proxy->upstream)));
+ ldb_set_errstring(module->ldb, ldb_errstring(proxy->upstream));
talloc_free(newreq);
return -1;
}
diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index efb3d9a05f9..ab9c43577cd 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -152,7 +152,7 @@ static int rootdse_callback(struct ldb_context *ldb, void *context, struct ldb_r
struct rootdse_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/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index d0c278257e4..55f545a45aa 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -138,9 +138,9 @@ static int samldb_find_next_rid(struct ldb_module *module, TALLOC_CTX *mem_ctx,
str = ldb_msg_find_string(res->msgs[0], "nextRid", NULL);
if (str == NULL) {
- ldb_set_errstring(module->ldb,
- talloc_asprintf(mem_ctx, "attribute nextRid not found in %s\n",
- ldb_dn_linearize(res, dn)));
+ ldb_asprintf_errstring(module->ldb,
+ "attribute nextRid not found in %s\n",
+ ldb_dn_linearize(res, dn));
talloc_free(res);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -177,7 +177,9 @@ static int samldb_allocate_next_rid(struct ldb_module *module, TALLOC_CTX *mem_c
* This is a critical situation it means that someone messed up with
* the DB and nextRid is not returning free RIDs, report an error
* and refuse to create any user until the problem is fixed */
- ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "Critical Error: unconsistent DB, unable to retireve an unique RID to generate a new SID: %s", ldb_errstring(module->ldb)));
+ ldb_asprintf_errstring(module->ldb,
+ "Critical Error: unconsistent DB, unable to retireve an unique RID to generate a new SID: %s",
+ ldb_errstring(module->ldb));
return ret;
}
return ret;
@@ -233,7 +235,9 @@ static int samldb_get_new_sid(struct ldb_module *module,
dom_dn = samldb_search_domain(module, mem_ctx, obj_dn);
if (dom_dn == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "Invalid dn (%s) not child of a domain object!\n", ldb_dn_linearize(mem_ctx, obj_dn)));
+ ldb_asprintf_errstring(module->ldb,
+ "Invalid dn (%s) not child of a domain object!\n",
+ ldb_dn_linearize(mem_ctx, obj_dn));
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -241,22 +245,24 @@ static int samldb_get_new_sid(struct ldb_module *module,
ret = ldb_search(module->ldb, dom_dn, LDB_SCOPE_BASE, "objectSid=*", attrs, &res);
if (ret != LDB_SUCCESS) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "samldb_get_new_sid: error retrieving domain sid from %s: %s!\n",
- ldb_dn_linearize(mem_ctx, dom_dn),
- ldb_errstring(module->ldb)));
+ ldb_asprintf_errstring(module->ldb,
+ "samldb_get_new_sid: error retrieving domain sid from %s: %s!\n",
+ ldb_dn_linearize(mem_ctx, dom_dn),
+ ldb_errstring(module->ldb));
talloc_free(res);
return ret;
}
if (res->count != 1) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "samldb_get_new_sid: error retrieving domain sid from %s: not found!\n",
- ldb_dn_linearize(mem_ctx, dom_dn)));
+ ldb_asprintf_errstring(module->ldb,
+ "samldb_get_new_sid: error retrieving domain sid from %s: not found!\n",
+ ldb_dn_linearize(mem_ctx, dom_dn));
return LDB_ERR_CONSTRAINT_VIOLATION;
}
dom_sid = samdb_result_dom_sid(res, res->msgs[0], "objectSid");
if (dom_sid == NULL) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "samldb_get_new_sid: error parsing domain sid!\n"));
+ ldb_set_errstring(module->ldb, "samldb_get_new_sid: error parsing domain sid!\n");
talloc_free(res);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -299,19 +305,19 @@ int samldb_notice_sid(struct ldb_module *module,
if (ret == LDB_SUCCESS) {
if (res->count > 0) {
talloc_free(res);
- ldb_set_errstring(module->ldb,
- talloc_asprintf(mem_ctx,
- "Attempt to add record with SID %s rejected,"
- " because this SID is already in the database",
- dom_sid_string(mem_ctx, sid)));
+ ldb_asprintf_errstring(module->ldb,
+ "Attempt to add record with SID %s rejected,"
+ " because this SID is already in the database",
+ dom_sid_string(mem_ctx, sid));
/* We have a duplicate SID, we must reject the add */
return LDB_ERR_CONSTRAINT_VIOLATION;
}
talloc_free(res);
} else {
- ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "samldb_notice_sid: error searching to see if sid %s is in use: %s\n",
- dom_sid_string(mem_ctx, sid),
- ldb_errstring(module->ldb)));
+ ldb_asprintf_errstring(module->ldb,
+ "samldb_notice_sid: error searching to see if sid %s is in use: %s\n",
+ dom_sid_string(mem_ctx, sid),
+ ldb_errstring(module->ldb));
return ret;
}
@@ -338,14 +344,16 @@ int samldb_notice_sid(struct ldb_module *module,
if (dom_res->count > 1) {
talloc_free(dom_res);
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "samldb_notice_sid: error retrieving domain from sid: duplicate (found %d) domain: %s!\n",
- dom_res->count, dom_sid_string(dom_res, dom_sid)));
+ ldb_asprintf_errstring(module->ldb,
+ "samldb_notice_sid: error retrieving domain from sid: duplicate (found %d) domain: %s!\n",
+ dom_res->count, dom_sid_string(dom_res, dom_sid));
return LDB_ERR_OPERATIONS_ERROR;
}
} else {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "samldb_notice_sid: error retrieving domain from sid: %s: %s\n",
- dom_sid_string(dom_res, dom_sid),
- ldb_errstring(module->ldb)));
+ ldb_asprintf_errstring(module->ldb,
+ "samldb_notice_sid: error retrieving domain from sid: %s: %s\n",
+ dom_sid_string(dom_res, dom_sid),
+ ldb_errstring(module->ldb));
return ret;
}
@@ -537,7 +545,7 @@ static int samldb_fill_user_or_computer_object(struct ldb_module *module, const
rdn = ldb_dn_get_rdn(msg2, msg2->dn);
if (strcasecmp(rdn->name, "cn") != 0) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Bad RDN (%s=) for user/computer, should be CN=!\n", rdn->name));
+ ldb_asprintf_errstring(module->ldb, "Bad RDN (%s=) for user/computer, should be CN=!\n", rdn->name);
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -606,7 +614,7 @@ static int samldb_fill_foreignSecurityPrincipal_object(struct ldb_module *module
rdn = ldb_dn_get_rdn(msg2, msg2->dn);
if (strcasecmp(rdn->name, "cn") != 0) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "Bad RDN (%s=) for ForeignSecurityPrincipal, should be CN=!", rdn->name));
+ ldb_asprintf_errstring(module->ldb, "Bad RDN (%s=) for ForeignSecurityPrincipal, should be CN=!", rdn->name);
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -617,7 +625,7 @@ static int samldb_fill_foreignSecurityPrincipal_object(struct ldb_module *module
sid = dom_sid_parse_talloc(msg2, (const char *)rdn->value.data);
if (!sid) {
- ldb_set_errstring(module->ldb, talloc_asprintf(module, "No valid found SID in ForeignSecurityPrincipal CN!"));
+ ldb_set_errstring(module->ldb, "No valid found SID in ForeignSecurityPrincipal CN!");
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -647,9 +655,9 @@ static int samldb_fill_foreignSecurityPrincipal_object(struct ldb_module *module
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "NOTE (strange but valid): Adding foreign SID record with SID %s, but this domian (%s) is already in the database",
dom_sid_string(mem_ctx, sid), name);
} else if (ret == -1) {
- ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx,
- "samldb_fill_foreignSecurityPrincipal_object: error searching for a domain with this sid: %s\n",
- dom_sid_string(mem_ctx, dom_sid)));
+ ldb_asprintf_errstring(module->ldb,
+ "samldb_fill_foreignSecurityPrincipal_object: error searching for a domain with this sid: %s\n",
+ dom_sid_string(mem_ctx, dom_sid));
talloc_free(dom_msgs);
return LDB_ERR_OPERATIONS_ERROR;
}
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 9420318fa90..ce42a36a595 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 c4718c7f522..2548a5495aa 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 d38c873c3bd..e863a2beb5d 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 2fe9e39e68e..b0dc74bdb57 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 97e2828371b..99b9f99fb34 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 f6ddbf49318..c71f1be9ba2 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 1a20a285909..74ef1fcb478 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 153a6d27d48..dcac88a6b94 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 2a3781b2f09..6a35595d524 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 7ee715f5619..8f8cb68d985 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 110470c8bb6..1185cd8dac0 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 4a21defc2b1..33d8fe0e4df 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 a8c99226cd8..9f9e8dadae2 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 7e7c8d83add..934622eccd9 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 2d972b73164..ddaed38fe9b 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 1ab034f4fb5..0ae16d08ab9 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;
}
diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c
index c70bf652b7b..5bd1783c690 100644
--- a/source4/nbt_server/wins/wins_ldb.c
+++ b/source4/nbt_server/wins/wins_ldb.c
@@ -42,7 +42,6 @@ static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req)
struct winsdb_handle *h = talloc_get_type(ldb_get_opaque(module->ldb, "winsdb_handle"),
struct winsdb_handle);
const struct ldb_message *msg;
- char *error = NULL;
switch (req->operation) {
case LDB_ADD:
@@ -63,9 +62,7 @@ static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req)
}
if (!h) {
- error = talloc_strdup(module, "WINS_LDB: INTERNAL ERROR: no winsdb_handle present!");
- ldb_debug(module->ldb, LDB_DEBUG_FATAL, "%s", error);
- ldb_set_errstring(module->ldb, error);
+ ldb_debug_set(module->ldb, LDB_DEBUG_FATAL, "%s", "WINS_LDB: INTERNAL ERROR: no winsdb_handle present!");
return LDB_ERR_OTHER;
}
@@ -76,8 +73,7 @@ static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req)
return ldb_next_request(module, req);
case WINSDB_HANDLE_CALLER_ADMIN:
- error = talloc_strdup(module, "WINS_LDB: TODO verify add/modify for WINSDB_HANDLE_CALLER_ADMIN");
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "%s\n", error);
+ ldb_debug(module->ldb, LDB_DEBUG_WARNING, "%s\n", "WINS_LDB: TODO verify add/modify for WINSDB_HANDLE_CALLER_ADMIN");
return ldb_next_request(module, req);
}