From: Kurt Zeilenga Date: Fri, 31 Oct 2003 17:41:31 +0000 (+0000) Subject: Update entryUUID to latest draft specification X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~472 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=80fa73bf8c08b9acbae058012bcf048bcca57226;p=openldap Update entryUUID to latest draft specification --- diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index a120a3690a..10298b5c78 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -850,7 +850,7 @@ int slap_mods_opattrs( mod->sml_type.bv_val = NULL; mod->sml_desc = slap_schema.si_ad_entryUUID; mod->sml_values = - (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_values[0], &tmpval ); mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; @@ -863,7 +863,8 @@ int slap_mods_opattrs( mod->sml_op = mop; mod->sml_type.bv_val = NULL; mod->sml_desc = slap_schema.si_ad_creatorsName; - mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + mod->sml_values = + (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_values[0], &name ); mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; @@ -881,7 +882,8 @@ int slap_mods_opattrs( mod->sml_op = mop; mod->sml_type.bv_val = NULL; mod->sml_desc = slap_schema.si_ad_createTimestamp; - mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + mod->sml_values = + (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); ber_dupbv( &mod->sml_values[0], ×tamp ); mod->sml_values[1].bv_len = 0; mod->sml_values[1].bv_val = NULL; diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 0d64d5cbbc..a3cd70f295 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -1770,6 +1770,86 @@ IA5StringNormalize( return LDAP_SUCCESS; } +static int +UUIDValidate( + Syntax *syntax, + struct berval *in ) +{ + int i; + if( in->bv_len != 36 ) { + assert(0); + return LDAP_INVALID_SYNTAX; + } + + for( i=0; i<36; i++ ) { + switch(i) { + case 8: + case 13: + case 18: + case 23: + if( in->bv_val[i] != '-' ) { + return LDAP_INVALID_SYNTAX; + } + break; + default: + if( !ASCII_HEX( in->bv_val[i]) ) { + return LDAP_INVALID_SYNTAX; + } + } + } + + return LDAP_SUCCESS; +} + +static int +UUIDNormalize( + slap_mask_t usage, + Syntax *syntax, + MatchingRule *mr, + struct berval *val, + struct berval *normalized, + void *ctx ) +{ + unsigned char octet; + int i; + int j; + normalized->bv_len = 16; + normalized->bv_val = sl_malloc( normalized->bv_len+1, ctx ); + + for( i=0, j=0; i<36; i++ ) { + unsigned char nibble; + if( val->bv_val[i] == '-' ) { + continue; + + } else if( ASCII_DIGIT( val->bv_val[i] ) ) { + nibble = val->bv_val[i] - '0'; + + } else if( ASCII_HEXLOWER( val->bv_val[i] ) ) { + nibble = val->bv_val[i] - ('a'-10); + + } else if( ASCII_HEXUPPER( val->bv_val[i] ) ) { + nibble = val->bv_val[i] - ('A'-10); + + } else { + sl_free( normalized->bv_val, ctx ); + return LDAP_INVALID_SYNTAX; + } + + if( j % 2 ) { + octet = nibble << 4; + } else { + octet |= nibble; + normalized->bv_val[j>>1] = octet; + } + j++; + } + + normalized->bv_val[normalized->bv_len] = 0; + return LDAP_SUCCESS; +} + + + static int numericStringValidate( Syntax *syntax, @@ -2761,6 +2841,9 @@ static slap_syntax_defs_rec syntax_defs[] = { SLAP_SYNTAX_HIDE, NULL, NULL}, #endif + {"( 1.3.6.1.4.1.4203.666.2.6 DESC 'UUID' )", + SLAP_SYNTAX_HIDE, UUIDValidate, NULL}, + /* OpenLDAP Void Syntax */ {"( 1.3.6.1.4.1.4203.1.1.1 DESC 'OpenLDAP void' )" , SLAP_SYNTAX_HIDE, inValidate, NULL}, @@ -3109,6 +3192,20 @@ static slap_mrule_defs_rec mrule_defs[] = { NULL, NULL, "integerMatch" }, + {"( 1.3.6.1.4.1.4203.666.4.6 NAME 'UUIDMatch' " + "SYNTAX 1.3.6.1.4.1.4203.666.2.6 )", + SLAP_MR_HIDE | SLAP_MR_EQUALITY, NULL, + NULL, UUIDNormalize, octetStringMatch, + octetStringIndexer, octetStringFilter, + NULL}, + + {"( 1.3.6.1.4.1.4203.666.4.7 NAME 'UUIDOrderingMatch' " + "SYNTAX 1.3.6.1.4.1.4203.666.2.6 )", + SLAP_MR_HIDE | SLAP_MR_ORDERING, NULL, + NULL, UUIDNormalize, octetStringOrderingMatch, + octetStringIndexer, octetStringFilter, + "UUIDMatch"}, + {NULL, SLAP_MR_NONE, NULL, NULL, NULL, NULL, NULL, NULL, NULL } diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index 0b43eea524..306015eea6 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -368,8 +368,9 @@ static struct slap_schema_ad_map { { "entryUUID", "( 1.3.6.1.4.1.4203.666.1.6 NAME 'entryUUID' " "DESC 'UUID of the entry' " - "EQUALITY octetStringMatch " - "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} " + "EQUALITY UUIDMatch " + "ORDERING UUIDOrderingMatch " + "SYNTAX 1.3.6.1.4.1.4203.666.2.6 " "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )", NULL, SLAP_AT_HIDE, NULL, NULL, diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 47e2613739..5d4a5967b7 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -96,6 +96,10 @@ LDAP_BEGIN_DECL #define ASCII_UPPER(c) ( (c) >= 'A' && (c) <= 'Z' ) #define ASCII_ALPHA(c) ( ASCII_LOWER(c) || ASCII_UPPER(c) ) #define ASCII_DIGIT(c) ( (c) >= '0' && (c) <= '9' ) +#define ASCII_HEXLOWER(c) ( (c) >= 'a' && (c) <= 'h' ) +#define ASCII_HEXUPPER(c) ( (c) >= 'A' && (c) <= 'H' ) +#define ASCII_HEX(c) ( ASCII_DIGIT(c) || \ + ASCII_HEXLOWER(c) || ASCII_HEXUPPER(c) ) #define ASCII_ALNUM(c) ( ASCII_ALPHA(c) || ASCII_DIGIT(c) ) #define ASCII_PRINTABLE(c) ( (c) >= ' ' && (c) <= '~' )