#include "ldap_rq.h"
-const struct berval slap_syncrepl_bvc = BER_BVC("syncreplxxx");
-const struct berval slap_syncrepl_cn_bvc = BER_BVC("cn=syncreplxxx");
+static const struct berval slap_syncrepl_bvc = BER_BVC("syncreplxxx");
+static const struct berval slap_syncrepl_cn_bvc = BER_BVC("cn=syncreplxxx");
static void
syncrepl_del_nonpresent( LDAP *, Operation * );
struct berval base_bv = { 0, NULL };
struct berval pbase = { 0, NULL };
struct berval nbase = { 0, NULL };
- struct berval sub_bv = { 0, NULL };
struct berval psubrdn = { 0, NULL };
struct berval nsubrdn = { 0, NULL };
struct berval psub = { 0, NULL };
struct berval nsub = { 0, NULL };
- char substr[64];
Modifications *modlist = NULL;
Modifications *ml, *mlnext;
char *def_filter_str = NULL;
+ struct berval slap_syncrepl_bv = BER_BVNULL;
+
const char *text;
int match;
ber_str2bv( si->base, 0, 0, &base_bv );
dnPrettyNormal( 0, &base_bv, &pbase, &nbase, op.o_tmpmemctx );
- sprintf( substr, "cn=syncrepl%d", si->id );
- ber_str2bv( substr, 0, 0, &sub_bv );
- dnPrettyNormal( 0, &sub_bv, &psubrdn, &nsubrdn, op.o_tmpmemctx );
-
- build_new_dn( &op.o_req_dn, &pbase, &psubrdn, op.o_tmpmemctx );
- build_new_dn( &op.o_req_ndn, &nbase, &nsubrdn, op.o_tmpmemctx );
+ ber_dupbv( &slap_syncrepl_bv, (struct berval *) &slap_syncrepl_bvc );
+ slap_syncrepl_bv.bv_len = snprintf( slap_syncrepl_bv.bv_val,
+ slap_syncrepl_bvc.bv_len,
+ "syncrepl%d", si->id );
+ build_new_dn( &op.o_req_dn, &pbase, &slap_syncrepl_bv, op.o_tmpmemctx );
+ build_new_dn( &op.o_req_ndn, &nbase, &slap_syncrepl_bv, op.o_tmpmemctx );
/* set callback function */
cb.sc_response = cookie_callback;
si->syncCookie = NULL;
be->be_search( &op, &rs );
+ if ( op.o_req_dn.bv_val )
+ ch_free( op.o_req_dn.bv_val );
+ if ( op.o_req_ndn.bv_val )
+ ch_free( op.o_req_ndn.bv_val );
+ if ( op.ors_filter )
+ filter_free( op.ors_filter );
+ if ( op.ors_filterstr.bv_val )
+ ch_free( op.ors_filterstr.bv_val );
+ if ( slap_syncrepl_bv.bv_val )
+ ch_free( slap_syncrepl_bv.bv_val );
+ if ( pbase.bv_val )
+ ch_free( pbase.bv_val );
+ if ( nbase.bv_val )
+ ch_free( nbase.bv_val );
+
ber_dupbv( &syncCookie_req, si->syncCookie );
psub = be->be_nsuffix[0];
rc = be->be_search( op, &rs );
- ch_free( op->o_req_dn.bv_val );
- ch_free( op->o_req_ndn.bv_val );
- filter_free( op->ors_filter );
- ch_free( op->ors_filterstr.bv_val );
+ if ( op->o_req_dn.bv_val )
+ ch_free( op->o_req_dn.bv_val );
+ if ( op->o_req_ndn.bv_val )
+ ch_free( op->o_req_ndn.bv_val );
+ if ( op->ors_filter )
+ filter_free( op->ors_filter );
+ if ( op->ors_filterstr.bv_val )
+ ch_free( op->ors_filterstr.bv_val );
cb.sc_response = null_callback;
cb.sc_private = si;
be->be_search( op, &rs );
op->o_nocaching = 0;
+ if ( op->o_req_dn.bv_val )
+ ch_free( op->o_req_dn.bv_val );
+ if ( op->o_req_ndn.bv_val )
+ ch_free( op->o_req_ndn.bv_val );
+ if ( op->ors_filter )
+ filter_free( op->ors_filter );
+ if ( op->ors_filterstr.bv_val )
+ ch_free( op->ors_filterstr.bv_val );
+
if ( !LDAP_LIST_EMPTY( &si->nonpresentlist ) ) {
np_list = LDAP_LIST_FIRST( &si->nonpresentlist );
while ( np_list != NULL ) {
}
}
- if ( op->o_req_dn.bv_val )
- ch_free( op->o_req_dn.bv_val );
- if ( op->o_req_ndn.bv_val )
- ch_free( op->o_req_ndn.bv_val );
- filter_free( op->ors_filter );
- ch_free( op->ors_filterstr.bv_val );
-
return;
}
return;
}
+static struct berval ocbva[] = {
+ BER_BVC("top"),
+ BER_BVC("subentry"),
+ BER_BVC("syncConsumerSubentry"),
+ BER_BVNULL
+};
+
+static struct berval cnbva[] = {
+ BER_BVNULL,
+ BER_BVNULL
+};
+
+static struct berval ssbva[] = {
+ BER_BVC("{}"),
+ BER_BVNULL
+};
+
+static struct berval scbva[] = {
+ BER_BVC("subentry"),
+ BER_BVNULL
+};
+
void
syncrepl_updateCookie(
syncinfo_t *si,
Modifications *modlist = NULL;
Modifications **modtail = &modlist;
- struct berval* ocbva = NULL;
- struct berval* cnbva = NULL;
- struct berval* ssbva = NULL;
- struct berval* scbva = NULL;
-
- char substr[64];
- char rdnstr[67];
const char *text;
char txtbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof txtbuf;
Entry* e = NULL;
int rc;
- struct berval sub_bv = { 0, NULL };
- struct berval psubrdn = { 0, NULL };
+ struct berval slap_syncrepl_dn_bv = BER_BVNULL;
+ struct berval slap_syncrepl_cn_bv = BER_BVNULL;
slap_callback cb;
SlapReply rs = {REP_RESULT};
- ocbva = ( struct berval * ) ch_calloc( 4, sizeof( struct berval ));
- cnbva = ( struct berval * ) ch_calloc( 2, sizeof( struct berval ));
- ssbva = ( struct berval * ) ch_calloc( 2, sizeof( struct berval ));
- scbva = ( struct berval * ) ch_calloc( 2, sizeof( struct berval ));
-
/* update in memory cookie */
if ( si->syncCookie != NULL ) {
ber_bvfree( si->syncCookie );
}
si->syncCookie = ber_dupbv( NULL, syncCookie );
- ber_str2bv( "top", strlen("top"), 1, &ocbva[0] );
- ber_str2bv( "subentry", strlen("subentry"), 1, &ocbva[1] );
- ber_str2bv( "syncConsumerSubentry",
- strlen("syncConsumerSubentry"), 1, &ocbva[2] );
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
mod->sml_op = LDAP_MOD_REPLACE;
- ber_str2bv( "objectClass", strlen("objectClass"), 1, &mod->sml_type );
+ mod->sml_desc = slap_schema.si_ad_objectClass;
+ mod->sml_type = mod->sml_desc->ad_cname;
mod->sml_bvalues = ocbva;
*modtail = mod;
modtail = &mod->sml_next;
- sprintf( substr, "syncrepl%d", si->id );
- sprintf( rdnstr, "cn=%s", substr );
- ber_str2bv( substr, strlen( substr ), 1, &cnbva[0] );
- ber_str2bv( rdnstr, strlen( rdnstr ), 1, &psubrdn );
+ ber_dupbv( &cnbva[0], (struct berval *) &slap_syncrepl_bvc );
+ cnbva[0].bv_len = snprintf( cnbva[0].bv_val,
+ slap_syncrepl_bvc.bv_len,
+ "syncrepl%d", si->id );
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
mod->sml_op = LDAP_MOD_REPLACE;
- ber_str2bv( "cn", strlen("cn"), 1, &mod->sml_type );
+ mod->sml_desc = slap_schema.si_ad_cn;
+ mod->sml_type = mod->sml_desc->ad_cname;
mod->sml_bvalues = cnbva;
*modtail = mod;
modtail = &mod->sml_next;
ber_dupbv( &scbva[0], si->syncCookie );
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
mod->sml_op = LDAP_MOD_REPLACE;
- ber_str2bv( "syncreplCookie", strlen("syncreplCookie"),
- 1, &mod->sml_type );
+ mod->sml_desc = slap_schema.si_ad_syncreplCookie;
+ mod->sml_type = mod->sml_desc->ad_cname;
mod->sml_bvalues = scbva;
*modtail = mod;
modtail = &mod->sml_next;
- ber_str2bv( "{}", strlen("{}"), 1, &ssbva[0] );
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
mod->sml_op = LDAP_MOD_REPLACE;
- ber_str2bv( "subtreeSpecification",
- strlen("subtreeSpecification"), 1, &mod->sml_type );
+ mod->sml_desc = slap_schema.si_ad_subtreeSpecification;
+ mod->sml_type = mod->sml_desc->ad_cname;
mod->sml_bvalues = ssbva;
*modtail = mod;
modtail = &mod->sml_next;
+#if 0
rc = slap_mods_check( modlist, 1, &text, txtbuf, textlen, NULL );
if ( rc != LDAP_SUCCESS ) {
text, 0, 0 );
#endif
}
+#endif
op->o_tag = LDAP_REQ_ADD;
rc = slap_mods_opattrs( op, modlist, modtail,
e = ( Entry * ) ch_calloc( 1, sizeof( Entry ));
- build_new_dn( &sub_bv, pdn, &psubrdn, NULL );
- dnPrettyNormal( NULL, &sub_bv, &e->e_name, &e->e_nname, NULL );
- ch_free( sub_bv.bv_val );
- ch_free( psubrdn.bv_val );
+ ber_dupbv( &slap_syncrepl_cn_bv, (struct berval *) &slap_syncrepl_cn_bvc );
+ slap_syncrepl_cn_bv.bv_len = snprintf( slap_syncrepl_cn_bv.bv_val,
+ slap_syncrepl_cn_bvc.bv_len,
+ "cn=syncrepl%d", si->id );
+
+ build_new_dn( &slap_syncrepl_dn_bv, pdn, &slap_syncrepl_cn_bv, NULL );
+ dnPrettyNormal( NULL, &slap_syncrepl_dn_bv, &e->e_name, &e->e_nname, NULL );
+
+ if ( slap_syncrepl_cn_bv.bv_val )
+ ch_free( slap_syncrepl_cn_bv.bv_val );
+ if ( slap_syncrepl_dn_bv.bv_val )
+ ch_free( slap_syncrepl_dn_bv.bv_val );
e->e_attrs = NULL;
done :
- if ( modlist ) {
- slap_mods_free( modlist );
+ if ( cnbva[0].bv_val )
+ ch_free( cnbva[0].bv_val );
+
+ for ( ; ml != NULL; ml = mlnext ) {
+ mlnext = ml->sml_next;
+ free( ml );
}
return;
return LDAP_SUCCESS;
}
-static struct berval ocbva[] = {
- BER_BVC("top"),
- BER_BVC("subentry"),
- BER_BVC("syncProviderSubentry"),
- {0,NULL}
-};
-
Entry *
slap_create_syncrepl_entry(
Backend *be,