ldb: Output more error information when a connect fails
authorAndrew Bartlett <abartlet@samba.org>
Tue, 18 Oct 2011 00:30:52 +0000 (11:30 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 18 Oct 2011 02:13:34 +0000 (13:13 +1100)
lib/ldb/common/ldb_modules.c
lib/ldb/ldb_tdb/ldb_tdb.c

index 61d1901513aa7f38e6eb9b90a42c36db3b0254f5..c8a53e2a059b543cdfbffa5db2dbe30adfe7ba21 100644 (file)
@@ -218,7 +218,7 @@ int ldb_module_connect_backend(struct ldb_context *ldb,
 
        if (ret != LDB_SUCCESS) {
                ldb_debug(ldb, LDB_DEBUG_ERROR,
-                         "Failed to connect to '%s' with backend '%s'", url, be->ops->name);
+                         "Failed to connect to '%s' with backend '%s': %s", url, be->ops->name, ldb_errstring(ret));
                return ret;
        }
        return ret;
index 3630a185942b1c08ff12b18e6d97923d5f553e6e..a85e41d987e8ca0ad1a4b796aeb80e098e444aa8 100644 (file)
@@ -1499,6 +1499,8 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
                                   tdb_flags, open_flags,
                                   ldb_get_create_perms(ldb), ldb);
        if (!ltdb->tdb) {
+               ldb_asprintf_errstring(ldb,
+                                      "Unable to open tdb '%s'", path);
                ldb_debug(ldb, LDB_DEBUG_ERROR,
                          "Unable to open tdb '%s'", path);
                talloc_free(ltdb);
@@ -1513,6 +1515,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
 
        module = ldb_module_new(ldb, ldb, "ldb_tdb backend", &ltdb_ops);
        if (!module) {
+               ldb_oom(ldb);
                talloc_free(ltdb);
                return LDB_ERR_OPERATIONS_ERROR;
        }
@@ -1520,6 +1523,8 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
        talloc_steal(module, ltdb);
 
        if (ltdb_cache_load(module) != 0) {
+               ldb_asprintf_errstring(ldb,
+                                      "Unable to load ltdb cache records of tdb '%s'", path);
                talloc_free(module);
                return LDB_ERR_OPERATIONS_ERROR;
        }