From 81d31dc7218eb2e0ff5958f3f2a83e68cb954da4 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 28 Apr 2004 05:12:53 +0000 Subject: [PATCH] ITS#3118: initial fix: (objectClasses=2.5.6.0) works need to add special handler to allow (objectClasses=top) to work --- servers/slapd/oc.c | 9 +++++---- servers/slapd/schema_init.c | 33 +++++++++++++++++++-------------- tests/scripts/test000-rootdse | 24 +++++++++++++++++++----- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/servers/slapd/oc.c b/servers/slapd/oc.c index d67ea5ecd0..52aa6e2e69 100644 --- a/servers/slapd/oc.c +++ b/servers/slapd/oc.c @@ -501,13 +501,14 @@ oc_schema_info( Entry *e ) return -1; } -#if 0 - Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n", - (long) val.bv_len, val.bv_val, 0 ); -#endif nval.bv_val = oc->soc_oid; nval.bv_len = strlen(oc->soc_oid); +#if 0 + Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s (%s)\n", + (long) val.bv_len, val.bv_val, nval.bv_val ); +#endif + if( attr_merge_one( e, ad_objectClasses, &val, &nval ) ) { return -1; diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 87e7786aaf..4f501a0f71 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -2790,19 +2790,24 @@ firstComponentNormalize( void *ctx ) { int rc; - struct berval oid; - ber_len_t len = 0; + struct berval comp; + ber_len_t len; - if( val->bv_len == 0 ) return LDAP_INVALID_SYNTAX; + if( SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX( usage )) { + ber_dupbv_x( normalized, val, ctx ); + return LDAP_SUCCESS; + } - if( val->bv_val[0] == '(' /*')'*/ || - val->bv_val[0] == '{' /*'}'*/ ) + if( val->bv_len < 3 ) return LDAP_INVALID_SYNTAX; + + if( val->bv_val[0] != '(' /*')'*/ && + val->bv_val[0] != '{' /*'}'*/ ) { - len = 1; + return LDAP_INVALID_SYNTAX; } /* trim leading white space */ - for( ; + for( len=1; len < val->bv_len && ASCII_SPACE(val->bv_val[len]); len++ ) { @@ -2810,26 +2815,26 @@ firstComponentNormalize( } /* grab next word */ - oid.bv_val = &val->bv_val[len]; + comp.bv_val = &val->bv_val[len]; len = val->bv_len - len; - for( oid.bv_len=0; - !ASCII_SPACE(oid.bv_val[oid.bv_len]) && oid.bv_len < len; - oid.bv_len++ ) + for( comp.bv_len=0; + !ASCII_SPACE(comp.bv_val[comp.bv_len]) && comp.bv_len < len; + comp.bv_len++ ) { /* empty */ } if( mr == slap_schema.si_mr_objectIdentifierFirstComponentMatch ) { - rc = numericoidValidate( NULL, &oid ); + rc = numericoidValidate( NULL, &comp ); } else if( mr == slap_schema.si_mr_integerFirstComponentMatch ) { - rc = integerValidate( NULL, &oid ); + rc = integerValidate( NULL, &comp ); } else { rc = LDAP_INVALID_SYNTAX; } if( rc == LDAP_SUCCESS ) { - ber_dupbv_x( normalized, &oid, ctx ); + ber_dupbv_x( normalized, &comp, ctx ); } return rc; diff --git a/tests/scripts/test000-rootdse b/tests/scripts/test000-rootdse index 0db0731d66..90935a3604 100755 --- a/tests/scripts/test000-rootdse +++ b/tests/scripts/test000-rootdse @@ -30,7 +30,8 @@ KILLPIDS="$PID" echo "Using ldapsearch to retrieve the root DSE..." for i in 0 1 2 3 4 5; do - $LDAPSEARCH -b "" -s base -h $LOCALHOST -p $PORT1 '+extensibleObject' > $SEARCHOUT 2>&1 + $LDAPSEARCH -b "" -s base -h $LOCALHOST -p $PORT1 \ + '+extensibleObject' > $SEARCHOUT 2>&1 RC=$? if test $RC = 0 ; then break @@ -39,9 +40,18 @@ for i in 0 1 2 3 4 5; do sleep 5 done +if test $RC = 0 ; then + echo "Using ldapsearch to retrieve the cn=Subschema..." + $LDAPSEARCH -b "cn=Subschema" -s base -h $LOCALHOST -p $PORT1 \ + '(objectClasses=2.5.6.0)' cn objectClass >> $SEARCHOUT 2>&1 + RC=$? + +fi + if test $RC = 0 -a $MONITORDB = yes ; then echo "Using ldapsearch to retrieve the cn=Monitor..." - $LDAPSEARCH -b "cn=Monitor" -s base -h $LOCALHOST -p $PORT1 '+extensibleObject' >> $SEARCHOUT 2>&1 + $LDAPSEARCH -b "cn=Monitor" -s base -h $LOCALHOST -p $PORT1 \ + '+extensibleObject' >> $SEARCHOUT 2>&1 RC=$? fi @@ -49,13 +59,17 @@ test $KILLSERVERS != no && kill -HUP $KILLPIDS cat $SEARCHOUT + if test $RC != 0 ; then echo ">>>>> Test failed" else - if grep "TLS:" $SEARCHOUT; then - RC=-1 + RC=`grep '^dn:' $SEARCHOUT | wc -l` + if test $RC != 3 ; then + echo ">>>>> Test failed: expected 3 entries, got" $RC + RC=1 else - echo ">>>>> Test succeeded" + echo ">>>>> Test succeeded" + RC=0 fi fi -- 2.39.5