From: Andrew Bartlett Date: Tue, 29 May 2018 22:06:54 +0000 (+1200) Subject: repl_meta_data: Cope with the strange but unusual case of isDeleted: FALSE in replmd_... X-Git-Tag: ldb-1.4.0~14 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=5ea111471aff23c66ab9a62b4e3a4db25b7f5738;p=samba.git repl_meta_data: Cope with the strange but unusual case of isDeleted: FALSE in replmd_process_linked_attribute() BUG: https://bugzilla.samba.org/show_bug.cgi?id=13448 Signed-off-by: Andrew Bartlett Reviewed-by: Garming Sam --- diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index f38a3720226..7395f52524e 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -7249,6 +7249,19 @@ linked_attributes[0]: return LDB_ERR_OPERATIONS_ERROR; } + /* + * All attributes listed here must be dealt with in some way + * by replmd_process_linked_attribute() otherwise in the case + * of isDeleted: FALSE the modify will fail with: + * + * Failed to apply linked attribute change 'attribute 'isDeleted': + * invalid modify flags on + * 'CN=g1_1527570609273,CN=Users,DC=samba,DC=example,DC=com': + * 0x0' + * + * This is becaue isDeleted is a Boolean, so FALSE is a + * legitimate value (set by Samba's deletetest.py) + */ attrs[0] = attr->lDAPDisplayName; attrs[1] = "isDeleted"; attrs[2] = "isRecycled"; @@ -7629,6 +7642,9 @@ static int replmd_process_linked_attribute(struct ldb_module *module, * recycled and tombstone objects. We don't have to delete * any existing link, that should have happened when the * object deletion was replicated or initiated. + * + * This needs isDeleted and isRecycled to be included as + * attributes in the search and so in msg if set. */ replmd_deletion_state(module, msg, &deletion_state, NULL); @@ -7637,6 +7653,24 @@ static int replmd_process_linked_attribute(struct ldb_module *module, return LDB_SUCCESS; } + /* + * Now that we know the deletion_state, remove the extra + * attributes added for that purpose. We need to do this + * otherwise in the case of isDeleted: FALSE the modify will + * fail with: + * + * Failed to apply linked attribute change 'attribute 'isDeleted': + * invalid modify flags on + * 'CN=g1_1527570609273,CN=Users,DC=samba,DC=example,DC=com': + * 0x0' + * + * This is becaue isDeleted is a Boolean, so FALSE is a + * legitimate value (set by Samba's deletetest.py) + */ + + ldb_msg_remove_attr(msg, "isDeleted"); + ldb_msg_remove_attr(msg, "isRecycled"); + old_el = ldb_msg_find_element(msg, attr->lDAPDisplayName); if (old_el == NULL) { ret = ldb_msg_add_empty(msg, attr->lDAPDisplayName, LDB_FLAG_MOD_REPLACE, &old_el);