s4-ldb: allow modules to override error return values
authorAndrew Tridgell <tridge@samba.org>
Tue, 29 Dec 2009 00:40:30 +0000 (11:40 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 1 Jan 2010 21:16:55 +0000 (08:16 +1100)
The samldb module overrides the error code for some returns when
handling primaryGroupID. We need to take the error from the async
callback to allow this to work reliably

source4/lib/ldb/common/ldb_modules.c

index e49d46a987ee4d3c6c1b721a1ecd66be15ce89a6..5e9d0e6e988adc5a55e5f1028100c11afda346aa 100644 (file)
@@ -606,7 +606,7 @@ int ldb_next_request(struct ldb_module *module, struct ldb_request *request)
                 * all our modules, and leaves us one less sharp
                 * corner for module developers to cut themselves on
                 */
-               ldb_module_done(request, NULL, NULL, ret);
+               ret = ldb_module_done(request, NULL, NULL, ret);
        }
        return ret;
 }
@@ -830,7 +830,9 @@ int ldb_module_done(struct ldb_request *req,
        }
 
        req->callback(req, ares);
-       return error;
+       /* returning ares->error here allows the callback routines in
+          modules to override the error code */
+       return ares->error;
 }
 
 /* to be used *only* in modules init functions.