]> git.sur5r.net Git - openldap/commitdiff
allow to manage entryUUID; allow to manage noUserMod attrs during add
authorPierangelo Masarati <ando@openldap.org>
Wed, 17 Aug 2005 20:53:39 +0000 (20:53 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 17 Aug 2005 20:53:39 +0000 (20:53 +0000)
servers/slapd/modify.c
servers/slapd/schema_prep.c

index 56d6c0bf4aaa23b1ae63ef334851ba9b0bc32a56..ef204292173605db0983cfdcfbd766527d59d929 100644 (file)
@@ -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, &timestamp );
 
-               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], &timestamp );
+                               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], &timestamp );
                        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], &timestamp );
-               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;
 }
index 2b2d8b1e371a4594d479ee97625eec19b7044052..ac81a92017eff971819befd16e0f8bac21a3ed8c 100644 (file)
@@ -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) },