summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/common/ldb.c18
-rw-r--r--source4/lib/ldb/common/ldb_debug.c2
-rw-r--r--source4/lib/ldb/include/ldb.h2
-rw-r--r--source4/lib/ldb/include/ldb_private.h2
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c26
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c10
-rw-r--r--source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c18
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c12
-rw-r--r--source4/lib/ldb/modules/ldb_map.c2
-rw-r--r--source4/lib/ldb/modules/objectclass.c2
10 files changed, 52 insertions, 42 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 68722cde96..87705a855a 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -106,12 +106,12 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co
return LDB_SUCCESS;
}
-void ldb_set_errstring(struct ldb_module *module, char *err_string)
+void ldb_set_errstring(struct ldb_context *ldb, char *err_string)
{
- if (module->ldb->err_string) {
- talloc_free(module->ldb->err_string);
+ if (ldb->err_string) {
+ talloc_free(ldb->err_string);
}
- module->ldb->err_string = talloc_steal(module->ldb, err_string);
+ ldb->err_string = talloc_steal(ldb, err_string);
}
void ldb_reset_err_string(struct ldb_context *ldb)
@@ -158,7 +158,7 @@ int ldb_transaction_start(struct ldb_context *ldb)
if (status != LDB_SUCCESS) {
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb->modules,
+ ldb_set_errstring(ldb,
talloc_asprintf(ldb, "ldb transaction start error %d", status));
}
}
@@ -186,7 +186,7 @@ int ldb_transaction_commit(struct ldb_context *ldb)
if (status != LDB_SUCCESS) {
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb->modules,
+ ldb_set_errstring(ldb,
talloc_asprintf(ldb, "ldb transaction commit error %d", status));
}
}
@@ -212,7 +212,7 @@ int ldb_transaction_cancel(struct ldb_context *ldb)
if (status != LDB_SUCCESS) {
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb->modules,
+ ldb_set_errstring(ldb,
talloc_asprintf(ldb, "ldb transaction cancel error %d", status));
}
}
@@ -238,7 +238,7 @@ static int ldb_op_finish(struct ldb_context *ldb, int status)
}
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb->modules,
+ ldb_set_errstring(ldb,
talloc_asprintf(ldb, "ldb error %d", status));
}
ldb_transaction_cancel(ldb);
@@ -330,7 +330,7 @@ int ldb_search(struct ldb_context *ldb,
tree = ldb_parse_tree(ldb, expression);
if (tree == NULL) {
- ldb_set_errstring(ldb->modules, talloc_strdup(ldb, "Unable to parse search expression"));
+ ldb_set_errstring(ldb, talloc_strdup(ldb, "Unable to parse search expression"));
return -1;
}
diff --git a/source4/lib/ldb/common/ldb_debug.c b/source4/lib/ldb/common/ldb_debug.c
index 21b02956b8..c4718c7f52 100644
--- a/source4/lib/ldb/common/ldb_debug.c
+++ b/source4/lib/ldb/common/ldb_debug.c
@@ -97,7 +97,7 @@ void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
msg = talloc_vasprintf(ldb, fmt, ap);
va_end(ap);
if (msg != NULL) {
- ldb_set_errstring(ldb->modules, msg);
+ ldb_set_errstring(ldb, msg);
ldb_debug(ldb, level, "%s", msg);
}
}
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 4a40e34363..8a9e8bea76 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -577,10 +577,12 @@ enum ldb_reply_type {
enum ldb_async_wait_type {
LDB_WAIT_ALL,
+ LDB_WAIT_ONCE,
LDB_WAIT_NONE
};
enum ldb_async_state {
+ LDB_ASYNC_INIT,
LDB_ASYNC_PENDING,
LDB_ASYNC_DONE
};
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index db34b58858..24967faeea 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -133,7 +133,7 @@ int ldb_next_end_trans(struct ldb_module *module);
int ldb_next_del_trans(struct ldb_module *module);
int ldb_next_second_stage_init(struct ldb_module *module);
-void ldb_set_errstring(struct ldb_module *module, char *err_string);
+void ldb_set_errstring(struct ldb_context *ldb, char *err_string);
void ldb_reset_err_string(struct ldb_context *ldb);
/* The following definitions come from lib/ldb/common/ldb_debug.c */
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index 33d3954a73..de32c10ba4 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -230,7 +230,7 @@ static void ildb_async_callback(struct ldap_request *req)
}
if (msg->r.SearchResultDone.resultcode) {
if (msg->r.SearchResultDone.errormessage) {
- ldb_set_errstring(ac->module, talloc_strdup(ac->module, msg->r.SearchResultDone.errormessage));
+ ldb_set_errstring(ac->module->ldb, talloc_strdup(ac->module, msg->r.SearchResultDone.errormessage));
}
}
@@ -309,13 +309,13 @@ static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg
h = talloc_zero(ildb->ldap, struct ldb_async_handle);
if (h == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return LDB_ERR_OPERATIONS_ERROR;
}
ildb_ac = talloc(h, struct ildb_async_context);
if (ildb_ac == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -324,7 +324,7 @@ static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg
req = ldap_request_send(ildb->ldap, msg);
if (req == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "async send request failed"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "async send request failed"));
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -369,18 +369,18 @@ static int ildb_search_async(struct ldb_module *module, const struct ldb_dn *bas
*handle = NULL;
if (!callback || !context) {
- ldb_set_errstring(module, talloc_asprintf(module, "Async interface called with NULL callback function or NULL context"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Async interface called with NULL callback function or NULL context"));
return LDB_ERR_OPERATIONS_ERROR;
}
if (tree == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "Invalid expression parse tree"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Invalid expression parse tree"));
return LDB_ERR_OPERATIONS_ERROR;
}
msg = new_ldap_message(ildb);
if (msg == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -397,7 +397,7 @@ static int ildb_search_async(struct ldb_module *module, const struct ldb_dn *bas
msg->r.SearchRequest.basedn = ldb_dn_linearize(msg, base);
}
if (msg->r.SearchRequest.basedn == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "Unable to determine baseDN"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Unable to determine baseDN"));
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -434,7 +434,7 @@ static int ildb_search_sync_callback(struct ldb_context *ldb, void *context, str
int n;
if (!context) {
- ldb_set_errstring(ldb->modules, talloc_asprintf(ldb, "NULL Context in callback"));
+ ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context in callback"));
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -923,6 +923,14 @@ static int ildb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_
return LDB_ERR_OTHER;
}
break;
+ case LDB_WAIT_ONCE:
+ handle->state = LDB_ASYNC_INIT;
+ while (handle->status == LDB_SUCCESS && handle->state == LDB_ASYNC_INIT) {
+ if (event_loop_once(ac->req->conn->event.event_ctx) != 0) {
+ return LDB_ERR_OTHER;
+ }
+ }
+ break;
case LDB_WAIT_ALL:
while (handle->status == LDB_SUCCESS && handle->state != LDB_ASYNC_DONE) {
if (event_loop_once(ac->req->conn->event.event_ctx) != 0) {
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index 7233498eb3..c27ded7767 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -78,7 +78,7 @@ static int lldb_rename(struct ldb_module *module, const struct ldb_dn *olddn, co
lldb->last_rc = ldap_rename_s(lldb->ldap, old_dn, newrdn, parentdn, 1, NULL, NULL);
if (lldb->last_rc != LDAP_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
ret = -1;
}
@@ -108,7 +108,7 @@ static int lldb_delete(struct ldb_module *module, const struct ldb_dn *edn)
lldb->last_rc = ldap_delete_s(lldb->ldap, dn);
if (lldb->last_rc != LDAP_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
ret = -1;
}
@@ -226,7 +226,7 @@ static int lldb_search_bytree(struct ldb_module *module, const struct ldb_dn *ba
0, &ldapres);
talloc_free(search_base);
if (lldb->last_rc != LDAP_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
return lldb->last_rc;
}
@@ -412,7 +412,7 @@ static int lldb_add(struct ldb_module *module, const struct ldb_message *msg)
lldb->last_rc = ldap_add_s(lldb->ldap, dn, mods);
if (lldb->last_rc != LDAP_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
ret = -1;
}
@@ -451,7 +451,7 @@ static int lldb_modify(struct ldb_module *module, const struct ldb_message *msg)
lldb->last_rc = ldap_modify_s(lldb->ldap, dn, mods);
if (lldb->last_rc != LDAP_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
ret = -1;
}
diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
index 48d849746f..aedba4e895 100644
--- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
+++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
@@ -943,7 +943,7 @@ static int lsqlite3_search_bytree(struct ldb_module * module, const struct ldb_d
ret = sqlite3_exec(lsqlite3->sqlite, query, lsqlite3_search_callback, &msgs, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1039,7 +1039,7 @@ static int lsqlite3_add(struct ldb_module *module, const struct ldb_message *msg
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1094,7 +1094,7 @@ static int lsqlite3_add(struct ldb_module *module, const struct ldb_message *msg
ret = sqlite3_exec(lsqlite3->sqlite, insert, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1184,7 +1184,7 @@ static int lsqlite3_modify(struct ldb_module *module, const struct ldb_message *
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1222,7 +1222,7 @@ static int lsqlite3_modify(struct ldb_module *module, const struct ldb_message *
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1248,7 +1248,7 @@ static int lsqlite3_modify(struct ldb_module *module, const struct ldb_message *
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1282,7 +1282,7 @@ static int lsqlite3_modify(struct ldb_module *module, const struct ldb_message *
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1343,7 +1343,7 @@ static int lsqlite3_delete(struct ldb_module *module, const struct ldb_dn *dn)
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
@@ -1402,7 +1402,7 @@ static int lsqlite3_rename(struct ldb_module *module, const struct ldb_dn *olddn
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 1be11bc64c..8d8c01278d 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -142,7 +142,7 @@ int ltdb_check_special_dn(struct ldb_module *module, const struct ldb_message *m
if (ltdb_check_at_attributes_values(&msg->elements[i].values[j]) != 0) {
char *err_string = talloc_strdup(module, "Invalid attribute value in an @ATTRIBUTES entry");
if (err_string) {
- ldb_set_errstring(module, err_string);
+ ldb_set_errstring(module->ldb, err_string);
}
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
@@ -532,7 +532,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
for (j=0;j<el->num_values;j++) {
if (ldb_msg_find_val(el2, &el->values[j])) {
err_string = talloc_strdup(module, "Type or value exists");
- if (err_string) ldb_set_errstring(module, err_string);
+ if (err_string) ldb_set_errstring(module->ldb, err_string);
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto failed;
}
@@ -577,7 +577,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
if (msg_delete_attribute(module, ldb, msg2,
msg->elements[i].name) != 0) {
err_string = talloc_asprintf(module, "No such attribute: %s", msg->elements[i].name);
- if (err_string) ldb_set_errstring(module, err_string);
+ if (err_string) ldb_set_errstring(module->ldb, err_string);
ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
@@ -589,7 +589,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
msg->elements[i].name,
&msg->elements[i].values[j]) != 0) {
err_string = talloc_asprintf(module, "No such attribute: %s", msg->elements[i].name);
- if (err_string) ldb_set_errstring(module, err_string);
+ if (err_string) ldb_set_errstring(module->ldb, err_string);
ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
@@ -602,7 +602,7 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
err_string = talloc_asprintf(module, "Invalid ldb_modify flags on %s: 0x%x",
msg->elements[i].name,
msg->elements[i].flags & LDB_FLAG_MOD_MASK);
- if (err_string) ldb_set_errstring(module, err_string);
+ if (err_string) ldb_set_errstring(module->ldb, err_string);
ret = LDB_ERR_PROTOCOL_ERROR;
goto failed;
}
@@ -690,7 +690,7 @@ static int ltdb_rename(struct ldb_module *module, const struct ldb_dn *olddn, co
ltdb_delete(module, newdn);
}
- ldb_set_errstring(module, error_str);
+ ldb_set_errstring(module->ldb, error_str);
talloc_free(msg);
diff --git a/source4/lib/ldb/modules/ldb_map.c b/source4/lib/ldb/modules/ldb_map.c
index 4c2ef5b239..f313a6e564 100644
--- a/source4/lib/ldb/modules/ldb_map.c
+++ b/source4/lib/ldb/modules/ldb_map.c
@@ -827,7 +827,7 @@ static int map_search_mp(struct ldb_module *module, struct ldb_request *req)
talloc_free(newattrs);
if (mpret != LDB_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldb_errstring(privdat->mapped_ldb)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldb_errstring(privdat->mapped_ldb)));
return mpret;
}
diff --git a/source4/lib/ldb/modules/objectclass.c b/source4/lib/ldb/modules/objectclass.c
index 479d943a91..8b4ad598cc 100644
--- a/source4/lib/ldb/modules/objectclass.c
+++ b/source4/lib/ldb/modules/objectclass.c
@@ -115,7 +115,7 @@ static int objectclass_handle(struct ldb_module *module, struct ldb_request *req
res = search_request->op.search.res;
talloc_steal(mem_ctx, res);
if (res->count != 1) {
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "objectClass_handle: "
"search for %s found %d != 1 objects, for entry we just added/modified",
ldb_dn_linearize(mem_ctx, msg->dn),