]> git.sur5r.net Git - openldap/commitdiff
Fix for "no structuralObjectClass" when lastmod is off (ITS#1904)
authorKurt Zeilenga <kurt@openldap.org>
Tue, 25 Jun 2002 01:04:54 +0000 (01:04 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 25 Jun 2002 01:04:54 +0000 (01:04 +0000)
servers/slapd/add.c
servers/slapd/modify.c
servers/slapd/proto-slap.h

index 3d308ea8c19a66ab3c9496358a49040d334cc159..48411f3b9908f69031daf99e51cca56aa3940f4f 100644 (file)
@@ -258,7 +258,7 @@ do_add( Connection *conn, Operation *op )
                                goto done;
                        }
 
-                       if ( SLAP_LASTMOD(be) && !repl_user ) {
+                       if ( !repl_user ) {
                                for( modtail = &modlist;
                                        *modtail != NULL;
                                        modtail = &(*modtail)->sml_next )
@@ -266,7 +266,7 @@ do_add( Connection *conn, Operation *op )
                                        assert( (*modtail)->sml_op == LDAP_MOD_ADD );
                                        assert( (*modtail)->sml_desc != NULL );
                                }
-                               rc = slap_mods_opattrs( op, modlist, modtail, &text,
+                               rc = slap_mods_opattrs( be, op, modlist, modtail, &text,
                                        textbuf, textlen );
                                if( rc != LDAP_SUCCESS ) {
                                        send_ldap_result( conn, op, rc,
index 6bb923671bd7f22db33136e0057eb5528ef87f91..fcbe86a46c490b3d5c6efdcfa031096d4934a71d 100644 (file)
@@ -346,7 +346,7 @@ do_modify(
                                goto cleanup;
                        }
 
-                       if ( SLAP_LASTMOD(be) && !repl_user ) {
+                       if ( !repl_user ) {
                                for( modtail = &modlist;
                                        *modtail != NULL;
                                        modtail = &(*modtail)->sml_next )
@@ -354,7 +354,7 @@ do_modify(
                                        /* empty */
                                }
 
-                               rc = slap_mods_opattrs( op, modlist, modtail, &text,
+                               rc = slap_mods_opattrs( be, op, modlist, modtail, &text,
                                        textbuf, textlen );
                                if( rc != LDAP_SUCCESS ) {
                                        send_ldap_result( conn, op, rc,
@@ -550,6 +550,7 @@ int slap_mods_check(
 }
 
 int slap_mods_opattrs(
+       Backend *be,
        Operation *op,
        Modifications *mods,
        Modifications **modtail,
@@ -557,10 +558,8 @@ int slap_mods_opattrs(
        char *textbuf, size_t textlen )
 {
        struct berval name, timestamp, csn;
-       time_t now = slap_get_time();
        char timebuf[22];
        char csnbuf[64];
-       struct tm *ltm;
        Modifications *mod;
 
        int mop = op->o_tag == LDAP_REQ_ADD
@@ -569,55 +568,100 @@ int slap_mods_opattrs(
        assert( modtail != NULL );
        assert( *modtail == NULL );
 
-       ldap_pvt_thread_mutex_lock( &gmtime_mutex );
-       ltm = gmtime( &now );
-       strftime( timebuf, sizeof(timebuf), "%Y%m%d%H%M%SZ", ltm );
+       if( SLAP_LASTMOD(be) ) {
+               struct tm *ltm;
+               time_t now = slap_get_time();
 
-       csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
-       ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
-       csn.bv_val = csnbuf;
+               ldap_pvt_thread_mutex_lock( &gmtime_mutex );
+               ltm = gmtime( &now );
+               strftime( timebuf, sizeof(timebuf), "%Y%m%d%H%M%SZ", ltm );
 
-       timestamp.bv_val = timebuf;
-       timestamp.bv_len = strlen(timebuf);
+               csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
+               ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+               csn.bv_val = csnbuf;
 
-       if( op->o_dn.bv_len == 0 ) {
-               name.bv_val = SLAPD_ANONYMOUS;
-               name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
-       } else {
-               name = op->o_dn;
+               timestamp.bv_val = timebuf;
+               timestamp.bv_len = strlen(timebuf);
+
+               if( op->o_dn.bv_len == 0 ) {
+                       name.bv_val = SLAPD_ANONYMOUS;
+                       name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
+               } else {
+                       name = op->o_dn;
+               }
        }
 
        if( op->o_tag == LDAP_REQ_ADD ) {
                struct berval tmpval;
-               char uuidbuf[40];
-               int rc;
 
-               rc = mods_structural_class( mods, &tmpval, text, textbuf, textlen );
-               if( rc != LDAP_SUCCESS ) {
-                       return rc;
+               if( global_schemacheck ) {
+                       int rc = mods_structural_class( mods, &tmpval,
+                               text, textbuf, textlen );
+                       if( rc != LDAP_SUCCESS ) {
+                               return rc;
+                       }
+                       if ( tmpval.bv_len ) {
+                               mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
+                               mod->sml_op = mop;
+                               mod->sml_type.bv_val = NULL;
+                               mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
+                               mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+                               ber_dupbv( &mod->sml_bvalues[0], &tmpval );
+                               mod->sml_bvalues[1].bv_val = NULL;
+                               assert( mod->sml_bvalues[0].bv_val );
+                               *modtail = mod;
+                               modtail = &mod->sml_next;
+                       }
                }
-               if ( tmpval.bv_len ) {
+
+               if( SLAP_LASTMOD(be) ) {
+                       char uuidbuf[40];
+
+                       tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
+                       tmpval.bv_val = uuidbuf;
+               
                        mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                        mod->sml_op = mop;
                        mod->sml_type.bv_val = NULL;
-                       mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
+                       mod->sml_desc = slap_schema.si_ad_entryUUID;
                        mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                        ber_dupbv( &mod->sml_bvalues[0], &tmpval );
                        mod->sml_bvalues[1].bv_val = NULL;
                        assert( mod->sml_bvalues[0].bv_val );
                        *modtail = mod;
                        modtail = &mod->sml_next;
+
+                       mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
+                       mod->sml_op = mop;
+                       mod->sml_type.bv_val = NULL;
+                       mod->sml_desc = slap_schema.si_ad_creatorsName;
+                       mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+                       ber_dupbv( &mod->sml_bvalues[0], &name );
+                       mod->sml_bvalues[1].bv_val = NULL;
+                       assert( mod->sml_bvalues[0].bv_val );
+                       *modtail = mod;
+                       modtail = &mod->sml_next;
+
+                       mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
+                       mod->sml_op = mop;
+                       mod->sml_type.bv_val = NULL;
+                       mod->sml_desc = slap_schema.si_ad_createTimestamp;
+                       mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
+                       ber_dupbv( &mod->sml_bvalues[0], &timestamp );
+                       mod->sml_bvalues[1].bv_val = NULL;
+                       assert( mod->sml_bvalues[0].bv_val );
+                       *modtail = mod;
+                       modtail = &mod->sml_next;
                }
+       }
 
-               tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
-               tmpval.bv_val = uuidbuf;
-               
+       if( SLAP_LASTMOD(be) ) {
                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                mod->sml_op = mop;
                mod->sml_type.bv_val = NULL;
-               mod->sml_desc = slap_schema.si_ad_entryUUID;
+               mod->sml_desc = slap_schema.si_ad_entryCSN;
                mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
-               ber_dupbv( &mod->sml_bvalues[0], &tmpval );
+               ber_dupbv( &mod->sml_bvalues[0], &csn );
                mod->sml_bvalues[1].bv_val = NULL;
                assert( mod->sml_bvalues[0].bv_val );
                *modtail = mod;
@@ -626,7 +670,7 @@ int slap_mods_opattrs(
                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                mod->sml_op = mop;
                mod->sml_type.bv_val = NULL;
-               mod->sml_desc = slap_schema.si_ad_creatorsName;
+               mod->sml_desc = slap_schema.si_ad_modifiersName;
                mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                ber_dupbv( &mod->sml_bvalues[0], &name );
                mod->sml_bvalues[1].bv_val = NULL;
@@ -637,7 +681,7 @@ int slap_mods_opattrs(
                mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
                mod->sml_op = mop;
                mod->sml_type.bv_val = NULL;
-               mod->sml_desc = slap_schema.si_ad_createTimestamp;
+               mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
                mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
                ber_dupbv( &mod->sml_bvalues[0], &timestamp );
                mod->sml_bvalues[1].bv_val = NULL;
@@ -646,40 +690,6 @@ int slap_mods_opattrs(
                modtail = &mod->sml_next;
        }
 
-       mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
-       mod->sml_op = mop;
-       mod->sml_type.bv_val = NULL;
-       mod->sml_desc = slap_schema.si_ad_entryCSN;
-       mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
-       ber_dupbv( &mod->sml_bvalues[0], &csn );
-       mod->sml_bvalues[1].bv_val = NULL;
-       assert( mod->sml_bvalues[0].bv_val );
-       *modtail = mod;
-       modtail = &mod->sml_next;
-
-       mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
-       mod->sml_op = mop;
-       mod->sml_type.bv_val = NULL;
-       mod->sml_desc = slap_schema.si_ad_modifiersName;
-       mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
-       ber_dupbv( &mod->sml_bvalues[0], &name );
-       mod->sml_bvalues[1].bv_val = NULL;
-       assert( mod->sml_bvalues[0].bv_val );
-       *modtail = mod;
-       modtail = &mod->sml_next;
-
-       mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
-       mod->sml_op = mop;
-       mod->sml_type.bv_val = NULL;
-       mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
-       mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
-       ber_dupbv( &mod->sml_bvalues[0], &timestamp );
-       mod->sml_bvalues[1].bv_val = NULL;
-       assert( mod->sml_bvalues[0].bv_val );
-       *modtail = mod;
-       modtail = &mod->sml_next;
-
        *modtail = NULL;
-
        return LDAP_SUCCESS;
 }
index 98aab651f7b26ad8f3a933c2cd9b47b5cce6ce0b..3e75823e0d78d97a1c7cde13915ba00da26370ce 100644 (file)
@@ -539,6 +539,7 @@ LDAP_SLAPD_F( int ) slap_mods_check(
        char *textbuf, size_t textlen );
 
 LDAP_SLAPD_F( int ) slap_mods_opattrs(
+       Backend *be,
        Operation *op,
        Modifications *mods,
        Modifications **modlist,