if( rc != LDAP_SUCCESS ) {
/* free entry */
bdb_cache_return_entry_rw(bdb->bi_dbenv, &bdb->bi_cache, e, rw, &lock);
+
} else {
- *ent = e;
- /* big drag. we need a place to store a read lock so we can
- * release it later??
- */
- if ( op && !boi ) {
- boi = op->o_tmpcalloc(1,sizeof(struct bdb_op_info),op->o_tmpmemctx);
- boi->boi_lock = lock;
- op->o_private = boi;
+ if ( slapMode == SLAP_SERVER_MODE ) {
+ *ent = e;
+ /* big drag. we need a place to store a read lock so we can
+ * release it later??
+ */
+ if ( op && !boi ) {
+ boi = op->o_tmpcalloc(1,sizeof(struct bdb_op_info),op->o_tmpmemctx);
+ boi->boi_lock = lock;
+ op->o_private = boi;
+ }
+
+ } else {
+ *ent = entry_dup( e );
+ bdb_cache_return_entry_rw(bdb->bi_dbenv, &bdb->bi_cache, e, rw, &lock);
}
}
rc = 1;
goto destroy;
}
+
+ } else if ( !BER_BVISNULL( &authcDN ) ) {
+ struct berval ndn;
+
+ rc = dnNormalize( 0, NULL, NULL, &authcDN, &ndn, NULL );
+ if ( rc != LDAP_SUCCESS ) {
+ fprintf( stderr, "autchDN=\"%s\" normalization failed %d (%s)\n",
+ authcDN.bv_val, rc,
+ ldap_err2string( rc ) );
+ rc = 1;
+ goto destroy;
+ }
+ ch_free( authcDN.bv_val );
+ authcDN = ndn;
}
+
if ( !BER_BVISNULL( &authcDN ) ) {
fprintf( stderr, "DN: \"%s\"\n", authcDN.bv_val );
}
lmax = 0;
lineno = 0;
- if( be->be_entry_open( be, 1 ) != 0 ) {
+ if( !dryrun && be->be_entry_open( be, 1 ) != 0 ) {
fprintf( stderr, "%s: could not open database.\n",
progname );
exit( EXIT_FAILURE );
}
}
+ if ( dryrun ) {
+ if ( verbose ) {
+ fprintf( stderr, "(dry) added: \"%s\"\n", e->e_dn );
+ }
+ goto done;
+ }
+
if ( update_ctxcsn == SLAP_TOOL_CTXCSN_KEEP &&
( replica_promotion || replica_demotion )) {
if ( is_entry_syncProviderSubentry( e )) {
}
if (( !is_entry_syncProviderSubentry( e ) &&
- !is_entry_syncConsumerSubentry( e )) ||
- ( !replica_promotion && !replica_demotion )) {
+ !is_entry_syncConsumerSubentry( e )) ||
+ ( !replica_promotion && !replica_demotion ))
+ {
+ /* dryrun moved earlier */
+ assert( !dryrun );
+
if (!dryrun) {
ID id = be->be_entry_put( be, e, &bvtext );
if( id == NOID ) {
}
}
+done:;
entry_free( e );
}
if ( ctxcsn_id == NOID ) {
ctxcsn_e = slap_create_context_csn_entry( be, &maxcsn );
+
+ /* dryrun moved earlier */
+ assert( !dryrun );
+
if ( !dryrun ) {
ctxcsn_id = be->be_entry_put( be, ctxcsn_e, &bvtext );
if( ctxcsn_id == NOID ) {
AC_MEMCPY( attr->a_vals[0].bv_val, maxcsn.bv_val, maxcsn.bv_len );
attr->a_vals[0].bv_val[maxcsn.bv_len] = '\0';
attr->a_vals[0].bv_len = maxcsn.bv_len;
+
+ /* dryrun moved earlier */
+ assert( !dryrun );
+
if ( !dryrun ) {
ctxcsn_id = be->be_entry_modify( be, ctxcsn_e, &bvtext );
if( ctxcsn_id == NOID ) {
if ( ctxcsn_id == NOID ) {
ctxcsn_e = slap_create_syncrepl_entry( be, &mc,
- &slap_syncrepl_cn_bv,
- &slap_syncrepl_bv );
+ &slap_syncrepl_cn_bv,
+ &slap_syncrepl_bv );
+
+ /* dryrun moved earlier */
+ assert( !dryrun );
+
if ( !dryrun ) {
ctxcsn_id = be->be_entry_put( be, ctxcsn_e, &bvtext );
if( ctxcsn_id == NOID ) {
AC_MEMCPY( attr->a_vals[0].bv_val, mc.bv_val, mc.bv_len );
attr->a_vals[0].bv_val[maxcsn.bv_len] = '\0';
attr->a_vals[0].bv_len = maxcsn.bv_len;
+
+ /* dryrun moved earlier */
+ assert( !dryrun );
+
if ( !dryrun ) {
ctxcsn_id = be->be_entry_modify( be,
ctxcsn_e, &bvtext );
if ( ctxcsn_id == NOID ) {
ctxcsn_e = slap_create_syncrepl_entry( be, &sei->cookie,
- &sei->rdn, &sei->cn );
+ &sei->rdn, &sei->cn );
+
+ /* dryrun moved earlier */
+ assert( !dryrun );
+
if ( !dryrun ) {
ctxcsn_id = be->be_entry_put( be, ctxcsn_e, &bvtext );
if( ctxcsn_id == NOID ) {
AC_MEMCPY( attr->a_vals[0].bv_val, sei->cookie.bv_val, sei->cookie.bv_len );
attr->a_vals[0].bv_val[sei->cookie.bv_len] = '\0';
attr->a_vals[0].bv_len = sei->cookie.bv_len;
+
+ /* dryrun moved earlier */
+ assert( !dryrun );
+
if ( !dryrun ) {
ctxcsn_id = be->be_entry_modify( be,
ctxcsn_e, &bvtext );
case SLAPDN:
case SLAPTEST:
options = "d:f:v";
+ mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
break;
case SLAPAUTH:
options = "d:f:U:vX:";
+ mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
break;
case SLAPINDEX:
case SLAPACL:
options = "b:D:d:f:U:v";
+ mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
break;
default:
break;
case 'D':
- ber_str2bv( optarg, 0, 0, &authcDN );
+ ber_str2bv( optarg, 0, 1, &authcDN );
break;
case 'f': /* specify a conf file */
be = select_backend( &nbase, 0, 0 );
ber_memfree( nbase.bv_val );
- if ( tool == SLAPACL ) {
+ switch ( tool ) {
+ case SLAPACL:
goto startup;
+
+ default:
+ break;
}
if( be == NULL ) {
#ifdef CSRIMALLOC
mal_dumpleaktrace( leakfile );
#endif
+
+ if ( !BER_BVISNULL( &authcDN ) ) {
+ ch_free( authcDN.bv_val );
+ }
}