From 2b9b232912a6e561e0f5ba57afbd605dc4197d97 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Sat, 3 Oct 2009 00:06:41 +0200 Subject: Revert "s4:LDB/LDAP - Re-allow renames" This reverts commit 767fce6fccf484b547219abd5e6abc941eacaf92. Simo pointed out that the patch generates race conditions. We need to solve this using a new control. --- source4/lib/ldb/modules/rdn_name.c | 53 +++----------------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) (limited to 'source4') diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c index 888f35561a..ccbb1ddde4 100644 --- a/source4/lib/ldb/modules/rdn_name.c +++ b/source4/lib/ldb/modules/rdn_name.c @@ -3,7 +3,6 @@ Copyright (C) Andrew Bartlett 2005-2009 Copyright (C) Simo Sorce 2006-2008 - Copyright (C) Matthias Dieter Wallnöfer 2009 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -40,11 +39,6 @@ #include "ldb_includes.h" #include "ldb_module.h" -struct rdn_name_private { - /* rename operation? */ - bool rename; -}; - struct rename_context { struct ldb_module *module; struct ldb_request *req; @@ -52,21 +46,6 @@ struct rename_context { struct ldb_reply *ares; }; -static int rdn_name_init(struct ldb_module *module) -{ - struct rdn_name_private *rdn_name_private; - struct ldb_context *ldb = ldb_module_get_ctx(module); - - rdn_name_private = talloc_zero(module, struct rdn_name_private); - if (rdn_name_private == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - ldb_module_set_private(module, rdn_name_private); - - return ldb_next_init(module); -} - static struct ldb_message_element *rdn_name_find_attribute(const struct ldb_message *msg, const char *name) { int i; @@ -135,13 +114,11 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) msg = ldb_msg_copy_shallow(req, req->op.add.message); if (msg == NULL) { - talloc_free(ac); return LDB_ERR_OPERATIONS_ERROR; } rdn_name = ldb_dn_get_rdn_name(msg->dn); if (rdn_name == NULL) { - talloc_free(ac); return LDB_ERR_OPERATIONS_ERROR; } @@ -153,7 +130,6 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) } if (ldb_msg_add_value(msg, "name", &rdn_val, NULL) != 0) { - talloc_free(ac); return LDB_ERR_OPERATIONS_ERROR; } @@ -161,7 +137,6 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) if (!attribute) { if (ldb_msg_add_value(msg, rdn_name, &rdn_val, NULL) != 0) { - talloc_free(ac); return LDB_ERR_OPERATIONS_ERROR; } } else { @@ -188,7 +163,6 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) (const char *)attribute->values[i].data); } ldb_set_errstring(ldb, rdn_errstring); - talloc_free(ac); /* Match AD's error here */ return LDB_ERR_INVALID_DN_SYNTAX; } @@ -200,7 +174,6 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) ac, rdn_name_add_callback, req); if (ret != LDB_SUCCESS) { - talloc_free(ac); return ret; } @@ -212,15 +185,9 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req) static int rdn_modify_callback(struct ldb_request *req, struct ldb_reply *ares) { - struct rdn_name_private *rdn_name_private; struct rename_context *ac; ac = talloc_get_type(req->context, struct rename_context); - rdn_name_private = talloc_get_type(ldb_module_get_private(ac->module), - struct rdn_name_private); - - /* our rename is finished */ - rdn_name_private->rename = false; if (!ares) { return ldb_module_done(ac->req, NULL, NULL, @@ -244,9 +211,8 @@ static int rdn_modify_callback(struct ldb_request *req, struct ldb_reply *ares) static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) { - struct rdn_name_private *rdn_name_private; - struct rename_context *ac; struct ldb_context *ldb; + struct rename_context *ac; struct ldb_request *mod_req; const char *rdn_name; struct ldb_val rdn_val; @@ -255,8 +221,6 @@ static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) ac = talloc_get_type(req->context, struct rename_context); ldb = ldb_module_get_ctx(ac->module); - rdn_name_private = talloc_get_type(ldb_module_get_private(ac->module), - struct rdn_name_private); if (!ares) { goto error; @@ -302,9 +266,6 @@ static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares) goto error; } - /* we do a rename */ - rdn_name_private->rename = true; - ret = ldb_build_mod_req(&mod_req, ldb, ac, msg, NULL, ac, rdn_modify_callback, @@ -356,8 +317,7 @@ static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req) req); if (ret != LDB_SUCCESS) { - talloc_free(ac); - return ret; + return LDB_ERR_OPERATIONS_ERROR; } /* rename first, modify "name" if rename is ok */ @@ -366,8 +326,6 @@ static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req) static int rdn_name_modify(struct ldb_module *module, struct ldb_request *req) { - struct rdn_name_private *rdn_name_private = - talloc_get_type(ldb_module_get_private(module), struct rdn_name_private); struct ldb_context *ldb; ldb = ldb_module_get_ctx(module); @@ -378,15 +336,13 @@ static int rdn_name_modify(struct ldb_module *module, struct ldb_request *req) return ldb_next_request(module, req); } - if ((!rdn_name_private->rename) - && ldb_msg_find_element(req->op.mod.message, "name")) { + if (ldb_msg_find_element(req->op.mod.message, "name")) { ldb_asprintf_errstring(ldb, "Modify of 'name' on %s not permitted, must use 'rename' operation instead", ldb_dn_get_linearized(req->op.mod.message->dn)); return LDB_ERR_NOT_ALLOWED_ON_RDN; } - if ((!rdn_name_private->rename) - && ldb_msg_find_element(req->op.mod.message, ldb_dn_get_rdn_name(req->op.mod.message->dn))) { + if (ldb_msg_find_element(req->op.mod.message, ldb_dn_get_rdn_name(req->op.mod.message->dn))) { ldb_asprintf_errstring(ldb, "Modify of RDN '%s' on %s not permitted, must use 'rename' operation instead", ldb_dn_get_rdn_name(req->op.mod.message->dn), ldb_dn_get_linearized(req->op.mod.message->dn)); return LDB_ERR_NOT_ALLOWED_ON_RDN; @@ -398,7 +354,6 @@ static int rdn_name_modify(struct ldb_module *module, struct ldb_request *req) const struct ldb_module_ops ldb_rdn_name_module_ops = { .name = "rdn_name", - .init_context = rdn_name_init, .add = rdn_name_add, .modify = rdn_name_modify, .rename = rdn_name_rename -- cgit