s4-drs: Fixes bugs regarding Urgent Replication on wrong situations
authorFernando J V da Silva <fernandojvsilva@yahoo.com.br>
Thu, 4 Feb 2010 18:46:52 +0000 (16:46 -0200)
committerAndrew Tridgell <tridge@samba.org>
Mon, 15 Feb 2010 10:57:07 +0000 (21:57 +1100)
It fixes the bug which causes an urgent replication to be enabled
incorrectly when an object is modified, but it should happen only
when it was created. This patch also fixes the bug that enable an
urgent replication when an object is deleted, but it should happen
only when it was modified and fixes the bug that does not enable
an urgent replication when an object is deleted and it should happen
only when it is deleted (not when it is modified).

Signed-off-by: Andrew Tridgell <tridge@samba.org>
source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 725ba2a47c3cca305b6fdcbd6ad1d5507a1a6f81..51611aca1d3e5ea8c7b26de729cd8882f931e571 100644 (file)
@@ -92,7 +92,7 @@ struct replmd_replicated_request {
 
 enum urgent_situation {
        REPL_URGENT_ON_CREATE = 1,
-       REPL_URGENT_ON_UPDATE = 3, /* activated on creating as well*/
+       REPL_URGENT_ON_UPDATE = 2,
        REPL_URGENT_ON_DELETE = 4
 };
 
@@ -103,10 +103,10 @@ static const struct {
 } urgent_objects[] = {
                {"nTDSDSA", (REPL_URGENT_ON_CREATE | REPL_URGENT_ON_DELETE)},
                {"crossRef", (REPL_URGENT_ON_CREATE | REPL_URGENT_ON_DELETE)},
-               {"attributeSchema", REPL_URGENT_ON_UPDATE},
-               {"classSchema", REPL_URGENT_ON_UPDATE},
-               {"secret", REPL_URGENT_ON_UPDATE},
-               {"rIDManager", REPL_URGENT_ON_UPDATE},
+               {"attributeSchema", (REPL_URGENT_ON_CREATE | REPL_URGENT_ON_UPDATE)},
+               {"classSchema", (REPL_URGENT_ON_CREATE | REPL_URGENT_ON_UPDATE)},
+               {"secret", (REPL_URGENT_ON_CREATE | REPL_URGENT_ON_UPDATE)},
+               {"rIDManager", (REPL_URGENT_ON_CREATE | REPL_URGENT_ON_UPDATE)},
                {NULL, 0}
 };
 
@@ -1077,6 +1077,7 @@ static int replmd_update_rpmd(struct ldb_module *module,
        struct ldb_result *res;
        struct ldb_context *ldb;
        struct ldb_message_element *objectclass_el;
+       enum urgent_situation situation;
 
        ldb = ldb_module_get_ctx(module);
 
@@ -1098,9 +1099,17 @@ static int replmd_update_rpmd(struct ldb_module *module,
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
+       /* if isDeleted is present and is TRUE, then we consider we are deleting,
+        * otherwise we consider we are updating */
+       if (ldb_msg_check_string_attribute(msg, "isDeleted", "TRUE")) {
+               situation = REPL_URGENT_ON_DELETE;
+       } else {
+               situation = REPL_URGENT_ON_UPDATE;
+       }
+
        objectclass_el = ldb_msg_find_element(res->msgs[0], "objectClass");
        if (is_urgent && replmd_check_urgent_objectclass(objectclass_el,
-                                                       REPL_URGENT_ON_UPDATE)) {
+                                                       situation)) {
                *is_urgent = true;
        }
 
@@ -1133,7 +1142,7 @@ static int replmd_update_rpmd(struct ldb_module *module,
                        return ret;
                }
 
-               if (is_urgent && !*is_urgent) {
+               if (is_urgent && !*is_urgent && (situation == REPL_URGENT_ON_UPDATE)) {
                        *is_urgent = replmd_check_urgent_attribute(&msg->elements[i]);
                }