From: Pierangelo Masarati Date: Wed, 17 Aug 2005 20:53:39 +0000 (+0000) Subject: allow to manage entryUUID; allow to manage noUserMod attrs during add X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~679 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=965d00a1ddc6697c2a315ff3da09f2d84952fb5c;p=openldap allow to manage entryUUID; allow to manage noUserMod attrs during add --- diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 56d6c0bf4a..ef20429217 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -844,7 +844,7 @@ int slap_mods_opattrs( assert( modtail != NULL ); assert( *modtail == NULL ); - if ( SLAP_LASTMOD( op->o_bd )) { + if ( SLAP_LASTMOD( op->o_bd ) ) { time_t now = slap_get_time(); slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, manage_ctxcsn ); @@ -854,7 +854,7 @@ int slap_mods_opattrs( slap_timestamp( &now, ×tamp ); - if( op->o_dn.bv_len == 0 ) { + if ( BER_BVISEMPTY( &op->o_dn ) ) { BER_BVSTR( &name, SLAPD_ANONYMOUS ); nname = name; } else { @@ -863,10 +863,20 @@ int slap_mods_opattrs( } } - if( op->o_tag == LDAP_REQ_ADD ) { + if ( op->o_tag == LDAP_REQ_ADD ) { struct berval tmpval; - { + mod = *modtail; + if ( get_manageDIT( op ) ) { + for ( mod = mods; mod != *modtail; mod = mod->sml_next ) { + if ( mod->sml_desc == slap_schema.si_ad_structuralObjectClass ) { + break; + } + } + + } + + if ( mod == *modtail ) { int rc = mods_structural_class( mods, &tmpval, text, textbuf, textlen ); if( rc != LDAP_SUCCESS ) return rc; @@ -892,42 +902,136 @@ int slap_mods_opattrs( modtail = &mod->sml_next; } - if ( SLAP_LASTMOD( op->o_bd )) { - char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ]; + if ( SLAP_LASTMOD( op->o_bd ) ) { + mod = *modtail; + if ( get_manageDIT( op ) ) { + for ( mod = mods; mod != *modtail; mod = mod->sml_next ) { + if ( mod->sml_desc == slap_schema.si_ad_entryUUID ) { + break; + } + } + } - tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) ); - tmpval.bv_val = uuidbuf; - - mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); - mod->sml_op = mop; - mod->sml_flags = SLAP_MOD_INTERNAL; - mod->sml_type.bv_val = NULL; - mod->sml_desc = slap_schema.si_ad_entryUUID; - mod->sml_values = - (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; - assert( mod->sml_values[0].bv_val != NULL ); - mod->sml_nvalues = - (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); - (*mod->sml_desc->ad_type->sat_equality->smr_normalize)( - SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, - mod->sml_desc->ad_type->sat_syntax, - mod->sml_desc->ad_type->sat_equality, - mod->sml_values, mod->sml_nvalues, NULL ); - mod->sml_nvalues[1].bv_len = 0; - mod->sml_nvalues[1].bv_val = NULL; - *modtail = mod; - modtail = &mod->sml_next; + if ( mod == *modtail ) { + char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ]; + + tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) ); + tmpval.bv_val = uuidbuf; + + mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); + mod->sml_op = mop; + mod->sml_flags = SLAP_MOD_INTERNAL; + mod->sml_type.bv_val = NULL; + mod->sml_desc = slap_schema.si_ad_entryUUID; + mod->sml_values = + (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; + assert( mod->sml_values[0].bv_val != NULL ); + mod->sml_nvalues = + (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + (*mod->sml_desc->ad_type->sat_equality->smr_normalize)( + SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, + mod->sml_desc->ad_type->sat_syntax, + mod->sml_desc->ad_type->sat_equality, + mod->sml_values, mod->sml_nvalues, NULL ); + mod->sml_nvalues[1].bv_len = 0; + mod->sml_nvalues[1].bv_val = NULL; + *modtail = mod; + modtail = &mod->sml_next; + } + + mod = *modtail; + if ( get_manageDIT( op ) ) { + for ( mod = mods; mod != *modtail; mod = mod->sml_next ) { + if ( mod->sml_desc == slap_schema.si_ad_creatorsName ) { + break; + } + } + } + + if ( mod == *modtail ) { + mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); + mod->sml_op = mop; + mod->sml_flags = SLAP_MOD_INTERNAL; + mod->sml_type.bv_val = NULL; + mod->sml_desc = slap_schema.si_ad_creatorsName; + 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; + assert( mod->sml_values[0].bv_val != NULL ); + mod->sml_nvalues = + (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + ber_dupbv( &mod->sml_nvalues[0], &nname ); + mod->sml_nvalues[1].bv_len = 0; + mod->sml_nvalues[1].bv_val = NULL; + assert( mod->sml_nvalues[0].bv_val != NULL ); + *modtail = mod; + modtail = &mod->sml_next; + } + + mod = *modtail; + if ( get_manageDIT( op ) ) { + for ( mod = mods; mod != *modtail; mod = mod->sml_next ) { + if ( mod->sml_desc == slap_schema.si_ad_createTimestamp ) { + break; + } + } + } + + if ( mod == *modtail ) { + mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); + mod->sml_op = mop; + mod->sml_flags = SLAP_MOD_INTERNAL; + mod->sml_type.bv_val = NULL; + mod->sml_desc = slap_schema.si_ad_createTimestamp; + 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; + assert( mod->sml_values[0].bv_val != NULL ); + mod->sml_nvalues = NULL; + *modtail = mod; + modtail = &mod->sml_next; + } + } + } + + if ( SLAP_LASTMOD( op->o_bd ) ) { + mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); + mod->sml_op = mop; + mod->sml_flags = SLAP_MOD_INTERNAL; + mod->sml_type.bv_val = NULL; + mod->sml_desc = slap_schema.si_ad_entryCSN; + mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); + ber_dupbv( &mod->sml_values[0], &csn ); + mod->sml_values[1].bv_len = 0; + mod->sml_values[1].bv_val = NULL; + assert( mod->sml_values[0].bv_val != NULL ); + mod->sml_nvalues = NULL; + *modtail = mod; + modtail = &mod->sml_next; + + mod = *modtail; + if ( get_manageDIT( op ) ) { + for ( mod = mods; mod != *modtail; mod = mod->sml_next ) { + if ( mod->sml_desc == slap_schema.si_ad_modifiersName ) { + break; + } + } + } + if ( mod == *modtail ) { mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); mod->sml_op = mop; mod->sml_flags = SLAP_MOD_INTERNAL; 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_desc = slap_schema.si_ad_modifiersName; + 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; @@ -940,14 +1044,24 @@ int slap_mods_opattrs( assert( mod->sml_nvalues[0].bv_val != NULL ); *modtail = mod; modtail = &mod->sml_next; + } + mod = *modtail; + if ( get_manageDIT( op ) ) { + for ( mod = mods; mod != *modtail; mod = mod->sml_next ) { + if ( mod->sml_desc == slap_schema.si_ad_modifyTimestamp ) { + break; + } + } + } + + if ( mod == *modtail ) { mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); mod->sml_op = mop; mod->sml_flags = SLAP_MOD_INTERNAL; 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_desc = slap_schema.si_ad_modifyTimestamp; + 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; @@ -958,55 +1072,6 @@ int slap_mods_opattrs( } } - if ( SLAP_LASTMOD( op->o_bd )) { - mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); - mod->sml_op = mop; - mod->sml_flags = SLAP_MOD_INTERNAL; - mod->sml_type.bv_val = NULL; - mod->sml_desc = slap_schema.si_ad_entryCSN; - mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); - ber_dupbv( &mod->sml_values[0], &csn ); - mod->sml_values[1].bv_len = 0; - mod->sml_values[1].bv_val = NULL; - assert( mod->sml_values[0].bv_val != NULL ); - mod->sml_nvalues = NULL; - *modtail = mod; - modtail = &mod->sml_next; - - mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); - mod->sml_op = mop; - mod->sml_flags = SLAP_MOD_INTERNAL; - mod->sml_type.bv_val = NULL; - mod->sml_desc = slap_schema.si_ad_modifiersName; - 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; - assert( mod->sml_values[0].bv_val != NULL ); - mod->sml_nvalues = - (BerVarray) ch_malloc( 2 * sizeof( struct berval ) ); - ber_dupbv( &mod->sml_nvalues[0], &nname ); - mod->sml_nvalues[1].bv_len = 0; - mod->sml_nvalues[1].bv_val = NULL; - assert( mod->sml_nvalues[0].bv_val != NULL ); - *modtail = mod; - modtail = &mod->sml_next; - - mod = (Modifications *) ch_malloc( sizeof( Modifications ) ); - mod->sml_op = mop; - mod->sml_flags = SLAP_MOD_INTERNAL; - mod->sml_type.bv_val = NULL; - mod->sml_desc = slap_schema.si_ad_modifyTimestamp; - 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; - assert( mod->sml_values[0].bv_val != NULL ); - mod->sml_nvalues = NULL; - *modtail = mod; - modtail = &mod->sml_next; - } - *modtail = NULL; return LDAP_SUCCESS; } diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index 2b2d8b1e37..ac81a92017 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -551,7 +551,7 @@ static struct slap_schema_ad_map { "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, SLAP_AT_HIDE|SLAP_AT_MANAGEABLE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, offsetof(struct slap_internal_schema, si_ad_entryUUID) },