/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2008 The OpenLDAP Foundation.
+ * Copyright 1998-2011 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
(void)backend_set_controls( be );
} else {
+ char *type = be->bd_info->bi_type;
+ char *suffix = "(null)";
+
+ if ( overlay_is_over( be ) ) {
+ slap_overinfo *oi = (slap_overinfo *)be->bd_info->bi_private;
+ type = oi->oi_orig->bi_type;
+ }
+
+ if ( be->be_suffix != NULL && !BER_BVISNULL( &be->be_suffix[0] ) ) {
+ suffix = be->be_suffix[0].bv_val;
+ }
+
Debug( LDAP_DEBUG_ANY,
- "backend_startup_one: bi_db_open failed! (%d)\n",
- rc, 0, 0 );
+ "backend_startup_one (type=%s, suffix=\"%s\"): "
+ "bi_db_open failed! (%d)\n",
+ type, suffix, rc );
}
}
}
acl_destroy( bd->be_acl );
limits_destroy( bd->be_limits );
+ if ( bd->be_extra_anlist ) {
+ anlist_free( bd->be_extra_anlist, 1, NULL );
+ }
if ( !BER_BVISNULL( &bd->be_update_ndn ) ) {
ch_free( bd->be_update_ndn.bv_val );
}
ber_bvarray_free( bd->be_update_refs );
}
+ ldap_pvt_thread_mutex_destroy( &bd->be_pcl_mutex );
+
if ( dynamic ) {
free( bd );
}
/* If we created and linked this be, remove it and free it */
if ( !b0 ) {
LDAP_STAILQ_REMOVE(&backendDB, be, BackendDB, be_next);
+ ldap_pvt_thread_mutex_destroy( &be->be_pcl_mutex );
ch_free( be );
be = NULL;
nbackends--;
}
} else {
+ if ( !bi->bi_nDB ) {
+ backend_init_controls( bi );
+ }
bi->bi_nDB++;
}
return( be );
int
be_shadow_update( Operation *op )
{
- /* This assumes that all internal ops (connid == -1) on a syncrepl
+ /* This assumes that all internal ops (connid <= -1000) on a syncrepl
* database are syncrepl operations.
*/
- return (( SLAP_SYNC_SHADOW( op->o_bd ) && op->o_connid == -1 ) ||
+ return ( ( SLAP_SYNC_SHADOW( op->o_bd ) && SLAPD_SYNC_IS_SYNCCONN( op->o_connid ) ) ||
( SLAP_SHADOW( op->o_bd ) && be_isupdate_dn( op->o_bd, &op->o_ndn ) ) );
}
slap_mask_t requires;
slap_mask_t opflag;
slap_mask_t exopflag = 0;
- slap_ssf_set_t *ssf;
+ slap_ssf_set_t ssfs, *ssf;
int updateop = 0;
int starttls = 0;
int session = 0;
+ restrictops = frontendDB->be_restrictops;
+ requires = frontendDB->be_requires;
+ ssfs = frontendDB->be_ssf_set;
+ ssf = &ssfs;
+
if ( op->o_bd ) {
- int rc = SLAP_CB_CONTINUE;
+ slap_ssf_t *fssf, *bssf;
+ int rc = SLAP_CB_CONTINUE, i;
if ( op->o_bd->be_chk_controls ) {
rc = ( *op->o_bd->be_chk_controls )( op, rs );
return rs->sr_err;
}
- restrictops = op->o_bd->be_restrictops;
- requires = op->o_bd->be_requires;
- ssf = &op->o_bd->be_ssf_set;
-
- } else {
- restrictops = frontendDB->be_restrictops;
- requires = frontendDB->be_requires;
- ssf = &frontendDB->be_ssf_set;
+ restrictops |= op->o_bd->be_restrictops;
+ requires |= op->o_bd->be_requires;
+ bssf = &op->o_bd->be_ssf_set.sss_ssf;
+ fssf = &ssfs.sss_ssf;
+ for ( i=0; i < (int)(sizeof(ssfs)/sizeof(slap_ssf_t)); i++ ) {
+ if ( bssf[i] ) fssf[i] = bssf[i];
+ }
}
switch( op->o_tag ) {
}
if( ( restrictops & opflag )
- || ( exopflag && ( restrictops & exopflag ) ) ) {
+ || ( exopflag && ( restrictops & exopflag ) )
+ || (( restrictops & SLAP_RESTRICT_READONLY ) && updateop )) {
if( ( restrictops & SLAP_RESTRICT_OP_MASK) == SLAP_RESTRICT_OP_READS ) {
rs->sr_text = "read operations restricted";
} else if ( restrictops & exopflag ) {
a = attr_find( e->e_attrs, entry_at );
if ( a == NULL ) {
- SlapReply rs = { 0 };
+ SlapReply rs = { REP_SEARCH };
AttributeName anlist[ 2 ];
anlist[ 0 ].an_name = entry_at->ad_cname;
* to do no harm to entries */
rs.sr_entry = e;
rc = backend_operational( op, &rs );
- rs.sr_entry = NULL;
-
+
if ( rc == LDAP_SUCCESS ) {
if ( rs.sr_operational_attrs ) {
freeattr = 1;
slap_mask_t *mask )
{
Entry *e = NULL;
- void *o_priv = op->o_private, *e_priv = NULL;
+ void *o_priv, *e_priv = NULL;
int rc = LDAP_INSUFFICIENT_ACCESS;
- Backend *be = op->o_bd;
+ Backend *be;
/* pedantic */
assert( op != NULL );
assert( edn != NULL );
assert( access > ACL_NONE );
+ be = op->o_bd;
+ o_priv = op->o_private;
+
if ( !op->o_bd ) {
op->o_bd = select_backend( edn, 0 );
}
} else {
a = attr_find( e->e_attrs, entry_at );
if ( a == NULL ) {
- SlapReply rs = { 0 };
+ SlapReply rs = { REP_SEARCH };
AttributeName anlist[ 2 ];
anlist[ 0 ].an_name = entry_at->ad_cname;
* to do no harm to entries */
rs.sr_entry = e;
rc = backend_operational( op, &rs );
- rs.sr_entry = NULL;
if ( rc == LDAP_SUCCESS ) {
if ( rs.sr_operational_attrs ) {
return rc;
}
+/* helper that calls the bi_tool_entry_first_x() variant with default args;
+ * use to initialize a backend's bi_tool_entry_first() when appropriate
+ */
+ID
+backend_tool_entry_first( BackendDB *be )
+{
+ return be->bd_info->bi_tool_entry_first_x( be,
+ NULL, LDAP_SCOPE_DEFAULT, NULL );
+}