Commit 923d033c authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Finish adding subclassing indexing support

parent 1086ffb4
......@@ -200,14 +200,14 @@ int octetStringFilter(
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
void * assertedValue,
BerVarray *keysp )
{
size_t slen, mlen;
BerVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval *value = (struct berval *) assertValue;
struct berval *value = (struct berval *) assertedValue;
struct berval digest;
digest.bv_val = HASHdigest;
digest.bv_len = sizeof(HASHdigest);
......@@ -931,7 +931,7 @@ approxFilter(
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
void * assertedValue,
BerVarray *keysp )
{
char *c;
......@@ -940,7 +940,7 @@ approxFilter(
BerVarray keys;
/* Yes, this is necessary */
val = UTF8bvnormalize( ((struct berval *)assertValue),
val = UTF8bvnormalize( ((struct berval *)assertedValue),
NULL, LDAP_UTF8_APPROX );
if( val == NULL || val->bv_val == NULL ) {
keys = (struct berval *)ch_malloc( sizeof(struct berval) );
......@@ -1070,7 +1070,7 @@ approxFilter(
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
void * assertedValue,
BerVarray *keysp )
{
BerVarray keys;
......@@ -1079,7 +1079,7 @@ approxFilter(
keys = (struct berval *)ch_malloc( sizeof( struct berval * ) * 2 );
/* Yes, this is necessary */
s = UTF8normalize( ((struct berval *)assertValue),
s = UTF8normalize( ((struct berval *)assertedValue),
UTF8_NOCASEFOLD );
if( s == NULL ) {
keys[0] = NULL;
......@@ -1335,7 +1335,7 @@ static int caseExactIgnoreFilter(
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
void * assertedValue,
BerVarray *keysp )
{
unsigned casefold;
......@@ -1355,7 +1355,7 @@ static int caseExactIgnoreFilter(
casefold = ( mr != caseExactMatchingRule )
? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
UTF8bvnormalize( (struct berval *) assertValue, &value, casefold );
UTF8bvnormalize( (struct berval *) assertedValue, &value, casefold );
/* This usually happens if filter contains bad UTF8 */
if( value.bv_val == NULL ) {
keys = ch_malloc( sizeof( struct berval ) );
......@@ -1574,7 +1574,7 @@ static int caseExactIgnoreSubstringsFilter(
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
void * assertedValue,
BerVarray *keysp )
{
SubstringsAssertion *sa;
......@@ -1591,7 +1591,7 @@ static int caseExactIgnoreSubstringsFilter(
casefold = ( mr != caseExactSubstringsMatchingRule )
? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
sa = UTF8SubstringsassertionNormalize( assertValue, casefold );
sa = UTF8SubstringsassertionNormalize( assertedValue, casefold );
if( sa == NULL ) {
*keysp = NULL;
return LDAP_SUCCESS;
......@@ -2023,7 +2023,7 @@ static int integerFilter(
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
void * assertedValue,
BerVarray *keysp )
{
size_t slen, mlen;
......@@ -2038,7 +2038,7 @@ static int integerFilter(
slen = syntax->ssyn_oidlen;
mlen = mr->smr_oidlen;
integerNormalize( syntax, assertValue, &norm );
integerNormalize( syntax, assertedValue, &norm );
keys = ch_malloc( sizeof( struct berval ) * 2 );
......@@ -2417,7 +2417,7 @@ static int caseExactIA5Filter(
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
void * assertedValue,
BerVarray *keysp )
{
size_t slen, mlen;
......@@ -2432,7 +2432,7 @@ static int caseExactIA5Filter(
slen = syntax->ssyn_oidlen;
mlen = mr->smr_oidlen;
value = (struct berval *) assertValue;
value = (struct berval *) assertedValue;
keys = ch_malloc( sizeof( struct berval ) * 2 );
......@@ -2623,10 +2623,10 @@ static int caseExactIA5SubstringsFilter(
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
void * assertedValue,
BerVarray *keysp )
{
SubstringsAssertion *sa = assertValue;
SubstringsAssertion *sa = assertedValue;
char pre;
ber_len_t nkeys = 0;
size_t slen, mlen, klen;
......@@ -3004,7 +3004,7 @@ static int caseIgnoreIA5Filter(
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
void * assertedValue,
BerVarray *keysp )
{
size_t slen, mlen;
......@@ -3019,7 +3019,7 @@ static int caseIgnoreIA5Filter(
slen = syntax->ssyn_oidlen;
mlen = mr->smr_oidlen;
ber_dupbv( &value, (struct berval *) assertValue );
ber_dupbv( &value, (struct berval *) assertedValue );
ldap_pvt_str2lower( value.bv_val );
keys = ch_malloc( sizeof( struct berval ) * 2 );
......@@ -3218,10 +3218,10 @@ static int caseIgnoreIA5SubstringsFilter(
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
void * assertedValue,
BerVarray *keysp )
{
SubstringsAssertion *sa = assertValue;
SubstringsAssertion *sa = assertedValue;
char pre;
ber_len_t nkeys = 0;
size_t slen, mlen, klen;
......@@ -3917,13 +3917,13 @@ static int certificateExactFilter(
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
void * assertedValue,
BerVarray *keysp )
{
BerVarray keys;
struct berval asserted_serial;
serial_and_issuer_parse(assertValue,
serial_and_issuer_parse(assertedValue,
&asserted_serial,
NULL);
......
......@@ -17,6 +17,8 @@
#include "ldap_pvt.h"
#include "ldap_pvt_uc.h"
#define OCDEBUG 0
int schema_init_done = 0;
struct slap_internal_schema slap_schema;
......@@ -36,7 +38,7 @@ static int objectClassNormalize(
ber_dupbv( out, in );
}
#if 0
#if OCDEBUG
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, ENTRY,
"< objectClassNormalize(%s, %s)\n", in->bv_val, out->bv_val, 0 );
......@@ -62,7 +64,7 @@ objectSubClassMatch(
ObjectClass *oc = oc_bvfind( value );
ObjectClass *asserted = oc_bvfind( a );
#if 0
#if OCDEBUG
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, ENTRY,
"> objectSubClassMatch(%s, %s)\n", value->bv_val, a->bv_val, 0 );
......@@ -94,7 +96,7 @@ objectSubClassMatch(
*matchp = !is_object_subclass( asserted, oc );
}
#if 0
#if OCDEBUG
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, ENTRY,
"< objectSubClassMatch(%s, %s) = %d\n",
......@@ -121,26 +123,33 @@ static int objectSubClassIndexer(
BerVarray ocvalues;
for( noc=0; values[noc].bv_val != NULL; noc++ ) {
#if 0
/* just count em */;
}
/* over allocate */
ocvalues = ch_malloc( sizeof( struct berval ) * (noc+16) );
/* copy listed values (and termination) */
for( i=0; i<noc; i++ ) {
ObjectClass *oc = oc_bvfind( &values[i] );
if( oc ) {
ocvalues[i] = oc->soc_cname;
} else {
ocvalues[i] = values[i];
}
#if OCDEBUG
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, ENTRY,
"> objectSubClassIndexer(%d, %s)\n",
noc, values[noc].bv_val, 0 );
i, ocvalues[i].bv_val, 0 );
#else
Debug( LDAP_DEBUG_TRACE,
"> objectSubClassIndexer(%d, %s)\n",
noc, values[noc].bv_val, 0 );
i, ocvalues[i].bv_val, 0 );
#endif
#endif
/* just count em */;
}
/* over allocate */
ocvalues = ch_malloc( sizeof( struct berval ) * (noc+16) );
/* copy listed values (and termination) */
AC_MEMCPY( ocvalues, values, sizeof( struct berval ) * noc+1 );
/* expand values */
for( i=0; i<noc; i++ ) {
int j;
......@@ -187,7 +196,7 @@ static int objectSubClassIndexer(
ocvalues[noc].bv_len = 0;
ocvalues[noc].bv_val = NULL;
#if 0
#if OCDEBUG
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, ENTRY,
"< objectSubClassIndexer(%d, %d, %s)\n",
......@@ -219,7 +228,35 @@ static int objectSubClassIndexer(
return rc;
}
#define objectSubClassFilter octetStringFilter
/* Index generation function */
static int objectSubClassFilter(
slap_mask_t use,
slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
void * assertedValue,
BerVarray *keysp )
{
#if OCDEBUG
struct berval *bv = (struct berval *) assertedValue;
ObjectClass *oc = oc_bvfind( bv );
if( oc ) {
bv = &oc->soc_cname;
}
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, ENTRY,
"< objectSubClassFilter(%s)\n", bv->bv_val, 0, 0 );
#else
Debug( LDAP_DEBUG_TRACE, "< objectSubClassFilter(%s)\n",
bv->bv_val, 0, 0 );
#endif
#endif
return octetStringFilter( use, flags, syntax, mr,
prefix, assertedValue, keysp );
}
static ObjectClassSchemaCheckFN rootDseObjectClass;
static ObjectClassSchemaCheckFN aliasObjectClass;
......@@ -320,7 +357,7 @@ static struct slap_schema_ad_map {
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
NULL, SLAP_AT_FINAL,
NULL, objectClassNormalize, objectSubClassMatch,
objectSubClassIndexer, NULL,
objectSubClassIndexer, objectSubClassFilter,
offsetof(struct slap_internal_schema, si_ad_objectClass) },
/* user entry operational attributes */
......@@ -331,7 +368,7 @@ static struct slap_schema_ad_map {
"SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
NULL, 0,
NULL, objectClassNormalize, objectSubClassMatch,
objectSubClassIndexer, NULL,
objectSubClassIndexer, objectSubClassFilter,
offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },
{ "createTimestamp", "( 2.5.18.1 NAME 'createTimestamp' "
"DESC 'RFC2252: time which object was created' "
......@@ -851,25 +888,31 @@ slap_schema_load( void )
(*adp)->ad_type->sat_flags |= ad_map[i].ssam_flags;
/* install custom rule routine */
if( ad_map[i].ssam_convert ) {
(*adp)->ad_type->sat_equality->smr_convert
= ad_map[i].ssam_convert;
}
if( ad_map[i].ssam_normalize ) {
(*adp)->ad_type->sat_equality->smr_normalize
= ad_map[i].ssam_normalize;
}
if( ad_map[i].ssam_match ) {
(*adp)->ad_type->sat_equality->smr_match
= ad_map[i].ssam_match;
}
if( ad_map[i].ssam_indexer ) {
(*adp)->ad_type->sat_equality->smr_indexer
= ad_map[i].ssam_indexer;
}
if( ad_map[i].ssam_filter ) {
(*adp)->ad_type->sat_equality->smr_filter
= ad_map[i].ssam_filter;
if( ad_map[i].ssam_convert ||
ad_map[i].ssam_normalize ||
ad_map[i].ssam_match ||
ad_map[i].ssam_indexer ||
ad_map[i].ssam_filter )
{
MatchingRule *mr = ch_malloc( sizeof( MatchingRule ) );
*mr = *(*adp)->ad_type->sat_equality;
(*adp)->ad_type->sat_equality = mr;
if( ad_map[i].ssam_convert ) {
mr->smr_convert = ad_map[i].ssam_convert;
}
if( ad_map[i].ssam_normalize ) {
mr->smr_normalize = ad_map[i].ssam_normalize;
}
if( ad_map[i].ssam_match ) {
mr->smr_match = ad_map[i].ssam_match;
}
if( ad_map[i].ssam_indexer ) {
mr->smr_indexer = ad_map[i].ssam_indexer;
}
if( ad_map[i].ssam_filter ) {
mr->smr_filter = ad_map[i].ssam_filter;
}
}
}
}
......
......@@ -264,3 +264,8 @@ postaladdress: University of Michigan $ 535 W. William St. $ Ann Arbor, MI 481
telephonenumber: +1 313 764-1817
associateddomain: umich.edu
dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,o=University of Michiga
n,c=US
objectClass: OpenLDAPperson
uid: uham
......@@ -19,5 +19,5 @@ suffix "o=University of Michigan,c=US"
directory ./test-db
rootdn "cn=Manager,o=University of Michigan,c=US"
rootpw secret
#ldbm#index objectClass eq
#bdb#index objectClass eq
# #ldbm#index objectClass eq
# #bdb#index objectClass eq
......@@ -54,7 +54,7 @@ fi
echo "Testing slapd searching..."
for i in 0 1 2 3 4 5; do
$LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT \
'objectclass=*' > /dev/null 2>&1
'(objectclass=*)' > /dev/null 2>&1
RC=$?
if test $RC = 1 ; then
echo "Waiting 5 seconds for slapd to start..."
......@@ -72,7 +72,7 @@ cat /dev/null > $SEARCHOUT
echo "Testing exact searching..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
'sn=jensen' >> $SEARCHOUT 2>&1
'(sn=jensen)' >> $SEARCHOUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed ($RC)!"
......@@ -104,14 +104,25 @@ echo "Testing NOT searching..."
$LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
'(!(objectclass=pilotPerson))' >> $SEARCHOUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed ($RC)!"
kill -HUP $PID
exit $RC
fi
kill -HUP $PID
echo "Testing objectClass/attributeType inheritance ..."
$LDAPSEARCH -M -a never -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
'(&(objectClass=inetorgperson)(uid=uham))' \
"2.5.4.0" "userid" >> $SEARCHOUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed ($RC)!"
kill -HUP $PID
exit $RC
fi
kill -HUP $PID
LDIF=$SEARCHOUTMASTER
echo "Filtering ldapsearch results..."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment