summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules
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 /source4/dsdb/samdb/ldb_modules
parenta9ad616a6820cb98f85e2543f65a2b711e080da7 (diff)
downloadsamba-faed8175063b16df94d5332581baf1af0562bb09.tar.gz
samba-faed8175063b16df94d5332581baf1af0562bb09.tar.bz2
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)
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules')
-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
8 files changed, 125 insertions, 130 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn.c b/source4/dsdb/samdb/ldb_modules/extended_dn.c
index e79af57042..64600fff8b 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 ecb3e00f95..088f2657cc 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 90fb3ae23b..85e4318693 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 af8fa475d1..ba0c2bc9f4 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 804235258f..93af3ae260 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 6a7d04d331..c8e5a91e58 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 efb3d9a05f..ab9c43577c 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 d0c278257e..55f545a45a 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;
}