ldap/servers/slapd/back-ldbm/index.c | 8 +
ldap/servers/slapd/back-ldbm/ldbm_attr.c | 1
ldap/servers/slapd/back-ldbm/ldbm_index_config.c | 3
ldap/servers/slapd/back-ldbm/matchrule.c | 26 ++++++
ldap/servers/slapd/match.c | 39 +++++++++
ldap/servers/slapd/plugin_mr.c | 2
ldap/servers/slapd/schema.c | 95 +++--------------------
ldap/servers/slapd/slapi-plugin.h | 12 ++
8 files changed, 100 insertions(+), 86 deletions(-)
New commits:
commit 5c1cd5f4b3519530ac62df3dd31291e4bf65852a
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Apr 4 15:00:04 2011 -0600
Bug 693466 - Unable to change schema online
https://bugzilla.redhat.com/show_bug.cgi?id=693466
Resolves: bug 693466
Bug Description: Unable to change schema online
Reviewed by: nkinder (Thanks!)
Branch: 389-ds-base-1.2.8
Fix Description: The problem is only with attributes that specify a SUP.
There was some old code that assumed the attributes were stored in a list
in order of SUP. This is not the case. They are stored in a hashtable
which is not in any order at all. But the check is redundant anyway.
If a SUP is specified, the code already checks if the superior exists and
returns an error if not.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 466fced49dd1b6893c19ce5a7ecd8121f6eceeab)
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index 4868b06..dc5e9a9 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -3107,65 +3107,6 @@ oc_free( struct objclass **ocp )
}
}
-struct supargs{
- char *sup, *oid;
- unsigned long rc;
-};
-
-static int
-at_sup_dependency_callback(struct asyntaxinfo *asi, void *arg)
-{
- struct supargs *aew = (struct supargs *)arg;
- int rc=ATTR_SYNTAX_ENUM_NEXT;
-
- if (!asi) {
- LDAPDebug(LDAP_DEBUG_ANY, "Error: no attribute types in
at_schema_attributes_callback\n",
- 0, 0, 0);
- }
- else
- {
- if (strcasecmp (asi->asi_oid, aew->oid ) == 0) {
- rc=ATTR_SYNTAX_ENUM_STOP;
- } else {
- if(asi->asi_name != NULL) {
- if (strcasecmp (asi->asi_name, aew->sup ) == 0) {
- aew->rc=0;
- } else if (asi->asi_aliases) {
- int i = 0;
-
- /* Loop through aliases to see if any match */
- for (i=0; asi->asi_aliases[i] != NULL; i++) {
- if (strcasecmp (asi->asi_aliases[i], aew->sup ) == 0) {
- aew->rc=0;
- }
- }
- }
- }
- }
- }
- return rc;
-}
-
-/* walks down attribute types and makes sure that the superior value is found in an
attribute type
- preceeding in the hash table. I have concerns about collisions messing with the order
here but this
- may be the best we can do.
-*/
-
-static int
-slapi_check_at_sup_dependency(char *sup, char *oid)
-{
- struct supargs aew;
-
- memset(&aew,0,sizeof(struct supargs));
- aew.rc=LDAP_TYPE_OR_VALUE_EXISTS;
- aew.sup=sup;
- aew.oid=oid;
- attr_syntax_enumerate_attrs(at_sup_dependency_callback, &aew, PR_FALSE);
- return aew.rc;
-}
-
-
-
/*
* if asipp is NULL, the attribute type is added to the global set of schema.
* if asipp is not NULL, the AT is not added but *asipp is set. When you are
@@ -3469,24 +3410,6 @@ read_at_ldif(const char *input, struct asyntaxinfo **asipp, char
*errorbuf,
attr_syntax_return( asi_parent );
}
}
- /*
- if we are remote (via modify_schema_dse) then check sup dependencies. Locally
- was done in if statement above
- */
-
- if(!status)
- {
- if(is_remote && (pSuperior != NULL))
- {
- status=slapi_check_at_sup_dependency(pSuperior, pOid);
- }
- if(LDAP_SUCCESS != status) {
- schema_create_errormsg( errorbuf, errorbufsize,
- schema_errprefix_at, first_attr_name,
- "Missing parent attribute syntax OID");
- status = LDAP_TYPE_OR_VALUE_EXISTS;
- }
- }
if (!status && (NULL == pSyntax)) {
schema_create_errormsg( errorbuf, errorbufsize, schema_errprefix_at,
commit 87ca67e21f99bbc553aafc06d277dc6af53aad7a
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Apr 4 14:20:06 2011 -0600
Bug 693503 - matching rules do not inherit from superior attribute type
https://bugzilla.redhat.com/show_bug.cgi?id=693503
Resolves: bug 693503
Bug Description: matching rules do not inherit from superior attribute type
Reviewed by: nkinder (Thanks!)
Branch: 389-ds-base-1.2.8
Fix Description: If the attribute definition specifies a superior, use the
superior equality, substrings, and ordering matching rule from the
superior if not specified in the child.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit b5e708a3e907381c66fbcdba2ed1fd69a99198f3)
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index 14f3e76..4868b06 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -3441,21 +3441,31 @@ read_at_ldif(const char *input, struct asyntaxinfo **asipp, char
*errorbuf,
status = invalid_syntax_error;
/* We only want to use the parent syntax if a SYNTAX
* wasn't explicitly specified for this attribute. */
- } else if (NULL == pSyntax) {
+ } else if ((NULL == pSyntax) || (NULL == pMREquality) || (NULL == pMRSubstring)
||
+ (NULL == pMROrdering)) {
char *pso = asi_parent->asi_plugin->plg_syntax_oid;
- if (pso) {
- slapi_ch_free ((void **)&pSyntax);
+ if (pso && (NULL == pSyntax)) {
pSyntax = slapi_ch_strdup(pso);
LDAPDebug (LDAP_DEBUG_TRACE,
"Inheriting syntax %s from parent type %s\n",
pSyntax, pSuperior,NULL);
- } else {
+ } else if (NULL == pSyntax) {
schema_create_errormsg( errorbuf, errorbufsize,
schema_errprefix_at, first_attr_name,
"Missing parent attribute syntax OID");
status = invalid_syntax_error;
}
+
+ if (NULL == pMREquality) {
+ pMREquality = slapi_ch_strdup(asi_parent->asi_mr_equality);
+ }
+ if (NULL == pMRSubstring) {
+ pMRSubstring = slapi_ch_strdup(asi_parent->asi_mr_substring);
+ }
+ if (NULL == pMROrdering) {
+ pMROrdering = slapi_ch_strdup(asi_parent->asi_mr_ordering);
+ }
attr_syntax_return( asi_parent );
}
}
commit 9a5ad287f2b4d0c3ce49be3107c61c00551b9314
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Mon Apr 4 11:55:30 2011 -0600
Bug 693455 - nsMatchingRule does not work with multiple values
https://bugzilla.redhat.com/show_bug.cgi?id=693455
Resolves: bug 693455
Bug Description: nsMatchingRule does not work with multiple values
Reviewed by: nkinder (Thanks!)
Branch: 389-ds-base-1.2.8
Fix Description: The variable isFirst was not being used correctly. Instead
of using it, just use tmpBuf[0] to see if this is the first iteration or
not.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 58902a28c077309cf0e942bfb03762d96eb9c8af)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
b/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
index 5575ef2..aa47584 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
@@ -202,12 +202,11 @@ static int ldbm_index_parse_entry(ldbm_instance *inst, Slapi_Entry
*e,
tmpBuf[0] = 0;
/* Get the list of matching rules from the entry. */
if (0 == slapi_entry_attr_find(e, "nsMatchingRule", &attr)) {
- isFirst = 1;
for (i = slapi_attr_first_value(attr, &sval); i != -1;
i = slapi_attr_next_value(attr, i, &sval)) {
attrValue = slapi_value_get_berval(sval);
if (NULL != attrValue->bv_val && strlen(attrValue->bv_val) >
0) {
- if (isFirst) {
+ if (0 == tmpBuf[0]) {
ZCAT_SAFE(tmpBuf, "", attrValue->bv_val);
} else {
ZCAT_SAFE(tmpBuf, ",", attrValue->bv_val);
commit ee0ab6921fbc6a92a554faa3218c36851b5cfe30
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Fri Apr 1 19:10:54 2011 -0600
Bug 693451 - cannot use localized matching rules
https://bugzilla.redhat.com/show_bug.cgi?id=693451
Resolves: bug 693451
Bug Description: cannot use localized matching rules
Reviewed by: nkinder (Thanks!)
Branch: 389-ds-base-1.2.8
Fix Description: With the new matching rule code, the old method of
identifying a simple matching rule that can use a compare function is
not valid. All of the collation plugin matching rules are ordering,
either ignore case or exact case. So we need another way to tell if
the matching rule can use a simple compare function to generate index
keys. The new function
int slapi_matchingrule_can_use_compare_fn(const char *mr_oid_or_name);
is used for this purpose. It looks up the oid of the matching rule and
compares it to the oids used by the collation plugin.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit cb2239082a27f00d470754e5924311bd9bee4b34)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_attr.c
b/ldap/servers/slapd/back-ldbm/ldbm_attr.c
index 8c09da0..b95f2ff 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_attr.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_attr.c
@@ -293,6 +293,7 @@ attr_index_config(
/* check if this is a simple ordering specification
for an attribute that has no ordering matching rule */
} else if (slapi_matchingrule_is_ordering(index_rules[j], attrsyntax_oid) &&
+ slapi_matchingrule_can_use_compare_fn(index_rules[j]) &&
!a->ai_sattr.a_mr_ord_plugin) { /* no ordering for this attribute */
need_compare_fn = 1; /* get compare func for this attr */
do_continue = 1; /* done with j - next j */
diff --git a/ldap/servers/slapd/match.c b/ldap/servers/slapd/match.c
index 91fa0a8..fe5e365 100644
--- a/ldap/servers/slapd/match.c
+++ b/ldap/servers/slapd/match.c
@@ -333,3 +333,42 @@ int slapi_matchingrule_is_compat(const char *mr_oid_or_name, const
char *syntax_
return 0;
}
+
+/* the matching rules defined in the collation plugin
+ all start with this OID
+*/
+#define COLLATION_BASE_OID "2.16.840.1.113730.3.3.2."
+#define COLLATION_BASE_OID_LEN 24
+
+/*
+ See if a matching rule for this name or OID
+ can use a simple compare function for generating index entries
+*/
+int slapi_matchingrule_can_use_compare_fn(const char *mr_oid_or_name)
+{
+ struct matchingRuleList *mrl=NULL;
+ int found = 0;
+
+ for (mrl = g_get_global_mrl(); mrl != NULL; mrl = mrl->mrl_next) {
+ if (mrl->mr_entry->mr_name && !strcasecmp(mr_oid_or_name,
mrl->mr_entry->mr_name)) {
+ found = 1;
+ break;
+ }
+ if (mrl->mr_entry->mr_oid && !strcmp(mr_oid_or_name,
mrl->mr_entry->mr_oid)) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found) {
+ return 0;
+ }
+
+ if (!strncmp(mrl->mr_entry->mr_oid, COLLATION_BASE_OID,
COLLATION_BASE_OID_LEN)) {
+ /* this OID is provided by the collation plugin so we can't just
+ use a simple compare function to generate index keys */
+ return 0;
+ }
+
+ return 1;
+}
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index f0be0a6..8531fbe 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -4659,6 +4659,18 @@ int slapi_matchingrule_is_ordering(const char *oid_or_name, const
char *syntax_o
*/
int slapi_matchingrule_is_compat(const char *mr_oid_or_name, const char *syntax_oid);
+/**
+ * In certain cases, we can just use a simple compare function to
+ * generate index keys. The compare function is usually provided
+ * by the syntax plugin. If this is the case, we can skip generating
+ * an indexer in the index config code.
+ *
+ * \param mr_name_or_oid Name or OID of a matching rule
+ * \return \c TRUE if the matching rule can use a simple compare function
+ * \return \c FALSE otherwise
+ */
+int slapi_matchingrule_can_use_compare_fn(const char *mr_oid_or_name);
+
/*
* access control
*/
commit e98229a602b3acfafd616afda743d268dae42ff2
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Wed Mar 30 20:00:27 2011 -0600
Bug 692331 - Segfault on index update during full replication push on 1.2.7.5
https://bugzilla.redhat.com/show_bug.cgi?id=692331
Resolves: bug 692331
Bug Description: Segfault on index update during full replication push on 1.2.7.5
Reviewed by: nkinder (Thanks!)
Branch: 389-ds-base-1.2.8
Fix Description: The collation plugin still uses the old style index key
generation function that uses struct berval **. If we don't find a new
style index key function that uses Slapi_Value**, wrap the old function
to convert Slapi_Value** to struct berval **
The plugin_mr code keeps track of the Slapi_Value**. The old style
collation code keeps track of and deletes the struct berval** values.
We store the output keys in the MR_KEYS pblock field and free them
in the indexer destroyer code. The new style mr indexer code sets
MR_KEYS to NULL so the indexer destroyer code won't try to free them
again.
Steps to reproduce:
1) find or create an attribute which has an ORDERING matching rule
(and not via inheritance - that's another bug)
2) add or change the index for the attribute to have an nsMatchingRule
with one of the l10n matching rules defined by the collation plugin
e.g. 2.16.840.1.113730.3.3.2.11.1 for en or en-US
3) add an entry which has that attribute and a valid value
4) do an import or re-index
It crashes in matchrule_values_to_keys_sv because mrINDEX is NULL
because the old style collation plugin indexer does not support
Slapi_Values.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
squash with previous commit
(cherry picked from commit 62a7368e3aed00b44d9f1828b9235d0a2d7572cd)
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index 03ea5e4..a4bd8a2 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -2001,6 +2001,7 @@ index_addordel_values_ext_sv(
{
Slapi_Value** keys = NULL;
matchrule_values_to_keys_sv(pb,vals,&keys);
+ /* the matching rule indexer owns keys now */
if(keys != NULL && keys[0] != NULL)
{
/* we've computed keys */
@@ -2008,16 +2009,17 @@ index_addordel_values_ext_sv(
if ( err != 0 )
{
ldbm_nasty(errmsg, 1260, err);
- slapi_ch_free((void **)&keys);
- goto bad;
}
}
/*
* It would improve speed to save the indexer, for future use.
* But, for simplicity, we destroy it now:
*/
+ /* this will also free keys */
destroy_matchrule_indexer(pb);
- slapi_ch_free((void **)&keys);
+ if ( err != 0 ) {
+ goto bad;
+ }
}
}
}
diff --git a/ldap/servers/slapd/back-ldbm/matchrule.c
b/ldap/servers/slapd/back-ldbm/matchrule.c
index 043c968..7af42f4 100644
--- a/ldap/servers/slapd/back-ldbm/matchrule.c
+++ b/ldap/servers/slapd/back-ldbm/matchrule.c
@@ -118,6 +118,7 @@ create_matchrule_indexer(Slapi_PBlock **pb,char* matchrule,char*
type)
int
destroy_matchrule_indexer(Slapi_PBlock *pb)
{
+ Slapi_Value **keys = NULL;
IFP mrDESTROY = NULL;
if (!slapi_pblock_get (pb, SLAPI_PLUGIN_DESTROY_FN, &mrDESTROY))
{
@@ -126,6 +127,18 @@ destroy_matchrule_indexer(Slapi_PBlock *pb)
mrDESTROY (pb);
}
}
+ /* matching rule indexers which handle Slapi_Value**
+ directly will own the keys, free them, and set
+ SLAPI_PLUGIN_MR_KEYS to NULL in the destroy
+ function - the old style matching rule indexers
+ which only deal with struct berval ** will not
+ free the Slapi_Value** wrappers so we have to free
+ them here */
+ slapi_pblock_get(pb, SLAPI_PLUGIN_MR_KEYS, &keys);
+ if (keys) {
+ valuearray_free(&keys);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_KEYS, NULL);
+ }
return 0;
}
@@ -158,6 +171,19 @@ matchrule_values_to_keys_sv(Slapi_PBlock *pb,Slapi_Value
**input_values,Slapi_Va
IFP mrINDEX = NULL;
slapi_pblock_get (pb, SLAPI_PLUGIN_MR_INDEX_SV_FN, &mrINDEX);
+ if (NULL == mrINDEX) { /* old school - does not have SV function */
+ int rc;
+ struct berval **bvi = NULL, **bvo = NULL;
+ valuearray_get_bervalarray(input_values, &bvi);
+ rc = matchrule_values_to_keys(pb, bvi, &bvo);
+ ber_bvecfree(bvi);
+ /* note - the indexer owns bvo and will free it when destroyed */
+ valuearray_init_bervalarray(bvo, output_values);
+ /* store output values in SV form - caller expects SLAPI_PLUGIN_MR_KEYS is
Slapi_Value** */
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_KEYS, *output_values);
+ return rc;
+ }
+
slapi_pblock_set (pb, SLAPI_PLUGIN_MR_VALUES, input_values);
mrINDEX (pb);
slapi_pblock_get (pb, SLAPI_PLUGIN_MR_KEYS, output_values);
diff --git a/ldap/servers/slapd/plugin_mr.c b/ldap/servers/slapd/plugin_mr.c
index 7590f26..12dece7 100644
--- a/ldap/servers/slapd/plugin_mr.c
+++ b/ldap/servers/slapd/plugin_mr.c
@@ -634,6 +634,8 @@ default_mr_indexer_destroy(Slapi_PBlock* pb)
mr_private_free(&mrpriv);
mrpriv = NULL;
slapi_pblock_set(pb, SLAPI_PLUGIN_OBJECT, mrpriv);
+ /* keys destroyed in mr_private_free */
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_KEYS, NULL);
return 0;
}