Commit 7d8206ac authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Fix lastmod bugs

parent 9cf13941
......@@ -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,
......
......@@ -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,56 +568,103 @@ 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;
#if 0
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;
#endif
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) ) {
#if 0
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;
......@@ -628,7 +674,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;
......@@ -639,7 +685,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;
......@@ -648,42 +694,6 @@ int slap_mods_opattrs(
modtail = &mod->sml_next;
}
#if 0
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;
#endif
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;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment