}
#ifdef LDAP_SLAPI
- ret = slapi_x_access_allowed( op, e, desc, val, access, state );
- if ( ret == 0 ) {
+ if ( op->o_pb &&
+ !slapi_x_access_allowed( op, e, desc, val, access, state )) {
/* ACL plugin denied access */
goto done;
}
}
#ifdef LDAP_SLAPI
- initAddPlugin( op, &dn, e, manageDSAit );
+ if ( op->o_pb ) initAddPlugin( op, &dn, e, manageDSAit );
#endif /* LDAP_SLAPI */
/*
* Call the preoperation plugin here, because the entry
* will actually contain something.
*/
- rs->sr_err = doPreAddPluginFNs( op );
- if ( rs->sr_err != LDAP_SUCCESS ) {
- /* plugin will have sent result */
- goto done;
+ if ( op->o_pb ) {
+ rs->sr_err = doPreAddPluginFNs( op );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ /* plugin will have sent result */
+ goto done;
+ }
}
#endif /* LDAP_SLAPI */
* SLAPI_ADD_ENTRY will be empty, but this may be acceptable
* on replicas (for now, it involves the minimum code intrusion).
*/
- rs->sr_err = doPreAddPluginFNs( op );
- if ( rs->sr_err != LDAP_SUCCESS ) {
- /* plugin will have sent result */
- goto done;
+ if ( op->o_pb ) {
+ rs->sr_err = doPreAddPluginFNs( op );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ /* plugin will have sent result */
+ goto done;
+ }
}
#endif /* LDAP_SLAPI */
}
} else {
#ifdef LDAP_SLAPI
- rs->sr_err = doPreAddPluginFNs( op );
- if ( rs->sr_err != LDAP_SUCCESS ) {
- /* plugin will have sent result */
- goto done;
+ if ( op->o_pb ) {
+ rs->sr_err = doPreAddPluginFNs( op );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ /* plugin will have sent result */
+ goto done;
+ }
}
#endif
#ifdef NEW_LOGGING
}
#ifdef LDAP_SLAPI
- doPostAddPluginFNs( op );
+ if ( op->o_pb ) doPostAddPluginFNs( op );
#endif /* LDAP_SLAPI */
done:
backend_unbind( Operation *op, SlapReply *rs )
{
int i;
-#if defined( LDAP_SLAPI )
- Slapi_PBlock *pb = op->o_pb;
-
- int rc;
- slapi_x_pblock_set_operation( pb, op );
-#endif /* defined( LDAP_SLAPI ) */
for ( i = 0; i < nbackends; i++ ) {
#if defined( LDAP_SLAPI )
- slapi_pblock_set( pb, SLAPI_BACKEND, (void *)&backends[i] );
- rc = doPluginFNs( &backends[i], SLAPI_PLUGIN_PRE_UNBIND_FN,
- (Slapi_PBlock *)pb );
- if ( rc < 0 ) {
- /*
- * A preoperation plugin failure will abort the
- * entire operation.
- */
+ if ( op->o_pb ) {
+ int rc;
+ if ( i == 0 ) slapi_x_pblock_set_operation( op->o_pb, op );
+ slapi_pblock_set( op->o_pb, SLAPI_BACKEND, (void *)&backends[i] );
+ rc = doPluginFNs( &backends[i], SLAPI_PLUGIN_PRE_UNBIND_FN,
+ (Slapi_PBlock *)op->o_pb );
+ if ( rc < 0 ) {
+ /*
+ * A preoperation plugin failure will abort the
+ * entire operation.
+ */
#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, INFO, "do_bind: Unbind preoperation plugin "
- "failed\n", 0, 0, 0);
+ LDAP_LOG( OPERATION, INFO, "do_bind: Unbind preoperation plugin "
+ "failed\n", 0, 0, 0);
#else
- Debug(LDAP_DEBUG_TRACE, "do_bind: Unbind preoperation plugin "
- "failed.\n", 0, 0, 0);
+ Debug(LDAP_DEBUG_TRACE, "do_bind: Unbind preoperation plugin "
+ "failed.\n", 0, 0, 0);
#endif
- return 0;
+ return 0;
+ }
}
#endif /* defined( LDAP_SLAPI ) */
}
#if defined( LDAP_SLAPI )
- if ( doPluginFNs( &backends[i], SLAPI_PLUGIN_POST_UNBIND_FN,
- (Slapi_PBlock *)pb ) < 0 ) {
+ if ( op->o_pb && doPluginFNs( &backends[i], SLAPI_PLUGIN_POST_UNBIND_FN,
+ (Slapi_PBlock *)op->o_pb ) < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_unbind: Unbind postoperation plugins "
"failed\n", 0, 0, 0);
ber_tag_t tag;
Backend *be = NULL;
-#ifdef LDAP_SLAPI
- Slapi_PBlock *pb = op->o_pb;
- int rc;
-#endif
-
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ENTRY, "do_bind: conn %d\n", op->o_connid, 0, 0 );
#else
}
#ifdef LDAP_SLAPI
+#define pb op->o_pb
/*
* Normally post-operation plugins are called only after the
* backend operation. Because the front-end performs SASL
* exception to call the post-operation plugins after a
* SASL bind.
*/
- slapi_x_pblock_set_operation( pb, op );
- slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
- slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)method );
- slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
- slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
- (void) doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb );
+ if ( pb ) {
+ slapi_x_pblock_set_operation( pb, op );
+ slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
+ slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)method );
+ slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
+ slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
+ (void) doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb );
+ }
#endif /* LDAP_SLAPI */
ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
}
#if defined( LDAP_SLAPI )
- slapi_x_pblock_set_operation( pb, op );
- slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
- slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)method );
- slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
- slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
- slapi_pblock_set( pb, SLAPI_CONN_DN, (void *)(0) );
+ if ( pb ) {
+ int rc;
+ slapi_x_pblock_set_operation( pb, op );
+ slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
+ slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)method );
+ slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
+ slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
+ slapi_pblock_set( pb, SLAPI_CONN_DN, (void *)(0) );
- rc = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb );
+ rc = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb );
#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, INFO,
- "do_bind: Bind preoperation plugin returned %d\n",
- rs->sr_err, 0, 0);
+ LDAP_LOG( OPERATION, INFO,
+ "do_bind: Bind preoperation plugin returned %d\n",
+ rs->sr_err, 0, 0);
#else
- Debug(LDAP_DEBUG_TRACE,
- "do_bind: Bind preoperation plugin returned %d.\n",
- rs->sr_err, 0, 0);
+ Debug(LDAP_DEBUG_TRACE,
+ "do_bind: Bind preoperation plugin returned %d.\n",
+ rs->sr_err, 0, 0);
#endif
- switch ( rc ) {
- case SLAPI_BIND_SUCCESS:
- /* Continue with backend processing */
- break;
- case SLAPI_BIND_FAIL:
- /* Failure, server sends result */
- rs->sr_err = LDAP_INVALID_CREDENTIALS;
- send_ldap_result( op, rs );
- goto cleanup;
- break;
- case SLAPI_BIND_ANONYMOUS:
- /* SLAPI_BIND_ANONYMOUS is undocumented XXX */
- default:
- /* Authoritative, plugin sent result, or no plugins called. */
- if ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE,
- (void *)&rs->sr_err) != 0 )
- {
- rs->sr_err = LDAP_OTHER;
- }
+ switch ( rc ) {
+ case SLAPI_BIND_SUCCESS:
+ /* Continue with backend processing */
+ break;
+ case SLAPI_BIND_FAIL:
+ /* Failure, server sends result */
+ rs->sr_err = LDAP_INVALID_CREDENTIALS;
+ send_ldap_result( op, rs );
+ goto cleanup;
+ break;
+ case SLAPI_BIND_ANONYMOUS:
+ /* SLAPI_BIND_ANONYMOUS is undocumented XXX */
+ default:
+ /* Authoritative, plugin sent result, or no plugins called. */
+ if ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE,
+ (void *)&rs->sr_err) != 0 )
+ {
+ rs->sr_err = LDAP_OTHER;
+ }
- op->orb_edn.bv_val = NULL;
- op->orb_edn.bv_len = 0;
+ op->orb_edn.bv_val = NULL;
+ op->orb_edn.bv_len = 0;
- if ( rs->sr_err == LDAP_SUCCESS ) {
- slapi_pblock_get( pb, SLAPI_CONN_DN, (void *)&op->orb_edn.bv_val );
- if ( op->orb_edn.bv_val == NULL ) {
- if ( rc == 1 ) {
- /* No plugins were called; continue. */
- break;
+ if ( rs->sr_err == LDAP_SUCCESS ) {
+ slapi_pblock_get( pb, SLAPI_CONN_DN, (void *)&op->orb_edn.bv_val );
+ if ( op->orb_edn.bv_val == NULL ) {
+ if ( rc == 1 ) {
+ /* No plugins were called; continue. */
+ break;
+ }
+ } else {
+ op->orb_edn.bv_len = strlen( op->orb_edn.bv_val );
}
- } else {
- op->orb_edn.bv_len = strlen( op->orb_edn.bv_val );
- }
- rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn,
- &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
- ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
- ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
- ber_dupbv(&op->o_conn->c_ndn, &op->o_req_ndn);
- op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
- op->o_req_dn.bv_val = NULL;
- op->o_req_dn.bv_len = 0;
- op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
- op->o_req_ndn.bv_val = NULL;
- op->o_req_ndn.bv_len = 0;
- if ( op->o_conn->c_dn.bv_len != 0 ) {
- ber_len_t max = sockbuf_max_incoming_auth;
- ber_sockbuf_ctrl( op->o_conn->c_sb,
- LBER_SB_OPT_SET_MAX_INCOMING, &max );
+ rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn,
+ &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
+ ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
+ ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
+ ber_dupbv(&op->o_conn->c_ndn, &op->o_req_ndn);
+ op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
+ op->o_req_dn.bv_val = NULL;
+ op->o_req_dn.bv_len = 0;
+ op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
+ op->o_req_ndn.bv_val = NULL;
+ op->o_req_ndn.bv_len = 0;
+ if ( op->o_conn->c_dn.bv_len != 0 ) {
+ ber_len_t max = sockbuf_max_incoming_auth;
+ ber_sockbuf_ctrl( op->o_conn->c_sb,
+ LBER_SB_OPT_SET_MAX_INCOMING, &max );
+ }
+ /* log authorization identity */
+ Statslog( LDAP_DEBUG_STATS,
+ "conn=%lu op=%lu BIND dn=\"%s\" mech=simple (SLAPI) ssf=0\n",
+ op->o_connid, op->o_opid,
+ op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
+ 0, 0 );
+ ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
}
- /* log authorization identity */
- Statslog( LDAP_DEBUG_STATS,
- "conn=%lu op=%lu BIND dn=\"%s\" mech=simple (SLAPI) ssf=0\n",
- op->o_connid, op->o_opid,
- op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
- 0, 0 );
- ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
+ goto cleanup;
+ break;
}
- goto cleanup;
- break;
}
#endif /* defined( LDAP_SLAPI ) */
}
#if defined( LDAP_SLAPI )
- if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb ) < 0 ) {
+ if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb ) < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO,
"do_bind: Bind postoperation plugins failed\n",
AttributeAssertion ava = { NULL, { 0, NULL } };
int manageDSAit;
-#ifdef LDAP_SLAPI
- Slapi_PBlock *pb = op->o_pb;
-#endif
-
ava.aa_desc = NULL;
#ifdef NEW_LOGGING
ava.aa_desc->ad_cname.bv_val, 0 );
#if defined( LDAP_SLAPI )
- slapi_x_pblock_set_operation( pb, op );
- slapi_pblock_set( pb, SLAPI_COMPARE_TARGET, (void *)dn.bv_val );
- slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
- slapi_pblock_set( pb, SLAPI_COMPARE_TYPE, (void *)desc.bv_val );
- slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&value );
-
- rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_COMPARE_FN, pb );
- if ( rs->sr_err < 0 ) {
- /*
- * A preoperation plugin failure will abort the
- * entire operation.
- */
+#define pb op->o_pb
+ if ( pb ) {
+ slapi_x_pblock_set_operation( pb, op );
+ slapi_pblock_set( pb, SLAPI_COMPARE_TARGET, (void *)dn.bv_val );
+ slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
+ slapi_pblock_set( pb, SLAPI_COMPARE_TYPE, (void *)desc.bv_val );
+ slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&value );
+
+ rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_COMPARE_FN, pb );
+ if ( rs->sr_err < 0 ) {
+ /*
+ * A preoperation plugin failure will abort the
+ * entire operation.
+ */
#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, INFO, "do_compare: compare preoperation plugin "
- "failed\n", 0, 0, 0);
+ LDAP_LOG( OPERATION, INFO, "do_compare: compare preoperation plugin "
+ "failed\n", 0, 0, 0);
#else
- Debug(LDAP_DEBUG_TRACE, "do_compare: compare preoperation plugin "
- "failed.\n", 0, 0, 0);
+ Debug(LDAP_DEBUG_TRACE, "do_compare: compare preoperation plugin "
+ "failed.\n", 0, 0, 0);
#endif
- if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
- rs->sr_err == LDAP_SUCCESS ) {
- rs->sr_err = LDAP_OTHER;
+ if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
+ rs->sr_err == LDAP_SUCCESS ) {
+ rs->sr_err = LDAP_OTHER;
+ }
+ goto cleanup;
}
- goto cleanup;
}
#endif /* defined( LDAP_SLAPI ) */
}
#if defined( LDAP_SLAPI )
- if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_COMPARE_FN, pb ) < 0 ) {
+ if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_COMPARE_FN, pb ) < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_compare: compare postoperation plugins "
"failed\n", 0, 0, 0 );
int use_reverse_lookup = 0;
+#ifdef LDAP_SLAPI
+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);
!= LDAP_SUCCESS ) {
return( 1 );
}
+ slapi_plugins_used++;
#else /* !defined( LDAP_SLAPI ) */
#ifdef NEW_LOGGING
#define SLAP_C_ACTIVE 0x02 /* one or more threads */
#define SLAP_C_BINDING 0x03 /* binding */
#define SLAP_C_CLOSING 0x04 /* closing */
+#define SLAP_C_CLIENT 0x05 /* outbound client conn */
const char *
connection_state2str( int state )
{
switch( state ) {
- case SLAP_C_INVALID: return "!";
- case SLAP_C_INACTIVE: return "|";
- case SLAP_C_ACTIVE: return "";
+ case SLAP_C_INVALID: return "!";
+ case SLAP_C_INACTIVE: return "|";
+ case SLAP_C_ACTIVE: return "";
case SLAP_C_BINDING: return "B";
- case SLAP_C_CLOSING: return "C";
+ case SLAP_C_CLOSING: return "C";
+ case SLAP_C_CLIENT: return "L";
}
return "?";
ldap_pvt_thread_cond_init( &c->c_write_cv );
#ifdef LDAP_SLAPI
- slapi_x_create_object_extensions( SLAPI_X_EXT_CONNECTION, c );
+ if ( slapi_plugins_used ) {
+ slapi_x_create_object_extensions( SLAPI_X_EXT_CONNECTION, c );
+ }
#endif
c->c_struct_state = SLAP_C_UNUSED;
#ifdef LDAP_SLAPI
/* call destructors, then constructors; avoids unnecessary allocation */
- slapi_x_clear_object_extensions( SLAPI_X_EXT_CONNECTION, c );
+ if ( slapi_plugins_used ) {
+ slapi_x_clear_object_extensions( SLAPI_X_EXT_CONNECTION, c );
+ }
#endif
}
struct berval dn = { 0, NULL };
int manageDSAit;
-#ifdef LDAP_SLAPI
- Slapi_PBlock *pb = op->o_pb;
-#endif
-
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ENTRY,
"do_delete: conn %d\n", op->o_connid, 0, 0 );
}
#if defined( LDAP_SLAPI )
- slapi_x_pblock_set_operation( pb, op );
- slapi_pblock_set( pb, SLAPI_DELETE_TARGET, (void *)dn.bv_val );
- slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
-
- rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_DELETE_FN, pb );
- if ( rs->sr_err < 0 ) {
- /*
- * A preoperation plugin failure will abort the
- * entire operation.
- */
+#define pb op->o_pb
+ if ( pb ) {
+ slapi_x_pblock_set_operation( pb, op );
+ slapi_pblock_set( pb, SLAPI_DELETE_TARGET, (void *)dn.bv_val );
+ slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
+
+ rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_DELETE_FN, pb );
+ if ( rs->sr_err < 0 ) {
+ /*
+ * A preoperation plugin failure will abort the
+ * entire operation.
+ */
#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, INFO, "do_delete: delete preoperation plugin "
- "failed\n", 0, 0, 0 );
+ LDAP_LOG( OPERATION, INFO, "do_delete: delete preoperation plugin "
+ "failed\n", 0, 0, 0 );
#else
- Debug (LDAP_DEBUG_TRACE, "do_delete: delete preoperation plugin failed.\n",
- 0, 0, 0);
+ Debug (LDAP_DEBUG_TRACE, "do_delete: delete preoperation plugin failed.\n",
+ 0, 0, 0);
#endif
- if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
- rs->sr_err == LDAP_SUCCESS ) {
- rs->sr_err = LDAP_OTHER;
+ if ( ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
+ rs->sr_err == LDAP_SUCCESS ) {
+ rs->sr_err = LDAP_OTHER;
+ }
+ goto cleanup;
}
- goto cleanup;
}
#endif /* defined( LDAP_SLAPI ) */
}
#if defined( LDAP_SLAPI )
- if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_DELETE_FN, pb ) < 0) {
+ if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_DELETE_FN, pb ) < 0) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_delete: delete postoperation plugins "
"failed\n", 0, 0, 0 );
#endif
#ifdef LDAP_SLAPI
LDAPMod **modv = NULL;
- Slapi_PBlock *pb = op->o_pb;
#endif
int manageDSAit;
int increment = 0;
}
#if defined( LDAP_SLAPI )
- slapi_x_pblock_set_operation( pb, op );
- slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
- slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
- modv = slapi_x_modifications2ldapmods( &modlist );
- slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
-
- rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
- if ( rs->sr_err < 0 ) {
- /*
- * A preoperation plugin failure will abort the
- * entire operation.
- */
+#define pb op->o_pb
+ if ( pb ) {
+ slapi_x_pblock_set_operation( pb, op );
+ slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
+ slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
+ modv = slapi_x_modifications2ldapmods( &modlist );
+ slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
+
+ rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
+ if ( rs->sr_err < 0 ) {
+ /*
+ * A preoperation plugin failure will abort the
+ * entire operation.
+ */
#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, INFO, "do_modify: modify preoperation plugin "
- "failed\n", 0, 0, 0 );
+ LDAP_LOG( OPERATION, INFO, "do_modify: modify preoperation plugin "
+ "failed\n", 0, 0, 0 );
#else
- Debug(LDAP_DEBUG_TRACE, "do_modify: modify preoperation plugin failed.\n",
- 0, 0, 0);
+ Debug(LDAP_DEBUG_TRACE, "do_modify: modify preoperation plugin failed.\n",
+ 0, 0, 0);
#endif
- if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
- rs->sr_err == LDAP_SUCCESS ) {
- rs->sr_err = LDAP_OTHER;
+ if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
+ rs->sr_err == LDAP_SUCCESS ) {
+ rs->sr_err = LDAP_OTHER;
+ }
+ slapi_x_free_ldapmods( modv );
+ modv = NULL;
+ goto cleanup;
}
- slapi_x_free_ldapmods( modv );
- modv = NULL;
- goto cleanup;
- }
- /*
- * It's possible that the preoperation plugin changed the
- * modification array, so we need to convert it back to
- * a Modification list.
- *
- * Calling slapi_x_modifications2ldapmods() destroyed modlist so
- * we don't need to free it.
- */
- slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
- modlist = slapi_x_ldapmods2modifications( modv );
+ /*
+ * It's possible that the preoperation plugin changed the
+ * modification array, so we need to convert it back to
+ * a Modification list.
+ *
+ * Calling slapi_x_modifications2ldapmods() destroyed modlist so
+ * we don't need to free it.
+ */
+ slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
+ modlist = slapi_x_ldapmods2modifications( modv );
+ }
/*
* NB: it is valid for the plugin to return no modifications
#if defined( LDAP_SLAPI )
} /* modlist != NULL */
- if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
+ if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
"failed\n", 0, 0, 0 );
ber_len_t length;
int manageDSAit;
-#ifdef LDAP_SLAPI
- Slapi_PBlock *pb = op->o_pb;
-#endif
-
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ENTRY, "do_modrdn: begin\n", 0, 0, 0 );
#else
}
#if defined( LDAP_SLAPI )
- slapi_x_pblock_set_operation( pb, op );
- slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)dn.bv_val );
- slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn.bv_val );
- slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR,
- (void *)newSuperior.bv_val );
- slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
- slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
-
- rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODRDN_FN, pb );
- if ( rs->sr_err < 0 ) {
- /*
- * A preoperation plugin failure will abort the
- * entire operation.
- */
+#define pb op->o_pb
+ if ( pb ) {
+ slapi_x_pblock_set_operation( pb, op );
+ slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)dn.bv_val );
+ slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn.bv_val );
+ slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR,
+ (void *)newSuperior.bv_val );
+ slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
+ slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
+
+ rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODRDN_FN, pb );
+ if ( rs->sr_err < 0 ) {
+ /*
+ * A preoperation plugin failure will abort the
+ * entire operation.
+ */
#ifdef NEW_LOGGING
- LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn preoperation plugin "
- "failed\n", 0, 0, 0 );
+ LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn preoperation plugin "
+ "failed\n", 0, 0, 0 );
#else
- Debug(LDAP_DEBUG_TRACE, "do_modrdn: modrdn preoperation plugin "
- "failed.\n", 0, 0, 0);
+ Debug(LDAP_DEBUG_TRACE, "do_modrdn: modrdn preoperation plugin "
+ "failed.\n", 0, 0, 0);
#endif
- if ( ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
- rs->sr_err == LDAP_SUCCESS ) {
- rs->sr_err = LDAP_OTHER;
+ if ( ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
+ rs->sr_err == LDAP_SUCCESS ) {
+ rs->sr_err = LDAP_OTHER;
+ }
+ goto cleanup;
}
- goto cleanup;
}
#endif /* defined( LDAP_SLAPI ) */
}
#if defined( LDAP_SLAPI )
- if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODRDN_FN, pb ) < 0 ) {
+ if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODRDN_FN, pb ) < 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, INFO, "do_modrdn: modrdn postoperation plugins "
"failed\n", 0, 0, 0 );
#if defined( LDAP_SLAPI )
if ( op->o_pb != NULL ) {
slapi_pblock_destroy( (Slapi_PBlock *)op->o_pb );
+ slapi_x_free_object_extensions( SLAPI_X_EXT_OPERATION, op );
}
- slapi_x_free_object_extensions( SLAPI_X_EXT_OPERATION, op );
#endif /* defined( LDAP_SLAPI ) */
memset( op, 0, sizeof(Operation) );
op->o_res_ber = NULL;
#if defined( LDAP_SLAPI )
- op->o_pb = slapi_pblock_new();
- slapi_x_create_object_extensions( SLAPI_X_EXT_OPERATION, op );
+ if ( slapi_plugins_used ) {
+ op->o_pb = slapi_pblock_new();
+ slapi_x_create_object_extensions( SLAPI_X_EXT_OPERATION, op );
+ }
#endif /* defined( LDAP_SLAPI ) */
return( op );
LDAP_SLAPD_F (int) read_config LDAP_P(( const char *fname, int depth ));
LDAP_SLAPD_F (void) config_destroy LDAP_P ((void));
LDAP_SLAPD_F (char **) str2clist LDAP_P(( char ***, char *, const char * ));
+#ifdef LDAP_SLAPI
+LDAP_SLAPD_V (int) slapi_plugins_used;
+#endif
/*
* connection.c
}
#ifdef LDAP_SLAPI
- slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
- slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
- slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
+ if ( op->o_pb ) {
+ slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
+ slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
+ slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
+ }
#endif /* LDAP_SLAPI */
ldap_pvt_thread_mutex_lock( &num_sent_mutex );
* should just set SLAPI_RESULT_CODE rather than sending a
* result if they wish to change the result.
*/
- slapi_x_pblock_set_operation( op->o_pb, op );
- slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
- slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
- slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
+ if ( op->o_pb ) {
+ slapi_x_pblock_set_operation( op->o_pb, op );
+ slapi_pblock_set( op->o_pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
+ slapi_pblock_set( op->o_pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
+ slapi_pblock_set( op->o_pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
- (void) doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_RESULT_FN, op->o_pb );
+ (void) doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_RESULT_FN, op->o_pb );
+ }
#endif /* LDAP_SLAPI */
if ( op->o_protocol < LDAP_VERSION3 ) {
* First, setup the computed attribute context that is
* passed to all plugins.
*/
- ctx.cac_pb = op->o_pb;
- ctx.cac_attrs = rs->sr_attrs;
- ctx.cac_attrsonly = op->ors_attrsonly;
- ctx.cac_userattrs = userattrs;
- ctx.cac_opattrs = opattrs;
- ctx.cac_acl_state = acl_state;
- ctx.cac_private = (void *)ber;
+ if ( op->o_pb ) {
+ ctx.cac_pb = op->o_pb;
+ ctx.cac_attrs = rs->sr_attrs;
+ ctx.cac_attrsonly = op->ors_attrsonly;
+ ctx.cac_userattrs = userattrs;
+ ctx.cac_opattrs = opattrs;
+ ctx.cac_acl_state = acl_state;
+ ctx.cac_private = (void *)ber;
- /*
- * For each client requested attribute, call the plugins.
- */
- if ( rs->sr_attrs != NULL ) {
- for ( anp = rs->sr_attrs; anp->an_name.bv_val != NULL; anp++ ) {
- rc = compute_evaluator( &ctx, anp->an_name.bv_val,
- rs->sr_entry, slapi_x_compute_output_ber );
- if ( rc == 1 ) {
- break;
- }
- }
- } else {
/*
- * Technically we shouldn't be returning operational attributes
- * when the user requested only user attributes. We'll let the
- * plugin decide whether to be naughty or not.
+ * For each client requested attribute, call the plugins.
*/
- rc = compute_evaluator( &ctx, "*",
- rs->sr_entry, slapi_x_compute_output_ber );
- }
- if ( rc == 1 ) {
- if ( op->o_res_ber == NULL ) ber_free_buf( ber );
- send_ldap_error( op, rs, LDAP_OTHER, "computed attribute error" );
- goto error_return;
+ if ( rs->sr_attrs != NULL ) {
+ for ( anp = rs->sr_attrs; anp->an_name.bv_val != NULL; anp++ ) {
+ rc = compute_evaluator( &ctx, anp->an_name.bv_val,
+ rs->sr_entry, slapi_x_compute_output_ber );
+ if ( rc == 1 ) {
+ break;
+ }
+ }
+ } else {
+ /*
+ * Technically we shouldn't be returning operational attributes
+ * when the user requested only user attributes. We'll let the
+ * plugin decide whether to be naughty or not.
+ */
+ rc = compute_evaluator( &ctx, "*",
+ rs->sr_entry, slapi_x_compute_output_ber );
+ }
+ if ( rc == 1 ) {
+ if ( op->o_res_ber == NULL ) ber_free_buf( ber );
+ send_ldap_error( op, rs, LDAP_OTHER, "computed attribute error" );
+ goto error_return;
+ }
}
#endif /* LDAP_SLAPI */
manageDSAit = get_manageDSAit( op );
- if ( op->ors_scope == LDAP_SCOPE_BASE ) {
+ /* fake while loop to allow breaking out */
+ while ( op->ors_scope == LDAP_SCOPE_BASE ) {
Entry *entry = NULL;
if ( op->o_req_ndn.bv_len == 0 ) {
}
#ifdef LDAP_SLAPI
- attrs = anlist2charray( op, op->ors_attrs );
- initSearchPlugin( op, attrs, manageDSAit );
- rs->sr_err = doPreSearchPluginFNs( op );
- if ( rs->sr_err == LDAP_SUCCESS ) {
+ if ( op->o_pb ) {
+ attrs = anlist2charray( op, op->ors_attrs );
+ initSearchPlugin( op, attrs, manageDSAit );
+ rs->sr_err = doPreSearchPluginFNs( op );
+ if ( rs->sr_err ) break;
doSearchRewriteFNs( op );
-#endif /* LDAP_SLAPI */
- rs->sr_err = root_dse_info( op->o_conn, &entry, &rs->sr_text );
-#ifdef LDAP_SLAPI
}
#endif /* LDAP_SLAPI */
+ rs->sr_err = root_dse_info( op->o_conn, &entry, &rs->sr_text );
} else if ( bvmatch( &op->o_req_ndn, &global_schemandn ) ) {
/* check restrictions */
}
#ifdef LDAP_SLAPI
- attrs = anlist2charray( op, op->ors_attrs );
- initSearchPlugin( op, attrs, manageDSAit );
- rs->sr_err = doPreSearchPluginFNs( op );
- if ( rs->sr_err == LDAP_SUCCESS ) {
+ if ( op->o_pb ) {
+ attrs = anlist2charray( op, op->ors_attrs );
+ initSearchPlugin( op, attrs, manageDSAit );
+ rs->sr_err = doPreSearchPluginFNs( op );
+ if ( rs->sr_err ) break;
doSearchRewriteFNs( op );
-#endif /* LDAP_SLAPI */
- rs->sr_err = schema_info( &entry, &rs->sr_text );
-#ifdef LDAP_SLAPI
}
#endif /* LDAP_SLAPI */
+ rs->sr_err = schema_info( &entry, &rs->sr_text );
}
if( rs->sr_err != LDAP_SUCCESS ) {
send_ldap_result( op, rs );
#ifdef LDAP_SLAPI
- doPostSearchPluginFNs( op );
+ if ( op->o_pb ) doPostSearchPluginFNs( op );
#endif /* LDAP_SLAPI */
goto return_results;
rs->sr_err = LDAP_SUCCESS;
send_ldap_result( op, rs );
#ifdef LDAP_SLAPI
- doPostSearchPluginFNs( op );
+ if ( op->o_pb ) doPostSearchPluginFNs( op );
#endif /* LDAP_SLAPI */
goto return_results;
}
+ break;
}
if( !op->o_req_ndn.bv_len && default_search_nbase.bv_len ) {
}
#ifdef LDAP_SLAPI
- attrs = anlist2charray( op, op->ors_attrs );
- initSearchPlugin( op, attrs, manageDSAit );
- rs->sr_err = doPreSearchPluginFNs( op );
- if ( rs->sr_err != LDAP_SUCCESS ) {
- goto return_results;
- }
+ if ( op->o_pb ) {
+ attrs = anlist2charray( op, op->ors_attrs );
+ initSearchPlugin( op, attrs, manageDSAit );
+ rs->sr_err = doPreSearchPluginFNs( op );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ goto return_results;
+ }
- doSearchRewriteFNs( op );
+ doSearchRewriteFNs( op );
+ }
#endif /* LDAP_SLAPI */
/* actually do the search and send the result(s) */
}
#ifdef LDAP_SLAPI
- doPostSearchPluginFNs( op );
+ if ( op->o_pb ) doPostSearchPluginFNs( op );
#endif /* LDAP_SLAPI */
return_results:;
op.o_conn = &conn;
op.o_connid = op.o_conn->c_connid;
#if defined( LDAP_SLAPI )
- op.o_pb = slapi_pblock_new();
- slapi_x_create_object_extensions( SLAPI_X_EXT_OPERATION, &op );
+ if ( slapi_plugins_used ) {
+ op.o_pb = slapi_pblock_new();
+ slapi_x_create_object_extensions( SLAPI_X_EXT_OPERATION, &op );
+ }
#endif /* defined( LDAP_SLAPI ) */
/* get syncrepl cookie of shadow replica from subentry */