s4:repl_meta_data LDB module - always return the original LDB result codes on failure
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Fri, 14 Oct 2011 07:27:56 +0000 (09:27 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Thu, 27 Oct 2011 16:52:29 +0000 (18:52 +0200)
And add "ldb_operr()" before the "return ret" to point out the position
where it failed (for "add_time_element" and "add_uint64_element")

Reworked after a suggestion by abartlet.

source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 090e28fdf549db75dfca9b6ee803adea7e15f276..46094f5f0de45c9b83197ea92db9fbb355bad2ad 100644 (file)
@@ -2362,12 +2362,14 @@ static int replmd_modify(struct ldb_module *module, struct ldb_request *req)
                ret = add_time_element(msg, "whenChanged", t);
                if (ret != LDB_SUCCESS) {
                        talloc_free(ac);
+                       ldb_operr(ldb);
                        return ret;
                }
 
                ret = add_uint64_element(ldb, msg, "uSNChanged", ac->seq_num);
                if (ret != LDB_SUCCESS) {
                        talloc_free(ac);
+                       ldb_operr(ldb);
                        return ret;
                }
        }
@@ -2609,12 +2611,14 @@ static int replmd_rename_callback(struct ldb_request *req, struct ldb_reply *are
        ret = add_time_element(msg, "whenChanged", t);
        if (ret != LDB_SUCCESS) {
                talloc_free(ac);
+               ldb_operr(ldb);
                return ret;
        }
 
        ret = add_uint64_element(ldb, msg, "uSNChanged", ac->seq_num);
        if (ret != LDB_SUCCESS) {
                talloc_free(ac);
+               ldb_operr(ldb);
                return ret;
        }
 
@@ -4725,15 +4729,18 @@ linked_attributes[0]:
 
        /* we only change whenChanged and uSNChanged if the seq_num
           has changed */
-       if (add_time_element(msg, "whenChanged", t) != LDB_SUCCESS) {
+       ret = add_time_element(msg, "whenChanged", t);
+       if (ret != LDB_SUCCESS) {
                talloc_free(tmp_ctx);
-               return ldb_operr(ldb);
+               ldb_operr(ldb);
+               return ret;
        }
 
-       if (add_uint64_element(ldb, msg, "uSNChanged",
-                              seq_num) != LDB_SUCCESS) {
+       ret = add_uint64_element(ldb, msg, "uSNChanged", seq_num);
+       if (ret != LDB_SUCCESS) {
                talloc_free(tmp_ctx);
-               return ldb_operr(ldb);
+               ldb_operr(ldb);
+               return ret;
        }
 
        old_el = ldb_msg_find_element(msg, attr->lDAPDisplayName);