andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 6 months ago
Clone

Blame SOURCES/0034-Additional-fix-for-ticket-47526-v3.patch

f92ce9
From b046f03c6a7b828152246f44bcacfee6347e5337 Mon Sep 17 00:00:00 2001
f92ce9
From: Ludwig Krispenz <lkrispen@redhat.com>
f92ce9
Date: Wed, 17 Dec 2014 18:11:44 +0100
f92ce9
Subject: [PATCH 34/53] Additional fix for ticket 47526 v3
f92ce9
f92ce9
            In modrdn we need to distinguish if the entry is changed is a group or a
f92ce9
            regular memebr of a group. for the group case do the same as when deleting a group
f92ce9
            For the modrdn of an user entry, the case where no memberof attribute exists has
f92ce9
            to succeed.
f92ce9
f92ce9
            Reviewed by: noriko, thanks
f92ce9
f92ce9
            https://fedorahosted.org/389/ticket/47526
f92ce9
f92ce9
(cherry picked from commit c8951669b3a74cb9fda013ffe914031b76e2e452)
f92ce9
---
f92ce9
 ldap/servers/plugins/memberof/memberof.c | 46 +++++++++++++++++++++++++-------
f92ce9
 1 file changed, 36 insertions(+), 10 deletions(-)
f92ce9
f92ce9
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
f92ce9
index bd87ee9..80b52ab 100644
f92ce9
--- a/ldap/servers/plugins/memberof/memberof.c
f92ce9
+++ b/ldap/servers/plugins/memberof/memberof.c
f92ce9
@@ -566,7 +566,7 @@ int memberof_postop_del(Slapi_PBlock *pb)
f92ce9
 		}
f92ce9
 
f92ce9
 		/* is the entry of interest as a group? */
f92ce9
-		if(e && configCopy.group_filter && !slapi_filter_test_simple(e, configCopy.group_filter))
f92ce9
+		if(e && configCopy.group_filter && 0 == slapi_filter_test_simple(e, configCopy.group_filter))
f92ce9
 		{
f92ce9
 			int i = 0;
f92ce9
 			Slapi_Attr *attr = 0;
f92ce9
@@ -664,6 +664,12 @@ memberof_del_dn_type_callback(Slapi_Entry *e, void *callback_data)
f92ce9
 
f92ce9
 	slapi_pblock_destroy(mod_pb);
f92ce9
 
f92ce9
+	if (rc == LDAP_NO_SUCH_ATTRIBUTE && val[0] == NULL) {
f92ce9
+		/* if no memberof attribut exists 
f92ce9
+		 * handle as success
f92ce9
+		 */
f92ce9
+		rc = LDAP_SUCCESS;
f92ce9
+	}
f92ce9
 	return rc;
f92ce9
 }
f92ce9
 
f92ce9
@@ -861,7 +867,7 @@ int memberof_postop_modrdn(Slapi_PBlock *pb)
f92ce9
 
f92ce9
 		/*  update any downstream members */
f92ce9
 		if(pre_sdn && post_sdn && configCopy.group_filter &&
f92ce9
-			!slapi_filter_test_simple(post_e, configCopy.group_filter))
f92ce9
+			0 == slapi_filter_test_simple(post_e, configCopy.group_filter))
f92ce9
 		{
f92ce9
 			int i = 0;
f92ce9
 			Slapi_Attr *attr = 0;
f92ce9
@@ -890,17 +896,37 @@ int memberof_postop_modrdn(Slapi_PBlock *pb)
f92ce9
 		if (ret == LDAP_SUCCESS && pre_sdn && post_sdn) {
f92ce9
 			if ((entry_scope && !slapi_sdn_issuffix(post_sdn, entry_scope)) || 
f92ce9
                             (entry_scope_exclude_subtree && slapi_sdn_issuffix(post_sdn, entry_scope_exclude_subtree))) {
f92ce9
-				memberof_del_dn_data del_data = {0, configCopy.memberof_attr};
f92ce9
 				if((ret = memberof_del_dn_from_groups(pb, &configCopy, pre_sdn))){
f92ce9
 					slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
f92ce9
 						"memberof_postop_modrdn - delete dn failed for (%s), error (%d)\n",
f92ce9
 						slapi_sdn_get_dn(pre_sdn), ret);
f92ce9
 				}
f92ce9
-				if(ret == LDAP_SUCCESS && (ret = memberof_del_dn_type_callback(post_e, &del_data))){
f92ce9
-					slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
f92ce9
-						"memberof_postop_modrdn - delete dn callback failed for (%s), error (%d)\n",
f92ce9
-						slapi_entry_get_dn(post_e), ret);
f92ce9
-				}
f92ce9
+				if(ret == LDAP_SUCCESS && pre_e && configCopy.group_filter &&
f92ce9
+						0 == slapi_filter_test_simple(pre_e, configCopy.group_filter)) {
f92ce9
+					/* is the entry of interest as a group? */
f92ce9
+						int i = 0;
f92ce9
+						Slapi_Attr *attr = 0;
f92ce9
+
f92ce9
+						/* Loop through to find each grouping attribute separately. */
f92ce9
+						for (i = 0; configCopy.groupattrs[i] && ret == LDAP_SUCCESS; i++) {
f92ce9
+							if (0 == slapi_entry_attr_find(pre_e, configCopy.groupattrs[i], &attr)) {
f92ce9
+								if((ret = memberof_del_attr_list(pb, &configCopy, pre_sdn, attr))){
f92ce9
+									slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
f92ce9
+									"memberof_postop_modrdn: error deleting attr list - dn (%s). Error (%d)\n",
f92ce9
+									slapi_sdn_get_dn(pre_sdn),ret);
f92ce9
+								}
f92ce9
+
f92ce9
+							}
f92ce9
+						}
f92ce9
+					} 
f92ce9
+				if(ret == LDAP_SUCCESS) {
f92ce9
+						memberof_del_dn_data del_data = {0, configCopy.memberof_attr};
f92ce9
+						if(ret = memberof_del_dn_type_callback(post_e, &del_data)){
f92ce9
+							slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
f92ce9
+								"memberof_postop_modrdn - delete dn callback failed for (%s), error (%d)\n",
f92ce9
+								slapi_entry_get_dn(post_e), ret);
f92ce9
+						}
f92ce9
+					}
f92ce9
 			} else {
f92ce9
 				if((ret = memberof_replace_dn_from_groups(pb, &configCopy, pre_sdn, post_sdn))){
f92ce9
 					slapi_log_error( SLAPI_LOG_FATAL, MEMBEROF_PLUGIN_SUBSYSTEM,
f92ce9
@@ -1261,7 +1287,7 @@ int memberof_postop_add(Slapi_PBlock *pb)
f92ce9
 		memberof_rlock_config();
f92ce9
 		mainConfig = memberof_get_config();
f92ce9
 		if(e && mainConfig && mainConfig->group_filter &&
f92ce9
-		   !slapi_filter_test_simple(e, mainConfig->group_filter))
f92ce9
+		   0 == slapi_filter_test_simple(e, mainConfig->group_filter))
f92ce9
 		{
f92ce9
 			interested = 1;
f92ce9
 			/* copy config so it doesn't change out from under us */
f92ce9
@@ -1554,7 +1580,7 @@ memberof_modop_one_replace_r(Slapi_PBlock *pb, MemberOfConfig *config,
f92ce9
 		"memberof_modop_one_replace_r: %s %s in %s\n"
f92ce9
 		,op_str, op_this, op_to);
f92ce9
 
f92ce9
-	if(config->group_filter && !slapi_filter_test_simple(e, config->group_filter))
f92ce9
+	if(config->group_filter && 0 == slapi_filter_test_simple(e, config->group_filter))
f92ce9
 	{
f92ce9
 		/* group */
f92ce9
 		Slapi_Value *ll_dn_val = 0;
f92ce9
-- 
f92ce9
1.9.3
f92ce9