From 40009114d1ec9ec19bc6fd63fb572d607c661bd6 Mon Sep 17 00:00:00 2001
From: Ondrej Kuznik <ondrej.kuznik@acision.com>
Date: Fri, 9 Mar 2012 14:37:59 +0100
Subject: [PATCH] (ITS#6987) Consider only same attribute siblings for
 Cft_misc.

For all other ce_types it holds that each is represented by one
attribute, making ce_type matching for X-ORDERED siblings equivalent to
how back-ldif handles them. Cft_misc is means "all other types", however
no overlay/backend so far has used different attributes as siblings,
triggering the difference in handling between bconfig.c and back-ldif.
---
 servers/slapd/bconfig.c | 39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c
index 0ad60aa463..d289a3bff1 100644
--- a/servers/slapd/bconfig.c
+++ b/servers/slapd/bconfig.c
@@ -4634,9 +4634,42 @@ check_name_index( CfEntryInfo *parent, ConfigType ce_type, Entry *e,
 		}
 	}
 
-	/* count related kids */
-	for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
-		if ( ce->ce_type == ce_type ) nsibs++;
+	/* count related kids, for entries of type Cft_Misc, consider only
+	 * same attribute siblings */
+	if ( ce_type == Cft_Misc )
+	{
+		AttributeDescription *ad = NULL;
+
+		ptr1 = strchr( rdn.bv_val, '=' );
+		assert( ptr1 != NULL );
+
+		rdn.bv_len = ptr1 - rdn.bv_val;
+		slap_bv2ad( &rdn, &ad, &ptr2 );
+		assert( ad != NULL );
+
+		for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
+			AttributeDescription *ad2 = NULL;
+			if ( ce->ce_type != ce_type )
+				continue;
+
+			dnRdn( &ce->ce_entry->e_name, &rdn );
+
+			ptr1 = strchr( rdn.bv_val, '=' );
+			assert( ptr1 != NULL );
+
+			rdn.bv_len = ptr1 - rdn.bv_val;
+			slap_bv2ad( &rdn, &ad2, &ptr2 );
+			assert( ad2 != NULL );
+
+			if ( ad == ad2 )
+				nsibs++;
+		}
+	}
+	else
+	{
+		for (nsibs=0, ce=parent->ce_kids; ce; ce=ce->ce_sibs) {
+			if ( ce->ce_type == ce_type ) nsibs++;
+		}
 	}
 
 	/* account for -1 frontend */
-- 
GitLab