Browse Source

Ticket 48270: fail to index an attribute with a specific matching rule

Bug Description:
	During index configuration, if a new rule type matching rule is added
	(attribute 'nsMatchingRule') it creates an indexer.
	If the indexer was not already registered (plugin_mr_bind),

	In a first step it tries to find/call, for the specified matching rule, an indexer_create callback of
	all the registered matching rule plugins .

	If no indexer_create function exist or match the specified matching rule, then it tries to find
	a registered matching rule plugins that matches the specified matching rule (plg_mr_names).

	The problem occurs in the first step, because it uses 'rc' for intermediate returned code and
	can erronously believe the first step was successful although no indexer_create was found.
	So it skips the second step and no matching rule plugin is found.

Fix Description:
	The fix consist to avoid using the 'rc' return code in intermediate slapi-pblock-get/set

https://fedorahosted.org/389/ticket/48270

Reviewed by: Noriko Hosoi (Thank you sooo much Noriko !!)

Platforms tested: F17

Flag Day: no

Doc impact: no
Thierry Bordaz 9 years ago
parent
commit
3752886326
1 changed files with 17 additions and 14 deletions
  1. 17 14
      ldap/servers/slapd/plugin_mr.c

+ 17 - 14
ldap/servers/slapd/plugin_mr.c

@@ -170,22 +170,25 @@ slapi_mr_indexer_create (Slapi_PBlock* opb)
 		    for (mrp = get_plugin_list(PLUGIN_LIST_MATCHINGRULE); mrp != NULL; mrp = mrp->plg_next)
 		    {
 				IFP indexFn = NULL;
+				IFP indexSvFn = NULL;
 				Slapi_PBlock pb;
 				memcpy (&pb, opb, sizeof(Slapi_PBlock));
-				if (!(rc = slapi_pblock_set (&pb, SLAPI_PLUGIN, mrp)) &&
-				    !(rc = slapi_pblock_get (&pb, SLAPI_PLUGIN_MR_INDEXER_CREATE_FN, &createFn)) &&
-				    createFn != NULL &&
-				    !(rc = createFn (&pb)) &&
-					((!(rc = slapi_pblock_get (&pb, SLAPI_PLUGIN_MR_INDEX_FN, &indexFn)) &&
-					 indexFn != NULL) ||
-					 (!(rc = slapi_pblock_get (&pb, SLAPI_PLUGIN_MR_INDEX_SV_FN, &indexFn)) &&
-					  indexFn != NULL)))
-				{
-				    /* Success: this plugin can handle it. */
-				    memcpy (opb, &pb, sizeof(Slapi_PBlock));
-				    plugin_mr_bind (oid, mrp); /* for future reference */
-					rc = 0; /* success */
-				    break;
+				slapi_pblock_set(&pb, SLAPI_PLUGIN, mrp);
+				if (slapi_pblock_get(&pb, SLAPI_PLUGIN_MR_INDEXER_CREATE_FN, &createFn)) {
+					/* plugin not a matchingrule type */
+					continue;
+				}
+				if (createFn && !createFn(&pb)) {
+					slapi_pblock_get(&pb, SLAPI_PLUGIN_MR_INDEX_FN, &indexFn);
+					slapi_pblock_get(&pb, SLAPI_PLUGIN_MR_INDEX_SV_FN, &indexSvFn);
+					if (indexFn || indexSvFn) {
+						/* Success: this plugin can handle it. */
+						memcpy(opb, &pb, sizeof (Slapi_PBlock));
+						plugin_mr_bind(oid, mrp); /* for future reference */
+						rc = 0; /* success */
+						break;
+					}
+
 				}
 		    }
 			if (rc != 0) {