Przeglądaj źródła

Fix for 157021: server doesn't correctly process modifies to windows sync agreements

David Boreham 20 lat temu
rodzic
commit
bc338326a2

+ 1 - 0
ldap/servers/plugins/replication/repl5.h

@@ -565,6 +565,7 @@ ReplicaId agmt_get_consumerRID(Repl_Agmt *ra);
 
 
 void windows_init_agreement_from_entry(Repl_Agmt *ra, Slapi_Entry *e);
+int windows_handle_modify_agreement(Repl_Agmt *ra, const char *type, Slapi_Entry *e);
 void windows_agreement_delete(Repl_Agmt *ra);
 Repl_Connection *windows_conn_new(Repl_Agmt *agmt);
 

+ 1 - 1
ldap/servers/plugins/replication/repl5_agmtlist.c

@@ -433,7 +433,7 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
             /* ignore modifier's name and timestamp attributes and the description. */
             continue;
         }
-        else
+        else if (0 == windows_handle_modify_agreement(agmt, mods[i]->mod_type, e))
         {
             slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmtlist_modify_callback: " 
                             "modification of %s attribute is not allowed\n", mods[i]->mod_type);

+ 69 - 25
ldap/servers/plugins/replication/windows_private.c

@@ -75,51 +75,95 @@ true_value_from_string(char *val)
 	}
 }
 
-void
-windows_init_agreement_from_entry(Repl_Agmt *ra, Slapi_Entry *e)
+static int
+windows_parse_config_entry(Repl_Agmt *ra, const char *type, Slapi_Entry *e)
 {
 	char *tmpstr = NULL;
-	agmt_set_priv(ra,windows_private_new());
+	int retval = 0;
 	
-	/* DN of entry at root of replicated area */
-	tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7WindowsReplicaArea);
-	if (NULL != tmpstr)
+	if (type == NULL || slapi_attr_types_equivalent(type,type_nsds7WindowsReplicaArea))
 	{
-		windows_private_set_windows_subtree(ra, slapi_sdn_new_dn_passin(tmpstr) );
+		tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7WindowsReplicaArea);
+		if (NULL != tmpstr)
+		{
+			windows_private_set_windows_subtree(ra, slapi_sdn_new_dn_passin(tmpstr) );
+		}
+		retval = 1;
+		slapi_ch_free((void**)&tmpstr);
 	}
-	tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7DirectoryReplicaArea); 
-	if (NULL != tmpstr)
+	if (type == NULL || slapi_attr_types_equivalent(type,type_nsds7DirectoryReplicaArea))
 	{
-		windows_private_set_directory_subtree(ra, slapi_sdn_new_dn_passin(tmpstr) );
+		tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7DirectoryReplicaArea); 
+		if (NULL != tmpstr)
+		{
+			windows_private_set_directory_subtree(ra, slapi_sdn_new_dn_passin(tmpstr) );
+		}
+		retval = 1;
+		slapi_ch_free((void**)&tmpstr);
 	}
-
-	tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7CreateNewUsers); 
-	if (NULL != tmpstr && true_value_from_string(tmpstr))
+	if (type == NULL || slapi_attr_types_equivalent(type,type_nsds7CreateNewUsers))
 	{
-		windows_private_set_create_users(ra, PR_TRUE);
+		tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7CreateNewUsers); 
+		if (NULL != tmpstr && true_value_from_string(tmpstr))
+		{
+			windows_private_set_create_users(ra, PR_TRUE);
+		}
+		else
+		{
+			windows_private_set_create_users(ra, PR_FALSE);
+		}
+		retval = 1;
 		slapi_ch_free((void**)&tmpstr);
 	}
-	else
+	if (type == NULL || slapi_attr_types_equivalent(type,type_nsds7CreateNewGroups))
 	{
-		windows_private_set_create_users(ra, PR_FALSE);
+		tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7CreateNewGroups); 
+		if (NULL != tmpstr && true_value_from_string(tmpstr))
+		{
+			windows_private_set_create_groups(ra, PR_TRUE);
+		}
+		else
+		{
+			windows_private_set_create_groups(ra, PR_FALSE);
+		}
+		retval = 1;
+		slapi_ch_free((void**)&tmpstr);
 	}
-	tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7CreateNewGroups); 
-	if (NULL != tmpstr && true_value_from_string(tmpstr))
+	if (type == NULL || slapi_attr_types_equivalent(type,type_nsds7WindowsDomain))
 	{
-		windows_private_set_create_groups(ra, PR_TRUE);
+		tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7WindowsDomain); 
+		if (NULL != tmpstr)
+		{
+			windows_private_set_windows_domain(ra,tmpstr);
+		}
+		retval = 1;
 		slapi_ch_free((void**)&tmpstr);
 	}
-	else
+	return retval;
+}
+
+/* Returns non-zero if the modify was ok, zero if not */
+int
+windows_handle_modify_agreement(Repl_Agmt *ra, const char *type, Slapi_Entry *e)
+{
+	/* Is this a Windows agreement ? */
+	if (get_agmt_agreement_type(ra) == REPLICA_TYPE_WINDOWS)
 	{
-		windows_private_set_create_groups(ra, PR_FALSE);
-	}
-	tmpstr = slapi_entry_attr_get_charptr(e, type_nsds7WindowsDomain); 
-	if (NULL != tmpstr)
+		return windows_parse_config_entry(ra,type,e);
+	} else
 	{
-		windows_private_set_windows_domain(ra,tmpstr);
+		return 0;
 	}
 }
 
+void
+windows_init_agreement_from_entry(Repl_Agmt *ra, Slapi_Entry *e)
+{
+	agmt_set_priv(ra,windows_private_new());
+
+	windows_parse_config_entry(ra,NULL,e);
+}
+
 const char* windows_private_get_purl(const Repl_Agmt *ra)
 {
 	const char* windows_purl;