diff --git a/libraries/liblutil/csn.c b/libraries/liblutil/csn.c index 33907102e1b436a592cfcb564e1aea63526ba2ae..0a18918b3bdc20bfe6a576e090d7c3c1b82aea81 100644 --- a/libraries/liblutil/csn.c +++ b/libraries/liblutil/csn.c @@ -54,7 +54,7 @@ lutil_csnstr(char *buf, size_t len, unsigned int replica, unsigned int mod) ltm = gmtime( &t ); n = snprintf( buf, len, "%4d%02d%02d%02d:%02d:%02dZ#0x%04x#%d#%04x", - ltm->tm_year + 1900, ltm->tm_mon, ltm->tm_mday, ltm->tm_hour, + ltm->tm_year + 1900, ltm->tm_mon + 1, ltm->tm_mday, ltm->tm_hour, ltm->tm_min, ltm->tm_sec, op, replica, mod ); if( n < 0 ) return 0; diff --git a/servers/slapd/tools/slapadd.c b/servers/slapd/tools/slapadd.c index 771012774028b89b2c7c634084196d32b5c7cf90..3c71859e832a8ac70eac77f6aa4f69d86ae12a4c 100644 --- a/servers/slapd/tools/slapadd.c +++ b/servers/slapd/tools/slapadd.c @@ -31,6 +31,10 @@ main( int argc, char **argv ) char textbuf[SLAP_TEXT_BUFLEN] = { '\0' }; size_t textlen = sizeof textbuf; + struct berval name, timestamp, csn; + char timebuf[22]; + char csnbuf[64]; + #ifdef NEW_LOGGING lutil_log_initialize(argc, argv ); #endif @@ -137,6 +141,27 @@ main( int argc, char **argv ) } } + if ( SLAP_LASTMOD(be) ) { + struct tm *ltm; + time_t now = slap_get_time(); + + ltm = gmtime(&now); + lutil_gentime( timebuf, sizeof(timebuf), ltm ); + + csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 ); + csn.bv_val = csnbuf; + + timestamp.bv_val = timebuf; + timestamp.bv_len = strlen(timebuf); + + if ( be->be_rootndn.bv_len == 0 ) { + name.bv_val = SLAPD_ANONYMOUS; + name.bv_len = sizeof(SLAPD_ANONYMOUS) - 1; + } else { + name = be->be_rootndn; + } + } + if( global_schemacheck ) { /* check schema */ @@ -152,6 +177,42 @@ main( int argc, char **argv ) } } + if ( SLAP_LASTMOD(be) ) { + char uuidbuf[40]; + struct berval vals[2]; + + vals[0].bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) ); + vals[0].bv_val = uuidbuf; + vals[1].bv_len = 0; + vals[1].bv_val = NULL; + attr_merge( e, slap_schema.si_ad_entryUUID, vals ); + + ber_dupbv( &vals[0], &name ); + vals[1].bv_len = 0; + vals[1].bv_val = NULL; + attr_merge( e, slap_schema.si_ad_creatorsName, vals); + + ber_dupbv( &vals[0], &name ); + vals[1].bv_len = 0; + vals[1].bv_val = NULL; + attr_merge( e, slap_schema.si_ad_modifiersName, vals); + + ber_dupbv( &vals[0], ×tamp ); + vals[1].bv_len = 0; + vals[1].bv_val = NULL; + attr_merge( e, slap_schema.si_ad_createTimestamp, vals ); + + ber_dupbv( &vals[0], ×tamp ); + vals[1].bv_len = 0; + vals[1].bv_val = NULL; + attr_merge( e, slap_schema.si_ad_modifyTimestamp, vals ); + + ber_dupbv( &vals[0], &csn ); + vals[1].bv_len = 0; + vals[1].bv_val = NULL; + attr_merge( e, slap_schema.si_ad_entryCSN, vals ); + } + if (!dryrun) { ID id = be->be_entry_put( be, e, &bvtext ); if( id == NOID ) {