From f80d21069b7e22fbe8abdd59e7acb748f0a6b1ce Mon Sep 17 00:00:00 2001
From: Andrew Bartlett <abartlet@samba.org>
Date: Thu, 8 Mar 2007 03:32:28 +0000
Subject: r21760: Try to pin down were some errors are coming from.  Ensure we
 at least name the module.

Andrew Bartlett
(This used to be commit 2e85b1583b3da95db9b5b724b38748ff7d1f9efd)
---
 source4/lib/ldb/common/ldb_modules.c | 33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

(limited to 'source4/lib')

diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 848ad7e551..59a2713df8 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -392,32 +392,49 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
 
 int ldb_next_request(struct ldb_module *module, struct ldb_request *request)
 {
+	int ret;
 	switch (request->operation) {
 	case LDB_SEARCH:
 		FIND_OP(module, search);
-		return module->ops->search(module, request);
+		ret = module->ops->search(module, request);
+		break;
 	case LDB_ADD:
 		FIND_OP(module, add);
-		return module->ops->add(module, request);
+		ret = module->ops->add(module, request);
+		break;
 	case LDB_MODIFY:
 		FIND_OP(module, modify);
-		return module->ops->modify(module, request);
+		ret = module->ops->modify(module, request);
+		break;
 	case LDB_DELETE:
 		FIND_OP(module, del);
-		return module->ops->del(module, request);
+		ret = module->ops->del(module, request);
+		break;
 	case LDB_RENAME:
 		FIND_OP(module, rename);
-		return module->ops->rename(module, request);
+		ret = module->ops->rename(module, request);
+		break;
 	case LDB_EXTENDED:
 		FIND_OP(module, extended);
-		return module->ops->extended(module, request);
+		ret = module->ops->extended(module, request);
+		break;
 	case LDB_SEQUENCE_NUMBER:
 		FIND_OP(module, sequence_number);
-		return module->ops->sequence_number(module, request);
+		ret = module->ops->sequence_number(module, request);
+		break;
 	default:
 		FIND_OP(module, request);
-		return module->ops->request(module, request);
+		ret = module->ops->request(module, request);
+		break;
+	}
+	if (ret == LDB_SUCCESS) {
+		return ret;
 	}
+	if (!ldb_errstring(module->ldb)) {
+		/* Set a default error string, to place the blame somewhere */
+		ldb_asprintf_errstring(module->ldb, "error in module %s: %s", module->ops->name, ldb_strerror(ret));
+	}
+	return ret;
 }
 
 int ldb_next_init(struct ldb_module *module)
-- 
cgit