[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Sat Jul 9 16:42:03 UTC 2016
The branch, master has been updated
via 89e67e3 Revert selftest: Add knownfail entry required to disable tombstone_reanimation
via fb9af97 Revert "dsdb: Disable tombstone_reanimation module until we isolate what causes flaky tests"
via 7ea5ec0 s4:dsdb/tests: add RestoreUserPwdObjectTestCase test
via 55932d7 s4:dsdb/tests: improve the RestoreUserObjectTestCase test
via cf19ab6 s4:dsdb/tests: improve tombstone_reanimation varifications
via 16d3660 s4:dsdb/tests: make tombstone_reanimation.py executable
via 7bfefa9 s4:dsdb/tests: make use assertAttributesEqual() in RestoreUserObjectTestCase()
via c16b30c s4:dsdb/tombstone_reanimate: restructure the module logic
via 272d647 s4:dsdb/common: prepare dsdb_user_obj_set_defaults() for tombstone reanimation
via 0350e3a s4:dsdb/repl_meta_data: remove secret attributes on delete
via 5287e40 s4:dsdb/repl_meta_data: sort preserved_attrs and add "msDS-PortLDAP"
via 73d9f8b s4:password_hash: correctly update pwdLastSet on deleted objects.
via 6d4c485 s4:dsdb/samdb: add const to dsdb_make_object_category()
via 49cd4c9 drsuapi.idl: add DRSUAPI_ATTID_operatorCount and DRSUAPI_ATTID_adminCount
from 6e4e914 selftest: Add more tests for samba-tool drs replicate
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 89e67e309a640df690d0fa0aa8c1b2f2537e47f4
Author: Andrew Bartlett <abartlet at samba.org>
Date: Mon Mar 21 17:06:00 2016 +1300
Revert selftest: Add knownfail entry required to disable tombstone_reanimation
This reverts e0fa42201b5ff1b2d67f1c3cdb0d3dbcce9b6e40
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
Autobuild-Date(master): Sat Jul 9 18:41:40 CEST 2016 on sn-devel-144
commit fb9af9727f4a9b1664c5a9e541981d239c72b0cf
Author: Andrew Bartlett <abartlet at samba.org>
Date: Mon Mar 21 17:05:19 2016 +1300
Revert "dsdb: Disable tombstone_reanimation module until we isolate what causes flaky tests"
This reverts commit 252b62c54ed5a4aabbdccf315f1a0ae3d958d11c.
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 7ea5ec0f281886bb202fcde4cde43da0c2dca62c
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 09:30:04 2016 +0200
s4:dsdb/tests: add RestoreUserPwdObjectTestCase test
This is the same as RestoreUserObjectTestCase, but we
set the password on add and reanimate.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 55932d7ecd02f29fbcba90418db574e6fe198b22
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 15:26:18 2016 +0200
s4:dsdb/tests: improve the RestoreUserObjectTestCase test
We verify attributes, values and their replication metadata after
each step (add, delete, reanimate).
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit cf19ab651a336b3eb3104baba82da625ff39ed56
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 15:24:21 2016 +0200
s4:dsdb/tests: improve tombstone_reanimation varifications
We should do case sensitive checks.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 16d36603e8ef1166e4f4ed6e5f221887430a6714
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 15:21:03 2016 +0200
s4:dsdb/tests: make tombstone_reanimation.py executable
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 7bfefa9ae229a19a6feb757b4968568558d748f3
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 06:23:53 2016 +0200
s4:dsdb/tests: make use assertAttributesEqual() in RestoreUserObjectTestCase()
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit c16b30c4113a2d6598d98e8353435e204951094c
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 14:37:54 2016 +0200
s4:dsdb/tombstone_reanimate: restructure the module logic
Now we keep all state in struct tr_context and split
the preparation and exectution of sub requests into
helper functions.
The most important change is that we now
pass mod_req to dsdb_user_obj_set_defaults(),
so that it can add controls to it.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 272d6478a2a1efcbe0eed6676f370ede544eca50
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 10:43:19 2016 +0200
s4:dsdb/common: prepare dsdb_user_obj_set_defaults() for tombstone reanimation
accountExpires gets a different value, logonHours is not updated,
operatorCount and adminCount are added.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 0350e3a42ab509130a5f48b43b1923d8738b2ad0
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 10:47:41 2016 +0200
s4:dsdb/repl_meta_data: remove secret attributes on delete
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 5287e4046d93d935609d2354eea58280c13d1e99
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 10:15:29 2016 +0200
s4:dsdb/repl_meta_data: sort preserved_attrs and add "msDS-PortLDAP"
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 73d9f8bef750c4c12dcfc3750d13ef743254b55f
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 14:52:50 2016 +0200
s4:password_hash: correctly update pwdLastSet on deleted objects.
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 6d4c4855c9901bded4963bec9be13ca8bea5b27f
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 14:38:06 2016 +0200
s4:dsdb/samdb: add const to dsdb_make_object_category()
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 49cd4c9853c3d6c8d27b79d58698991349308a0d
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 08:46:43 2016 +0200
drsuapi.idl: add DRSUAPI_ATTID_operatorCount and DRSUAPI_ATTID_adminCount
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
-----------------------------------------------------------------------
Summary of changes:
librpc/idl/drsuapi.idl | 2 +
selftest/knownfail | 4 -
source4/dsdb/common/util.c | 61 ++-
source4/dsdb/samdb/ldb_modules/password_hash.c | 26 +-
source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 60 ++-
source4/dsdb/samdb/ldb_modules/samba_dsdb.c | 1 +
.../dsdb/samdb/ldb_modules/tombstone_reanimate.c | 305 +++++++-------
source4/dsdb/samdb/ldb_modules/util.c | 2 +-
source4/dsdb/tests/python/tombstone_reanimation.py | 440 ++++++++++++++++++++-
source4/selftest/tests.py | 5 +
10 files changed, 694 insertions(+), 212 deletions(-)
mode change 100644 => 100755 source4/dsdb/tests/python/tombstone_reanimation.py
Changeset truncated at 500 lines:
diff --git a/librpc/idl/drsuapi.idl b/librpc/idl/drsuapi.idl
index 67f9604..c3af8a5 100644
--- a/librpc/idl/drsuapi.idl
+++ b/librpc/idl/drsuapi.idl
@@ -508,8 +508,10 @@ interface drsuapi
DRSUAPI_ATTID_trustAuthOutgoing = 0x00090087,
DRSUAPI_ATTID_userParameters = 0x0009008a,
DRSUAPI_ATTID_profilePath = 0x0009008b,
+ DRSUAPI_ATTID_operatorCount = 0x00090090,
DRSUAPI_ATTID_objectSid = 0x00090092,
DRSUAPI_ATTID_schemaIDGUID = 0x00090094,
+ DRSUAPI_ATTID_adminCount = 0x00090096,
DRSUAPI_ATTID_comment = 0x0009009C,/* User-Comment */
DRSUAPI_ATTID_accountExpires = 0x0009009f,
DRSUAPI_ATTID_lmPwdHistory = 0x000900a0,
diff --git a/selftest/knownfail b/selftest/knownfail
index c16c4d7..1a92a5d 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -249,10 +249,6 @@
#
^samba4.winbind.pac.*\(nt4_member:local\) # No KDC on a classic DC
#
-# This fails because it requires the tombstone_reanimation module to be enabled
-#
-^samba4.ldap.acl.python\(.*\).__main__.AclUndeleteTests.test_undelete\(.*\)
-#
# This fails because our python bindings create python Lists, not a type
# we can watch for set methods on.
#
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index 2aed804..bd0b5a3 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -745,6 +745,8 @@ static int samdb_find_or_add_attribute_ex(struct ldb_context *ldb,
int ret;
struct ldb_message_element *el;
+ SMB_ASSERT(attr_flags != 0);
+
el = ldb_msg_find_element(msg, name);
if (el) {
if (added != NULL) {
@@ -754,10 +756,8 @@ static int samdb_find_or_add_attribute_ex(struct ldb_context *ldb,
return LDB_SUCCESS;
}
- SMB_ASSERT(set_value != NULL || attr_flags != 0);
-
ret = ldb_msg_add_empty(msg, name,
- LDB_FLAG_MOD_ADD | attr_flags,
+ attr_flags,
&el);
if (ret != LDB_SUCCESS) {
return ret;
@@ -778,7 +778,7 @@ static int samdb_find_or_add_attribute_ex(struct ldb_context *ldb,
int samdb_find_or_add_attribute(struct ldb_context *ldb, struct ldb_message *msg, const char *name, const char *set_value)
{
- return samdb_find_or_add_attribute_ex(ldb, msg, name, set_value, 0, NULL);
+ return samdb_find_or_add_attribute_ex(ldb, msg, name, set_value, LDB_FLAG_MOD_ADD, NULL);
}
/*
@@ -5305,12 +5305,16 @@ int dsdb_user_obj_set_defaults(struct ldb_context *ldb,
const struct attribute_values {
const char *name;
const char *value;
- const char *add_control;
- unsigned attr_flags;
+ const char *add_value;
+ const char *mod_value;
+ const char *control;
+ unsigned add_flags;
+ unsigned mod_flags;
} map[] = {
{
.name = "accountExpires",
- .value = "9223372036854775807"
+ .add_value = "9223372036854775807",
+ .mod_value = "0",
},
{
.name = "badPasswordTime",
@@ -5342,30 +5346,59 @@ int dsdb_user_obj_set_defaults(struct ldb_context *ldb,
},
{
.name = "logonHours",
- .attr_flags = DSDB_FLAG_INTERNAL_FORCE_META_DATA,
+ .add_flags = DSDB_FLAG_INTERNAL_FORCE_META_DATA,
},
{
.name = "pwdLastSet",
.value = "0",
- .add_control = DSDB_CONTROL_PASSWORD_DEFAULT_LAST_SET_OID,
- }
+ .control = DSDB_CONTROL_PASSWORD_DEFAULT_LAST_SET_OID,
+ },
+ {
+ .name = "adminCount",
+ .mod_value = "0",
+ },
+ {
+ .name = "operatorCount",
+ .mod_value = "0",
+ },
};
for (i = 0; i < ARRAY_SIZE(map); i++) {
bool added = false;
+ const char *value = NULL;
+ unsigned flags = 0;
+
+ if (req != NULL && req->operation == LDB_ADD) {
+ value = map[i].add_value;
+ flags = map[i].add_flags;
+ } else {
+ value = map[i].mod_value;
+ flags = map[i].mod_flags;
+ }
+
+ if (value == NULL) {
+ value = map[i].value;
+ }
+
+ if (value != NULL) {
+ flags |= LDB_FLAG_MOD_ADD;
+ }
+
+ if (flags == 0) {
+ continue;
+ }
ret = samdb_find_or_add_attribute_ex(ldb, usr_obj,
map[i].name,
- map[i].value,
- map[i].attr_flags,
+ value, flags,
&added);
if (ret != LDB_SUCCESS) {
return ret;
}
- if (req != NULL && added && map[i].add_control != NULL) {
+ if (req != NULL && added && map[i].control != NULL) {
ret = ldb_request_add_control(req,
- map[i].add_control,
+ map[i].control,
false, NULL);
if (ret != LDB_SUCCESS) {
return ret;
diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c
index 7213015..d52ad2d 100644
--- a/source4/dsdb/samdb/ldb_modules/password_hash.c
+++ b/source4/dsdb/samdb/ldb_modules/password_hash.c
@@ -1799,7 +1799,10 @@ static int setup_last_set_field(struct setup_password_fields_io *io)
}
/* fall through */
case UINT64_MAX:
- if (!io->ac->update_password && io->u.pwdLastSet != 0) {
+ if (!io->ac->update_password &&
+ io->u.pwdLastSet != 0 &&
+ io->u.pwdLastSet != UINT64_MAX)
+ {
/*
* Just setting pwdLastSet to -1, while not changing
* any password field has no effect if pwdLastSet
@@ -2532,8 +2535,12 @@ static int setup_io(struct ph_context *ac,
/*
* We only take pwdLastSet from the existing object
* otherwise we leave it as 0.
+ *
+ * If no attribute is available, e.g. on deleted objects
+ * we remember that as UINT64_MAX.
*/
- io->u.pwdLastSet = samdb_result_nttime(info_msg, "pwdLastSet", 0);
+ io->u.pwdLastSet = samdb_result_nttime(info_msg, "pwdLastSet",
+ UINT64_MAX);
}
io->u.sAMAccountName = ldb_msg_find_attr_as_string(info_msg,
"sAMAccountName", NULL);
@@ -3454,6 +3461,7 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r
struct ldb_message_element *passwordAttr;
struct ldb_message *msg;
struct ldb_request *down_req;
+ struct ldb_control *restore = NULL;
int ret;
unsigned int i = 0;
@@ -3541,7 +3549,19 @@ static int password_hash_modify(struct ldb_module *module, struct ldb_request *r
return LDB_ERR_UNWILLING_TO_PERFORM;
}
- ldb_msg_remove_attr(msg, "pwdLastSet");
+ restore = ldb_request_get_control(req,
+ DSDB_CONTROL_RESTORE_TOMBSTONE_OID);
+ if (restore == NULL) {
+ /*
+ * A tomstone reanimation generates a double update
+ * of pwdLastSet.
+ *
+ * So we only remove it without the
+ * DSDB_CONTROL_RESTORE_TOMBSTONE_OID control.
+ */
+ ldb_msg_remove_attr(msg, "pwdLastSet");
+ }
+
/* if there was nothing else to be modified skip to next step */
if (msg->num_elements == 0) {
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index 8080834..9a1ff16 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -3084,17 +3084,57 @@ static int replmd_delete_internals(struct ldb_module *module, struct ldb_request
struct ldb_message_element *el;
TALLOC_CTX *tmp_ctx;
struct ldb_result *res, *parent_res;
- const char *preserved_attrs[] = {
+ static const char * const preserved_attrs[] = {
/* yes, this really is a hard coded list. See MS-ADTS
section 3.1.1.5.5.1.1 */
- "nTSecurityDescriptor", "attributeID", "attributeSyntax", "dNReferenceUpdate", "dNSHostName",
- "flatName", "governsID", "groupType", "instanceType", "lDAPDisplayName", "legacyExchangeDN",
- "isDeleted", "isRecycled", "lastKnownParent", "msDS-LastKnownRDN", "mS-DS-CreatorSID",
- "mSMQOwnerID", "nCName", "objectClass", "distinguishedName", "objectGUID", "objectSid",
- "oMSyntax", "proxiedObjectName", "name", "replPropertyMetaData", "sAMAccountName",
- "securityIdentifier", "sIDHistory", "subClassOf", "systemFlags", "trustPartner", "trustDirection",
- "trustType", "trustAttributes", "userAccountControl", "uSNChanged", "uSNCreated", "whenCreated",
- "whenChanged", NULL};
+ "attributeID",
+ "attributeSyntax",
+ "dNReferenceUpdate",
+ "dNSHostName",
+ "flatName",
+ "governsID",
+ "groupType",
+ "instanceType",
+ "lDAPDisplayName",
+ "legacyExchangeDN",
+ "isDeleted",
+ "isRecycled",
+ "lastKnownParent",
+ "msDS-LastKnownRDN",
+ "msDS-PortLDAP",
+ "mS-DS-CreatorSID",
+ "mSMQOwnerID",
+ "nCName",
+ "objectClass",
+ "distinguishedName",
+ "objectGUID",
+ "objectSid",
+ "oMSyntax",
+ "proxiedObjectName",
+ "name",
+ "nTSecurityDescriptor",
+ "replPropertyMetaData",
+ "sAMAccountName",
+ "securityIdentifier",
+ "sIDHistory",
+ "subClassOf",
+ "systemFlags",
+ "trustPartner",
+ "trustDirection",
+ "trustType",
+ "trustAttributes",
+ "userAccountControl",
+ "uSNChanged",
+ "uSNCreated",
+ "whenCreated",
+ "whenChanged",
+ NULL
+ };
+ static const char * const all_attrs[] = {
+ DSDB_SECRET_ATTRIBUTES,
+ "*",
+ NULL
+ };
unsigned int i, el_count = 0;
enum deletion_state deletion_state, next_deletion_state;
@@ -3132,7 +3172,7 @@ static int replmd_delete_internals(struct ldb_module *module, struct ldb_request
/* we need the complete msg off disk, so we can work out which
attributes need to be removed */
- ret = dsdb_module_search_dn(module, tmp_ctx, &res, old_dn, NULL,
+ ret = dsdb_module_search_dn(module, tmp_ctx, &res, old_dn, all_attrs,
DSDB_FLAG_NEXT_MODULE |
DSDB_SEARCH_SHOW_RECYCLED |
DSDB_SEARCH_REVEAL_INTERNALS |
diff --git a/source4/dsdb/samdb/ldb_modules/samba_dsdb.c b/source4/dsdb/samdb/ldb_modules/samba_dsdb.c
index 3f8cc51..21168a9 100644
--- a/source4/dsdb/samdb/ldb_modules/samba_dsdb.c
+++ b/source4/dsdb/samdb/ldb_modules/samba_dsdb.c
@@ -275,6 +275,7 @@ static int samba_dsdb_init(struct ldb_module *module)
NULL };
/* extended_dn_in or extended_dn_in_openldap goes here */
static const char *modules_list1a[] = {"objectclass",
+ "tombstone_reanimate",
"descriptor",
"acl",
"aclread",
diff --git a/source4/dsdb/samdb/ldb_modules/tombstone_reanimate.c b/source4/dsdb/samdb/ldb_modules/tombstone_reanimate.c
index fad856f..64e0519 100644
--- a/source4/dsdb/samdb/ldb_modules/tombstone_reanimate.c
+++ b/source4/dsdb/samdb/ldb_modules/tombstone_reanimate.c
@@ -53,25 +53,31 @@
#include "libds/common/flag_mapping.h"
struct tr_context {
-
struct ldb_module *module;
+
struct ldb_request *req;
- const struct dsdb_schema *schema;
+ const struct ldb_message *req_msg;
- struct ldb_reply *search_res;
- struct ldb_reply *search_res2;
+ struct ldb_result *search_res;
+ const struct ldb_message *search_msg;
- int (*step_fn)(struct tr_context *);
+ struct ldb_message *mod_msg;
+ struct ldb_result *mod_res;
+ struct ldb_request *mod_req;
+
+ struct ldb_dn *rename_dn;
+ struct ldb_result *rename_res;
+ struct ldb_request *rename_req;
+
+ const struct dsdb_schema *schema;
};
static struct tr_context *tr_init_context(struct ldb_module *module,
struct ldb_request *req)
{
- struct ldb_context *ldb;
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
struct tr_context *ac;
- ldb = ldb_module_get_ctx(module);
-
ac = talloc_zero(req, struct tr_context);
if (ac == NULL) {
ldb_oom(ldb);
@@ -80,26 +86,38 @@ static struct tr_context *tr_init_context(struct ldb_module *module,
ac->module = module;
ac->req = req;
+ ac->req_msg = req->op.mod.message;
ac->schema = dsdb_get_schema(ldb, ac);
return ac;
}
-static bool is_tombstone_reanimate_request(struct ldb_request *req, struct ldb_message_element **pel_dn)
+static bool is_tombstone_reanimate_request(struct ldb_request *req,
+ const struct ldb_message_element **pel_dn)
{
struct ldb_message_element *el_dn;
struct ldb_message_element *el_deleted;
/* check distinguishedName requirement */
el_dn = ldb_msg_find_element(req->op.mod.message, "distinguishedName");
- if (el_dn == NULL || el_dn->flags != LDB_FLAG_MOD_REPLACE) {
+ if (el_dn == NULL) {
+ return false;
+ }
+ if (el_dn->flags != LDB_FLAG_MOD_REPLACE) {
+ return false;
+ }
+ if (el_dn->num_values != 1) {
return false;
}
/* check isDeleted requirement */
el_deleted = ldb_msg_find_element(req->op.mod.message, "isDeleted");
- if (el_deleted == NULL || el_deleted->flags != LDB_FLAG_MOD_DELETE) {
+ if (el_deleted == NULL) {
+ return false;
+ }
+
+ if (el_deleted->flags != LDB_FLAG_MOD_DELETE) {
return false;
}
@@ -111,57 +129,34 @@ static bool is_tombstone_reanimate_request(struct ldb_request *req, struct ldb_m
* Local rename implementation based on dsdb_module_rename()
* so we could fine tune it and add more controls
*/
-static int tr_do_rename(struct ldb_module *module, struct ldb_request *parent_req,
- struct ldb_dn *dn_from, struct ldb_dn *dn_to)
+static int tr_prepare_rename(struct tr_context *ac,
+ const struct ldb_message_element *new_dn)
{
- int ret;
- struct ldb_request *req;
- struct ldb_context *ldb = ldb_module_get_ctx(module);
- TALLOC_CTX *tmp_ctx = talloc_new(parent_req);
- struct ldb_result *res;
-
- res = talloc_zero(tmp_ctx, struct ldb_result);
- if (!res) {
- talloc_free(tmp_ctx);
- return ldb_oom(ldb_module_get_ctx(module));
- }
+ struct ldb_context *ldb = ldb_module_get_ctx(ac->module);
+ int ret;
- ret = ldb_build_rename_req(&req, ldb, tmp_ctx,
- dn_from,
- dn_to,
- NULL,
- res,
- ldb_modify_default_callback,
- parent_req);
- LDB_REQ_SET_LOCATION(req);
- if (ret != LDB_SUCCESS) {
- talloc_free(tmp_ctx);
- return ret;
+ ac->rename_dn = ldb_dn_from_ldb_val(ac, ldb, &new_dn->values[0]);
+ if (ac->rename_dn == NULL) {
+ return ldb_module_oom(ac->module);
}
- ret = ldb_request_add_control(req, LDB_CONTROL_SHOW_DELETED_OID, false, NULL);
- if (ret != LDB_SUCCESS) {
- talloc_free(tmp_ctx);
- return ret;
+ ac->rename_res = talloc_zero(ac, struct ldb_result);
+ if (ac->rename_res == NULL) {
+ return ldb_module_oom(ac->module);
}
- /* mark request as part of Tombstone reanimation */
- ret = ldb_request_add_control(req, DSDB_CONTROL_RESTORE_TOMBSTONE_OID, false, NULL);
+ ret = ldb_build_rename_req(&ac->rename_req, ldb, ac,
+ ac->req_msg->dn,
+ ac->rename_dn,
+ NULL,
+ ac->rename_res,
+ ldb_modify_default_callback,
+ ac->req);
+ LDB_REQ_SET_LOCATION(ac->rename_req);
if (ret != LDB_SUCCESS) {
- talloc_free(tmp_ctx);
return ret;
}
- /*
- * Run request from the top module
- * so we get show_deleted control OID resolved
- */
- ret = ldb_next_request(module, req);
- if (ret == LDB_SUCCESS) {
- ret = ldb_wait(req->handle, LDB_WAIT_ALL);
- }
-
- talloc_free(tmp_ctx);
return ret;
}
@@ -169,102 +164,104 @@ static int tr_do_rename(struct ldb_module *module, struct ldb_request *parent_re
* Local rename implementation based on dsdb_module_modify()
* so we could fine tune it and add more controls
*/
-static int tr_do_modify(struct ldb_module *module, struct ldb_request *parent_req, struct ldb_message *msg)
+static int tr_do_down_req(struct tr_context *ac, struct ldb_request *down_req)
{
- int ret;
- struct ldb_request *mod_req;
- struct ldb_context *ldb = ldb_module_get_ctx(module);
- TALLOC_CTX *tmp_ctx = talloc_new(parent_req);
- struct ldb_result *res;
-
- res = talloc_zero(tmp_ctx, struct ldb_result);
- if (!res) {
- talloc_free(tmp_ctx);
- return ldb_oom(ldb_module_get_ctx(module));
- }
-
- ret = ldb_build_mod_req(&mod_req, ldb, tmp_ctx,
- msg,
- NULL,
- res,
- ldb_modify_default_callback,
- parent_req);
- LDB_REQ_SET_LOCATION(mod_req);
- if (ret != LDB_SUCCESS) {
- talloc_free(tmp_ctx);
- return ret;
- }
+ int ret;
/* We need this since object is 'delete' atm */
- ret = ldb_request_add_control(mod_req, LDB_CONTROL_SHOW_DELETED_OID, false, NULL);
+ ret = ldb_request_add_control(down_req,
+ LDB_CONTROL_SHOW_DELETED_OID,
--
Samba Shared Repository
More information about the samba-cvs
mailing list