[Fedora-directory-commits] ldapserver/ldap/servers/slapd match.c, 1.5, 1.6 slap.h, 1.26, 1.27 slapi-plugin.h, 1.16, 1.17

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Tue Oct 2 18:39:53 UTC 2007


Author: rmeggins

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8531/ldapserver/ldap/servers/slapd

Modified Files:
	match.c slap.h slapi-plugin.h 
Log Message:
Resolves: bug 249366
Bug Description: rhds71 - search filters returns too many entries on integer attributes value greater than 2 to the power of 31
Reviewed by: nkinder, nhosoi (Thanks!)
Fix Description: The way >= and <= searches are supposed to work in LDAP is that you are supposed to define an ORDERING matching rule for the attribute you want to use in the search filter.  The way our code is written, most strings "just work" as a side effect of the way bdb sorts the keys by default - so you can do (uid>=jvedder) and get what you would expect, even though LDAP says this is illegal because the schema definition of the uid attribute does not have an ORDERING matching rule.  And INTEGER worked with the old binary format for the same reason.  The only attribute definitions we use with ORDERING are attributes that use Generalized Time syntax (e.g. createTimestamp, et. al.) and numSubordinates (which uses INTEGER, but this is a special case handled internally by the db code).
The way it works now is that the indexing code will honor the ORDERING matching rule specified in the schema definition.  Or, if ORDERING is not specified, the user can use the nsMatchingRule index configuration.  This will allow an existing customer that depends all integer syntax attributes (e.g. uidNumber) to allow range searches by default to enable range searches without editing the schema.  The syntax definition for the attribute must also specify a compare function.  This compare function will be used by the bdb bt_compare() function.
I also fixed a bug in the integer normalize code - a string of all zeros should normalize to a single "0".  In all other cases, the leading zeros should be removed.
Platforms tested: RHEL5 x86_64
Flag Day: Yes.  Integer indexes will need to be rebuilt (except for numsubordinates).
Doc impact: Yes - document slapi API additions
QA impact: Pay close attention to tests that use >= or <= search filters, both with and without index attributes.  Also, pay close attention to greater/less than searches using i18n collations.
New Tests integrated into TET: Forthcoming



Index: match.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/match.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- match.c	10 Nov 2006 23:45:40 -0000	1.5
+++ match.c	2 Oct 2007 18:39:50 -0000	1.6
@@ -270,5 +270,26 @@
     return(0);
 }
 
+/*
+  See if a matching rule for this name or OID
+  is registered and is an ORDERING matching rule that applies
+  to the given syntax.
+*/
+int slapi_matchingrule_is_ordering(const char *oid_or_name, const char *syntax_oid)
+{
+    struct matchingRuleList *mrl=NULL;
+    for (mrl = g_get_global_mrl(); mrl != NULL; mrl = mrl->mrl_next) {
+        if (mrl->mr_entry->mr_name && !strcasecmp(oid_or_name, mrl->mr_entry->mr_name)) {
+            return (mrl->mr_entry->mr_name &&
+                    PL_strcasestr(mrl->mr_entry->mr_name, "ordering") &&
+                    !strcmp(mrl->mr_entry->mr_syntax, syntax_oid));
+        }
+        if (mrl->mr_entry->mr_oid && !strcmp(oid_or_name, mrl->mr_entry->mr_oid)) {
+            return (mrl->mr_entry->mr_name &&
+                    PL_strcasestr(mrl->mr_entry->mr_name, "ordering") &&
+                    !strcmp(mrl->mr_entry->mr_syntax, syntax_oid));
+        }
+    }
 
-
+    return 0;
+}


Index: slap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slap.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- slap.h	7 Sep 2007 19:08:45 -0000	1.26
+++ slap.h	2 Oct 2007 18:39:50 -0000	1.27
@@ -616,15 +616,6 @@
 	struct objclass		*oc_next;
 };
 
-typedef struct slapi_matchingRuleEntry {
-    char *mr_oid;
-    char *mr_oidalias;
-    char *mr_name;
-    char *mr_desc;
-    char *mr_syntax;
-    int mr_obsolete;
-} slapi_matchingRuleEntry;
- 
 struct matchingRuleList {
     Slapi_MatchingRuleEntry *mr_entry;
     struct matchingRuleList *mrl_next;


Index: slapi-plugin.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-plugin.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- slapi-plugin.h	30 Aug 2007 15:56:36 -0000	1.16
+++ slapi-plugin.h	2 Oct 2007 18:39:50 -0000	1.17
@@ -140,7 +140,6 @@
 typedef struct slapi_value  		Slapi_Value;
 typedef struct slapi_value_set  	Slapi_ValueSet;
 typedef struct slapi_filter		Slapi_Filter;
-typedef struct slapi_matchingRuleEntry	Slapi_MatchingRuleEntry;
 typedef struct backend			Slapi_Backend;
 typedef struct _guid_t			Slapi_UniqueID;
 typedef struct op			Slapi_Operation;
@@ -645,6 +644,16 @@
 #define SLAPI_BERVAL_EQ(L,R) ((L)->bv_len == (R)->bv_len && \
         ! memcmp ((L)->bv_val, (R)->bv_val, (L)->bv_len))
 
+typedef struct slapi_matchingRuleEntry {
+    char *mr_oid;
+    char *mr_oidalias;
+    char *mr_name;
+    char *mr_desc;
+    char *mr_syntax;
+    int mr_obsolete;
+} slapi_matchingRuleEntry;
+typedef struct slapi_matchingRuleEntry	Slapi_MatchingRuleEntry;
+
 Slapi_MatchingRuleEntry *slapi_matchingrule_new(void);
 void slapi_matchingrule_free(Slapi_MatchingRuleEntry **mrEntry,
                              int freeMembers);
@@ -652,6 +661,7 @@
 int slapi_matchingrule_set(Slapi_MatchingRuleEntry *mr, int arg, void *value);
 int slapi_matchingrule_register(Slapi_MatchingRuleEntry *mrEntry);
 int slapi_matchingrule_unregister(char *oid);
+int slapi_matchingrule_is_ordering(const char *oid_or_name, const char *syntax_oid);
 
 /*
  * access control




More information about the Fedora-directory-commits mailing list