## top-level directory of the distribution or, alternatively, at
## <http://www.OpenLDAP.org/license.html>.
-SLAPTOOLS=slapadd slapcat slapindex slappasswd
+SLAPTOOLS=slapadd slapcat slapdn slapindex slappasswd slaptest
PROGRAMS=slapd $(SLAPTOOLS)
XPROGRAMS=sslapd libbackends.a .backend liboverlays.a
XSRCS=version.c
oidm.c starttls.c index.c sets.c referral.c root_dse.c \
sasl.c module.c mra.c mods.c sl_malloc.c limits.c \
backglue.c operational.c matchedValues.c cancel.c syncrepl.c \
- slapadd.c slapcat.c slapcommon.c slapindex.c slappasswd.c \
- backover.c ctxcsn.c ldapsync.c sessionlog.c $(@PLAT@_SRCS)
+ backover.c ctxcsn.c ldapsync.c sessionlog.c \
+ slapadd.c slapcat.c slapcommon.c slapdn.c slapindex.c \
+ slappasswd.c slaptest.c \
+ $(@PLAT@_SRCS)
OBJS = main.o globals.o config.o daemon.o \
connection.o search.o filter.o add.o cr.o \
oidm.o starttls.o index.o sets.o referral.o root_dse.o \
sasl.o module.o mra.o mods.o sl_malloc.o limits.o \
backglue.o operational.o matchedValues.o cancel.o syncrepl.o \
- slapadd.o slapcat.o slapcommon.o slapindex.o slappasswd.o \
- backover.o ctxcsn.o ldapsync.o sessionlog.o $(@PLAT@_OBJS)
+ backover.o ctxcsn.o ldapsync.o sessionlog.o \
+ slapadd.o slapcat.o slapcommon.o slapdn.o slapindex.o \
+ slappasswd.o slaptest.o \
+ $(@PLAT@_OBJS)
LDAP_INCDIR= ../../include -I$(srcdir)/slapi
LDAP_LIBDIR= ../../libraries
#ifndef BDB_MULTIPLE_SUFFIXES
}
- while( !be_issuffix( op->o_bd, &ptr )) {
+ while( !be_issuffix( op->o_bd, &ptr ))
#else
- for (;;) {
+ for (;;)
#endif
+ {
ptr.bv_val[-1] = DN_SUBTREE_PREFIX;
rc = bdb_idl_insert_key( op->o_bd, db, txn, &key, e->e_id );
DBT key;
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
DB *db = bdb->bi_dn2id->bdi_db;
- int prefix = op->ors_scope == LDAP_SCOPE_SUBTREE ? DN_SUBTREE_PREFIX :
- DN_ONE_PREFIX;
+ int prefix = ( op->ors_scope == LDAP_SCOPE_ONELEVEL )
+ ? DN_ONE_PREFIX : DN_SUBTREE_PREFIX;
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS,
- "=> bdb_dn2ididl( \"%s\" )\n", e->e_nname.bv_val, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_dn2ididl( \"%s\" )\n",
+ e->e_nname.bv_val, 0, 0 );
#else
- Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2idl( \"%s\" )\n", e->e_nname.bv_val, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "=> bdb_dn2idl( \"%s\" )\n",
+ e->e_nname.bv_val, 0, 0 );
#endif
#ifndef BDB_MULTIPLE_SUFFIXES
- if (prefix == DN_SUBTREE_PREFIX && BEI(e)->bei_parent->bei_id == 0 )
- {
+ if ( prefix == DN_SUBTREE_PREFIX && BEI(e)->bei_parent->bei_id == 0 ) {
BDB_IDL_ALL(bdb, ids);
return 0;
}
#endif
#ifndef BDB_MULTIPLE_SUFFIXES
- if ( op->ors_scope == LDAP_SCOPE_SUBTREE &&
- BEI(e)->bei_parent->bei_id == 0 ) {
+ if ( op->ors_scope != LDAP_SCOPE_ONELEVEL &&
+ BEI(e)->bei_parent->bei_id == 0 )
+ {
BDB_IDL_ALL( bdb, ids );
return 0;
}
cx.ei = BEI(e);
cx.bdb = bdb;
cx.db = cx.bdb->bi_dn2id->bdi_db;
- cx.prefix = op->ors_scope == LDAP_SCOPE_SUBTREE ? DN_SUBTREE_PREFIX :
- DN_ONE_PREFIX;
+ cx.prefix = op->ors_scope == LDAP_SCOPE_ONELEVEL
+ ? DN_ONE_PREFIX : DN_SUBTREE_PREFIX;
cx.ids = ids;
cx.buf = stack;
cx.op = op;
#else
Debug( LDAP_DEBUG_FILTER, "=> bdb_filter_candidates\n", 0, 0, 0 );
#endif
+#if 0
+ char *subtree="SUBTREE";
+#endif
switch ( f->f_choice ) {
case SLAPD_FILTER_COMPUTED:
/* This technically is not the same as FALSE, but it
* certainly will produce no matches.
*/
- /* FALLTHRU */
+ /* FALL THRU */
case LDAP_COMPARE_FALSE:
BDB_IDL_ZERO( ids );
break;
BDB_IDL_ALL( bdb, ids );
} break;
case LDAP_SUCCESS:
- /* this is a pre-computed scope, leave it alone */
+ /* this is a pre-computed scope, leave it alone */
break;
}
break;
#if 0 /* Not used any more, search calls bdb_dn2idl directly */
case SLAPD_FILTER_DN_ONE:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN ONE\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN ONE\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 );
#endif
}
break;
+ case SLAPD_FILTER_DN_CHILDREN:
+ subtree="CHILDREN";
+ /* Fall Thru */
case SLAPD_FILTER_DN_SUBTREE:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN SUBTREE\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tDN %s\n",
+ subtree, 0, 0 );
#else
- Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_FILTER, "\tDN %s\n",
+ subtree, 0, 0 );
#endif
rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_SUBTREE_PREFIX, ids,
stack, op->o_tmpmemctx );
#endif
case LDAP_FILTER_PRESENT:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tPRESENT\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tPRESENT\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tPRESENT\n", 0, 0, 0 );
#endif
case LDAP_FILTER_EQUALITY:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tEQUALITY\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tEQUALITY\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 );
#endif
case LDAP_FILTER_APPROX:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAPPROX\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAPPROX\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 );
#endif
case LDAP_FILTER_SUBSTRINGS:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tSUBSTRINGS\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tSUBSTRINGS\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tSUBSTRINGS\n", 0, 0, 0 );
#endif
case LDAP_FILTER_GE:
/* no GE index, use pres */
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tGE\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tGE\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 );
#endif
case LDAP_FILTER_LE:
/* no LE index, use pres */
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tLE\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tLE\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 );
#endif
case LDAP_FILTER_NOT:
/* no indexing to support NOT filters */
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tNOT\n",0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tNOT\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tNOT\n", 0, 0, 0 );
#endif
case LDAP_FILTER_AND:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAND\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tAND\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tAND\n", 0, 0, 0 );
#endif
case LDAP_FILTER_OR:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tOR\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tOR\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tOR\n", 0, 0, 0 );
#endif
default:
#ifdef NEW_LOGGING
- LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tUNKNOWN\n", 0, 0, 0 );
+ LDAP_LOG ( INDEX, ARGS, "=> bdb_filter_candidates: \tUNKNOWN\n",
+ 0, 0, 0 );
#else
Debug( LDAP_DEBUG_FILTER, "\tUNKNOWN %lu\n",
(unsigned long) f->f_choice, 0, 0 );
rs->sr_text = "maximum deref depth exceeded";
while (BDB_IDL_N(tmp) < op->o_bd->be_max_deref_depth) {
-
/* Remember the last entry we looked at, so we can
* report broken links
*/
rs->sr_err = bdb_dn2entry( op, NULL, &ndn, &ei,
0, locker, &lockr );
- if ( ei ) e = ei->bei_e;
- else e = NULL;
+ if ( ei ) {
+ e = ei->bei_e;
+ } else {
+ e = NULL;
+ }
if (!e) {
rs->sr_err = LDAP_ALIAS_PROBLEM;
u_int32_t locker,
ID *ids,
ID *scopes,
- ID *stack
-)
+ ID *stack )
{
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
ID *aliases, *curscop, *subscop, *visited, *newsubs, *oldsubs, *tmp;
*/
BDB_IDL_CPY( curscop, aliases );
rs->sr_err = bdb_dn2idl( op, e, subscop,
- subscop2+BDB_IDL_DB_SIZE );
+ subscop2+BDB_IDL_DB_SIZE );
if (first) {
first = 0;
} else {
/* If this is a OneLevel search, we're done; oldsubs only had one
* ID in it. For a Subtree search, oldsubs may be a list of scope IDs.
*/
- if (op->ors_scope != LDAP_SCOPE_SUBTREE) break;
+ if ( op->ors_scope == LDAP_SCOPE_ONELEVEL ) break;
nextido:
ido = bdb_idl_next( oldsubs, &cursoro );
return rs->sr_err;
}
-static
-int is_sync_protocol( Operation *op )
-{
- if ( op->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST )
- return 1;
- return 0;
-}
-
+#define is_sync_protocol(op) \
+ ((op)->o_sync_mode & SLAP_SYNC_REFRESH_AND_PERSIST)
+
#define IS_BDB_REPLACE(type) (( type == LDAP_PSEARCH_BY_DELETE ) || \
( type == LDAP_PSEARCH_BY_SCOPEOUT ))
#define IS_PSEARCH (op != sop)
id != NOID && !no_sync_state_change;
id = bdb_idl_next( candidates, &cursor ) )
{
- int scopeok = 0;
+ int scopeok = 0;
loop_begin:
/* check for abandon */
if ( ei->bei_parent->bei_id == base.e_id ) scopeok = 1;
break;
+#ifdef LDAP_SCOPE_CHILDREN
+ case LDAP_SCOPE_CHILDREN:
+ if ( id == base.e_id ) break;
+ /* Fall-thru */
+#endif
case LDAP_SCOPE_SUBTREE: {
EntryInfo *tmp;
for (tmp = BEI(e); tmp->bei_parent;
if ( !scopeok && BDB_IDL_N(scopes) ) {
unsigned x;
if ( sop->ors_scope == LDAP_SCOPE_ONELEVEL ) {
- x = bdb_idl_search( scopes,
- e->e_id );
- if ( scopes[x] == e->e_id )
- scopeok = 1;
+ x = bdb_idl_search( scopes, e->e_id );
+ if ( scopes[x] == e->e_id ) scopeok = 1;
} else {
- /* subtree, walk up the tree */
+ /* subtree, walk up the tree */
EntryInfo *tmp = BEI(e);
for (;tmp->bei_parent; tmp=tmp->bei_parent) {
x = bdb_idl_search( scopes, tmp->bei_id );
&& is_entry_referral( e ) )
{
BerVarray erefs = get_entry_referrals( sop, e );
- rs->sr_ref = referral_rewrite( erefs,
- &e->e_name, NULL,
- sop->oq_search.rs_scope == LDAP_SCOPE_SUBTREE
- ? LDAP_SCOPE_SUBTREE
- : LDAP_SCOPE_BASE );
+ rs->sr_ref = referral_rewrite( erefs, &e->e_name, NULL,
+ sop->oq_search.rs_scope == LDAP_SCOPE_ONELEVEL
+ ? LDAP_SCOPE_BASE : LDAP_SCOPE_SUBTREE );
send_search_reference( sop, rs );
} else {
struct berval cookie;
slap_compose_sync_cookie( sop, &cookie,
- search_context_csn,
- sop->o_sync_state.sid,
- sop->o_sync_state.rid );
+ search_context_csn,
+ sop->o_sync_state.sid,
+ sop->o_sync_state.rid );
rs->sr_err = slap_build_sync_state_ctrl( sop,
rs, e, entry_sync_state, ctrls,
num_ctrls++, 1, &cookie );
if ( rs->sr_err != LDAP_SUCCESS ) goto done;
rs->sr_attrs = attrs;
rs->sr_ctrls = ctrls;
+ rs->sr_flags = 0;
result = send_search_entry( sop, rs );
- if ( cookie.bv_val )
- ch_free( cookie.bv_val );
+ if ( cookie.bv_val ) ch_free( cookie.bv_val );
sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
- sop->o_tmpmemctx );
+ sop->o_tmpmemctx );
sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
rs->sr_ctrls = NULL;
}
} else if ( ps_type == LDAP_PSEARCH_BY_PREMODIFY ) {
struct psid_entry* psid_e;
- psid_e = (struct psid_entry *) ch_calloc (1,
+ psid_e = (struct psid_entry *) ch_calloc(1,
sizeof(struct psid_entry));
psid_e->ps_op = sop;
LDAP_LIST_INSERT_HEAD( &op->o_pm_list,
}
} else {
if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
-
if ( rc_sync == LDAP_COMPARE_TRUE ) { /* ADD */
rs->sr_err = slap_build_sync_state_ctrl( sop,
rs, e, entry_sync_state, ctrls,
if ( rs->sr_err != LDAP_SUCCESS ) goto done;
rs->sr_ctrls = ctrls;
rs->sr_attrs = sop->oq_search.rs_attrs;
+ rs->sr_flags = 0;
result = send_search_entry( sop, rs );
sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
- sop->o_tmpmemctx );
+ sop->o_tmpmemctx );
sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
rs->sr_ctrls = NULL;
} else { /* PRESENT */
if ( sync_send_present_mode ) {
result = slap_build_syncUUID_set( sop,
- &syncUUID_set, e );
+ &syncUUID_set, e );
if ( result <= 0 ) {
result = -1;
} else {
syncUUID_set_cnt++;
- if ( syncUUID_set_cnt == SLAP_SYNCUUID_SET_SIZE ) {
+ if ( syncUUID_set_cnt ==
+ SLAP_SYNCUUID_SET_SIZE )
+ {
rs->sr_err = LDAP_SUCCESS;
rs->sr_rspoid = LDAP_SYNC_INFO;
rs->sr_ctrls = NULL;
result = slap_send_syncinfo( sop, rs,
- LDAP_TAG_SYNC_ID_SET,
- NULL, 0, syncUUID_set, 0 );
- if ( result != LDAP_SUCCESS )
+ LDAP_TAG_SYNC_ID_SET,
+ NULL, 0, syncUUID_set, 0 );
+ if ( result != LDAP_SUCCESS ) {
result = -1;
+ }
ber_bvarray_free_x( syncUUID_set,
- sop->o_tmpmemctx );
+ sop->o_tmpmemctx );
syncUUID_set = NULL;
syncUUID_set_cnt = 0;
}
} else {
rs->sr_attrs = sop->oq_search.rs_attrs;
rs->sr_ctrls = NULL;
+ rs->sr_flags = 0;
result = send_search_entry( sop, rs );
}
}
rs->sr_rspoid = LDAP_SYNC_INFO;
rs->sr_ctrls = NULL;
slap_send_syncinfo( sop, rs, LDAP_TAG_SYNC_ID_SET,
- NULL, 0, syncUUID_set, 0 );
+ NULL, 0, syncUUID_set, 0 );
ber_bvarray_free_x( syncUUID_set, sop->o_tmpmemctx );
syncUUID_set_cnt = 0;
}
if ( sop->o_sync_mode & SLAP_SYNC_REFRESH ) {
if ( sop->o_sync_mode & SLAP_SYNC_PERSIST ) {
struct berval cookie;
- slap_compose_sync_cookie( sop, &cookie,
- search_context_csn,
- sop->o_sync_state.sid,
- sop->o_sync_state.rid );
+ slap_compose_sync_cookie( sop, &cookie, search_context_csn,
+ sop->o_sync_state.sid, sop->o_sync_state.rid );
if ( sync_send_present_mode ) {
rs->sr_err = LDAP_SUCCESS;
if ( !no_sync_state_change ) {
int slog_found = 0;
ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
- LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
+ LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list,
+ o_ps_link )
+ {
if ( ps_list->o_sync_slog_size > 0 ) {
- if ( ps_list->o_sync_state.sid == sop->o_sync_state.sid ) {
+ if ( ps_list->o_sync_state.sid ==
+ sop->o_sync_state.sid ) {
slog_found = 1;
break;
}
} else {
/* refreshOnly mode */
struct berval cookie;
- slap_compose_sync_cookie( sop, &cookie,
- search_context_csn,
- sop->o_sync_state.sid,
- sop->o_sync_state.rid );
+ slap_compose_sync_cookie( sop, &cookie, search_context_csn,
+ sop->o_sync_state.sid, sop->o_sync_state.rid );
if ( sync_send_present_mode ) {
slap_build_sync_done_ctrl( sop, rs, ctrls,
int slog_found = 0;
ldap_pvt_thread_rdwr_rlock( &bdb->bi_pslist_rwlock );
LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list,
- o_ps_link ) {
+ o_ps_link )
+ {
if ( ps_list->o_sync_slog_size > 0 ) {
if ( ps_list->o_sync_state.sid ==
sop->o_sync_state.sid ) {
rs->sr_ctrls = ctrls;
rs->sr_ref = rs->sr_v2ref;
- rs->sr_err = (rs->sr_v2ref == NULL) ? LDAP_SUCCESS : LDAP_REFERRAL;
+ rs->sr_err = (rs->sr_v2ref == NULL)
+ ? LDAP_SUCCESS : LDAP_REFERRAL;
rs->sr_rspoid = NULL;
send_ldap_result( sop, rs );
if ( ctrls[num_ctrls-1]->ldctl_value.bv_val != NULL ) {
- sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val, sop->o_tmpmemctx );
+ sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val,
+ sop->o_tmpmemctx );
}
sl_free( ctrls[--num_ctrls], sop->o_tmpmemctx );
ctrls[num_ctrls] = NULL;
- if ( cookie.bv_val )
- ch_free( cookie.bv_val );
+ if ( cookie.bv_val ) ch_free( cookie.bv_val );
}
} else {
rs->sr_ctrls = NULL;
done:
if( !IS_PSEARCH && e != NULL ) {
/* free reader lock */
- bdb_cache_return_entry_r ( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
+ bdb_cache_return_entry_r( bdb->bi_dbenv, &bdb->bi_cache, e, &lock );
}
- LOCK_ID_FREE (bdb->bi_dbenv, locker );
+ LOCK_ID_FREE( bdb->bi_dbenv, locker );
ber_bvfree( search_context_csn );
static int oc_filter(
Filter *f,
int cur,
- int *max
-)
+ int *max )
{
int rc = 0;
if( cur > *max ) *max = cur;
- switch(f->f_choice) {
+ switch( f->f_choice ) {
case LDAP_FILTER_PRESENT:
if (f->f_desc == slap_schema.si_ad_objectClass) {
rc = 1;
case LDAP_FILTER_AND:
case LDAP_FILTER_OR:
cur++;
- for (f=f->f_and; f; f=f->f_next) {
+ for ( f=f->f_and; f; f=f->f_next ) {
(void) oc_filter(f, cur, max);
}
break;
/* Dummy; we compute scope separately now */
nf.f_choice = SLAPD_FILTER_COMPUTED;
nf.f_result = LDAP_SUCCESS;
- nf.f_next = xf.f_or == op->oq_search.rs_filter
+ nf.f_next = ( xf.f_or == op->oq_search.rs_filter )
? op->oq_search.rs_filter : &xf ;
/* Filter depth increased again, adding dummy clause */
depth++;
lastid, rs->sr_nentries, NULL );
#else
Debug(LDAP_DEBUG_ARGS, "send_pagerequest_response: lastid: (0x%08lx) "
- "nentries: (0x%081x)\n", lastid, rs->sr_nentries, NULL );
+ "nentries: (0x%081x)\n", lastid, rs->sr_nentries, NULL );
#endif
ctrl.ldctl_value.bv_val = NULL;
if( rc == LDAP_COMPARE_TRUE ) {
rs->sr_entry = e;
rs->sr_attrs = op->oq_search.rs_attrs;
+ rs->sr_flags = REP_ENTRY_MODIFIABLE;
send_search_entry( op, rs );
rs->sr_entry = NULL;
rs->sr_attrs = NULL;
/* URI of server to query (preferred over "server" directive) */
} else if ( strcasecmp( argv[0], "uri" ) == 0 ) {
+ LDAPURLDesc *lud, tmplud;
+
if (argc != 2) {
- fprintf( stderr,
- "%s: line %d: missing address in \"uri <address>\" line\n",
- fname, lineno );
+ fprintf( stderr, "%s: line %d: "
+ "missing uri "
+ "in \"uri <uri>\" line\n",
+ fname, lineno );
return( 1 );
}
- if (li->url != NULL)
- ch_free(li->url);
- li->url = ch_strdup(argv[1]);
+ if ( li->url != NULL ) {
+ ch_free( li->url );
+ }
+
+ if ( ldap_url_parse( argv[ 1 ], &lud ) != LDAP_URL_SUCCESS ) {
+ fprintf( stderr, "%s: line %d: "
+ "unable to parse uri \"%s\" "
+ "in \"uri <uri>\" line\n",
+ fname, lineno, argv[ 1 ] );
+ return 1;
+ }
+
+ if ( ( lud->lud_dn != NULL && lud->lud_dn[0] != '\0' )
+ || lud->lud_attrs != NULL
+ || lud->lud_filter != NULL
+ || lud->lud_exts != NULL )
+ {
+ fprintf( stderr, "%s: line %d: "
+ "warning, only protocol, "
+ "host and port allowed "
+ "in \"uri <uri>\" line\n",
+ fname, lineno );
+ }
+
+#if 0
+ tmplud = *lud;
+ tmplud.lud_dn = NULL;
+ tmplud.lud_attrs = NULL;
+ tmplud.lud_filter = NULL;
+ if ( !ldap_is_ldapi_url( argv[ 1 ] ) ) {
+ tmplud.lud_exts = NULL;
+ tmplud.lud_crit_exts = 0;
+ }
+
+ li->url = ldap_url_desc2str( &tmplud );
+ if ( li->url == NULL ) {
+ fprintf( stderr, "%s: line %d: "
+ "unable to rebuild uri \"%s\" "
+ "in \"uri <uri>\" line\n",
+ fname, lineno, argv[ 1 ] );
+ return 1;
+ }
+#else
+ li->url = ch_strdup( argv[ 1 ] );
+#endif
+
+ ldap_free_urldesc( lud );
/* name to use for ldap_back_group */
} else if ( strcasecmp( argv[0], "binddn" ) == 0 ) {
LDAP_BUILD_ENTRY_PRIVATE)) == LDAP_SUCCESS ) {
rs->sr_entry = &ent;
rs->sr_attrs = op->ors_attrs;
+ rs->sr_flags = 0;
abort = send_search_entry( op, rs );
while (ent.e_attrs) {
Attribute *a;
Filter *f
)
{
+ char *sub = "SUBTREE";
ID_BLOCK *result;
#ifdef NEW_LOGGING
}
break;
+#ifdef SLAPD_FILTER_DN_CHILDREN
+ case SLAPD_FILTER_DN_CHILDREN:
+ sub = "CHILDREN";
+#endif
case SLAPD_FILTER_DN_SUBTREE:
#ifdef NEW_LOGGING
LDAP_LOG( FILTER, DETAIL1,
- "filter_candidates: DN SUBTREE (%s)\n", f->f_dn, 0, 0 );
+ "filter_candidates: DN %s (%s)\n", sub, f->f_dn, 0 );
#else
- Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_FILTER,
+ "\tDN %s\n", sub, 0, 0 );
#endif
/* an error is treated as an empty list */
{
scopeok = dnIsSuffix( &e->e_nname, &realbase );
+#ifdef LDAP_SCOPE_SUBORDINATE
+ } else if ( !scopeok
+ && op->ors_scope == LDAP_SCOPE_SUBORDINATE )
+ {
+ scopeok = !dn_match( &e->e_nname, &realbase )
+ && dnIsSuffix( &e->e_nname, &realbase );
+#endif
+
} else {
scopeok = 1;
}
{
scopeok = dnIsSuffix( &e->e_nname, &realbase );
+#ifdef LDAP_SCOPE_SUBORDINATE
+ } else if ( !scopeok &&
+ op->ors_scope == LDAP_SCOPE_SUBORDINATE )
+ {
+ scopeok = !dn_match( &e->e_nname, &realbase )
+ && dnIsSuffix( &e->e_nname, &realbase );
+#endif
+
} else {
scopeok = 1;
}
}
if (e) {
+ rs->sr_flags = 0;
result = send_search_entry( op, rs );
switch (result) {
operational.c \
cache.c entry.c \
backend.c database.c thread.c conn.c rww.c log.c \
- operation.c sent.c listener.c time.c
+ operation.c sent.c listener.c time.c overlay.c
OBJS = init.lo search.lo compare.lo modify.lo bind.lo \
operational.lo \
cache.lo entry.lo \
backend.lo database.lo thread.lo conn.lo rww.lo log.lo \
- operation.lo sent.lo listener.lo time.lo
+ operation.lo sent.lo listener.lo time.lo overlay.lo
LDAP_INCDIR= ../../../include
LDAP_LIBDIR= ../../../libraries
AttributeDescription *mi_ad_monitorConnectionLocalAddress;
AttributeDescription *mi_ad_monitorConnectionPeerAddress;
AttributeDescription *mi_ad_monitorTimestamp;
+ AttributeDescription *mi_ad_monitorOverlay;
/*
* Generic description attribute
AttributeDescription *mi_ad_description;
AttributeDescription *mi_ad_seeAlso;
AttributeDescription *mi_ad_l;
+ AttributeDescription *mi_ad_labeledURI;
};
/*
* DNs
*/
+
+#define SLAPD_MONITOR_AT "cn"
+
#define SLAPD_MONITOR_LISTENER 0
#define SLAPD_MONITOR_LISTENER_NAME "Listeners"
#define SLAPD_MONITOR_LISTENER_RDN \
- "cn=" SLAPD_MONITOR_LISTENER_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LISTENER_NAME
#define SLAPD_MONITOR_LISTENER_DN \
SLAPD_MONITOR_LISTENER_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_DATABASE 1
#define SLAPD_MONITOR_DATABASE_NAME "Databases"
#define SLAPD_MONITOR_DATABASE_RDN \
- "cn=" SLAPD_MONITOR_DATABASE_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_DATABASE_NAME
#define SLAPD_MONITOR_DATABASE_DN \
SLAPD_MONITOR_DATABASE_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_BACKEND 2
#define SLAPD_MONITOR_BACKEND_NAME "Backends"
#define SLAPD_MONITOR_BACKEND_RDN \
- "cn=" SLAPD_MONITOR_BACKEND_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_BACKEND_NAME
#define SLAPD_MONITOR_BACKEND_DN \
SLAPD_MONITOR_BACKEND_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_THREAD 3
#define SLAPD_MONITOR_THREAD_NAME "Threads"
#define SLAPD_MONITOR_THREAD_RDN \
- "cn=" SLAPD_MONITOR_THREAD_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_THREAD_NAME
#define SLAPD_MONITOR_THREAD_DN \
SLAPD_MONITOR_THREAD_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_SASL 4
#define SLAPD_MONITOR_SASL_NAME "SASL"
#define SLAPD_MONITOR_SASL_RDN \
- "cn=" SLAPD_MONITOR_SASL_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SASL_NAME
#define SLAPD_MONITOR_SASL_DN \
SLAPD_MONITOR_SASL_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_TLS 5
#define SLAPD_MONITOR_TLS_NAME "TLS"
#define SLAPD_MONITOR_TLS_RDN \
- "cn=" SLAPD_MONITOR_TLS_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TLS_NAME
#define SLAPD_MONITOR_TLS_DN \
SLAPD_MONITOR_TLS_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_CONN 6
#define SLAPD_MONITOR_CONN_NAME "Connections"
#define SLAPD_MONITOR_CONN_RDN \
- "cn=" SLAPD_MONITOR_CONN_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_CONN_NAME
#define SLAPD_MONITOR_CONN_DN \
SLAPD_MONITOR_CONN_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_RWW 7
#define SLAPD_MONITOR_RWW_NAME "Waiters"
#define SLAPD_MONITOR_RWW_RDN \
- "cn=" SLAPD_MONITOR_RWW_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_RWW_NAME
#define SLAPD_MONITOR_RWW_DN \
SLAPD_MONITOR_RWW_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_LOG 8
#define SLAPD_MONITOR_LOG_NAME "Log"
#define SLAPD_MONITOR_LOG_RDN \
- "cn=" SLAPD_MONITOR_LOG_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_LOG_NAME
#define SLAPD_MONITOR_LOG_DN \
SLAPD_MONITOR_LOG_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_OPS 9
#define SLAPD_MONITOR_OPS_NAME "Operations"
#define SLAPD_MONITOR_OPS_RDN \
- "cn=" SLAPD_MONITOR_OPS_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OPS_NAME
#define SLAPD_MONITOR_OPS_DN \
SLAPD_MONITOR_OPS_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_SENT 10
#define SLAPD_MONITOR_SENT_NAME "Statistics"
#define SLAPD_MONITOR_SENT_RDN \
- "cn=" SLAPD_MONITOR_SENT_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_SENT_NAME
#define SLAPD_MONITOR_SENT_DN \
SLAPD_MONITOR_SENT_RDN "," SLAPD_MONITOR_DN
#define SLAPD_MONITOR_TIME 11
#define SLAPD_MONITOR_TIME_NAME "Time"
#define SLAPD_MONITOR_TIME_RDN \
- "cn=" SLAPD_MONITOR_TIME_NAME
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_TIME_NAME
#define SLAPD_MONITOR_TIME_DN \
SLAPD_MONITOR_TIME_RDN "," SLAPD_MONITOR_DN
+#define SLAPD_MONITOR_OVERLAY 12
+#define SLAPD_MONITOR_OVERLAY_NAME "Overlay"
+#define SLAPD_MONITOR_OVERLAY_RDN \
+ SLAPD_MONITOR_AT "=" SLAPD_MONITOR_OVERLAY_NAME
+#define SLAPD_MONITOR_OVERLAY_DN \
+ SLAPD_MONITOR_OVERLAY_RDN "," SLAPD_MONITOR_DN
+
struct monitorsubsys {
int mss_type;
char *mss_name;
static int monitor_back_add_plugin( Backend *be, Entry *e );
#endif /* defined(LDAP_SLAPI) */
+#if defined(SLAPD_LDAP)
+#include "../back-ldap/back-ldap.h"
+#endif /* defined(SLAPD_LDAP) */
+
int
monitor_subsys_database_init(
BackendDB *be
be->be_suffix, be->be_nsuffix );
}
+ if ( oi != NULL ) {
+ slap_overinst *on = oi->oi_list;
+
+ for ( ; on; on = on->on_next ) {
+ struct berval bv;
+ slap_overinst *on2;
+
+ bv.bv_val = on->on_bi.bi_type;
+ bv.bv_len = strlen( bv.bv_val );
+ attr_merge_normalize_one( e, mi->mi_ad_monitorOverlay,
+ &bv, NULL );
+
+ for ( on2 = overlay_next( NULL ), j = 0; on2; on2 = overlay_next( on2 ), j++ ) {
+ if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
+ break;
+ }
+ }
+ assert( on2 );
+
+ snprintf( buf, sizeof( buf ),
+ "cn=Overlay %d,%s",
+ j, monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_dn.bv_val );
+ bv.bv_val = buf;
+ bv.bv_len = strlen( buf );
+ attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
+ &bv, NULL );
+ }
+ }
+
+#if defined(SLAPD_LDAP)
+ if ( strcmp( be->bd_info->bi_type, "ldap" ) == 0 ) {
+ struct ldapinfo *li = (struct ldapinfo *)be->be_private;
+ struct berval bv;
+
+ bv.bv_val = li->url;
+ bv.bv_len = strlen( bv.bv_val );
+ attr_merge_normalize_one( e, mi->mi_ad_labeledURI,
+ &bv, NULL );
+ }
+#endif /* defined(SLAPD_LDAP) */
+
for ( j = nBackendInfo; j--; ) {
if ( backendInfo[ j ].bi_type == be->bd_info->bi_type ) {
struct berval bv;
monitor_subsys_time_update,
NULL, /* create */
NULL, /* modify */
+ }, {
+ SLAPD_MONITOR_OVERLAY, SLAPD_MONITOR_OVERLAY_NAME,
+ BER_BVNULL, BER_BVNULL, BER_BVNULL,
+ MONITOR_F_PERSISTENT_CH,
+ monitor_subsys_overlay_init,
+ NULL, /* update */
+ NULL, /* create */
+ NULL, /* modify */
}, { -1, NULL }
};
"$ postalCode "
#endif
"$ seeAlso "
+ "$ labeledURI "
"$ monitoredInfo "
"$ managedInfo "
+ "$ monitorOverlay "
") )", SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
offsetof(struct monitorinfo, mi_oc_monitor) },
{ "monitorServer", "( 1.3.6.1.4.1.4203.666.3.7 "
"NO-USER-MODIFICATION "
"USAGE directoryOperation )", SLAP_AT_FINAL|SLAP_AT_HIDE,
offsetof(struct monitorinfo, mi_ad_monitorTimestamp) },
+ { "monitorOverlay", "( 1.3.6.1.4.1.4203.666.1.27 "
+ "NAME 'monitorOverlay' "
+ "DESC 'name of overlays defined for a give database' "
+ "SUP monitoredInfo "
+ "NO-USER-MODIFICATION "
+ "USAGE directoryOperation )", SLAP_AT_HIDE,
+ offsetof(struct monitorinfo, mi_ad_monitorOverlay) },
#ifdef INTEGRATE_CORE_SCHEMA
{ NULL, NULL, 0, -1 }, /* description */
{ NULL, NULL, 0, -1 }, /* seeAlso */
{ NULL, NULL, 0, -1 }, /* l */
+ { NULL, NULL, 0, -1 }, /* labeledURI */
#endif /* INTEGRATE_CORE_SCHEMA */
{ NULL, NULL, 0, -1 }
}, mat_core[] = {
"DESC 'RFC2256: locality which this object resides in' "
"SUP name )", 0,
offsetof(struct monitorinfo, mi_ad_l) },
+ { "labeledURI", "( 1.3.6.1.4.1.250.1.57 "
+ "NAME 'labeledURI' "
+ "DESC 'RFC2079: Uniform Resource Identifier with optional label' "
+ "EQUALITY caseExactMatch "
+ "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )", 0,
+ offsetof(struct monitorinfo, mi_ad_labeledURI) },
{ NULL, NULL, 0, -1 }
};
--- /dev/null
+/* overlay.c - deals with overlay subsystem */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Portions Copyright 2001-2003 Pierangelo Masarati.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by Pierangelo Masarati for inclusion
+ * in OpenLDAP Software.
+ */
+
+
+#include "portable.h"
+
+#include <stdio.h>
+#include <ac/string.h>
+
+#include "slap.h"
+#include "back-monitor.h"
+
+/*
+ * initializes overlay subentries
+ */
+int
+monitor_subsys_overlay_init(
+ BackendDB *be
+)
+{
+ struct monitorinfo *mi;
+ Entry *e, *e_overlay, *e_tmp;
+ int i;
+ struct monitorentrypriv *mp;
+ slap_overinst *on;
+
+ mi = ( struct monitorinfo * )be->be_private;
+
+ if ( monitor_cache_get( mi,
+ &monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn,
+ &e_overlay ) ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, CRIT,
+ "monitor_subsys_overlay_init: "
+ "unable to get entry '%s'\n",
+ monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "monitor_subsys_overlay_init: "
+ "unable to get entry '%s'\n%s%s",
+ monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
+ "", "" );
+#endif
+ return( -1 );
+ }
+
+ e_tmp = NULL;
+ for ( on = overlay_next( NULL ), i = 0; on ; on = overlay_next( on ), i++ ) {
+ char buf[ BACKMONITOR_BUFSIZE ];
+ struct berval bv;
+ int j;
+
+ snprintf( buf, sizeof( buf ),
+ "dn: cn=Overlay %d,%s\n"
+ "objectClass: %s\n"
+ "structuralObjectClass: %s\n"
+ "cn: Overlay %d\n"
+ "createTimestamp: %s\n"
+ "modifyTimestamp: %s\n",
+ i,
+ monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_dn.bv_val,
+ mi->mi_oc_monitoredObject->soc_cname.bv_val,
+ mi->mi_oc_monitoredObject->soc_cname.bv_val,
+ i,
+ mi->mi_startTime.bv_val,
+ mi->mi_startTime.bv_val );
+
+ e = str2entry( buf );
+ if ( e == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, CRIT,
+ "monitor_subsys_overlay_init: "
+ "unable to create entry 'cn=Overlay %d,%s'\n",
+ i, monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "monitor_subsys_overlay_init: "
+ "unable to create entry 'cn=Overlay %d,%s'\n%s",
+ i,
+ monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
+ "" );
+#endif
+ return( -1 );
+ }
+
+ bv.bv_val = on->on_bi.bi_type;
+ bv.bv_len = strlen( bv.bv_val );
+
+ attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo,
+ &bv, NULL );
+ attr_merge_normalize_one( e_overlay, mi->mi_ad_monitoredInfo,
+ &bv, NULL );
+
+ for ( j = 0; j < nBackendDB; j++ ) {
+ BackendDB *be = &backendDB[j];
+ char buf[ SLAP_LDAPDN_MAXLEN ];
+ struct berval dn;
+ slap_overinst *on2;
+
+ if ( strcmp( be->bd_info->bi_type, "over" ) != 0 ) {
+ continue;
+ }
+
+ on2 = ((slap_overinfo *)be->bd_info)->oi_list;
+ for ( ; on2; on2 = on2->on_next ) {
+ if ( on2->on_bi.bi_type == on->on_bi.bi_type ) {
+ break;
+ }
+ }
+
+ if ( on2 == NULL ) {
+ continue;
+ }
+
+ snprintf( buf, sizeof( buf ), "cn=Database %d,%s",
+ j, monitor_subsys[SLAPD_MONITOR_DATABASE].mss_dn.bv_val );
+ dn.bv_val = buf;
+ dn.bv_len = strlen( buf );
+
+ attr_merge_normalize_one( e, mi->mi_ad_seeAlso,
+ &dn, NULL );
+ }
+
+ mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
+ e->e_private = ( void * )mp;
+ mp->mp_next = e_tmp;
+ mp->mp_children = NULL;
+ mp->mp_info = &monitor_subsys[SLAPD_MONITOR_OVERLAY];
+ mp->mp_flags = monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_flags
+ | MONITOR_F_SUB;
+
+ if ( monitor_cache_add( mi, e ) ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( OPERATION, CRIT,
+ "monitor_subsys_overlay_init: "
+ "unable to add entry 'cn=Overlay %d,%s'\n",
+ i, monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "monitor_subsys_overlay_init: "
+ "unable to add entry 'cn=Overlay %d,%s'\n%s",
+ i,
+ monitor_subsys[SLAPD_MONITOR_OVERLAY].mss_ndn.bv_val,
+ "" );
+#endif
+ return( -1 );
+ }
+
+ e_tmp = e;
+ }
+
+ mp = ( struct monitorentrypriv * )e_overlay->e_private;
+ mp->mp_children = e_tmp;
+
+ monitor_cache_release( mi, e_overlay );
+
+ return( 0 );
+}
+
int monitor_subsys_ops_init LDAP_P(( BackendDB *be ));
int monitor_subsys_ops_update LDAP_P(( Operation *op, Entry *e ));
+/*
+ * overlay
+ */
+int monitor_subsys_overlay_init LDAP_P(( BackendDB *be ));
+
/*
* sent
*/
rc = test_filter( op, e, op->oq_search.rs_filter );
if ( rc == LDAP_COMPARE_TRUE ) {
rs->sr_entry = e;
+ rs->sr_flags = 0;
send_search_entry( op, rs );
rs->sr_entry = NULL;
}
rc = test_filter( op, e, op->oq_search.rs_filter );
if ( rc == LDAP_COMPARE_TRUE ) {
rs->sr_entry = e;
+ rs->sr_flags = 0;
send_search_entry( op, rs );
rs->sr_entry = NULL;
}
rc = test_filter( op, e, op->oq_search.rs_filter );
if ( rc == LDAP_COMPARE_TRUE ) {
rs->sr_entry = e;
+ rs->sr_flags = 0;
send_search_entry( op, rs );
rs->sr_entry = NULL;
}
if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE ) {
rs->sr_entry = e;
rs->sr_attrs = op->ors_attrs;
+ rs->sr_flags = REP_ENTRY_MODIFIABLE;
send_search_entry( op, rs );
}
}
rs->sr_entry = e;
rs->sr_attrs = op->ors_attrs;
+ rs->sr_flags = REP_ENTRY_MODIFIABLE;
send_search_entry( op, rs );
}
if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE ) {
rs->sr_entry = e;
rs->sr_attrs = op->ors_attrs;
+ rs->sr_flags = REP_ENTRY_MODIFIABLE;
send_search_entry( op, rs );
}
if (send_entry) {
rs->sr_entry = e;
rs->sr_attrs = op->ors_attrs;
+ rs->sr_flags = REP_ENTRY_MODIFIABLE;
send_search_entry( op, rs );
}
{
rs->sr_attrs = op->ors_attrs;
rs->sr_entry = entry;
+ rs->sr_flags = REP_ENTRY_MODIFIABLE;
sres = send_search_entry( op, rs );
rs->sr_entry = NULL;
rs->sr_attrs = NULL;
#if defined(SLAPD_PERL) && !defined(SLAPD_PERL_DYNAMIC)
#include "back-perl/external.h"
#endif
+#if defined(SLAPD_RELAY) && !defined(SLAPD_RELAY_DYNAMIC)
+#include "back-relay/external.h"
+#endif
#if defined(SLAPD_SHELL) && !defined(SLAPD_SHELL_DYNAMIC)
#include "back-shell/external.h"
#endif
#if defined(SLAPD_PERL) && !defined(SLAPD_PERL_DYNAMIC)
{"perl", perl_back_initialize},
#endif
+#if defined(SLAPD_RELAY) && !defined(SLAPD_RELAY_DYNAMIC)
+ {"relay", relay_back_initialize},
+#endif
#if defined(SLAPD_SHELL) && !defined(SLAPD_SHELL_DYNAMIC)
{"shell", shell_back_initialize},
#endif
case LDAP_SCOPE_SUBTREE:
if ( !dnIsSuffix( op_ndn, &nbase )) goto loopit;
break;
+#ifdef LDAP_SCOPE_SUBORDINATE
+ case LDAP_SCOPE_SUBORDINATE:
+ if ( dn_match( &nbase, op_ndn ) &&
+ !dnIsSuffix(op_ndn, &nbase ))
+ {
+ goto loopit;
+ }
+#endif
}
filter = str2filter_x( op, ludp->lud_filter );
if ( filter ) {
case LDAP_SCOPE_ONELEVEL:
case LDAP_SCOPE_SUBTREE:
+#ifdef LDAP_SCOPE_SUBORDINATE
+ case LDAP_SCOPE_SUBORDINATE: /* FIXME */
+#endif
op->o_callback = &cb;
rs->sr_err = gs.err = LDAP_UNWILLING_TO_PERFORM;
scope0 = op->ors_scope;
static int
over_back_response ( Operation *op, SlapReply *rs )
{
- slap_overinfo *oi = (slap_overinfo *) op->o_bd->bd_info;
+ slap_overinfo *oi = op->o_callback->sc_private;
slap_overinst *on = oi->oi_list;
int rc = SLAP_CB_CONTINUE;
BackendDB *be = op->o_bd, db = *op->o_bd;
op->o_bd = &db;
cb.sc_next = op->o_callback;
+ cb.sc_private = oi;
op->o_callback = &cb;
for (; on; on=on->on_next ) {
return 0;
}
+slap_overinst *
+overlay_next(
+ slap_overinst *on
+)
+{
+ if ( on == NULL ) {
+ return overlays;
+ }
+
+ return on->on_next;
+}
+
static const char overtype[] = "over";
/* add an overlay to a particular backend. */
int
overlay_config( BackendDB *be, const char *ov )
{
- slap_overinst *on, *on2, *prev;
- slap_overinfo *oi;
- BackendInfo *bi;
+ slap_overinst *on = NULL, *on2 = NULL, *prev = NULL;
+ slap_overinfo *oi = NULL;
+ BackendInfo *bi = NULL;
for ( on = overlays; on; on=on->on_next ) {
if (!strcmp( ov, on->on_bi.bi_type ) )
bi->bi_extended = over_op_extended;
be->bd_info = bi;
+
+ } else {
+ oi = (slap_overinfo *) be->bd_info;
}
#if 0
/* Walk to the end of the list of overlays, add the new
* one onto the end
*/
- oi = (slap_overinfo *) be->bd_info;
for ( prev=NULL, on2 = oi->oi_list; on2; prev=on2, on2=on2->on_next );
on2 = ch_calloc( 1, sizeof(slap_overinst) );
if ( !prev ) {
int slapi_plugins_used = 0;
#endif
-static char *fp_getline(FILE *fp, int *lineno);
-static void fp_getline_init(int *lineno);
-static int fp_parse_line(int lineno, char *line);
+static char *fp_getline(FILE *fp, int *lineno);
+static void fp_getline_init(int *lineno);
+static int fp_parse_line(int lineno, char *line);
static char *strtok_quote(char *line, char *sep);
-static int load_ucdata(char *path);
+static int load_ucdata(char *path);
-static int add_syncrepl LDAP_P(( Backend *, char **, int ));
-static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
+static int add_syncrepl LDAP_P(( Backend *, char **, int ));
+static int parse_syncrepl_line LDAP_P(( char **, int, syncinfo_t *));
int
read_config( const char *fname, int depth )
if ( si->si_rid == si_entry->si_rid ) {
#ifdef NEW_LOGGING
LDAP_LOG( CONFIG, ERR,
- "add_syncrepl: duplicaetd replica id\n", 0, 0,0 );
+ "add_syncrepl: duplicated replica id\n", 0, 0,0 );
#else
Debug( LDAP_DEBUG_ANY,
- "add_syncrepl: duplicated replica id\n",0, 0, 0 );
+ "add_syncrepl: duplicated replica id\n",0, 0, 0 );
#endif
duplicated_replica_id = 1;
break;
si->si_scope = LDAP_SCOPE_BASE;
} else if ( !strncasecmp( val, "one", sizeof( "one" ) - 1 )) {
si->si_scope = LDAP_SCOPE_ONELEVEL;
+#ifdef LDAP_SCOPE_SUBORDINATE
+ } else if ( !strcasecmp( val, "subordinate" ) ||
+ !strcasecmp( val, "children" ))
+ {
+ si->si_scope = LDAP_SCOPE_SUBORDINATE;
+#endif
} else if ( !strncasecmp( val, "sub", sizeof( "sub" ) - 1 )) {
si->si_scope = LDAP_SCOPE_SUBTREE;
} else {
#endif
typedef int (MainFunc) LDAP_P(( int argc, char *argv[] ));
-extern MainFunc slapadd, slapcat, slapindex, slappasswd;
+extern MainFunc slapadd, slapcat, slapdn, slapindex, slappasswd, slaptest;
static struct {
char *name;
} tools[] = {
{"slapadd", slapadd},
{"slapcat", slapcat},
+ {"slapdn", slapdn},
{"slapindex", slapindex},
{"slappasswd", slappasswd},
+ {"slaptest", slaptest},
{NULL, NULL}
};
#endif /* LOG_LOCAL4 */
-static int check_config = 0;
+#define CHECK_NONE 0x00
+#define CHECK_CONFIG 0x01
+static int check = CHECK_NONE;
static int version = 0;
static void
fprintf( stderr,
"\t-4\t\tIPv4 only\n"
"\t-6\t\tIPv6 only\n"
- "\t-T (a|c|i|p)\tRun in Tool mode\n"
+ "\t-T {acdipt}\tRun in Tool mode\n"
"\t-c cookie\tSync cookie of consumer\n"
"\t-d level\tDebug level" "\n"
"\t-f filename\tConfiguration file\n"
"\t-r directory\tSandbox directory to chroot to\n"
#endif
"\t-s level\tSyslog level\n"
- "\t-t\t\tCheck configuration file and exit\n"
#if defined(HAVE_SETUID) && defined(HAVE_SETGID)
"\t-u user\t\tUser (id or name) to run as\n"
"\t-V\t\tprint version info (-VV only)\n"
#endif
while ( (i = getopt( argc, argv,
- "c:d:f:h:s:n:t:T:V"
+ "c:d:f:h:s:n:tT:V"
#if LDAP_PF_INET6
"46"
#endif
break;
case 't':
- check_config++;
+ /* deprecated; use slaptest instead */
+ fprintf( stderr, "option -t deprecated; "
+ "use slaptest command instead\n" );
+ check |= CHECK_CONFIG;
break;
+
case 'V':
version++;
break;
Debug( LDAP_DEBUG_ANY, "%s", Versionstr, 0, 0 );
#endif
- if( !check_config && slapd_daemon_init( urls ) != 0 ) {
+ if( check == CHECK_NONE && slapd_daemon_init( urls ) != 0 ) {
rc = 1;
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 16 );
goto stop;
rc = 1;
SERVICE_EXIT( ERROR_SERVICE_SPECIFIC_ERROR, 19 );
- if ( check_config ) {
+ if ( check & CHECK_CONFIG ) {
fprintf( stderr, "config check failed\n" );
}
goto destroy;
}
- if ( check_config ) {
- rc = 0;
+ if ( check & CHECK_CONFIG ) {
fprintf( stderr, "config check succeeded\n" );
- goto destroy;
+
+ check &= ~CHECK_CONFIG;
+ if ( check == CHECK_NONE ) {
+ rc = 0;
+ goto destroy;
+ }
}
if ( glue_sub_init( ) != 0 ) {
}
struct query_info {
- struct berval* uuid;
- int deleted;
+ struct query_info *next;
+ struct berval xdn;
+ int del;
};
static int
SlapReply *rs
)
{
- struct query_info *info = op->o_callback->sc_private;
- int count = 0;
- Modifications mod;
- struct berval vals[2];
+ Attribute *attr;
+ struct query_info *qi;
+ int count = 0;
- Attribute *attr;
- Operation op_tmp = *op;
-
- SlapReply sreply = {REP_RESULT};
-
- if (rs->sr_type == REP_RESULT)
- return 0;
+ if ( rs->sr_type != REP_SEARCH ) return 0;
for (attr = rs->sr_entry->e_attrs; attr!= NULL; attr = attr->a_next) {
if (attr->a_desc == ad_queryid) {
break;
}
}
-
- if (count == 0) {
- return 0;
- }
- if (count == 1) {
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "DELETING ENTRY TEMPLATE=%s\n",
- attr->a_vals[0].bv_val, 0, 0 );
-#else
- Debug( LDAP_DEBUG_ANY, "DELETING ENTRY TEMPLATE=%s\n",
- attr->a_vals[0].bv_val, 0, 0 );
-#endif
-
- op_tmp.o_req_dn = rs->sr_entry->e_name;
- op_tmp.o_req_ndn = rs->sr_entry->e_nname;
-
- if (op->o_bd->be_delete(&op_tmp, rs) == LDAP_SUCCESS) {
- info->deleted++;
- }
- return 0;
- }
-
- vals[0] = *info->uuid;
- vals[1].bv_val = NULL;
- vals[1].bv_len = 0;
- mod.sml_op = LDAP_MOD_DELETE;
- mod.sml_desc = ad_queryid;
- mod.sml_type = ad_queryid->ad_cname;
- mod.sml_bvalues = vals;
- mod.sml_next = NULL;
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "REMOVING TEMP ATTR : TEMPLATE=%s\n",
- attr->a_vals[0].bv_val, 0, 0 );
-#else
- Debug( LDAP_DEBUG_ANY, "REMOVING TEMP ATTR : TEMPLATE=%s\n",
- attr->a_vals[0].bv_val, 0, 0 );
-#endif
-
- op_tmp.o_req_dn = rs->sr_entry->e_name;
- op_tmp.o_req_ndn = rs->sr_entry->e_nname;
- op_tmp.orm_modlist = &mod;
-
- op->o_bd->be_modify( &op_tmp, &sreply );
+ if ( count == 0 ) return 0;
+ qi = op->o_tmpalloc( sizeof( struct query_info ), op->o_tmpmemctx );
+ qi->next = op->o_callback->sc_private;
+ op->o_callback->sc_private = qi;
+ ber_dupbv_x( &qi->xdn, &rs->sr_entry->e_nname, op->o_tmpmemctx );
+ qi->del = ( count == 1 );
return 0;
}
SlapReply *rs,
struct berval* query_uuid)
{
- struct query_info info;
+ struct query_info *qi, *qnext;
char filter_str[64];
+ AttributeAssertion ava;
Filter filter = {LDAP_FILTER_EQUALITY};
SlapReply sreply = {REP_RESULT};
slap_callback cb = { NULL, remove_func, NULL, NULL };
+ int deleted = 0;
sreply.sr_entry = NULL;
sreply.sr_nentries = 0;
op->ors_filterstr.bv_len = snprintf(filter_str, sizeof(filter_str),
"(%s=%s)", ad_queryid->ad_cname.bv_val, query_uuid->bv_val);
+ filter.f_ava = &ava;
filter.f_av_desc = ad_queryid;
filter.f_av_value = *query_uuid;
- info.uuid = query_uuid;
- info.deleted = 0;
- cb.sc_private = &info;
op->o_tag = LDAP_REQ_SEARCH;
op->o_protocol = LDAP_VERSION3;
op->o_bd->be_search( op, &sreply );
- return info.deleted;
+ for ( qi=cb.sc_private; qi; qi=qnext ) {
+ qnext = qi->next;
+
+ op->o_req_dn = qi->xdn;
+ op->o_req_ndn = qi->xdn;
+
+ if ( qi->del) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( BACK_META, DETAIL1,
+ "DELETING ENTRY TEMPLATE=%s\n",
+ query_uuid->bv_val, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY, "DELETING ENTRY TEMPLATE=%s\n",
+ query_uuid->bv_val, 0, 0 );
+#endif
+
+ op->o_tag = LDAP_REQ_DELETE;
+
+ if (op->o_bd->be_delete(op, &sreply) == LDAP_SUCCESS) {
+ deleted++;
+ }
+ } else {
+ Modifications mod;
+ struct berval vals[2];
+
+ vals[0] = *query_uuid;
+ vals[1].bv_val = NULL;
+ vals[1].bv_len = 0;
+ mod.sml_op = LDAP_MOD_DELETE;
+ mod.sml_desc = ad_queryid;
+ mod.sml_type = ad_queryid->ad_cname;
+ mod.sml_bvalues = vals;
+ mod.sml_next = NULL;
+#ifdef NEW_LOGGING
+ LDAP_LOG( BACK_META, DETAIL1,
+ "REMOVING TEMP ATTR : TEMPLATE=%s\n",
+ query_uuid->bv_val, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY,
+ "REMOVING TEMP ATTR : TEMPLATE=%s\n",
+ query_uuid->bv_val, 0, 0 );
+#endif
+
+ op->orm_modlist = &mod;
+
+ op->o_bd->be_modify( op, &sreply );
+ }
+ op->o_tmpfree( qi->xdn.bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( qi, op->o_tmpmemctx );
+ }
+ return deleted;
}
static int
cache_manager *cm = on->on_bi.bi_private;
query_manager *qm = cm->qm;
Operation op = {0};
+ Connection conn = {0};
SlapReply rs = {REP_RESULT};
CachedQuery* query, *query_prev;
int i, return_val, pause = 1;
QueryTemplate* templ;
+ connection_fake_init( &conn, &op, ctx );
+
op.o_bd = &cm->db;
op.o_dn = cm->db.be_rootdn;
op.o_ndn = cm->db.be_rootndn;
- op.o_threadctx = ctx;
-
- op.o_tmpmemctx = sl_mem_create( SLMALLOC_SLAB_SIZE, ctx );
- op.o_tmpmfuncs = &sl_mfuncs;
cm->cc_arg = arg;
rs->sr_entry = &e;
rs->sr_attrs = uuid_attr;
rs->sr_ctrls = ctrls;
+ rs->sr_flags = 0;
result = send_search_entry( op, rs );
sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val, op->o_tmpmemctx );
sl_free( ctrls[--num_ctrls], op->o_tmpmemctx );
{
char *options = NULL;
fprintf( stderr,
- "usage: %s [-v] [-c] [-d debuglevel] [-f configfile]\n"
- "\t[-n databasenumber | -b suffix]", progname );
+ "usage: %s [-v] [-c] [-d debuglevel] [-f configfile]\n",
+ progname );
switch( tool ) {
case SLAPADD:
- options = "\n\t[-l ldiffile] [-u] [-p [-w] | -r [-i syncreplidlist] [-w]]\n";
+ options = "\t[-n databasenumber | -b suffix]\n"
+ "\t[-l ldiffile] [-u] [-p [-w] | -r [-i syncreplidlist] [-w]]\n";
break;
case SLAPCAT:
- options = "\t[-l ldiffile] [-m] [-k]\n";
+ options = "\t[-n databasenumber | -b suffix] [-l ldiffile] [-m] [-k]\n";
+ break;
+
+ case SLAPDN:
+ options = "\tDN [...]\n";
break;
case SLAPINDEX:
- options = "\n";
+ options = "\t[-n databasenumber | -b suffix]\n";
break;
}
- if( options != NULL ) {
+ if ( options != NULL ) {
fputs( options, stderr );
}
exit( EXIT_FAILURE );
options = "b:cd:f:i:l:n:prtuvWw";
break;
- case SLAPINDEX:
- options = "b:cd:f:n:v";
- mode |= SLAP_TOOL_READMAIN;
- break;
-
case SLAPCAT:
options = "b:cd:f:kl:mn:s:v";
mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
break;
+ case SLAPDN:
+ case SLAPTEST:
+ options = "d:f:v";
+ break;
+
+ case SLAPINDEX:
+ options = "b:cd:f:n:v";
+ mode |= SLAP_TOOL_READMAIN;
+ break;
+
default:
fprintf( stderr, "%s: unknown tool mode (%d)\n",
progname, tool );
}
}
- if ( ( argc != optind ) || (dbnum >= 0 && base.bv_val != NULL ) ) {
- usage( tool, progname );
- }
+ switch ( tool ) {
+ case SLAPADD:
+ case SLAPCAT:
+ case SLAPINDEX:
+ if ( ( argc != optind ) || (dbnum >= 0 && base.bv_val != NULL ) ) {
+ usage( tool, progname );
+ }
+
+ if ( replica_promotion && replica_demotion ) {
+ usage( tool, progname );
+
+ } else if ( !replica_promotion && !replica_demotion ) {
+ if ( update_ctxcsn != SLAP_TOOL_CTXCSN_KEEP ) {
+ usage( tool, progname );
+ }
+ }
+ break;
- if ( replica_promotion && replica_demotion ) {
- usage( tool, progname );
- } else if ( !replica_promotion && !replica_demotion ) {
- if ( update_ctxcsn != SLAP_TOOL_CTXCSN_KEEP ) {
+ case SLAPDN:
+ if ( argc == optind ) {
usage( tool, progname );
}
+ break;
+
+ case SLAPTEST:
+ if ( argc != optind ) {
+ usage( tool, progname );
+ }
+ break;
+
+ default:
+ break;
}
if ( ldiffile == NULL ) {
ldap_syslog = 0;
- if ( !nbackends ) {
- fprintf( stderr, "No databases found in config file\n" );
- exit( EXIT_FAILURE );
+ switch ( tool ) {
+ case SLAPADD:
+ case SLAPCAT:
+ case SLAPINDEX:
+ if ( !nbackends ) {
+ fprintf( stderr, "No databases found "
+ "in config file\n" );
+ exit( EXIT_FAILURE );
+ }
+ break;
+
+ default:
+ break;
}
rc = glue_sub_init();
exit( EXIT_FAILURE );
}
+ switch ( tool ) {
+ case SLAPDN:
+ case SLAPTEST:
+ return;
+
+ default:
+ break;
+ }
+
if( subtree ) {
struct berval val;
val.bv_val = subtree;
enum slaptool {
SLAPADD=1, /* LDIF -> database tool */
SLAPCAT, /* database -> LDIF tool */
+ SLAPDN, /* DN check w/ syntax tool */
SLAPINDEX, /* database index tool */
- SLAPPASSWD /* password generation tool */
+ SLAPPASSWD, /* password generation tool */
+ SLAPTEST, /* slapd.conf test tool */
+ SLAPLAST
};
#define SLAP_TOOL_CTXCSN_KEEP 0
rs.sr_type = REP_SEARCH;
rs.sr_err = LDAP_SUCCESS;
rs.sr_attrs = an;
+ rs.sr_flags = REP_ENTRY_MODIFIABLE;
send_search_entry( op, &rs );
}
rs.sr_attrs = an;
rs.sr_entry = e;
rs.sr_v2ref = NULL;
+ rs.sr_flags = 0;
if ( slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&pOp ) != 0 ) {
return LDAP_OTHER;
return rc;
}
-static const Listener dummy_list = { {0, ""}, {0, ""} };
-
static int
do_syncrep1(
Operation *op,
return NULL;
}
- conn.c_connid = -1;
- conn.c_send_ldap_result = slap_send_ldap_result;
- conn.c_send_search_entry = slap_send_search_entry;
- conn.c_send_search_reference = slap_send_search_reference;
- conn.c_listener = (Listener *)&dummy_list;
- conn.c_peer_name = slap_empty_bv;
-
- /* set memory context */
- op.o_tmpmemctx = sl_mem_create( SLMALLOC_SLAB_SIZE, ctx );
- op.o_tmpmfuncs = &sl_mfuncs;
+ connection_fake_init( &conn, &op, ctx );
op.o_dn = si->si_updatedn;
op.o_ndn = si->si_updatedn;
- op.o_time = slap_get_time();
- op.o_threadctx = ctx;
op.o_managedsait = 1;
op.o_bd = si->si_be;
- op.o_conn = &conn;
- op.o_connid = op.o_conn->c_connid;
op.o_sync_state.ctxcsn = NULL;
op.o_sync_state.sid = -1;
*/
if ( rc == LDAP_SUCCESS ) {
if ( first ) {
- rc = connection_client_setup( s, (Listener *)&dummy_list, do_syncrepl,
+ rc = connection_client_setup( s, do_syncrepl,
arg );
} else {
connection_client_enable( s );