summaryrefslogtreecommitdiff
path: root/lib/ldb/ldb_map/ldb_map_outbound.c
diff options
context:
space:
mode:
authorKarolin Seeger <kseeger@samba.org>2014-07-28 09:13:45 +0200
committerKarolin Seeger <kseeger@samba.org>2014-07-28 09:18:00 +0200
commitfcc634b483255bedf53f3aea40334c018e13dcce (patch)
tree7d59833bd515e295e70ec188e1aa2b1436b3355c /lib/ldb/ldb_map/ldb_map_outbound.c
parent97d7291d12e803076022d71556c792b0cd4e60e8 (diff)
parent80a1dfddf9086700a8de5fd6005a9179b0bb3d9e (diff)
downloadsamba-2cd741d5ceefd9e0771f5ea4891bc93baa48a165.tar.gz
Merge commit 'origin/v4-1-test^' into v4-1-stablesamba-4.1.10
This was needed because of a changed commit message (fixed version number) in v4-1-stable after generating the 'samba-4.1.9' tag. Karolin Signed-off-by: Karolin Seeger <kseeger@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib/ldb/ldb_map/ldb_map_outbound.c')
-rw-r--r--lib/ldb/ldb_map/ldb_map_outbound.c64
1 files changed, 35 insertions, 29 deletions
diff --git a/lib/ldb/ldb_map/ldb_map_outbound.c b/lib/ldb/ldb_map/ldb_map_outbound.c
index 2c517a625dc..1ee2dfe12de 100644
--- a/lib/ldb/ldb_map/ldb_map_outbound.c
+++ b/lib/ldb/ldb_map/ldb_map_outbound.c
@@ -134,6 +134,7 @@ static const char **map_attrs_collect_remote(struct ldb_module *module, void *me
goto named;
case LDB_MAP_RENAME:
+ case LDB_MAP_RENDROP:
case LDB_MAP_CONVERT:
name = map->u.rename.remote_name;
goto named;
@@ -189,26 +190,30 @@ static int map_attrs_partition(struct ldb_module *module, void *mem_ctx, const c
static int ldb_msg_replace(struct ldb_message *msg, const struct ldb_message_element *el)
{
struct ldb_message_element *old;
-
+ int j;
old = ldb_msg_find_element(msg, el->name);
/* no local result, add as new element */
if (old == NULL) {
if (ldb_msg_add_empty(msg, el->name, 0, &old) != 0) {
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
- talloc_free(discard_const_p(char, old->name));
+ }
+ else {
+ talloc_free(old->values);
}
- /* copy new element */
- *old = *el;
-
- /* and make sure we reference the contents */
- if (!talloc_reference(msg->elements, el->name)) {
- return -1;
+ old->values = talloc_array(msg->elements, struct ldb_val, el->num_values);
+ old->num_values = el->num_values;
+ if (old->values == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- if (!talloc_reference(msg->elements, el->values)) {
- return -1;
+ /* copy the values into the element */
+ for (j=0;j<el->num_values;j++) {
+ old->values[j] = ldb_val_dup(old->values, &el->values[j]);
+ if (old->values[j].data == NULL && el->values[j].length != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
}
return 0;
@@ -241,7 +246,7 @@ static struct ldb_message_element *ldb_msg_el_map_remote(struct ldb_module *modu
for (i = 0; data->attribute_maps[i].local_name; i++) {
struct ldb_map_attribute *am = &data->attribute_maps[i];
- if ((am->type == LDB_MAP_RENAME &&
+ if (((am->type == LDB_MAP_RENAME || am->type == LDB_MAP_RENDROP) &&
!strcmp(am->u.rename.remote_name, attr_name))
|| (am->type == LDB_MAP_CONVERT &&
!strcmp(am->u.convert.remote_name, attr_name))) {
@@ -306,6 +311,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
remote_name = attr_name;
break;
case LDB_MAP_RENAME:
+ case LDB_MAP_RENDROP:
remote_name = map->u.rename.remote_name;
break;
case LDB_MAP_GENERATE:
@@ -327,6 +333,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
/* fall through */
case LDB_MAP_KEEP:
case LDB_MAP_RENAME:
+ case LDB_MAP_RENDROP:
old = ldb_msg_find_element(remote, remote_name);
if (old) {
el = ldb_msg_el_map_remote(module, local, map, attr_name, old);
@@ -480,7 +487,7 @@ static int map_reply_remote(struct map_context *ac, struct ldb_reply *ares)
msg = ldb_msg_new(ares);
if (msg == NULL) {
map_oom(ac->module);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
/* Merge remote message into new message */
@@ -494,7 +501,7 @@ static int map_reply_remote(struct map_context *ac, struct ldb_reply *ares)
dn = ldb_dn_map_rebase_remote(ac->module, msg, ares->message->dn);
if (dn == NULL) {
talloc_free(msg);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
msg->dn = dn;
@@ -581,7 +588,7 @@ static int map_subtree_select_local_not(struct ldb_module *module, void *mem_ctx
*new = talloc_memdup(mem_ctx, tree, sizeof(struct ldb_parse_tree));
if (*new == NULL) {
map_oom(module);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
/* Generate new subtree */
@@ -613,7 +620,7 @@ static int map_subtree_select_local_list(struct ldb_module *module, void *mem_ct
*new = talloc_memdup(mem_ctx, tree, sizeof(struct ldb_parse_tree));
if (*new == NULL) {
map_oom(module);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
/* Prepare list of subtrees */
@@ -622,7 +629,7 @@ static int map_subtree_select_local_list(struct ldb_module *module, void *mem_ct
if ((*new)->u.list.elements == NULL) {
map_oom(module);
talloc_free(*new);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
/* Generate new list of subtrees */
@@ -662,7 +669,7 @@ static int map_subtree_select_local_simple(struct ldb_module *module, void *mem_
*new = talloc_memdup(mem_ctx, tree, sizeof(struct ldb_parse_tree));
if (*new == NULL) {
map_oom(module);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
return 0;
@@ -705,7 +712,7 @@ static int map_subtree_collect_remote_not(struct ldb_module *module, void *mem_c
*new = talloc_memdup(mem_ctx, tree, sizeof(struct ldb_parse_tree));
if (*new == NULL) {
map_oom(module);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
/* Generate new subtree */
@@ -737,7 +744,7 @@ static int map_subtree_collect_remote_list(struct ldb_module *module, void *mem_
*new = talloc_memdup(mem_ctx, tree, sizeof(struct ldb_parse_tree));
if (*new == NULL) {
map_oom(module);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
/* Prepare list of subtrees */
@@ -746,7 +753,7 @@ static int map_subtree_collect_remote_list(struct ldb_module *module, void *mem_
if ((*new)->u.list.elements == NULL) {
map_oom(module);
talloc_free(*new);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
/* Generate new list of subtrees */
@@ -788,7 +795,7 @@ int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx,
*new = talloc(mem_ctx, struct ldb_parse_tree);
if (*new == NULL) {
map_oom(module);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
**new = *tree;
@@ -825,7 +832,7 @@ int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx,
break;
default: /* unknown kind of simple subtree */
talloc_free(*new);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
if (attr == NULL) {
@@ -834,7 +841,7 @@ int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx,
return 0;
}
- if (map->type == LDB_MAP_RENAME) {
+ if (map->type == LDB_MAP_RENAME || map->type == LDB_MAP_RENDROP) {
/* Nothing more to do here, the attribute has been renamed */
return 0;
}
@@ -848,7 +855,7 @@ int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx,
int i;
/* Map value */
(*new)->u.substring.chunks = NULL;
- for (i=0; tree->u.substring.chunks[i]; i++) {
+ for (i=0; tree->u.substring.chunks && tree->u.substring.chunks[i]; i++) {
(*new)->u.substring.chunks = talloc_realloc(*new, (*new)->u.substring.chunks, struct ldb_val *, i+2);
if (!(*new)->u.substring.chunks) {
talloc_free(*new);
@@ -880,7 +887,7 @@ int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx,
break;
default: /* unknown kind of simple subtree */
talloc_free(*new);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
return 0;
@@ -1031,7 +1038,7 @@ done:
oom:
map_oom(module);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
@@ -1264,8 +1271,7 @@ static int map_remote_search_callback(struct ldb_request *req,
if (ret != LDB_SUCCESS) {
talloc_free(ares);
- return ldb_module_done(ac->req, NULL, NULL,
- LDB_ERR_OPERATIONS_ERROR);
+ return ldb_module_done(ac->req, NULL, NULL, ret);
}
break;