Author: mkhl Date: 2006-06-15 14:53:45 +0000 (Thu, 15 Jun 2006) New Revision: 16258
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16258 Log: Take Simo's feedback w.r.t. talloc_steal into account. Martin Modified: branches/SOC/mkhl/,,ldb-unspecial.c-remap-special-DNs.patch Changeset: Modified: branches/SOC/mkhl/,,ldb-unspecial.c-remap-special-DNs.patch =================================================================== --- branches/SOC/mkhl/,,ldb-unspecial.c-remap-special-DNs.patch 2006-06-15 14:31:53 UTC (rev 16257) +++ branches/SOC/mkhl/,,ldb-unspecial.c-remap-special-DNs.patch 2006-06-15 14:53:45 UTC (rev 16258) @@ -1,8 +1,8 @@ Index: modules/unspecial.c =================================================================== ---- modules/unspecial.c (Revision 0) -+++ modules/unspecial.c (Revision 0) -@@ -0,0 +1,503 @@ +--- modules/unspecial.c (revision 0) ++++ modules/unspecial.c (revision 0) +@@ -0,0 +1,508 @@ +/* + special DN remapping ldb module + @@ -193,11 +193,7 @@ + if (!ldb_dn_is_special(req->op.search.base)) + return ldb_next_request(module, req); + -+ dn = un_remap_special_dn(module, req->op.search.base); -+ if (dn == NULL) -+ return LDB_ERR_OPERATIONS_ERROR; + -+ + h = un_init_handle(req, module); + if (!h) { + talloc_free(dn); @@ -225,8 +221,14 @@ + ldb_set_timeout_from_prev_req(module->ldb, req, ac->search_req); + + /* adapt the message */ ++ dn = un_remap_special_dn(ac->search_req, req->op.search.base); ++ if (dn == NULL) { ++ talloc_free(ac->search_req); ++ return LDB_ERR_OPERATIONS_ERROR; ++ } ++ + /* Is that enough or should I copy more members explicitly? */ -+ ac->search_req->op.search.base = talloc_steal(ac->search_req, dn); ++ ac->search_req->op.search.base = dn; + + /* ac->step = UN_DO_SEARCH; */ + @@ -244,12 +246,6 @@ + if (!ldb_dn_is_special(req->op.add.message->dn)) + return ldb_next_request(module, req); + -+ msg = un_msg_copy_with_dn(module, req->op.add.message, -+ un_remap_special_dn(module, -+ req->op.add.message->dn)); -+ if (msg == NULL) -+ return LDB_ERR_OPERATIONS_ERROR; -+ + h = un_init_handle(req, module); + if (!h) { + talloc_free(msg); @@ -277,8 +273,16 @@ + ldb_set_timeout_from_prev_req(module->ldb, req, ac->down_req); + + /* adapt the message */ -+ ac->down_req->op.add.message = talloc_steal(ac->down_req, msg); ++ msg = un_msg_copy_with_dn(ac->down_req, req->op.add.message, ++ un_remap_special_dn(ac->down_req, ++ req->op.add.message->dn)); ++ if (msg == NULL) { ++ talloc_free(ac->down_req); ++ return LDB_ERR_OPERATIONS_ERROR; ++ } + ++ ac->down_req->op.add.message = msg; ++ + /* ac->step = UN_DO_REQ; */ + + return ldb_next_request(module, ac->down_req); @@ -295,13 +299,6 @@ + if (!ldb_dn_is_special(req->op.mod.message->dn)) + return ldb_next_request(module, req); + -+ msg = un_msg_copy_with_dn(module, req->op.mod.message, -+ un_remap_special_dn(module, -+ req->op.mod.message->dn)); -+ if (msg == NULL) { -+ return LDB_ERR_OPERATIONS_ERROR; -+ } -+ + h = un_init_handle(req, module); + if (!h) { + talloc_free(msg); @@ -329,8 +326,16 @@ + ldb_set_timeout_from_prev_req(module->ldb, req, ac->down_req); + + /* adapt the message */ -+ ac->down_req->op.mod.message = talloc_steal(ac->down_req, msg); ++ msg = un_msg_copy_with_dn(ac->down_req, req->op.mod.message, ++ un_remap_special_dn(ac->down_req, ++ req->op.mod.message->dn)); ++ if (msg == NULL) { ++ talloc_free(ac->down_req); ++ return LDB_ERR_OPERATIONS_ERROR; ++ } + ++ ac->down_req->op.mod.message = msg; ++ + /* ac->step = UN_DO_REQ; */ + + return ldb_next_request(module, ac->down_req);