X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fmodify.c;h=dd7689cfaf9bc23f031ea5607917c4211d62fe6e;hb=76ed17f7942d4e3810fa90b46143e615af311167;hp=6575fe36adbd7a434c772d6ab328acd9fc51ad77;hpb=58ea169c92679eb5b0598c2420c95c626ccac27d;p=openldap diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 6575fe36ad..dd7689cfaf 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -155,14 +155,14 @@ do_modify( */ if ( be->be_modify != NULL ) { /* do the update here */ - if ( be->be_updatedn == NULL || strcasecmp( be->be_updatedn, - op->o_dn ) == 0 ) { - if ( (be->be_lastmod == ON || be->be_lastmod == 0 && - global_lastmod == ON) && be->be_updatedn == NULL ) { + if ( be->be_updatedn == NULL || + strcasecmp( be->be_updatedn, op->o_dn ) == 0 ) { + + if ( (be->be_lastmod == ON || ( be->be_lastmod == UNDEFINED && + global_lastmod == ON ) ) && be->be_updatedn == NULL ) { add_lastmods( op, &mods ); } - if ( (*be->be_modify)( be, conn, op, odn, mods ) - == 0 ) { + if ( (*be->be_modify)( be, conn, op, odn, mods ) == 0 ) { replog( be, LDAP_REQ_MODIFY, dn, mods, 0 ); } @@ -200,7 +200,7 @@ modlist_free( static void add_lastmods( Operation *op, LDAPMod **mods ) { - char buf[20]; + char buf[22]; struct berval bv; struct berval *bvals[2]; LDAPMod **m; @@ -214,17 +214,25 @@ add_lastmods( Operation *op, LDAPMod **mods ) /* remove any attempts by the user to modify these attrs */ for ( m = mods; *m != NULL; m = &(*m)->mod_next ) { - if ( strcasecmp( (*m)->mod_type, "modifytimestamp" ) == 0 - || strcasecmp( (*m)->mod_type, "modifiersname" ) == 0 ) { - tmp = *m; - *m = (*m)->mod_next; - free( tmp->mod_type ); - if ( tmp->mod_bvalues != NULL ) { - ber_bvecfree( tmp->mod_bvalues ); - } - free( tmp ); - } - } + if ( strcasecmp( (*m)->mod_type, "modifytimestamp" ) == 0 || + strcasecmp( (*m)->mod_type, "modifiersname" ) == 0 || + strcasecmp( (*m)->mod_type, "createtimestamp" ) == 0 || + strcasecmp( (*m)->mod_type, "creatorsname" ) == 0 ) { + + Debug( LDAP_DEBUG_TRACE, + "add_lastmods: found lastmod attr: %s\n", + (*m)->mod_type, 0, 0 ); + tmp = *m; + *m = (*m)->mod_next; + free( tmp->mod_type ); + if ( tmp->mod_bvalues != NULL ) { + ber_bvecfree( tmp->mod_bvalues ); + } + free( tmp ); + if (!*m) + break; + } + } if ( op->o_dn == NULL || op->o_dn[0] == '\0' ) { bv.bv_val = "NULLDN"; @@ -243,16 +251,19 @@ add_lastmods( Operation *op, LDAPMod **mods ) *mods = tmp; pthread_mutex_lock( ¤ttime_mutex ); - ltm = localtime( ¤ttime ); - strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); + ltm = localtime( ¤ttime ); +#ifdef LDAP_Y2K + strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm ); +#else + strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm ); +#endif pthread_mutex_unlock( ¤ttime_mutex ); bv.bv_val = buf; bv.bv_len = strlen( bv.bv_val ); tmp = (LDAPMod *) ch_calloc( 1, sizeof(LDAPMod) ); tmp->mod_type = strdup( "modifytimestamp" ); tmp->mod_op = LDAP_MOD_REPLACE; - tmp->mod_bvalues = (struct berval **) ch_calloc( 1, - 2 * sizeof(struct berval *) ); + tmp->mod_bvalues = (struct berval **) ch_calloc( 1, 2 * sizeof(struct berval *) ); tmp->mod_bvalues[0] = ber_bvdup( &bv ); tmp->mod_next = *mods; *mods = tmp;