summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/modules/ldb_map.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-10-12 06:10:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:41 -0500
commita599edf04cbdeef9014923ba0d3713b8ff84f266 (patch)
tree3754385df962fd26fe8bd0e16f3c3b706a385c24 /source4/lib/ldb/modules/ldb_map.c
parent655138602c75925a6d655841ee80cf5346a9a399 (diff)
downloadsamba-a599edf04cbdeef9014923ba0d3713b8ff84f266.tar.gz
samba-a599edf04cbdeef9014923ba0d3713b8ff84f266.tar.bz2
samba-a599edf04cbdeef9014923ba0d3713b8ff84f266.zip
r10913: This patch isn't as big as it looks ...
most of the changes are fixes to make all the ldb code compile without warnings on gcc4. Unfortunately That required a lot of casts :-( I have also added the start of an 'operational' module, which will replace the timestamp module, plus add support for some other operational attributes In ldb_msg_*() I added some new utility functions to make the operational module sane, and remove the 'ldb' argument from the ldb_msg_add_*() functions. That argument was only needed back in the early days of ldb when we didn't use the hierarchical talloc and thus needed a place to get the allocation function from. Now its just a pain to pass around everywhere. Also added a ldb_debug_set() function that calls ldb_debug() plus sets the result using ldb_set_errstring(). That saves on some awkward coding in a few places. (This used to be commit f6818daecca95760c12f79fd307770cbe3346f57)
Diffstat (limited to 'source4/lib/ldb/modules/ldb_map.c')
-rw-r--r--source4/lib/ldb/modules/ldb_map.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/source4/lib/ldb/modules/ldb_map.c b/source4/lib/ldb/modules/ldb_map.c
index 246fc5709d..48aa7e2ef5 100644
--- a/source4/lib/ldb/modules/ldb_map.c
+++ b/source4/lib/ldb/modules/ldb_map.c
@@ -625,7 +625,7 @@ static struct ldb_message *ldb_map_message_incoming(struct ldb_module *module, c
for (j = 0; j < oldelm->num_values; j++)
elm->values[j] = ldb_val_dup(elm, &oldelm->values[j]);
- ldb_msg_add(module->ldb, msg, elm, oldelm->flags);
+ ldb_msg_add(msg, elm, oldelm->flags);
break;
case MAP_CONVERT:
@@ -642,7 +642,7 @@ static struct ldb_message *ldb_map_message_incoming(struct ldb_module *module, c
for (j = 0; j < oldelm->num_values; j++)
elm->values[j] = attr->u.convert.convert_remote(module, elm, &oldelm->values[j]);
- ldb_msg_add(module->ldb, msg, elm, oldelm->flags);
+ ldb_msg_add(msg, elm, oldelm->flags);
break;
case MAP_KEEP:
@@ -659,7 +659,7 @@ static struct ldb_message *ldb_map_message_incoming(struct ldb_module *module, c
elm->name = talloc_strdup(elm, oldelm->name);
- ldb_msg_add(module->ldb, msg, elm, oldelm->flags);
+ ldb_msg_add(msg, elm, oldelm->flags);
break;
case MAP_GENERATE:
@@ -671,7 +671,7 @@ static struct ldb_message *ldb_map_message_incoming(struct ldb_module *module, c
if (!elm)
continue;
- ldb_msg_add(module->ldb, msg, elm, elm->flags);
+ ldb_msg_add(msg, elm, elm->flags);
break;
default:
ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Unknown attr->type for %s", attr->local_name);
@@ -750,9 +750,11 @@ static int map_search_fb(struct ldb_module *module, const struct ldb_dn *base,
{
int ret;
struct ldb_parse_tree t_and, t_not, t_present, *childs[2];
+ char *ismapped;
t_present.operation = LDB_OP_PRESENT;
- t_present.u.present.attr = talloc_strdup(NULL, "isMapped");
+ ismapped = talloc_strdup(module, "isMapped");
+ t_present.u.present.attr = ismapped;
t_not.operation = LDB_OP_NOT;
t_not.u.isnot.child = &t_present;
@@ -765,7 +767,7 @@ static int map_search_fb(struct ldb_module *module, const struct ldb_dn *base,
ret = ldb_next_search_bytree(module, base, scope, &t_and, attrs, res);
- talloc_free(t_present.u.present.attr);
+ talloc_free(ismapped);
return ret;
}
@@ -847,7 +849,7 @@ static int map_search_mp(struct ldb_module *module, const struct ldb_dn *base,
int j;
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "Extra data found for remote DN: %s", ldb_dn_linearize(merged, merged->dn));
for (j = 0; j < extrares[0]->num_elements; j++) {
- ldb_msg_add(module->ldb, merged, &(extrares[0]->elements[j]), extrares[0]->elements[j].flags);
+ ldb_msg_add(merged, &(extrares[0]->elements[j]), extrares[0]->elements[j].flags);
}
}
@@ -941,7 +943,7 @@ static int map_add(struct ldb_module *module, const struct ldb_message *msg)
fb->dn = talloc_reference(fb, msg->dn);
/* We add objectClass, so 'top' should be no problem */
- ldb_msg_add_string(module->ldb, mp, "objectClass", "top");
+ ldb_msg_add_string(mp, "objectClass", "top");
/* make a list of remote objectclasses that can be used
* given the attributes that are available and add to
@@ -971,7 +973,7 @@ static int map_add(struct ldb_module *module, const struct ldb_message *msg)
/* Apparently, it contains all required elements */
if (has_musts && has_baseclasses) {
- ldb_msg_add_string(module->ldb, mp, "objectClass", privdat->objectclass_maps[i].remote_name);
+ ldb_msg_add_string(mp, "objectClass", privdat->objectclass_maps[i].remote_name);
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "map_add: Adding objectClass %s", privdat->objectclass_maps[i].remote_name);
}
}
@@ -1071,7 +1073,7 @@ static int map_add(struct ldb_module *module, const struct ldb_message *msg)
continue;
}
- ldb_msg_add(module->ldb, mp, elm, 0);
+ ldb_msg_add(mp, elm, 0);
mapped++;
}
@@ -1083,7 +1085,7 @@ static int map_add(struct ldb_module *module, const struct ldb_message *msg)
elm->values = talloc_reference(elm, msg->elements[i].values);
elm->name = talloc_strdup(elm, msg->elements[i].name);
- ldb_msg_add(module->ldb, fb, elm, 0);
+ ldb_msg_add(fb, elm, 0);
}
}
@@ -1095,7 +1097,7 @@ static int map_add(struct ldb_module *module, const struct ldb_message *msg)
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "ldb_map_add: Added mapped record");
- ldb_msg_add_string(module->ldb, fb, "isMapped", "TRUE");
+ ldb_msg_add_string(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_errstring(module->ldb));
@@ -1159,7 +1161,7 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
elm->values[j] = msg->elements[i].values[j];
}
- ldb_msg_add(module->ldb, mp, elm, msg->elements[i].flags);
+ ldb_msg_add(mp, elm, msg->elements[i].flags);
mapped++;
continue;
@@ -1176,7 +1178,7 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
elm->values[j] = attr->u.convert.convert_local(module, mp, &msg->elements[i].values[j]);
}
- ldb_msg_add(module->ldb, mp, elm, msg->elements[i].flags);
+ ldb_msg_add(mp, elm, msg->elements[i].flags);
mapped++;
continue;
@@ -1191,7 +1193,7 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
elm->name = talloc_strdup(elm, msg->elements[i].name);
- ldb_msg_add(module->ldb, mp, elm, msg->elements[i].flags);
+ ldb_msg_add(mp, elm, msg->elements[i].flags);
mapped++;
continue;
@@ -1209,8 +1211,7 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
elm->values = talloc_reference(elm, msg->elements[i].values);
elm->name = talloc_strdup(elm, msg->elements[i].name);
- ldb_msg_add(module->ldb, fb, elm, msg->elements[i].flags);
-
+ ldb_msg_add(fb, elm, msg->elements[i].flags);
}
}
@@ -1218,7 +1219,7 @@ static int map_modify(struct ldb_module *module, const struct ldb_message *msg)
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "Modifying fallback record with %d elements", fb->num_elements);
fb_ret = ldb_next_modify_record(module, fb);
if (fb_ret == -1) {
- ldb_msg_add_string(module->ldb, fb, "isMapped", "TRUE");
+ ldb_msg_add_string(fb, "isMapped", "TRUE");
fb_ret = ldb_next_add_record(module, fb);
}
} else fb_ret = 0;