summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/auth/gensec/schannel_state.c18
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectguid.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/samba3sam.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c17
-rw-r--r--source4/dsdb/samdb/samdb.c20
-rw-r--r--source4/include/ioctl.h4
-rw-r--r--source4/lib/ldb/common/attrib_handlers.c26
-rw-r--r--source4/lib/ldb/common/ldb_debug.c18
-rw-r--r--source4/lib/ldb/common/ldb_dn.c19
-rw-r--r--source4/lib/ldb/common/ldb_ldif.c14
-rw-r--r--source4/lib/ldb/common/ldb_match.c21
-rw-r--r--source4/lib/ldb/common/ldb_msg.c111
-rw-r--r--source4/lib/ldb/common/ldb_parse.c48
-rw-r--r--source4/lib/ldb/common/ldb_utf8.c1
-rw-r--r--source4/lib/ldb/config.mk9
-rw-r--r--source4/lib/ldb/include/ldb.h44
-rw-r--r--source4/lib/ldb/include/ldb_private.h2
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_cache.c13
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c28
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_pack.c14
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c16
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c2
-rw-r--r--source4/lib/ldb/modules/ldb_map.c37
-rw-r--r--source4/lib/ldb/modules/operational.c217
-rw-r--r--source4/lib/ldb/modules/rdn_name.c6
-rw-r--r--source4/lib/ldb/modules/schema.c81
-rw-r--r--source4/lib/ldb/modules/timestamps.c2
-rw-r--r--source4/lib/ldb/tools/ldbtest.c42
-rw-r--r--source4/lib/ldb/tools/oLschema2ldif.c12
-rw-r--r--source4/lib/registry/reg_backend_ldb.c12
-rw-r--r--source4/libcli/ldap/ldap.c11
-rw-r--r--source4/libnet/libnet_join.c6
-rw-r--r--source4/nbt_server/wins/winsdb.c21
-rw-r--r--source4/rpc_server/lsa/dcesrv_lsa.c2
-rw-r--r--source4/web_server/web_server.c2
35 files changed, 625 insertions, 281 deletions
diff --git a/source4/auth/gensec/schannel_state.c b/source4/auth/gensec/schannel_state.c
index 0c4f99499c..5b398b2996 100644
--- a/source4/auth/gensec/schannel_state.c
+++ b/source4/auth/gensec/schannel_state.c
@@ -118,15 +118,15 @@ NTSTATUS schannel_store_session_key(TALLOC_CTX *mem_ctx,
seed.data = creds->seed.data;
seed.length = sizeof(creds->seed.data);
- ldb_msg_add_string(ldb, msg, "objectClass", "schannelState");
- ldb_msg_add_value(ldb, msg, "sessionKey", &val);
- ldb_msg_add_value(ldb, msg, "seed", &seed);
- ldb_msg_add_string(ldb, msg, "negotiateFlags", f);
- ldb_msg_add_string(ldb, msg, "secureChannelType", sct);
- ldb_msg_add_string(ldb, msg, "accountName", creds->account_name);
- ldb_msg_add_string(ldb, msg, "computerName", creds->computer_name);
- ldb_msg_add_string(ldb, msg, "flatname", creds->domain);
- ldb_msg_add_string(ldb, msg, "rid", rid);
+ ldb_msg_add_string(msg, "objectClass", "schannelState");
+ ldb_msg_add_value(msg, "sessionKey", &val);
+ ldb_msg_add_value(msg, "seed", &seed);
+ ldb_msg_add_string(msg, "negotiateFlags", f);
+ ldb_msg_add_string(msg, "secureChannelType", sct);
+ ldb_msg_add_string(msg, "accountName", creds->account_name);
+ ldb_msg_add_string(msg, "computerName", creds->computer_name);
+ ldb_msg_add_string(msg, "flatname", creds->domain);
+ ldb_msg_add_string(msg, "rid", rid);
ldb_delete(ldb, msg->dn);
diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c
index 7dc6a433c0..70bbaf179c 100644
--- a/source4/dsdb/samdb/ldb_modules/objectguid.c
+++ b/source4/dsdb/samdb/ldb_modules/objectguid.c
@@ -101,7 +101,7 @@ static int objectguid_add_record(struct ldb_module *module, const struct ldb_mes
return -1;
}
- ret = ldb_msg_add_value(module->ldb, msg2, "objectGUID", &v);
+ ret = ldb_msg_add_value(msg2, "objectGUID", &v);
if (ret) {
return ret;
}
diff --git a/source4/dsdb/samdb/ldb_modules/samba3sam.c b/source4/dsdb/samdb/ldb_modules/samba3sam.c
index a68f6f0640..5e88cd6469 100644
--- a/source4/dsdb/samdb/ldb_modules/samba3sam.c
+++ b/source4/dsdb/samdb/ldb_modules/samba3sam.c
@@ -55,17 +55,17 @@ static void generate_hashes (struct ldb_module *module, const char *local_attr,
if (!upwd)
return;
- ldb_msg_add_string(module->ldb, remote_fb, local_attr, upwd);
+ ldb_msg_add_string(remote_fb, local_attr, upwd);
val.length = 16;
val.data = talloc_zero_size(module, val.length);
E_md4hash(upwd, val.data);
- ldb_msg_add_value(module->ldb, remote_mp, "sambaNTPassword", &val);
+ ldb_msg_add_value(remote_mp, "sambaNTPassword", &val);
val.data = talloc_zero_size(module, val.length);
E_deshash(upwd, val.data);
- ldb_msg_add_value(module->ldb, remote_mp, "sambaLMPassword", &val);
+ ldb_msg_add_value(remote_mp, "sambaLMPassword", &val);
}
@@ -119,7 +119,7 @@ static void generate_sambaPrimaryGroupSID(struct ldb_module *module, const char
sidstring = dom_sid_string(remote_mp, sid);
talloc_free(sid);
- ldb_msg_add_fmt(module->ldb, remote_mp, "sambaPrimaryGroupSID", "%s-%d", sidstring, ldb_msg_find_uint(local, "primaryGroupID", 0));
+ ldb_msg_add_fmt(remote_mp, "sambaPrimaryGroupSID", "%s-%d", sidstring, ldb_msg_find_uint(local, "primaryGroupID", 0));
talloc_free(sidstring);
}
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 906a2299f7..5ed84cc10d 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -107,17 +107,17 @@ static int samldb_allocate_next_rid(struct ldb_context *ldb, TALLOC_CTX *mem_ctx
els[1].flags = LDB_FLAG_MOD_ADD;
els[1].name = els[0].name;
- vals[0].data = talloc_asprintf(mem_ctx, "%u", *id);
+ vals[0].data = (uint8_t *)talloc_asprintf(mem_ctx, "%u", *id);
if (!vals[0].data) {
return -1;
}
- vals[0].length = strlen(vals[0].data);
+ vals[0].length = strlen((char *)vals[0].data);
- vals[1].data = talloc_asprintf(mem_ctx, "%u", (*id)+1);
+ vals[1].data = (uint8_t *)talloc_asprintf(mem_ctx, "%u", (*id)+1);
if (!vals[1].data) {
return -1;
}
- vals[1].length = strlen(vals[1].data);
+ vals[1].length = strlen((char *)vals[1].data);
ret = ldb_modify(ldb, &msg);
if (ret != 0) {
@@ -240,7 +240,8 @@ static struct ldb_message_element *samldb_find_attribute(const struct ldb_messag
return &msg->elements[i];
}
for (j = 0; j < msg->elements[i].num_values; j++) {
- if (strcasecmp(value, msg->elements[i].values[j].data) == 0) {
+ if (strcasecmp(value,
+ (char *)msg->elements[i].values[j].data) == 0) {
return &msg->elements[i];
}
}
@@ -260,7 +261,7 @@ static BOOL samldb_msg_add_string(struct ldb_module *module, struct ldb_message
return False;
}
- if (ldb_msg_add_string(module->ldb, msg, aname, aval) != 0) {
+ if (ldb_msg_add_string(msg, aname, aval) != 0) {
return False;
}
@@ -276,7 +277,7 @@ static BOOL samldb_msg_add_sid(struct ldb_module *module, struct ldb_message *ms
if (!NT_STATUS_IS_OK(status)) {
return -1;
}
- return (ldb_msg_add_value(module->ldb, msg, name, &v) == 0);
+ return (ldb_msg_add_value(msg, name, &v) == 0);
}
static BOOL samldb_find_or_add_attribute(struct ldb_module *module, struct ldb_message *msg, const char *name, const char *value, const char *set_value)
@@ -497,7 +498,7 @@ static struct ldb_message *samldb_fill_foreignSecurityPrincipal_object(struct ld
}
if ((attribute = samldb_find_attribute(msg2, "objectSid", NULL)) == NULL ) {
- struct dom_sid *sid = dom_sid_parse_talloc(msg2, rdn->value.data);
+ struct dom_sid *sid = dom_sid_parse_talloc(msg2, (char *)rdn->value.data);
if (sid == NULL) {
ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_fill_foreignSecurityPrincipal_object: internal error! Can't parse sid in CN\n");
return NULL;
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index bc8dcd0f06..6afa83e1aa 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -699,7 +699,7 @@ int samdb_msg_add_string(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struc
if (s == NULL || a == NULL) {
return -1;
}
- return ldb_msg_add_string(sam_ldb, msg, a, s);
+ return ldb_msg_add_string(msg, a, s);
}
/*
@@ -715,7 +715,7 @@ int samdb_msg_add_dom_sid(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, stru
if (!NT_STATUS_IS_OK(status)) {
return -1;
}
- return ldb_msg_add_value(sam_ldb, msg, attr_name, &v);
+ return ldb_msg_add_value(msg, attr_name, &v);
}
@@ -731,7 +731,7 @@ int samdb_msg_add_delete(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struc
}
/* we use an empty replace rather than a delete, as it allows for
samdb_replace() to be used everywhere */
- return ldb_msg_add_empty(sam_ldb, msg, a, LDB_FLAG_MOD_REPLACE);
+ return ldb_msg_add_empty(msg, a, LDB_FLAG_MOD_REPLACE);
}
/*
@@ -749,7 +749,7 @@ int samdb_msg_add_addval(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struc
v = talloc_strdup(mem_ctx, value);
if (v == NULL)
return -1;
- ret = ldb_msg_add_string(sam_ldb, msg, a, v);
+ ret = ldb_msg_add_string(msg, a, v);
if (ret != 0)
return ret;
el = ldb_msg_find_element(msg, a);
@@ -774,7 +774,7 @@ int samdb_msg_add_delval(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struc
v = talloc_strdup(mem_ctx, value);
if (v == NULL)
return -1;
- ret = ldb_msg_add_string(sam_ldb, msg, a, v);
+ ret = ldb_msg_add_string(msg, a, v);
if (ret != 0)
return ret;
el = ldb_msg_find_element(msg, a);
@@ -826,7 +826,7 @@ int samdb_msg_add_hash(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct
return -1;
}
val.length = 16;
- return ldb_msg_add_value(sam_ldb, msg, attr_name, &val);
+ return ldb_msg_add_value(msg, attr_name, &val);
}
/*
@@ -845,7 +845,7 @@ int samdb_msg_add_hashes(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struc
for (i=0;i<count;i++) {
memcpy(i*16 + (char *)val.data, hashes[i].hash, 16);
}
- return ldb_msg_add_value(sam_ldb, msg, attr_name, &val);
+ return ldb_msg_add_value(msg, attr_name, &val);
}
/*
@@ -866,7 +866,7 @@ int samdb_msg_add_logon_hours(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx,
struct ldb_val val;
val.length = hours->units_per_week / 8;
val.data = hours->bits;
- return ldb_msg_add_value(sam_ldb, msg, attr_name, &val);
+ return ldb_msg_add_value(msg, attr_name, &val);
}
/*
@@ -875,7 +875,7 @@ int samdb_msg_add_logon_hours(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx,
int samdb_msg_add_value(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, const struct ldb_val *val)
{
- return ldb_msg_add_value(sam_ldb, msg, attr_name, val);
+ return ldb_msg_add_value(msg, attr_name, val);
}
/*
@@ -890,7 +890,7 @@ int samdb_msg_set_value(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct
if (el) {
el->num_values = 0;
}
- return ldb_msg_add_value(sam_ldb, msg, attr_name, val);
+ return ldb_msg_add_value(msg, attr_name, val);
}
/*
diff --git a/source4/include/ioctl.h b/source4/include/ioctl.h
index 272004d3dc..1c08a58d76 100644
--- a/source4/include/ioctl.h
+++ b/source4/include/ioctl.h
@@ -26,5 +26,5 @@
/* filesystem control codes */
#define FSCTL_FILESYSTEM 0x90000
-#define FSCTL_SET_SPARSE (FSCTL_FILESYSTEM | 0xc4)
-
+#define FSCTL_SET_SPARSE (FSCTL_FILESYSTEM | (49<<2))
+#define FSCTL_REQUEST_BATCH_OPLOCK (FSCTL_FILESYSTEM | (2<<2))
diff --git a/source4/lib/ldb/common/attrib_handlers.c b/source4/lib/ldb/common/attrib_handlers.c
index 61ca566570..d073203b3c 100644
--- a/source4/lib/ldb/common/attrib_handlers.c
+++ b/source4/lib/ldb/common/attrib_handlers.c
@@ -53,7 +53,7 @@ static int ldb_handler_fold(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *in, struct ldb_val *out)
{
uint8_t *s1, *s2;
- out->data = talloc_size(mem_ctx, strlen(in->data)+1);
+ out->data = talloc_size(mem_ctx, strlen((char *)in->data)+1);
if (out->data == NULL) {
ldb_oom(ldb);
return -1;
@@ -69,7 +69,7 @@ static int ldb_handler_fold(struct ldb_context *ldb, void *mem_ctx,
s2++; s1++;
}
*s2 = 0;
- out->length = strlen(out->data);
+ out->length = strlen((char *)out->data);
return 0;
}
@@ -82,15 +82,15 @@ static int ldb_canonicalise_Integer(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *in, struct ldb_val *out)
{
char *end;
- long long i = strtoll(in->data, &end, 0);
+ long long i = strtoll((char *)in->data, &end, 0);
if (*end != 0) {
return -1;
}
- out->data = talloc_asprintf(mem_ctx, "%lld", i);
+ out->data = (uint8_t *)talloc_asprintf(mem_ctx, "%lld", i);
if (out->data == NULL) {
return -1;
}
- out->length = strlen(out->data);
+ out->length = strlen((char *)out->data);
return 0;
}
@@ -100,7 +100,7 @@ static int ldb_canonicalise_Integer(struct ldb_context *ldb, void *mem_ctx,
static int ldb_comparison_Integer(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2)
{
- return strtoll(v1->data, NULL, 0) - strtoll(v2->data, NULL, 0);
+ return strtoll((char *)v1->data, NULL, 0) - strtoll((char *)v2->data, NULL, 0);
}
/*
@@ -123,7 +123,7 @@ int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx,
static int ldb_comparison_fold(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2)
{
- const char *s1=v1->data, *s2=v2->data;
+ const char *s1=(const char *)v1->data, *s2=(const char *)v2->data;
while (*s1 == ' ') s1++;
while (*s2 == ' ') s2++;
/* TODO: make utf8 safe, possibly with helper function from application */
@@ -153,16 +153,16 @@ static int ldb_canonicalise_dn(struct ldb_context *ldb, void *mem_ctx,
out->length = 0;
out->data = NULL;
- dn = ldb_dn_explode_casefold(ldb, in->data);
+ dn = ldb_dn_explode_casefold(ldb, (char *)in->data);
if (dn == NULL) {
return -1;
}
- out->data = ldb_dn_linearize(mem_ctx, dn);
+ out->data = (uint8_t *)ldb_dn_linearize(mem_ctx, dn);
if (out->data == NULL) {
goto done;
}
- out->length = strlen(out->data);
+ out->length = strlen((char *)out->data);
ret = 0;
@@ -181,10 +181,10 @@ static int ldb_comparison_dn(struct ldb_context *ldb, void *mem_ctx,
struct ldb_dn *dn1 = NULL, *dn2 = NULL;
int ret;
- dn1 = ldb_dn_explode_casefold(mem_ctx, v1->data);
+ dn1 = ldb_dn_explode_casefold(mem_ctx, (char *)v1->data);
if (dn1 == NULL) return -1;
- dn2 = ldb_dn_explode_casefold(mem_ctx, v2->data);
+ dn2 = ldb_dn_explode_casefold(mem_ctx, (char *)v2->data);
if (dn2 == NULL) {
talloc_free(dn1);
return -1;
@@ -209,7 +209,7 @@ static int ldb_comparison_objectclass(struct ldb_context *ldb, void *mem_ctx,
if (ret == 0) {
return 0;
}
- subclasses = ldb_subclass_list(ldb, v1->data);
+ subclasses = ldb_subclass_list(ldb, (char *)v1->data);
if (subclasses == NULL) {
return ret;
}
diff --git a/source4/lib/ldb/common/ldb_debug.c b/source4/lib/ldb/common/ldb_debug.c
index 59f00ccc96..d046c8cd1f 100644
--- a/source4/lib/ldb/common/ldb_debug.c
+++ b/source4/lib/ldb/common/ldb_debug.c
@@ -86,3 +86,21 @@ void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *
va_end(ap);
}
+
+/*
+ log a message, and set the ldb error string to the same message
+*/
+void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
+ const char *fmt, ...)
+{
+ va_list ap;
+ char *msg;
+ va_start(ap, fmt);
+ msg = talloc_vasprintf(ldb, fmt, ap);
+ va_end(ap);
+ if (msg != NULL) {
+ ldb_set_errstring(ldb->modules, msg);
+ ldb_debug(ldb, level, "%s", msg);
+ }
+}
+
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 2cd7d590fe..92e06025d5 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -54,7 +54,7 @@ int ldb_dn_check_special(const struct ldb_dn *dn, const char *check)
{
if (dn == NULL || dn->comp_num != 1) return 0;
- return ! strcmp(dn->components[0].value.data, check);
+ return ! strcmp((char *)dn->components[0].value.data, check);
}
static int ldb_dn_is_valid_attribute_name(const char *name)
@@ -163,7 +163,7 @@ static struct ldb_val ldb_dn_unescape_value(void *mem_ctx, const char *src)
}
value.length = end - dst;
- value.data = dst;
+ value.data = (uint8_t *)dst;
return value;
failed:
@@ -367,7 +367,7 @@ struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn)
if (edn->components == NULL) goto failed;
edn->components[0].name = talloc_strdup(edn->components, LDB_SPECIAL);
if (edn->components[0].name == NULL) goto failed;
- edn->components[0].value.data = talloc_strdup(edn->components, dn);
+ edn->components[0].value.data = (uint8_t *)talloc_strdup(edn->components, dn);
if (edn->components[0].value.data== NULL) goto failed;
edn->components[0].value.length = strlen(dn);
return edn;
@@ -425,7 +425,7 @@ char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn)
/* Special DNs */
if (ldb_dn_is_special(edn)) {
- dn = talloc_strdup(mem_ctx, edn->components[0].value.data);
+ dn = talloc_strdup(mem_ctx, (char *)edn->components[0].value.data);
return dn;
}
@@ -598,7 +598,7 @@ char *ldb_dn_linearize_casefold(struct ldb_context *ldb, const struct ldb_dn *ed
/* Special DNs */
if (ldb_dn_is_special(edn)) {
- dn = talloc_strdup(ldb, edn->components[0].value.data);
+ dn = talloc_strdup(ldb, (char *)edn->components[0].value.data);
return dn;
}
@@ -703,7 +703,7 @@ struct ldb_dn_component *ldb_dn_build_component(void *mem_ctx, const char *attr,
return NULL;
}
- dc->value.data = talloc_strdup(dc, val);
+ dc->value.data = (uint8_t *)talloc_strdup(dc, val);
if (dc->value.data == NULL) {
talloc_free(dc);
return NULL;
@@ -736,9 +736,9 @@ struct ldb_dn *ldb_dn_build_child(void *mem_ctx, const char *attr,
new->components[0].name = talloc_strdup(new->components, attr);
LDB_DN_NULL_FAILED(new->components[0].name);
- new->components[0].value.data = talloc_strdup(new->components, value);
+ new->components[0].value.data = (uint8_t *)talloc_strdup(new->components, value);
LDB_DN_NULL_FAILED(new->components[0].value.data);
- new->components[0].value.length = strlen(new->components[0].value.data);
+ new->components[0].value.length = strlen((char *)new->components[0].value.data);
return new;
@@ -753,7 +753,8 @@ struct ldb_dn *ldb_dn_make_child(void *mem_ctx, const struct ldb_dn_component *c
{
if (component == NULL) return NULL;
- return ldb_dn_build_child(mem_ctx, component->name, component->value.data, base);
+ return ldb_dn_build_child(mem_ctx, component->name,
+ (char *)component->value.data, base);
}
struct ldb_dn *ldb_dn_compose(void *mem_ctx, const struct ldb_dn *dn1, const struct ldb_dn *dn2)
diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c
index b268cca578..7ba6a00147 100644
--- a/source4/lib/ldb/common/ldb_ldif.c
+++ b/source4/lib/ldb/common/ldb_ldif.c
@@ -55,7 +55,7 @@ static int ldb_read_data_file(void *mem_ctx, struct ldb_val *value)
int ret;
int f;
- f = open(value->data, O_RDONLY);
+ f = open((const char *)value->data, O_RDONLY);
if (f == -1) {
return -1;
}
@@ -79,7 +79,7 @@ static int ldb_read_data_file(void *mem_ctx, struct ldb_val *value)
count = 0;
size = statbuf.st_size;
- buf = value->data;
+ buf = (char *)value->data;
while (count < statbuf.st_size) {
bytes = read(f, buf, size);
if (bytes == -1) {
@@ -325,7 +325,7 @@ int ldb_ldif_write(struct ldb_context *ldb,
msg->elements[i].name);
CHECK_RET;
ret = base64_encode_f(ldb, fprintf_fn, private_data,
- v.data, v.length,
+ (char *)v.data, v.length,
strlen(msg->elements[i].name)+3);
CHECK_RET;
ret = fprintf_fn(private_data, "\n");
@@ -334,7 +334,7 @@ int ldb_ldif_write(struct ldb_context *ldb,
ret = fprintf_fn(private_data, "%s: ", msg->elements[i].name);
CHECK_RET;
ret = fold_string(fprintf_fn, private_data,
- v.data, v.length,
+ (char *)v.data, v.length,
strlen(msg->elements[i].name)+2);
CHECK_RET;
ret = fprintf_fn(private_data, "\n");
@@ -461,7 +461,7 @@ static int next_attr(void *mem_ctx, char **s, const char **attr, struct ldb_val
p++;
}
- value->data = p;
+ value->data = (uint8_t *)p;
p = strchr(p, '\n');
@@ -475,7 +475,7 @@ static int next_attr(void *mem_ctx, char **s, const char **attr, struct ldb_val
}
if (base64_encoded) {
- int len = ldb_base64_decode(value->data);
+ int len = ldb_base64_decode((char *)value->data);
if (len == -1) {
/* it wasn't valid base64 data */
return -1;
@@ -588,7 +588,7 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
goto failed;
}
- msg->dn = ldb_dn_explode(msg, value.data);
+ msg->dn = ldb_dn_explode(msg, (char *)value.data);
if (msg->dn == NULL) {
ldb_debug(ldb, LDB_DEBUG_ERROR, "Error: Unable to parse dn '%s'\n",
diff --git a/source4/lib/ldb/common/ldb_match.c b/source4/lib/ldb/common/ldb_match.c
index 14031a6dd1..7573cfc808 100644
--- a/source4/lib/ldb/common/ldb_match.c
+++ b/source4/lib/ldb/common/ldb_match.c
@@ -153,7 +153,8 @@ static int ldb_match_equality(struct ldb_context *ldb,
if (ldb_attr_cmp(tree->u.equality.attr, "dn") == 0 ||
ldb_attr_cmp(tree->u.equality.attr, "distinguishedName") == 0) {
- valuedn = ldb_dn_explode_casefold(ldb, tree->u.equality.value.data);
+ valuedn = ldb_dn_explode_casefold(ldb,
+ (char *)tree->u.equality.value.data);
if (valuedn == NULL) {
return 0;
}
@@ -194,7 +195,7 @@ static int ldb_wildcard_compare(struct ldb_context *ldb,
struct ldb_val cnk;
struct ldb_val *chunk;
char *p, *g;
- char *save_p = NULL;
+ uint8_t *save_p = NULL;
int c = 0;
h = ldb_attrib_handler(ldb, tree->u.substring.attr);
@@ -211,7 +212,7 @@ static int ldb_wildcard_compare(struct ldb_context *ldb,
if(h->canonicalise_fn(ldb, ldb, chunk, &cnk) != 0) goto failed;
/* FIXME: case of embedded nulls */
- if (strncmp(val.data, cnk.data, cnk.length) != 0) goto failed;
+ if (strncmp((char *)val.data, (char *)cnk.data, cnk.length) != 0) goto failed;
val.length -= cnk.length;
val.data += cnk.length;
c++;
@@ -225,16 +226,16 @@ static int ldb_wildcard_compare(struct ldb_context *ldb,
if(h->canonicalise_fn(ldb, ldb, chunk, &cnk) != 0) goto failed;
/* FIXME: case of embedded nulls */
- p = strstr(val.data, cnk.data);
+ p = strstr((char *)val.data, (char *)cnk.data);
if (p == NULL) goto failed;
if ( (! tree->u.substring.chunks[c + 1]) && (! tree->u.substring.end_with_wildcard) ) {
do { /* greedy */
- g = strstr(p + cnk.length, cnk.data);
+ g = strstr((char *)p + cnk.length, (char *)cnk.data);
if (g) p = g;
} while(g);
}
val.length = val.length - (p - (char *)(val.data)) - cnk.length;
- val.data = p + cnk.length;
+ val.data = (uint8_t *)(p + cnk.length);
c++;
talloc_free(cnk.data);
cnk.data = NULL;
@@ -282,8 +283,8 @@ static int ldb_match_substring(struct ldb_context *ldb,
static int ldb_comparator_and(struct ldb_val *v1, struct ldb_val *v2)
{
uint64_t i1, i2;
- i1 = strtoull(v1->data, NULL, 0);
- i2 = strtoull(v2->data, NULL, 0);
+ i1 = strtoull((char *)v1->data, NULL, 0);
+ i2 = strtoull((char *)v2->data, NULL, 0);
return ((i1 & i2) == i2);
}
@@ -293,8 +294,8 @@ static int ldb_comparator_and(struct ldb_val *v1, struct ldb_val *v2)
static int ldb_comparator_or(struct ldb_val *v1, struct ldb_val *v2)
{
uint64_t i1, i2;
- i1 = strtoull(v1->data, NULL, 0);
- i2 = strtoull(v2->data, NULL, 0);
+ i1 = strtoull((char *)v1->data, NULL, 0);
+ i2 = strtoull((char *)v2->data, NULL, 0);
return ((i1 & i2) != 0);
}
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index c2f40f308a..01941f5728 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -107,7 +107,7 @@ struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v)
/* the +1 is to cope with buggy C library routines like strndup
that look one byte beyond */
- v2.data = talloc_array(mem_ctx, char, v->length+1);
+ v2.data = talloc_array(mem_ctx, uint8_t, v->length+1);
if (!v2.data) {
v2.length = 0;
return v2;
@@ -121,13 +121,12 @@ struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v)
/*
add an empty element to a message
*/
-int ldb_msg_add_empty(struct ldb_context *ldb,
- struct ldb_message *msg, const char *attr_name, int flags)
+int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags)
{
struct ldb_message_element *els;
els = talloc_realloc(msg, msg->elements,
- struct ldb_message_element, msg->num_elements+1);
+ struct ldb_message_element, msg->num_elements+1);
if (!els) {
errno = ENOMEM;
return -1;
@@ -150,12 +149,11 @@ int ldb_msg_add_empty(struct ldb_context *ldb,
/*
add an empty element to a message
*/
-int ldb_msg_add(struct ldb_context *ldb,
- struct ldb_message *msg,
+int ldb_msg_add(struct ldb_message *msg,
const struct ldb_message_element *el,
int flags)
{
- if (ldb_msg_add_empty(ldb, msg, el->name, flags) != 0) {
+ if (ldb_msg_add_empty(msg, el->name, flags) != 0) {
return -1;
}
@@ -168,8 +166,7 @@ int ldb_msg_add(struct ldb_context *ldb,
/*
add a value to a message
*/
-int ldb_msg_add_value(struct ldb_context *ldb,
- struct ldb_message *msg,
+int ldb_msg_add_value(struct ldb_message *msg,
const char *attr_name,
const struct ldb_val *val)
{
@@ -178,7 +175,7 @@ int ldb_msg_add_value(struct ldb_context *ldb,
el = ldb_msg_find_element(msg, attr_name);
if (!el) {
- ldb_msg_add_empty(ldb, msg, attr_name, 0);
+ ldb_msg_add_empty(msg, attr_name, 0);
el = ldb_msg_find_element(msg, attr_name);
}
if (!el) {
@@ -201,7 +198,7 @@ int ldb_msg_add_value(struct ldb_context *ldb,
/*
add a string element to a message
*/
-int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg,
+int ldb_msg_add_string(struct ldb_message *msg,
const char *attr_name, const char *str)
{
struct ldb_val val;
@@ -209,13 +206,13 @@ int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg,
val.data = discard_const_p(uint8_t, str);
val.length = strlen(str);
- return ldb_msg_add_value(ldb, msg, attr_name, &val);
+ return ldb_msg_add_value(msg, attr_name, &val);
}
/*
add a printf formatted element to a message
*/
-int ldb_msg_add_fmt(struct ldb_context *ldb, struct ldb_message *msg,
+int ldb_msg_add_fmt(struct ldb_message *msg,
const char *attr_name, const char *fmt, ...)
{
struct ldb_val val;
@@ -228,10 +225,10 @@ int ldb_msg_add_fmt(struct ldb_context *ldb, struct ldb_message *msg,
if (str == NULL) return -1;
- val.data = str;
+ val.data = (uint8_t *)str;
val.length = strlen(str);
- return ldb_msg_add_value(ldb, msg, attr_name, &val);
+ return ldb_msg_add_value(msg, attr_name, &val);
}
/*
@@ -287,7 +284,7 @@ int ldb_msg_find_int(const struct ldb_message *msg,
if (!v || !v->data) {
return default_value;
}
- return strtol(v->data, NULL, 0);
+ return strtol((const char *)v->data, NULL, 0);
}
unsigned int ldb_msg_find_uint(const struct ldb_message *msg,
@@ -298,7 +295,7 @@ unsigned int ldb_msg_find_uint(const struct ldb_message *msg,
if (!v || !v->data) {
return default_value;
}
- return strtoul(v->data, NULL, 0);
+ return strtoul((const char *)v->data, NULL, 0);
}
int64_t ldb_msg_find_int64(const struct ldb_message *msg,
@@ -309,7 +306,7 @@ int64_t ldb_msg_find_int64(const struct ldb_message *msg,
if (!v || !v->data) {
return default_value;
}
- return strtoll(v->data, NULL, 0);
+ return strtoll((const char *)v->data, NULL, 0);
}
uint64_t ldb_msg_find_uint64(const struct ldb_message *msg,
@@ -320,7 +317,7 @@ uint64_t ldb_msg_find_uint64(const struct ldb_message *msg,
if (!v || !v->data) {
return default_value;
}
- return strtoull(v->data, NULL, 0);
+ return strtoull((const char *)v->data, NULL, 0);
}
double ldb_msg_find_double(const struct ldb_message *msg,
@@ -331,7 +328,7 @@ double ldb_msg_find_double(const struct ldb_message *msg,
if (!v || !v->data) {
return default_value;
}
- return strtod(v->data, NULL);
+ return strtod((const char *)v->data, NULL);
}
const char *ldb_msg_find_string(const struct ldb_message *msg,
@@ -342,7 +339,7 @@ const char *ldb_msg_find_string(const struct ldb_message *msg,
if (!v || !v->data) {
return default_value;
}
- return v->data;
+ return (const char *)v->data;
}
/*
@@ -479,7 +476,7 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb,
continue;
}
- if (ldb_msg_add(ldb, mod,
+ if (ldb_msg_add(mod,
&msg2->elements[i],
el?LDB_FLAG_MOD_REPLACE:LDB_FLAG_MOD_ADD) != 0) {
return NULL;
@@ -490,7 +487,7 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb,
for (i=0;i<msg1->num_elements;i++) {
el = ldb_msg_find_element(msg2, msg1->elements[i].name);
if (!el) {
- if (ldb_msg_add_empty(ldb, mod,
+ if (ldb_msg_add_empty(mod,
msg1->elements[i].name,
LDB_FLAG_MOD_DELETE) != 0) {
return NULL;
@@ -529,3 +526,71 @@ int ldb_msg_sanity_check(const struct ldb_message *msg)
return LDB_SUCCESS;
}
+
+
+
+
+/*
+ copy an attribute list. This only copies the array, not the elements
+ (ie. the elements are left as the same pointers)
+*/
+const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs)
+{
+ const char **ret;
+ int i;
+ for (i=0;attrs[i];i++) /* noop */ ;
+ ret = talloc_array(mem_ctx, const char *, i+1);
+ if (ret == NULL) {
+ return NULL;
+ }
+ for (i=0;attrs[i];i++) {
+ ret[i] = attrs[i];
+ }
+ ret[i] = attrs[i];
+ return ret;
+}
+
+
+/*
+ return 1 if an attribute is in a list of attributes, or 0 otherwise
+*/
+int ldb_attr_in_list(const char * const *attrs, const char *attr)
+{
+ int i;
+ for (i=0;attrs[i];i++) {
+ if (ldb_attr_cmp(attrs[i], attr) == 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+/*
+ rename the specified attribute in a search result
+*/
+void ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace)
+{
+ struct ldb_message_element *el = ldb_msg_find_element(msg, attr);
+ if (el != NULL) {
+ el->name = replace;
+ }
+}
+
+
+/*
+ copy the specified attribute in a search result to a new attribute
+*/
+int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace)
+{
+ struct ldb_message_element *el = ldb_msg_find_element(msg, attr);
+ if (el == NULL) {
+ return 0;
+ }
+ if (ldb_msg_add(msg, el, 0) != 0) {
+ return -1;
+ }
+ ldb_msg_rename_attr(msg, attr, replace);
+ return 0;
+}
+
diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c
index e61511ebec..5824a8d003 100644
--- a/source4/lib/ldb/common/ldb_parse.c
+++ b/source4/lib/ldb/common/ldb_parse.c
@@ -753,3 +753,51 @@ char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree)
return NULL;
}
+
+
+/*
+ replace any occurances of an attribute name in the parse tree with a
+ new name
+*/
+void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree,
+ const char *attr,
+ const char *replace)
+{
+ int i;
+ switch (tree->operation) {
+ case LDB_OP_AND:
+ case LDB_OP_OR:
+ for (i=0;i<tree->u.list.num_elements;i++) {
+ ldb_parse_tree_attr_replace(tree->u.list.elements[i],
+ attr, replace);
+ }
+ break;
+ case LDB_OP_NOT:
+ ldb_parse_tree_attr_replace(tree->u.isnot.child, attr, replace);
+ break;
+ case LDB_OP_EQUALITY:
+ case LDB_OP_GREATER:
+ case LDB_OP_LESS:
+ case LDB_OP_APPROX:
+ if (ldb_attr_cmp(tree->u.equality.attr, attr) == 0) {
+ tree->u.equality.attr = replace;
+ }
+ break;
+ case LDB_OP_SUBSTRING:
+ if (ldb_attr_cmp(tree->u.substring.attr, attr) == 0) {
+ tree->u.substring.attr = replace;
+ }
+ break;
+ case LDB_OP_PRESENT:
+ if (ldb_attr_cmp(tree->u.present.attr, attr) == 0) {
+ tree->u.present.attr = replace;
+ }
+ break;
+ case LDB_OP_EXTENDED:
+ if (tree->u.extended.attr &&
+ ldb_attr_cmp(tree->u.extended.attr, attr) == 0) {
+ tree->u.extended.attr = replace;
+ }
+ break;
+ }
+}
diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c
index cd68180f77..69faeb46d3 100644
--- a/source4/lib/ldb/common/ldb_utf8.c
+++ b/source4/lib/ldb/common/ldb_utf8.c
@@ -80,4 +80,3 @@ int ldb_attr_cmp(const char *attr1, const char *attr2)
{
return ldb_caseless_cmp(attr1, attr2);
}
-
diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk
index f75964c44f..cdb0e171e5 100644
--- a/source4/lib/ldb/config.mk
+++ b/source4/lib/ldb/config.mk
@@ -8,6 +8,15 @@ INIT_OBJ_FILES = \
################################################
################################################
+# Start MODULE libldb_operational
+[MODULE::libldb_operational]
+SUBSYSTEM = LIBLDB
+INIT_OBJ_FILES = \
+ lib/ldb/modules/operational.o
+# End MODULE libldb_operational
+################################################
+
+################################################
# Start MODULE libldb_rdn_name
[MODULE::libldb_rdn_name]
SUBSYSTEM = LIBLDB
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 73bac2088a..d75ca4fe86 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -182,24 +182,24 @@ struct ldb_parse_tree {
struct ldb_parse_tree *child;
} isnot;
struct {
- char *attr;
+ const char *attr;
struct ldb_val value;
} equality;
struct {
- char *attr;
+ const char *attr;
int start_with_wildcard;
int end_with_wildcard;
struct ldb_val **chunks;
} substring;
struct {
- char *attr;
+ const char *attr;
} present;
struct {
- char *attr;
+ const char *attr;
struct ldb_val value;
} comparison;
struct {
- char *attr;
+ const char *attr;
int dnAttributes;
char *rule_id;
struct ldb_val value;
@@ -241,7 +241,10 @@ struct ldb_attrib_handler {
ldb_attr_comparison_t comparison_fn;
};
-#define LDB_ATTR_FLAG_HIDDEN (1<<0)
+#define LDB_ATTR_FLAG_HIDDEN (1<<0) /* the attribute is not returned by default */
+#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */
+#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */
+
/* well-known ldap attribute syntaxes - see rfc2252 section 4.3.2 */
#define LDB_SYNTAX_DN "1.3.6.1.4.1.1466.115.121.1.12"
@@ -383,7 +386,7 @@ struct ldb_dn *ldb_dn_make_child(void *mem_ctx,
const struct ldb_dn_component *component,
const struct ldb_dn *base);
struct ldb_dn *ldb_dn_compose(void *mem_ctx, const struct ldb_dn *dn1, const struct ldb_dn *dn2);
-struct ldb_dn *ldb_dn_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...);
+struct ldb_dn *ldb_dn_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...) PRINTF_ATTRIBUTE(3,4);
struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn);
/* useful functions for ldb_message structure manipulation */
@@ -406,22 +409,19 @@ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el,
struct ldb_val *val);
/* add a new empty element to a ldb_message */
-int ldb_msg_add_empty(struct ldb_context *ldb,
- struct ldb_message *msg, const char *attr_name, int flags);
+int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags);
/* add a element to a ldb_message */
-int ldb_msg_add(struct ldb_context *ldb,
- struct ldb_message *msg,
+int ldb_msg_add(struct ldb_message *msg,
const struct ldb_message_element *el,
int flags);
-int ldb_msg_add_value(struct ldb_context *ldb,
- struct ldb_message *msg,
+int ldb_msg_add_value(struct ldb_message *msg,
const char *attr_name,
const struct ldb_val *val);
-int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg,
+int ldb_msg_add_string(struct ldb_message *msg,
const char *attr_name, const char *str);
-int ldb_msg_add_fmt(struct ldb_context *ldb, struct ldb_message *msg,
- const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(4,5);
+int ldb_msg_add_fmt(struct ldb_message *msg,
+ const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
/* compare two message elements - return 0 on match */
int ldb_msg_element_compare(struct ldb_message_element *el1,
@@ -485,4 +485,16 @@ void *ldb_get_opaque(struct ldb_context *ldb, const char *name);
const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb,
const char *attrib);
+
+const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs);
+int ldb_attr_in_list(const char * const *attrs, const char *attr);
+
+
+void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree,
+ const char *attr,
+ const char *replace);
+
+void ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace);
+int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace);
+
#endif
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index 9777ad0d92..2367d6c3f8 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -145,6 +145,8 @@ void ldb_set_errstring(struct ldb_module *module, char *err_string);
/* The following definitions come from lib/ldb/common/ldb_debug.c */
void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
+ const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
/* The following definitions come from lib/ldb/common/ldb_ldif.c */
int ldb_should_b64_encode(const struct ldb_val *val);
diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c
index 5e40b8fd3f..01f9338009 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_cache.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c
@@ -95,7 +95,7 @@ static int ltdb_attributes_flags(struct ldb_message_element *el, unsigned *v)
int j;
for (j=0;ltdb_valid_attr_flags[j].name;j++) {
if (strcmp(ltdb_valid_attr_flags[j].name,
- el->values[i].data) == 0) {
+ (char *)el->values[i].data) == 0) {
value |= ltdb_valid_attr_flags[j].value;
break;
}
@@ -197,7 +197,8 @@ static int ltdb_subclasses_load(struct ldb_module *module)
for (i=0;i<msg->num_elements;i++) {
struct ldb_message_element *el = &msg->elements[i];
for (j=0;j<el->num_values;j++) {
- if (ldb_subclass_add(module->ldb, el->name, el->values[j].data) != 0) {
+ if (ldb_subclass_add(module->ldb, el->name,
+ (char *)el->values[j].data) != 0) {
goto failed;
}
}
@@ -268,7 +269,7 @@ static int ltdb_baseinfo_init(struct ldb_module *module)
el.values = &val;
el.num_values = 1;
el.flags = 0;
- val.data = talloc_strdup(msg, initial_sequence_number);
+ val.data = (uint8_t *)talloc_strdup(msg, initial_sequence_number);
if (!val.data) {
goto failed;
}
@@ -446,7 +447,7 @@ int ltdb_increase_sequence_number(struct ldb_module *module)
el.values = &val;
el.num_values = 1;
el.flags = LDB_FLAG_MOD_REPLACE;
- val.data = s;
+ val.data = (uint8_t *)s;
val.length = strlen(s);
ret = ltdb_modify_internal(module, msg);
@@ -495,7 +496,7 @@ int ltdb_attribute_flags(struct ldb_module *module, const char *attr_name)
for (i = 0; i < attr_el->num_values; i++) {
for (j=0; ltdb_valid_attr_flags[j].name; j++) {
if (strcmp(ltdb_valid_attr_flags[j].name,
- attr_el->values[i].data) == 0) {
+ (char *)attr_el->values[i].data) == 0) {
ret |= ltdb_valid_attr_flags[j].value;
}
}
@@ -514,7 +515,7 @@ int ltdb_check_at_attributes_values(const struct ldb_val *value)
int i;
for (i = 0; ltdb_valid_attr_flags[i].name != NULL; i++) {
- if ((strcmp(ltdb_valid_attr_flags[i].name, value->data) == 0)) {
+ if ((strcmp(ltdb_valid_attr_flags[i].name, (char *)value->data) == 0)) {
return 0;
}
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index 7c920dd78b..e80cf74c62 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -120,7 +120,7 @@ static struct ldb_dn *ldb_dn_key(struct ldb_context *ldb,
return NULL;
}
if (ldb_should_b64_encode(&v)) {
- char *vstr = ldb_base64_encode(ldb, v.data, v.length);
+ char *vstr = ldb_base64_encode(ldb, (char *)v.data, v.length);
if (!vstr) return NULL;
dn = talloc_asprintf(ldb, "%s:%s::%s", LTDB_INDEX, attr_folded, vstr);
talloc_free(vstr);
@@ -261,7 +261,7 @@ static int ltdb_index_dn_objectclass(struct ldb_module *module,
struct ldb_context *ldb = module->ldb;
unsigned int i;
int ret;
- const char *target = tree->u.equality.value.data;
+ const char *target = (const char *)tree->u.equality.value.data;
const char **subclasses;
list->count = 0;
@@ -279,17 +279,19 @@ static int ltdb_index_dn_objectclass(struct ldb_module *module,
struct ldb_parse_tree tree2;
struct dn_list *list2;
tree2.operation = LDB_OP_EQUALITY;
- tree2.u.equality.attr = talloc_strdup(list, LTDB_OBJECTCLASS);
+ tree2.u.equality.attr = LTDB_OBJECTCLASS;
if (!tree2.u.equality.attr) {
return -1;
}
- tree2.u.equality.value.data = talloc_strdup(tree2.u.equality.attr, subclasses[i]);
+ tree2.u.equality.value.data =
+ (uint8_t *)talloc_strdup(list, subclasses[i]);
if (tree2.u.equality.value.data == NULL) {
return -1;
}
tree2.u.equality.value.length = strlen(subclasses[i]);
list2 = talloc(list, struct dn_list);
if (list2 == NULL) {
+ talloc_free(tree2.u.equality.value.data);
return -1;
}
if (ltdb_index_dn_objectclass(module, &tree2,
@@ -302,7 +304,7 @@ static int ltdb_index_dn_objectclass(struct ldb_module *module,
talloc_free(list2);
}
}
- talloc_free(tree2.u.equality.attr);
+ talloc_free(tree2.u.equality.value.data);
}
return ret;
@@ -747,7 +749,7 @@ static int ltdb_index_add1_new(struct ldb_context *ldb,
return -1;
}
msg->elements[msg->num_elements].values[0].length = strlen(dn);
- msg->elements[msg->num_elements].values[0].data = dn;
+ msg->elements[msg->num_elements].values[0].data = (uint8_t *)dn;
msg->elements[msg->num_elements].num_values = 1;
msg->num_elements++;
@@ -770,7 +772,7 @@ static int ltdb_index_add1_add(struct ldb_context *ldb,
/* for multi-valued attributes we can end up with repeats */
for (i=0;i<msg->elements[idx].num_values;i++) {
- if (strcmp(dn, msg->elements[idx].values[i].data) == 0) {
+ if (strcmp(dn, (char *)msg->elements[idx].values[i].data) == 0) {
return 0;
}
}
@@ -784,7 +786,7 @@ static int ltdb_index_add1_add(struct ldb_context *ldb,
msg->elements[idx].values = v2;
msg->elements[idx].values[msg->elements[idx].num_values].length = strlen(dn);
- msg->elements[idx].values[msg->elements[idx].num_values].data = dn;
+ msg->elements[idx].values[msg->elements[idx].num_values].data = (uint8_t *)dn;
msg->elements[idx].num_values++;
return 0;
@@ -1027,7 +1029,7 @@ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
static int delete_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state)
{
const char *dn = "DN=" LTDB_INDEX ":";
- if (strncmp(key.dptr, dn, strlen(dn)) == 0) {
+ if (strncmp((char *)key.dptr, dn, strlen(dn)) == 0) {
return tdb_delete(tdb, key);
}
return 0;
@@ -1044,8 +1046,8 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
int ret;
TDB_DATA key2;
- if (strncmp(key.dptr, "DN=@", 4) == 0 ||
- strncmp(key.dptr, "DN=", 3) != 0) {
+ if (strncmp((char *)key.dptr, "DN=@", 4) == 0 ||
+ strncmp((char *)key.dptr, "DN=", 3) != 0) {
return 0;
}
@@ -1070,14 +1072,14 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
talloc_free(msg);
return 0;
}
- if (strcmp(key2.dptr, key.dptr) != 0) {
+ if (strcmp((char *)key2.dptr, (char *)key.dptr) != 0) {
tdb_delete(tdb, key);
tdb_store(tdb, key2, data, 0);
}
talloc_free(key2.dptr);
if (msg->dn == NULL) {
- dn = key.dptr + 3;
+ dn = (char *)key.dptr + 3;
} else {
dn = ldb_dn_linearize(msg->dn, msg->dn);
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_pack.c b/source4/lib/ldb/ldb_tdb/ldb_pack.c
index 332dbf03df..bf57aa904c 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_pack.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_pack.c
@@ -75,7 +75,7 @@ int ltdb_pack_data(struct ldb_module *module,
unsigned int i, j, real_elements=0;
size_t size;
char *dn;
- char *p;
+ uint8_t *p;
size_t len;
dn = ldb_dn_linearize(ldb, message->dn);
@@ -106,7 +106,7 @@ int ltdb_pack_data(struct ldb_module *module,
}
/* allocate it */
- data->dptr = talloc_array(ldb, char, size);
+ data->dptr = talloc_array(ldb, uint8_t, size);
if (!data->dptr) {
talloc_free(dn);
errno = ENOMEM;
@@ -157,7 +157,7 @@ int ltdb_unpack_data(struct ldb_module *module,
struct ldb_message *message)
{
struct ldb_context *ldb = module->ldb;
- char *p;
+ uint8_t *p;
unsigned int remaining;
unsigned int i, j;
unsigned format;
@@ -183,12 +183,12 @@ int ltdb_unpack_data(struct ldb_module *module,
break;
case LTDB_PACKING_FORMAT:
- len = strnlen(p, remaining);
+ len = strnlen((char *)p, remaining);
if (len == remaining) {
errno = EIO;
goto failed;
}
- message->dn = ldb_dn_explode(message, p);
+ message->dn = ldb_dn_explode(message, (char *)p);
if (message->dn == NULL) {
errno = ENOMEM;
goto failed;
@@ -226,13 +226,13 @@ int ltdb_unpack_data(struct ldb_module *module,
errno = EIO;
goto failed;
}
- len = strnlen(p, remaining-6);
+ len = strnlen((char *)p, remaining-6);
if (len == remaining-6) {
errno = EIO;
goto failed;
}
message->elements[i].flags = 0;
- message->elements[i].name = p;
+ message->elements[i].name = (char *)p;
remaining -= len + 1;
p += len + 1;
message->elements[i].num_values = pull_uint32(p, 0);
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index e0a62962c7..97f8a7d0be 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -100,17 +100,13 @@ static int msg_add_distinguished_name(struct ldb_module *module, struct ldb_mess
int ret;
el.flags = 0;
- el.name = talloc_strdup(msg, "distinguishedName");
- if (!el.name) {
- return -1;
- }
+ el.name = "distinguishedName";
el.num_values = 1;
el.values = &val;
- val.data = ldb_dn_linearize(msg, msg->dn);
- val.length = strlen(val.data);
+ val.data = (uint8_t *)ldb_dn_linearize(msg, msg->dn);
+ val.length = strlen((char *)val.data);
ret = msg_add_element(module->ldb, msg, &el, 1);
- talloc_free(el.name);
return ret;
}
@@ -190,7 +186,7 @@ static struct ldb_message *ltdb_pull_attrs(struct ldb_module *module,
if (ldb_attr_cmp(attrs[i], "distinguishedName") == 0) {
if (msg_add_distinguished_name(module, ret) != 0) {
- return -1;
+ return NULL;
}
continue;
}
@@ -358,7 +354,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
int ret;
if (key.dsize < 4 ||
- strncmp(key.dptr, "DN=", 3) != 0) {
+ strncmp((char *)key.dptr, "DN=", 3) != 0) {
return 0;
}
@@ -376,7 +372,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
}
if (!msg->dn) {
- msg->dn = ldb_dn_explode(msg, key.dptr + 3);
+ msg->dn = ldb_dn_explode(msg, (char *)key.dptr + 3);
if (msg->dn == NULL) {
talloc_free(msg);
return -1;
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 22360ffb1c..b9404a557b 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -80,7 +80,7 @@ struct TDB_DATA ltdb_key(struct ldb_module *module, const struct ldb_dn *dn)
goto failed;
}
- key.dptr = key_str;
+ key.dptr = (uint8_t *)key_str;
key.dsize = strlen(key_str) + 1;
return key;
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;
diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c
new file mode 100644
index 0000000000..911bc087ca
--- /dev/null
+++ b/source4/lib/ldb/modules/operational.c
@@ -0,0 +1,217 @@
+/*
+ ldb database library
+
+ Copyright (C) Andrew Tridgell 2005
+
+ ** NOTE! The following LGPL license applies to the ldb
+ ** library. This does NOT imply that all of Samba is released
+ ** under the LGPL
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+/*
+ handle operational attributes
+ */
+
+/*
+ createTimestamp: HIDDEN, searchable, ldaptime, alias for whenCreated
+ modifyTimestamp: HIDDEN, searchable, ldaptime, alias for whenChanged
+
+ for the above two, we do the search as normal, and if
+ createTimestamp or modifyTimestamp is asked for, then do
+ additional searches for whenCreated and whenChanged and fill in
+ the resulting values
+
+ we also need to replace these with the whenCreated/whenChanged
+ equivalent in the search expression trees
+
+ whenCreated: not-HIDDEN, CONSTRUCTED, SEARCHABLE
+ whenChanged: not-HIDDEN, CONSTRUCTED, SEARCHABLE
+
+ on init we need to setup attribute handlers for these so
+ comparisons are done correctly. The resolution is 1 second.
+
+ on add we need to add both the above, for current time
+
+ on modify we need to change whenChanged
+
+
+ subschemaSubentry: HIDDEN, not-searchable,
+ points at DN CN=Aggregate,CN=Schema,CN=Configuration,$BASEDN
+
+ for this one we do the search as normal, then add the static
+ value if requested. How do we work out the $BASEDN from inside a
+ module?
+
+
+ structuralObjectClass: HIDDEN, CONSTRUCTED, not-searchable. always same as objectclass?
+
+ for this one we do the search as normal, then if requested ask
+ for objectclass, change the attribute name, and add it
+
+ attributeTypes: in schema only
+ objectClasses: in schema only
+ matchingRules: in schema only
+ matchingRuleUse: in schema only
+ creatorsName: not supported by w2k3?
+ modifiersName: not supported by w2k3?
+*/
+
+
+#include "includes.h"
+#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_private.h"
+#include <time.h>
+
+/*
+ a list of attribute names that should be substituted in the parse
+ tree before the search is done
+*/
+static const struct {
+ const char *attr;
+ const char *replace;
+} parse_tree_sub[] = {
+ { "createTimestamp", "whenCreated" },
+ { "modifyTimestamp", "whenChanged" }
+};
+
+/*
+ a list of attribute names that are hidden, but can be searched for
+ using another (non-hidden) name to produce the correct result
+*/
+static const struct {
+ const char *attr;
+ const char *replace;
+} search_sub[] = {
+ { "createTimestamp", "whenCreated" },
+ { "modifyTimestamp", "whenChanged" },
+ { "structuralObjectClass", "objectClass" }
+};
+
+/*
+ hook search operations
+*/
+static int operational_search_bytree(struct ldb_module *module,
+ const struct ldb_dn *base,
+ enum ldb_scope scope, struct ldb_parse_tree *tree,
+ const char * const *attrs,
+ struct ldb_message ***res)
+{
+ int i, r, a;
+ int ret;
+ const char **search_attrs = NULL;
+
+ /* replace any attributes in the parse tree that are
+ searchable, but are stored using a different name in the
+ backend */
+ for (i=0;i<ARRAY_SIZE(parse_tree_sub);i++) {
+ ldb_parse_tree_attr_replace(tree,
+ parse_tree_sub[i].attr,
+ parse_tree_sub[i].replace);
+ }
+
+ /* in the list of attributes we are looking for, rename any
+ attributes to the alias for any hidden attributes that can
+ be fetched directly using non-hidden names */
+ for (i=0;i<ARRAY_SIZE(search_sub);i++) {
+ for (a=0;attrs[a];a++) {
+ if (ldb_attr_cmp(attrs[a], search_sub[i].attr) == 0) {
+ if (!search_attrs) {
+ search_attrs = ldb_attr_list_copy(module, attrs);
+ if (search_attrs == NULL) {
+ goto oom;
+ }
+ }
+ search_attrs[a] = search_sub[i].replace;
+ }
+ }
+ }
+
+
+ /* perform the search */
+ ret = ldb_next_search_bytree(module, base, scope, tree,
+ search_attrs?search_attrs:attrs, res);
+ if (ret <= 0) {
+ return ret;
+ }
+
+ /* for each record returned see if we have added any
+ attributes to the search, and if we have then either copy
+ them (if the aliased name was also asked for) or rename
+ them (if the aliased entry was not asked for) */
+ for (r=0;r<ret;r++) {
+ for (i=0;i<ARRAY_SIZE(search_sub);i++) {
+ for (a=0;attrs[a];a++) {
+ if (ldb_attr_cmp(attrs[a], search_sub[i].attr) != 0) {
+ continue;
+ }
+ if (ldb_attr_in_list(attrs, search_sub[i].replace) ||
+ ldb_attr_in_list(attrs, "*")) {
+ if (ldb_msg_copy_attr((*res)[r],
+ search_sub[i].replace,
+ search_sub[i].attr) != 0) {
+ goto oom;
+ }
+ } else {
+ ldb_msg_rename_attr((*res)[r],
+ search_sub[i].replace,
+ search_sub[i].attr);
+ }
+ }
+ }
+ }
+
+ /* all done */
+ talloc_free(search_attrs);
+ return ret;
+
+oom:
+ talloc_free(search_attrs);
+ ldb_oom(module->ldb);
+ return -1;
+}
+
+
+static const struct ldb_module_ops operational_ops = {
+ .name = "operational",
+ .search_bytree = operational_search_bytree,
+#if 0
+ .add_record = operational_add_record,
+ .modify_record = operational_modify_record,
+ .rename_record = operational_rename_record
+#endif
+};
+
+
+/* the init function */
+#ifdef HAVE_DLOPEN_DISABLED
+ struct ldb_module *init_module(struct ldb_context *ldb, const char *options[])
+#else
+struct ldb_module *operational_module_init(struct ldb_context *ldb, const char *options[])
+#endif
+{
+ struct ldb_module *ctx;
+
+ ctx = talloc(ldb, struct ldb_module);
+ if (!ctx)
+ return NULL;
+
+ ctx->private_data = NULL;
+ ctx->ldb = ldb;
+ ctx->prev = ctx->next = NULL;
+ ctx->ops = &operational_ops;
+
+ return ctx;
+}
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index 40ff75744e..c8f2ebaabd 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -97,7 +97,7 @@ static int rdn_name_add_record(struct ldb_module *module, const struct ldb_messa
return -1;
}
- if (ldb_msg_add_value(module->ldb, msg2, "name", &rdn->value) != 0) {
+ if (ldb_msg_add_value(msg2, "name", &rdn->value) != 0) {
talloc_free(msg2);
return -1;
}
@@ -105,7 +105,7 @@ static int rdn_name_add_record(struct ldb_module *module, const struct ldb_messa
attribute = rdn_name_find_attribute(msg2, rdn->name);
if (!attribute) {
- if (ldb_msg_add_value(module->ldb, msg2, rdn->name, &rdn->value) != 0) {
+ if (ldb_msg_add_value(msg2, rdn->name, &rdn->value) != 0) {
talloc_free(msg2);
return -1;
}
@@ -175,7 +175,7 @@ static int rdn_name_modify_record(struct ldb_module *module, const struct ldb_me
return -1;
}
- if (ldb_msg_add_value(module->ldb, msg2, "name", &rdn->value) != 0) {
+ if (ldb_msg_add_value(msg2, "name", &rdn->value) != 0) {
talloc_free(msg2);
return -1;
}
diff --git a/source4/lib/ldb/modules/schema.c b/source4/lib/ldb/modules/schema.c
index 0cae110487..27177116c2 100644
--- a/source4/lib/ldb/modules/schema.c
+++ b/source4/lib/ldb/modules/schema.c
@@ -106,7 +106,7 @@ static int get_msg_attributes(struct schema_structures *ss, const struct ldb_mes
}
for (j = 0, cnum = ss->objectclasses.num; j < msg->elements[i].num_values; j++) {
- ss->objectclasses.attr[cnum+j].name = msg->elements[i].values[j].data;
+ ss->objectclasses.attr[cnum+j].name = (char *)msg->elements[i].values[j].data;
ss->objectclasses.attr[cnum+j].flags = msg->elements[i].flags & flag_mask;
}
ss->objectclasses.num += msg->elements[i].num_values;
@@ -164,14 +164,15 @@ static int add_attribute_uniq(void *mem_ctx, struct schema_attribute_list *list,
for (c = 0; c < list->num; c++) {
len = strlen(list->attr[c].name);
if (len == el->values[i].length) {
- if (ldb_attr_cmp(list->attr[c].name, el->values[i].data) == 0) {
+ if (ldb_attr_cmp(list->attr[c].name,
+ (char *)el->values[i].data) == 0) {
found = 1;
break;
}
}
}
if (!found) {
- list->attr[j + list->num].name = el->values[i].data;
+ list->attr[j + list->num].name = (char *)el->values[i].data;
list->attr[j + list->num].flags = flags;
j++;
}
@@ -187,7 +188,6 @@ static int add_attribute_uniq(void *mem_ctx, struct schema_attribute_list *list,
static int get_attr_list_recursive(struct ldb_module *module, struct schema_structures *schema_struct)
{
struct ldb_message **srch;
- char *error_string;
int i, j;
int ret;
@@ -209,21 +209,18 @@ static int get_attr_list_recursive(struct ldb_module *module, struct schema_stru
talloc_steal(schema_struct, srch);
if (ret <= 0) {
- /* Schema DB Error: Error occurred retrieving Object Class Description */
- error_string = talloc_asprintf(module, "Error retrieving Objectclass %s.\n", schema_struct->objectclasses.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
+ /* Schema DB Error: Error occurred retrieving
+ Object Class Description */
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "Error retrieving Objectclass %s.\n",
+ schema_struct->objectclasses.attr[i].name);
return -1;
}
if (ret > 1) {
/* Schema DB Error: Too Many Records */
- error_string = talloc_asprintf(module, "Too many records found retrieving Objectclass %s.\n", schema_struct->objectclasses.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "Too many records found retrieving Objectclass %s.\n",
+ schema_struct->objectclasses.attr[i].name);
return -1;
}
@@ -294,7 +291,6 @@ static int schema_search_bytree(struct ldb_module *module, const struct ldb_dn *
static int schema_add_record(struct ldb_module *module, const struct ldb_message *msg)
{
struct schema_structures *entry_structs;
- char *error_string;
unsigned int i;
int ret;
@@ -338,13 +334,9 @@ static int schema_add_record(struct ldb_module *module, const struct ldb_message
entry_structs->required_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- error_string = talloc_asprintf(module,
- "The required_attrs attribute %s is missing.\n",
- entry_structs->required_attrs.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "The required_attrs attribute %s is missing.\n",
+ entry_structs->required_attrs.attr[i].name);
talloc_free(entry_structs);
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
@@ -363,13 +355,9 @@ static int schema_add_record(struct ldb_module *module, const struct ldb_message
entry_structs->entry_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- error_string = talloc_asprintf(module,
- "The attribute %s is not referenced by any objectclass.\n",
- entry_structs->entry_attrs.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "The attribute %s is not referenced by any objectclass.\n",
+ entry_structs->entry_attrs.attr[i].name);
talloc_free(entry_structs);
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
@@ -385,7 +373,6 @@ static int schema_add_record(struct ldb_module *module, const struct ldb_message
static int schema_modify_record(struct ldb_module *module, const struct ldb_message *msg)
{
struct schema_structures *entry_structs;
- char *error_string;
unsigned int i;
int ret;
@@ -437,13 +424,9 @@ static int schema_modify_record(struct ldb_module *module, const struct ldb_mess
entry_structs->required_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- error_string = talloc_asprintf(module,
- "The required_attrs attribute %s is missing.\n",
- entry_structs->required_attrs.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "The required_attrs attribute %s is missing.\n",
+ entry_structs->required_attrs.attr[i].name);
talloc_free(entry_structs);
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
@@ -451,14 +434,9 @@ static int schema_modify_record(struct ldb_module *module, const struct ldb_mess
/* check we are not trying to delete a required attribute */
/* TODO: consider multivalued attrs */
if ((attr->flags & SCHEMA_FLAG_MOD_DELETE) != 0) {
- error_string = talloc_asprintf(module,
- "Trying to delete the required attribute %s.\n",
- attr->name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
-
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "Trying to delete the required attribute %s.\n",
+ attr->name);
talloc_free(entry_structs);
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
@@ -477,14 +455,9 @@ static int schema_modify_record(struct ldb_module *module, const struct ldb_mess
entry_structs->entry_attrs.attr[i].name);
if (attr == NULL) { /* not found */
- error_string = talloc_asprintf(module,
- "The attribute %s is not referenced by any objectclass.\n",
- entry_structs->entry_attrs.attr[i].name);
- if (error_string) {
- ldb_set_errstring(module, error_string);
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, error_string);
- }
-
+ ldb_debug_set(module->ldb, LDB_DEBUG_ERROR,
+ "The attribute %s is not referenced by any objectclass.\n",
+ entry_structs->entry_attrs.attr[i].name);
talloc_free(entry_structs);
return LDB_ERR_OBJECT_CLASS_VIOLATION;
}
diff --git a/source4/lib/ldb/modules/timestamps.c b/source4/lib/ldb/modules/timestamps.c
index 13e9c2ccc4..8451da2445 100644
--- a/source4/lib/ldb/modules/timestamps.c
+++ b/source4/lib/ldb/modules/timestamps.c
@@ -58,7 +58,7 @@ static int add_time_element(struct ldb_module *module, struct ldb_message *msg,
}
}
- if (ldb_msg_add_string(module->ldb, msg, attr_name, time_string) != 0) {
+ if (ldb_msg_add_string(msg, attr_name, time_string) != 0) {
return -1;
}
diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c
index 08ce99d20f..cda912c9b2 100644
--- a/source4/lib/ldb/tools/ldbtest.c
+++ b/source4/lib/ldb/tools/ldbtest.c
@@ -86,43 +86,43 @@ static void add_records(struct ldb_context *ldb,
el[0].name = talloc_strdup(tmp_ctx, "cn");
el[0].num_values = 1;
el[0].values = vals[0];
- vals[0][0].data = name;
+ vals[0][0].data = (uint8_t *)name;
vals[0][0].length = strlen(name);
el[1].flags = 0;
- el[1].name = talloc_strdup(tmp_ctx, "title");
+ el[1].name = "title";
el[1].num_values = 1;
el[1].values = vals[1];
- vals[1][0].data = talloc_asprintf(tmp_ctx, "The title of %s", name);
- vals[1][0].length = strlen(vals[1][0].data);
+ vals[1][0].data = (uint8_t *)talloc_asprintf(tmp_ctx, "The title of %s", name);
+ vals[1][0].length = strlen((char *)vals[1][0].data);
el[2].flags = 0;
el[2].name = talloc_strdup(tmp_ctx, "uid");
el[2].num_values = 1;
el[2].values = vals[2];
- vals[2][0].data = ldb_casefold(tmp_ctx, name);
- vals[2][0].length = strlen(vals[2][0].data);
+ vals[2][0].data = (uint8_t *)ldb_casefold(tmp_ctx, name);
+ vals[2][0].length = strlen((char *)vals[2][0].data);
el[3].flags = 0;
el[3].name = talloc_strdup(tmp_ctx, "mail");
el[3].num_values = 1;
el[3].values = vals[3];
- vals[3][0].data = talloc_asprintf(tmp_ctx, "%s@example.com", name);
- vals[3][0].length = strlen(vals[3][0].data);
+ vals[3][0].data = (uint8_t *)talloc_asprintf(tmp_ctx, "%s@example.com", name);
+ vals[3][0].length = strlen((char *)vals[3][0].data);
el[4].flags = 0;
el[4].name = talloc_strdup(tmp_ctx, "objectClass");
el[4].num_values = 1;
el[4].values = vals[4];
- vals[4][0].data = talloc_strdup(tmp_ctx, "OpenLDAPperson");
- vals[4][0].length = strlen(vals[4][0].data);
+ vals[4][0].data = (uint8_t *)talloc_strdup(tmp_ctx, "OpenLDAPperson");
+ vals[4][0].length = strlen((char *)vals[4][0].data);
el[5].flags = 0;
el[5].name = talloc_strdup(tmp_ctx, "sn");
el[5].num_values = 1;
el[5].values = vals[5];
- vals[5][0].data = name;
- vals[5][0].length = strlen(vals[5][0].data);
+ vals[5][0].data = (uint8_t *)name;
+ vals[5][0].length = strlen((char *)vals[5][0].data);
ldb_delete(ldb, msg.dn);
@@ -172,15 +172,15 @@ static void modify_records(struct ldb_context *ldb,
el[1].name = talloc_strdup(tmp_ctx, "mail");
el[1].num_values = 1;
el[1].values = &vals[1];
- vals[1].data = talloc_asprintf(tmp_ctx, "%s@other.example.com", name);
- vals[1].length = strlen(vals[1].data);
+ vals[1].data = (uint8_t *)talloc_asprintf(tmp_ctx, "%s@other.example.com", name);
+ vals[1].length = strlen((char *)vals[1].data);
el[2].flags = LDB_FLAG_MOD_REPLACE;
el[2].name = talloc_strdup(tmp_ctx, "mail");
el[2].num_values = 1;
el[2].values = &vals[2];
- vals[2].data = talloc_asprintf(tmp_ctx, "%s@other2.example.com", name);
- vals[2].length = strlen(vals[2].data);
+ vals[2].data = (uint8_t *)talloc_asprintf(tmp_ctx, "%s@other2.example.com", name);
+ vals[2].length = strlen((char *)vals[2].data);
if (ldb_modify(ldb, &msg) != 0) {
printf("Modify of %s failed - %s\n", name, ldb_errstring(ldb));
@@ -314,7 +314,7 @@ static void start_test_index(struct ldb_context **ldb)
msg = ldb_msg_new(NULL);
msg->dn = indexlist;
- ldb_msg_add_string(*ldb, msg, "@IDXATTR", strdup("uid"));
+ ldb_msg_add_string(msg, "@IDXATTR", strdup("uid"));
if (ldb_add(*ldb, msg) != 0) {
printf("Add of %s failed - %s\n", ldb_dn_linearize(*ldb, msg->dn), ldb_errstring(*ldb));
@@ -325,10 +325,10 @@ static void start_test_index(struct ldb_context **ldb)
memset(msg, 0, sizeof(*msg));
msg->dn = ldb_dn_build_child(msg, "cn", "test", basedn);
- ldb_msg_add_string(*ldb, msg, "cn", strdup("test"));
- ldb_msg_add_string(*ldb, msg, "sn", strdup("test"));
- ldb_msg_add_string(*ldb, msg, "uid", strdup("test"));
- ldb_msg_add_string(*ldb, msg, "objectClass", strdup("OpenLDAPperson"));
+ ldb_msg_add_string(msg, "cn", strdup("test"));
+ ldb_msg_add_string(msg, "sn", strdup("test"));
+ ldb_msg_add_string(msg, "uid", strdup("test"));
+ ldb_msg_add_string(msg, "objectClass", strdup("OpenLDAPperson"));
if (ldb_add(*ldb, msg) != 0) {
printf("Add of %s failed - %s\n", ldb_dn_linearize(*ldb, msg->dn), ldb_errstring(*ldb));
diff --git a/source4/lib/ldb/tools/oLschema2ldif.c b/source4/lib/ldb/tools/oLschema2ldif.c
index 4e1607f314..0fcd531987 100644
--- a/source4/lib/ldb/tools/oLschema2ldif.c
+++ b/source4/lib/ldb/tools/oLschema2ldif.c
@@ -123,7 +123,7 @@ static char *skip_spaces(char *string) {
return (string + strspn(string, " \t\n"));
}
-static int add_multi_string(struct ldb_context *ldb, struct ldb_message *msg, const char *attr, char *values)
+static int add_multi_string(struct ldb_message *msg, const char *attr, char *values)
{
char *c;
char *s;
@@ -133,7 +133,7 @@ static int add_multi_string(struct ldb_context *ldb, struct ldb_message *msg, co
while (*c) {
n = strcspn(c, " \t$");
s = talloc_strndup(msg, c, n);
- if (ldb_msg_add_string(ldb, msg, attr, s) != 0) {
+ if (ldb_msg_add_string(msg, attr, s) != 0) {
return -1;
}
c += n;
@@ -143,8 +143,8 @@ static int add_multi_string(struct ldb_context *ldb, struct ldb_message *msg, co
return 0;
}
-#define MSG_ADD_STRING(a, v) do { if (ldb_msg_add_string(ldb_ctx, msg, a, v) != 0) goto failed; } while(0)
-#define MSG_ADD_M_STRING(a, v) do { if (add_multi_string(ldb_ctx, msg, a, v) != 0) goto failed; } while(0)
+#define MSG_ADD_STRING(a, v) do { if (ldb_msg_add_string(msg, a, v) != 0) goto failed; } while(0)
+#define MSG_ADD_M_STRING(a, v) do { if (add_multi_string(msg, a, v) != 0) goto failed; } while(0)
static char *get_def_value(TALLOC_CTX *ctx, char **string)
{
@@ -373,7 +373,7 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, const char *entry)
ctx = talloc_new(mem_ctx);
msg = ldb_msg_new(ctx);
- ldb_msg_add_string(ldb_ctx, msg, "objectClass", "top");
+ ldb_msg_add_string(msg, "objectClass", "top");
c = talloc_strdup(ctx, entry);
if (!c) return NULL;
@@ -488,7 +488,7 @@ failed:
return NULL;
}
-static const struct schema_conv process_file(FILE *in, FILE *out)
+static struct schema_conv process_file(FILE *in, FILE *out)
{
TALLOC_CTX *ctx;
struct schema_conv ret;
diff --git a/source4/lib/registry/reg_backend_ldb.c b/source4/lib/registry/reg_backend_ldb.c
index 469961dfb4..108dd01a6b 100644
--- a/source4/lib/registry/reg_backend_ldb.c
+++ b/source4/lib/registry/reg_backend_ldb.c
@@ -70,25 +70,25 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, TALLOC_CT
struct ldb_message *msg = talloc_zero(mem_ctx, struct ldb_message);
char *type_s;
- ldb_msg_add_string(ctx, msg, "value", talloc_strdup(mem_ctx, name));
+ ldb_msg_add_string(msg, "value", talloc_strdup(mem_ctx, name));
switch (type) {
case REG_SZ:
case REG_EXPAND_SZ:
val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8, (void *)data.data, data.length, (void **)&val.data);
- ldb_msg_add_value(ctx, msg, "data", &val);
+ ldb_msg_add_value(msg, "data", &val);
break;
case REG_DWORD:
- ldb_msg_add_string(ctx, msg, "data", talloc_asprintf(mem_ctx, "0x%x", IVAL(data.data, 0)));
+ ldb_msg_add_string(msg, "data", talloc_asprintf(mem_ctx, "0x%x", IVAL(data.data, 0)));
break;
default:
- ldb_msg_add_value(ctx, msg, "data", &data);
+ ldb_msg_add_value(msg, "data", &data);
}
type_s = talloc_asprintf(mem_ctx, "%u", type);
- ldb_msg_add_string(ctx, msg, "type", type_s);
+ ldb_msg_add_string(msg, "type", type_s);
return msg;
}
@@ -276,7 +276,7 @@ static WERROR ldb_add_key (TALLOC_CTX *mem_ctx, const struct registry_key *paren
msg->dn = reg_path_to_ldb(msg, parent, name, NULL);
- ldb_msg_add_string(ctx, msg, "key", talloc_strdup(mem_ctx, name));
+ ldb_msg_add_string(msg, "key", talloc_strdup(mem_ctx, name));
ret = ldb_add(ctx, msg);
if (ret < 0) {
diff --git a/source4/libcli/ldap/ldap.c b/source4/libcli/ldap/ldap.c
index 815d543038..043faabf2f 100644
--- a/source4/libcli/ldap/ldap.c
+++ b/source4/libcli/ldap/ldap.c
@@ -79,7 +79,7 @@ static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
i = 0;
if ( ! tree->u.substring.start_with_wildcard) {
asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(0));
- asn1_write_LDAPString(data, tree->u.substring.chunks[i]->data);
+ asn1_write_LDAPString(data, (char *)tree->u.substring.chunks[i]->data);
asn1_pop_tag(data);
i++;
}
@@ -93,7 +93,7 @@ static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
ctx = 1;
}
asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(ctx));
- asn1_write_LDAPString(data, tree->u.substring.chunks[i]->data);
+ asn1_write_LDAPString(data, (char *)tree->u.substring.chunks[i]->data);
asn1_pop_tag(data);
i++;
}
@@ -159,7 +159,7 @@ static BOOL ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree
asn1_pop_tag(data);
}
asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(3));
- asn1_write_LDAPString(data, tree->u.extended.value.data);
+ asn1_write_LDAPString(data, (char *)tree->u.extended.value.data);
asn1_pop_tag(data);
asn1_push_tag(data, ASN1_CONTEXT_SIMPLE(4));
asn1_write_uint8(data, tree->u.extended.dnAttributes);
@@ -517,7 +517,7 @@ static struct ldb_val **ldap_decode_substring(TALLOC_CTX *mem_ctx, struct ldb_va
return NULL;
}
- chunks[chunk_num]->data = talloc_strdup(mem_ctx, value);
+ chunks[chunk_num]->data = (uint8_t *)talloc_strdup(mem_ctx, value);
if (chunks[chunk_num]->data == NULL) {
return NULL;
}
@@ -631,8 +631,7 @@ static struct ldb_parse_tree *ldap_decode_filter_tree(TALLOC_CTX *mem_ctx,
}
ret->operation = LDB_OP_SUBSTRING;
- ret->u.substring.attr = talloc_memdup(ret, attr.data, attr.length + 1);
- ret->u.substring.attr[attr.length] = '\0';
+ ret->u.substring.attr = talloc_strndup(ret, (char *)attr.data, attr.length);
ret->u.substring.chunks = NULL;
ret->u.substring.start_with_wildcard = 1;
ret->u.substring.end_with_wildcard = 1;
diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c
index c71fe0c53e..e3ed325d92 100644
--- a/source4/libnet/libnet_join.c
+++ b/source4/libnet/libnet_join.c
@@ -109,19 +109,19 @@ static NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
return NT_STATUS_NO_MEMORY;
}
- rtn = ldb_msg_add_string(remote_ldb, msg, "objectClass", "server");
+ rtn = ldb_msg_add_string(msg, "objectClass", "server");
if (rtn != 0) {
libnet_r->out.error_string = NULL;
talloc_free(tmp_ctx);
return NT_STATUS_NO_MEMORY;
}
- rtn = ldb_msg_add_string(remote_ldb, msg, "systemFlags", "50000000");
+ rtn = ldb_msg_add_string(msg, "systemFlags", "50000000");
if (rtn != 0) {
libnet_r->out.error_string = NULL;
talloc_free(tmp_ctx);
return NT_STATUS_NO_MEMORY;
}
- rtn = ldb_msg_add_string(remote_ldb, msg, "serverReference",libnet_r->out.account_dn_str);
+ rtn = ldb_msg_add_string(msg, "serverReference",libnet_r->out.account_dn_str);
if (rtn != 0) {
libnet_r->out.error_string = NULL;
talloc_free(tmp_ctx);
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index cd6f262eb6..ea56fece1d 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -41,9 +41,9 @@ static BOOL winsdb_save_version(struct wins_server *winssrv)
msg->dn = ldb_dn_explode(msg, "CN=VERSION");
if (msg->dn == NULL) goto failed;
- ret |= ldb_msg_add_string(ldb, msg, "objectClass", "winsEntry");
- ret |= ldb_msg_add_fmt(ldb, msg, "minVersion", "%llu", winssrv->min_version);
- ret |= ldb_msg_add_fmt(ldb, msg, "maxVersion", "%llu", winssrv->max_version);
+ ret |= ldb_msg_add_string(msg, "objectClass", "winsEntry");
+ ret |= ldb_msg_add_fmt(msg, "minVersion", "%llu", winssrv->min_version);
+ ret |= ldb_msg_add_fmt(msg, "maxVersion", "%llu", winssrv->max_version);
if (ret != 0) goto failed;
for (i=0;i<msg->num_elements;i++) {
@@ -177,21 +177,20 @@ static struct ldb_message *winsdb_message(struct wins_server *winssrv,
struct winsdb_record *rec, TALLOC_CTX *mem_ctx)
{
int i, ret=0;
- struct ldb_context *ldb = winssrv->wins_db;
struct ldb_message *msg = ldb_msg_new(mem_ctx);
if (msg == NULL) goto failed;
msg->dn = winsdb_dn(msg, rec->name);
if (msg->dn == NULL) goto failed;
- ret |= ldb_msg_add_fmt(ldb, msg, "objectClass", "wins");
- ret |= ldb_msg_add_fmt(ldb, msg, "active", "%u", rec->state);
- ret |= ldb_msg_add_fmt(ldb, msg, "nbFlags", "0x%04x", rec->nb_flags);
- ret |= ldb_msg_add_string(ldb, msg, "registeredBy", rec->registered_by);
- ret |= ldb_msg_add_string(ldb, msg, "expires",
+ ret |= ldb_msg_add_fmt(msg, "objectClass", "wins");
+ ret |= ldb_msg_add_fmt(msg, "active", "%u", rec->state);
+ ret |= ldb_msg_add_fmt(msg, "nbFlags", "0x%04x", rec->nb_flags);
+ ret |= ldb_msg_add_string(msg, "registeredBy", rec->registered_by);
+ ret |= ldb_msg_add_string(msg, "expires",
ldap_timestring(msg, rec->expire_time));
- ret |= ldb_msg_add_fmt(ldb, msg, "version", "%llu", rec->version);
+ ret |= ldb_msg_add_fmt(msg, "version", "%llu", rec->version);
for (i=0;rec->addresses[i];i++) {
- ret |= ldb_msg_add_string(ldb, msg, "address", rec->addresses[i]);
+ ret |= ldb_msg_add_string(msg, "address", rec->addresses[i]);
}
if (ret != 0) goto failed;
return msg;
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c
index 34d9bb899e..d2212d5a50 100644
--- a/source4/rpc_server/lsa/dcesrv_lsa.c
+++ b/source4/rpc_server/lsa/dcesrv_lsa.c
@@ -1459,7 +1459,7 @@ static NTSTATUS lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_call,
return NT_STATUS_NO_SUCH_USER;
}
- if (ldb_msg_add_empty(state->sam_ldb, msg, "privilege", ldb_flag)) {
+ if (ldb_msg_add_empty(msg, "privilege", ldb_flag)) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c
index e85c4f20c7..57bb5c62b1 100644
--- a/source4/web_server/web_server.c
+++ b/source4/web_server/web_server.c
@@ -84,7 +84,7 @@ static void websrv_recv(struct stream_connection *conn, uint16_t flags)
b = web->input.partial;
while (!web->input.end_of_headers &&
(p=memchr(b.data, '\n', b.length))) {
- const char *line = b.data;
+ const char *line = (const char *)b.data;
*p = 0;
if (p != b.data && p[-1] == '\r') {
p[-1] = 0;