]> git.sur5r.net Git - openldap/commitdiff
UUID naming attribute fix
authorKurt Zeilenga <kurt@openldap.org>
Wed, 21 Dec 2005 01:06:30 +0000 (01:06 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 21 Dec 2005 01:06:30 +0000 (01:06 +0000)
servers/slapd/dn.c
servers/slapd/schema_init.c
servers/slapd/slap.h

index 0f4c1e93961020f06d57f345d88ce7d3b0d1370f..f96ccf50fba20ac6a6b12d4b1d59242b7731f528 100644 (file)
@@ -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 ) {
index 505a375c519f2c83cd83a11e45edad2d13c9681b..095f131814cba4f238ed0cc800159d60f483c36a 100644 (file)
@@ -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"},
index 4379a6dadc167870b1b707c26e2cb50da200ba4c..37f1e709eb626320dde922e9755ceb9b4e36e64e 100644 (file)
@@ -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