From: Kurt Zeilenga Date: Wed, 21 Dec 2005 01:06:30 +0000 (+0000) Subject: UUID naming attribute fix X-Git-Tag: OPENLDAP_REL_ENG_2_3_14~34 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=55324e9fbf016ec0b7fb9c76af2628b435aaa1de;p=openldap UUID naming attribute fix --- diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 0f4c1e9396..f96ccf50fb 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -386,7 +386,9 @@ LDAPRDN_rewrite( LDAPRDN rdn, unsigned flags, void *ctx ) } else { /* normalization */ validf = ad->ad_type->sat_syntax->ssyn_validate; mr = ad->ad_type->sat_equality; - if( mr ) normf = mr->smr_normalize; + if( mr && (!( mr->smr_usage & SLAP_MR_MUTATION_NORMALIZER ))) { + normf = mr->smr_normalize; + } } if ( validf ) { @@ -516,7 +518,9 @@ LDAPDN_rewrite( LDAPDN dn, unsigned flags, void *ctx ) } else { /* normalization */ validf = ad->ad_type->sat_syntax->ssyn_validate; mr = ad->ad_type->sat_equality; - if( mr ) normf = mr->smr_normalize; + if( mr && (!( mr->smr_usage & SLAP_MR_MUTATION_NORMALIZER ))) { + normf = mr->smr_normalize; + } } if ( validf ) { diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 505a375c51..095f131814 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -2188,6 +2188,56 @@ UUIDValidate( } static int +UUIDPretty( + Syntax *syntax, + struct berval *in, + struct berval *out, + void *ctx ) +{ + int i; + int rc=LDAP_INVALID_SYNTAX; + + assert( in != NULL ); + assert( out != NULL ); + + if( in->bv_len != 36 ) return LDAP_INVALID_SYNTAX; + + out->bv_len = 36; + out->bv_val = slap_sl_malloc( out->bv_len + 1, ctx ); + + for( i=0; i<36; i++ ) { + switch(i) { + case 8: + case 13: + case 18: + case 23: + if( in->bv_val[i] != '-' ) { + goto handle_error; + } + out->bv_val[i] = '-'; + break; + + default: + if( !ASCII_HEX( in->bv_val[i]) ) { + goto handle_error; + } + out->bv_val[i] = TOLOWER( in->bv_val[i] ); + } + } + + rc = LDAP_SUCCESS; + out->bv_val[ out->bv_len ] = '\0'; + + if( 0 ) { +handle_error: + slap_sl_free( out->bv_val, ctx ); + out->bv_val = NULL; + } + + return rc; +} + +int UUIDNormalize( slap_mask_t usage, Syntax *syntax, @@ -3448,7 +3498,7 @@ static slap_syntax_defs_rec syntax_defs[] = { #endif {"( 1.3.6.1.1.16.1 DESC 'UUID' )", - 0, UUIDValidate, NULL}, + 0, UUIDValidate, UUIDPretty}, {"( 1.3.6.1.4.1.4203.666.11.2.1 DESC 'CSN' )", SLAP_SYNTAX_HIDE, csnValidate, NULL}, @@ -3873,14 +3923,14 @@ static slap_mrule_defs_rec mrule_defs[] = { {"( 1.3.6.1.1.16.2 NAME 'UUIDMatch' " "SYNTAX 1.3.6.1.1.16.1 )", - SLAP_MR_EQUALITY, NULL, + SLAP_MR_EQUALITY | SLAP_MR_MUTATION_NORMALIZER, NULL, NULL, UUIDNormalize, octetStringMatch, octetStringIndexer, octetStringFilter, NULL}, {"( 1.3.6.1.1.16.3 NAME 'UUIDOrderingMatch' " "SYNTAX 1.3.6.1.1.16.1 )", - SLAP_MR_ORDERING, NULL, + SLAP_MR_ORDERING | SLAP_MR_MUTATION_NORMALIZER, NULL, NULL, UUIDNormalize, octetStringOrderingMatch, octetStringIndexer, octetStringFilter, "UUIDMatch"}, diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 4379a6dadc..37f1e709eb 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -511,6 +511,8 @@ typedef struct slap_matching_rule { #define SLAP_MR_HIDE 0x8000U #endif +#define SLAP_MR_MUTATION_NORMALIZER 0x4000U + #define SLAP_MR_TYPE_MASK 0x0F00U #define SLAP_MR_SUBTYPE_MASK 0x00F0U #define SLAP_MR_USAGE 0x000FU