Revert "ldb/sample_module: don't write to const memory" master4-mdw
authorStefan Metzmacher <metze@samba.org>
Wed, 11 Sep 2013 11:28:02 +0000 (13:28 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 25 Sep 2013 22:11:44 +0000 (00:11 +0200)
This reverts commit 121e51206c19df012766e9085a49c090b6e05490.

lib/ldb/tests/sample_module.c

index 09d1b6ab19a293c97e7b0e6ba6d3073f3de12b6d..bee40a5e80fc105447010631e03c981c486672af 100644 (file)
 static int sample_add(struct ldb_module *mod, struct ldb_request *req)
 {
        struct ldb_control *control;
-       struct ldb_context *ldb = ldb_module_get_ctx(mod);
-       struct ldb_message *msg;
-       struct ldb_request *down_req;
-       int ret;
+
+       ldb_msg_add_fmt(req->op.add.message, "touchedBy", "sample");
 
        /* check if there's a relax control */
        control = ldb_request_get_control(req, LDB_CONTROL_RELAX_OID);
-       if (control != NULL) {
+       if (control == NULL) {
+               /* not found go on */
+               return ldb_next_request(mod, req);
+       } else {
                return LDB_ERR_UNWILLING_TO_PERFORM;
        }
-
-       msg = ldb_msg_copy_shallow(req, req->op.add.message);
-       if (msg == NULL) {
-               return LDB_ERR_OPERATIONS_ERROR;
-       }
-
-       ldb_msg_add_fmt(msg, "touchedBy", "sample");
-
-       ret = ldb_build_add_req(&down_req, ldb, req,
-                               msg,
-                               req->controls,
-                               NULL, /* callback context */
-                               ldb_op_default_callback,
-                               req);
-       if (ret != LDB_SUCCESS) {
-               return ret;
-       }
-
-       talloc_steal(down_req, msg);
-
-       /* go on with the call chain */
-       return ldb_next_request(mod, down_req);
 }
 
 static int sample_modify(struct ldb_module *mod, struct ldb_request *req)