From 7bbc9032015aeb17c140fedcce1018be18bdf7fb Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 25 Apr 2003 02:28:06 +0000 Subject: [PATCH] fix up nvalues code so that pretty routines work properly re-add objectClass pretty routines --- servers/slapd/add.c | 11 +- servers/slapd/modify.c | 2 + servers/slapd/schema_init.c | 52 ++++---- servers/slapd/schema_prep.c | 250 ++++++++++++++++-------------------- servers/slapd/value.c | 1 - 5 files changed, 151 insertions(+), 165 deletions(-) diff --git a/servers/slapd/add.c b/servers/slapd/add.c index b9ce04c16a..fa61285c4a 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -437,6 +437,7 @@ slap_mods2entry( /* trim the mods array */ ch_free( mods->sml_nvalues ); mods->sml_nvalues = NULL; + } else { attr->a_nvals = attr->a_vals; } @@ -475,14 +476,20 @@ slap_mods2entry( int rc = LDAP_SUCCESS; int match; - for ( i = 0; mods->sml_nvalues[i].bv_val != NULL; i++ ) { + for ( i = 0; mods->sml_values[i].bv_val != NULL; i++ ) { /* test asserted values against themselves */ for( j = 0; j < i; j++ ) { rc = value_match( &match, mods->sml_desc, mr, SLAP_MR_EQUALITY | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH, - &mods->sml_nvalues[i], &mods->sml_nvalues[j], text ); + mods->sml_nvalues + ? &mods->sml_nvalues[i] + : &mods->sml_values[i], + mods->sml_nvalues + ? &mods->sml_nvalues[j] + : &mods->sml_values[j], + text ); if ( rc == LDAP_SUCCESS && match == 0 ) { /* value exists already */ snprintf( textbuf, textlen, diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index df5c60d6e8..df77beaf15 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -660,6 +660,8 @@ int slap_mods_check( ml->sml_nvalues[nvals].bv_val = NULL; ml->sml_nvalues[nvals].bv_len = 0; + + } else { } } } diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index fea000a757..7a385baaf6 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -32,7 +32,6 @@ /* not yet implemented */ #define integerFirstComponentNormalize NULL -#define objectIdentifierNormalize NULL #define objectIdentifierFirstComponentNormalize NULL #define uniqueMemberMatch NULL @@ -1425,41 +1424,46 @@ telephoneNumberNormalize( } static int -oidValidate( +numericoidValidate( Syntax *syntax, - struct berval *val ) + struct berval *in ) { - ber_len_t i; + struct berval val = *in; - if( val->bv_len == 0 ) { + if( val.bv_len == 0 ) { /* disallow empty strings */ return LDAP_INVALID_SYNTAX; } - if( OID_LEADCHAR(val->bv_val[0]) ) { - int dot = 0; - for(i=1; i < val->bv_len; i++) { - if( OID_SEPARATOR( val->bv_val[i] ) ) { - if( dot++ ) return 1; - } else if ( OID_CHAR( val->bv_val[i] ) ) { - dot = 0; - } else { - return LDAP_INVALID_SYNTAX; - } + while( OID_LEADCHAR( val.bv_val[0] ) ) { + if ( val.bv_len == 1 ) { + return LDAP_SUCCESS; } - return !dot ? LDAP_SUCCESS : LDAP_INVALID_SYNTAX; + if ( val.bv_val[0] == '0' ) { + break; + } - } else if( DESC_LEADCHAR(val->bv_val[0]) ) { - for(i=1; i < val->bv_len; i++) { - if( !DESC_CHAR(val->bv_val[i] ) ) { - return LDAP_INVALID_SYNTAX; + val.bv_val++; + val.bv_len--; + + while ( OID_LEADCHAR( val.bv_val[0] )) { + val.bv_val++; + val.bv_len--; + + if ( val.bv_len == 0 ) { + return LDAP_SUCCESS; } } - return LDAP_SUCCESS; + if( !OID_SEPARATOR( val.bv_val[0] )) { + break; + } + + val.bv_val++; + val.bv_len--; } - + return LDAP_INVALID_SYNTAX; } @@ -2689,7 +2693,7 @@ static slap_syntax_defs_rec syntax_defs[] = { {"( 1.3.6.1.4.1.1466.115.121.1.37 DESC 'Object Class Description' )", 0, NULL, NULL}, {"( 1.3.6.1.4.1.1466.115.121.1.38 DESC 'OID' )", - 0, oidValidate, NULL}, + 0, numericoidValidate, NULL}, {"( 1.3.6.1.4.1.1466.115.121.1.39 DESC 'Other Mailbox' )", 0, IA5StringValidate, NULL}, {"( 1.3.6.1.4.1.1466.115.121.1.40 DESC 'Octet String' )", @@ -2840,7 +2844,7 @@ static slap_mrule_defs_rec mrule_defs[] = { {"( 2.5.13.0 NAME 'objectIdentifierMatch' " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )", SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL, - NULL, objectIdentifierNormalize, octetStringMatch, + NULL, NULL, octetStringMatch, octetStringIndexer, octetStringFilter, NULL }, diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index 48d00a9df3..b90c07e515 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -23,10 +23,8 @@ int schema_init_done = 0; struct slap_internal_schema slap_schema; -static int objectClassNormalize( - slap_mask_t use, - struct slap_syntax *syntax, /* NULL if in is asserted value */ - struct slap_matching_rule *mr, +static int objectClassPretty( + struct slap_syntax *syntax, struct berval * in, struct berval * out, void *ctx ) @@ -39,16 +37,6 @@ static int objectClassNormalize( ber_dupbv_x( out, in, ctx ); } -#if OCDEBUG -#ifdef NEW_LOGGING - LDAP_LOG( CONFIG, ENTRY, - "< objectClassNormalize(%s, %s)\n", in->bv_val, out->bv_val, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "< objectClassNormalize(%s,%s)\n", - in->bv_val, out->bv_val, 0 ); -#endif -#endif - return LDAP_SUCCESS; } @@ -65,16 +53,6 @@ objectSubClassMatch( ObjectClass *oc = oc_bvfind( value ); ObjectClass *asserted = oc_bvfind( a ); -#if OCDEBUG -#ifdef NEW_LOGGING - LDAP_LOG( CONFIG, ENTRY, - "> objectSubClassMatch(%s, %s)\n", value->bv_val, a->bv_val, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "> objectSubClassMatch(%s,%s)\n", - value->bv_val, a->bv_val, 0 ); -#endif -#endif - if( asserted == NULL ) { if( OID_LEADCHAR( *a->bv_val ) ) { /* OID form, return FALSE */ @@ -91,24 +69,12 @@ objectSubClassMatch( return SLAPD_COMPARE_UNDEFINED; } - if( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( flags ) ) - { + if( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( flags ) ) { *matchp = ( asserted != oc ); } else { *matchp = !is_object_subclass( asserted, oc ); } -#if OCDEBUG -#ifdef NEW_LOGGING - LDAP_LOG( CONFIG, ENTRY, - "< objectSubClassMatch(%s, %s) = %d\n", - value->bv_val, a->bv_val, *matchp ); -#else - Debug( LDAP_DEBUG_TRACE, "< objectSubClassMatch(%s,%s) = %d\n", - value->bv_val, a->bv_val, *matchp ); -#endif -#endif - return LDAP_SUCCESS; } @@ -140,17 +106,6 @@ static int objectSubClassIndexer( } else { ocvalues[i] = values[i]; } -#if OCDEBUG -#ifdef NEW_LOGGING - LDAP_LOG( CONFIG, ENTRY, - "> objectSubClassIndexer(%d, %s)\n", - i, ocvalues[i].bv_val, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, - "> objectSubClassIndexer(%d, %s)\n", - i, ocvalues[i].bv_val, 0 ); -#endif -#endif } ocvalues[i].bv_val = NULL; @@ -168,18 +123,6 @@ static int objectSubClassIndexer( int k; for( k=0; ksoc_cname.bv_val ); -#else - Debug( LDAP_DEBUG_TRACE, - "= objectSubClassIndexer(%d, %s, %s)\n", - k, ocvalues[k].bv_val, sup->soc_cname.bv_val ); -#endif -#endif if( bvmatch( &ocvalues[k], &sup->soc_cname ) ) { found++; break; @@ -201,32 +144,10 @@ static int objectSubClassIndexer( ocvalues[noc].bv_len = 0; ocvalues[noc].bv_val = NULL; - -#if OCDEBUG -#ifdef NEW_LOGGING - LDAP_LOG( CONFIG, ENTRY, - "< objectSubClassIndexer(%d, %d, %s)\n", - i, k, sup->soc_cname.bv_val ); -#else - Debug( LDAP_DEBUG_TRACE, - "< objectSubClassIndexer(%d, %d, %s)\n", - i, k, sup->soc_cname.bv_val ); -#endif -#endif } } } -#if 0 -#ifdef NEW_LOGGING - LDAP_LOG( CONFIG, ENTRY, - "< objectSubClassIndexer(%d)\n", noc, 0, 0 ); -#else - Debug( LDAP_DEBUG_TRACE, "< objectSubClassIndexer(%d)\n", - noc, 0, 0 ); -#endif -#endif - rc = octetStringIndexer( use, mask, syntax, mr, prefix, ocvalues, keysp, ctx ); @@ -234,36 +155,7 @@ static int objectSubClassIndexer( return rc; } -/* 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, - void *ctx ) -{ -#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, ctx ); -} +#define objectSubClassFilter octetStringFilter static ObjectClassSchemaCheckFN rootDseObjectClass; static ObjectClassSchemaCheckFN aliasObjectClass; @@ -371,11 +263,13 @@ static struct slap_schema_ad_map { char *ssam_defn; AttributeTypeSchemaCheckFN *ssam_check; slap_mask_t ssam_flags; - slap_mr_convert_func *ssam_convert; - slap_mr_normalize_func *ssam_normalize; - slap_mr_match_func *ssam_match; - slap_mr_indexer_func *ssam_indexer; - slap_mr_filter_func *ssam_filter; + slap_syntax_validate_func *ssam_syn_validate; + slap_syntax_transform_func *ssam_syn_pretty; + slap_mr_convert_func *ssam_mr_convert; + slap_mr_normalize_func *ssam_mr_normalize; + slap_mr_match_func *ssam_mr_match; + slap_mr_indexer_func *ssam_mr_indexer; + slap_mr_filter_func *ssam_mr_filter; size_t ssam_offset; } ad_map[] = { { "objectClass", "( 2.5.4.0 NAME 'objectClass' " @@ -383,7 +277,8 @@ static struct slap_schema_ad_map { "EQUALITY objectIdentifierMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )", NULL, SLAP_AT_FINAL, - NULL, objectClassNormalize, objectSubClassMatch, + NULL, objectClassPretty, + NULL, NULL, objectSubClassMatch, objectSubClassIndexer, objectSubClassFilter, offsetof(struct slap_internal_schema, si_ad_objectClass) }, @@ -394,7 +289,8 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, 0, - NULL, objectClassNormalize, objectSubClassMatch, + NULL, objectClassPretty, + NULL, NULL, objectSubClassMatch, objectSubClassIndexer, objectSubClassFilter, offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) }, { "createTimestamp", "( 2.5.18.1 NAME 'createTimestamp' " @@ -404,6 +300,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_createTimestamp) }, { "modifyTimestamp", "( 2.5.18.2 NAME 'modifyTimestamp' " @@ -413,6 +310,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) }, { "creatorsName", "( 2.5.18.3 NAME 'creatorsName' " @@ -421,6 +319,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_creatorsName) }, { "modifiersName", "( 2.5.18.4 NAME 'modifiersName' " @@ -429,6 +328,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_modifiersName) }, { "hasSubordinates", "( 2.5.18.9 NAME 'hasSubordinates' " @@ -437,6 +337,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_hasSubordinates) }, { "subschemaSubentry", "( 2.5.18.10 NAME 'subschemaSubentry' " @@ -445,6 +346,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE " "NO-USER-MODIFICATION USAGE directoryOperation )", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) }, #ifdef LDAP_DEVEL @@ -454,6 +356,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 " "NO-USER-MODIFICATION USAGE directoryOperation )", NULL, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_collectiveSubentries) }, { "collectiveExclusions", "( 2.5.18.7 NAME 'collectiveExclusions' " @@ -461,6 +364,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 " "USAGE directoryOperation )", NULL, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_collectiveExclusions) }, #endif @@ -471,6 +375,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_entryUUID) }, { "entryCSN", "( 1.3.6.1.4.1.4203.666.1.7 NAME 'entryCSN' " @@ -480,6 +385,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_entryCSN) }, { "namingCSN", "( 1.3.6.1.4.1.4203.666.1.13 NAME 'namingCSN' " @@ -489,6 +395,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_namingCSN) }, @@ -498,6 +405,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_superiorUUID) }, @@ -509,6 +417,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} " "NO-USER-MODIFICATION USAGE directoryOperation )", NULL, 0, /* SLAP_AT_HIDE or SLAP_AT_NONE ? */ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_queryid) }, #endif /* LDAP_CACHING */ @@ -522,6 +431,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_syncreplCookie) }, #endif @@ -531,6 +441,7 @@ static struct slap_schema_ad_map { "DESC 'RFC2252: alternative servers' " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 USAGE dSAOperation )", rootDseAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_altServer) }, { "namingContexts", "( 1.3.6.1.4.1.1466.101.120.5 " @@ -538,6 +449,7 @@ static struct slap_schema_ad_map { "DESC 'RFC2252: naming contexts' " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 USAGE dSAOperation )", rootDseAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_namingContexts) }, { "supportedControl", "( 1.3.6.1.4.1.1466.101.120.13 " @@ -545,6 +457,7 @@ static struct slap_schema_ad_map { "DESC 'RFC2252: supported controls' " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )", rootDseAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_supportedControl) }, { "supportedExtension", "( 1.3.6.1.4.1.1466.101.120.7 " @@ -552,6 +465,7 @@ static struct slap_schema_ad_map { "DESC 'RFC2252: supported extended operations' " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )", rootDseAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_supportedExtension) }, { "supportedLDAPVersion", "( 1.3.6.1.4.1.1466.101.120.15 " @@ -559,6 +473,7 @@ static struct slap_schema_ad_map { "DESC 'RFC2252: supported LDAP versions' " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 USAGE dSAOperation )", rootDseAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) }, { "supportedSASLMechanisms", "( 1.3.6.1.4.1.1466.101.120.14 " @@ -566,6 +481,7 @@ static struct slap_schema_ad_map { "DESC 'RFC2252: supported SASL mechanisms'" "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE dSAOperation )", rootDseAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) }, { "supportedFeatures", "( 1.3.6.1.4.1.4203.1.3.5 " @@ -575,6 +491,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 " "USAGE dSAOperation )", rootDseAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_supportedFeatures) }, { "monitorContext", "( 1.3.6.1.4.1.4203.666.1.10 " @@ -584,6 +501,7 @@ static struct slap_schema_ad_map { "SINGLE-VALUE NO-USER-MODIFICATION " "USAGE dSAOperation )", rootDseAttribute, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_monitorContext) }, { "vendorName", "( 1.3.6.1.1.4 NAME 'vendorName' " @@ -593,6 +511,7 @@ static struct slap_schema_ad_map { "SINGLE-VALUE NO-USER-MODIFICATION " "USAGE dSAOperation )", rootDseAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_vendorName) }, { "vendorVersion", "( 1.3.6.1.1.5 NAME 'vendorVersion' " @@ -602,6 +521,7 @@ static struct slap_schema_ad_map { "SINGLE-VALUE NO-USER-MODIFICATION " "USAGE dSAOperation )", rootDseAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_vendorVersion) }, @@ -611,6 +531,7 @@ static struct slap_schema_ad_map { "USAGE directoryOperation " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )", administrativeRoleAttribute, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_administrativeRole) }, { "subtreeSpecification", "( 2.5.18.6 NAME 'subtreeSpecification' " @@ -618,6 +539,7 @@ static struct slap_schema_ad_map { "USAGE directoryOperation " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 )", subentryAttribute, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_subtreeSpecification) }, @@ -628,6 +550,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 " "USAGE directoryOperation ) ", subentryAttribute, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_ditStructureRules) }, { "ditContentRules", "( 2.5.21.2 NAME 'dITContentRules' " @@ -635,6 +558,7 @@ static struct slap_schema_ad_map { "EQUALITY objectIdentifierFirstComponentMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 USAGE directoryOperation )", subentryAttribute, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_ditContentRules) }, { "matchingRules", "( 2.5.21.4 NAME 'matchingRules' " @@ -642,6 +566,7 @@ static struct slap_schema_ad_map { "EQUALITY objectIdentifierFirstComponentMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.30 USAGE directoryOperation )", subentryAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_matchingRules) }, { "attributeTypes", "( 2.5.21.5 NAME 'attributeTypes' " @@ -649,6 +574,7 @@ static struct slap_schema_ad_map { "EQUALITY objectIdentifierFirstComponentMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.3 USAGE directoryOperation )", subentryAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_attributeTypes) }, { "objectClasses", "( 2.5.21.6 NAME 'objectClasses' " @@ -656,6 +582,7 @@ static struct slap_schema_ad_map { "EQUALITY objectIdentifierFirstComponentMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.37 USAGE directoryOperation )", subentryAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_objectClasses) }, { "nameForms", "( 2.5.21.7 NAME 'nameForms' " @@ -663,6 +590,7 @@ static struct slap_schema_ad_map { "EQUALITY objectIdentifierFirstComponentMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.35 USAGE directoryOperation )", subentryAttribute, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_nameForms) }, { "matchingRuleUse", "( 2.5.21.8 NAME 'matchingRuleUse' " @@ -670,6 +598,7 @@ static struct slap_schema_ad_map { "EQUALITY objectIdentifierFirstComponentMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.31 USAGE directoryOperation )", subentryAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_matchingRuleUse) }, @@ -678,6 +607,7 @@ static struct slap_schema_ad_map { "EQUALITY objectIdentifierFirstComponentMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.54 USAGE directoryOperation )", subentryAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) }, @@ -688,6 +618,7 @@ static struct slap_schema_ad_map { "EQUALITY distinguishedNameMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )", aliasAttribute, SLAP_AT_FINAL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_aliasedObjectName) }, { "ref", "( 2.16.840.1.113730.3.1.34 NAME 'ref' " @@ -696,6 +627,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " "USAGE distributedOperation )", referralAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_ref) }, @@ -706,6 +638,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.4203.1.1.1 " "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )", NULL, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_entry) }, { "children", "( 1.3.6.1.4.1.4203.1.3.2 " @@ -714,6 +647,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.4203.1.1.1 " "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )", NULL, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_children) }, { "saslAuthzTo", "( 1.3.6.1.4.1.4203.666.1.8 " @@ -723,6 +657,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " "USAGE distributedOperation )", NULL, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_saslAuthzTo) }, { "saslAuthzFrom", "( 1.3.6.1.4.1.4203.666.1.9 " @@ -732,6 +667,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " "USAGE distributedOperation )", NULL, SLAP_AT_HIDE, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_saslAuthzFrom) }, #ifdef SLAPD_ACI_ENABLED @@ -742,6 +678,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.4203.666.2.1 " "USAGE directoryOperation )", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_aci) }, #endif @@ -752,6 +689,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE " "NO-USER-MODIFICATION USAGE dSAOperation )", dynamicAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_entryTtl) }, { "dynamicSubtrees", "( 1.3.6.1.4.1.1466.101.119.4 " @@ -760,6 +698,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 NO-USER-MODIFICATION " "USAGE dSAOperation )", rootDseAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_dynamicSubtrees) }, #endif @@ -770,6 +709,7 @@ static struct slap_schema_ad_map { "EQUALITY distinguishedNameMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )", NULL, SLAP_AT_ABSTRACT, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_distinguishedName) }, { "name", "( 2.5.4.41 NAME 'name' " @@ -778,12 +718,14 @@ static struct slap_schema_ad_map { "SUBSTR caseIgnoreSubstringsMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )", NULL, SLAP_AT_ABSTRACT, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_name) }, { "cn", "( 2.5.4.3 NAME ( 'cn' 'commonName' ) " "DESC 'RFC2256: common name(s) for which the entity is known by' " "SUP name )", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_cn) }, { "userPassword", "( 2.5.4.35 NAME 'userPassword' " @@ -791,6 +733,7 @@ static struct slap_schema_ad_map { "EQUALITY octetStringMatch " "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128} )", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_userPassword) }, @@ -801,6 +744,7 @@ static struct slap_schema_ad_map { "EQUALITY 1.3.6.1.4.1.4203.1.2.2 " "SYNTAX 1.3.6.1.4.1.4203.1.1.2 )", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_authPassword) }, { "supportedAuthPasswordSchemes", "( 1.3.6.1.4.1.4203.1.3.3 " @@ -810,6 +754,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{32} " "USAGE dSAOperation )", subschemaAttribute, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_authPassword) }, #endif @@ -821,6 +766,7 @@ static struct slap_schema_ad_map { "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 " "SINGLE-VALUE )", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_krbName) }, #endif @@ -834,7 +780,7 @@ static AttributeType slap_at_undefined = { { sizeof("UNDEFINED")-1, "UNDEFINED" }, /* cname */ NULL, /* sup */ NULL, /* subtypes */ - NULL, NULL, NULL, NULL, /* matching rules */ + NULL, NULL, NULL, NULL, /* matching rules routines */ NULL, /* syntax (this may need to be defined) */ (AttributeTypeSchemaCheckFN *) 0, /* schema check function */ SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */ @@ -949,6 +895,7 @@ slap_schema_load( void ) { int rc; const char *text; + Syntax *syntax = NULL; AttributeDescription ** adp = (AttributeDescription **) &(((char *) &slap_schema)[ad_map[i].ssam_offset]); @@ -970,32 +917,59 @@ slap_schema_load( void ) /* install flags */ (*adp)->ad_type->sat_flags |= ad_map[i].ssam_flags; - /* install custom rule routine */ - 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 ) + /* install custom syntax routines */ + if( ad_map[i].ssam_syn_validate || + ad_map[i].ssam_syn_pretty ) + { + Syntax *syn; + + syntax = (*adp)->ad_type->sat_syntax; + + syn = ch_malloc( sizeof( Syntax ) ); + *syn = *syntax; + + if( ad_map[i].ssam_syn_validate ) { + syn->ssyn_validate = ad_map[i].ssam_syn_validate; + } + if( ad_map[i].ssam_syn_pretty ) { + syn->ssyn_pretty = ad_map[i].ssam_syn_pretty; + } + + (*adp)->ad_type->sat_syntax = syn; + } + + /* install custom rule routines */ + if( ( (*adp)->ad_type->sat_equality != NULL && + syntax == (*adp)->ad_type->sat_equality->smr_syntax ) || + ad_map[i].ssam_mr_convert || + ad_map[i].ssam_mr_normalize || + ad_map[i].ssam_mr_match || + ad_map[i].ssam_mr_indexer || + ad_map[i].ssam_mr_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 ( syntax == mr->smr_syntax ) { + mr->smr_syntax = (*adp)->ad_type->sat_syntax; } - if( ad_map[i].ssam_normalize ) { - mr->smr_normalize = ad_map[i].ssam_normalize; + if ( ad_map[i].ssam_mr_convert ) { + mr->smr_convert = ad_map[i].ssam_mr_convert; } - if( ad_map[i].ssam_match ) { - mr->smr_match = ad_map[i].ssam_match; + if ( ad_map[i].ssam_mr_normalize ) { + mr->smr_normalize = ad_map[i].ssam_mr_normalize; } - if( ad_map[i].ssam_indexer ) { - mr->smr_indexer = ad_map[i].ssam_indexer; + if ( ad_map[i].ssam_mr_match ) { + mr->smr_match = ad_map[i].ssam_mr_match; } - if( ad_map[i].ssam_filter ) { - mr->smr_filter = ad_map[i].ssam_filter; + if ( ad_map[i].ssam_mr_indexer ) { + mr->smr_indexer = ad_map[i].ssam_mr_indexer; } + if ( ad_map[i].ssam_mr_filter ) { + mr->smr_filter = ad_map[i].ssam_mr_filter; + } + + (*adp)->ad_type->sat_equality = mr; } } } diff --git a/servers/slapd/value.c b/servers/slapd/value.c index c05c1a0975..cf0129738f 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -205,7 +205,6 @@ value_match( return LDAP_INAPPROPRIATE_MATCHING; } - rc = (mr->smr_match)( match, flags, ad->ad_type->sat_syntax, mr, -- 2.39.5