]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_init.c
More system schema checks
[openldap] / servers / slapd / schema_init.c
index 558a528abf7a51015345fb18905c5e4bd7c9742c..cfd141b2fcba882a814eb77db8dc1ce76c30d46d 100644 (file)
@@ -1,7 +1,7 @@
 /* schema_init.c - init builtin schema */
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
@@ -123,19 +123,19 @@ static int octetStringIndexer(
        Syntax *syntax,
        MatchingRule *mr,
        struct berval *prefix,
-       struct berval **values,
-       struct berval **keysp )
+       BVarray values,
+       BVarray *keysp )
 {
        int i;
        size_t slen, mlen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval digest;
        digest.bv_val = HASHdigest;
        digest.bv_len = sizeof(HASHdigest);
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* just count them */
        }
 
@@ -147,7 +147,7 @@ static int octetStringIndexer(
        slen = syntax->ssyn_oidlen;
        mlen = mr->smr_oidlen;
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                HASH_Init( &HASHcontext );
                if( prefix != NULL && prefix->bv_len > 0 ) {
                        HASH_Update( &HASHcontext,
@@ -158,7 +158,7 @@ static int octetStringIndexer(
                HASH_Update( &HASHcontext,
                        mr->smr_oid, mlen );
                HASH_Update( &HASHcontext,
-                       values[i]->bv_val, values[i]->bv_len );
+                       values[i].bv_val, values[i].bv_len );
                HASH_Final( HASHdigest, &HASHcontext );
 
                ber_dupbv( &keys[i], &digest );
@@ -179,10 +179,10 @@ static int octetStringFilter(
        MatchingRule *mr,
        struct berval *prefix,
        void * assertValue,
-       struct berval **keysp )
+       BVarray *keysp )
 {
        size_t slen, mlen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval *value = (struct berval *) assertValue;
@@ -222,38 +222,38 @@ nameUIDValidate(
        struct berval *in )
 {
        int rc;
-       struct berval *dn;
+       struct berval dn;
 
        if( in->bv_len == 0 ) return LDAP_SUCCESS;
 
-       dn = ber_bvdup( in );
-       if( !dn ) return LDAP_OTHER;
+       ber_dupbv( &dn, in );
+       if( !dn.bv_val ) return LDAP_OTHER;
 
-       if( dn->bv_val[dn->bv_len-1] == 'B'
-               && dn->bv_val[dn->bv_len-2] == '\'' )
+       if( dn.bv_val[dn.bv_len-1] == 'B'
+               && dn.bv_val[dn.bv_len-2] == '\'' )
        {
                /* assume presence of optional UID */
                ber_len_t i;
 
-               for(i=dn->bv_len-3; i>1; i--) {
-                       if( dn->bv_val[i] != '0' &&     dn->bv_val[i] != '1' ) {
+               for(i=dn.bv_len-3; i>1; i--) {
+                       if( dn.bv_val[i] != '0' &&      dn.bv_val[i] != '1' ) {
                                break;
                        }
                }
-               if( dn->bv_val[i] != '\'' ||
-                   dn->bv_val[i-1] != '#' ) {
-                       ber_bvfree( dn );
+               if( dn.bv_val[i] != '\'' ||
+                   dn.bv_val[i-1] != '#' ) {
+                       ber_memfree( dn.bv_val );
                        return LDAP_INVALID_SYNTAX;
                }
 
                /* trim the UID to allow use of dnValidate */
-               dn->bv_val[i-1] = '\0';
-               dn->bv_len = i-1;
+               dn.bv_val[i-1] = '\0';
+               dn.bv_len = i-1;
        }
 
-       rc = dnValidate( NULL, dn );
+       rc = dnValidate( NULL, &dn );
 
-       ber_bvfree( dn );
+       ber_memfree( &dn );
        return rc;
 }
 
@@ -303,12 +303,12 @@ nameUIDNormalize(
                if( uidlen ) {
                        struct berval b2;
                        b2.bv_val = ch_malloc(dnlen + uidlen + 1);
-                       SAFEMEMCPY( b2.bv_val, normalized->bv_val, dnlen );
+                       AC_MEMCPY( b2.bv_val, normalized->bv_val, dnlen );
 
                        /* restore the separator */
                        *uid = '#';
                        /* shift the UID */
-                       SAFEMEMCPY( normalized->bv_val+dnlen, uid, uidlen );
+                       AC_MEMCPY( normalized->bv_val+dnlen, uid, uidlen );
                        b2.bv_len = dnlen + uidlen;
                        normalized->bv_val[dnlen+uidlen] = '\0';
                        free(normalized->bv_val);
@@ -493,12 +493,14 @@ UTF8StringNormalize(
        struct berval *normalized )
 {
        char *p, *q, *s;
+       int len = 0;
 
        p = val->bv_val;
 
        /* Ignore initial whitespace */
-       while ( ldap_utf8_isspace( p ) ) {
-               LDAP_UTF8_INCR( p );
+       /* All space is ASCII. All ASCII is 1 byte */
+       while ( ASCII_SPACE( *p ) ) {
+               p++;
        }
 
        if( *p == '\0' ) {
@@ -513,31 +515,28 @@ UTF8StringNormalize(
        s = NULL;
 
        while ( *p ) {
-               int len;
-
-               if ( ldap_utf8_isspace( p ) ) {
-                       len = LDAP_UTF8_COPY(q,p);
-                       s=q;
-                       p+=len;
-                       q+=len;
+               q += len;
+               if ( ASCII_SPACE( *p ) ) {
+                       s = q - len;
+                       len = 1;
+                       *q = *p++;
 
                        /* Ignore the extra whitespace */
-                       while ( ldap_utf8_isspace( p ) ) {
-                               LDAP_UTF8_INCR( p );
+                       while ( ASCII_SPACE( *p ) ) {
+                               p++;
                        }
                } else {
                        len = LDAP_UTF8_COPY(q,p);
                        s=NULL;
                        p+=len;
-                       q+=len;
                }
        }
 
        assert( normalized->bv_val < p );
-       assert( q <= p );
+       assert( q+len <= p );
 
        /* cannot start with a space */
-       assert( !ldap_utf8_isspace(normalized->bv_val) );
+       assert( !ASCII_SPACE(normalized->bv_val[0]) );
 
        /*
         * If the string ended in space, backup the pointer one
@@ -546,11 +545,14 @@ UTF8StringNormalize(
         */
 
        if ( s != NULL ) {
+               len = q - s;
                q = s;
        }
 
        /* cannot end with a space */
-       assert( !ldap_utf8_isspace( LDAP_UTF8_PREV(q) ) );
+       assert( !ASCII_SPACE( *q ) );
+
+       q += len;
 
        /* null terminate */
        *q = '\0';
@@ -560,12 +562,12 @@ UTF8StringNormalize(
        return LDAP_SUCCESS;
 }
 
-/* Returns Unicode cannonically normalized copy of a substring assertion
+/* Returns Unicode canonically normalized copy of a substring assertion
  * Skipping attribute description */
 static SubstringsAssertion *
 UTF8SubstringsassertionNormalize(
        SubstringsAssertion *sa,
-       char casefold )
+       unsigned casefold )
 {
        SubstringsAssertion *nsa;
        int i;
@@ -632,7 +634,7 @@ strip8bitChars(
                        while( *++q & 0x80 ) {
                                /* empty */
                        }
-                       p = memmove(p, q, strlen(q) + 1);
+                       p = AC_MEMCPY(p, q, strlen(q) + 1);
                } else {
                        p++;
                }
@@ -664,7 +666,7 @@ approxMatch(
        size_t avlen;
 
        /* Yes, this is necessary */
-       nval = UTF8normalize( value, UTF8_NOCASEFOLD );
+       nval = UTF8normalize( value, LDAP_UTF8_NOCASEFOLD );
        if( nval == NULL ) {
                *matchp = 1;
                return LDAP_SUCCESS;
@@ -673,7 +675,7 @@ approxMatch(
 
        /* Yes, this is necessary */
        assertv = UTF8normalize( ((struct berval *)assertedValue),
-                                UTF8_NOCASEFOLD );
+               LDAP_UTF8_NOCASEFOLD );
        if( assertv == NULL ) {
                ch_free( nval );
                *matchp = 1;
@@ -769,16 +771,17 @@ approxIndexer(
        Syntax *syntax,
        MatchingRule *mr,
        struct berval *prefix,
-       struct berval **values,
-       struct berval **keysp )
+       BVarray values,
+       BVarray *keysp )
 {
        char *val, *c;
        int i,j, len, wordcount, keycount=0;
-       struct berval *newkeys, *keys=NULL;
+       struct berval *newkeys;
+       BVarray keys=NULL;
 
-       for( j=0; values[j] != NULL; j++ ) {
+       for( j=0; values[j].bv_val != NULL; j++ ) {
                /* Yes, this is necessary */
-               val = UTF8normalize( values[j], UTF8_NOCASEFOLD );
+               val = UTF8normalize( &values[j], LDAP_UTF8_NOCASEFOLD );
                strip8bitChars( val );
 
                /* Isolate how many words there are. There will be a key for each */
@@ -793,7 +796,7 @@ approxIndexer(
                /* Allocate/increase storage to account for new keys */
                newkeys = (struct berval *)ch_malloc( (keycount + wordcount + 1) 
                        * sizeof(struct berval) );
-               memcpy( newkeys, keys, keycount * sizeof(struct berval) );
+               AC_MEMCPY( newkeys, keys, keycount * sizeof(struct berval) );
                if( keys ) ch_free( keys );
                keys = newkeys;
 
@@ -822,15 +825,15 @@ approxFilter(
        MatchingRule *mr,
        struct berval *prefix,
        void * assertValue,
-       struct berval **keysp )
+       BVarray *keysp )
 {
        char *val, *c;
        int i, count, len;
-       struct berval *keys;
+       BVarray keys;
 
        /* Yes, this is necessary */
        val = UTF8normalize( ((struct berval *)assertValue),
-                            UTF8_NOCASEFOLD );
+               LDAP_UTF8_NOCASEFOLD );
        if( val == NULL ) {
                keys = (struct berval *)ch_malloc( sizeof(struct berval) );
                keys[0].bv_val = NULL;
@@ -920,14 +923,14 @@ approxIndexer(
        Syntax *syntax,
        MatchingRule *mr,
        struct berval *prefix,
-       struct berval **values,
-       struct berval **keysp )
+       BVarray values,
+       BVarray *keysp )
 {
        int i;
-       struct berval *keys;
+       BVarray *keys;
        char *s;
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* empty - just count them */
        }
 
@@ -937,9 +940,9 @@ approxIndexer(
        keys = (struct berval *)ch_malloc( sizeof( struct berval ) * (i+1) );
 
        /* Copy each value and run it through phonetic() */
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* Yes, this is necessary */
-               s = UTF8normalize( values[i], UTF8_NOCASEFOLD );
+               s = UTF8normalize( &values[i], UTF8_NOCASEFOLD );
 
                /* strip 8-bit chars and run through phonetic() */
                ber_str2bv( phonetic( strip8bitChars( s ) ), 0, 0, &keys[i] );
@@ -960,9 +963,9 @@ approxFilter(
        MatchingRule *mr,
        struct berval *prefix,
        void * assertValue,
-       struct berval **keysp )
+       BVarray *keysp )
 {
-       struct berval *keys;
+       BVarray keys;
        char *s;
 
        keys = (struct berval *)ch_malloc( sizeof( struct berval * ) * 2 );
@@ -996,7 +999,7 @@ caseExactMatch(
 {
        *matchp = UTF8normcmp( value->bv_val,
                ((struct berval *) assertedValue)->bv_val,
-               UTF8_NOCASEFOLD );
+               LDAP_UTF8_NOCASEFOLD );
        return LDAP_SUCCESS;
 }
 
@@ -1014,10 +1017,11 @@ caseExactIgnoreSubstringsMatch(
        struct berval left;
        int i;
        ber_len_t inlen=0;
-       char *nav, casefold;
+       char *nav;
+       unsigned casefold;
 
        casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
-               ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+               ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
 
        nav = UTF8normalize( value, casefold );
        if( nav == NULL ) {
@@ -1165,20 +1169,20 @@ static int caseExactIgnoreIndexer(
        Syntax *syntax,
        MatchingRule *mr,
        struct berval *prefix,
-       struct berval **values,
-       struct berval **keysp )
+       BVarray values,
+       BVarray *keysp )
 {
        int i;
-       char casefold;
+       unsigned casefold;
        size_t slen, mlen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval digest;
        digest.bv_val = HASHdigest;
        digest.bv_len = sizeof(HASHdigest);
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* empty - just count them */
        }
 
@@ -1191,11 +1195,11 @@ static int caseExactIgnoreIndexer(
        mlen = mr->smr_oidlen;
 
        casefold = strcmp( mr->smr_oid, caseExactMatchOID )
-               ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+               ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                struct berval value;
-               ber_str2bv( UTF8normalize( values[i], casefold ), 0, 0,
+               ber_str2bv( UTF8normalize( &values[i], casefold ), 0, 0,
                        &value );
 
                HASH_Init( &HASHcontext );
@@ -1229,11 +1233,11 @@ static int caseExactIgnoreFilter(
        MatchingRule *mr,
        struct berval *prefix,
        void * assertValue,
-       struct berval **keysp )
+       BVarray *keysp )
 {
-       char casefold;
+       unsigned casefold;
        size_t slen, mlen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval value;
@@ -1245,7 +1249,7 @@ static int caseExactIgnoreFilter(
        mlen = mr->smr_oidlen;
 
        casefold = strcmp( mr->smr_oid, caseExactMatchOID )
-               ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+               ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
 
        ber_str2bv( UTF8normalize( ((struct berval *) assertValue), casefold ),
                0, 0, &value );
@@ -1287,14 +1291,14 @@ static int caseExactIgnoreSubstringsIndexer(
        Syntax *syntax,
        MatchingRule *mr,
        struct berval *prefix,
-       struct berval **values,
-       struct berval **keysp )
+       BVarray values,
+       BVarray *keysp )
 {
-       char casefold;
+       unsigned casefold;
        ber_len_t i, nkeys;
        size_t slen, mlen;
-       struct berval *keys;
-       struct berval **nvalues;
+       BVarray keys;
+       BVarray nvalues;
 
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
@@ -1304,7 +1308,7 @@ static int caseExactIgnoreSubstringsIndexer(
 
        nkeys=0;
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* empty - just count them */
        }
 
@@ -1312,43 +1316,43 @@ static int caseExactIgnoreSubstringsIndexer(
        assert( i > 0 );
 
        casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
-               ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+               ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
 
-       nvalues = ch_malloc( sizeof( struct berval ) * (i+1) );
-       for( i=0; values[i] != NULL; i++ ) {
-               nvalues[i] = ber_str2bv( UTF8normalize( values[i], casefold ),
-                       0, 0, NULL );
+       nvalues = ch_malloc( sizeof( struct berval ) * (i+1) );
+       for( i=0; values[i].bv_val != NULL; i++ ) {
+               ber_str2bv( UTF8normalize( &values[i], casefold ),
+                       0, 0, &nvalues[i] );
        }
-       nvalues[i] = NULL;
+       nvalues[i].bv_val = NULL;
        values = nvalues;
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* count number of indices to generate */
-               if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
+               if( values[i].bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
                        continue;
                }
 
                if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
-                       if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+                       if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
                                nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
                                        ( SLAP_INDEX_SUBSTR_MINLEN - 1);
                        } else {
-                               nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+                               nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
                        }
                }
 
                if( flags & SLAP_INDEX_SUBSTR_ANY ) {
-                       if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
-                               nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
+                       if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+                               nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
                        }
                }
 
                if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
-                       if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+                       if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
                                nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
                                        ( SLAP_INDEX_SUBSTR_MINLEN - 1);
                        } else {
-                               nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+                               nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
                        }
                }
        }
@@ -1356,7 +1360,7 @@ static int caseExactIgnoreSubstringsIndexer(
        if( nkeys == 0 ) {
                /* no keys to generate */
                *keysp = NULL;
-               ber_bvecfree( nvalues );
+               bvarray_free( nvalues );
                return LDAP_SUCCESS;
        }
 
@@ -1366,16 +1370,16 @@ static int caseExactIgnoreSubstringsIndexer(
        mlen = mr->smr_oidlen;
 
        nkeys=0;
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                ber_len_t j,max;
 
-               if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
+               if( values[i].bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
 
                if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
-                       ( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
+                       ( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
                {
                        char pre = SLAP_INDEX_SUBSTR_PREFIX;
-                       max = values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1);
+                       max = values[i].bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1);
 
                        for( j=0; j<max; j++ ) {
                                HASH_Init( &HASHcontext );
@@ -1391,7 +1395,7 @@ static int caseExactIgnoreSubstringsIndexer(
                                HASH_Update( &HASHcontext,
                                        mr->smr_oid, mlen );
                                HASH_Update( &HASHcontext,
-                                       &values[i]->bv_val[j],
+                                       &values[i].bv_val[j],
                                        SLAP_INDEX_SUBSTR_MAXLEN );
                                HASH_Final( HASHdigest, &HASHcontext );
 
@@ -1399,8 +1403,8 @@ static int caseExactIgnoreSubstringsIndexer(
                        }
                }
 
-               max = SLAP_INDEX_SUBSTR_MAXLEN < values[i]->bv_len
-                       ? SLAP_INDEX_SUBSTR_MAXLEN : values[i]->bv_len;
+               max = SLAP_INDEX_SUBSTR_MAXLEN < values[i].bv_len
+                       ? SLAP_INDEX_SUBSTR_MAXLEN : values[i].bv_len;
 
                for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) {
                        char pre;
@@ -1419,7 +1423,7 @@ static int caseExactIgnoreSubstringsIndexer(
                                HASH_Update( &HASHcontext,
                                        mr->smr_oid, mlen );
                                HASH_Update( &HASHcontext,
-                                       values[i]->bv_val, j );
+                                       values[i].bv_val, j );
                                HASH_Final( HASHdigest, &HASHcontext );
 
                                ber_dupbv( &keys[nkeys++], &digest );
@@ -1439,7 +1443,7 @@ static int caseExactIgnoreSubstringsIndexer(
                                HASH_Update( &HASHcontext,
                                        mr->smr_oid, mlen );
                                HASH_Update( &HASHcontext,
-                                       &values[i]->bv_val[values[i]->bv_len-j], j );
+                                       &values[i].bv_val[values[i].bv_len-j], j );
                                HASH_Final( HASHdigest, &HASHcontext );
 
                                ber_dupbv( &keys[nkeys++], &digest );
@@ -1457,7 +1461,7 @@ static int caseExactIgnoreSubstringsIndexer(
                *keysp = NULL;
        }
 
-       ber_bvecfree( nvalues );
+       bvarray_free( nvalues );
 
        return LDAP_SUCCESS;
 }
@@ -1469,20 +1473,21 @@ static int caseExactIgnoreSubstringsFilter(
        MatchingRule *mr,
        struct berval *prefix,
        void * assertValue,
-       struct berval **keysp )
+       BVarray *keysp )
 {
        SubstringsAssertion *sa;
-       char pre, casefold;
+       char pre;
+       unsigned casefold;
        ber_len_t nkeys = 0;
        size_t slen, mlen, klen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval *value;
        struct berval digest;
 
        casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
-               ? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
+               ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
 
        sa = UTF8SubstringsassertionNormalize( assertValue, casefold );
        if( sa == NULL ) {
@@ -1648,7 +1653,7 @@ caseIgnoreMatch(
 {
        *matchp = UTF8normcmp( value->bv_val,
                ((struct berval *) assertedValue)->bv_val,
-               UTF8_CASEFOLD );
+               LDAP_UTF8_CASEFOLD );
        return LDAP_SUCCESS;
 }
        
@@ -1852,7 +1857,7 @@ integerNormalize(
                if( negative ) {
                        normalized->bv_val[0] = '-';
                }
-               memcpy( normalized->bv_val + negative, p, len );
+               AC_MEMCPY( normalized->bv_val + negative, p, len );
        }
 
        return LDAP_SUCCESS;
@@ -1865,23 +1870,23 @@ static int integerIndexer(
        Syntax *syntax,
        MatchingRule *mr,
        struct berval *prefix,
-       struct berval **values,
-       struct berval **keysp )
+       BVarray values,
+       BVarray *keysp )
 {
        int i;
-       struct berval *keys;
+       BVarray keys;
 
        /* we should have at least one value at this point */
-       assert( values != NULL && values[0] != NULL );
+       assert( values != NULL && values[0].bv_val != NULL );
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* empty -- just count them */
        }
 
        keys = ch_malloc( sizeof( struct berval ) * (i+1) );
 
-       for( i=0; values[i] != NULL; i++ ) {
-               integerNormalize( syntax, values[i], &keys[i] );
+       for( i=0; values[i].bv_val != NULL; i++ ) {
+               integerNormalize( syntax, &values[i], &keys[i] );
        }
 
        keys[i].bv_val = NULL;
@@ -1897,9 +1902,9 @@ static int integerFilter(
        MatchingRule *mr,
        struct berval *prefix,
        void * assertValue,
-       struct berval **keysp )
+       BVarray *keysp )
 {
-       struct berval *keys;
+       BVarray keys;
 
        keys = ch_malloc( sizeof( struct berval ) * 2 );
        integerNormalize( syntax, assertValue, &keys[0] );
@@ -1934,8 +1939,6 @@ printableStringValidate(
 {
        ber_len_t i;
 
-       if( !val->bv_len ) return LDAP_INVALID_SYNTAX;
-
        for(i=0; i < val->bv_len; i++) {
                if( !SLAP_PRINTABLE(val->bv_val[i]) ) {
                        return LDAP_INVALID_SYNTAX;
@@ -1952,8 +1955,6 @@ printablesStringValidate(
 {
        ber_len_t i;
 
-       if( !val->bv_len ) return LDAP_INVALID_SYNTAX;
-
        for(i=0; i < val->bv_len; i++) {
                if( !SLAP_PRINTABLES(val->bv_val[i]) ) {
                        return LDAP_INVALID_SYNTAX;
@@ -1970,10 +1971,10 @@ IA5StringValidate(
 {
        ber_len_t i;
 
-       if( !val->bv_len ) return LDAP_INVALID_SYNTAX;
-
        for(i=0; i < val->bv_len; i++) {
-               if( !isascii(val->bv_val[i]) ) return LDAP_INVALID_SYNTAX;
+               if( !LDAP_ASCII(val->bv_val[i]) ) {
+                       return LDAP_INVALID_SYNTAX;
+               }
        }
 
        return LDAP_SUCCESS;
@@ -1994,10 +1995,6 @@ IA5StringNormalize(
                p++;
        }
 
-       if( *p == '\0' ) {
-               return LDAP_INVALID_SYNTAX;
-       }
-
        normalized->bv_val = ch_strdup( p );
        p = q = normalized->bv_val;
 
@@ -2014,12 +2011,9 @@ IA5StringNormalize(
                }
        }
 
-       assert( normalized->bv_val < p );
+       assert( normalized->bv_val <= p );
        assert( q <= p );
 
-       /* cannot start with a space */
-       assert( !ASCII_SPACE(*normalized->bv_val) );
-
        /*
         * If the string ended in space, backup the pointer one
         * position.  One is enough because the above loop collapsed
@@ -2030,9 +2024,6 @@ IA5StringNormalize(
                --q;
        }
 
-       /* cannot end with a space */
-       assert( !ASCII_SPACE( q[-1] ) );
-
        /* null terminate */
        *q = '\0';
 
@@ -2194,19 +2185,19 @@ static int caseExactIA5Indexer(
        Syntax *syntax,
        MatchingRule *mr,
        struct berval *prefix,
-       struct berval **values,
-       struct berval **keysp )
+       BVarray values,
+       BVarray *keysp )
 {
        int i;
        size_t slen, mlen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval digest;
        digest.bv_val = HASHdigest;
        digest.bv_len = sizeof(HASHdigest);
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* empty - just count them */
        }
 
@@ -2218,8 +2209,8 @@ static int caseExactIA5Indexer(
        slen = syntax->ssyn_oidlen;
        mlen = mr->smr_oidlen;
 
-       for( i=0; values[i] != NULL; i++ ) {
-               struct berval *value = values[i];
+       for( i=0; values[i].bv_val != NULL; i++ ) {
+               struct berval *value = &values[i];
 
                HASH_Init( &HASHcontext );
                if( prefix != NULL && prefix->bv_len > 0 ) {
@@ -2250,10 +2241,10 @@ static int caseExactIA5Filter(
        MatchingRule *mr,
        struct berval *prefix,
        void * assertValue,
-       struct berval **keysp )
+       BVarray *keysp )
 {
        size_t slen, mlen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval *value;
@@ -2295,12 +2286,12 @@ static int caseExactIA5SubstringsIndexer(
        Syntax *syntax,
        MatchingRule *mr,
        struct berval *prefix,
-       struct berval **values,
-       struct berval **keysp )
+       BVarray values,
+       BVarray *keysp )
 {
        ber_len_t i, nkeys;
        size_t slen, mlen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval digest;
@@ -2308,36 +2299,36 @@ static int caseExactIA5SubstringsIndexer(
        digest.bv_len = sizeof(HASHdigest);
 
        /* we should have at least one value at this point */
-       assert( values != NULL && values[0] != NULL );
+       assert( values != NULL && values[0].bv_val != NULL );
 
        nkeys=0;
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* count number of indices to generate */
-               if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
+               if( values[i].bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
                        continue;
                }
 
                if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
-                       if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+                       if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
                                nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
                                        ( SLAP_INDEX_SUBSTR_MINLEN - 1);
                        } else {
-                               nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+                               nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
                        }
                }
 
                if( flags & SLAP_INDEX_SUBSTR_ANY ) {
-                       if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
-                               nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
+                       if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+                               nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
                        }
                }
 
                if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
-                       if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+                       if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
                                nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
                                        ( SLAP_INDEX_SUBSTR_MINLEN - 1);
                        } else {
-                               nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+                               nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
                        }
                }
        }
@@ -2354,11 +2345,11 @@ static int caseExactIA5SubstringsIndexer(
        mlen = mr->smr_oidlen;
 
        nkeys=0;
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                ber_len_t j,max;
                struct berval *value;
 
-               value = values[i];
+               value = &values[i];
                if( value->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
 
                if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
@@ -2456,13 +2447,13 @@ static int caseExactIA5SubstringsFilter(
        MatchingRule *mr,
        struct berval *prefix,
        void * assertValue,
-       struct berval **keysp )
+       BVarray *keysp )
 {
        SubstringsAssertion *sa = assertValue;
        char pre;
        ber_len_t nkeys = 0;
        size_t slen, mlen, klen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval *value;
@@ -2760,12 +2751,12 @@ static int caseIgnoreIA5Indexer(
        Syntax *syntax,
        MatchingRule *mr,
        struct berval *prefix,
-       struct berval **values,
-       struct berval **keysp )
+       BVarray values,
+       BVarray *keysp )
 {
        int i;
        size_t slen, mlen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval digest;
@@ -2773,9 +2764,9 @@ static int caseIgnoreIA5Indexer(
        digest.bv_len = sizeof(HASHdigest);
 
        /* we should have at least one value at this point */
-       assert( values != NULL && values[0] != NULL );
+       assert( values != NULL && values[0].bv_val != NULL );
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* just count them */
        }
 
@@ -2784,9 +2775,9 @@ static int caseIgnoreIA5Indexer(
        slen = syntax->ssyn_oidlen;
        mlen = mr->smr_oidlen;
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                struct berval value;
-               ber_dupbv( &value, values[i] );
+               ber_dupbv( &value, &values[i] );
                ldap_pvt_str2upper( value.bv_val );
 
                HASH_Init( &HASHcontext );
@@ -2820,10 +2811,10 @@ static int caseIgnoreIA5Filter(
        MatchingRule *mr,
        struct berval *prefix,
        void * assertValue,
-       struct berval **keysp )
+       BVarray *keysp )
 {
        size_t slen, mlen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval value;
@@ -2869,12 +2860,12 @@ static int caseIgnoreIA5SubstringsIndexer(
        Syntax *syntax,
        MatchingRule *mr,
        struct berval *prefix,
-       struct berval **values,
-       struct berval **keysp )
+       BVarray values,
+       BVarray *keysp )
 {
        ber_len_t i, nkeys;
        size_t slen, mlen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval digest;
@@ -2882,36 +2873,36 @@ static int caseIgnoreIA5SubstringsIndexer(
        digest.bv_len = sizeof(HASHdigest);
 
        /* we should have at least one value at this point */
-       assert( values != NULL && values[0] != NULL );
+       assert( values != NULL && values[0].bv_val != NULL );
 
        nkeys=0;
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* count number of indices to generate */
-               if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
+               if( values[i].bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
                        continue;
                }
 
                if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
-                       if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+                       if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
                                nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
                                        ( SLAP_INDEX_SUBSTR_MINLEN - 1);
                        } else {
-                               nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+                               nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
                        }
                }
 
                if( flags & SLAP_INDEX_SUBSTR_ANY ) {
-                       if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
-                               nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
+                       if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+                               nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
                        }
                }
 
                if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
-                       if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+                       if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
                                nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
                                        ( SLAP_INDEX_SUBSTR_MINLEN - 1);
                        } else {
-                               nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+                               nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
                        }
                }
        }
@@ -2928,13 +2919,13 @@ static int caseIgnoreIA5SubstringsIndexer(
        mlen = mr->smr_oidlen;
 
        nkeys=0;
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                int j,max;
                struct berval value;
 
-               if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
+               if( values[i].bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
 
-               ber_dupbv( &value, values[i] );
+               ber_dupbv( &value, &values[i] );
                ldap_pvt_str2upper( value.bv_val );
 
                if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
@@ -3034,13 +3025,13 @@ static int caseIgnoreIA5SubstringsFilter(
        MatchingRule *mr,
        struct berval *prefix,
        void * assertValue,
-       struct berval **keysp )
+       BVarray *keysp )
 {
        SubstringsAssertion *sa = assertValue;
        char pre;
        ber_len_t nkeys = 0;
        size_t slen, mlen, klen;
-       struct berval *keys;
+       BVarray keys;
        HASH_CONTEXT   HASHcontext;
        unsigned char   HASHdigest[HASH_BYTES];
        struct berval value;
@@ -3528,12 +3519,12 @@ certificateExactConvert(
 
        X509_free(xcert);
 
-       out->bv_len = serial->bv_len + 3 + issuer_dn->bv_len + 1;
+       out->bv_len = serial->bv_len + issuer_dn->bv_len + sizeof(" $ ");
        out->bv_val = ch_malloc(out->bv_len);
        p = out->bv_val;
        AC_MEMCPY(p, serial->bv_val, serial->bv_len);
        p += serial->bv_len;
-       AC_MEMCPY(p, " $ ", 3);
+       AC_MEMCPY(p, " $ ", sizeof(" $ ")-1);
        p += 3;
        AC_MEMCPY(p, issuer_dn->bv_val, issuer_dn->bv_len);
        p += issuer_dn->bv_len;
@@ -3584,7 +3575,7 @@ serial_and_issuer_parse(
 
        bv.bv_len = end-begin+1;
        bv.bv_val = begin;
-       *serial = ber_bvdup(&bv);
+       *serial = ber_dupbv(NULL, &bv);
 
        /* now extract the issuer, remember p was at the dollar sign */
        begin = p+1;
@@ -3693,27 +3684,27 @@ static int certificateExactIndexer(
        Syntax *syntax,
        MatchingRule *mr,
        struct berval *prefix,
-       struct berval **values,
-       struct berval **keysp )
+       BVarray values,
+       BVarray *keysp )
 {
        int i;
-       struct berval *keys;
+       BVarray keys;
        X509 *xcert;
        unsigned char *p;
        struct berval * serial;
 
        /* we should have at least one value at this point */
-       assert( values != NULL && values[0] != NULL );
+       assert( values != NULL && values[0].bv_val != NULL );
 
-       for( i=0; values[i] != NULL; i++ ) {
+       for( i=0; values[i].bv_val != NULL; i++ ) {
                /* empty -- just count them */
        }
 
        keys = ch_malloc( sizeof( struct berval ) * (i+1) );
 
-       for( i=0; values[i] != NULL; i++ ) {
-               p = values[i]->bv_val;
-               xcert = d2i_X509(NULL, &p, values[i]->bv_len);
+       for( i=0; values[i].bv_val != NULL; i++ ) {
+               p = values[i].bv_val;
+               xcert = d2i_X509(NULL, &p, values[i].bv_len);
                if ( !xcert ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
@@ -3761,9 +3752,9 @@ static int certificateExactFilter(
        MatchingRule *mr,
        struct berval *prefix,
        void * assertValue,
-       struct berval **keysp )
+       BVarray *keysp )
 {
-       struct berval *keys;
+       BVarray keys;
        struct berval *asserted_serial;
        struct berval *asserted_issuer_dn;
 
@@ -4038,7 +4029,7 @@ nisNetgroupTripleValidate(
                return LDAP_INVALID_SYNTAX;
        }
 
-       for ( p++; ( p < e ) && ( *p != ')' ); p++ ) {
+       for ( p++; ( p < e ) && ( *p != /*'('*/ ')' ); p++ ) {
                if ( *p == ',' ) {
                        commas++;
                        if ( commas > 2 ) {
@@ -4122,15 +4113,18 @@ static struct syntax_defs_rec {
        slap_syntax_transform_func *sd_str2ber;
 #endif
 } syntax_defs[] = {
-       {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' " X_BINARY X_NOT_H_R ")",
+       {"( 1.3.6.1.4.1.1466.115.121.1.1 DESC 'ACI Item' "
+               X_BINARY X_NOT_H_R ")",
                SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.2 DESC 'Access Point' " X_NOT_H_R ")",
                0, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.3 DESC 'Attribute Type Description' )",
                0, NULL, NULL, NULL},
-       {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' " X_NOT_H_R ")",
+       {"( 1.3.6.1.4.1.1466.115.121.1.4 DESC 'Audio' "
+               X_NOT_H_R ")",
                SLAP_SYNTAX_BLOB, blobValidate, NULL, NULL},
-       {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' " X_NOT_H_R ")",
+       {"( 1.3.6.1.4.1.1466.115.121.1.5 DESC 'Binary' "
+               X_NOT_H_R ")",
                SLAP_SYNTAX_BER, berValidate, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.6 DESC 'Bit String' )",
                0, bitStringValidate, bitStringNormalize, NULL },
@@ -4211,6 +4205,9 @@ static struct syntax_defs_rec {
                0, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.44 DESC 'Printable String' )",
                0, printableStringValidate, IA5StringNormalize, NULL},
+       {"( 1.3.6.1.4.1.1466.115.121.1.45 DESC 'SubtreeSpecification' "
+               X_BINARY X_NOT_H_R ")",
+               SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, NULL, NULL, NULL},
        {"( 1.3.6.1.4.1.1466.115.121.1.49 DESC 'Supported Algorithm' "
                X_BINARY X_NOT_H_R ")",
                SLAP_SYNTAX_BINARY|SLAP_SYNTAX_BER, berValidate, NULL, NULL},
@@ -4255,9 +4252,11 @@ static struct syntax_defs_rec {
                UTF8StringValidate /* THIS WILL CHANGE FOR NEW ACI SYNTAX */,
                NULL, NULL},
 
+#ifdef SLAPD_AUTHPASSWD
        /* needs updating */
        {"( 1.3.6.1.4.1.4203.666.2.2 DESC 'OpenLDAP authPassword' )",
                SLAP_SYNTAX_HIDE, NULL, NULL, NULL},
+#endif
 
        /* OpenLDAP Void Syntax */
        {"( 1.3.6.1.4.1.4203.1.1.1 DESC 'OpenLDAP void' )" ,
@@ -4305,7 +4304,7 @@ static struct mrule_defs_rec {
         */
        {"( " directoryStringApproxMatchOID " NAME 'directoryStringApproxMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
-               SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
+               SLAP_MR_HIDE | SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
                NULL, NULL,
                directoryStringApproxMatch,
                directoryStringApproxIndexer, 
@@ -4314,7 +4313,7 @@ static struct mrule_defs_rec {
 
        {"( " IA5StringApproxMatchOID " NAME 'IA5StringApproxMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
-               SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
+               SLAP_MR_HIDE | SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
                NULL, NULL,
                IA5StringApproxMatch,
                IA5StringApproxIndexer, 
@@ -4554,6 +4553,7 @@ static struct mrule_defs_rec {
                caseExactIA5SubstringsFilter,
                NULL},
 
+#ifdef SLAPD_AUTHPASSWD
        /* needs updating */
        {"( 1.3.6.1.4.1.4203.666.4.1 NAME 'authPasswordMatch' "
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
@@ -4561,6 +4561,7 @@ static struct mrule_defs_rec {
                NULL, NULL,
                authPasswordMatch, NULL, NULL,
                NULL},
+#endif
 
        {"( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
                "SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
@@ -4587,7 +4588,7 @@ static struct mrule_defs_rec {
 };
 
 int
-schema_init( void )
+slap_schema_init( void )
 {
        int             res;
        int             i;
@@ -4609,7 +4610,7 @@ schema_init( void )
                );
 
                if ( res ) {
-                       fprintf( stderr, "schema_init: Error registering syntax %s\n",
+                       fprintf( stderr, "slap_schema_init: Error registering syntax %s\n",
                                 syntax_defs[i].sd_desc );
                        return LDAP_OTHER;
                }
@@ -4618,7 +4619,7 @@ schema_init( void )
        for ( i=0; mrule_defs[i].mrd_desc != NULL; i++ ) {
                if( mrule_defs[i].mrd_usage == SLAP_MR_NONE ) {
                        fprintf( stderr,
-                               "schema_init: Ingoring unusable matching rule %s\n",
+                               "slap_schema_init: Ingoring unusable matching rule %s\n",
                                 mrule_defs[i].mrd_desc );
                        continue;
                }
@@ -4635,18 +4636,21 @@ schema_init( void )
 
                if ( res ) {
                        fprintf( stderr,
-                               "schema_init: Error registering matching rule %s\n",
+                               "slap_schema_init: Error registering matching rule %s\n",
                                 mrule_defs[i].mrd_desc );
                        return LDAP_OTHER;
                }
        }
+
+       res = slap_schema_load();
        schema_init_done = 1;
-       return LDAP_SUCCESS;
+       return res;
 }
 
 void
 schema_destroy( void )
 {
+       oidm_destroy();
        oc_destroy();
        at_destroy();
        mr_destroy();