ldb:ldb.c/"ldb_request" - make "ldb_request" always return an error string
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Wed, 21 Sep 2011 10:35:20 +0000 (12:35 +0200)
committerAndrew Tridgell <tridge@samba.org>
Tue, 11 Oct 2011 06:42:07 +0000 (08:42 +0200)
Signed-off-by: Andrew Tridgell <tridge@samba.org>
lib/ldb/common/ldb.c

index 2dd2d1bdde8c0a9e62593536359a0f861f4ea879..0c5f40ae4b593e687765974a7a9bed93f80894e3 100644 (file)
@@ -848,11 +848,15 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
                                        discard_const(&req->op.add.message));
                if (ret != LDB_SUCCESS) {
                        ldb_oom(ldb);
-                       return LDB_ERR_OPERATIONS_ERROR;
+                       return ret;
                }
                FIRST_OP(ldb, add);
                ret = ldb_msg_check_element_flags(ldb, req->op.add.message);
                if (ret != LDB_SUCCESS) {
+                       /*
+                        * "ldb_msg_check_element_flags" generates an error
+                        * string
+                        */
                        return ret;
                }
                ret = module->ops->add(module, req);
@@ -866,6 +870,10 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
                FIRST_OP(ldb, modify);
                ret = ldb_msg_check_element_flags(ldb, req->op.mod.message);
                if (ret != LDB_SUCCESS) {
+                       /*
+                        * "ldb_msg_check_element_flags" generates an error
+                        * string
+                        */
                        return ret;
                }
                ret = module->ops->modify(module, req);
@@ -903,6 +911,12 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
                break;
        }
 
+       if ((ret != LDB_SUCCESS) && (ldb->err_string == NULL)) {
+               /* if no error string was setup by the backend */
+               ldb_asprintf_errstring(ldb, "ldb_request: %s (%d)",
+                                      ldb_strerror(ret), ret);
+       }
+
        return ret;
 }