From c6743b5a82bcbdb41dc4db52626b33d652cea9ff Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Thu, 29 Mar 2007 15:39:52 +0000 Subject: [PATCH] Add operational Attributes when creating frontend and config database entries. (Otherwise test049-sync-config fails) --- servers/slapd/bconfig.c | 94 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 15dd2500a2..7844eccbb6 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -6089,7 +6089,10 @@ config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text ) STRLENOF( "olcDatabase" ), "=frontend", STRLENOF( "=frontend" ))) { Entry *fe; - struct berval rdn; + struct berval rdn, vals[ 2 ]; + Attribute *attr; + vals[1].bv_len = 0; + vals[1].bv_val = NULL; memset( &ca, 0, sizeof(ConfigArgs)); ca.be = frontendDB; ca.bi = frontendDB->bd_info; @@ -6101,6 +6104,48 @@ config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text ) ca.bi->bi_type); fe = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn, &CFOC_DATABASE, ca.be->be_cf_ocs ); + if( attr_find( fe->e_attrs, slap_schema.si_ad_entryUUID ) + == NULL ) + { + char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ]; + vals[0].bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) ); + vals[0].bv_val = uuidbuf; + attr_merge_normalize_one( fe, slap_schema.si_ad_entryUUID, + vals, NULL ); + } + if ( attr_find( fe->e_attrs, slap_schema.si_ad_entryCSN) + == NULL ) + { + char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ]; + vals[0].bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), + 0, 0 ); + vals[0].bv_val = csnbuf; + attr_merge( fe, slap_schema.si_ad_entryCSN, vals, NULL ); + } + attr = attr_find( e->e_attrs, slap_schema.si_ad_creatorsName ); + if ( attr ) + { + attr_merge( fe, slap_schema.si_ad_creatorsName, + attr->a_vals, attr->a_nvals ); + } + attr = attr_find( e->e_attrs, slap_schema.si_ad_modifiersName ); + if ( attr ) + { + attr_merge( fe, slap_schema.si_ad_modifiersName, + attr->a_vals, attr->a_nvals ); + } + attr = attr_find( e->e_attrs, slap_schema.si_ad_createTimestamp ); + if (attr) + { + attr_merge( fe, slap_schema.si_ad_createTimestamp, + attr->a_vals, attr->a_nvals ); + } + attr = attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp ); + if (attr) + { + attr_merge( fe, slap_schema.si_ad_modifyTimestamp, + attr->a_vals, attr->a_nvals ); + } if ( fe && bi && bi->bi_tool_entry_put && bi->bi_tool_entry_put( &cfb->cb_db, fe, text ) != NOID ) { entry_put_got_frontend++; @@ -6125,7 +6170,10 @@ config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text ) STRLENOF( "olcDatabase" ), "=config", STRLENOF( "=config" )) ) { Entry *cfe; - struct berval rdn; + struct berval rdn, vals[ 2 ]; + Attribute *attr; + vals[1].bv_len = 0; + vals[1].bv_val = NULL; memset( &ca, 0, sizeof(ConfigArgs)); ca.be = LDAP_STAILQ_FIRST( &backendDB ); ca.bi = ca.be->bd_info; @@ -6136,6 +6184,48 @@ config_tool_entry_put( BackendDB *be, Entry *e, struct berval *text ) ca.bi->bi_type); cfe = config_build_entry( NULL, NULL, cfb->cb_root, &ca, &rdn, &CFOC_DATABASE, ca.be->be_cf_ocs ); + if( attr_find( cfe->e_attrs, slap_schema.si_ad_entryUUID ) + == NULL ) + { + char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ]; + vals[0].bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) ); + vals[0].bv_val = uuidbuf; + attr_merge_normalize_one( cfe, slap_schema.si_ad_entryUUID, + vals, NULL ); + } + if ( attr_find( cfe->e_attrs, slap_schema.si_ad_entryCSN) + == NULL ) + { + char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ]; + vals[0].bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), + 0, 0 ); + vals[0].bv_val = csnbuf; + attr_merge( cfe, slap_schema.si_ad_entryCSN, vals, NULL ); + } + attr = attr_find( e->e_attrs, slap_schema.si_ad_creatorsName ); + if ( attr ) + { + attr_merge( cfe, slap_schema.si_ad_creatorsName, + attr->a_vals, attr->a_nvals ); + } + attr = attr_find( e->e_attrs, slap_schema.si_ad_modifiersName ); + if ( attr ) + { + attr_merge( cfe, slap_schema.si_ad_modifiersName, + attr->a_vals, attr->a_nvals ); + } + attr = attr_find( e->e_attrs, slap_schema.si_ad_createTimestamp ); + if (attr) + { + attr_merge( cfe, slap_schema.si_ad_createTimestamp, + attr->a_vals, attr->a_nvals ); + } + attr = attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp ); + if (attr) + { + attr_merge( cfe, slap_schema.si_ad_modifyTimestamp, + attr->a_vals, attr->a_nvals ); + } if (cfe && bi && bi->bi_tool_entry_put && bi->bi_tool_entry_put( &cfb->cb_db, cfe, text ) != NOID ) { entry_put_got_frontend++; -- 2.39.5