summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/modules/ldb_map.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-09-18 18:49:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:16 -0500
commit16aff2a184f7fab64d718b356056070e305e99e9 (patch)
treec1c3dd59cb0e9c54c0ce95bf9165d353206ebd8e /source4/lib/ldb/modules/ldb_map.c
parent46a8d809376cab59c579c654b0de5105727a9585 (diff)
downloadsamba-16aff2a184f7fab64d718b356056070e305e99e9.tar.gz
samba-16aff2a184f7fab64d718b356056070e305e99e9.tar.bz2
samba-16aff2a184f7fab64d718b356056070e305e99e9.zip
r10305: start implementing better error handling
changed the prioivate modules API error string are now not spread over all modules but are kept in a single place. This allows a better control of memory and error reporting. (This used to be commit 3fc676ac1d6f59d08bedbbd9377986154cf84ce4)
Diffstat (limited to 'source4/lib/ldb/modules/ldb_map.c')
-rw-r--r--source4/lib/ldb/modules/ldb_map.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/source4/lib/ldb/modules/ldb_map.c b/source4/lib/ldb/modules/ldb_map.c
index 93ae13ffc2..69e021b4ee 100644
--- a/source4/lib/ldb/modules/ldb_map.c
+++ b/source4/lib/ldb/modules/ldb_map.c
@@ -97,7 +97,6 @@ static const struct ldb_map_objectclass *map_find_objectclass_remote(struct ldb_
struct map_private {
struct ldb_map_context context;
- const char *last_err_string;
};
static struct ldb_map_context *map_get_privdat(struct ldb_module *module)
@@ -807,8 +806,7 @@ static int map_search_bytree_mp(struct ldb_module *module, const struct ldb_dn *
talloc_free(newattrs);
if (mpret == -1) {
- struct map_private *map_private = module->private_data;
- map_private->last_err_string = ldb_errstring(privdat->mapped_ldb);
+ ldb_set_errstring(module, talloc_strdup(module, ldb_errstring(privdat->mapped_ldb)));
return -1;
}
@@ -910,13 +908,12 @@ static int map_search(struct ldb_module *module, const struct ldb_dn *base,
enum ldb_scope scope, const char *expression,
const char * const *attrs, struct ldb_message ***res)
{
- struct map_private *map = module->private_data;
struct ldb_parse_tree *tree;
int ret;
tree = ldb_parse_tree(NULL, expression);
if (tree == NULL) {
- map->last_err_string = "expression parse failed";
+ ldb_set_errstring(module, talloc_strdup(module, "expression parse failed"));
return -1;
}
@@ -1121,7 +1118,7 @@ static int map_add(struct ldb_module *module, const struct ldb_message *msg)
ldb_msg_add_string(module->ldb, fb, "isMapped", "TRUE");
ret = ldb_next_add_record(module, fb);
if (ret == -1) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Adding fallback record failed: %s", ldb_next_errstring(module));
+ ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Adding fallback record failed: %s", ldb_errstring(module->ldb));
return -1;
}
@@ -1266,19 +1263,6 @@ static int map_end_trans(struct ldb_module *module, int status)
return ldb_next_end_trans(module, status);
}
-/*
- return extended error information
-*/
-static const char *map_errstring(struct ldb_module *module)
-{
- struct map_private *map = module->private_data;
-
- if (map->last_err_string)
- return map->last_err_string;
-
- return ldb_next_errstring(module);
-}
-
static const struct ldb_module_ops map_ops = {
.name = "map",
.search = map_search,
@@ -1288,8 +1272,7 @@ static const struct ldb_module_ops map_ops = {
.delete_record = map_delete,
.rename_record = map_rename,
.start_transaction = map_start_trans,
- .end_transaction = map_end_trans,
- .errstring = map_errstring
+ .end_transaction = map_end_trans
};
static char *map_find_url(struct ldb_context *ldb, const char *name)
@@ -1354,8 +1337,6 @@ struct ldb_module *ldb_map_init(struct ldb_context *ldb, const struct ldb_map_at
talloc_free(url);
- data->last_err_string = NULL;
-
/* Get list of attribute maps */
j = 0;
data->context.attribute_maps = NULL;