This is an automated email from the git hooks/post-receive script.
firstyear pushed a commit to branch master
in repository 389-ds-base.
commit 74c666b83e3e1789c2ef3f7935c327bd7555193e
Author: William Brown <firstyear(a)redhat.com>
Date: Tue Apr 11 16:56:59 2017 +1000
Ticket 49097 - Pblock get/set cleanup
Bug Description: In order to break up the pblock, we have to guarantee
that there are no users of the struct members directly. This throws our
stats tracking off, and is just a violation of the api.
Fix Description: To achieve this, we move the pblock struct definition
to be completely hidden. This "breaks" direct access to pblock members,
forcing the access to be through the api. Once this access is through
the api, we can then re-arrange the contents inside of the pblock
behind the get / set, and make the pblock struct itself signifigantly
smaller, with a tree based structure behind it.
https://pagure.io/389-ds-base/issue/49097
Author: wibrown
Review by: mreynolds (Thanks!)
---
ldap/servers/plugins/acl/acleffectiverights.c | 4 +-
ldap/servers/plugins/referint/referint.c | 9 +-
ldap/servers/slapd/abandon.c | 30 +--
ldap/servers/slapd/add.c | 33 ++--
ldap/servers/slapd/back-ldbm/filterindex.c | 51 +++--
ldap/servers/slapd/back-ldbm/findentry.c | 5 +-
ldap/servers/slapd/back-ldbm/import-threads.c | 53 ++---
ldap/servers/slapd/back-ldbm/import.c | 3 +-
ldap/servers/slapd/back-ldbm/index.c | 15 +-
ldap/servers/slapd/back-ldbm/ldbm_add.c | 4 +-
ldap/servers/slapd/back-ldbm/ldbm_config.c | 8 +-
ldap/servers/slapd/back-ldbm/ldbm_delete.c | 12 +-
ldap/servers/slapd/back-ldbm/ldbm_modrdn.c | 15 +-
ldap/servers/slapd/back-ldbm/ldbm_search.c | 10 +-
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 4 +-
ldap/servers/slapd/back-ldbm/vlv.c | 9 +-
ldap/servers/slapd/backend.c | 4 +-
ldap/servers/slapd/backend_manager.c | 64 +++---
ldap/servers/slapd/bind.c | 83 ++++----
ldap/servers/slapd/compare.c | 13 +-
ldap/servers/slapd/connection.c | 66 ++++---
ldap/servers/slapd/control.c | 17 +-
ldap/servers/slapd/daemon.c | 22 +--
ldap/servers/slapd/defbackend.c | 38 ++--
ldap/servers/slapd/delete.c | 22 ++-
ldap/servers/slapd/dn.c | 10 +-
ldap/servers/slapd/dse.c | 27 ++-
ldap/servers/slapd/entry.c | 32 +--
ldap/servers/slapd/extendop.c | 61 +++---
ldap/servers/slapd/fedse.c | 24 +--
ldap/servers/slapd/filter.c | 7 +-
ldap/servers/slapd/filtercmp.c | 9 +-
ldap/servers/slapd/main.c | 184 +++++++++---------
ldap/servers/slapd/mapping_tree.c | 50 ++---
ldap/servers/slapd/modify.c | 61 +++---
ldap/servers/slapd/modrdn.c | 32 +--
ldap/servers/slapd/operation.c | 27 +--
ldap/servers/slapd/opshared.c | 129 +++++++------
ldap/servers/slapd/pagedresults.c | 7 +-
ldap/servers/slapd/passwd_extop.c | 32 +--
ldap/servers/slapd/pblock.c | 102 +++++++---
ldap/servers/slapd/pblock_v3.h | 186 ++++++++++++++++++
ldap/servers/slapd/plugin.c | 199 ++++++++++---------
ldap/servers/slapd/plugin_internal_op.c | 43 +++--
ldap/servers/slapd/plugin_mr.c | 144 +++++++++-----
ldap/servers/slapd/plugin_syntax.c | 94 +++++----
ldap/servers/slapd/psearch.c | 49 ++---
ldap/servers/slapd/pw.c | 57 ++++--
ldap/servers/slapd/pw_mgmt.c | 27 +--
ldap/servers/slapd/pw_retry.c | 11 +-
ldap/servers/slapd/referral.c | 6 +-
ldap/servers/slapd/result.c | 60 +++---
ldap/servers/slapd/saslbind.c | 78 ++++----
ldap/servers/slapd/schema.c | 25 +--
ldap/servers/slapd/search.c | 17 +-
ldap/servers/slapd/slap.h | 182 ++----------------
ldap/servers/slapd/slapi-plugin.h | 5 +-
ldap/servers/slapd/slapi-private.h | 4 +
ldap/servers/slapd/sort.c | 12 +-
ldap/servers/slapd/ssl.c | 8 +-
ldap/servers/slapd/start_tls_extop.c | 17 +-
ldap/servers/slapd/task.c | 267 ++++++++++++++++----------
ldap/servers/slapd/unbind.c | 18 +-
ldap/servers/slapd/vattr.c | 14 +-
64 files changed, 1695 insertions(+), 1216 deletions(-)
diff --git a/ldap/servers/plugins/acl/acleffectiverights.c
b/ldap/servers/plugins/acl/acleffectiverights.c
index 2414ef4..fc6f726 100644
--- a/ldap/servers/plugins/acl/acleffectiverights.c
+++ b/ldap/servers/plugins/acl/acleffectiverights.c
@@ -104,7 +104,9 @@ _ger_g_permission_granted (
else
{
slapi_ch_free_string(&proxydn); /* this could still have been set - free it */
- requestor_sdn = &(pb->pb_op->o_sdn);
+ Operation *pb_op;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ requestor_sdn = &(pb_op->o_sdn);
}
if ( slapi_sdn_get_dn (requestor_sdn) == NULL )
{
diff --git a/ldap/servers/plugins/referint/referint.c
b/ldap/servers/plugins/referint/referint.c
index 0d95a86..b4eed3d 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -1224,12 +1224,13 @@ update_integrity(Slapi_DN *origSDN,
"update_integrity - Search (base=%s filter=%s) returned
"
"error %d\n", search_base, filter, search_result);
rc = SLAPI_PLUGIN_FAILURE;
+ slapi_free_search_results_internal(search_result_pb);
goto free_and_return;
}
}
slapi_ch_free_string(&filter);
+ slapi_free_search_results_internal(search_result_pb);
}
- slapi_free_search_results_internal(search_result_pb);
}
if (plugin_ContainerScope) {
/* at the moment only a single scope is supported
@@ -1248,11 +1249,7 @@ free_and_return:
slapi_ch_array_free(membership_attrs);
slapi_pblock_destroy(mod_pb);
- if (search_result_pb) {
- slapi_free_search_results_internal(search_result_pb);
- slapi_pblock_destroy(search_result_pb);
- }
-
+ slapi_pblock_destroy(search_result_pb);
return(rc);
}
diff --git a/ldap/servers/slapd/abandon.c b/ldap/servers/slapd/abandon.c
index 0485006..779ec49 100644
--- a/ldap/servers/slapd/abandon.c
+++ b/ldap/servers/slapd/abandon.c
@@ -35,8 +35,14 @@ do_abandon( Slapi_PBlock *pb )
{
int err, suppressed_by_plugin = 0;
ber_int_t id;
+ Connection *pb_conn = NULL;
+ Operation *pb_op = NULL;
Operation *o;
- BerElement *ber = pb->pb_op->o_ber;
+
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
+ BerElement *ber = pb_op->o_ber;
slapi_log_err(SLAPI_LOG_TRACE, "do_abandon", "->\n");
@@ -76,9 +82,9 @@ do_abandon( Slapi_PBlock *pb )
* flag and abort the operation at a convenient time.
*/
- PR_EnterMonitor(pb->pb_conn->c_mutex);
- for ( o = pb->pb_conn->c_ops; o != NULL; o = o->o_next ) {
- if ( o->o_msgid == id && o != pb->pb_op)
+ PR_EnterMonitor(pb_conn->c_mutex);
+ for ( o = pb_conn->c_ops; o != NULL; o = o->o_next ) {
+ if ( o->o_msgid == id && o != pb_op)
break;
}
@@ -94,12 +100,12 @@ do_abandon( Slapi_PBlock *pb )
are applicable for the operation */
ts = operation_get_target_spec (o);
if (ts) {
- operation_set_target_spec (pb->pb_op, ts);
+ operation_set_target_spec (pb_op, ts);
} else {
slapi_log_err(SLAPI_LOG_TRACE, "do_abandon", "no target spec of
abandoned operation\n");
}
- operation_set_abandoned_op (pb->pb_op, o->o_abandoned_op);
+ operation_set_abandoned_op (pb_op, o->o_abandoned_op);
if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_ABANDON_FN ) == 0 ) {
int rc = 0;
@@ -118,26 +124,26 @@ do_abandon( Slapi_PBlock *pb )
slapi_log_err(SLAPI_LOG_TRACE, "do_abandon", "op not found\n");
}
- if ( 0 == pagedresults_free_one_msgid_nolock(pb->pb_conn, id) ) {
+ if ( 0 == pagedresults_free_one_msgid_nolock(pb_conn, id) ) {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64
" op=%d ABANDON targetop=Simple Paged Results msgid=%d\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid, id );
+ pb_conn->c_connid, pb_op->o_opid, id );
} else if ( NULL == o ) {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d
ABANDON"
" targetop=NOTFOUND msgid=%d\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid, id );
+ pb_conn->c_connid, pb_op->o_opid, id );
} else if ( suppressed_by_plugin ) {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d
ABANDON"
" targetop=SUPPRESSED-BY-PLUGIN msgid=%d\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid, id );
+ pb_conn->c_connid, pb_op->o_opid, id );
} else {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d
ABANDON"
" targetop=%d msgid=%d nentries=%d etime=%ld\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid, o->o_opid, id,
+ pb_conn->c_connid, pb_op->o_opid, o->o_opid, id,
o->o_results.r.r_search.nentries, current_time() - o->o_time );
}
- PR_ExitMonitor(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb_conn->c_mutex);
/*
* Wake up the persistent searches, so they
* can notice if they've been abandoned.
diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c
index 7176ceb..1286b89 100644
--- a/ldap/servers/slapd/add.c
+++ b/ldap/servers/slapd/add.c
@@ -60,9 +60,11 @@ do_add( Slapi_PBlock *pb )
int err;
int rc;
PRBool searchsubentry=PR_TRUE;
+ Connection *pb_conn = NULL;
slapi_log_err(SLAPI_LOG_TRACE, "do_add", "==>\n");
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
slapi_pblock_get( pb, SLAPI_OPERATION, &operation);
ber = operation->o_ber;
@@ -164,12 +166,12 @@ do_add( Slapi_PBlock *pb )
/* for now we just ignore attributes that client is not allowed
to modify so not to break existing clients */
- if (op_shared_is_allowed_attr (normtype,
pb->pb_conn->c_isreplication_session)){
+ if (op_shared_is_allowed_attr (normtype, pb_conn->c_isreplication_session)){
if (( rc = slapi_entry_add_values( e, normtype, vals ))
!= LDAP_SUCCESS ) {
slapi_log_access( LDAP_DEBUG_STATS,
"conn=%" PRIu64 " op=%d ADD dn=\"%s\", add values for type
%s failed\n",
- pb->pb_conn->c_connid, operation->o_opid,
+ pb_conn->c_connid, operation->o_opid,
slapi_entry_get_dn_const(e), normtype );
send_ldap_result( pb, rc, NULL, NULL, 0, NULL );
@@ -220,7 +222,7 @@ do_add( Slapi_PBlock *pb )
slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &operation->o_isroot );
slapi_pblock_set( pb, SLAPI_ADD_ENTRY, e );
- if (pb->pb_conn->c_flags & CONN_FLAG_IMPORT) {
+ if (pb_conn->c_flags & CONN_FLAG_IMPORT) {
/* this add is actually part of a bulk import -- punt */
handle_fast_add(pb, e);
} else {
@@ -282,23 +284,21 @@ done:
Slapi_PBlock *
slapi_add_entry_internal(Slapi_Entry *e, LDAPControl **controls, int dummy
__attribute__((unused)))
{
- Slapi_PBlock pb;
+ Slapi_PBlock *pb = slapi_pblock_new();
Slapi_PBlock *result_pb = NULL;
int opresult;
- pblock_init(&pb);
-
- slapi_add_entry_internal_set_pb (&pb, e, controls,
plugin_get_default_component_id(), 0);
+ slapi_add_entry_internal_set_pb (pb, e, controls, plugin_get_default_component_id(),
0);
- add_internal_pb (&pb);
+ add_internal_pb (pb);
result_pb = slapi_pblock_new();
if (result_pb)
{
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
slapi_pblock_set(result_pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
}
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
return result_pb;
}
@@ -431,8 +431,10 @@ static void op_shared_add (Slapi_PBlock *pb)
char *errtext = NULL;
Slapi_DN *sdn = NULL;
passwdPolicy *pwpolicy;
+ Connection *pb_conn = NULL;
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
+ slapi_pblock_get (pb, SLAPI_CONNECTION, &pb_conn);
slapi_pblock_get (pb, SLAPI_ADD_ENTRY, &e);
slapi_pblock_get (pb, SLAPI_IS_REPLICATED_OPERATION, &repl_op);
slapi_pblock_get (pb, SLAPI_IS_LEGACY_REPLICATED_OPERATION, &legacy_op);
@@ -461,7 +463,7 @@ static void op_shared_add (Slapi_PBlock *pb)
if ( !internal_op )
{
slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d ADD
dn=\"%s\"%s\n",
- pb->pb_conn->c_connid,
+ pb_conn->c_connid,
operation->o_opid,
slapi_entry_get_dn_const(e),
proxystr ? proxystr : "");
@@ -905,9 +907,12 @@ static void handle_fast_add(Slapi_PBlock *pb, Slapi_Entry *entry)
{
Slapi_Backend *be;
Slapi_Operation *operation;
+ Connection *pb_conn = NULL;
int ret;
- be = pb->pb_conn->c_bi_backend;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
+ be = pb_conn->c_bi_backend;
if ((be == NULL) || (be->be_wire_import == NULL)) {
/* can this even happen? */
@@ -967,8 +972,8 @@ static void handle_fast_add(Slapi_PBlock *pb, Slapi_Entry *entry)
slapi_entry_free(entry);
/* turn off fast replica init -- import is now aborted */
- pb->pb_conn->c_bi_backend = NULL;
- pb->pb_conn->c_flags &= ~CONN_FLAG_IMPORT;
+ pb_conn->c_bi_backend = NULL;
+ pb_conn->c_flags &= ~CONN_FLAG_IMPORT;
return;
}
diff --git a/ldap/servers/slapd/back-ldbm/filterindex.c
b/ldap/servers/slapd/back-ldbm/filterindex.c
index 4562be9..6af8e09 100644
--- a/ldap/servers/slapd/back-ldbm/filterindex.c
+++ b/ldap/servers/slapd/back-ldbm/filterindex.c
@@ -196,6 +196,8 @@ ava_candidates(
Slapi_Attr sattr;
back_txn txn = {NULL};
int pr_idx = -1;
+ Operation *pb_op;
+ Connection *pb_conn;
slapi_log_err(SLAPI_LOG_TRACE, "ava_candidates", "=>\n");
@@ -205,6 +207,8 @@ ava_candidates(
}
slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx);
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
slapi_attr_init(&sattr, type);
#ifdef LDAP_ERROR_LOGGING
@@ -288,7 +292,7 @@ ava_candidates(
if ( unindexed ) {
unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED;
slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote );
- pagedresults_set_unindexed( pb->pb_conn, pb->pb_op, pr_idx );
+ pagedresults_set_unindexed( pb_conn, pb_op, pr_idx );
}
/* We don't use valuearray_free here since the valueset, berval
@@ -320,7 +324,7 @@ ava_candidates(
if ( unindexed ) {
unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED;
slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote );
- pagedresults_set_unindexed( pb->pb_conn, pb->pb_op, pr_idx );
+ pagedresults_set_unindexed( pb_conn, pb_op, pr_idx );
}
valuearray_free( &ivals );
slapi_log_err(SLAPI_LOG_TRACE, "ava_candidates", "<=
%lu\n",
@@ -356,11 +360,17 @@ presence_candidates(
NULL, &txn, err, &unindexed, allidslimit );
if ( unindexed ) {
+ Operation *pb_op;
+ Connection *pb_conn;
+
int pr_idx = -1;
unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED;
- slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote );
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
+ slapi_pblock_set(pb, SLAPI_OPERATION_NOTES, &opnote );
slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx);
- pagedresults_set_unindexed(pb->pb_conn, pb->pb_op, pr_idx);
+ pagedresults_set_unindexed(pb_conn, pb_op, pr_idx);
}
if (idl != NULL && ALLIDS(idl) && strcasecmp(type,
"nscpentrydn") == 0) {
@@ -467,14 +477,15 @@ extensible_candidates(
if ( unindexed ) {
int pr_idx = -1;
unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED;
- slapi_pblock_set( glob_pb,
- SLAPI_OPERATION_NOTES, &opnote );
- slapi_pblock_get( glob_pb,
- SLAPI_PAGED_RESULTS_INDEX,
- &pr_idx );
- pagedresults_set_unindexed( glob_pb->pb_conn,
- glob_pb->pb_op,
- pr_idx );
+
+ Operation *pb_op;
+ Connection *pb_conn;
+ slapi_pblock_get(glob_pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(glob_pb, SLAPI_CONNECTION,
&pb_conn);
+
+ slapi_pblock_set( glob_pb, SLAPI_OPERATION_NOTES,
&opnote );
+ slapi_pblock_get( glob_pb, SLAPI_PAGED_RESULTS_INDEX,
&pr_idx );
+ pagedresults_set_unindexed( pb_conn, pb_op, pr_idx );
}
if (idl2 == NULL)
{
@@ -933,8 +944,12 @@ substring_candidates(
attr_done(&sattr);
slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx);
if ( ivals == NULL || *ivals == NULL ) {
- slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote );
- pagedresults_set_unindexed( pb->pb_conn, pb->pb_op, pr_idx );
+ Operation *pb_op;
+ Connection *pb_conn;
+ slapi_pblock_set(pb, SLAPI_OPERATION_NOTES, &opnote );
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ pagedresults_set_unindexed( pb_conn, pb_op, pr_idx );
slapi_log_err(SLAPI_LOG_TRACE, "substring_candidates",
"<= ALLIDS (no keys)\n");
return( idl_allids( be ) );
@@ -947,8 +962,12 @@ substring_candidates(
slapi_pblock_get(pb, SLAPI_TXN, &txn.back_txn_txn);
idl = keys2idl( pb, be, type, indextype_SUB, ivals, err, &unindexed, &txn,
allidslimit );
if ( unindexed ) {
- slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote );
- pagedresults_set_unindexed( pb->pb_conn, pb->pb_op, pr_idx );
+ Operation *pb_op;
+ Connection *pb_conn;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ slapi_pblock_set(pb, SLAPI_OPERATION_NOTES, &opnote );
+ pagedresults_set_unindexed( pb_conn, pb_op, pr_idx );
}
valuearray_free( &ivals );
diff --git a/ldap/servers/slapd/back-ldbm/findentry.c
b/ldap/servers/slapd/back-ldbm/findentry.c
index 458679b..7565c43 100644
--- a/ldap/servers/slapd/back-ldbm/findentry.c
+++ b/ldap/servers/slapd/back-ldbm/findentry.c
@@ -159,7 +159,10 @@ find_entry_internal_dn(
struct backentry *me;
Slapi_DN ancestorsdn;
slapi_sdn_init(&ancestorsdn);
- me = dn2ancestor(pb->pb_backend, sdn, &ancestorsdn, txn, &err, 1 /*
allow_suffix */);
+ Slapi_Backend *pb_backend;
+ slapi_pblock_get(pb, SLAPI_BACKEND, &pb_backend);
+
+ me = dn2ancestor(pb_backend, sdn, &ancestorsdn, txn, &err, 1 /* allow_suffix
*/);
if ( !managedsait && me != NULL ) {
/* if the entry is a referral send the referral */
if(check_entry_for_referral(pb, me->ep_entry,
(char*)slapi_sdn_get_dn(&ancestorsdn), "find_entry_internal_dn"))
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c
b/ldap/servers/slapd/back-ldbm/import-threads.c
index 9f64f2e..c45a358 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -3163,8 +3163,11 @@ static int bulk_import_start(Slapi_PBlock *pb)
}
job->main_thread = thread;
- slapi_set_object_extension(li->li_bulk_import_object, pb->pb_conn,
- li->li_bulk_import_handle, job);
+
+ Connection *pb_conn;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
+ slapi_set_object_extension(li->li_bulk_import_object, pb_conn,
li->li_bulk_import_handle, job);
/* wait for the import_main to signal that it's ready for entries */
/* (don't want to send the success code back to the LDAP client until
@@ -3406,7 +3409,9 @@ int ldbm_back_wire_import(Slapi_PBlock *pb)
ImportJob *job = NULL;
PRThread *thread;
int state;
+ Connection *pb_conn;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
slapi_pblock_get(pb, SLAPI_BACKEND, &be);
if (be == NULL) {
slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_wire_import",
@@ -3421,37 +3426,35 @@ int ldbm_back_wire_import(Slapi_PBlock *pb)
int rc = bulk_import_start(pb);
if (!rc) {
/* job must be available since bulk_import_start was successful */
- job =
- (ImportJob *)slapi_get_object_extension(li->li_bulk_import_object,
- pb->pb_conn,
- li->li_bulk_import_handle);
+ job = (ImportJob *)slapi_get_object_extension(li->li_bulk_import_object,
pb_conn, li->li_bulk_import_handle);
/* Get entryusn, if needed. */
_get_import_entryusn(job, &(job->usn_value));
}
return rc;
}
- PR_ASSERT(pb->pb_conn != NULL);
- if (pb->pb_conn != NULL) {
- job = (ImportJob *)slapi_get_object_extension(li->li_bulk_import_object,
pb->pb_conn, li->li_bulk_import_handle);
+ PR_ASSERT(pb_conn != NULL);
+ if (pb_conn != NULL) {
+ job = (ImportJob *)slapi_get_object_extension(li->li_bulk_import_object,
pb_conn, li->li_bulk_import_handle);
}
- if ((job == NULL) || (pb->pb_conn == NULL)) {
+ if ((job == NULL) || (pb_conn == NULL)) {
/* import might be aborting */
return -1;
}
if (state == SLAPI_BI_STATE_ADD) {
+ Slapi_Entry *pb_import_entry = NULL;
+ slapi_pblock_get(pb, SLAPI_BULK_IMPORT_ENTRY, &pb_import_entry);
/* continuing previous import */
- if (! import_entry_belongs_here(pb->pb_import_entry,
- job->inst->inst_be)) {
+ if (! import_entry_belongs_here(pb_import_entry, job->inst->inst_be)) {
/* silently skip */
/* We need to consume pb->pb_import_entry on success, so we free it here.
*/
- slapi_entry_free(pb->pb_import_entry);
+ slapi_entry_free(pb_import_entry);
return 0;
}
- return bulk_import_queue(job, pb->pb_import_entry);
+ return bulk_import_queue(job, pb_import_entry);
}
thread = job->main_thread;
@@ -3465,8 +3468,7 @@ int ldbm_back_wire_import(Slapi_PBlock *pb)
*/
/* wait for import_main to finish... */
PR_JoinThread(thread);
- slapi_set_object_extension(li->li_bulk_import_object, pb->pb_conn,
- li->li_bulk_import_handle, NULL);
+ slapi_set_object_extension(li->li_bulk_import_object, pb_conn,
li->li_bulk_import_handle, NULL);
return 0;
}
@@ -3672,7 +3674,6 @@ dse_conf_verify_core(struct ldbminfo *li, char *src_dir, char
*file_name, char *
Slapi_Entry **backup_entries = NULL;
Slapi_Entry **bep = NULL;
Slapi_Entry **curr_entries = NULL;
- Slapi_PBlock srch_pb = {0};
filename = slapi_ch_smprintf("%s/%s", src_dir, file_name);
@@ -3745,10 +3746,12 @@ dse_conf_verify_core(struct ldbminfo *li, char *src_dir, char
*file_name, char *
search_scope = slapi_ch_strdup(li->li_plugin->plg_dn);
}
- slapi_search_internal_set_pb(&srch_pb, search_scope,
+ Slapi_PBlock *srch_pb = slapi_pblock_new();
+
+ slapi_search_internal_set_pb(srch_pb, search_scope,
LDAP_SCOPE_SUBTREE, filter, NULL, 0, NULL, NULL, li->li_identity, 0);
- slapi_search_internal_pb(&srch_pb);
- slapi_pblock_get(&srch_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES,
&curr_entries);
+ slapi_search_internal_pb(srch_pb);
+ slapi_pblock_get(srch_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &curr_entries);
if (0 != slapi_entries_diff(backup_entries, curr_entries, 1 /* test_all */,
@@ -3759,12 +3762,13 @@ dse_conf_verify_core(struct ldbminfo *li, char *src_dir, char
*file_name, char *
"The backup is restored.\n", log_str);
}
- slapi_free_search_results_internal(&srch_pb);
- pblock_done(&srch_pb);
+ slapi_free_search_results_internal(srch_pb);
+ slapi_pblock_destroy(srch_pb);
import_free_ldif(&c);
out:
- for (bep = backup_entries; bep && *bep; bep++)
+ for (bep = backup_entries; bep && *bep; bep++) {
slapi_entry_free(*bep);
+ }
slapi_ch_free((void **)&backup_entries);
slapi_ch_free_string(&filename);
@@ -3772,8 +3776,9 @@ out:
slapi_ch_free_string(&search_scope);
- if (fd > 0)
+ if (fd > 0) {
close(fd);
+ }
return rval;
}
diff --git a/ldap/servers/slapd/back-ldbm/import.c
b/ldap/servers/slapd/back-ldbm/import.c
index 7161bac..8b07939 100644
--- a/ldap/servers/slapd/back-ldbm/import.c
+++ b/ldap/servers/slapd/back-ldbm/import.c
@@ -1199,8 +1199,9 @@ int import_main_offline(void *arg)
ImportWorkerInfo *producer = NULL;
char *opstr = "Import";
- if (job->task)
+ if (job->task) {
slapi_task_inc_refcount(job->task);
+ }
if (job->flags & (FLAG_UPGRADEDNFORMAT|FLAG_UPGRADEDNFORMAT_V1)) {
if (job->flags & FLAG_DRYRUN) {
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index 7b4fdb0..bb34c3f 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -2101,13 +2101,11 @@ index_addordel_values_ext_sv(
Slapi_Value **esubvals = NULL;
Slapi_Value **substresult = NULL;
Slapi_Value **origvals = NULL;
- Slapi_PBlock pipb;
+ Slapi_PBlock *pipb = slapi_pblock_new();
/* prepare pblock to pass ai_substr_lens */
- pblock_init( &pipb );
- slapi_pblock_set( &pipb, SLAPI_SYNTAX_SUBSTRLENS, ai->ai_substr_lens );
- slapi_attr_values2keys_sv_pb( &ai->ai_sattr, vals, &ivals,
- LDAP_FILTER_SUBSTRINGS, &pipb );
+ slapi_pblock_set( pipb, SLAPI_SYNTAX_SUBSTRLENS, ai->ai_substr_lens );
+ slapi_attr_values2keys_sv_pb( &ai->ai_sattr, vals, &ivals,
LDAP_FILTER_SUBSTRINGS, pipb );
origvals = ivals;
/* delete only: if the attribute has multiple values,
@@ -2116,17 +2114,18 @@ index_addordel_values_ext_sv(
* then get rid of them from the being deleted values
*/
if ( evals != NULL ) {
- slapi_attr_values2keys_sv_pb( &ai->ai_sattr, evals,
- &esubvals, LDAP_FILTER_SUBSTRINGS, &pipb );
+ slapi_attr_values2keys_sv_pb( &ai->ai_sattr, evals, &esubvals,
LDAP_FILTER_SUBSTRINGS, pipb );
substresult = valuearray_minus_valuearray( &ai->ai_sattr, ivals,
esubvals );
ivals = substresult;
valuearray_free( &esubvals );
}
+ slapi_pblock_destroy(pipb);
if ( ivals != NULL ) {
err = addordel_values_sv( be, db, basetype, indextype_SUB,
ivals, id, flags, txn, ai, idl_disposition,
buffer_handle );
- if ( ivals != origvals )
+ if ( ivals != origvals ) {
valuearray_free( &origvals );
+ }
valuearray_free( &ivals );
if ( err != 0 ) {
ldbm_nasty("index_addordel_values_ext_sv", errmsg, 1250, err);
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_add.c
b/ldap/servers/slapd/back-ldbm/ldbm_add.c
index 9e80479..8acaaeb 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_add.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_add.c
@@ -293,7 +293,7 @@ ldbm_back_add( Slapi_PBlock *pb )
* If the parent is conflict, slapi_sdn_get_backend_parent does not support it.
* That is, adding children to a conflict entry is not allowed.
*/
- slapi_sdn_get_backend_parent(sdn, &parentsdn, pb->pb_backend);
+ slapi_sdn_get_backend_parent(sdn, &parentsdn, be);
/* Check if an entry with the intended DN already exists. */
done_with_pblock_entry(pb,SLAPI_ADD_EXISTING_DN_ENTRY); /* Could be through this
multiple times */
addr.sdn = sdn;
@@ -466,7 +466,7 @@ ldbm_back_add( Slapi_PBlock *pb )
Slapi_DN ancestorsdn;
struct backentry *ancestorentry;
slapi_sdn_init(&ancestorsdn);
- ancestorentry = dn2ancestor(pb->pb_backend, sdn, &ancestorsdn, &txn,
&err, 0);
+ ancestorentry = dn2ancestor(be, sdn, &ancestorsdn, &txn, &err, 0);
slapi_sdn_done(&ancestorsdn);
if ( ancestorentry != NULL )
{
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c
b/ldap/servers/slapd/back-ldbm/ldbm_config.c
index 585f9ef..c8a6801 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c
@@ -2420,17 +2420,17 @@ void ldbm_config_internal_set(struct ldbminfo *li, char *attrname,
char *value)
*/
void replace_ldbm_config_value(char *conftype, char *val, struct ldbminfo *li)
{
- Slapi_PBlock pb = {0};
+ Slapi_PBlock *pb = slapi_pblock_new();
Slapi_Mods smods;
slapi_mods_init(&smods, 1);
slapi_mods_add(&smods, LDAP_MOD_REPLACE, conftype, strlen(val), val);
- slapi_modify_internal_set_pb(&pb, CONFIG_LDBM_DN,
+ slapi_modify_internal_set_pb(pb, CONFIG_LDBM_DN,
slapi_mods_get_ldapmods_byref(&smods),
NULL, NULL, li->li_identity, 0);
- slapi_modify_internal_pb(&pb);
+ slapi_modify_internal_pb(pb);
slapi_mods_done(&smods);
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
}
/* Dispose of an ldbminfo struct for good */
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
index 0b0b37e..65b0cce 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c
@@ -78,6 +78,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
ID ep_id = 0;
ID tomb_ep_id = 0;
int result_sent = 0;
+ Connection *pb_conn;
if (slapi_pblock_get(pb, SLAPI_CONN_ID, &conn_id) < 0) {
conn_id = 0; /* connection is NULL */
@@ -90,6 +91,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
slapi_pblock_get( pb, SLAPI_TXN, (void**)&parent_txn );
slapi_pblock_get( pb, SLAPI_OPERATION, &operation );
slapi_pblock_get( pb, SLAPI_IS_REPLICATED_OPERATION, &is_replicated_operation );
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
slapi_sdn_init(&nscpEntrySDN);
slapi_sdn_init(&parentsdn);
@@ -105,10 +107,10 @@ ldbm_back_delete( Slapi_PBlock *pb )
slapi_pblock_set( pb, SLAPI_TXN, parent_txn );
}
- if (pb->pb_conn)
+ if (pb_conn)
{
slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_delete", "Enter conn=%"
PRIu64 " op=%d\n",
- pb->pb_conn->c_connid, operation->o_opid);
+ pb_conn->c_connid, operation->o_opid);
}
if ((NULL == addr) || (NULL == sdnp))
@@ -457,7 +459,7 @@ ldbm_back_delete( Slapi_PBlock *pb )
* seems to deadlock the database when dblayer_txn_begin is
* called.
*/
- slapi_sdn_get_backend_parent_ext(sdnp, &parentsdn, pb->pb_backend,
is_tombstone_entry);
+ slapi_sdn_get_backend_parent_ext(sdnp, &parentsdn, be, is_tombstone_entry);
if ( !slapi_sdn_isempty(&parentsdn) )
{
struct backentry *parent = NULL;
@@ -1491,10 +1493,10 @@ diskfull_return:
slapi_sdn_done(&nscpEntrySDN);
slapi_ch_free_string(&e_uniqueid);
slapi_sdn_done(&parentsdn);
- if (pb->pb_conn)
+ if (pb_conn)
{
slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_delete", "leave conn=%"
PRIu64 " op=%d\n",
- pb->pb_conn->c_connid, operation->o_opid);
+ pb_conn->c_connid, operation->o_opid);
}
return rc;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
index f7b334d..622ff0b 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_modrdn.c
@@ -96,6 +96,8 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
PRUint64 conn_id;
int op_id;
int result_sent = 0;
+ Connection *pb_conn = NULL;
+
if (slapi_pblock_get(pb, SLAPI_CONN_ID, &conn_id) < 0) {
conn_id = 0; /* connection is NULL */
}
@@ -117,6 +119,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
is_fixup_operation = operation_is_flag_set(operation, OP_FLAG_REPL_FIXUP);
is_resurect_operation = operation_is_flag_set(operation,OP_FLAG_RESURECT_ENTRY);
is_tombstone = operation_is_flag_set(operation,OP_FLAG_TOMBSTONE_ENTRY); /*
tombstone_to_glue on parent entry*/
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
if (NULL == sdn) {
slapi_send_ldap_result( pb, LDAP_INVALID_DN_SYNTAX, NULL,
@@ -140,10 +143,10 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
slapi_pblock_set( pb, SLAPI_TXN, parent_txn );
}
- if (pb->pb_conn)
+ if (pb_conn)
{
slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_modrdn", "enter
conn=%" PRIu64 " op=%d\n",
- pb->pb_conn->c_connid, operation->o_opid);
+ pb_conn->c_connid, operation->o_opid);
}
inst = (ldbm_instance *) be->be_instance_info;
@@ -575,7 +578,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
{
/* If the new entry is not to be a suffix,
* return an error no matter who requested this modrdn */
- if (!slapi_be_issuffix(pb->pb_backend, &dn_newdn))
+ if (!slapi_be_issuffix(be, &dn_newdn))
{
/* Here means that we didn't find the parent */
int err = 0;
@@ -621,7 +624,7 @@ ldbm_back_modrdn( Slapi_PBlock *pb )
if ( parententry == NULL )
{
/* If the entry a suffix, and we're root, then it's OK that the
parent doesn't exist */
- if (!(slapi_be_issuffix(pb->pb_backend, sdn)) && !isroot)
+ if (!(slapi_be_issuffix(be, sdn)) && !isroot)
{
/* Here means that we didn't find the parent */
ldap_result_matcheddn = "NULL";
@@ -1536,11 +1539,11 @@ common_return:
slapi_pblock_set(pb, SLAPI_URP_NAMING_COLLISION_DN,
slapi_ch_strdup(slapi_sdn_get_dn(sdn)));
}
- if (pb->pb_conn)
+ if (pb_conn)
{
slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_modrdn",
"leave conn=%" PRIu64 " op=%d\n",
- pb->pb_conn->c_connid, operation->o_opid);
+ pb_conn->c_connid, operation->o_opid);
}
return retval;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c
b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index 3753d9a..3b3b5b2 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -879,6 +879,8 @@ vlv_bail:
unsigned int opnote;
int ri = 0;
int pr_idx = -1;
+ Connection *pb_conn = NULL;
+ Operation *pb_op = NULL;
/*
* Return error if nsslapd-require-index is set and
@@ -905,7 +907,9 @@ vlv_bail:
slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, NULL );
slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote );
slapi_pblock_get( pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx );
- pagedresults_set_unindexed( pb->pb_conn, pb->pb_op, pr_idx );
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ pagedresults_set_unindexed( pb_conn, pb_op, pr_idx );
}
sr->sr_candidates = candidates;
@@ -1904,7 +1908,9 @@ delete_search_result_set( Slapi_PBlock *pb, back_search_result_set
**sr )
return;
}
if (pb) {
- if (op_is_pagedresults(pb->pb_op)) {
+ Operation *pb_op = NULL;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ if (op_is_pagedresults(pb_op)) {
/* If the op is pagedresults, let the module clean up sr. */
return;
}
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index b2e0305..8637b3e 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -1092,7 +1092,7 @@ ldbm_back_ldbm2ldif( Slapi_PBlock *pb )
char **exclude_suffix = NULL;
char **include_suffix = NULL;
int decrypt = 0;
- int dump_replica = 0;
+ int32_t dump_replica = 0;
int dump_uniqueid = 1;
int fd = STDOUT_FILENO;
IDList *idl = NULL; /* optimization for -s include lists */
@@ -1124,7 +1124,7 @@ ldbm_back_ldbm2ldif( Slapi_PBlock *pb )
slapi_pblock_get( pb, SLAPI_DB2LDIF_SERVER_RUNNING, &server_running );
run_from_cmdline = (task_flags & SLAPI_TASK_RUNNING_FROM_COMMANDLINE);
- dump_replica = pb->pb_ldif_dump_replica;
+ dump_replica = slapi_pblock_get_ldif_dump_replica(pb);
if (run_from_cmdline) {
li->li_flags |= SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
if (!dump_replica) {
diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c
index 00ec40f..4840be2 100644
--- a/ldap/servers/slapd/back-ldbm/vlv.c
+++ b/ldap/servers/slapd/back-ldbm/vlv.c
@@ -1208,10 +1208,17 @@ vlv_search_build_candidate_list(Slapi_PBlock *pb, const Slapi_DN
*base, int *vlv
if((pi=vlv_find_search(be, base, scope, fstr, sort_control)) == NULL) {
unsigned int opnote = SLAPI_OP_NOTE_UNINDEXED;
int pr_idx = -1;
+ Connection *pb_conn = NULL;
+ Operation *pb_op = NULL;
+
slapi_pblock_get( pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx );
slapi_rwlock_unlock(be->vlvSearchList_lock);
slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote );
- pagedresults_set_unindexed( pb->pb_conn, pb->pb_op, pr_idx );
+
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
+ pagedresults_set_unindexed( pb_conn, pb_op, pr_idx );
rc = VLV_FIND_SEARCH_FAILED;
} else if((*vlv_rc=vlvIndex_accessallowed(pi, pb)) != LDAP_SUCCESS) {
slapi_rwlock_unlock(be->vlvSearchList_lock);
diff --git a/ldap/servers/slapd/backend.c b/ldap/servers/slapd/backend.c
index 58dafd4..16edd21 100644
--- a/ldap/servers/slapd/backend.c
+++ b/ldap/servers/slapd/backend.c
@@ -480,7 +480,9 @@ slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void
*ret_fnptr, Slapi
/* this is something needed for most of the entry points */
if (pb)
{
- be->be_database=pb->pb_plugin;
+ struct slapdplugin *pb_plugin = NULL;
+ slapi_pblock_get(pb, SLAPI_PLUGIN, &pb_plugin);
+ be->be_database=pb_plugin;
return 0;
}
diff --git a/ldap/servers/slapd/backend_manager.c b/ldap/servers/slapd/backend_manager.c
index c9b98e2..238dae6 100644
--- a/ldap/servers/slapd/backend_manager.c
+++ b/ldap/servers/slapd/backend_manager.c
@@ -23,7 +23,7 @@ static int defsize = SLAPD_DEFAULT_SIZELIMIT;
static int deftime = SLAPD_DEFAULT_TIMELIMIT;
static int nbackends= 0;
static Slapi_Backend **backends= NULL;
-static int maxbackends= 0;
+static size_t maxbackends = 0;
Slapi_Backend *
slapi_be_new( const char *type, const char *name, int isprivate, int logchanges )
@@ -271,8 +271,7 @@ int strtrimcasecmp(const char *s1, const char *s2)
Slapi_Backend *
slapi_be_select_by_instance_name( const char *name )
{
- int i;
- for ( i = 0; i < maxbackends; i++ )
+ for (size_t i = 0; i < maxbackends; i++ )
{
if ( backends[i] && (backends[i]->be_state != BE_STATE_DELETED) &&
strtrimcasecmp( backends[i]->be_name, name ) == 0)
@@ -286,16 +285,15 @@ slapi_be_select_by_instance_name( const char *name )
void
be_cleanupall()
{
- int i;
- Slapi_PBlock pb = {0};
-
- for ( i = 0; i < maxbackends; i++ )
+ for (size_t i = 0; i < maxbackends; i++ )
{
if (backends[i] && (backends[i]->be_state == BE_STATE_STOPPED ||
backends[i]->be_state == BE_STATE_DELETED)) {
if (backends[i]->be_cleanup != NULL) {
- slapi_pblock_set( &pb, SLAPI_PLUGIN, backends[i]->be_database );
- slapi_pblock_set( &pb, SLAPI_BACKEND, backends[i] );
- (*backends[i]->be_cleanup)( &pb );
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_PLUGIN, backends[i]->be_database );
+ slapi_pblock_set(pb, SLAPI_BACKEND, backends[i] );
+ (*backends[i]->be_cleanup)( pb );
+ slapi_pblock_destroy(pb);
}
slapi_be_free(&backends[i]);
}
@@ -312,24 +310,18 @@ be_cleanupall()
*/
void
be_flushall()
-#if defined(__has_feature)
-# if __has_feature(address_sanitizer) && __GNUC__ == 6
-__attribute__((no_sanitize("address")))
-# endif
-#endif
{
- int i;
- Slapi_PBlock pb = {0};
-
- for ( i = 0; i < maxbackends; i++ )
+ for (size_t i = 0; i < maxbackends; i++ )
{
if ( backends[i] &&
backends[i]->be_state == BE_STATE_STARTED &&
backends[i]->be_flush != NULL )
{
- slapi_pblock_set( &pb, SLAPI_PLUGIN, backends[i]->be_database );
- slapi_pblock_set( &pb, SLAPI_BACKEND, backends[i] );
- (*backends[i]->be_flush)( &pb );
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_PLUGIN, backends[i]->be_database );
+ slapi_pblock_set(pb, SLAPI_BACKEND, backends[i] );
+ (*backends[i]->be_flush)( pb );
+ slapi_pblock_destroy(pb);
}
}
}
@@ -337,30 +329,34 @@ __attribute__((no_sanitize("address")))
void
be_unbindall(Connection *conn, Operation *op)
{
- int i;
- Slapi_PBlock pb = {0};
-
- for ( i = 0; i < maxbackends; i++ )
+ for (size_t i = 0; i < maxbackends; i++ )
{
if ( backends[i] && (backends[i]->be_unbind != NULL) )
{
/* This is the modern, and faster way to do pb memset(0)
* It also doesn't trigger the HORRIBLE stack overflows I found ...
*/
- pblock_init_common( &pb, backends[i], conn, op );
+ Slapi_PBlock *pb = slapi_pblock_new();
+ pblock_init_common( pb, backends[i], conn, op );
- if ( plugin_call_plugins( &pb, SLAPI_PLUGIN_PRE_UNBIND_FN ) == 0 )
+ if ( plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_UNBIND_FN ) == 0 )
{
int rc = 0;
- slapi_pblock_set( &pb, SLAPI_PLUGIN, backends[i]->be_database );
- if(backends[i]->be_state != BE_STATE_DELETED &&
- backends[i]->be_unbind!=NULL)
+ slapi_pblock_set( pb, SLAPI_PLUGIN, backends[i]->be_database );
+ if(backends[i]->be_state != BE_STATE_DELETED &&
backends[i]->be_unbind!=NULL)
{
- rc = (*backends[i]->be_unbind)( &pb );
+ rc = (*backends[i]->be_unbind)( pb );
}
- slapi_pblock_set( &pb, SLAPI_PLUGIN_OPRETURN, &rc );
- (void) plugin_call_plugins( &pb, SLAPI_PLUGIN_POST_UNBIND_FN );
+ slapi_pblock_set( pb, SLAPI_PLUGIN_OPRETURN, &rc );
+ (void) plugin_call_plugins( pb, SLAPI_PLUGIN_POST_UNBIND_FN );
}
+ /*
+ * pblock_destroy implicitly frees operation, so we need to NULL it, else
+ * we cause a use-after-free.
+ */
+ slapi_pblock_set(pb, SLAPI_OPERATION, NULL);
+
+ slapi_pblock_destroy(pb);
}
}
}
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index 648a0f9..41e112e 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -53,7 +53,13 @@ static void log_bind_access(
void
do_bind( Slapi_PBlock *pb )
{
- BerElement *ber = pb->pb_op->o_ber;
+ Operation *pb_op = NULL;
+ Connection *pb_conn = NULL;
+
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
+ BerElement *ber = pb_op->o_ber;
int err, isroot;
ber_tag_t method = LBER_DEFAULT;
ber_int_t version = -1;
@@ -135,7 +141,7 @@ do_bind( Slapi_PBlock *pb )
dn?dn:"empty", method, version );
/* target spec is used to decide which plugins are applicable for the operation */
- operation_set_target_spec (pb->pb_op, sdn);
+ operation_set_target_spec (pb_op, sdn);
switch ( method ) {
case LDAP_AUTH_SASL:
@@ -222,9 +228,9 @@ do_bind( Slapi_PBlock *pb )
slapi_pblock_get (pb, SLAPI_PWPOLICY, &pw_response_requested);
}
- PR_EnterMonitor(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb_conn->c_mutex);
- bind_credentials_clear( pb->pb_conn, PR_FALSE, /* do not lock conn */
+ bind_credentials_clear( pb_conn, PR_FALSE, /* do not lock conn */
PR_FALSE /* do not clear external creds. */ );
#if defined(ENABLE_AUTOBIND)
@@ -236,13 +242,13 @@ do_bind( Slapi_PBlock *pb )
*/
if((LDAP_AUTH_SASL == method) &&
(0 == strcasecmp (saslmech, LDAP_SASL_EXTERNAL)) &&
- (0 == dn || 0 == dn[0]) && pb->pb_conn->c_unix_local)
+ (0 == dn || 0 == dn[0]) && pb_conn->c_unix_local)
{
- slapd_bind_local_user(pb->pb_conn);
- if(pb->pb_conn->c_dn)
+ slapd_bind_local_user(pb_conn);
+ if(pb_conn->c_dn)
{
auto_bind = 1; /* flag the bind method */
- dn = slapi_ch_strdup(pb->pb_conn->c_dn);
+ dn = slapi_ch_strdup(pb_conn->c_dn);
slapi_sdn_free(&sdn);
sdn = slapi_sdn_new_dn_passin(dn);
}
@@ -254,8 +260,8 @@ do_bind( Slapi_PBlock *pb )
* With a new bind, the flag should be reset so that the new
* bound user can work properly
*/
- pb->pb_conn->c_needpw = 0;
- PR_ExitMonitor(pb->pb_conn->c_mutex);
+ pb_conn->c_needpw = 0;
+ PR_ExitMonitor(pb_conn->c_mutex);
log_bind_access(pb, dn?dn:"empty", method, version, saslmech, NULL);
@@ -264,7 +270,7 @@ do_bind( Slapi_PBlock *pb )
if (method == LDAP_AUTH_SIMPLE
&& (config_get_force_sasl_external() ||
((dn == NULL || *dn == '\0') && cred.bv_len == 0))
- && pb->pb_conn->c_external_dn != NULL) {
+ && pb_conn->c_external_dn != NULL) {
/* Treat this like a SASL EXTERNAL Bind: */
method = LDAP_AUTH_SASL;
saslmech = slapi_ch_strdup (LDAP_SASL_EXTERNAL);
@@ -277,7 +283,7 @@ do_bind( Slapi_PBlock *pb )
case LDAP_VERSION3:
if ((method == LDAP_AUTH_SIMPLE) &&
config_get_force_sasl_external() &&
- (pb->pb_conn->c_external_dn != NULL)) {
+ (pb_conn->c_external_dn != NULL)) {
/* Treat this like a SASL EXTERNAL Bind: */
method = LDAP_AUTH_SASL;
saslmech = slapi_ch_strdup (LDAP_SASL_EXTERNAL);
@@ -296,7 +302,7 @@ do_bind( Slapi_PBlock *pb )
slapi_log_err(SLAPI_LOG_TRACE, "do_bind", "version %d method %lu dn
%s\n",
version, method, dn );
- pb->pb_conn->c_ldapversion = version;
+ pb_conn->c_ldapversion = version;
isroot = slapi_dn_isroot( slapi_sdn_get_ndn(sdn) );
slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &isroot );
@@ -311,7 +317,7 @@ do_bind( Slapi_PBlock *pb )
* RFC2251: client may abort a sasl bind negotiation by sending
* an authentication choice other than sasl.
*/
- pb->pb_conn->c_flags &= ~CONN_FLAG_SASL_CONTINUE;
+ pb_conn->c_flags &= ~CONN_FLAG_SASL_CONTINUE;
}
switch ( method ) {
@@ -376,7 +382,7 @@ do_bind( Slapi_PBlock *pb )
* if this is not an SSL connection, fail and return an
* inappropriateAuth error.
*/
- if ( 0 == ( pb->pb_conn->c_flags & CONN_FLAG_SSL )) {
+ if ( 0 == ( pb_conn->c_flags & CONN_FLAG_SSL )) {
send_ldap_result( pb, LDAP_INAPPROPRIATE_AUTH, NULL,
"SASL EXTERNAL bind requires an SSL
connection",
0, NULL );
@@ -388,7 +394,7 @@ do_bind( Slapi_PBlock *pb )
/*
* Check for the client certificate.
*/
- if( NULL == pb->pb_conn->c_client_cert){
+ if( NULL == pb_conn->c_client_cert){
send_ldap_result( pb, LDAP_INAPPROPRIATE_AUTH, NULL,
"missing client certificate", 0, NULL );
/* call postop plugins */
@@ -400,7 +406,7 @@ do_bind( Slapi_PBlock *pb )
* if the client sent us a certificate but we could not map it
* to an LDAP DN, fail and return an invalidCredentials error.
*/
- if ( NULL == pb->pb_conn->c_external_dn ) {
+ if ( NULL == pb_conn->c_external_dn ) {
slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, "Client certificate
mapping failed");
send_ldap_result(pb, LDAP_INVALID_CREDENTIALS, NULL, "", 0,
NULL);
/* call postop plugins */
@@ -410,7 +416,7 @@ do_bind( Slapi_PBlock *pb )
if (!isroot) {
/* check if the account is locked */
- bind_target_entry = get_entry(pb, pb->pb_conn->c_external_dn);
+ bind_target_entry = get_entry(pb, pb_conn->c_external_dn);
if ( bind_target_entry && slapi_check_account_lock(pb,
bind_target_entry,
pw_response_requested, 1 /*check password policy*/, 1 /*send ldap
result*/) == 1) {
/* call postop plugins */
@@ -422,12 +428,12 @@ do_bind( Slapi_PBlock *pb )
/*
* copy external credentials into connection structure
*/
- bind_credentials_set( pb->pb_conn,
- pb->pb_conn->c_external_authtype,
- pb->pb_conn->c_external_dn,
+ bind_credentials_set( pb_conn,
+ pb_conn->c_external_authtype,
+ pb_conn->c_external_dn,
NULL, NULL, NULL , NULL);
if ( auth_response_requested ) {
- slapi_add_auth_response_control( pb, pb->pb_conn->c_external_dn );
+ slapi_add_auth_response_control( pb, pb_conn->c_external_dn );
}
send_ldap_result( pb, LDAP_SUCCESS, NULL, NULL, 0, NULL );
/* call postop plugins */
@@ -447,9 +453,9 @@ do_bind( Slapi_PBlock *pb )
* there.
*/
minssf_exclude_rootdse = config_get_minssf_exclude_rootdse();
- if (!minssf_exclude_rootdse && (pb->pb_conn->c_sasl_ssf <
minssf) &&
- (pb->pb_conn->c_ssl_ssf < minssf) &&
- (pb->pb_conn->c_local_ssf < minssf)) {
+ if (!minssf_exclude_rootdse && (pb_conn->c_sasl_ssf < minssf)
&&
+ (pb_conn->c_ssl_ssf < minssf) &&
+ (pb_conn->c_local_ssf < minssf)) {
send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL,
"Minimum SSF not met.", 0, NULL);
/* increment BindSecurityErrorcount */
@@ -475,7 +481,7 @@ do_bind( Slapi_PBlock *pb )
}
/* set the bind credentials so anonymous limits are set */
- bind_credentials_set( pb->pb_conn, SLAPD_AUTH_NONE,
+ bind_credentials_set( pb_conn, SLAPD_AUTH_NONE,
NULL, NULL, NULL, NULL , NULL);
/* call preop plugins */
@@ -525,7 +531,7 @@ do_bind( Slapi_PBlock *pb )
/* Allow simple binds only for SSL/TLS established connections
* or connections using SASL privacy layers */
- conn = pb->pb_conn;
+ conn = pb_conn;
if ( slapi_pblock_get(pb, SLAPI_CONN_SASL_SSF, &sasl_ssf) != 0) {
slapi_log_err(SLAPI_LOG_PLUGIN, "do_bind",
"Could not get SASL SSF from connection\n" );
@@ -583,7 +589,7 @@ do_bind( Slapi_PBlock *pb )
/*
* right dn and passwd - authorize
*/
- bind_credentials_set( pb->pb_conn, SLAPD_AUTH_SIMPLE,
slapi_ch_strdup(slapi_sdn_get_ndn(sdn)),
+ bind_credentials_set( pb_conn, SLAPD_AUTH_SIMPLE,
slapi_ch_strdup(slapi_sdn_get_ndn(sdn)),
NULL, NULL, NULL , NULL);
} else {
/*
@@ -626,7 +632,7 @@ do_bind( Slapi_PBlock *pb )
rc = 0;
/* Check if a pre_bind plugin mapped the DN to another backend */
- Slapi_DN *target_spec_sdn = operation_get_target_spec(pb->pb_op);
+ Slapi_DN *target_spec_sdn = operation_get_target_spec(pb_op);
Slapi_DN *pb_sdn;
slapi_pblock_get(pb, SLAPI_BIND_TARGET_SDN, &pb_sdn);
if (!pb_sdn) {
@@ -651,7 +657,7 @@ do_bind( Slapi_PBlock *pb )
* It's really important that when we start to rethink pblock, that we kill
this with fire.
*/
slapi_sdn_free(&target_spec_sdn);
- operation_set_target_spec(pb->pb_op, pb_sdn);
+ operation_set_target_spec(pb_op, pb_sdn);
/* We could be serving multiple database backends. Select the appropriate one
*/
/* pw_verify_be_dn will select the backend we need for us. */
@@ -745,7 +751,7 @@ do_bind( Slapi_PBlock *pb )
goto free_and_return;
}
}
- bind_credentials_set(pb->pb_conn, authtype,
+ bind_credentials_set(pb_conn, authtype,
slapi_ch_strdup(slapi_sdn_get_ndn(sdn)),
NULL, NULL, NULL, bind_target_entry);
if (!slapi_be_is_flag_set(be, SLAPI_BE_FLAG_REMOTE_DATA)) {
@@ -773,7 +779,7 @@ do_bind( Slapi_PBlock *pb )
}
} else { /* anonymous */
/* set bind creds here so anonymous limits are set */
- bind_credentials_set(pb->pb_conn, authtype, NULL, NULL, NULL, NULL,
NULL);
+ bind_credentials_set(pb_conn, authtype, NULL, NULL, NULL, NULL, NULL);
if ( auth_response_requested ) {
slapi_add_auth_response_control(pb, "");
@@ -851,29 +857,34 @@ log_bind_access (
const char *msg
)
{
+ Operation *pb_op = NULL;
+ Connection *pb_conn = NULL;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
if (method == LDAP_AUTH_SASL && saslmech && msg) {
slapi_log_access( LDAP_DEBUG_STATS,
"conn=%" PRIu64 " op=%d BIND dn=\"%s\"
"
"method=sasl version=%d mech=%s, %s\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid, dn,
+ pb_conn->c_connid, pb_op->o_opid, dn,
version, saslmech, msg );
} else if (method == LDAP_AUTH_SASL && saslmech) {
slapi_log_access( LDAP_DEBUG_STATS,
"conn=%" PRIu64 " op=%d BIND dn=\"%s\"
"
"method=sasl version=%d mech=%s\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid, dn,
+ pb_conn->c_connid, pb_op->o_opid, dn,
version, saslmech );
} else if (msg) {
slapi_log_access( LDAP_DEBUG_STATS,
"conn=%" PRIu64 " op=%d BIND dn=\"%s\"
"
"method=%" BERTAG_T " version=%d, %s\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid, dn,
+ pb_conn->c_connid, pb_op->o_opid, dn,
method, version, msg );
} else {
slapi_log_access( LDAP_DEBUG_STATS,
"conn=%" PRIu64 " op=%d BIND dn=\"%s\"
"
"method=%" BERTAG_T " version=%d\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid, dn,
+ pb_conn->c_connid, pb_op->o_opid, dn,
method, version );
}
}
diff --git a/ldap/servers/slapd/compare.c b/ldap/servers/slapd/compare.c
index 3c03053..d66bf3b 100644
--- a/ldap/servers/slapd/compare.c
+++ b/ldap/servers/slapd/compare.c
@@ -33,7 +33,12 @@
void
do_compare( Slapi_PBlock *pb )
{
- BerElement *ber = pb->pb_op->o_ber;
+ Operation *pb_op = NULL;
+ Connection *pb_conn = NULL;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
+ BerElement *ber = pb_op->o_ber;
char *rawdn = NULL;
const char *dn = NULL;
struct ava ava = {0};
@@ -105,14 +110,14 @@ do_compare( Slapi_PBlock *pb )
}
/* target spec is used to decide which plugins are applicable for the operation */
- operation_set_target_spec (pb->pb_op, &sdn);
+ operation_set_target_spec (pb_op, &sdn);
slapi_log_err(SLAPI_LOG_ARGS, "do_compare: dn (%s) attr (%s)\n",
rawdn, ava.ava_type, 0 );
slapi_log_access( LDAP_DEBUG_STATS,
"conn=%" PRIu64 " op=%d CMP dn=\"%s\"
attr=\"%s\"\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid, dn, ava.ava_type );
+ pb_conn->c_connid, pb_op->o_opid, dn, ava.ava_type );
/*
* We could be serving multiple database backends. Select the
@@ -146,7 +151,7 @@ do_compare( Slapi_PBlock *pb )
int isroot;
slapi_pblock_set( pb, SLAPI_BACKEND, be );
- isroot = pb->pb_op->o_isroot;
+ isroot = pb_op->o_isroot;
slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &isroot );
/* EXCEPTION: compare target does not allocate memory. */
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index f1daad7..3b2f6d5 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -482,7 +482,7 @@ referral_mode_reply(Slapi_PBlock *pb)
struct berval *urls[2], url;
char *refer;
refer = config_get_referral_mode();
- pb->pb_plugin = plugin;
+ slapi_pblock_set(pb, SLAPI_PLUGIN, plugin);
set_db_default_result_handlers(pb);
urls[0] = &url;
urls[1] = NULL;
@@ -512,7 +512,7 @@ connection_need_new_password(const Connection *conn, const Operation
*op, Slapi_
{
slapi_add_pwd_control ( pb, LDAP_CONTROL_PWEXPIRED, 0);
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d %s\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid,
+ conn->c_connid, op->o_opid,
"UNPROCESSED OPERATION - need new password" );
send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM,
NULL, NULL, 0, NULL );
@@ -941,7 +941,7 @@ connection_free_private_buffer(Connection *conn)
#define CONN_TURBO_PERCENTILE 50 /* proportion of threads allowed to be in turbo mode */
#define CONN_TURBO_HYSTERESIS 0 /* avoid flip flopping in and out of turbo mode */
-void connection_make_new_pb(Slapi_PBlock *pb, Connection *conn)
+void connection_make_new_pb(Slapi_PBlock *pb, Connection *conn)
{
struct Slapi_op_stack *stack_obj = NULL;
/* we used to malloc/free the pb for each operation - now, just use a local stack pb
@@ -949,11 +949,11 @@ void connection_make_new_pb(Slapi_PBlock *pb, Connection *conn)
*/
/* *ppb = (Slapi_PBlock *) slapi_ch_calloc( 1, sizeof(Slapi_PBlock) ); */
/* *ppb = slapi_pblock_new(); */
- pb->pb_conn = conn;
+ slapi_pblock_set(pb, SLAPI_CONNECTION, conn);
stack_obj = connection_get_operation();
- pb->pb_op = stack_obj->op;
- pb->op_stack_elem = stack_obj;
- connection_add_operation( conn, pb->pb_op );
+ slapi_pblock_set(pb, SLAPI_OPERATION, stack_obj->op);
+ slapi_pblock_set_op_stack_elem(pb, stack_obj);
+ connection_add_operation( conn, stack_obj->op );
}
int connection_wait_for_new_work(Slapi_PBlock *pb, PRIntervalTime interval)
@@ -977,9 +977,9 @@ int connection_wait_for_new_work(Slapi_PBlock *pb, PRIntervalTime
interval)
ret = CONN_NOWORK;
} else {
/* make new pb */
- pb->pb_conn = (Connection *)wqitem;
- pb->op_stack_elem = op_stack_obj;
- pb->pb_op = op_stack_obj->op;
+ slapi_pblock_set(pb, SLAPI_CONNECTION, wqitem);
+ slapi_pblock_set_op_stack_elem(pb, op_stack_obj);
+ slapi_pblock_set(pb, SLAPI_OPERATION, op_stack_obj->op);
}
PR_Unlock( work_q_lock );
@@ -1491,8 +1491,7 @@ void connection_enter_leave_turbo(Connection *conn, int
current_turbo_flag, int
static void
connection_threadmain()
{
- Slapi_PBlock local_pb;
- Slapi_PBlock *pb = &local_pb;
+ Slapi_PBlock *pb = slapi_pblock_new();
/* wait forever for new pb until one is available or shutdown */
PRIntervalTime interval = PR_INTERVAL_NO_TIMEOUT; /* PR_SecondsToInterval(10); */
Connection *conn = NULL;
@@ -1507,6 +1506,8 @@ connection_threadmain()
int maxthreads = 0;
int enable_nunc_stans = 0;
long bypasspollcnt = 0;
+ Connection *pb_conn = NULL;
+ Operation *pb_op = NULL;
#ifdef ENABLE_NUNC_STANS
enable_nunc_stans = config_get_enable_nunc_stans();
@@ -1516,7 +1517,6 @@ connection_threadmain()
SIGNAL( SIGPIPE, SIG_IGN );
#endif
- pblock_init(pb);
while (1) {
int is_timedout = 0;
time_t curtime = 0;
@@ -1534,6 +1534,13 @@ connection_threadmain()
done sending the request and wait for the response forever.
[blackflag 624234] */
ret = connection_wait_for_new_work(pb,interval);
+
+ /*
+ * Connection wait for new work provides the conn and op for us.
+ */
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+
switch (ret) {
case CONN_NOWORK:
PR_ASSERT(interval != PR_INTERVAL_NO_TIMEOUT); /* this should never happen with
PR_INTERVAL_NO_TIMEOUT */
@@ -1549,7 +1556,7 @@ connection_threadmain()
in connection_activity when the conn is added to the
work queue, setup_pr_read_pds won't add the connection prfd
to the poll list */
- if(pb->pb_conn->c_opscompleted == 0){
+ if(pb_conn->c_opscompleted == 0){
/*
* We have a new connection, set the anonymous reslimit idletimeout
* if applicable.
@@ -1559,19 +1566,19 @@ connection_threadmain()
/* If an anonymous limits dn is set, use it to set the limits. */
if (anon_dn && (strlen(anon_dn) > 0)) {
Slapi_DN *anon_sdn = slapi_sdn_new_normdn_byref( anon_dn );
- reslimit_update_from_dn( pb->pb_conn, anon_sdn );
+ reslimit_update_from_dn( pb_conn, anon_sdn );
slapi_sdn_free( &anon_sdn );
- if (slapi_reslimit_get_integer_limit(pb->pb_conn,
- pb->pb_conn->c_idletimeout_handle,
+ if (slapi_reslimit_get_integer_limit(pb_conn,
+ pb_conn->c_idletimeout_handle,
&idletimeout)
== SLAPI_RESLIMIT_STATUS_SUCCESS)
{
- pb->pb_conn->c_idletimeout = idletimeout;
+ pb_conn->c_idletimeout = idletimeout;
}
}
slapi_ch_free_string( &anon_dn );
}
- if (connection_call_io_layer_callbacks(pb->pb_conn)) {
+ if (connection_call_io_layer_callbacks(pb_conn)) {
slapi_log_err(SLAPI_LOG_ERR, "connection_threadmain",
"Could not add/remove IO layers from connection\n");
}
@@ -1587,7 +1594,7 @@ connection_threadmain()
PR_EnterMonitor(conn->c_mutex);
/* Make our own pb in turbo mode */
- connection_make_new_pb(pb,conn);
+ connection_make_new_pb(pb, conn);
if (connection_call_io_layer_callbacks(conn)) {
slapi_log_err(SLAPI_LOG_ERR, "connection_threadmain",
"Could not add/remove IO layers from connection\n" );
@@ -1599,8 +1606,8 @@ connection_threadmain()
}
}
/* Once we're here we have a pb */
- conn = pb->pb_conn;
- op = pb->pb_op;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);
+ slapi_pblock_get(pb, SLAPI_OPERATION, &op);
maxthreads = config_get_maxthreadsperconn();
more_data = 0;
ret = connection_read_operation(conn, op, &tag, &more_data);
@@ -1771,6 +1778,7 @@ done:
connection_release_nolock(conn);
PR_ExitMonitor(conn->c_mutex);
signal_listner();
+ slapi_pblock_destroy(pb);
return;
}
/*
@@ -1785,7 +1793,7 @@ done:
/* total number of ops for the server */
slapi_counter_increment(ops_completed);
/* If this op isn't a persistent search, remove it */
- if ( pb->pb_op->o_flags & OP_FLAG_PS ) {
+ if ( pb_op->o_flags & OP_FLAG_PS ) {
PR_EnterMonitor(conn->c_mutex);
connection_release_nolock (conn); /* psearch acquires ref to conn - release this
one now */
PR_ExitMonitor(conn->c_mutex);
@@ -1793,7 +1801,7 @@ done:
* can't free it or init it here - just memset it to 0
* ps_send_results will call connection_remove_operation_ext to free it
*/
- memset(pb, 0, sizeof(*pb));
+ slapi_pblock_init(pb);
} else {
/* delete from connection operation queue & decr refcnt */
int conn_closed = 0;
@@ -1816,10 +1824,11 @@ done:
need_wakeup = 1;
}
if (!need_wakeup) {
- if (conn->c_threadnumber == maxthreads)
+ if (conn->c_threadnumber == maxthreads) {
need_wakeup = 1;
- else
+ } else {
need_wakeup = 0;
+ }
}
if(conn->c_threadnumber == maxthreads){
@@ -2048,8 +2057,9 @@ void
connection_remove_operation_ext( Slapi_PBlock *pb, Connection *conn, Operation *op )
{
connection_remove_operation(conn, op);
- connection_done_operation(conn, pb->op_stack_elem);
- pb->pb_op = NULL;
+ void *op_stack_elem = slapi_pblock_get_op_stack_elem(pb);
+ connection_done_operation(conn, op_stack_elem);
+ slapi_pblock_set(pb, SLAPI_OPERATION, NULL);
slapi_pblock_init(pb);
}
diff --git a/ldap/servers/slapd/control.c b/ldap/servers/slapd/control.c
index 1b31c9c..981dca1 100644
--- a/ldap/servers/slapd/control.c
+++ b/ldap/servers/slapd/control.c
@@ -181,6 +181,7 @@ get_ldapmessage_controls_ext(
int rc, maxcontrols, curcontrols;
char *last;
int managedsait, pwpolicy_ctrl;
+ Connection *pb_conn = NULL;
/*
* Each LDAPMessage can have a set of controls appended
@@ -244,11 +245,12 @@ get_ldapmessage_controls_ext(
* A sequence of controls is present. If connection is not LDAPv3
* or better, return a protocol error. Otherwise, parse the controls.
*/
- if ( pb->pb_conn != NULL
- && pb->pb_conn->c_ldapversion < LDAP_VERSION3 ) {
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
+ if ( pb_conn != NULL && pb_conn->c_ldapversion < LDAP_VERSION3 ) {
slapi_log_err(SLAPI_LOG_ERR, "get_ldapmessage_controls_ext",
"Received control(s) on an LDAPv%d connection\n",
- pb->pb_conn->c_ldapversion );
+ pb_conn->c_ldapversion );
return( LDAP_PROTOCOL_ERROR );
}
@@ -305,10 +307,13 @@ get_ldapmessage_controls_ext(
}
}
+ Operation *pb_op = NULL;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+
if ( supported_controls == NULL ||
supported_controls[i] == NULL ||
( 0 == ( supported_controls_ops[i] &
- operation_get_type(pb->pb_op) ))) {
+ operation_get_type(pb_op) ))) {
rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
slapi_rwlock_unlock(supported_controls_lock);
goto free_and_return;
@@ -331,12 +336,14 @@ get_ldapmessage_controls_ext(
if (curcontrols == 0) {
int ctrl_not_found = 0; /* means that a given control is not present in
the request */
+ Operation *pb_op = NULL;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
slapi_pblock_set(pb, SLAPI_REQCONTROLS, NULL);
slapi_pblock_set(pb, SLAPI_MANAGEDSAIT, &ctrl_not_found);
slapi_pblock_set(pb, SLAPI_PWPOLICY, &ctrl_not_found);
slapi_log_err(SLAPI_LOG_CONNS, "get_ldapmessage_controls_ext",
"Warning: conn=%" PRIu64 " op=%d contains an empty list of
controls\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid);
+ pb_conn->c_connid, pb_op->o_opid);
} else {
/* len, ber_len_t is uint, not int, cannot be != -1, may be better to
remove this check. */
if ((tag != LBER_END_OF_SEQORSET) && (len != -1)) {
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 6730857..866eac0 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -831,20 +831,19 @@ convert_pbe_des_to_aes(void)
for (i = 0; attrs && attrs[i]; i++){
char *filter = PR_smprintf("%s=*", attrs[i]);
- Slapi_PBlock pb = {0};
- slapi_search_internal_set_pb(&pb, "cn=config",
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_search_internal_set_pb(pb, "cn=config",
LDAP_SCOPE_SUBTREE, filter, NULL, 0, NULL, NULL,
(void *)plugin_get_default_component_id(),
SLAPI_OP_FLAG_IGNORE_UNINDEXED);
- slapi_search_internal_pb(&pb);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
+ slapi_search_internal_pb(pb);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
for (ii = 0; entries && entries[ii]; ii++){
if((val = slapi_entry_attr_get_charptr(entries[ii], attrs[i]))){
if(strlen(val) >= 5 && strncmp(val,"{DES}", 5)
== 0){
/*
* We have a DES encoded password, convert it to AES
*/
- Slapi_PBlock mod_pb = {0};
Slapi_Value *sval = NULL;
LDAPMod mod_replace;
LDAPMod *mods[2];
@@ -872,6 +871,7 @@ convert_pbe_des_to_aes(void)
}
if (rc == 0){
+ Slapi_PBlock *mod_pb = slapi_pblock_new();
/* replace the attribute in the entry */
replace_val[0] = (char *)slapi_value_get_string(sval);
replace_val[1] = NULL;
@@ -881,11 +881,12 @@ convert_pbe_des_to_aes(void)
mods[0] = &mod_replace;
mods[1] = 0;
- slapi_modify_internal_set_pb(&mod_pb,
slapi_entry_get_dn(entries[ii]),
+ slapi_modify_internal_set_pb(mod_pb,
slapi_entry_get_dn(entries[ii]),
mods, 0, 0, (void
*)plugin_get_default_component_id(), 0);
- slapi_modify_internal_pb(&mod_pb);
+ slapi_modify_internal_pb(mod_pb);
- slapi_pblock_get(&mod_pb, SLAPI_PLUGIN_INTOP_RESULT,
&result);
+ slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT,
&result);
+ slapi_pblock_destroy(mod_pb);
if (LDAP_SUCCESS != result) {
slapi_log_err(SLAPI_LOG_ERR,
"convert_pbe_des_to_aes",
"Failed to convert password for (%s) error
(%d)\n",
@@ -899,13 +900,12 @@ convert_pbe_des_to_aes(void)
}
slapi_ch_free_string(&passwd);
slapi_value_free(&sval);
- pblock_done(&mod_pb);
}
slapi_ch_free_string(&val);
}
}
- slapi_free_search_results_internal(&pb);
- pblock_done(&pb);
+ slapi_free_search_results_internal(pb);
+ slapi_pblock_destroy(pb);
slapi_ch_free_string(&filter);
}
if (!converted_des_passwd){
diff --git a/ldap/servers/slapd/defbackend.c b/ldap/servers/slapd/defbackend.c
index ee665b1..57290ee 100644
--- a/ldap/servers/slapd/defbackend.c
+++ b/ldap/servers/slapd/defbackend.c
@@ -56,9 +56,9 @@ static int defbackend_next_search_entry( Slapi_PBlock *pb );
void
defbackend_init( void )
{
- int rc;
- char *errmsg;
- Slapi_PBlock pb = {0};
+ int rc;
+ char *errmsg;
+ Slapi_PBlock *pb = slapi_pblock_new();
slapi_log_err(SLAPI_LOG_TRACE, "defbackend_init", "<==\n");
@@ -66,7 +66,7 @@ defbackend_init( void )
* create a new backend
*/
defbackend_backend = slapi_be_new( DEFBACKEND_TYPE , DEFBACKEND_TYPE, 1 /* Private
*/, 0 /* Do Not Log Changes */ );
- if (( rc = slapi_pblock_set( &pb, SLAPI_BACKEND, defbackend_backend )) != 0 ) {
+ if (( rc = slapi_pblock_set( pb, SLAPI_BACKEND, defbackend_backend )) != 0 ) {
errmsg = "slapi_pblock_set SLAPI_BACKEND failed";
goto cleanup_and_return;
}
@@ -77,7 +77,7 @@ defbackend_init( void )
*/
defbackend_plugin.plg_type = SLAPI_PLUGIN_DATABASE;
defbackend_backend->be_database = &defbackend_plugin;
- if (( rc = slapi_pblock_set( &pb, SLAPI_PLUGIN, &defbackend_plugin )) != 0 )
{
+ if (( rc = slapi_pblock_set( pb, SLAPI_PLUGIN, &defbackend_plugin )) != 0 ) {
errmsg = "slapi_pblock_set SLAPI_PLUGIN failed";
goto cleanup_and_return;
}
@@ -90,33 +90,35 @@ defbackend_init( void )
* install handler functions, etc.
*/
errmsg = "slapi_pblock_set handlers failed";
- rc = slapi_pblock_set( &pb, SLAPI_PLUGIN_VERSION,
+ rc = slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
(void *)SLAPI_PLUGIN_CURRENT_VERSION );
- rc |= slapi_pblock_set( &pb, SLAPI_PLUGIN_DB_BIND_FN,
+ rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_BIND_FN,
(void *)defbackend_bind );
- rc |= slapi_pblock_set( &pb, SLAPI_PLUGIN_DB_UNBIND_FN,
+ rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_UNBIND_FN,
(void *)defbackend_noop );
- rc |= slapi_pblock_set( &pb, SLAPI_PLUGIN_DB_SEARCH_FN,
+ rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_SEARCH_FN,
(void *)defbackend_default );
- rc |= slapi_pblock_set( &pb, SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN,
+ rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN,
(void *)defbackend_next_search_entry );
- rc |= slapi_pblock_set( &pb, SLAPI_PLUGIN_DB_COMPARE_FN,
+ rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_COMPARE_FN,
(void *)defbackend_default );
- rc |= slapi_pblock_set( &pb, SLAPI_PLUGIN_DB_MODIFY_FN,
+ rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_MODIFY_FN,
(void *)defbackend_default );
- rc |= slapi_pblock_set( &pb, SLAPI_PLUGIN_DB_MODRDN_FN,
+ rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_MODRDN_FN,
(void *)defbackend_default );
- rc |= slapi_pblock_set( &pb, SLAPI_PLUGIN_DB_ADD_FN,
+ rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_ADD_FN,
(void *)defbackend_default );
- rc |= slapi_pblock_set( &pb, SLAPI_PLUGIN_DB_DELETE_FN,
+ rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_DELETE_FN,
(void *)defbackend_default );
- rc |= slapi_pblock_set( &pb, SLAPI_PLUGIN_DB_ABANDON_FN,
+ rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_ABANDON_FN,
(void *)defbackend_abandon );
cleanup_and_return:
+
+ slapi_pblock_destroy(pb);
if ( rc != 0 ) {
- slapi_log_err(SLAPI_LOG_ERR, "defbackend_init", "Failed (%s)\n",
errmsg);
- exit( 1 );
+ slapi_log_err(SLAPI_LOG_ERR, "defbackend_init", "Failed
(%s)\n", errmsg);
+ exit( 1 );
}
}
diff --git a/ldap/servers/slapd/delete.c b/ldap/servers/slapd/delete.c
index f8d6a5e..fbcca6a 100644
--- a/ldap/servers/slapd/delete.c
+++ b/ldap/servers/slapd/delete.c
@@ -57,7 +57,7 @@ do_delete( Slapi_PBlock *pb )
* DelRequest := DistinguishedName
*/
- if ( ber_scanf( pb->pb_op->o_ber, "a", &rawdn ) == LBER_ERROR ) {
+ if ( ber_scanf( operation->o_ber, "a", &rawdn ) == LBER_ERROR ) {
slapi_log_err(SLAPI_LOG_ERR,
"do_delete", "ber_scanf failed (op=Delete; params=DN)\n");
op_shared_log_error_access (pb, "DEL", "???", "decoding
error");
@@ -91,7 +91,7 @@ do_delete( Slapi_PBlock *pb )
slapi_log_err(SLAPI_LOG_ARGS, "do_delete", "dn (%s)\n", rawdn );
- slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &pb->pb_op->o_isroot );
+ slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &(operation->o_isroot) );
slapi_pblock_set( pb, SLAPI_ORIGINAL_TARGET, rawdn);
op_shared_delete (pb);
@@ -107,21 +107,21 @@ free_and_return:;
Slapi_PBlock *
slapi_delete_internal(const char *idn, LDAPControl **controls, int dummy
__attribute__((unused)))
{
- Slapi_PBlock pb = {0};
+ Slapi_PBlock *pb = slapi_pblock_new();
Slapi_PBlock *result_pb;
int opresult;
- slapi_delete_internal_set_pb (&pb, idn, controls, NULL,
plugin_get_default_component_id(), 0);
+ slapi_delete_internal_set_pb (pb, idn, controls, NULL,
plugin_get_default_component_id(), 0);
- delete_internal_pb (&pb);
+ delete_internal_pb (pb);
result_pb = slapi_pblock_new();
if (result_pb)
{
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
slapi_pblock_set(result_pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
}
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
return result_pb;
}
@@ -260,9 +260,13 @@ static void op_shared_delete (Slapi_PBlock *pb)
if (!internal_op )
{
+ Connection *pb_conn = NULL;
+ Operation *pb_op = NULL;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d DEL
dn=\"%s\"%s\n",
- pb->pb_conn->c_connid,
- pb->pb_op->o_opid,
+ pb_conn->c_connid,
+ pb_op->o_opid,
slapi_sdn_get_dn(sdn),
proxystr ? proxystr: "");
}
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index 1422269..146fa84 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -1672,10 +1672,12 @@ slapi_dn_isbesuffix( Slapi_PBlock *pb, const char *dn )
{
int r;
Slapi_DN sdn;
- slapi_sdn_init_dn_byref(&sdn,dn);
- r= slapi_be_issuffix( pb->pb_backend, &sdn );
- slapi_sdn_done(&sdn);
- return r;
+ slapi_sdn_init_dn_byref(&sdn,dn);
+ Slapi_Backend *pb_backend = NULL;
+ slapi_pblock_get(pb, SLAPI_BACKEND, &pb_backend);
+ r = slapi_be_issuffix( pb_backend, &sdn );
+ slapi_sdn_done(&sdn);
+ return r;
}
/*
diff --git a/ldap/servers/slapd/dse.c b/ldap/servers/slapd/dse.c
index 78c3d4b..5715c83 100644
--- a/ldap/servers/slapd/dse.c
+++ b/ldap/servers/slapd/dse.c
@@ -1617,14 +1617,15 @@ do_dse_search(struct dse* pdse, Slapi_PBlock *pb, int scope, const
Slapi_DN *bas
stuff.nentries= 0;
stuff.attrs= attrs;
stuff.attrsonly= attrsonly;
- stuff.ss = NULL;
+ stuff.ss = NULL;
+ Operation *pb_op = NULL;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
/*
* If this is a persistent search and the client is only interested in
* entries that change, we skip looking through the DSE entries.
*/
- if ( pb->pb_op == NULL
- || !operation_is_flag_set( pb->pb_op, OP_FLAG_PS_CHANGESONLY )) {
+ if ( pb_op == NULL || !operation_is_flag_set( pb_op, OP_FLAG_PS_CHANGESONLY )) {
if (pdse->dse_rwlock)
slapi_rwlock_rdlock(pdse->dse_rwlock);
dse_apply_nolock(pdse,dse_search_filter_entry,(caddr_t)&stuff);
@@ -1799,6 +1800,7 @@ dse_modify(Slapi_PBlock *pb) /* JCM There should only be one exit
point from thi
int plugin_started = 0;
int internal_op = 0;
PRBool global_lock_owned = PR_FALSE;
+ Operation *pb_op = NULL;
PR_ASSERT(pb);
if (slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &pdse ) < 0 ||
@@ -1815,7 +1817,8 @@ dse_modify(Slapi_PBlock *pb) /* JCM There should only be one exit
point from thi
return retval;
}
- internal_op = operation_is_flag_set(pb->pb_op, OP_FLAG_INTERNAL);
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ internal_op = operation_is_flag_set(pb_op, OP_FLAG_INTERNAL);
/* Find the entry we are about to modify. */
ec = dse_get_entry_copy(pdse, sdn, DSE_USE_LOCK);
@@ -2680,12 +2683,18 @@ slapi_config_register_callback_plugin(int operation,
struct dse* pdse= (struct dse*)be->be_database->plg_private;
if (pdse!=NULL) {
Slapi_DN dn;
-
slapi_sdn_init_dn_byref(&dn,base);
- /* if a pblock was passed, this is a plugin, so set the f_arg as the plugin
*/
- rc = (NULL != dse_register_callback(pdse, operation, flags, &dn, scope,
filter, fn,
- pb ? (void*)pb->pb_plugin : fn_arg,
- pb ? pb->pb_plugin: NULL));
+ if (pb != NULL) {
+ /* if a pblock was passed, this is a plugin, so set the f_arg as the
plugin */
+ struct slapdplugin *pb_plugin = NULL;
+ slapi_pblock_get(pb, SLAPI_PLUGIN, &pb_plugin);
+ rc = (NULL != dse_register_callback(pdse, operation, flags, &dn,
scope, filter, fn,
+ (void*)pb_plugin, pb_plugin));
+ } else {
+ rc = (NULL != dse_register_callback(pdse, operation, flags, &dn,
scope, filter, fn,
+ fn_arg, NULL));
+ }
+
slapi_sdn_done(&dn);
}
}
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index c5f80df..4d57277 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -4125,16 +4125,16 @@ delete_subtree(Slapi_PBlock *pb, const char *dn, void *plg_id)
Slapi_DN *rootDN = slapi_sdn_new_dn_byval(dn);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
for (ep = entries; ep && *ep; ep++) {
- Slapi_PBlock mypb = {0};
const Slapi_DN *sdn = slapi_entry_get_sdn_const(*ep);
if (slapi_sdn_compare(sdn, rootDN) == 0) {
continue;
}
- slapi_delete_internal_set_pb(&mypb, slapi_sdn_get_dn(sdn),
+ Slapi_PBlock *mypb = slapi_pblock_new();
+ slapi_delete_internal_set_pb(mypb, slapi_sdn_get_dn(sdn),
NULL, NULL, plg_id, 0);
- slapi_delete_internal_pb(&mypb);
- slapi_pblock_get(&mypb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
- pblock_done(&mypb);
+ slapi_delete_internal_pb(mypb);
+ slapi_pblock_get(mypb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
+ slapi_pblock_destroy(mypb);
}
slapi_sdn_free(&rootDN);
}
@@ -4229,14 +4229,14 @@ slapi_entries_diff(Slapi_Entry **old_entries, Slapi_Entry
**curr_entries,
}
if (0 == isfirst && force_update && testall)
{
- Slapi_PBlock pb = {0};
- slapi_modify_internal_set_pb_ext(&pb,
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_modify_internal_set_pb_ext(pb,
slapi_entry_get_sdn_const(*oep),
slapi_mods_get_ldapmods_byref(smods),
NULL, NULL, plg_id, 0);
- slapi_modify_internal_pb(&pb);
- pblock_done(&pb);
+ slapi_modify_internal_pb(pb);
+ slapi_pblock_destroy(pb);
}
slapi_mods_free(&smods);
@@ -4257,14 +4257,14 @@ slapi_entries_diff(Slapi_Entry **old_entries, Slapi_Entry
**curr_entries,
{
if (force_update)
{
- Slapi_PBlock pb = {0};
+ Slapi_PBlock *pb = slapi_pblock_new();
LDAPMod **mods;
slapi_entry2mods(*oep, NULL, &mods);
- slapi_add_internal_set_pb(&pb, slapi_entry_get_dn_const(*oep),
+ slapi_add_internal_set_pb(pb, slapi_entry_get_dn_const(*oep),
mods, NULL, plg_id, 0);
- slapi_add_internal_pb(&pb);
+ slapi_add_internal_pb(pb);
freepmods(mods);
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
}
}
else
@@ -4286,9 +4286,9 @@ slapi_entries_diff(Slapi_Entry **old_entries, Slapi_Entry
**curr_entries,
if (testall)
{
if (force_update) {
- Slapi_PBlock pb = {0};
- delete_subtree(&pb, slapi_entry_get_dn_const(*cep), plg_id);
- pblock_done(&pb);
+ Slapi_PBlock *pb = slapi_pblock_new();
+ delete_subtree(pb, slapi_entry_get_dn_const(*cep), plg_id);
+ slapi_pblock_destroy(pb);
}
}
else
diff --git a/ldap/servers/slapd/extendop.c b/ldap/servers/slapd/extendop.c
index 792580d..60b7f62 100644
--- a/ldap/servers/slapd/extendop.c
+++ b/ldap/servers/slapd/extendop.c
@@ -30,6 +30,8 @@ static void extop_handle_import_start(Slapi_PBlock *pb, char *extoid
__attribute
Slapi_Backend *be = NULL;
struct berval bv;
int ret;
+ Operation *pb_op = NULL;
+ Connection *pb_conn = NULL;
if (extval == NULL || extval->bv_val == NULL) {
slapi_log_err(SLAPI_LOG_ERR,
@@ -76,8 +78,9 @@ static void extop_handle_import_start(Slapi_PBlock *pb, char *extoid
__attribute
goto out;
}
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
slapi_pblock_set(pb, SLAPI_BACKEND, be);
- slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &pb->pb_op->o_isroot );
+ slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &(pb_op->o_isroot));
{
/* Access Control Check to see if the client is
@@ -132,10 +135,11 @@ static void extop_handle_import_start(Slapi_PBlock *pb, char *extoid
__attribute
/* okay, the import is starting now -- save the backend in the
* connection block & mark this connection as belonging to a bulk import
*/
- PR_EnterMonitor(pb->pb_conn->c_mutex);
- pb->pb_conn->c_flags |= CONN_FLAG_IMPORT;
- pb->pb_conn->c_bi_backend = be;
- PR_ExitMonitor(pb->pb_conn->c_mutex);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ PR_EnterMonitor(pb_conn->c_mutex);
+ pb_conn->c_flags |= CONN_FLAG_IMPORT;
+ pb_conn->c_bi_backend = be;
+ PR_ExitMonitor(pb_conn->c_mutex);
slapi_pblock_set(pb, SLAPI_EXT_OP_RET_OID, EXTOP_BULK_IMPORT_START_OID);
bv.bv_val = NULL;
@@ -156,12 +160,14 @@ static void extop_handle_import_done(Slapi_PBlock *pb, char *extoid
__attribute_
Slapi_Backend *be;
struct berval bv;
int ret;
+ Connection *pb_conn;
- PR_EnterMonitor(pb->pb_conn->c_mutex);
- pb->pb_conn->c_flags &= ~CONN_FLAG_IMPORT;
- be = pb->pb_conn->c_bi_backend;
- pb->pb_conn->c_bi_backend = NULL;
- PR_ExitMonitor(pb->pb_conn->c_mutex);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ PR_EnterMonitor(pb_conn->c_mutex);
+ pb_conn->c_flags &= ~CONN_FLAG_IMPORT;
+ be = pb_conn->c_bi_backend;
+ pb_conn->c_bi_backend = NULL;
+ PR_ExitMonitor(pb_conn->c_mutex);
if ((be == NULL) || (be->be_wire_import == NULL)) {
/* can this even happen? */
@@ -206,9 +212,14 @@ do_extended( Slapi_PBlock *pb )
ber_len_t len;
ber_tag_t tag;
const char *name;
+ Operation *pb_op = NULL;
+ Connection *pb_conn = NULL;
slapi_log_err(SLAPI_LOG_TRACE, "do_extended", "->\n");
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
/*
* Parse the extended request. It looks like this:
*
@@ -218,7 +229,7 @@ do_extended( Slapi_PBlock *pb )
* }
*/
- if ( ber_scanf( pb->pb_op->o_ber, "{a", &extoid )
+ if ( ber_scanf( pb_op->o_ber, "{a", &extoid )
== LBER_ERROR ) {
slapi_log_err(SLAPI_LOG_ERR,
"do_extended", "ber_scanf failed (op=extended;
params=OID)\n");
@@ -227,17 +238,17 @@ do_extended( Slapi_PBlock *pb )
NULL );
goto free_and_return;
}
- tag = ber_peek_tag(pb->pb_op->o_ber, &len);
+ tag = ber_peek_tag(pb_op->o_ber, &len);
if (tag == LDAP_TAG_EXOP_REQ_VALUE) {
- if ( ber_scanf( pb->pb_op->o_ber, "o}", &extval ) ==
LBER_ERROR ) {
+ if ( ber_scanf( pb_op->o_ber, "o}", &extval ) == LBER_ERROR ) {
op_shared_log_error_access (pb, "EXT", "???",
"decoding error: fail to get extension value");
send_ldap_result( pb, LDAP_PROTOCOL_ERROR, NULL, "decoding error",
0,
NULL );
goto free_and_return;
}
} else {
- if ( ber_scanf( pb->pb_op->o_ber, "}") == LBER_ERROR ) {
+ if ( ber_scanf( pb_op->o_ber, "}") == LBER_ERROR ) {
op_shared_log_error_access (pb, "EXT", "???",
"decoding error");
send_ldap_result( pb, LDAP_PROTOCOL_ERROR, NULL, "decoding error",
0,
NULL );
@@ -248,20 +259,20 @@ do_extended( Slapi_PBlock *pb )
slapi_log_err(SLAPI_LOG_ARGS, "do_extended", "oid (%s)\n",
extoid);
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d EXT
oid=\"%s\"\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid, extoid );
+ pb_conn->c_connid, pb_op->o_opid, extoid );
} else {
slapi_log_err(SLAPI_LOG_ARGS, "do_extended", "oid
(%s-%s)\n",
extoid, name);
slapi_log_access( LDAP_DEBUG_STATS,
"conn=%" PRIu64 " op=%d EXT oid=\"%s\"
name=\"%s\"\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid, extoid, name );
+ pb_conn->c_connid, pb_op->o_opid, extoid, name );
}
/* during a bulk import, only BULK_IMPORT_DONE is allowed!
* (and this is the only time it's allowed)
*/
- if (pb->pb_conn->c_flags & CONN_FLAG_IMPORT) {
+ if (pb_conn->c_flags & CONN_FLAG_IMPORT) {
if (strcmp(extoid, EXTOP_BULK_IMPORT_DONE_OID) != 0) {
send_ldap_result(pb, LDAP_PROTOCOL_ERROR, NULL, NULL, 0, NULL);
goto free_and_return;
@@ -280,16 +291,16 @@ do_extended( Slapi_PBlock *pb )
/* If anonymous access is disabled and we haven't
* authenticated yet, only allow startTLS. */
- if ((config_get_anon_access_switch() != SLAPD_ANON_ACCESS_ON) &&
((pb->pb_op->o_authtype == NULL) ||
- (strcasecmp(pb->pb_op->o_authtype, SLAPD_AUTH_NONE) == 0))) {
+ if ((config_get_anon_access_switch() != SLAPD_ANON_ACCESS_ON) &&
((pb_op->o_authtype == NULL) ||
+ (strcasecmp(pb_op->o_authtype, SLAPD_AUTH_NONE) == 0))) {
send_ldap_result( pb, LDAP_INAPPROPRIATE_AUTH, NULL,
"Anonymous access is not allowed.", 0, NULL );
goto free_and_return;
}
/* If the minssf is not met, only allow startTLS. */
- if ((pb->pb_conn->c_sasl_ssf < minssf) &&
(pb->pb_conn->c_ssl_ssf < minssf) &&
- (pb->pb_conn->c_local_ssf < minssf)) {
+ if ((pb_conn->c_sasl_ssf < minssf) && (pb_conn->c_ssl_ssf <
minssf) &&
+ (pb_conn->c_local_ssf < minssf)) {
send_ldap_result( pb, LDAP_UNWILLING_TO_PERFORM, NULL,
"Minimum SSF not met.", 0, NULL );
goto free_and_return;
@@ -298,8 +309,8 @@ do_extended( Slapi_PBlock *pb )
/* If a password change is required, only allow the password
* modify extended operation */
- if (!pb->pb_conn->c_isreplication_session &&
- pb->pb_conn->c_needpw && (strcmp(extoid, EXTOP_PASSWD_OID)
!= 0))
+ if (!pb_conn->c_isreplication_session &&
+ pb_conn->c_needpw && (strcmp(extoid, EXTOP_PASSWD_OID) != 0))
{
char *dn = NULL;
slapi_pblock_get(pb, SLAPI_CONN_DN, &dn);
@@ -313,7 +324,7 @@ do_extended( Slapi_PBlock *pb )
}
/* decode the optional controls - put them in the pblock */
- if ( (lderr = get_ldapmessage_controls( pb, pb->pb_op->o_ber, NULL )) != 0 )
+ if ( (lderr = get_ldapmessage_controls( pb, pb_op->o_ber, NULL )) != 0 )
{
char *dn = NULL;
slapi_pblock_get(pb, SLAPI_CONN_DN, &dn);
@@ -327,7 +338,7 @@ do_extended( Slapi_PBlock *pb )
slapi_pblock_set( pb, SLAPI_EXT_OP_REQ_OID, extoid );
slapi_pblock_set( pb, SLAPI_EXT_OP_REQ_VALUE, &extval );
- slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &pb->pb_op->o_isroot);
+ slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &pb_op->o_isroot);
rc = plugin_determine_exop_plugins( extoid, &p );
slapi_log_err(SLAPI_LOG_TRACE, "do_extended",
"Plugin_determine_exop_plugins rc %d\n", rc);
diff --git a/ldap/servers/slapd/fedse.c b/ldap/servers/slapd/fedse.c
index bd6bc28..04fab98 100644
--- a/ldap/servers/slapd/fedse.c
+++ b/ldap/servers/slapd/fedse.c
@@ -1529,21 +1529,20 @@ static void
internal_add_helper(Slapi_Entry *e, int dont_write_file)
{
int plugin_actions = 0;
- Slapi_PBlock newpb;
+ Slapi_PBlock *newpb = slapi_pblock_new();
Slapi_Operation *op;
- pblock_init(&newpb);
- slapi_add_entry_internal_set_pb(&newpb, e, NULL,
+ slapi_add_entry_internal_set_pb(newpb, e, NULL,
plugin_get_default_component_id(),
plugin_actions);
- slapi_pblock_set(&newpb, SLAPI_TARGET_SDN, (void*)slapi_entry_get_sdn_const(e));
- slapi_pblock_set(&newpb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING,
+ slapi_pblock_set(newpb, SLAPI_TARGET_SDN, (void*)slapi_entry_get_sdn_const(e));
+ slapi_pblock_set(newpb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING,
(void *)&dont_write_file);
- slapi_pblock_get(&newpb, SLAPI_OPERATION, &op);
+ slapi_pblock_get(newpb, SLAPI_OPERATION, &op);
operation_set_flag(op, OP_FLAG_ACTION_NOLOG);
- slapi_add_internal_pb(&newpb);
- pblock_done(&newpb);
+ slapi_add_internal_pb(newpb);
+ slapi_pblock_destroy(newpb);
}
/*
@@ -1558,7 +1557,6 @@ static int
init_dse_file(const char *configdir, Slapi_DN *config)
{
int rc= 1; /* OK */
- Slapi_PBlock pb = {0};
if(pfedse==NULL)
{
@@ -1567,6 +1565,7 @@ init_dse_file(const char *configdir, Slapi_DN *config)
}
if(rc)
{
+ Slapi_PBlock *pb = slapi_pblock_new();
int dont_write = 1;
dse_register_callback(pfedse,DSE_OPERATION_READ,DSE_FLAG_PREOP,config,
LDAP_SCOPE_SUBTREE,"(objectclass=nsslapdPlugin)",
@@ -1575,15 +1574,16 @@ init_dse_file(const char *configdir, Slapi_DN *config)
LDAP_SCOPE_BASE,"(objectclass=*)",
load_config_dse,NULL, NULL);
- slapi_pblock_set(&pb, SLAPI_CONFIG_DIRECTORY, (void*)configdir);
+ slapi_pblock_set(pb, SLAPI_CONFIG_DIRECTORY, (void*)configdir);
/* don't write out the file when reading */
- slapi_pblock_set(&pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING, (void*)&dont_write);
- if(!(rc = dse_read_file(pfedse, &pb)))
+ slapi_pblock_set(pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING, (void*)&dont_write);
+ if(!(rc = dse_read_file(pfedse, pb)))
{
slapi_log_err(SLAPI_LOG_ERR, "init_dse_file",
"Could not load config file [%s]\n",
DSE_FILENAME );
}
+ slapi_pblock_destroy(pb);
}
return rc;
}
diff --git a/ldap/servers/slapd/filter.c b/ldap/servers/slapd/filter.c
index 0bb10c7..58e55b7 100644
--- a/ldap/servers/slapd/filter.c
+++ b/ldap/servers/slapd/filter.c
@@ -774,10 +774,11 @@ slapi_filter_free( struct slapi_filter *f, int recurse )
slapi_ch_free((void**)&f->f_mr_type);
slapi_ber_bvdone(&f->f_mr_value);
if (f->f_mr.mrf_destroy != NULL) {
- Slapi_PBlock pb = {0};
- if ( ! slapi_pblock_set (&pb, SLAPI_PLUGIN_OBJECT, f->f_mr.mrf_object)) {
- f->f_mr.mrf_destroy (&pb);
+ Slapi_PBlock *pb = slapi_pblock_new();
+ if ( ! slapi_pblock_set (pb, SLAPI_PLUGIN_OBJECT, f->f_mr.mrf_object)) {
+ f->f_mr.mrf_destroy (pb);
}
+ slapi_pblock_destroy(pb);
}
break;
diff --git a/ldap/servers/slapd/filtercmp.c b/ldap/servers/slapd/filtercmp.c
index fec31f2..9005ef4 100644
--- a/ldap/servers/slapd/filtercmp.c
+++ b/ldap/servers/slapd/filtercmp.c
@@ -85,14 +85,15 @@ static Slapi_PBlock *get_mr_normval(char *oid, char *type,
unsigned int sort_indicator = SLAPI_PLUGIN_MR_USAGE_SORT;
IFP mrIndex = NULL;
- if (!pb)
- return NULL;
+ if (!pb) {
+ return NULL;
+ }
slapi_pblock_set(pb, SLAPI_PLUGIN_MR_OID, oid);
slapi_pblock_set(pb, SLAPI_PLUGIN_MR_TYPE, type);
slapi_pblock_set(pb, SLAPI_PLUGIN_MR_USAGE, (void *)&sort_indicator);
if (slapi_mr_indexer_create(pb) != 0) {
- slapi_pblock_destroy(pb);
- return NULL;
+ slapi_pblock_destroy(pb);
+ return NULL;
}
if ((slapi_pblock_get(pb, SLAPI_PLUGIN_MR_INDEX_FN, &mrIndex) != 0) ||
!mrIndex) {
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 05e092e..08156fb 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -2008,7 +2008,6 @@ static int
slapd_exemode_ldif2db(void)
{
int return_value= 0;
- Slapi_PBlock pb = {0};
struct slapdplugin *plugin;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -2099,27 +2098,30 @@ slapd_exemode_ldif2db(void)
if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) {
g_set_detached(1);
}
- pb.pb_backend = NULL;
- pb.pb_plugin = plugin;
- pb.pb_removedupvals = ldif2db_removedupvals;
- pb.pb_ldif2db_noattrindexes = ldif2db_noattrindexes;
- pb.pb_ldif_generate_uniqueid = ldif2db_generate_uniqueid;
- pb.pb_ldif_namespaceid = ldif2db_namespaceid;
- pb.pb_ldif_encrypt = importexport_encrypt;
- pb.pb_instance_name = cmd_line_instance_name;
- pb.pb_ldif_files = ldif_file;
- pb.pb_ldif_include = db2ldif_include;
- pb.pb_ldif_exclude = db2ldif_exclude;
- pb.pb_task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_BACKEND, NULL);
+ slapi_pblock_set(pb, SLAPI_PLUGIN, plugin);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_REMOVEDUPVALS, &ldif2db_removedupvals);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_NOATTRINDEXES, &ldif2db_noattrindexes);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_GENERATE_UNIQUEID,
&ldif2db_generate_uniqueid);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_NAMESPACEID, &ldif2db_namespaceid);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_ENCRYPT, &importexport_encrypt);
+ slapi_pblock_set(pb, SLAPI_BACKEND_INSTANCE_NAME, cmd_line_instance_name);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_FILE, ldif_file);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_INCLUDE, db2ldif_include);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_EXCLUDE, db2ldif_exclude);
+ int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags);
main_setuid(slapdFrontendConfig->localuser);
if ( plugin->plg_ldif2db != NULL ) {
- return_value = (*plugin->plg_ldif2db)( &pb );
+ return_value = (*plugin->plg_ldif2db)( pb );
} else {
slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_ldif2db",
"No ldif2db function defined for "
"%s\n", plugin->plg_name);
return_value = -1;
}
+ slapi_pblock_destroy(pb);
slapi_ch_free((void**)&myname );
charray_free( db2index_attrs );
charray_free(ldif_file);
@@ -2130,7 +2132,6 @@ static int
slapd_exemode_db2ldif(int argc, char** argv)
{
int return_value= 0;
- Slapi_PBlock pb = {0};
struct slapdplugin *plugin;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
char *my_ldiffile;
@@ -2222,19 +2223,22 @@ slapd_exemode_db2ldif(int argc, char** argv)
if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) {
g_set_detached(1);
}
- pb.pb_backend = NULL;
- pb.pb_plugin = plugin;
- pb.pb_ldif_include = db2ldif_include;
- pb.pb_ldif_exclude = db2ldif_exclude;
- pb.pb_ldif_dump_replica = db2ldif_dump_replica;
- pb.pb_ldif_dump_uniqueid = db2ldif_dump_uniqueid;
- pb.pb_ldif_encrypt = importexport_encrypt;
- pb.pb_instance_name = *instp;
- pb.pb_task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
- if (is_slapd_running())
- pb.pb_server_running = 1;
- else
- pb.pb_server_running = 0;
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_BACKEND, NULL);
+ slapi_pblock_set(pb, SLAPI_PLUGIN, plugin);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_INCLUDE, db2ldif_include);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_EXCLUDE, db2ldif_exclude);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_ENCRYPT, &importexport_encrypt);
+ slapi_pblock_set(pb, SLAPI_BACKEND_INSTANCE_NAME, *instp);
+ slapi_pblock_set_ldif_dump_replica(pb, db2ldif_dump_replica);
+ slapi_pblock_set(pb, SLAPI_DB2LDIF_DUMP_UNIQUEID, &db2ldif_dump_uniqueid);
+ int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags);
+ int32_t is_running = 0;
+ if (is_slapd_running()) {
+ is_running = 1;
+ }
+ slapi_pblock_set(pb, SLAPI_DB2LDIF_SERVER_RUNNING, &is_running);
if (db2ldif_dump_replica) {
char **plugin_list = NULL;
@@ -2255,7 +2259,6 @@ slapd_exemode_db2ldif(int argc, char** argv)
charray_free(plugin_list);
}
- pb.pb_ldif_file = NULL;
if ( archive_name ) { /* redirect stdout to this file: */
char *p, *q;
char sep = '/';
@@ -2293,11 +2296,13 @@ slapd_exemode_db2ldif(int argc, char** argv)
* the backend open it (so they can do special
* stuff for 64-bit fs)
*/
- pb.pb_ldif_file = my_ldiffile;
- pb.pb_ldif_printkey = ldif_printkey;
+ slapi_pblock_set(pb, SLAPI_DB2LDIF_FILE, my_ldiffile);
+ slapi_pblock_set(pb, SLAPI_DB2LDIF_PRINTKEY, &ldif_printkey);
}
- return_value = (plugin->plg_db2ldif)( &pb );
+ return_value = (plugin->plg_db2ldif)( pb );
+
+ slapi_pblock_destroy(pb);
if (release_me) {
slapi_ch_free((void **)&my_ldiffile);
@@ -2347,7 +2352,6 @@ static int slapd_exemode_db2index(void)
{
int return_value= 0;
struct slapdplugin *plugin;
- Slapi_PBlock pb = {0};
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
mapping_tree_init();
@@ -2417,14 +2421,17 @@ static int slapd_exemode_db2index(void)
usage( myname, extraname );
return 1;
}
- pb.pb_backend = NULL;
- pb.pb_plugin = plugin;
- pb.pb_db2index_attrs = db2index_attrs;
- pb.pb_instance_name = cmd_line_instance_name;
- pb.pb_task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_BACKEND, NULL);
+ slapi_pblock_set(pb, SLAPI_PLUGIN, plugin);
+ slapi_pblock_set(pb, SLAPI_DB2INDEX_ATTRS, db2index_attrs);
+ slapi_pblock_set(pb, SLAPI_BACKEND_INSTANCE_NAME, cmd_line_instance_name);
+ int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags);
main_setuid(slapdFrontendConfig->localuser);
- return_value = (*plugin->plg_db2index)( &pb );
+ return_value = (*plugin->plg_db2index)( pb );
+ slapi_pblock_destroy(pb);
slapi_ch_free( (void**)&myname );
return( return_value );
}
@@ -2434,7 +2441,6 @@ static int
slapd_exemode_db2archive(void)
{
int return_value= 0;
- Slapi_PBlock pb = {0};
struct slapdplugin *backend_plugin;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -2471,13 +2477,15 @@ slapd_exemode_db2archive(void)
g_set_detached(1);
}
- pb.pb_backend = NULL;
- pb.pb_plugin = backend_plugin;
- pb.pb_instance_name = NULL;
- pb.pb_seq_val = archive_name;
- pb.pb_task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_BACKEND, NULL);
+ slapi_pblock_set(pb, SLAPI_PLUGIN, backend_plugin);
+ slapi_pblock_set(pb, SLAPI_SEQ_VAL, archive_name);
+ int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags);
main_setuid(slapdFrontendConfig->localuser);
- return_value = (backend_plugin->plg_db2archive)( &pb );
+ return_value = (backend_plugin->plg_db2archive)( pb );
+ slapi_pblock_destroy(pb);
return return_value;
}
@@ -2485,7 +2493,6 @@ static int
slapd_exemode_archive2db(void)
{
int return_value= 0;
- Slapi_PBlock pb = {0};
struct slapdplugin *backend_plugin;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -2523,13 +2530,16 @@ slapd_exemode_archive2db(void)
g_set_detached(1);
}
- pb.pb_backend = NULL;
- pb.pb_plugin = backend_plugin;
- pb.pb_instance_name = cmd_line_instance_name;
- pb.pb_seq_val = archive_name;
- pb.pb_task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_BACKEND, NULL);
+ slapi_pblock_set(pb, SLAPI_PLUGIN, backend_plugin);
+ slapi_pblock_set(pb, SLAPI_SEQ_VAL, archive_name);
+ int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags);
+ slapi_pblock_set(pb, SLAPI_BACKEND_INSTANCE_NAME, cmd_line_instance_name);
main_setuid(slapdFrontendConfig->localuser);
- return_value = (backend_plugin->plg_archive2db)( &pb );
+ return_value = (backend_plugin->plg_archive2db)( pb );
+ slapi_pblock_destroy(pb);
return return_value;
}
@@ -2541,7 +2551,6 @@ static int
slapd_exemode_upgradedb(void)
{
int return_value= 0;
- Slapi_PBlock pb = {0};
struct slapdplugin *backend_plugin;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -2579,25 +2588,26 @@ slapd_exemode_upgradedb(void)
return 1;
}
- pb.pb_backend = NULL;
- pb.pb_plugin = backend_plugin;
- pb.pb_seq_val = archive_name;
- pb.pb_seq_type = upgradedb_flags;
- pb.pb_task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_BACKEND, NULL);
+ slapi_pblock_set(pb, SLAPI_PLUGIN, backend_plugin);
+ slapi_pblock_set(pb, SLAPI_SEQ_VAL, archive_name);
+ slapi_pblock_set(pb, SLAPI_SEQ_TYPE, &upgradedb_flags);
+ int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags);
/* borrowing import code, so need to set up the import variables */
- pb.pb_ldif_generate_uniqueid = ldif2db_generate_uniqueid;
- pb.pb_ldif_namespaceid = ldif2db_namespaceid;
- pb.pb_ldif2db_noattrindexes = 0;
- pb.pb_removedupvals = 0;
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_GENERATE_UNIQUEID,
&ldif2db_generate_uniqueid);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_NAMESPACEID, &ldif2db_namespaceid);
main_setuid(slapdFrontendConfig->localuser);
if ( backend_plugin->plg_upgradedb != NULL ) {
- return_value = (*backend_plugin->plg_upgradedb)( &pb );
+ return_value = (*backend_plugin->plg_upgradedb)( pb );
} else {
slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_upgradedb",
"No upgradedb function defined for "
"%s\n", backend_plugin->plg_name);
return_value = -1;
}
+ slapi_pblock_destroy(pb);
slapi_ch_free((void**)&myname );
return( return_value );
}
@@ -2607,7 +2617,6 @@ static int
slapd_exemode_upgradednformat(void)
{
int rc = -1; /* error, by default */
- Slapi_PBlock pb = {0};
struct slapdplugin *backend_plugin;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
@@ -2649,29 +2658,30 @@ slapd_exemode_upgradednformat(void)
goto bail;
}
- pb.pb_backend = NULL;
- pb.pb_plugin = backend_plugin;
- pb.pb_instance_name = cmd_line_instance_name;
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_BACKEND, NULL);
+ slapi_pblock_set(pb, SLAPI_PLUGIN, backend_plugin);
+ slapi_pblock_set(pb, SLAPI_BACKEND_INSTANCE_NAME, cmd_line_instance_name);
+ int32_t seq_type = SLAPI_UPGRADEDNFORMAT;
if (upgradednformat_dryrun) {
- pb.pb_seq_type = SLAPI_UPGRADEDNFORMAT|SLAPI_DRYRUN;
- } else {
- pb.pb_seq_type = SLAPI_UPGRADEDNFORMAT;
+ seq_type = SLAPI_UPGRADEDNFORMAT|SLAPI_DRYRUN;
}
- pb.pb_seq_val = archive_name; /* Path to the work db instance dir */
- pb.pb_task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ slapi_pblock_set(pb, SLAPI_SEQ_TYPE, &seq_type);
+ slapi_pblock_set(pb, SLAPI_SEQ_VAL, archive_name); /* Path to the work db instance
dir */
+ int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags);
/* borrowing import code, so need to set up the import variables */
- pb.pb_ldif_generate_uniqueid = ldif2db_generate_uniqueid;
- pb.pb_ldif_namespaceid = ldif2db_namespaceid;
- pb.pb_ldif2db_noattrindexes = 0;
- pb.pb_removedupvals = 0;
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_GENERATE_UNIQUEID,
&ldif2db_generate_uniqueid);
+ slapi_pblock_set(pb, SLAPI_LDIF2DB_NAMESPACEID, &ldif2db_namespaceid);
main_setuid(slapdFrontendConfig->localuser);
if ( backend_plugin->plg_upgradednformat != NULL ) {
- rc = (*backend_plugin->plg_upgradednformat)( &pb );
+ rc = (*backend_plugin->plg_upgradednformat)( pb );
} else {
slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_upgradednformat",
"No upgradednformat function defined for "
"%s\n", backend_plugin->plg_name);
}
+ slapi_pblock_destroy(pb);
bail:
slapi_ch_free((void**)&myname );
return( rc );
@@ -2684,7 +2694,6 @@ static int
slapd_exemode_dbverify(void)
{
int return_value = 0;
- Slapi_PBlock pb = {0};
struct slapdplugin *backend_plugin;
/* this should be the first time to be called! if the init order
@@ -2704,21 +2713,24 @@ slapd_exemode_dbverify(void)
return 1;
}
- pb.pb_backend = NULL;
- pb.pb_seq_type = dbverify_verbose;
- pb.pb_plugin = backend_plugin;
- pb.pb_instance_name = (char *)cmd_line_instance_names;
- pb.pb_task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
- pb.pb_dbverify_dbdir = dbverify_dbdir;
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_BACKEND, NULL);
+ slapi_pblock_set(pb, SLAPI_PLUGIN, backend_plugin);
+ slapi_pblock_set(pb, SLAPI_SEQ_TYPE, &dbverify_verbose);
+ slapi_pblock_set(pb, SLAPI_BACKEND_INSTANCE_NAME, cmd_line_instance_name);
+ int32_t task_flags = SLAPI_TASK_RUNNING_FROM_COMMANDLINE;
+ slapi_pblock_set(pb, SLAPI_TASK_FLAGS, &task_flags);
+ slapi_pblock_set(pb, SLAPI_DBVERIFY_DBDIR, dbverify_dbdir);
if ( backend_plugin->plg_dbverify != NULL ) {
- return_value = (*backend_plugin->plg_dbverify)( &pb );
+ return_value = (*backend_plugin->plg_dbverify)( pb );
} else {
slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_dbverify",
"No db verify function defined for "
"%s\n", backend_plugin->plg_name);
return_value = -1;
}
+ slapi_pblock_destroy(pb);
return( return_value );
}
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index fbf3930..7552839 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -3338,7 +3338,6 @@ slapi_get_suffix_by_dn(const Slapi_DN *dn)
int
slapi_mtn_set_referral(const Slapi_DN *sdn, char ** referral)
{
- Slapi_PBlock pb = {0};
Slapi_Mods smods;
int rc = LDAP_SUCCESS,i = 0, j = 0;
Slapi_DN* node_sdn;
@@ -3407,23 +3406,24 @@ slapi_mtn_set_referral(const Slapi_DN *sdn, char ** referral)
valuearray_free(&svals);
}
}
-
+
if ( do_modify )
{
- slapi_modify_internal_set_pb_ext (&pb, node_sdn,
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_modify_internal_set_pb_ext (pb, node_sdn,
slapi_mods_get_ldapmods_byref(&smods), NULL,
NULL, (void *) plugin_get_default_component_id(), 0);
- slapi_modify_internal_pb (&pb);
+ slapi_modify_internal_pb (pb);
- slapi_pblock_get (&pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
- pblock_done(&pb);
+ slapi_pblock_get (pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
+ slapi_pblock_destroy(pb);
}
slapi_mods_done(&smods);
slapi_sdn_free(&node_sdn);
return rc;
-}
+}
/*
* Change the state of a mapping tree node entry
@@ -3435,7 +3435,6 @@ slapi_mtn_set_referral(const Slapi_DN *sdn, char ** referral)
int
slapi_mtn_set_state(const Slapi_DN *sdn, char *state)
{
- Slapi_PBlock pb = {0};
Slapi_Mods smods;
int rc = LDAP_SUCCESS;
Slapi_DN *node_sdn;
@@ -3461,17 +3460,18 @@ slapi_mtn_set_state(const Slapi_DN *sdn, char *state)
}
/* Otherwise, means that the state has changed, modify it */
+ Slapi_PBlock *pb = slapi_pblock_new();
slapi_mods_init (&smods, 1);
slapi_mods_add(&smods, LDAP_MOD_REPLACE, "nsslapd-state",
strlen(state), state);
- slapi_modify_internal_set_pb_ext (&pb, node_sdn,
+ slapi_modify_internal_set_pb_ext (pb, node_sdn,
slapi_mods_get_ldapmods_byref(&smods), NULL,
NULL, (void *) plugin_get_default_component_id(), 0);
- slapi_modify_internal_pb (&pb);
+ slapi_modify_internal_pb (pb);
- slapi_pblock_get (&pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
+ slapi_pblock_get (pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
slapi_mods_done(&smods);
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
bail:
slapi_ch_free_string(&value);
slapi_sdn_free(&node_sdn);
@@ -3484,7 +3484,7 @@ bail:
Slapi_Attr *
mtn_get_attr(char* node_dn, char * type)
{
- Slapi_PBlock pb = {0};
+ Slapi_PBlock *pb = slapi_pblock_new();
int res = 0;
Slapi_Entry **entries = NULL;
Slapi_Attr *attr = NULL;
@@ -3493,17 +3493,17 @@ mtn_get_attr(char* node_dn, char * type)
attrs = (char **)slapi_ch_calloc(2, sizeof(char *));
attrs[0] = slapi_ch_strdup(type);
- slapi_search_internal_set_pb(&pb, node_dn, LDAP_SCOPE_BASE,
+ slapi_search_internal_set_pb(pb, node_dn, LDAP_SCOPE_BASE,
"objectclass=nsMappingTree", attrs, 0, NULL, NULL,
(void *) plugin_get_default_component_id(), 0);
- slapi_search_internal_pb(&pb);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
+ slapi_search_internal_pb(pb);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
if (res != LDAP_SUCCESS) {
goto done;
}
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
if (NULL == entries || NULL == entries[0]) {
goto done;
}
@@ -3514,12 +3514,12 @@ mtn_get_attr(char* node_dn, char * type)
/* we need to make a copy here so we can free the search results */
ret_attr = slapi_attr_dup(attr);
- slapi_free_search_results_internal(&pb);
+ slapi_free_search_results_internal(pb);
done:
slapi_ch_free((void **)&attrs[0]);
slapi_ch_free((void **)&attrs);
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
return ret_attr;
}
@@ -3873,7 +3873,6 @@ static void dump_mapping_tree(mapping_tree_node *parent, int depth)
static int
_mtn_update_config_param(int op, char *type, char *strvalue)
{
- Slapi_PBlock confpb = {0};
Slapi_DN sdn;
Slapi_Mods smods;
LDAPMod **mods;
@@ -3891,19 +3890,20 @@ _mtn_update_config_param(int op, char *type, char *strvalue)
default:
return rc;
}
+ Slapi_PBlock *confpb = slapi_pblock_new();
slapi_sdn_init_ndn_byref(&sdn, SLAPD_CONFIG_DN);
- slapi_modify_internal_set_pb_ext(&confpb, &sdn,
+ slapi_modify_internal_set_pb_ext(confpb, &sdn,
slapi_mods_get_ldapmods_byref(&smods),
NULL, NULL,
(void *)plugin_get_default_component_id(), 0);
- slapi_modify_internal_pb(&confpb);
- slapi_pblock_get (&confpb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
+ slapi_modify_internal_pb(confpb);
+ slapi_pblock_get (confpb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
slapi_sdn_done(&sdn);
/* need to free passed out mods
* since the internal modify could realloced mods. */
- slapi_pblock_get(&confpb, SLAPI_MODIFY_MODS, &mods);
+ slapi_pblock_get(confpb, SLAPI_MODIFY_MODS, &mods);
ldap_mods_free (mods, 1 /* Free the Array and the Elements */);
- pblock_done(&confpb);
+ slapi_pblock_destroy(confpb);
return rc;
}
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
index fa0d599..0991e83 100644
--- a/ldap/servers/slapd/modify.c
+++ b/ldap/servers/slapd/modify.c
@@ -97,7 +97,8 @@ static struct attr_value_check {
void
do_modify( Slapi_PBlock *pb )
{
- Slapi_Operation *operation;
+ Slapi_Operation *operation = NULL;
+ Connection *pb_conn = NULL;
Slapi_Mods smods;
BerElement *ber;
ber_tag_t tag;
@@ -119,6 +120,8 @@ do_modify( Slapi_PBlock *pb )
slapi_pblock_get( pb, SLAPI_OPERATION, &operation);
ber = operation->o_ber;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
/* count the modify request */
slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsModifyEntryOps);
@@ -178,9 +181,9 @@ do_modify( Slapi_PBlock *pb )
int minssf = 0;
/* Check if the minimum SSF requirement has been met. */
minssf = config_get_minssf();
- if ((pb->pb_conn->c_sasl_ssf < minssf) &&
- (pb->pb_conn->c_ssl_ssf < minssf) &&
- (pb->pb_conn->c_local_ssf < minssf)) {
+ if ((pb_conn->c_sasl_ssf < minssf) &&
+ (pb_conn->c_ssl_ssf < minssf) &&
+ (pb_conn->c_local_ssf < minssf)) {
op_shared_log_error_access(pb, "MOD", rawdn?rawdn:"",
"Minimum SSF not met");
send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL,
@@ -190,7 +193,7 @@ do_modify( Slapi_PBlock *pb )
}
}
- slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &pb->pb_op->o_isroot);
+ slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &(operation->o_isroot));
slapi_pblock_set( pb, SLAPI_ORIGINAL_TARGET, rawdn );
/* collect modifications & save for later */
@@ -258,7 +261,7 @@ do_modify( Slapi_PBlock *pb )
}
/* check if user is allowed to modify the specified attribute */
- if (!op_shared_is_allowed_attr (mod->mod_type,
pb->pb_conn->c_isreplication_session))
+ if (!op_shared_is_allowed_attr (mod->mod_type,
pb_conn->c_isreplication_session))
{
/*
* For now we just ignore attributes that client is not allowed
@@ -281,7 +284,7 @@ do_modify( Slapi_PBlock *pb )
}
if (ignored_some_mods && (0 == smods.num_elements)) {
- if(pb->pb_conn->c_isreplication_session){
+ if(pb_conn->c_isreplication_session){
int connid, opid;
slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
slapi_pblock_get(pb, SLAPI_OPERATION_ID, &opid);
@@ -349,8 +352,8 @@ do_modify( Slapi_PBlock *pb )
}
}
- if (!pb->pb_conn->c_isreplication_session &&
- pb->pb_conn->c_needpw && pw_change == 0 )
+ if (!pb_conn->c_isreplication_session &&
+ pb_conn->c_needpw && pw_change == 0 )
{
(void)slapi_add_pwd_control ( pb, LDAP_CONTROL_PWEXPIRED, 0);
op_shared_log_error_access (pb, "MOD", rawdn, "need new
password");
@@ -406,22 +409,22 @@ slapi_modify_internal(const char *idn,
LDAPControl **controls,
int dummy __attribute__((unused)))
{
- Slapi_PBlock pb = {0};
+ Slapi_PBlock *pb = slapi_pblock_new();
Slapi_PBlock *result_pb = NULL;
int opresult;
- slapi_modify_internal_set_pb (&pb, idn, (LDAPMod**)mods, controls, NULL,
+ slapi_modify_internal_set_pb (pb, idn, (LDAPMod**)mods, controls, NULL,
(void *)plugin_get_default_component_id(), 0);
- modify_internal_pb (&pb);
+ modify_internal_pb (pb);
result_pb = slapi_pblock_new();
if (result_pb)
{
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
slapi_pblock_set(result_pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
}
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
return result_pb;
}
@@ -628,6 +631,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char
*old_pw)
int repl_op, internal_op, lastmod, skip_modified_attrs;
char *unhashed_pw_attr = NULL;
Slapi_Operation *operation;
+ Connection *pb_conn;
char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
int err;
LDAPMod *lc_mod = NULL;
@@ -645,6 +649,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char
*old_pw)
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
internal_op= operation_is_flag_set(operation, OP_FLAG_INTERNAL);
slapi_pblock_get (pb, SLAPI_SKIP_MODIFIED_ATTRS, &skip_modified_attrs);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
if (sdn) {
passin_sdn = 1;
@@ -664,7 +669,7 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char
*old_pw)
slapi_mods_init_passin (&smods, mods);
/* target spec is used to decide which plugins are applicable for the operation */
- operation_set_target_spec (pb->pb_op, sdn);
+ operation_set_target_spec (operation, sdn);
/* get the proxy auth dn if the proxy auth control is present */
proxy_err = proxyauth_get_dn(pb, &proxydn, &errtext);
@@ -681,8 +686,8 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char
*old_pw)
if ( !internal_op )
{
slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d MOD
dn=\"%s\"%s\n",
- pb->pb_conn->c_connid,
- pb->pb_op->o_opid,
+ pb_conn->c_connid,
+ operation->o_opid,
slapi_sdn_get_dn(sdn),
proxystr ? proxystr : "");
}
@@ -1200,6 +1205,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
int rc = 0;
Slapi_Value **values= NULL;
Slapi_Operation *operation;
+ Connection *pb_conn = NULL;
int proxy_err = LDAP_SUCCESS;
char *proxydn = NULL;
char *proxystr = NULL;
@@ -1218,6 +1224,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
slapi_pblock_get (pb, SLAPI_PWPOLICY, &pwresponse_req);
internal_op= operation_is_flag_set(operation, OP_FLAG_INTERNAL);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
slapi_sdn_init_dn_byref (&sdn, dn);
pwpolicy = new_passwdPolicy(pb, (char *)slapi_sdn_get_ndn(&sdn));
@@ -1228,7 +1235,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
if (operation_is_flag_set(operation,OP_FLAG_ACTION_LOG_ACCESS))
{
slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d MOD
dn=\"%s\"\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid,
+ pb_conn->c_connid, operation->o_opid,
slapi_sdn_get_dn(&sdn));
}
@@ -1268,7 +1275,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
proxystr = slapi_ch_smprintf(" authzid=\"%s\"", proxydn);
}
slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d MOD
dn=\"%s\"%s\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid,
+ pb_conn->c_connid, operation->o_opid,
slapi_sdn_get_dn(&sdn), proxystr ? proxystr : "");
}
@@ -1296,8 +1303,8 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
}
/* Check if password policy allows users to change their passwords.*/
- if (!pb->pb_op->o_isroot && slapi_sdn_compare(&sdn,
&pb->pb_op->o_sdn)==0 &&
- !pb->pb_conn->c_needpw && !pwpolicy->pw_change)
+ if (!operation->o_isroot && slapi_sdn_compare(&sdn,
&operation->o_sdn)==0 &&
+ !pb_conn->c_needpw && !pwpolicy->pw_change)
{
if ( pwresponse_req == 1 ) {
slapi_pwpolicy_make_response_control ( pb, -1, -1, LDAP_PWPOLICY_PWDMODNOTALLOWED );
@@ -1313,7 +1320,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
}
slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d MOD
dn=\"%s\"%s, %s\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid,
+ pb_conn->c_connid, operation->o_opid,
slapi_sdn_get_dn(&sdn),
proxystr ? proxystr : "",
"user is not allowed to change password");
@@ -1326,7 +1333,7 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
/* check if password is within password minimum age;
error result is sent directly from check_pw_minage */
- if (pb->pb_conn && !pb->pb_conn->c_needpw &&
+ if (pb_conn && !pb_conn->c_needpw &&
check_pw_minage(pb, &sdn, mod->mod_bvalues) == 1)
{
if (operation_is_flag_set(operation,OP_FLAG_ACTION_LOG_ACCESS))
@@ -1339,8 +1346,8 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
if ( !internal_op )
{
slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d MOD
dn=\"%s\"%s, %s\n",
- pb->pb_conn->c_connid,
- pb->pb_op->o_opid,
+ pb_conn->c_connid,
+ operation->o_opid,
slapi_sdn_get_dn(&sdn),
proxystr ? proxystr : "",
"within password minimum age");
@@ -1382,8 +1389,8 @@ static int op_shared_allow_pw_change (Slapi_PBlock *pb, LDAPMod
*mod, char **old
if ( !internal_op )
{
slapi_log_access(LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d MOD
dn=\"%s\"%s, %s\n",
- pb->pb_conn->c_connid,
- pb->pb_op->o_opid,
+ pb_conn->c_connid,
+ operation->o_opid,
slapi_sdn_get_dn(&sdn),
proxystr ? proxystr : "",
"invalid password syntax");
diff --git a/ldap/servers/slapd/modrdn.c b/ldap/servers/slapd/modrdn.c
index ec56948..1b6ae8c 100644
--- a/ldap/servers/slapd/modrdn.c
+++ b/ldap/servers/slapd/modrdn.c
@@ -40,6 +40,7 @@ void
do_modrdn( Slapi_PBlock *pb )
{
Slapi_Operation *operation;
+ Connection *pb_conn;
BerElement *ber;
char *rawdn = NULL, *rawnewsuperior = NULL;
const char *dn = NULL, *newsuperior = NULL;
@@ -59,6 +60,7 @@ do_modrdn( Slapi_PBlock *pb )
slapi_pblock_get( pb, SLAPI_OPERATION, &operation);
ber = operation->o_ber;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
slapi_sdn_init(&sdn);
slapi_sdn_init(&snewdn);
@@ -86,7 +88,7 @@ do_modrdn( Slapi_PBlock *pb )
if ( ber_peek_tag( ber, &len ) == LDAP_TAG_NEWSUPERIOR ) {
/* This "len" is not used... */
- if ( pb->pb_conn->c_ldapversion < LDAP_VERSION3 ) {
+ if ( pb_conn->c_ldapversion < LDAP_VERSION3 ) {
slapi_log_err(SLAPI_LOG_ERR, "do_modrdn",
"Got newSuperior in LDAPv2 modrdn op\n");
op_shared_log_error_access (pb, "MODRDN",
@@ -211,7 +213,7 @@ do_modrdn( Slapi_PBlock *pb )
"do_modrd", "dn (%s) newrdn (%s) deloldrdn (%d)\n", dn,
newrdn,
deloldrdn );
- slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &pb->pb_op->o_isroot );
+ slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &operation->o_isroot );
/* dn, newrdn and newsuperior are all normalized */
slapi_pblock_set( pb, SLAPI_ORIGINAL_TARGET,
(void *)slapi_sdn_get_udn(&sdn) );
@@ -245,7 +247,7 @@ slapi_modrdn_internal(const char *iodn, const char *inewrdn, int
deloldrdn, LDAP
Slapi_PBlock *
slapi_rename_internal(const char *iodn, const char *inewrdn, const char *inewsuperior,
int deloldrdn, LDAPControl **controls, int dummy __attribute__((unused)))
{
- Slapi_PBlock pb = {0};
+ Slapi_PBlock *pb = slapi_pblock_new();
Slapi_PBlock *result_pb = NULL;
int opresult= 0;
Slapi_DN sdn;
@@ -254,20 +256,20 @@ slapi_rename_internal(const char *iodn, const char *inewrdn, const
char *inewsup
slapi_sdn_init_dn_byref(&sdn, iodn);
slapi_sdn_init_dn_byref(&newsuperiorsdn, inewsuperior);
- slapi_rename_internal_set_pb_ext(&pb, &sdn, inewrdn, &newsuperiorsdn,
+ slapi_rename_internal_set_pb_ext(pb, &sdn, inewrdn, &newsuperiorsdn,
deloldrdn, controls, NULL,
plugin_get_default_component_id(), 0);
- rename_internal_pb (&pb);
+ rename_internal_pb (pb);
result_pb = slapi_pblock_new();
if (result_pb) {
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
slapi_pblock_set(result_pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult);
}
slapi_sdn_done(&sdn);
slapi_sdn_done(&newsuperiorsdn);
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
return result_pb;
}
@@ -399,6 +401,7 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
char *errtext = NULL;
Slapi_DN *sdn = NULL;
Slapi_DN *newsuperiorsdn = NULL;
+ Connection *pb_conn;
slapi_pblock_get(pb, SLAPI_ORIGINAL_TARGET, &dn);
slapi_pblock_get(pb, SLAPI_MODRDN_NEWRDN, &newrdn);
@@ -408,6 +411,7 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
slapi_pblock_get(pb, SLAPI_MODRDN_TARGET_SDN, &origsdn);
internal_op= operation_is_flag_set(operation, OP_FLAG_INTERNAL);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
/*
* If ownership has not been passed to this function, we replace the
@@ -464,8 +468,8 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
{
slapi_log_access(LDAP_DEBUG_STATS,
"conn=%" PRIu64 " op=%d MODRDN dn=\"%s\"
newrdn=\"%s\" newsuperior=\"%s\"%s\n",
- pb->pb_conn->c_connid,
- pb->pb_op->o_opid,
+ pb_conn->c_connid,
+ operation->o_opid,
dn,
newrdn ? newrdn : "(null)",
newsuperior ? newsuperior : "(null)",
@@ -498,8 +502,8 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
if ( !internal_op ) {
slapi_log_err(SLAPI_LOG_ARGS, "op_shared_rename",
"conn=%" PRIu64 " op=%d MODRDN invalid new RDN
(\"%s\")\n",
- pb->pb_conn->c_connid,
- pb->pb_op->o_opid,
+ pb_conn->c_connid,
+ operation->o_opid,
(NULL == newrdn) ? "(null)" : newrdn);
} else {
slapi_log_err(SLAPI_LOG_ARGS, "op_shared_rename",
@@ -532,8 +536,8 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
if (!internal_op) {
slapi_log_err(SLAPI_LOG_ARGS, "op_shared_rename",
"conn=%" PRIu64 " op=%d MODRDN invalid new superior
(\"%s\")",
- pb->pb_conn->c_connid,
- pb->pb_op->o_opid,
+ pb_conn->c_connid,
+ operation->o_opid,
newsuperior ? newsuperior : "(null)");
} else {
slapi_log_err(SLAPI_LOG_ARGS, "op_shared_rename",
@@ -553,7 +557,7 @@ op_shared_rename(Slapi_PBlock *pb, int passin_args)
}
/* target spec is used to decide which plugins are applicable for the operation */
- operation_set_target_spec (pb->pb_op, sdn);
+ operation_set_target_spec (operation, sdn);
/*
* Construct the new DN (code sdn from backend
diff --git a/ldap/servers/slapd/operation.c b/ldap/servers/slapd/operation.c
index 794afe8..3725b9f 100644
--- a/ldap/servers/slapd/operation.c
+++ b/ldap/servers/slapd/operation.c
@@ -23,7 +23,7 @@
int
slapi_is_operation_abandoned( Slapi_Operation *op )
{
- if (op) {
+ if (op != NULL) {
return( op->o_status == SLAPI_OP_STATUS_ABANDONED );
}
return 0;
@@ -32,22 +32,25 @@ slapi_is_operation_abandoned( Slapi_Operation *op )
int
slapi_op_abandoned( Slapi_PBlock *pb )
{
- int op_status;
-
- if (pb && pb->pb_op) {
- op_status = pb->pb_op->o_status;
- return( op_status == SLAPI_OP_STATUS_ABANDONED );
- }
- return 0;
+ if (pb != NULL) {
+ Operation *pb_op;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ return slapi_is_operation_abandoned(pb_op);
+ }
+ return 0;
}
int
slapi_op_internal( Slapi_PBlock *pb )
{
- if (pb && pb->pb_op) {
- return operation_is_flag_set(pb->pb_op, OP_FLAG_INTERNAL);
- }
- return 0;
+ if (pb) {
+ Operation *pb_op;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ if (pb_op) {
+ return operation_is_flag_set(pb_op, OP_FLAG_INTERNAL);
+ }
+ }
+ return 0;
}
void
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index 0456257..133597f 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -238,6 +238,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
int index = 0;
int sent_result = 0;
unsigned int pr_stat = 0;
+ Connection *pb_conn;
ber_int_t pagesize = -1;
ber_int_t estimate = 0; /* estimated search result set size */
@@ -281,7 +282,8 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
internal_op= operation_is_flag_set(operation, OP_FLAG_INTERNAL);
flag_psearch = operation_is_flag_set(operation, OP_FLAG_PS);
-
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
/* get the proxy auth dn if the proxy auth control is present */
proxy_err = proxyauth_get_dn(pb, &proxydn, &errtext);
@@ -336,8 +338,8 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
if ( !internal_op )
{
slapi_log_access(LDAP_DEBUG_STATS, fmtstr,
- pb->pb_conn->c_connid,
- pb->pb_op->o_opid,
+ pb_conn->c_connid,
+ operation->o_opid,
normbase,
scope, fstr, attrliststr,
flag_psearch ? " options=persistent" :
"",
@@ -368,7 +370,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
/* target spec is used to decide which plugins are applicable for
* the operation. basesdn is duplicated and set to target spec.
*/
- operation_set_target_spec (pb->pb_op, basesdn);
+ operation_set_target_spec (operation, basesdn);
/*
* this is time to check if mapping tree specific control was used to
@@ -486,7 +488,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
if ((LDAP_SUCCESS == rc) || (LDAP_CANCELLED == rc) || (0 == pagesize)) {
unsigned int opnote = SLAPI_OP_NOTE_SIMPLEPAGED;
op_set_pagedresults(operation);
- pr_be = pagedresults_get_current_be(pb->pb_conn, pr_idx);
+ pr_be = pagedresults_get_current_be(pb_conn, pr_idx);
if (be_name) {
if (pr_be != be_single) {
slapi_be_Unlock(be_single);
@@ -503,9 +505,9 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
be = be_list[index];
}
}
- pr_search_result = pagedresults_get_search_result(pb->pb_conn,
operation, 0/*not locked*/, pr_idx);
- estimate = pagedresults_get_search_result_set_size_estimate(pb->pb_conn,
operation, pr_idx);
- if (pagedresults_get_unindexed(pb->pb_conn, operation, pr_idx)) {
+ pr_search_result = pagedresults_get_search_result(pb_conn, operation,
0/*not locked*/, pr_idx);
+ estimate = pagedresults_get_search_result_set_size_estimate(pb_conn,
operation, pr_idx);
+ if (pagedresults_get_unindexed(pb_conn, operation, pr_idx)) {
opnote |= SLAPI_OP_NOTE_UNINDEXED;
}
slapi_pblock_set( pb, SLAPI_OPERATION_NOTES, &opnote );
@@ -551,7 +553,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
slapi_pblock_get( pb, SLAPI_SEARCH_TIMELIMIT, &tlimit );
slapi_pblock_get( pb, SLAPI_OPINITIATED_TIME, &optime );
time_up = (tlimit==-1 ? -1 : optime + tlimit); /* -1: no time limit */
- pagedresults_set_timelimit(pb->pb_conn, pb->pb_op, time_up, pr_idx);
+ pagedresults_set_timelimit(pb_conn, operation, time_up, pr_idx);
}
/*
@@ -589,10 +591,10 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
}
if (slapi_sdn_compare(basesdn, sdn)) {
slapi_sdn_free(&basesdn);
- basesdn = operation_get_target_spec(pb->pb_op);
+ basesdn = operation_get_target_spec(operation);
slapi_sdn_free(&basesdn);
basesdn = slapi_sdn_dup(sdn);
- operation_set_target_spec (pb->pb_op, basesdn);
+ operation_set_target_spec (operation, basesdn);
}
break;
@@ -673,20 +675,20 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
if (op_is_pagedresults(operation) && pr_search_result) {
void *sr = NULL;
/* PAGED RESULTS and already have the search results from the prev op */
- pagedresults_lock(pb->pb_conn, pr_idx);
+ pagedresults_lock(pb_conn, pr_idx);
/*
* In async paged result case, the search result might be released
* by other theads. We need to double check it in the locked region.
*/
- PR_EnterMonitor(pb->pb_conn->c_mutex);
- pr_search_result = pagedresults_get_search_result(pb->pb_conn, operation,
1/*locked*/, pr_idx);
+ PR_EnterMonitor(pb_conn->c_mutex);
+ pr_search_result = pagedresults_get_search_result(pb_conn, operation, 1/*locked*/,
pr_idx);
if (pr_search_result) {
- if (pagedresults_is_abandoned_or_notavailable(pb->pb_conn, 1/*locked*/,
pr_idx)) {
- pagedresults_unlock(pb->pb_conn, pr_idx);
+ if (pagedresults_is_abandoned_or_notavailable(pb_conn, 1/*locked*/, pr_idx)) {
+ pagedresults_unlock(pb_conn, pr_idx);
/* Previous operation was abandoned and the simplepaged object is not in use.
*/
send_ldap_result(pb, 0, NULL, "Simple Paged Results Search
abandoned", 0, NULL);
rc = LDAP_SUCCESS;
- PR_ExitMonitor(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb_conn->c_mutex);
goto free_and_return;
} else {
slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, pr_search_result );
@@ -694,14 +696,14 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
/* search result could be reset in the backend/dse */
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET, &sr);
- pagedresults_set_search_result(pb->pb_conn, operation, sr, 1/*locked*/,
pr_idx);
+ pagedresults_set_search_result(pb_conn, operation, sr, 1/*locked*/, pr_idx);
}
} else {
pr_stat = PAGEDRESULTS_SEARCH_END;
rc = LDAP_SUCCESS;
}
- PR_ExitMonitor(pb->pb_conn->c_mutex);
- pagedresults_unlock(pb->pb_conn, pr_idx);
+ PR_ExitMonitor(pb_conn->c_mutex);
+ pagedresults_unlock(pb_conn, pr_idx);
if ((PAGEDRESULTS_SEARCH_END == pr_stat) || (0 == pnentries)) {
/* no more entries to send in the backend */
@@ -719,22 +721,22 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
}
pagedresults_set_response_control(pb, 0, estimate,
curr_search_count, pr_idx);
- if (pagedresults_get_with_sort(pb->pb_conn, operation, pr_idx)) {
+ if (pagedresults_get_with_sort(pb_conn, operation, pr_idx)) {
sort_make_sort_response_control(pb, CONN_GET_SORT_RESULT_CODE, NULL);
}
- pagedresults_set_search_result_set_size_estimate(pb->pb_conn,
+ pagedresults_set_search_result_set_size_estimate(pb_conn,
operation,
estimate, pr_idx);
if (PAGEDRESULTS_SEARCH_END == pr_stat) {
- pagedresults_lock(pb->pb_conn, pr_idx);
+ pagedresults_lock(pb_conn, pr_idx);
slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_SET, NULL);
- if (!pagedresults_is_abandoned_or_notavailable(pb->pb_conn, 0/*not locked*/,
pr_idx)) {
- pagedresults_free_one(pb->pb_conn, operation, pr_idx);
+ if (!pagedresults_is_abandoned_or_notavailable(pb_conn, 0/*not locked*/, pr_idx))
{
+ pagedresults_free_one(pb_conn, operation, pr_idx);
}
- pagedresults_unlock(pb->pb_conn, pr_idx);
+ pagedresults_unlock(pb_conn, pr_idx);
if (next_be) {
/* no more entries, but at least another backend */
- if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx, 0) < 0) {
+ if (pagedresults_set_current_be(pb_conn, next_be, pr_idx, 0) < 0) {
goto free_and_return;
}
}
@@ -831,10 +833,10 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
/* PAGED RESULTS */
if (op_is_pagedresults(operation)) {
/* cleanup the slot */
- PR_EnterMonitor(pb->pb_conn->c_mutex);
- pagedresults_set_search_result(pb->pb_conn, operation, NULL, 1, pr_idx);
- rc = pagedresults_set_current_be(pb->pb_conn, NULL, pr_idx, 1);
- PR_ExitMonitor(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb_conn->c_mutex);
+ pagedresults_set_search_result(pb_conn, operation, NULL, 1, pr_idx);
+ rc = pagedresults_set_current_be(pb_conn, NULL, pr_idx, 1);
+ PR_ExitMonitor(pb_conn->c_mutex);
}
if (1 == flag_no_such_object) {
break;
@@ -876,11 +878,11 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET, &sr);
if ((PAGEDRESULTS_SEARCH_END == pr_stat) || (0 == pnentries)) {
/* no more entries, but at least another backend */
- PR_EnterMonitor(pb->pb_conn->c_mutex);
- pagedresults_set_search_result(pb->pb_conn, operation, NULL, 1,
pr_idx);
+ PR_EnterMonitor(pb_conn->c_mutex);
+ pagedresults_set_search_result(pb_conn, operation, NULL, 1, pr_idx);
be->be_search_results_release(&sr);
- rc = pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx, 1);
- PR_ExitMonitor(pb->pb_conn->c_mutex);
+ rc = pagedresults_set_current_be(pb_conn, next_be, pr_idx, 1);
+ PR_ExitMonitor(pb_conn->c_mutex);
pr_stat = PAGEDRESULTS_SEARCH_END; /* make sure stat is SEARCH_END */
if (NULL == next_be) {
/* no more entries && no more backends */
@@ -891,24 +893,24 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
} else {
curr_search_count = pnentries;
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET_SIZE_ESTIMATE,
&estimate);
- pagedresults_lock(pb->pb_conn, pr_idx);
- if ((pagedresults_set_current_be(pb->pb_conn, be, pr_idx, 0) < 0) ||
- (pagedresults_set_search_result(pb->pb_conn, operation, sr, 0,
pr_idx) < 0) ||
- (pagedresults_set_search_result_count(pb->pb_conn, operation,
curr_search_count, pr_idx) < 0) ||
- (pagedresults_set_search_result_set_size_estimate(pb->pb_conn,
operation, estimate, pr_idx) < 0) ||
- (pagedresults_set_with_sort(pb->pb_conn, operation, with_sort,
pr_idx) < 0)) {
- pagedresults_unlock(pb->pb_conn, pr_idx);
+ pagedresults_lock(pb_conn, pr_idx);
+ if ((pagedresults_set_current_be(pb_conn, be, pr_idx, 0) < 0) ||
+ (pagedresults_set_search_result(pb_conn, operation, sr, 0, pr_idx) <
0) ||
+ (pagedresults_set_search_result_count(pb_conn, operation,
curr_search_count, pr_idx) < 0) ||
+ (pagedresults_set_search_result_set_size_estimate(pb_conn, operation,
estimate, pr_idx) < 0) ||
+ (pagedresults_set_with_sort(pb_conn, operation, with_sort, pr_idx) <
0)) {
+ pagedresults_unlock(pb_conn, pr_idx);
goto free_and_return;
}
- pagedresults_unlock(pb->pb_conn, pr_idx);
+ pagedresults_unlock(pb_conn, pr_idx);
}
slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, NULL );
next_be = NULL; /* to break the loop */
if (operation->o_status & SLAPI_OP_STATUS_ABANDONED) {
/* It turned out this search was abandoned. */
- PR_EnterMonitor(pb->pb_conn->c_mutex);
- pagedresults_free_one_msgid_nolock( pb->pb_conn,
operation->o_msgid);
- PR_ExitMonitor(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb_conn->c_mutex);
+ pagedresults_free_one_msgid_nolock(pb_conn, operation->o_msgid);
+ PR_ExitMonitor(pb_conn->c_mutex);
/* paged-results-request was abandoned; making an empty cookie. */
pagedresults_set_response_control(pb, 0, estimate, -1, pr_idx);
send_ldap_result(pb, 0, NULL, "Simple Paged Results Search
abandoned", 0, NULL);
@@ -917,7 +919,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
}
pagedresults_set_response_control(pb, 0, estimate, curr_search_count,
pr_idx);
if (curr_search_count == -1) {
- pagedresults_free_one(pb->pb_conn, operation, pr_idx);
+ pagedresults_free_one(pb_conn, operation, pr_idx);
}
}
@@ -1244,7 +1246,7 @@ iterate_with_lookahead(Slapi_PBlock *pb, Slapi_Backend *be, int
send_result, int
* next entry function gets called again and has
* a chance to clean things up.
*/
- pb->pb_op->o_status = SLAPI_OP_STATUS_ABANDONED;
+ operation->o_status = SLAPI_OP_STATUS_ABANDONED;
break;
}
}
@@ -1427,7 +1429,7 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result,
* next entry function gets called again and has
* a chance to clean things up.
*/
- pb->pb_op->o_status = SLAPI_OP_STATUS_ABANDONED;
+ operation->o_status = SLAPI_OP_STATUS_ABANDONED;
break;
}
if (gerentry)
@@ -1464,8 +1466,9 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result,
if (process_entry(pb, e, send_result))
{
/* shouldn't send this entry */
- slapi_entry_free(pb->pb_pw_entry);
- pb->pb_pw_entry = NULL;
+ struct slapi_entry *pb_pw_entry = slapi_pblock_get_pw_entry(pb);
+ slapi_entry_free(pb_pw_entry);
+ slapi_pblock_set_pw_entry(pb, NULL);
continue;
}
@@ -1488,11 +1491,12 @@ iterate(Slapi_PBlock *pb, Slapi_Backend *be, int send_result,
* next entry function gets called again and has
* a chance to clean things up.
*/
- pb->pb_op->o_status = SLAPI_OP_STATUS_ABANDONED;
+ operation->o_status = SLAPI_OP_STATUS_ABANDONED;
break;
}
- slapi_entry_free(pb->pb_pw_entry);
- pb->pb_pw_entry = NULL;
+ struct slapi_entry *pb_pw_entry = slapi_pblock_get_pw_entry(pb);
+ slapi_entry_free(pb_pw_entry);
+ slapi_pblock_set_pw_entry(pb, NULL);
if (pagesize == *pnentries)
{
/* PAGED RESULTS: reached the pagesize */
@@ -1562,12 +1566,14 @@ compute_limits (Slapi_PBlock *pb)
Slapi_ComponentId *component_id = NULL;
Slapi_Backend *be;
Slapi_Operation *op;
+ Connection *pb_conn;
slapi_pblock_get (pb, SLAPI_SEARCH_TIMELIMIT, &requested_timelimit);
slapi_pblock_get (pb, SLAPI_SEARCH_SIZELIMIT, &requested_sizelimit);
slapi_pblock_get (pb, SLAPI_REQUESTOR_ISROOT, &isroot);
slapi_pblock_get (pb, SLAPI_BACKEND, &be);
slapi_pblock_get (pb, SLAPI_OPERATION, &op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
/* If the search belongs to the client authentication process, take the value at
@@ -1586,7 +1592,7 @@ compute_limits (Slapi_PBlock *pb)
/*
* Compute the time limit.
*/
- if ( slapi_reslimit_get_integer_limit( pb->pb_conn,
+ if ( slapi_reslimit_get_integer_limit( pb_conn,
timelimit_reslimit_handle, &max_timelimit )
!= SLAPI_RESLIMIT_STATUS_SUCCESS ) {
/*
@@ -1623,7 +1629,7 @@ compute_limits (Slapi_PBlock *pb)
/*
* Compute the size limit.
*/
- if ( slapi_reslimit_get_integer_limit( pb->pb_conn,
+ if ( slapi_reslimit_get_integer_limit( pb_conn,
sizelimit_reslimit_handle, &max_sizelimit )
!= SLAPI_RESLIMIT_STATUS_SUCCESS ) {
/*
@@ -1638,7 +1644,7 @@ compute_limits (Slapi_PBlock *pb)
}
if (op_is_pagedresults(op)) {
- if ( slapi_reslimit_get_integer_limit( pb->pb_conn,
+ if ( slapi_reslimit_get_integer_limit( pb_conn,
pagedsizelimit_reslimit_handle, &max_sizelimit )
!= SLAPI_RESLIMIT_STATUS_SUCCESS ) {
/*
@@ -1740,14 +1746,19 @@ void op_shared_log_error_access (Slapi_PBlock *pb, const char
*type, const char
{
char *proxydn = NULL;
char *proxystr = NULL;
+ Slapi_Operation *operation;
+ Connection *pb_conn;
+
+ slapi_pblock_get(pb, SLAPI_OPERATION, &operation);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
if ((proxyauth_get_dn(pb, &proxydn, NULL) == LDAP_SUCCESS)) {
proxystr = slapi_ch_smprintf(" authzid=\"%s\"", proxydn);
}
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d %s
dn=\"%s\"%s, %s\n",
- ( pb->pb_conn ? pb->pb_conn->c_connid : 0),
- ( pb->pb_op ? pb->pb_op->o_opid : 0),
+ ( pb_conn ? pb_conn->c_connid : 0),
+ ( operation ? operation->o_opid : 0),
type,
dn,
proxystr ? proxystr : "",
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index ed6877f..673019a 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -54,14 +54,17 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
{
int rc = LDAP_SUCCESS;
struct berval cookie = {0};
- Connection *conn = pb->pb_conn;
- Operation *op = pb->pb_op;
+ Connection *conn = NULL;
+ Operation *op = NULL;
BerElement *ber = NULL;
PagedResults *prp = NULL;
time_t ctime = current_time();
int i;
int maxreqs = config_get_maxsimplepaged_per_conn();
+ slapi_pblock_get(pb, SLAPI_OPERATION, &op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);
+
slapi_log_err(SLAPI_LOG_TRACE, "pagedresults_parse_control_value",
"=>\n");
if ( NULL == conn || NULL == op || NULL == pagesize || NULL == index ) {
slapi_log_err(SLAPI_LOG_ERR,
diff --git a/ldap/servers/slapd/passwd_extop.c b/ldap/servers/slapd/passwd_extop.c
index d020962..de1c8c2 100644
--- a/ldap/servers/slapd/passwd_extop.c
+++ b/ldap/servers/slapd/passwd_extop.c
@@ -118,7 +118,6 @@ static int
passwd_apply_mods(Slapi_PBlock *pb_orig, const Slapi_DN *sdn, Slapi_Mods *mods,
LDAPControl **req_controls, LDAPControl ***resp_controls)
{
- Slapi_PBlock pb;
LDAPControl **req_controls_copy = NULL;
LDAPControl **pb_resp_controls = NULL;
int ret=0;
@@ -133,8 +132,8 @@ passwd_apply_mods(Slapi_PBlock *pb_orig, const Slapi_DN *sdn,
Slapi_Mods *mods,
slapi_add_controls(&req_controls_copy, req_controls, 1);
}
- pblock_init(&pb);
- slapi_modify_internal_set_pb_ext (&pb, sdn,
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_modify_internal_set_pb_ext (pb, sdn,
slapi_mods_get_ldapmods_byref(mods),
req_controls_copy, NULL, /* UniqueID */
plugin_get_default_component_id(), /* PluginID */
@@ -146,19 +145,21 @@ passwd_apply_mods(Slapi_PBlock *pb_orig, const Slapi_DN *sdn,
Slapi_Mods *mods,
* that the password change was initiated by the user who
* sent the extended operation instead of always assuming
* that it was done by the root DN. */
- pb.pb_conn = pb_orig->pb_conn;
+ Connection *pb_conn = NULL;
+ slapi_pblock_get(pb_orig, SLAPI_CONNECTION, &pb_conn);
+ slapi_pblock_set(pb, SLAPI_CONNECTION, pb_conn);
- ret =slapi_modify_internal_pb (&pb);
+ ret =slapi_modify_internal_pb (pb);
/* We now clean up the connection that we copied into the
* new pblock. We want to leave it untouched. */
- pb.pb_conn = NULL;
+ slapi_pblock_set(pb, SLAPI_CONNECTION, NULL);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
/* Retrieve and duplicate the response controls since they will be
* destroyed along with the pblock used for the internal operation. */
- slapi_pblock_get(&pb, SLAPI_RESCONTROLS, &pb_resp_controls);
+ slapi_pblock_get(pb, SLAPI_RESCONTROLS, &pb_resp_controls);
if (pb_resp_controls) {
slapi_add_controls(resp_controls, pb_resp_controls, 1);
}
@@ -169,7 +170,7 @@ passwd_apply_mods(Slapi_PBlock *pb_orig, const Slapi_DN *sdn,
Slapi_Mods *mods,
ret, slapi_sdn_get_dn(sdn));
}
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
}
slapi_log_err(SLAPI_LOG_TRACE, "passwd_apply_mods", "<= %d\n",
ret);
@@ -478,7 +479,7 @@ passwd_modify_extop( Slapi_PBlock *pb )
#ifdef LDAP_EXTOP_PASSMOD_CONN_SECURE
/* Allow password modify only for SSL/TLS established connections and
* connections using SASL privacy layers */
- conn = pb->pb_conn;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);
if ( slapi_pblock_get(pb, SLAPI_CONN_SASL_SSF, &sasl_ssf) != 0) {
errMesg = "Could not get SASL SSF from connection\n";
rc = LDAP_OPERATIONS_ERROR;
@@ -719,9 +720,11 @@ parse_req_done:
leak any useful information to the client such as current password
wrong, etc.
*/
+ Operation *pb_op = NULL;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
- operation_set_target_spec (pb->pb_op, slapi_entry_get_sdn(targetEntry));
- slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &pb->pb_op->o_isroot );
+ operation_set_target_spec (pb_op, slapi_entry_get_sdn(targetEntry));
+ slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, &pb_op->o_isroot );
/* In order to perform the access control check , we need to select a backend (even
though
* we don't actually need it otherwise).
@@ -768,7 +771,10 @@ parse_req_done:
/* Check if password policy allows users to change their passwords. We need to do
* this here since the normal modify code doesn't perform this check for
* internal operations. */
- if (!pb->pb_op->o_isroot && !pb->pb_conn->c_needpw &&
!pwpolicy->pw_change) {
+
+ Connection *pb_conn;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ if (!pb_op->o_isroot && !pb_conn->c_needpw &&
!pwpolicy->pw_change) {
if (NULL == bindSDN) {
bindSDN = slapi_sdn_new_normdn_byref(bindDN);
}
diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c
index a99caac..916770d 100644
--- a/ldap/servers/slapd/pblock.c
+++ b/ldap/servers/slapd/pblock.c
@@ -15,7 +15,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
-#include "slap.h"
+#include "pblock_v3.h"
#include "cert.h"
#ifdef PBLOCK_ANALYTICS
@@ -208,6 +208,15 @@ slapi_pblock_destroy( Slapi_PBlock* pb )
}
}
+Slapi_PBlock *
+slapi_pblock_clone(Slapi_PBlock *pb)
+{
+ Slapi_PBlock *new_pb = slapi_pblock_new();
+ /* Perform a shallow copy. */
+ *new_pb = *pb;
+ return new_pb;
+}
+
/* JCM - when pb_o_params is used, check the operation type. */
/* JCM - when pb_o_results is used, check the operation type. */
@@ -222,21 +231,8 @@ if ( PBLOCK ->pb_plugin->plg_type != TYPE) return( -1 )
#define SLAPI_PBLOCK_GET_PLUGIN_RELATED_POINTER( pb, element ) \
((pb)->pb_plugin == NULL ? NULL : (pb)->pb_plugin->element)
-/*
- * This ifdef is needed to resolve a gcc 6 issue which throws a false positive
- * here. See also:
https://bugzilla.redhat.com/show_bug.cgi?id=1386445
- *
- * It's a good idea to run this in EL7 to check the overflows etc, but with
- * GCC 6 and lsan to find memory leaks ....
- */
-
int
slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
-#if defined(__has_feature)
-# if __has_feature(address_sanitizer) && __GNUC__ == 6
-__attribute__((no_sanitize("address")))
-# endif
-#endif
{
#ifdef PBLOCK_ANALYTICS
@@ -1759,7 +1755,7 @@ __attribute__((no_sanitize("address")))
/* ldif2db arguments */
case SLAPI_LDIF2DB_FILE:
- (*(char ***)value) = pblock->pb_ldif_files;
+ (*(char ***)value) = pblock->pb_ldif_files;
break;
case SLAPI_LDIF2DB_REMOVEDUPVALS:
(*(int *)value) = pblock->pb_removedupvals;
@@ -2103,8 +2099,11 @@ __attribute__((no_sanitize("address")))
break;
default:
- slapi_log_err(SLAPI_LOG_ERR, "slapi_pblock_get",
- "Unknown parameter block argument %d\n", arg);
+ slapi_log_err(SLAPI_LOG_ERR, "slapi_pblock_get", "Unknown parameter
block argument %d\n", arg);
+#ifdef DEBUG
+ Slapi_PBlock *boom = NULL;
+ void *x = (void *)boom->pb_plugin;
+#endif
return( -1 );
}
@@ -2121,11 +2120,6 @@ __attribute__((no_sanitize("address")))
int
slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value )
-#if defined(__has_feature)
-# if __has_feature(address_sanitizer) && __GNUC__ == 6
-__attribute__((no_sanitize("address")))
-# endif
-#endif
{
#ifdef PBLOCK_ANALYTICS
pblock_analytics_record(pblock, arg);
@@ -3460,7 +3454,7 @@ __attribute__((no_sanitize("address")))
/* ldif2db arguments */
case SLAPI_LDIF2DB_FILE:
- pblock->pb_ldif_file = (char *) value;
+ pblock->pb_ldif_files = (char **) value;
break;
case SLAPI_LDIF2DB_REMOVEDUPVALS:
pblock->pb_removedupvals = *((int *)value);
@@ -3471,6 +3465,12 @@ __attribute__((no_sanitize("address")))
case SLAPI_LDIF2DB_NOATTRINDEXES:
pblock->pb_ldif2db_noattrindexes = *((int *)value);
break;
+ case SLAPI_LDIF2DB_INCLUDE:
+ pblock->pb_ldif_include = (char **)value;
+ break;
+ case SLAPI_LDIF2DB_EXCLUDE:
+ pblock->pb_ldif_exclude = (char **)value;
+ break;
case SLAPI_LDIF2DB_GENERATE_UNIQUEID:
pblock->pb_ldif_generate_uniqueid = *((int *)value);
break;
@@ -3485,6 +3485,9 @@ __attribute__((no_sanitize("address")))
case SLAPI_DB2LDIF_DUMP_UNIQUEID:
pblock->pb_ldif_dump_uniqueid = *((int *)value);
break;
+ case SLAPI_DB2LDIF_FILE:
+ pblock->pb_ldif_file = (char *)value;
+ break;
/* db2ldif/ldif2db/db2bak/bak2db arguments */
case SLAPI_BACKEND_INSTANCE_NAME:
@@ -3741,6 +3744,10 @@ __attribute__((no_sanitize("address")))
default:
slapi_log_err(SLAPI_LOG_ERR, "slapi_pblock_set",
"Unknown parameter block argument %d\n", arg);
+#ifdef DEBUG
+ Slapi_PBlock *boom = NULL;
+ void *x = (void *)boom->pb_plugin;
+#endif
return( -1 );
}
@@ -3814,6 +3821,55 @@ bind_credentials_clear( Connection *conn, PRBool lock_conn,
}
+struct slapi_entry *
+slapi_pblock_get_pw_entry(Slapi_PBlock *pb) {
+ return pb->pb_pw_entry;
+}
+
+void
+slapi_pblock_set_pw_entry(Slapi_PBlock *pb, struct slapi_entry *entry) {
+ pb->pb_pw_entry = entry;
+}
+
+passwdPolicy *
+slapi_pblock_get_pwdpolicy(Slapi_PBlock *pb) {
+ return pb->pwdpolicy;
+}
+
+void
+slapi_pblock_set_pwdpolicy(Slapi_PBlock *pb, passwdPolicy *pwdpolicy) {
+ pb->pwdpolicy = pwdpolicy;
+}
+
+int32_t
+slapi_pblock_get_ldif_dump_replica(Slapi_PBlock *pb) {
+ return pb->pb_ldif_dump_replica;
+}
+
+void
+slapi_pblock_set_ldif_dump_replica(Slapi_PBlock *pb, int32_t dump_replica) {
+ pb->pb_ldif_dump_replica = dump_replica;
+}
+
+void *
+slapi_pblock_get_vattr_context(Slapi_PBlock *pb) {
+ return pb->pb_vattr_context;
+}
+
+void
+slapi_pblock_set_vattr_context(Slapi_PBlock *pb, void *vattr_ctx) {
+ pb->pb_vattr_context = vattr_ctx;
+}
+
+void *
+slapi_pblock_get_op_stack_elem(Slapi_PBlock *pb) {
+ return pb->op_stack_elem;
+}
+
+void
+slapi_pblock_set_op_stack_elem(Slapi_PBlock *pb, void *stack_elem) {
+ pb->op_stack_elem = stack_elem;
+}
/*
* Clear and then set the bind DN and related credentials for the
diff --git a/ldap/servers/slapd/pblock_v3.h b/ldap/servers/slapd/pblock_v3.h
new file mode 100644
index 0000000..df6d347
--- /dev/null
+++ b/ldap/servers/slapd/pblock_v3.h
@@ -0,0 +1,186 @@
+/** BEGIN COPYRIGHT BLOCK
+ * Copyright (C) 2017 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * License: GPL (version 3 or any later version).
+ * See LICENSE for details.
+ * END COPYRIGHT BLOCK **/
+
+/* Hide the pblock implementtation types to keep it truly private */
+
+#pragma once
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "slap.h"
+
+typedef struct slapi_pblock {
+ /* common */
+ Slapi_Backend *pb_backend;
+ Connection *pb_conn;
+ Operation *pb_op;
+ struct slapdplugin *pb_plugin; /* plugin being called */
+ int pb_opreturn;
+ void* pb_object; /* points to data private to plugin */
+ IFP pb_destroy_fn;
+ int pb_requestor_isroot;
+ /* config file */
+ char *pb_config_fname;
+ int pb_config_lineno;
+ int pb_config_argc;
+ char **pb_config_argv;
+ int plugin_tracking;
+
+ /* [pre|post]add arguments */
+ struct slapi_entry *pb_target_entry; /* JCM - Duplicated */
+ struct slapi_entry *pb_existing_dn_entry;
+ struct slapi_entry *pb_existing_uniqueid_entry;
+ struct slapi_entry *pb_parent_entry;
+ struct slapi_entry *pb_newparent_entry;
+
+ /* state of entry before and after add/delete/modify/moddn/modrdn */
+ struct slapi_entry *pb_pre_op_entry;
+ struct slapi_entry *pb_post_op_entry;
+ /* seq access arguments */
+ int pb_seq_type;
+ char *pb_seq_attrname;
+ char *pb_seq_val;
+ /* dbverify argument */
+ char *pb_dbverify_dbdir;
+ /* ldif2db arguments */
+ char *pb_ldif_file;
+ int pb_removedupvals;
+ char **pb_db2index_attrs;
+ int pb_ldif2db_noattrindexes;
+ /* db2ldif arguments */
+ int pb_ldif_printkey;
+ /* ldif2db/db2ldif/db2bak/bak2db args */
+ char *pb_instance_name;
+ Slapi_Task *pb_task;
+ int pb_task_flags;
+ /* matching rule arguments */
+ mrFilterMatchFn pb_mr_filter_match_fn;
+ IFP pb_mr_filter_index_fn;
+ IFP pb_mr_filter_reset_fn;
+ IFP pb_mr_index_fn; /* values and keys are struct berval ** */
+ char* pb_mr_oid;
+ char* pb_mr_type;
+ struct berval* pb_mr_value;
+ struct berval** pb_mr_values;
+ struct berval** pb_mr_keys;
+ unsigned int pb_mr_filter_reusable;
+ int pb_mr_query_operator;
+ unsigned int pb_mr_usage;
+
+ /* arguments for password storage scheme (kexcoff) */
+ char *pb_pwd_storage_scheme_user_passwd;
+ char *pb_pwd_storage_scheme_db_passwd;
+
+ /* controls we know about */
+ int pb_managedsait;
+
+ /* additional fields for plugin_internal_ldap_ops */
+ /* result code of internal ldap_operation */
+ int pb_internal_op_result;
+ /* pointer to array of results returned on search */
+ Slapi_Entry **pb_plugin_internal_search_op_entries;
+ char **pb_plugin_internal_search_op_referrals;
+ void *pb_plugin_identity; /* identifies plugin for internal operation */
+ char *pb_plugin_config_area; /* optional config area */
+ void *pb_parent_txn; /* parent transaction ID */
+ void *pb_txn; /* transaction ID */
+ IFP pb_txn_ruv_mods_fn; /* Function to fetch RUV mods for txn */
+
+ /* Size of the database on disk, in kilobytes */
+ unsigned int pb_dbsize;
+
+ /* THINGS BELOW THIS LINE EXIST ONLY IN SLAPI v2 (slapd 4.0+) */
+
+ /* ldif2db: array of files to import all at once */
+ char **pb_ldif_files;
+
+ char **pb_ldif_include;
+ char **pb_ldif_exclude;
+ int pb_ldif_dump_replica;
+ int pb_ldif_dump_uniqueid; /* dump uniqueid during db2ldif */
+ int pb_ldif_generate_uniqueid; /* generate uniqueid during db2ldif */
+ char* pb_ldif_namespaceid; /* used for name based uniqueid generation */
+ int pb_ldif_encrypt; /* used to enable encrypt/decrypt on import and
export */
+ /*
+ * notes to log with RESULT line in the access log
+ * these are actually stored as a bitmap; see slapi-plugin.h for
+ * defined notes.
+ */
+ unsigned int pb_operation_notes;
+ /*
+ * slapd command line arguments
+ */
+ int pb_slapd_argc;
+ char** pb_slapd_argv;
+ char *pb_slapd_configdir; /* the config directory passed to slapd on the command line
*/
+ LDAPControl **pb_ctrls_arg; /* allows to pass controls as arguments before
+ operation object is created */
+ int pb_dse_dont_add_write; /* if true, the dse is not written when an entry is added
*/
+ int pb_dse_add_merge; /* if true, if a duplicate entry is found when adding, the
+ new values are merged into the old entry */
+ int pb_dse_dont_check_dups; /* if false, use the "enhanced" version of
str2entry to catch
+ more errors when adding dse entries; this can only be
done
+ after the schema and syntax and matching rule plugins
are
+ running */
+ int pb_dse_is_primary_file; /* for read callbacks: non-zero for primary file */
+ int pb_schema_flags; /* schema flags */
+ /* . check/load info (schema reload task) */
+ /* . refresh user defined schema */
+
+ /* NEW in 5.0 for getting back the backend result in frontend */
+ int pb_result_code; /* operation result code */
+ char * pb_result_text; /* result text when available */
+ char * pb_result_matched; /* macthed dn when NO SUCH OBJECT error */
+ int pb_nentries; /* number of entries to be returned */
+ struct berval **urls; /* urls of referrals to be returned */
+
+ /*
+ * wire import (fast replica init) arguments
+ */
+ struct slapi_entry *pb_import_entry;
+ int pb_import_state;
+
+ int pb_destroy_content; /* flag to indicate that pblock content should be
+ destroyed when pblock is destroyed */
+ int pb_dse_reapply_mods; /* if true, dse_modify will reapply mods after modify
callback */
+ char * pb_urp_naming_collision_dn; /* replication naming conflict removal */
+ char * pb_urp_tombstone_uniqueid; /* replication change tombstone */
+ int pb_server_running; /* indicate that server is running */
+ int pb_backend_count; /* instance count involved in the op */
+
+ /* For password policy control */
+ int pb_pwpolicy_ctrl;
+ void *pb_vattr_context; /* hold the vattr_context for roles/cos */
+
+ int *pb_substrlens; /* user specified minimum substr search key lengths:
+ * nsSubStrBegin, nsSubStrMiddle, nsSubStrEnd
+ */
+ int pb_plugin_enabled; /* nsslapd-pluginEnabled: on|off */
+ /* used in plugin init; pb_plugin is not ready, then */
+ LDAPControl **pb_search_ctrls; /* for search operations, allows plugins to provide
+ controls to pass for each entry or referral
returned */
+ IFP pb_mr_index_sv_fn; /* values and keys are Slapi_Value ** */
+ int pb_syntax_filter_normalized; /* the syntax filter types/values are already
normalized */
+ void *pb_syntax_filter_data; /* extra data to pass to a syntax plugin function
*/
+ int pb_paged_results_index; /* stash SLAPI_PAGED_RESULTS_INDEX */
+ int pb_paged_results_cookie; /* stash SLAPI_PAGED_RESULTS_COOKIE */
+ passwdPolicy *pwdpolicy;
+ void *op_stack_elem;
+
+ /* For ACI Target Check */
+ int pb_aci_target_check; /* this flag prevents duplicate checking of ACI's target
existence */
+
+ struct slapi_entry *pb_pw_entry; /* stash dup'ed entry that shadow info is
added/replaced */
+#ifdef PBLOCK_ANALYTICS
+ uint32_t analytics_init;
+ PLHashTable *analytics;
+#endif
+} slapi_pblock;
+
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index 420c306..63ac056 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -845,7 +845,7 @@ typedef struct _plugin_dep_type{
typedef struct _plugin_dep_config {
char *name;
char *type;
- Slapi_PBlock pb;
+ Slapi_PBlock *pb;
struct slapdplugin *plugin;
Slapi_Entry *e;
int entry_created;
@@ -1094,7 +1094,7 @@ plugin_start(Slapi_Entry *entry, char *returntext)
plugin_dep_config *config = NULL;
plugin_dep_type the_plugin_type;
plugin_dep_type plugin_head = 0;
- Slapi_PBlock pb;
+ Slapi_PBlock *pb;
Slapi_Entry *plugin_entry;
struct slapdplugin *plugin;
char *value;
@@ -1132,9 +1132,9 @@ plugin_start(Slapi_Entry *entry, char *returntext)
continue;
}
- pblock_init(&pb);
- slapi_pblock_set( &pb, SLAPI_ARGC, &plugin->plg_argc);
- slapi_pblock_set( &pb, SLAPI_ARGV, &plugin->plg_argv);
+ pb = slapi_pblock_new();
+ slapi_pblock_set( pb, SLAPI_ARGC, &plugin->plg_argc);
+ slapi_pblock_set( pb, SLAPI_ARGV, &plugin->plg_argv);
config[plugin_index].pb = pb;
config[plugin_index].e = ep->e;
@@ -1150,10 +1150,10 @@ plugin_start(Slapi_Entry *entry, char *returntext)
* because these two items are stored in the operation parameters.
*/
Operation *op = internal_operation_new(SLAPI_OPERATION_ADD, 0);
- slapi_pblock_set(&(config[plugin_index].pb), SLAPI_OPERATION, op);
- slapi_pblock_set(&(config[plugin_index].pb), SLAPI_TARGET_SDN,
+ slapi_pblock_set(config[plugin_index].pb, SLAPI_OPERATION, op);
+ slapi_pblock_set(config[plugin_index].pb, SLAPI_TARGET_SDN,
(void*)(slapi_entry_get_sdn_const(plugin_entry)));
- slapi_pblock_set(&(config[plugin_index].pb), SLAPI_ADD_ENTRY,
+ slapi_pblock_set(config[plugin_index].pb, SLAPI_ADD_ENTRY,
plugin_entry );
/* Pass the plugin alternate config area DN in SLAPI_PLUGIN_CONFIG_AREA. */
@@ -1161,7 +1161,7 @@ plugin_start(Slapi_Entry *entry, char *returntext)
if(value){
config[plugin_index].config_area = value;
value = NULL;
- slapi_pblock_set(&(config[plugin_index].pb), SLAPI_PLUGIN_CONFIG_AREA,
+ slapi_pblock_set(config[plugin_index].pb, SLAPI_PLUGIN_CONFIG_AREA,
config[plugin_index].config_area);
}
@@ -1251,8 +1251,9 @@ plugin_start(Slapi_Entry *entry, char *returntext)
i++;
}
- if(!satisfied)
+ if(!satisfied) {
continue;
+ }
}
/*
@@ -1276,8 +1277,9 @@ plugin_start(Slapi_Entry *entry, char *returntext)
i++;
}
- if(!satisfied)
+ if(!satisfied) {
continue;
+ }
}
/**** This plugins dependencies have now been satisfied ****/
@@ -1294,10 +1296,10 @@ plugin_start(Slapi_Entry *entry, char *returntext)
* Put the plugin into the temporary pblock so the startup functions have
* access to the real plugin for registering callbacks, task, etc.
*/
- slapi_pblock_set(&(config[plugin_index].pb), SLAPI_PLUGIN,
config[plugin_index].plugin);
+ slapi_pblock_set(config[plugin_index].pb, SLAPI_PLUGIN,
config[plugin_index].plugin);
ret = plugin_call_one( config[plugin_index].plugin, SLAPI_PLUGIN_START_FN,
- &(config[plugin_index].pb));
- pblock_done(&(config[plugin_index].pb));
+ config[plugin_index].pb);
+ // slapi_pblock_destroy(config[plugin_index].pb);
if(ret){
/*
@@ -1335,8 +1337,8 @@ plugin_start(Slapi_Entry *entry, char *returntext)
index++;
}
}
- } else {
- pblock_done(&(config[plugin_index].pb));
+ // } else {
+ // /slapi_pblock_destroy(config[plugin_index].pb);
}
/* decrement the type counter for this plugin type */
@@ -1428,7 +1430,7 @@ plugin_free_plugin_dep_config(plugin_dep_config **cfg)
slapi_ch_free_string(&config[index].type);
slapi_ch_free_string(&config[index].name);
slapi_ch_free_string(&config[index].config_area);
- pblock_done(&config[index].pb);
+ slapi_pblock_destroy(config[index].pb);
index++;
}
slapi_ch_free((void**)&config);
@@ -1497,7 +1499,7 @@ static int
plugin_dependency_startall(int argc, char** argv, char *errmsg __attribute__((unused)),
int operation, char** plugin_list)
{
int ret = 0;
- Slapi_PBlock pb;
+ Slapi_PBlock *pb;
int total_plugins = 0;
plugin_dep_config *config = 0;
plugin_dep_type plugin_head = 0;
@@ -1567,9 +1569,9 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg
__attribute__((un
}
}
- pblock_init(&pb);
- slapi_pblock_set( &pb, SLAPI_ARGC, &argc);
- slapi_pblock_set( &pb, SLAPI_ARGV, &argv);
+ pb = slapi_pblock_new();
+ slapi_pblock_set( pb, SLAPI_ARGC, &argc);
+ slapi_pblock_set( pb, SLAPI_ARGV, &argv);
config[plugin_index].pb = pb;
config[plugin_index].e = ep->e;
@@ -1591,10 +1593,10 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg
__attribute__((un
only happens a few times at startup, this is not a very serious
leak - just after the call to plugin_call_one */
Operation *op = internal_operation_new(SLAPI_OPERATION_ADD, 0);
- slapi_pblock_set(&(config[plugin_index].pb), SLAPI_OPERATION, op);
- slapi_pblock_set(&(config[plugin_index].pb), SLAPI_TARGET_SDN,
+ slapi_pblock_set(config[plugin_index].pb, SLAPI_OPERATION, op);
+ slapi_pblock_set(config[plugin_index].pb, SLAPI_TARGET_SDN,
(void*)(slapi_entry_get_sdn_const(plugin_entry)));
- slapi_pblock_set(&(config[plugin_index].pb), SLAPI_ADD_ENTRY,
+ slapi_pblock_set(config[plugin_index].pb, SLAPI_ADD_ENTRY,
plugin_entry );
/* Pass the plugin alternate config area DN in SLAPI_PLUGIN_CONFIG_AREA. */
@@ -1603,7 +1605,7 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg
__attribute__((un
{
config[plugin_index].config_area = value;
value = NULL;
- slapi_pblock_set(&(config[plugin_index].pb), SLAPI_PLUGIN_CONFIG_AREA,
+ slapi_pblock_set(config[plugin_index].pb, SLAPI_PLUGIN_CONFIG_AREA,
config[plugin_index].config_area);
}
@@ -1711,8 +1713,9 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg
__attribute__((un
i++;
}
- if(!satisfied)
+ if(!satisfied) {
continue;
+ }
}
/*
@@ -1743,8 +1746,9 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg
__attribute__((un
i++;
}
- if(!satisfied)
+ if(!satisfied) {
continue;
+ }
}
/**** This plugins dependencies have now been satisfied ****/
@@ -1759,15 +1763,15 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg
__attribute__((un
if(!config[plugin_index].entry_created)
{
int plugin_actions = 0;
- Slapi_PBlock newpb = {0};
+ Slapi_PBlock *newpb = slapi_pblock_new();
Slapi_Entry *newe;
newe = slapi_entry_dup( config[plugin_index].e );
- slapi_add_entry_internal_set_pb(&newpb, newe, NULL,
+ slapi_add_entry_internal_set_pb(newpb, newe, NULL,
plugin_get_default_component_id(), plugin_actions);
- slapi_pblock_set(&newpb, SLAPI_TARGET_SDN,
(void*)slapi_entry_get_sdn_const(newe));
- slapi_add_internal_pb(&newpb);
- pblock_done(&newpb);
+ slapi_pblock_set(newpb, SLAPI_TARGET_SDN, (void*)slapi_entry_get_sdn_const(newe));
+ slapi_add_internal_pb(newpb);
+ slapi_pblock_destroy(newpb);
config[plugin_index].entry_created = 1;
}
@@ -1787,8 +1791,8 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg
__attribute__((un
* Put the plugin into the temporary pblock so the startup functions have
* access to the real plugin for registering callbacks, tasks, etc.
*/
- slapi_pblock_set(&(config[plugin_index].pb), SLAPI_PLUGIN,
config[plugin_index].plugin);
- ret = plugin_call_one( config[plugin_index].plugin, operation,
&(config[plugin_index].pb));
+ slapi_pblock_set(config[plugin_index].pb, SLAPI_PLUGIN,
config[plugin_index].plugin);
+ ret = plugin_call_one( config[plugin_index].plugin, operation,
config[plugin_index].pb);
/* We used to call pblock done here, bet we try to restart
* the plugin. If we call done on the pb here, the next attempt
@@ -1817,7 +1821,10 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg
__attribute__((un
* because at this point we *have* started correctly, so we
* can now free this.
*/
- pblock_done(&(config[plugin_index].pb));
+ /* This is freed in free_plugin_dep_config */
+ /*
+ slapi_pblock_destroy(config[plugin_index].pb);
+ */
/* Add this plugin to the shutdown list */
@@ -1843,7 +1850,8 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg
__attribute__((un
}
}
} else { /* if (enabled) == false */
- pblock_done(&(config[plugin_index].pb));
+ /* slapi_pblock_destroy(config[plugin_index].pb); */
+ /* This is freed in plugin_free_plugin_dep_config for us */
}
/* decrement the type counter for this plugin type */
@@ -1912,7 +1920,7 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg
__attribute__((un
void
plugin_dependency_closeall(void)
{
- Slapi_PBlock pb;
+ Slapi_PBlock *pb;
int plugins_closed = 0;
int index = 0;
@@ -1930,13 +1938,13 @@ plugin_dependency_closeall(void)
if(global_plugin_shutdown_order[index].name)
{
if(!global_plugin_shutdown_order[index].removed){
- pblock_init(&pb);
+ pb = slapi_pblock_new();
plugin_set_stopped(global_plugin_shutdown_order[index].plugin);
plugin_op_all_finished(global_plugin_shutdown_order[index].plugin);
- plugin_call_one( global_plugin_shutdown_order[index].plugin, SLAPI_PLUGIN_CLOSE_FN,
&pb);
+ plugin_call_one( global_plugin_shutdown_order[index].plugin, SLAPI_PLUGIN_CLOSE_FN,
pb);
/* set plg_closed to 1 to prevent any further plugin pre/post op function calls */
global_plugin_shutdown_order[index].plugin->plg_closed = 1;
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
}
plugins_closed++;
@@ -2851,7 +2859,7 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid
*group,
struct slapi_componentid *cid = NULL;
const char *existname = 0;
slapi_plugin_init_fnptr initfunc = p_initfunc;
- Slapi_PBlock pb = {0};
+ Slapi_PBlock *pb = NULL;
int status = 0;
int enabled = 1;
char *configdir = 0;
@@ -3074,16 +3082,18 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid
*group,
PR_snprintf(attrname, sizeof(attrname), "%s%d", ATTR_PLUGIN_ARG, ++ii);
} while (skipped < MAXSKIPPED);
- slapi_pblock_set(&pb, SLAPI_PLUGIN, plugin);
- slapi_pblock_set(&pb, SLAPI_PLUGIN_VERSION, (void *)SLAPI_PLUGIN_CURRENT_VERSION);
+ pb = slapi_pblock_new();
+
+ slapi_pblock_set(pb, SLAPI_PLUGIN, plugin);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, (void *)SLAPI_PLUGIN_CURRENT_VERSION);
cid = generate_componentid (plugin,NULL);
/* We take a copy of the pointer to this so we can free it correctly. */
plugin->plg_identity = cid;
- slapi_pblock_set(&pb, SLAPI_PLUGIN_IDENTITY, (void*)cid);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_IDENTITY, (void*)cid);
configdir = config_get_configdir();
- slapi_pblock_set(&pb, SLAPI_CONFIG_DIRECTORY, configdir);
+ slapi_pblock_set(pb, SLAPI_CONFIG_DIRECTORY, configdir);
/* see if the plugin is enabled or not */
if ((value = slapi_entry_attr_get_charptr(plugin_entry,
@@ -3097,11 +3107,11 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid
*group,
enabled = 1;
}
- slapi_pblock_set(&pb, SLAPI_PLUGIN_ENABLED, &enabled);
- slapi_pblock_set(&pb, SLAPI_PLUGIN_CONFIG_ENTRY, plugin_entry);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_ENABLED, &enabled);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_CONFIG_ENTRY, plugin_entry);
plugin->plg_op_counter = slapi_counter_new();
- if (enabled && (*initfunc)(&pb) != 0)
+ if (enabled && (*initfunc)(pb) != 0)
{
slapi_log_err(SLAPI_LOG_ERR, "plugin_setup", "Init function
\"%s\" for \"%s\" plugin in library \"%s\" failed\n",
plugin->plg_initfunc, plugin->plg_name, plugin->plg_libpath);
@@ -3143,7 +3153,7 @@ PLUGIN_CLEANUP:
plugin_free(plugin);
}
slapi_ch_free((void **)&configdir);
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
return status;
}
@@ -3477,7 +3487,6 @@ plugin_remove_plugins(struct slapdplugin *plugin_entry, char
*plugin_type __attr
/*
* Call the close function, cleanup the hashtable & the global
shutdown list
*/
- Slapi_PBlock pb = {0};
plugin_set_stopped(plugin);
if (slapi_counter_get_value(plugin->plg_op_counter) > 0){
/*
@@ -3486,7 +3495,9 @@ plugin_remove_plugins(struct slapdplugin *plugin_entry, char
*plugin_type __attr
*/
return PLUGIN_BUSY;
}
- plugin_call_one( plugin, SLAPI_PLUGIN_CLOSE_FN, &pb);
+ Slapi_PBlock *pb = slapi_pblock_new();
+ plugin_call_one( plugin, SLAPI_PLUGIN_CLOSE_FN, pb);
+ slapi_pblock_destroy(pb);
if(plugin_prev){
plugin_prev->plg_next = plugin_next;
@@ -3715,10 +3726,11 @@ static PRBool
plugin_invoke_plugin_pb (struct slapdplugin *plugin, int operation, Slapi_PBlock *pb)
{
Slapi_DN *target_spec;
+ Operation *pb_op = NULL;
PRBool rc;
PR_ASSERT (plugin);
- PR_ASSERT (pb);
+ PR_ASSERT (pb);
/* we always allow initialization and cleanup operations */
if (operation == SLAPI_PLUGIN_START_FN ||
@@ -3731,9 +3743,12 @@ plugin_invoke_plugin_pb (struct slapdplugin *plugin, int operation,
Slapi_PBlock
operation == SLAPI_PLUGIN_BE_POST_BACKUP_FN)
return PR_TRUE;
- PR_ASSERT (pb->pb_op);
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
- target_spec = operation_get_target_spec (pb->pb_op);
+
+ PR_ASSERT (pb_op);
+
+ target_spec = operation_get_target_spec (pb_op);
rc = plugin_invoke_plugin_sdn (plugin, operation, pb, target_spec);
@@ -3759,6 +3774,9 @@ plugin_invoke_plugin_sdn (struct slapdplugin *plugin, int operation
__attribute_
return PR_FALSE;
}
+ Operation *pb_op;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+
/* get configuration from the group plugin if necessary */
config = plugin_get_config (plugin);
slapi_pblock_get(pb, SLAPI_BIND_METHOD, &method);
@@ -3768,13 +3786,14 @@ plugin_invoke_plugin_sdn (struct slapdplugin *plugin, int
operation __attribute_
int repl_op;
slapi_pblock_get (pb, SLAPI_IS_REPLICATED_OPERATION, &repl_op);
- if (repl_op)
+ if (repl_op) {
return PR_FALSE;
+ }
}
- if (pb->pb_op)
+ if (pb_op)
{
- op = operation_get_type(pb->pb_op);
+ op = operation_get_type(pb_op);
if (op == SLAPI_OPERATION_BIND || op == SLAPI_OPERATION_UNBIND)
{
@@ -4331,7 +4350,7 @@ bail:
int
slapi_set_plugin_default_config(const char *type, Slapi_Value *value)
{
- Slapi_PBlock pb = {0};
+ Slapi_PBlock *pb = slapi_pblock_new();
Slapi_Entry **entries = NULL;
int rc = LDAP_SUCCESS;
char **search_attrs = NULL; /* used by search */
@@ -4343,7 +4362,7 @@ slapi_set_plugin_default_config(const char *type, Slapi_Value
*value)
charray_add(&search_attrs, slapi_ch_strdup(type));
/* cn=plugin default config,cn=config */
- slapi_search_internal_set_pb(&pb,
+ slapi_search_internal_set_pb(pb,
SLAPI_PLUGIN_DEFAULT_CONFIG, /* Base DN (normalized) */
LDAP_SCOPE_BASE,
"(objectclass=*)",
@@ -4353,9 +4372,9 @@ slapi_set_plugin_default_config(const char *type, Slapi_Value
*value)
NULL, /* UniqueID */
(void *)plugin_get_default_component_id(),
0);
- slapi_search_internal_pb(&pb);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
+ slapi_search_internal_pb(pb);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
if (LDAP_SUCCESS == rc && entries && *entries) {
/* plugin default config entry exists */
int exists = 0;
@@ -4369,8 +4388,8 @@ slapi_set_plugin_default_config(const char *type, Slapi_Value
*value)
exists = 1;
}
}
- slapi_free_search_results_internal(&pb);
- pblock_done(&pb);
+ slapi_free_search_results_internal(pb);
+ slapi_pblock_destroy(pb);
if (!exists) {
/* The argument attr is not in the plugin default config.
@@ -4383,23 +4402,23 @@ slapi_set_plugin_default_config(const char *type, Slapi_Value
*value)
slapi_mods_init(&smods, 1);
slapi_mods_add_mod_values(&smods, LDAP_MOD_ADD, type, va);
- pblock_init(&pb);
- slapi_modify_internal_set_pb(&pb, SLAPI_PLUGIN_DEFAULT_CONFIG,
+ pb = slapi_pblock_new();
+ slapi_modify_internal_set_pb(pb, SLAPI_PLUGIN_DEFAULT_CONFIG,
slapi_mods_get_ldapmods_byref(&smods),
NULL, NULL, /* UniqueID */
(void *)plugin_get_default_component_id(),
0 /* Flags */ );
- slapi_modify_internal_pb(&pb);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
+ slapi_modify_internal_pb(pb);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
slapi_mods_done(&smods);
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
}
} else { /* cn=plugin default config does not exist. Let's add it. */
Slapi_Mods smods;
Slapi_Value *va[2];
- slapi_free_search_results_internal(&pb);
- pblock_done(&pb);
+ slapi_free_search_results_internal(pb);
+ slapi_pblock_destroy(pb);
va[0] = value;
va[1] = NULL;
@@ -4410,15 +4429,15 @@ slapi_set_plugin_default_config(const char *type, Slapi_Value
*value)
"extensibleObject");
slapi_mods_add_mod_values(&smods, LDAP_MOD_ADD, type, va);
- pblock_init(&pb);
- slapi_add_internal_set_pb(&pb, SLAPI_PLUGIN_DEFAULT_CONFIG,
+ pb = slapi_pblock_new();
+ slapi_add_internal_set_pb(pb, SLAPI_PLUGIN_DEFAULT_CONFIG,
slapi_mods_get_ldapmods_byref(&smods), NULL,
(void *)plugin_get_default_component_id(),
0 /* Flags */ );
- slapi_add_internal_pb(&pb);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
+ slapi_add_internal_pb(pb);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
slapi_mods_done(&smods);
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
}
charray_free(search_attrs);
@@ -4434,7 +4453,6 @@ slapi_set_plugin_default_config(const char *type, Slapi_Value
*value)
int
slapi_get_plugin_default_config(char *type, Slapi_ValueSet **valueset)
{
- Slapi_PBlock pb = {0};
Slapi_Entry **entries = NULL;
int rc = LDAP_PARAM_ERROR;
char **search_attrs = NULL; /* used by search */
@@ -4445,8 +4463,10 @@ slapi_get_plugin_default_config(char *type, Slapi_ValueSet
**valueset)
charray_add(&search_attrs, slapi_ch_strdup(type));
+ Slapi_PBlock *pb = slapi_pblock_new();
+
/* cn=plugin default config,cn=config */
- slapi_search_internal_set_pb(&pb,
+ slapi_search_internal_set_pb(pb,
SLAPI_PLUGIN_DEFAULT_CONFIG, /* Base DN (normalized) */
LDAP_SCOPE_BASE,
"(objectclass=*)",
@@ -4456,9 +4476,9 @@ slapi_get_plugin_default_config(char *type, Slapi_ValueSet
**valueset)
NULL, /* UniqueID */
(void *)plugin_get_default_component_id(),
0);
- slapi_search_internal_pb(&pb);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
+ slapi_search_internal_pb(pb);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
if (LDAP_SUCCESS == rc && entries && *entries) {
/* default config entry exists */
/* retrieve attribute values from the entry */
@@ -4470,8 +4490,8 @@ slapi_get_plugin_default_config(char *type, Slapi_ValueSet
**valueset)
rc = LDAP_NO_SUCH_ATTRIBUTE;
}
}
- slapi_free_search_results_internal(&pb);
- pblock_done(&pb);
+ slapi_free_search_results_internal(pb);
+ slapi_pblock_destroy(pb);
charray_free(search_attrs);
return rc;
@@ -4479,9 +4499,11 @@ slapi_get_plugin_default_config(char *type, Slapi_ValueSet
**valueset)
void
slapi_set_plugin_open_rootdn_bind(Slapi_PBlock *pb){
- struct pluginconfig *config = &pb->pb_plugin->plg_conf;
+ struct slapdplugin *plug;
+ slapi_pblock_get(pb, SLAPI_PLUGIN, &plug);
+ struct pluginconfig *config = &plug->plg_conf;
- ptd_set_special_data(&(config->plgc_bind_subtrees), PLGC_DATA_BIND_ROOT);
+ ptd_set_special_data(&(config->plgc_bind_subtrees), PLGC_DATA_BIND_ROOT);
}
PRBool
@@ -4559,8 +4581,11 @@ slapi_plugin_running(Slapi_PBlock *pb)
{
int rc = 0;
- if(pb->pb_plugin){
- rc = pb->pb_plugin->plg_started;
+ struct slapdplugin *plugin;
+ slapi_pblock_get(pb, SLAPI_PLUGIN, &plugin);
+
+ if(plugin){
+ rc = plugin->plg_started;
}
return rc;
diff --git a/ldap/servers/slapd/plugin_internal_op.c
b/ldap/servers/slapd/plugin_internal_op.c
index 22c1807..c401918 100644
--- a/ldap/servers/slapd/plugin_internal_op.c
+++ b/ldap/servers/slapd/plugin_internal_op.c
@@ -202,7 +202,6 @@ slapi_seq_callback( const char *ibase,
plugin_referral_entry_callback ref_callback)
{
int r;
- Slapi_PBlock pb = {0};
if (ibase == NULL)
{
@@ -211,11 +210,13 @@ slapi_seq_callback( const char *ibase,
return -1;
}
- slapi_seq_internal_set_pb(&pb, (char *)ibase, type, attrname, val, attrs,
attrsonly, controls,
+ Slapi_PBlock *pb = slapi_pblock_new();
+
+ slapi_seq_internal_set_pb(pb, (char *)ibase, type, attrname, val, attrs, attrsonly,
controls,
plugin_get_default_component_id(), 0);
- r= seq_internal_callback_pb (&pb, callback_data, res_callback, srch_callback,
ref_callback);
- pblock_done(&pb);
+ r= seq_internal_callback_pb (pb, callback_data, res_callback, srch_callback,
ref_callback);
+ slapi_pblock_destroy(pb);
return r;
}
@@ -440,17 +441,15 @@ slapi_search_internal_callback(const char *ibase,
plugin_search_entry_callback srch_callback,
plugin_referral_entry_callback ref_callback)
{
- Slapi_PBlock pb;
+ Slapi_PBlock *pb = slapi_pblock_new();
int rc = 0;
- pblock_init(&pb);
-
- slapi_search_internal_set_pb (&pb, ibase, scope, ifstr, attrs, attrsonly,
+ slapi_search_internal_set_pb (pb, ibase, scope, ifstr, attrs, attrsonly,
controls, NULL, plugin_get_default_component_id(), 0);
- rc = search_internal_callback_pb (&pb, callback_data, res_callback,
+ rc = search_internal_callback_pb (pb, callback_data, res_callback,
srch_callback, ref_callback);
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
return (rc);
}
@@ -482,30 +481,34 @@ slapi_search_internal(const char *base,
void
slapi_free_search_results_internal(Slapi_PBlock *pb)
{
- int i;
-
if(pb == NULL)
{
return;
}
- if(pb->pb_plugin_internal_search_op_entries != NULL)
+ Slapi_Entry **op_entries = NULL;
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &op_entries);
+
+ if(op_entries != NULL)
{
- for(i=0; pb->pb_plugin_internal_search_op_entries[i] != NULL; i++)
+ for(size_t i = 0; op_entries[i] != NULL; i++)
{
- slapi_entry_free(pb->pb_plugin_internal_search_op_entries[i]);
+ slapi_entry_free(op_entries[i]);
}
- slapi_ch_free((void**)&(pb->pb_plugin_internal_search_op_entries));
+ slapi_ch_free((void**)&(op_entries));
}
+ char **op_referrals = NULL;
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS, &op_referrals);
+
/* free v3 referrals made from result handler */
- if(pb->pb_plugin_internal_search_op_referrals != NULL)
+ if(op_referrals != NULL)
{
- for(i=0; pb->pb_plugin_internal_search_op_referrals[i] != NULL; i++)
+ for(size_t i = 0; op_referrals[i] != NULL; i++)
{
-
slapi_ch_free((void**)&(pb->pb_plugin_internal_search_op_referrals[i]));
+ slapi_ch_free((void**)&(op_referrals[i]));
}
- slapi_ch_free((void**)&(pb->pb_plugin_internal_search_op_referrals));
+ slapi_ch_free((void**)&(op_referrals));
}
}
diff --git a/ldap/servers/slapd/plugin_mr.c b/ldap/servers/slapd/plugin_mr.c
index d216d12..614eba7 100644
--- a/ldap/servers/slapd/plugin_mr.c
+++ b/ldap/servers/slapd/plugin_mr.c
@@ -167,45 +167,86 @@ slapi_mr_indexer_create (Slapi_PBlock* opb)
{
/* call each plugin, until one is able to handle this request. */
rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
- for (mrp = get_plugin_list(PLUGIN_LIST_MATCHINGRULE); mrp != NULL; mrp =
mrp->plg_next)
- {
- IFP indexFn = NULL;
- IFP indexSvFn = NULL;
- Slapi_PBlock pb;
- memcpy (&pb, opb, sizeof(Slapi_PBlock));
- slapi_pblock_set(&pb, SLAPI_PLUGIN, mrp);
- if (slapi_pblock_get(&pb, SLAPI_PLUGIN_MR_INDEXER_CREATE_FN, &createFn)) {
- /* plugin not a matchingrule type */
- continue;
- }
- if (createFn && !createFn(&pb)) {
- slapi_pblock_get(&pb, SLAPI_PLUGIN_MR_INDEX_FN, &indexFn);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_MR_INDEX_SV_FN, &indexSvFn);
- if (indexFn || indexSvFn) {
- /* Success: this plugin can handle it. */
- memcpy(opb, &pb, sizeof (Slapi_PBlock));
- plugin_mr_bind(oid, mrp); /* for future reference */
- rc = 0; /* success */
- break;
- }
-
- }
- }
- if (rc != 0) {
- /* look for a new syntax-style mr plugin */
- struct slapdplugin *pi = plugin_mr_find(oid);
- if (pi) {
- Slapi_PBlock pb;
- memcpy (&pb, opb, sizeof(Slapi_PBlock));
- slapi_pblock_set(&pb, SLAPI_PLUGIN, pi);
- rc = default_mr_indexer_create(&pb);
- if (!rc) {
- memcpy (opb, &pb, sizeof(Slapi_PBlock));
- plugin_mr_bind (oid, pi); /* for future reference */
- }
- }
- }
- }
+ // We need to get the type and usage from the caller.
+ char *type;
+ uint32_t usage;
+ slapi_pblock_get(opb, SLAPI_PLUGIN_MR_TYPE, &type);
+ slapi_pblock_get(opb, SLAPI_PLUGIN_MR_USAGE, &usage);
+ for (mrp = get_plugin_list(PLUGIN_LIST_MATCHINGRULE); mrp != NULL; mrp =
mrp->plg_next)
+ {
+
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_PLUGIN, mrp);
+ /* From filtercmp.c and matchrule.c, these are the values we need to set.
into pb */
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_OID, oid);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_TYPE, type);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_USAGE, &usage);
+
+ /* This is associated with the pb_plugin struct, so it comes with mrp */
+ if (slapi_pblock_get(pb, SLAPI_PLUGIN_MR_INDEXER_CREATE_FN,
&createFn)) {
+ /* plugin not a matchingrule type */
+ slapi_pblock_destroy(pb);
+ continue;
+ }
+
+ if (createFn && !createFn(pb)) {
+ IFP indexFn = NULL;
+ IFP indexSvFn = NULL;
+ /* These however, are in the pblock direct, so we need to copy them.
*/
+ slapi_pblock_get(opb, SLAPI_PLUGIN_MR_INDEX_FN, &indexFn);
+ slapi_pblock_get(opb, SLAPI_PLUGIN_MR_INDEX_SV_FN, &indexSvFn);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_INDEX_FN, indexFn);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_INDEX_SV_FN, indexSvFn);
+ if (indexFn || indexSvFn) {
+ /* Success: this plugin can handle it. */
+ /* call create on the opb? */
+ createFn(opb);
+ plugin_mr_bind(oid, mrp); /* for future reference */
+ rc = 0; /* success */
+ slapi_pblock_destroy(pb);
+ break;
+ }
+ }
+ slapi_pblock_destroy(pb);
+ }
+ if (rc != 0) {
+ /* look for a new syntax-style mr plugin */
+ struct slapdplugin *pi = plugin_mr_find(oid);
+ if (pi) {
+ Slapi_PBlock *pb = slapi_pblock_new();
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_OID, oid);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_TYPE, type);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_USAGE, &usage);
+ slapi_pblock_set(pb, SLAPI_PLUGIN, pi);
+ rc = default_mr_indexer_create(pb);
+ if (!rc) {
+ /* On success, copy the needed values in. These are added by
default_mr_indexer_create */
+ void *pb_object = NULL;
+ IFP destroy_fn = NULL;
+ IFP index_fn = NULL;
+ IFP index_sv_fn = NULL;
+
+ slapi_pblock_get(pb, SLAPI_PLUGIN_OBJECT, &pb_object);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_DESTROY_FN, &destroy_fn);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_MR_INDEX_FN, &index_fn);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_MR_INDEX_SV_FN,
&index_sv_fn);
+
+ /* SLAPI_PLUGIN_MR_INDEXER_CREATE_FN, and
SLAPI_PLUGIN_MR_FILTER_CREATE_FN, are part of pb_plugin */
+ slapi_pblock_set(opb, SLAPI_PLUGIN, pi);
+ slapi_pblock_set(opb, SLAPI_PLUGIN_MR_OID, oid);
+ slapi_pblock_set(opb, SLAPI_PLUGIN_MR_TYPE, type);
+ slapi_pblock_set(opb, SLAPI_PLUGIN_MR_USAGE, &usage);
+ slapi_pblock_set(opb, SLAPI_PLUGIN_OBJECT, pb_object);
+ slapi_pblock_set(opb, SLAPI_PLUGIN_DESTROY_FN, destroy_fn);
+ slapi_pblock_set(opb, SLAPI_PLUGIN_MR_INDEX_FN, index_fn);
+ slapi_pblock_set(opb, SLAPI_PLUGIN_MR_INDEX_SV_FN, index_sv_fn);
+
+ plugin_mr_bind (oid, pi); /* for future reference */
+ }
+ slapi_pblock_destroy(pb);
+ }
+ }
+ }
}
return rc;
}
@@ -574,18 +615,18 @@ plugin_mr_filter_create (mr_filter_t* f)
{
int rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
struct slapdplugin* mrp = plugin_mr_find_registered (f->mrf_oid);
- Slapi_PBlock pb = {0};
+ Slapi_PBlock *pb = slapi_pblock_new();
if (mrp != NULL)
{
- rc = attempt_mr_filter_create (f, mrp, &pb);
+ rc = attempt_mr_filter_create (f, mrp, pb);
}
else
{
/* call each plugin, until one is able to handle this request. */
for (mrp = get_plugin_list(PLUGIN_LIST_MATCHINGRULE); mrp != NULL; mrp =
mrp->plg_next)
{
- if (!(rc = attempt_mr_filter_create (f, mrp, &pb)))
+ if (!(rc = attempt_mr_filter_create (f, mrp, pb)))
{
plugin_mr_bind (f->mrf_oid, mrp); /* for future reference */
break;
@@ -599,10 +640,10 @@ plugin_mr_filter_create (mr_filter_t* f)
if (mrp)
{
/* set the default index create fn */
- slapi_pblock_set(&pb, SLAPI_PLUGIN, mrp);
- slapi_pblock_set(&pb, SLAPI_PLUGIN_MR_FILTER_CREATE_FN,
default_mr_filter_create);
- slapi_pblock_set(&pb, SLAPI_PLUGIN_MR_INDEXER_CREATE_FN,
default_mr_indexer_create);
- if (!(rc = attempt_mr_filter_create (f, mrp, &pb)))
+ slapi_pblock_set(pb, SLAPI_PLUGIN, mrp);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_FILTER_CREATE_FN, default_mr_filter_create);
+ slapi_pblock_set(pb, SLAPI_PLUGIN_MR_INDEXER_CREATE_FN,
default_mr_indexer_create);
+ if (!(rc = attempt_mr_filter_create (f, mrp, pb)))
{
plugin_mr_bind (f->mrf_oid, mrp); /* for future reference */
}
@@ -611,12 +652,13 @@ plugin_mr_filter_create (mr_filter_t* f)
if (!rc)
{
/* This plugin has created the desired filter. */
- slapi_pblock_get (&pb, SLAPI_PLUGIN_MR_FILTER_INDEX_FN, &(f->mrf_index));
- slapi_pblock_get (&pb, SLAPI_PLUGIN_MR_FILTER_REUSABLE,
&(f->mrf_reusable));
- slapi_pblock_get (&pb, SLAPI_PLUGIN_MR_FILTER_RESET_FN, &(f->mrf_reset));
- slapi_pblock_get (&pb, SLAPI_PLUGIN_OBJECT, &(f->mrf_object));
- slapi_pblock_get (&pb, SLAPI_PLUGIN_DESTROY_FN, &(f->mrf_destroy));
+ slapi_pblock_get (pb, SLAPI_PLUGIN_MR_FILTER_INDEX_FN, &(f->mrf_index));
+ slapi_pblock_get (pb, SLAPI_PLUGIN_MR_FILTER_REUSABLE, &(f->mrf_reusable));
+ slapi_pblock_get (pb, SLAPI_PLUGIN_MR_FILTER_RESET_FN, &(f->mrf_reset));
+ slapi_pblock_get (pb, SLAPI_PLUGIN_OBJECT, &(f->mrf_object));
+ slapi_pblock_get (pb, SLAPI_PLUGIN_DESTROY_FN, &(f->mrf_destroy));
}
+ slapi_pblock_destroy(pb);
return rc;
}
diff --git a/ldap/servers/slapd/plugin_syntax.c b/ldap/servers/slapd/plugin_syntax.c
index a045a85..f0d1167 100644
--- a/ldap/servers/slapd/plugin_syntax.c
+++ b/ldap/servers/slapd/plugin_syntax.c
@@ -98,7 +98,6 @@ plugin_call_syntax_filter_ava_sv(
)
{
int rc;
- Slapi_PBlock pipb;
IFP ava_fn = NULL;
slapi_log_err(SLAPI_LOG_FILTER,
@@ -118,14 +117,14 @@ plugin_call_syntax_filter_ava_sv(
return( LDAP_PROTOCOL_ERROR ); /* syntax unkonwn */
}
- pblock_init( &pipb );
- slapi_pblock_set( &pipb, SLAPI_PLUGIN, (void *) a->a_plugin );
+ Slapi_PBlock *pipb = slapi_pblock_new();
+ slapi_pblock_set( pipb, SLAPI_PLUGIN, (void *) a->a_plugin );
if (ava->ava_private) {
int filter_normalized = 0;
int f_flags = 0;
f_flags = *(int *)ava->ava_private;
filter_normalized = f_flags | SLAPI_FILTER_NORMALIZED_VALUE;
- slapi_pblock_set( &pipb, SLAPI_PLUGIN_SYNTAX_FILTER_NORMALIZED,
&filter_normalized );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN_SYNTAX_FILTER_NORMALIZED, &filter_normalized
);
}
rc = -1; /* does not match by default */
@@ -144,10 +143,10 @@ plugin_call_syntax_filter_ava_sv(
/* if the attribute has an ordering matching rule plugin, use that,
otherwise, just use the syntax plugin */
if (a->a_mr_ord_plugin != NULL) {
- slapi_pblock_set( &pipb, SLAPI_PLUGIN, (void *) a->a_mr_ord_plugin );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN, (void *) a->a_mr_ord_plugin );
ava_fn = a->a_mr_ord_plugin->plg_mr_filter_ava;
} else {
- slapi_pblock_set( &pipb, SLAPI_PLUGIN, (void *) a->a_plugin );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN, (void *) a->a_plugin );
ava_fn = a->a_plugin->plg_syntax_filter_ava;
}
/* FALLTHROUGH */
@@ -157,10 +156,10 @@ plugin_call_syntax_filter_ava_sv(
/* if we have an equality matching rule plugin, use that,
otherwise, just use the syntax plugin */
if (a->a_mr_eq_plugin) {
- slapi_pblock_set( &pipb, SLAPI_PLUGIN, (void *) a->a_mr_eq_plugin );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN, (void *) a->a_mr_eq_plugin );
ava_fn = a->a_mr_eq_plugin->plg_mr_filter_ava;
} else {
- slapi_pblock_set( &pipb, SLAPI_PLUGIN, (void *) a->a_plugin );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN, (void *) a->a_plugin );
ava_fn = a->a_plugin->plg_syntax_filter_ava;
}
}
@@ -174,7 +173,7 @@ plugin_call_syntax_filter_ava_sv(
va= valueset_get_valuearray(&a->a_present_values);
}
if(va!=NULL) {
- rc = (*ava_fn)( &pipb, &ava->ava_value, va, ftype, retVal );
+ rc = (*ava_fn)( pipb, &ava->ava_value, va, ftype, retVal );
}
} else {
slapi_log_err(SLAPI_LOG_FILTER,
@@ -191,6 +190,7 @@ plugin_call_syntax_filter_ava_sv(
slapi_log_err(SLAPI_LOG_FILTER,
"plugin_call_syntax_filter_ava", "<= %d\n", rc);
+ slapi_pblock_destroy(pipb);
return( rc );
}
@@ -211,7 +211,6 @@ plugin_call_syntax_filter_sub_sv(
struct subfilt *fsub
)
{
- Slapi_PBlock pipb;
int rc;
IFP sub_fn = NULL;
int filter_normalized = 0;
@@ -230,20 +229,20 @@ plugin_call_syntax_filter_sub_sv(
return( -1 ); /* syntax unkonwn - does not match */
}
- pblock_init( &pipb );
+ Slapi_PBlock *pipb = slapi_pblock_new();
if (pb) {
slapi_pblock_get( pb, SLAPI_PLUGIN_SYNTAX_FILTER_NORMALIZED, &filter_normalized );
- slapi_pblock_set( &pipb, SLAPI_PLUGIN_SYNTAX_FILTER_NORMALIZED,
&filter_normalized );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN_SYNTAX_FILTER_NORMALIZED, &filter_normalized
);
}
- slapi_pblock_set( &pipb, SLAPI_PLUGIN_SYNTAX_FILTER_DATA, fsub );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN_SYNTAX_FILTER_DATA, fsub );
/* use the substr matching rule plugin if available, otherwise, use
the syntax plugin */
if (a->a_mr_sub_plugin) {
- slapi_pblock_set( &pipb, SLAPI_PLUGIN, (void *) a->a_mr_sub_plugin );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN, (void *) a->a_mr_sub_plugin );
sub_fn = a->a_mr_sub_plugin->plg_mr_filter_sub;
} else {
- slapi_pblock_set( &pipb, SLAPI_PLUGIN, (void *) a->a_plugin );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN, (void *) a->a_plugin );
sub_fn = a->a_plugin->plg_syntax_filter_sub;
}
@@ -255,15 +254,18 @@ plugin_call_syntax_filter_sub_sv(
Operation *op = NULL;
/* to pass SLAPI_SEARCH_TIMELIMIT & SLAPI_OPINITATED_TIME */
slapi_pblock_get( pb, SLAPI_OPERATION, &op );
- slapi_pblock_set( &pipb, SLAPI_OPERATION, op );
+ slapi_pblock_set( pipb, SLAPI_OPERATION, op );
}
- rc = (*sub_fn)( &pipb, fsub->sf_initial, fsub->sf_any, fsub->sf_final,
va);
+ rc = (*sub_fn)( pipb, fsub->sf_initial, fsub->sf_any, fsub->sf_final, va);
} else {
rc = -1;
}
slapi_log_err(SLAPI_LOG_FILTER, "plugin_call_syntax_filter_sub_sv",
"<= %d\n",
rc);
+ /* Operation is owned by our caller: We need to null it now, to prevent the free */
+ slapi_pblock_set( pipb, SLAPI_OPERATION, NULL );
+ slapi_pblock_destroy(pipb);
return( rc );
}
@@ -559,20 +561,21 @@ slapi_call_syntax_values2keys_sv(
)
{
int rc;
- Slapi_PBlock pipb;
+ Slapi_PBlock *pipb = slapi_pblock_new();
struct slapdplugin *pi = vpi;
slapi_log_err(SLAPI_LOG_FILTER, "slapi_call_syntax_values2keys_sv",
"=>\n");
- pblock_init( &pipb );
- slapi_pblock_set( &pipb, SLAPI_PLUGIN, vpi );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN, vpi );
*ivals = NULL;
rc = -1; /* means no values2keys function */
if ( pi != NULL && pi->plg_syntax_values2keys != NULL ) {
- rc = pi->plg_syntax_values2keys( &pipb, vals, ivals, ftype );
+ rc = pi->plg_syntax_values2keys( pipb, vals, ivals, ftype );
}
+ slapi_pblock_destroy(pipb);
+
slapi_log_err(SLAPI_LOG_FILTER,
"slapi_call_syntax_values2keys_sv", "<= %d\n", rc);
return( rc );
@@ -646,9 +649,11 @@ slapi_attr_values2keys_sv(
int ftype
)
{
- Slapi_PBlock pb;
- pblock_init(&pb);
- return slapi_attr_values2keys_sv_pb(sattr, vals, ivals, ftype, &pb);
+ int result = 0;
+ Slapi_PBlock *pb = slapi_pblock_new();
+ result = slapi_attr_values2keys_sv_pb(sattr, vals, ivals, ftype, pb);
+ slapi_pblock_destroy(pb);
+ return result;
}
SLAPI_DEPRECATED int
@@ -729,20 +734,20 @@ slapi_call_syntax_assertion2keys_ava_sv(
)
{
int rc;
- Slapi_PBlock pipb;
+ Slapi_PBlock *pipb = slapi_pblock_new();
struct slapdplugin *pi = vpi;
slapi_log_err(SLAPI_LOG_FILTER,
"slapi_call_syntax_assertion2keys_ava_sv" , "=>\n");
- pblock_init( &pipb );
- slapi_pblock_set( &pipb, SLAPI_PLUGIN, vpi );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN, vpi );
rc = -1; /* means no assertion2keys function */
if ( pi->plg_syntax_assertion2keys_ava != NULL ) {
- rc = pi->plg_syntax_assertion2keys_ava( &pipb, val, ivals, ftype );
+ rc = pi->plg_syntax_assertion2keys_ava( pipb, val, ivals, ftype );
}
+ slapi_pblock_destroy(pipb);
slapi_log_err(SLAPI_LOG_FILTER,
"slapi_call_syntax_assertion2keys_ava_sv", "<= %d\n", rc);
return( rc );
@@ -757,7 +762,6 @@ slapi_attr_assertion2keys_ava_sv(
)
{
int rc;
- Slapi_PBlock pipb;
struct slapdplugin *pi = NULL;
IFP a2k_fn = NULL;
@@ -787,13 +791,14 @@ slapi_attr_assertion2keys_ava_sv(
goto done;
}
- pblock_init( &pipb );
- slapi_pblock_set( &pipb, SLAPI_PLUGIN, pi );
+ Slapi_PBlock *pipb = slapi_pblock_new();
+ slapi_pblock_set( pipb, SLAPI_PLUGIN, pi );
rc = -1; /* means no assertion2keys function */
if ( a2k_fn != NULL ) {
- rc = (*a2k_fn)( &pipb, val, ivals, ftype );
+ rc = (*a2k_fn)( pipb, val, ivals, ftype );
}
+ slapi_pblock_destroy(pipb);
done:
slapi_log_err(SLAPI_LOG_FILTER,
"slapi_attr_assertion2keys_ava_sv", "=> %d\n", rc);
@@ -846,22 +851,23 @@ slapi_call_syntax_assertion2keys_sub_sv(
)
{
int rc;
- Slapi_PBlock pipb;
+ Slapi_PBlock *pipb = slapi_pblock_new();
struct slapdplugin *pi = vpi;
slapi_log_err(SLAPI_LOG_FILTER,
"slapi_call_syntax_assertion2keys_sub_sv", "=>\n");
- pblock_init( &pipb );
- slapi_pblock_set( &pipb, SLAPI_PLUGIN, vpi );
+ slapi_pblock_set( pipb, SLAPI_PLUGIN, vpi );
rc = -1; /* means no assertion2keys function */
*ivals = NULL;
if ( pi->plg_syntax_assertion2keys_sub != NULL ) {
- rc = pi->plg_syntax_assertion2keys_sub( &pipb, initial, any,
+ rc = pi->plg_syntax_assertion2keys_sub( pipb, initial, any,
final, ivals );
}
+ slapi_pblock_destroy(pipb);
+
slapi_log_err(SLAPI_LOG_FILTER,
"slapi_call_syntax_assertion2keys_sub_sv", "<= %d\n", rc);
return( rc );
@@ -890,7 +896,8 @@ slapi_attr_assertion2keys_sub_sv_pb(
)
{
int rc;
- Slapi_PBlock pipb;
+ Slapi_PBlock *pipb = NULL;
+ Slapi_PBlock *work_pb = NULL;
struct slapdplugin *pi = NULL;
struct slapdplugin *origpi = NULL;
IFP a2k_fn = NULL;
@@ -910,21 +917,24 @@ slapi_attr_assertion2keys_sub_sv_pb(
a2k_fn = sattr->a_plugin->plg_syntax_assertion2keys_sub;
}
if (NULL == pb) {
- pblock_init( &pipb );
- pb = &pipb;
+ pipb = slapi_pblock_new();
+ work_pb = pipb;
} else {
/* back up the original slapdplugin if any */
slapi_pblock_get(pb, SLAPI_PLUGIN, &origpi);
+ work_pb = pb;
}
- slapi_pblock_set(pb, SLAPI_PLUGIN, pi);
+ slapi_pblock_set(work_pb, SLAPI_PLUGIN, pi);
rc = -1; /* means no assertion2keys function */
*ivals = NULL;
if ( a2k_fn != NULL ) {
- rc = (*a2k_fn)( pb, initial, any, final, ivals );
+ rc = (*a2k_fn)( work_pb, initial, any, final, ivals );
}
- if (pb != &pipb) {
+ if (pb == NULL) {
+ slapi_pblock_destroy(pipb);
+ } else {
/* restore the original slapdplugin if pb is not local. */
slapi_pblock_set(pb, SLAPI_PLUGIN, origpi);
}
diff --git a/ldap/servers/slapd/psearch.c b/ldap/servers/slapd/psearch.c
index 2d0badc..9b9393d 100644
--- a/ldap/servers/slapd/psearch.c
+++ b/ldap/servers/slapd/psearch.c
@@ -141,14 +141,6 @@ ps_stop_psearch_system()
}
}
-static Slapi_PBlock *
-pblock_copy(Slapi_PBlock *src)
-{
- Slapi_PBlock *dest = slapi_pblock_new();
- *dest = *src;
- return dest;
-}
-
/*
* Add the given pblock to the list of outstanding persistent searches.
* Then, start a thread to send the results to the client as they
@@ -163,7 +155,7 @@ ps_add( Slapi_PBlock *pb, ber_int_t changetypes, int
send_entchg_controls )
if ( PS_IS_INITIALIZED() && NULL != pb ) {
/* Create the new node */
ps = psearch_alloc();
- ps->ps_pblock = pblock_copy(pb);
+ ps->ps_pblock = slapi_pblock_clone(pb);
ps->ps_changetypes = changetypes;
ps->ps_send_entchg_controls = send_entchg_controls;
@@ -272,29 +264,34 @@ ps_send_results( void *arg )
char **pbattrs = NULL;
int conn_acq_flag = 0;
Slapi_Connection *conn = NULL;
+ Connection *pb_conn = NULL;
+ Operation *pb_op = NULL;
g_incr_active_threadcnt();
+ slapi_pblock_get(ps->ps_pblock, SLAPI_CONNECTION, &pb_conn);
+ slapi_pblock_get(ps->ps_pblock, SLAPI_OPERATION, &pb_op);
+
/* need to acquire a reference to this connection so that it will not
be released or cleaned up out from under us */
- PR_EnterMonitor(ps->ps_pblock->pb_conn->c_mutex);
- conn_acq_flag = connection_acquire_nolock(ps->ps_pblock->pb_conn);
- PR_ExitMonitor(ps->ps_pblock->pb_conn->c_mutex);
+ PR_EnterMonitor(pb_conn->c_mutex);
+ conn_acq_flag = connection_acquire_nolock(pb_conn);
+ PR_ExitMonitor(pb_conn->c_mutex);
if (conn_acq_flag) {
slapi_log_err(SLAPI_LOG_CONNS, "ps_send_results",
"conn=%" PRIu64 " op=%d Could not acquire the connection - psearch
aborted\n",
- ps->ps_pblock->pb_conn->c_connid, ps->ps_pblock->pb_op->o_opid);
+ pb_conn->c_connid, pb_op->o_opid);
}
PR_Lock( psearch_list->pl_cvarlock );
while ( (conn_acq_flag == 0) && !ps->ps_complete ) {
/* Check for an abandoned operation */
- if ( ps->ps_pblock->pb_op == NULL || slapi_op_abandoned( ps->ps_pblock ) ) {
+ if ( pb_op == NULL || slapi_op_abandoned( ps->ps_pblock ) ) {
slapi_log_err(SLAPI_LOG_CONNS, "ps_send_results",
"conn=%" PRIu64 " op=%d The operation has been abandoned\n",
- ps->ps_pblock->pb_conn->c_connid, ps->ps_pblock->pb_op->o_opid);
+ pb_conn->c_connid, pb_op->o_opid);
break;
}
if ( NULL == ps->ps_eq_head ) {
@@ -352,8 +349,8 @@ ps_send_results( void *arg )
if (rc) {
slapi_log_err(SLAPI_LOG_CONNS, "ps_send_results",
"conn=%" PRIu64 " op=%d Error %d sending entry %s with op status
%d\n",
- ps->ps_pblock->pb_conn->c_connid,
ps->ps_pblock->pb_op->o_opid,
- rc, slapi_entry_get_dn_const(ec), ps->ps_pblock->pb_op->o_status);
+ pb_conn->c_connid, pb_op->o_opid,
+ rc, slapi_entry_get_dn_const(ec), pb_op->o_status);
}
}
@@ -395,15 +392,15 @@ ps_send_results( void *arg )
slapi_pblock_set(ps->ps_pblock, SLAPI_SEARCH_FILTER, NULL );
slapi_filter_free(filter, 1);
- conn = ps->ps_pblock->pb_conn; /* save to release later -
connection_remove_operation_ext will NULL the pb_conn */
+ conn = pb_conn; /* save to release later - connection_remove_operation_ext will NULL
the pb_conn */
/* Clean up the connection structure */
PR_EnterMonitor(conn->c_mutex);
slapi_log_err(SLAPI_LOG_CONNS, "ps_send_results",
"conn=%" PRIu64 " op=%d Releasing the connection and
operation\n",
- conn->c_connid, ps->ps_pblock->pb_op->o_opid);
+ conn->c_connid, pb_op->o_opid);
/* Delete this op from the connection's list */
- connection_remove_operation_ext( ps->ps_pblock, conn, ps->ps_pblock->pb_op
);
+ connection_remove_operation_ext( ps->ps_pblock, conn, pb_op );
/* Decrement the connection refcnt */
if (conn_acq_flag == 0) { /* we acquired it, so release it */
@@ -524,12 +521,16 @@ ps_service_persistent_searches( Slapi_Entry *e, Slapi_Entry *eprev,
ber_int_t ch
Slapi_DN *base = NULL;
Slapi_Filter *f;
int scope;
+ Connection *pb_conn = NULL;
+ Operation *pb_op = NULL;
+
+ slapi_pblock_get(ps->ps_pblock, SLAPI_OPERATION, &pb_op);
+ slapi_pblock_get(ps->ps_pblock, SLAPI_CONNECTION, &pb_conn);
/* Skip the node that doesn't meet the changetype,
* or is unable to use the change in ps_send_results()
*/
- if (( ps->ps_changetypes & chgtype ) == 0 ||
- ps->ps_pblock->pb_op == NULL ||
+ if (( ps->ps_changetypes & chgtype ) == 0 || pb_op == NULL ||
slapi_op_abandoned( ps->ps_pblock ) ) {
continue;
}
@@ -537,8 +538,8 @@ ps_service_persistent_searches( Slapi_Entry *e, Slapi_Entry *eprev,
ber_int_t ch
slapi_log_err(SLAPI_LOG_CONNS, "ps_service_persistent_searches",
"conn=%" PRIu64 " op=%d entry %s with chgtype %d "
"matches the ps changetype %d\n",
- ps->ps_pblock->pb_conn->c_connid,
- ps->ps_pblock->pb_op->o_opid,
+ pb_conn->c_connid,
+ pb_op->o_opid,
edn, chgtype, ps->ps_changetypes);
slapi_pblock_get( ps->ps_pblock, SLAPI_SEARCH_FILTER, &f );
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index 96e3857..e6a1484 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -594,6 +594,7 @@ int
update_pw_info ( Slapi_PBlock *pb , char *old_pw)
{
Slapi_Operation *operation = NULL;
+ Connection *pb_conn;
Slapi_Entry *e = NULL;
Slapi_DN *sdn = NULL;
Slapi_Mods smods;
@@ -605,6 +606,7 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw)
int internal_op = 0;
slapi_pblock_get( pb, SLAPI_OPERATION, &operation);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
slapi_pblock_get( pb, SLAPI_TARGET_SDN, &sdn );
slapi_pblock_get( pb, SLAPI_REQUESTOR_NDN, &bind_dn);
slapi_pblock_get( pb, SLAPI_ENTRY_PRE_OP, &e);
@@ -666,7 +668,7 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw)
* we stuff the actual user who initiated the password change in pb_conn. We check
* for this special case to ensure we reset the expiration date properly.
*/
- if ((internal_op && pwpolicy->pw_must_change && (!pb->pb_conn ||
strcasecmp(target_dn, pb->pb_conn->c_dn))) ||
+ if ((internal_op && pwpolicy->pw_must_change && (!pb_conn ||
strcasecmp(target_dn, pb_conn->c_dn))) ||
(!internal_op && pwpolicy->pw_must_change &&
((target_dn && bind_dn && strcasecmp(target_dn, bind_dn))
&& pw_is_pwp_admin(pb, pwpolicy)))) {
pw_exp_date = NO_TIME;
@@ -719,9 +721,9 @@ update_pw_info ( Slapi_PBlock *pb , char *old_pw)
pw_apply_mods(sdn, &smods);
slapi_mods_done(&smods);
- if (pb->pb_conn) { /* no conn for internal op */
+ if (pb_conn) { /* no conn for internal op */
/* reset c_needpw to 0 */
- pb->pb_conn->c_needpw = 0;
+ pb_conn->c_needpw = 0;
}
return 0;
}
@@ -732,11 +734,13 @@ check_pw_minage ( Slapi_PBlock *pb, const Slapi_DN *sdn, struct
berval **vals __
char *dn= (char*)slapi_sdn_get_ndn(sdn); /* jcm - Had to cast away const */
passwdPolicy *pwpolicy=NULL;
int pwresponse_req = 0;
+ Operation *pb_op;
pwpolicy = new_passwdPolicy(pb, dn);
slapi_pblock_get ( pb, SLAPI_PWPOLICY, &pwresponse_req );
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
- if (!pb->pb_op->o_isroot && pwpolicy->pw_minage) {
+ if (!pb_op->o_isroot && pwpolicy->pw_minage) {
Slapi_Entry *e;
char *passwordAllowChangeTime;
@@ -800,6 +804,7 @@ check_pw_syntax_ext ( Slapi_PBlock *pb, const Slapi_DN *sdn,
Slapi_Value **vals,
char *p = NULL;
passwdPolicy *pwpolicy = NULL;
Slapi_Operation *operation = NULL;
+ Connection *pb_conn;
char errormsg[SLAPI_DSE_RETURNTEXT_SIZE] = {0};
/*
@@ -831,6 +836,7 @@ check_pw_syntax_ext ( Slapi_PBlock *pb, const Slapi_DN *sdn,
Slapi_Value **vals,
slapi_log_err(SLAPI_LOG_ERR, "check_pw_syntax_ext", "No slapi
operation\n");
return -1;
}
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
internal_op = slapi_operation_is_flag_set(operation, SLAPI_OP_FLAG_INTERNAL);
/*
@@ -843,7 +849,7 @@ check_pw_syntax_ext ( Slapi_PBlock *pb, const Slapi_DN *sdn,
Slapi_Value **vals,
for ( i = 0; vals[ i ] != NULL; ++i ){
if (slapi_is_encoded((char *)slapi_value_get_string(vals[i]))) {
if (!is_replication && !config_get_allow_hashed_pw() &&
- ((internal_op && pb->pb_conn &&
!slapi_dn_isroot(pb->pb_conn->c_dn)) ||
+ ((internal_op && pb_conn && !slapi_dn_isroot(pb_conn->c_dn)) ||
(!internal_op && !pw_is_pwp_admin(pb, pwpolicy)))) {
PR_snprintf( errormsg, sizeof(errormsg) - 1, "invalid password syntax -
passwords with storage scheme are not allowed");
if ( pwresponse_req == 1 ) {
@@ -1158,7 +1164,7 @@ update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char
*old_pw )
Slapi_Entry *e = NULL;
LDAPMod attribute;
LDAPMod *list_of_mods[2];
- Slapi_PBlock mod_pb;
+ Slapi_PBlock *mod_pb;
char *str = NULL;
passwdPolicy *pwpolicy = NULL;
const char *dn = slapi_sdn_get_dn(sdn);
@@ -1231,15 +1237,15 @@ update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char
*old_pw )
list_of_mods[0] = &attribute;
list_of_mods[1] = NULL;
- pblock_init(&mod_pb);
- slapi_modify_internal_set_pb_ext(&mod_pb, sdn, list_of_mods, NULL, NULL,
pw_get_componentID(), 0);
- slapi_modify_internal_pb(&mod_pb);
- slapi_pblock_get(&mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
+ mod_pb = slapi_pblock_new();
+ slapi_modify_internal_set_pb_ext(mod_pb, sdn, list_of_mods, NULL, NULL,
pw_get_componentID(), 0);
+ slapi_modify_internal_pb(mod_pb);
+ slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
if (res != LDAP_SUCCESS){
slapi_log_err(SLAPI_LOG_ERR, "update_pw_history",
"Modify error %d on entry '%s'\n", res, dn);
}
- pblock_done(&mod_pb);
+ slapi_pblock_destroy(mod_pb);
slapi_ch_free_string(&str);
bail:
slapi_ch_array_free(values_replace);
@@ -1557,8 +1563,11 @@ pw_is_pwp_admin(Slapi_PBlock *pb, passwdPolicy *pwp){
Slapi_DN *bind_sdn = NULL;
int i;
+ int is_requestor_root = 0;
+ slapi_pblock_get(pb, SLAPI_REQUESTOR_ISROOT, &is_requestor_root);
+
/* first check if it's root */
- if(pb->pb_requestor_isroot){
+ if(is_requestor_root){
return 1;
}
/* now check if it's a Password Policy Administrator */
@@ -1669,9 +1678,12 @@ new_passwdPolicy(Slapi_PBlock *pb, const char *dn)
int optype = -1;
/* If we already allocated a pw policy, return it */
- if(pb && pb->pwdpolicy){
- return pb->pwdpolicy;
- }
+ if (pb != NULL) {
+ passwdPolicy *pwdpolicy = slapi_pblock_get_pwdpolicy(pb);
+ if (pwdpolicy != NULL) {
+ return pwdpolicy;
+ }
+ }
if (g_get_active_threadcnt() == 0){
/*
@@ -2006,7 +2018,7 @@ new_passwdPolicy(Slapi_PBlock *pb, const char *dn)
}
}
if (pb) {
- pb->pwdpolicy = pwdpolicy;
+ slapi_pblock_set_pwdpolicy(pb, pwdpolicy);
}
return pwdpolicy;
} else if ( e ) {
@@ -2026,9 +2038,9 @@ done:
pwdpolicy->pw_storagescheme = pwdscheme;
pwdpolicy->pw_admin = slapi_sdn_dup(slapdFrontendConfig->pw_policy.pw_admin);
pw_get_admin_users(pwdpolicy);
- if(pb){
- pb->pwdpolicy = pwdpolicy;
- }
+ if (pb) {
+ slapi_pblock_set_pwdpolicy(pb, pwdpolicy);
+ }
return pwdpolicy;
@@ -2822,6 +2834,7 @@ pw_get_ext_size(Slapi_Entry *entry, size_t *size)
int
add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry **e)
{
+ Operation *pb_op;
const char *dn = NULL;
passwdPolicy *pwpolicy = NULL;
long long shadowval = -1;
@@ -2845,7 +2858,9 @@ add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry **e)
/* Not a shadowAccount; nothing to do. */
return rc;
}
- if (operation_is_flag_set(pb->pb_op, OP_FLAG_INTERNAL)) {
+
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+ if (operation_is_flag_set(pb_op, OP_FLAG_INTERNAL)) {
/* external only */
return rc;
}
@@ -2943,7 +2958,7 @@ add_shadow_ext_password_attrs(Slapi_PBlock *pb, Slapi_Entry **e)
if (mods) {
Slapi_Entry *sentry = slapi_entry_dup(*e);
rc = slapi_entry_apply_mods(sentry, mods);
- pb->pb_pw_entry = sentry;
+ slapi_pblock_set_pw_entry(pb, sentry);
*e = sentry;
}
slapi_mods_free(&smods);
diff --git a/ldap/servers/slapd/pw_mgmt.c b/ldap/servers/slapd/pw_mgmt.c
index 101f4be..8707392 100644
--- a/ldap/servers/slapd/pw_mgmt.c
+++ b/ldap/servers/slapd/pw_mgmt.c
@@ -37,6 +37,7 @@ need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int
pwresponse_req )
passwdPolicy *pwpolicy = NULL;
int pwdGraceUserTime = 0;
char graceUserTime[16] = {0};
+ Connection *pb_conn = NULL;
if (NULL == e) {
return (-1);
@@ -86,6 +87,8 @@ need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int
pwresponse_req )
slapi_ch_free_string(&passwordExpirationTime);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
/* Check if password has been reset */
if ( pw_exp_date == NO_TIME ) {
@@ -93,7 +96,7 @@ need_new_pw( Slapi_PBlock *pb, long *t, Slapi_Entry *e, int
pwresponse_req )
if ( pwpolicy->pw_must_change ) {
/* set c_needpw for this connection to be true. this client
now can only change its own password */
- pb->pb_conn->c_needpw = 1;
+ pb_conn->c_needpw = 1;
*t=0;
/* We need to include "changeafterreset" error in
* passwordpolicy response control. So, we will not be
@@ -115,7 +118,7 @@ skip:
/* if password never expires, don't need to go on; return 0 */
if ( pwpolicy->pw_exp == 0 ) {
/* check for "changeafterreset" condition */
- if (pb->pb_conn->c_needpw == 1) {
+ if (pb_conn->c_needpw == 1) {
if (pwresponse_req) {
slapi_pwpolicy_make_response_control ( pb, -1, -1, LDAP_PWPOLICY_CHGAFTERRESET );
}
@@ -144,7 +147,7 @@ skip:
slapi_mods_done(&smods);
if (pwresponse_req) {
/* check for "changeafterreset" condition */
- if (pb->pb_conn->c_needpw == 1) {
+ if (pb_conn->c_needpw == 1) {
slapi_pwpolicy_make_response_control( pb, -1,
((pwpolicy->pw_gracelimit) - pwdGraceUserTime),
LDAP_PWPOLICY_CHGAFTERRESET);
@@ -155,7 +158,7 @@ skip:
}
}
- if (pb->pb_conn->c_needpw == 1) {
+ if (pb_conn->c_needpw == 1) {
slapi_add_pwd_control ( pb, LDAP_CONTROL_PWEXPIRED, 0);
}
return ( 0 );
@@ -176,10 +179,12 @@ skip:
do_unbind() checking for those. We might need to
create a pb for unbind operation. Also do_unbind calls
pre and post ops. Maybe we don't want to call them */
- if (pb->pb_conn && (LDAP_VERSION2 == pb->pb_conn->c_ldapversion)) {
+ if (pb_conn && (LDAP_VERSION2 == pb_conn->c_ldapversion)) {
+ Operation *pb_op = NULL;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
/* We close the connection only with LDAPv2 connections */
- disconnect_server( pb->pb_conn, pb->pb_op->o_connid,
- pb->pb_op->o_opid, SLAPD_DISCONNECT_UNBIND, 0);
+ disconnect_server( pb_conn, pb_op->o_connid,
+ pb_op->o_opid, SLAPD_DISCONNECT_UNBIND, 0);
}
/* Apply current modifications */
pw_apply_mods(sdn, &smods);
@@ -202,7 +207,7 @@ skip:
/* reset the expiration time to current + warning time
* and set passwordExpWarned to true
*/
- if (pb->pb_conn->c_needpw != 1) {
+ if (pb_conn->c_needpw != 1) {
pw_exp_date = time_plus_sec(cur_time, pwpolicy->pw_warning);
}
@@ -222,7 +227,7 @@ skip:
slapi_mods_done(&smods);
if (pwresponse_req) {
/* check for "changeafterreset" condition */
- if (pb->pb_conn->c_needpw == 1) {
+ if (pb_conn->c_needpw == 1) {
slapi_pwpolicy_make_response_control( pb, *t, -1,
LDAP_PWPOLICY_CHGAFTERRESET);
} else {
@@ -231,7 +236,7 @@ skip:
}
}
- if (pb->pb_conn->c_needpw == 1) {
+ if (pb_conn->c_needpw == 1) {
slapi_add_pwd_control ( pb, LDAP_CONTROL_PWEXPIRED, 0);
}
return (2);
@@ -245,7 +250,7 @@ skip:
pw_apply_mods(sdn, &smods);
slapi_mods_done(&smods);
/* Leftover from "changeafterreset" condition */
- if (pb->pb_conn->c_needpw == 1) {
+ if (pb_conn->c_needpw == 1) {
slapi_add_pwd_control ( pb, LDAP_CONTROL_PWEXPIRED, 0);
}
/* passes checking, return 0 */
diff --git a/ldap/servers/slapd/pw_retry.c b/ldap/servers/slapd/pw_retry.c
index da08f66..a54c784 100644
--- a/ldap/servers/slapd/pw_retry.c
+++ b/ldap/servers/slapd/pw_retry.c
@@ -226,30 +226,29 @@ bail:
void
pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods)
{
- Slapi_PBlock pb;
int res;
if (mods && (slapi_mods_get_num_mods(mods) > 0))
{
- pblock_init(&pb);
+ Slapi_PBlock *pb = slapi_pblock_new();
/* We don't want to overwrite the modifiersname, etc. attributes,
* so we set a flag for this operation */
- slapi_modify_internal_set_pb_ext (&pb, sdn,
+ slapi_modify_internal_set_pb_ext (pb, sdn,
slapi_mods_get_ldapmods_byref(mods),
NULL, /* Controls */
NULL, /* UniqueID */
pw_get_componentID(), /* PluginID */
OP_FLAG_SKIP_MODIFIED_ATTRS); /* Flags */
- slapi_modify_internal_pb (&pb);
+ slapi_modify_internal_pb (pb);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &res);
if (res != LDAP_SUCCESS){
slapi_log_err(SLAPI_LOG_WARNING,
"pw_apply_mods", "Modify error %d on entry
'%s'\n",
res, slapi_sdn_get_dn(sdn));
}
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
}
return;
diff --git a/ldap/servers/slapd/referral.c b/ldap/servers/slapd/referral.c
index a9c01fa..2e0aea0 100644
--- a/ldap/servers/slapd/referral.c
+++ b/ldap/servers/slapd/referral.c
@@ -475,9 +475,11 @@ get_data_source(Slapi_PBlock *pb, const Slapi_DN *sdn, int orc, void
*cfrp)
return (NULL);
}
+ Connection *pb_conn;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
- /* Fix for 310968 --- return an SSL referral to an SSL client */
- if ( 0 != ( pb->pb_conn->c_flags & CONN_FLAG_SSL )) {
+ /* Fix for 310968 --- return an SSL referral to an SSL client */
+ if ( 0 != ( pb_conn->c_flags & CONN_FLAG_SSL )) {
/* SSL connection */
char * old_referral_string = NULL;
char * new_referral_string = NULL;
diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
index c84ea0a..9c802a9 100644
--- a/ldap/servers/slapd/result.c
+++ b/ldap/servers/slapd/result.c
@@ -338,7 +338,7 @@ send_ldap_result_ext(
{
Slapi_Operation *operation;
passwdPolicy *pwpolicy = NULL;
- Connection *conn = pb->pb_conn;
+ Connection *conn = NULL;
Slapi_DN *sdn = NULL;
const char *dn = NULL;
ber_tag_t tag;
@@ -349,6 +349,7 @@ send_ldap_result_ext(
slapi_pblock_get (pb, SLAPI_BIND_METHOD, &bind_method);
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);
if (operation->o_status == SLAPI_OP_STATUS_RESULT_SENT) {
return; /* result already sent */
@@ -656,7 +657,8 @@ process_read_entry_controls(Slapi_PBlock *pb, char *oid)
if (slapi_control_present(req_ctls, oid, &req_value, &iscritical))
{
BerElement *req_ber = NULL;
- Operation *op = pb->pb_op;
+ Operation *op = NULL;
+ slapi_pblock_get(pb, SLAPI_OPERATION, &op);
if(strcmp(oid,LDAP_CONTROL_PRE_READ_ENTRY) == 0){
/* first verify this is the correct operation for a pre-read entry control
*/
@@ -811,19 +813,22 @@ send_ldapv3_referral(
struct berval **urls
)
{
- Connection *conn = pb->pb_conn;
+ Connection *conn = NULL;
BerElement *ber;
int i, rc, logit = 0;
Slapi_Operation *operation;
+ Slapi_Backend *pb_backend;
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);
+ slapi_pblock_get(pb, SLAPI_BACKEND, &pb_backend);
slapi_log_err(SLAPI_LOG_TRACE, "send_ldapv3_referral", "=>\n");
if ( conn == NULL ) {
if ( operation->o_search_referral_handler != NULL ) {
if (( rc = (*operation->o_search_referral_handler)(
- pb->pb_backend, conn, operation, urls )) == 0 ) {
+ pb_backend, conn, operation, urls )) == 0 ) {
logit = 1;
}
goto log_and_return;
@@ -904,6 +909,8 @@ send_ldap_referral (
char *refAttr = "ref";
char *attrs[2] = { NULL, NULL };
+ Connection *pb_conn;
+
/* count the referral */
slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsReferrals);
@@ -914,7 +921,7 @@ send_ldap_referral (
!= LDAP_SUCCESS ) {
return( 0 );
}
- if ( pb->pb_conn && pb->pb_conn->c_ldapversion > LDAP_VERSION2 ) {
+ if ( pb_conn && pb_conn->c_ldapversion > LDAP_VERSION2 ) {
/*
* v3 connection - send the referral(s) in a
* SearchResultReference packet right now.
@@ -1473,8 +1480,7 @@ send_ldap_search_entry_ext(
struct berval **urls
)
{
- Connection *conn = pb->pb_conn;
- Operation *op = pb->pb_op;
+ Connection *conn = NULL;
BerElement *ber = NULL;
int i, rc = 0, logit = 0;
int alluserattrs;
@@ -1489,6 +1495,7 @@ send_ldap_search_entry_ext(
LDAPControl **searchctrlp = NULL;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);
slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
slapi_log_err(SLAPI_LOG_TRACE, "send_ldap_search_entry_ext", "=>
(%s)\n",
@@ -1515,9 +1522,12 @@ send_ldap_search_entry_ext(
slapi_pblock_get(pb, SLAPI_SEARCH_CTRLS, &searchctrlp);
if ( conn == NULL && e ) {
- if ( op->o_search_entry_handler != NULL ) {
- if (( rc = (*op->o_search_entry_handler)(
- pb->pb_backend, conn, op, e )) == 0 ) {
+ Slapi_Backend *pb_backend;
+ slapi_pblock_get(pb, SLAPI_BACKEND, &pb_backend);
+
+ if ( operation->o_search_entry_handler != NULL ) {
+ if (( rc = (*operation->o_search_entry_handler)(
+ pb_backend, conn, operation, e )) == 0 ) {
logit = 1;
goto log_and_return;
} else {
@@ -1550,7 +1560,7 @@ send_ldap_search_entry_ext(
goto cleanup;
}
- rc = ber_printf( ber, "{it{s{", op->o_msgid,
+ rc = ber_printf( ber, "{it{s{", operation->o_msgid,
LDAP_RES_SEARCH_ENTRY, slapi_entry_get_dn_const(e) );
if ( rc == -1 ) {
@@ -1620,13 +1630,13 @@ send_ldap_search_entry_ext(
/* look through each attribute in the entry */
if ( alluserattrs || alloperationalattrs ) {
- rc = send_all_attrs(e, attrs, op, pb, ber, attrsonly, conn->c_ldapversion,
+ rc = send_all_attrs(e, attrs, operation, pb, ber, attrsonly, conn->c_ldapversion,
real_attrs_only, some_named_attrs, alloperationalattrs,
alluserattrs);
}
/* if the client explicitly specified a list of attributes look through each attribute
requested */
if( (rc == 0) && (attrs!=NULL) && !noattrs) {
- rc =
send_specific_attrs(e,attrs,op,pb,ber,attrsonly,conn->c_ldapversion,real_attrs_only);
+ rc =
send_specific_attrs(e,attrs,operation,pb,ber,attrsonly,conn->c_ldapversion,real_attrs_only);
}
/* Append effective rights to the stream of attribute list */
@@ -1682,7 +1692,7 @@ send_ldap_search_entry_ext(
}
/* write only one pdu at a time - wait til it's our turn */
- if ( (rc = flush_ber( pb, conn, op, ber, _LDAP_SEND_ENTRY )) == 0 ) {
+ if ( (rc = flush_ber( pb, conn, operation, ber, _LDAP_SEND_ENTRY )) == 0 ) {
logit = 1;
}
ber = NULL; /* flush_ber will always free the ber */
@@ -1690,12 +1700,12 @@ send_ldap_search_entry_ext(
log_and_return:
if ( logit && operation_is_flag_set(operation, OP_FLAG_ACTION_LOG_ACCESS)) {
- log_entry( op, e );
+ log_entry( operation, e );
if (send_result) {
ber_tag_t tag;
- switch ( op->o_tag ) {
+ switch ( operation->o_tag ) {
case LBER_DEFAULT:
tag = LBER_SEQUENCE;
break;
@@ -1716,11 +1726,11 @@ log_and_return:
/* FALLTHROUGH */
default:
- tag = op->o_tag + 1;
+ tag = operation->o_tag + 1;
break;
}
- log_result( pb, op, LDAP_SUCCESS, tag, nentries );
+ log_result( pb, operation, LDAP_SUCCESS, tag, nentries );
}
}
cleanup:
@@ -1939,6 +1949,7 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t tag,
int nentrie
char etime[ETIME_BUFSIZ];
int pr_idx = -1;
int pr_cookie = -1;
+ uint32_t operation_notes;
slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx);
slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_COOKIE, &pr_cookie);
@@ -1953,12 +1964,14 @@ log_result( Slapi_PBlock *pb, Operation *op, int err, ber_tag_t
tag, int nentrie
PR_snprintf(etime, ETIME_BUFSIZ, "%ld", current_time() - op->o_time);
}
- if ( 0 == pb->pb_operation_notes ) {
+ slapi_pblock_get(pb, SLAPI_OPERATION_NOTES, &operation_notes);
+
+ if ( 0 == operation_notes ) {
notes_str = "";
} else {
notes_str = notes_buf;
*notes_buf = ' ';
- notes2str( pb->pb_operation_notes, notes_buf + 1, sizeof( notes_buf ) - 1 );
+ notes2str( operation_notes, notes_buf + 1, sizeof( notes_buf ) - 1 );
}
csn_str[0] = '\0';
@@ -2187,8 +2200,8 @@ log_referral( Operation *op )
static struct berval *
encode_read_entry (Slapi_PBlock *pb, Slapi_Entry *e, char **attrs, int alluserattrs, int
attr_count)
{
- Slapi_Operation *op = pb->pb_op;
- Connection*conn = pb->pb_conn;
+ Slapi_Operation *op = NULL;
+ Connection *conn = NULL;
LDAPControl **ctrlp = NULL;
struct berval *bv = NULL;
BerElement *ber = NULL;
@@ -2200,6 +2213,9 @@ encode_read_entry (Slapi_PBlock *pb, Slapi_Entry *e, char **attrs,
int alluserat
goto cleanup;
}
+ slapi_pblock_get(pb, SLAPI_OPERATION, &op);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);
+
/* Start the ber encoding with the DN */
rc = ber_printf( ber, "t{s{", LDAP_RES_SEARCH_ENTRY,
slapi_entry_get_dn_const(e) );
if ( rc == -1 ) {
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index 9569a36..328d919 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -757,21 +757,28 @@ char **ids_sasl_listmech(Slapi_PBlock *pb)
const char *str;
char *dupstr;
sasl_conn_t *sasl_conn;
+ Connection *pb_conn = NULL;
slapi_log_err(SLAPI_LOG_TRACE, "ids_sasl_listmech", "=>\n");
PR_ASSERT(pb);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
/* hard-wired mechanisms and slapi plugin registered mechanisms */
ret = slapi_get_supported_saslmechanisms_copy();
- if (pb->pb_conn == NULL) return ret;
+ if (pb_conn == NULL) {
+ return ret;
+ }
- sasl_conn = (sasl_conn_t*)pb->pb_conn->c_sasl_conn;
- if (sasl_conn == NULL) return ret;
+ sasl_conn = (sasl_conn_t*)pb_conn->c_sasl_conn;
+ if (sasl_conn == NULL) {
+ return ret;
+ }
/* sasl library mechanisms are connection dependent */
- PR_EnterMonitor(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb_conn->c_mutex);
if (sasl_listmech(sasl_conn,
NULL, /* username */
"", ",", "",
@@ -784,7 +791,7 @@ char **ids_sasl_listmech(Slapi_PBlock *pb)
charray_free(others);
slapi_ch_free((void**)&dupstr);
}
- PR_ExitMonitor(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb_conn->c_mutex);
slapi_log_err(SLAPI_LOG_TRACE, "ids_sasl_listmech", "<=\n");
@@ -804,7 +811,10 @@ ids_sasl_mech_supported(Slapi_PBlock *pb, const char *mech)
char *dupstr;
const char *str;
int sasl_result = 0;
- sasl_conn_t *sasl_conn = (sasl_conn_t *)pb->pb_conn->c_sasl_conn;
+ Connection *pb_conn = NULL;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
+ sasl_conn_t *sasl_conn = (sasl_conn_t *)pb_conn->c_sasl_conn;
slapi_log_err(SLAPI_LOG_TRACE, "ids_sasl_mech_supported",
"=>\n");
@@ -860,19 +870,21 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
char authtype[256]; /* >26 (strlen(SLAPD_AUTH_SASL)+SASL_MECHNAMEMAX+1) */
Slapi_Entry *bind_target_entry = NULL, *referral = NULL;
Slapi_Backend *be = NULL;
+ Connection *pb_conn = NULL;
slapi_log_err(SLAPI_LOG_TRACE, "ids_sasl_check_bind",
"=>\n");
PR_ASSERT(pb);
- PR_ASSERT(pb->pb_conn);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ PR_ASSERT(pb_conn);
- PR_EnterMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
- continuing = pb->pb_conn->c_flags & CONN_FLAG_SASL_CONTINUE;
- pb->pb_conn->c_flags &= ~CONN_FLAG_SASL_CONTINUE; /* reset flag */
+ PR_EnterMonitor(pb_conn->c_mutex); /* BIG LOCK */
+ continuing = pb_conn->c_flags & CONN_FLAG_SASL_CONTINUE;
+ pb_conn->c_flags &= ~CONN_FLAG_SASL_CONTINUE; /* reset flag */
- sasl_conn = (sasl_conn_t*)pb->pb_conn->c_sasl_conn;
+ sasl_conn = (sasl_conn_t*)pb_conn->c_sasl_conn;
if (sasl_conn == NULL) {
- PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb_conn->c_mutex); /* BIG LOCK */
send_ldap_result( pb, LDAP_AUTH_METHOD_NOT_SUPPORTED, NULL,
"sasl library unavailable", 0, NULL );
return;
@@ -934,28 +946,28 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
* using the new mechanism. We also need to do this if the
* mechanism changed in the middle of the SASL authentication
* process. */
- if ((pb->pb_conn->c_flags & CONN_FLAG_SASL_COMPLETE) || continuing) {
+ if ((pb_conn->c_flags & CONN_FLAG_SASL_COMPLETE) || continuing) {
Slapi_Operation *operation;
slapi_pblock_get( pb, SLAPI_OPERATION, &operation);
slapi_log_err(SLAPI_LOG_CONNS, "ids_sasl_check_bind",
"cleaning up sasl IO conn=%" PRIu64 " op=%d
complete=%d continuing=%d\n",
- pb->pb_conn->c_connid, operation->o_opid,
- (pb->pb_conn->c_flags & CONN_FLAG_SASL_COMPLETE),
continuing);
+ pb_conn->c_connid, operation->o_opid,
+ (pb_conn->c_flags & CONN_FLAG_SASL_COMPLETE),
continuing);
/* reset flag */
- pb->pb_conn->c_flags &= ~CONN_FLAG_SASL_COMPLETE;
+ pb_conn->c_flags &= ~CONN_FLAG_SASL_COMPLETE;
/* remove any SASL I/O from the connection */
- connection_set_io_layer_cb(pb->pb_conn, NULL, sasl_io_cleanup, NULL);
+ connection_set_io_layer_cb(pb_conn, NULL, sasl_io_cleanup, NULL);
/* dispose of sasl_conn and create a new sasl_conn */
sasl_dispose(&sasl_conn);
- ids_sasl_server_new(pb->pb_conn);
- sasl_conn = (sasl_conn_t*)pb->pb_conn->c_sasl_conn;
+ ids_sasl_server_new(pb_conn);
+ sasl_conn = (sasl_conn_t*)pb_conn->c_sasl_conn;
if (sasl_conn == NULL) {
send_ldap_result( pb, LDAP_AUTH_METHOD_NOT_SUPPORTED, NULL,
"sasl library unavailable", 0, NULL );
- PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb_conn->c_mutex); /* BIG LOCK */
return;
}
}
@@ -971,7 +983,7 @@ sasl_check_result:
/* retrieve the authenticated username */
if (sasl_getprop(sasl_conn, SASL_USERNAME,
(const void**)&username) != SASL_OK) {
- PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb_conn->c_mutex); /* BIG LOCK */
send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL,
"could not obtain sasl username", 0, NULL);
break;
@@ -992,7 +1004,7 @@ sasl_check_result:
}
}
if (dn == NULL) {
- PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb_conn->c_mutex); /* BIG LOCK */
send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL,
"could not get auth dn from sasl", 0, NULL);
break;
@@ -1015,7 +1027,7 @@ sasl_check_result:
}
/* Set a flag to signify that sasl bind is complete */
- pb->pb_conn->c_flags |= CONN_FLAG_SASL_COMPLETE;
+ pb_conn->c_flags |= CONN_FLAG_SASL_COMPLETE;
/* note - we set this here in case there are pre-bind
plugins that want to know what the negotiated
ssf is - but this happens before we actually set
@@ -1024,16 +1036,16 @@ sasl_check_result:
encryption on the connection after the pre-bind
plugin has been called, and sasl encryption fails
and the operation returns an error */
- pb->pb_conn->c_sasl_ssf = (unsigned)*ssfp;
+ pb_conn->c_sasl_ssf = (unsigned)*ssfp;
/* set the connection bind credentials */
PR_snprintf(authtype, sizeof(authtype), "%s%s", SLAPD_AUTH_SASL,
mech);
/* normdn is consumed by bind_credentials_set_nolock */
- bind_credentials_set_nolock(pb->pb_conn, authtype,
+ bind_credentials_set_nolock(pb_conn, authtype,
slapi_ch_strdup(normdn),
NULL, NULL, NULL, bind_target_entry);
- PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb_conn->c_mutex); /* BIG LOCK */
if (plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN ) != 0){
break;
@@ -1108,9 +1120,9 @@ sasl_check_result:
/* see if we negotiated a security layer */
if (*ssfp > 0) {
/* Enable SASL I/O on the connection */
- PR_EnterMonitor(pb->pb_conn->c_mutex);
- connection_set_io_layer_cb(pb->pb_conn, sasl_io_enable, NULL, NULL);
- PR_ExitMonitor(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb_conn->c_mutex);
+ connection_set_io_layer_cb(pb_conn, sasl_io_enable, NULL, NULL);
+ PR_ExitMonitor(pb_conn->c_mutex);
}
/* send successful result */
@@ -1122,8 +1134,8 @@ sasl_check_result:
break;
case SASL_CONTINUE: /* another step needed */
- pb->pb_conn->c_flags |= CONN_FLAG_SASL_CONTINUE;
- PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
+ pb_conn->c_flags |= CONN_FLAG_SASL_CONTINUE;
+ PR_ExitMonitor(pb_conn->c_mutex); /* BIG LOCK */
if (plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN ) != 0){
break;
@@ -1145,7 +1157,7 @@ sasl_check_result:
case SASL_NOMECH:
- PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb_conn->c_mutex); /* BIG LOCK */
send_ldap_result(pb, LDAP_AUTH_METHOD_NOT_SUPPORTED, NULL,
"sasl mechanism not supported", 0, NULL);
break;
@@ -1153,7 +1165,7 @@ sasl_check_result:
default: /* other error */
errstr = sasl_errdetail(sasl_conn);
- PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb_conn->c_mutex); /* BIG LOCK */
slapi_pblock_set(pb, SLAPI_PB_RESULT_TEXT, (void *)errstr);
send_ldap_result(pb, LDAP_INVALID_CREDENTIALS, NULL, NULL, 0, NULL);
break;
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index af53fc7..6f14893 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -2422,18 +2422,17 @@ refresh_user_defined_schema( Slapi_PBlock *pb,
{
int rc;
Slapi_PBlock *mypbptr = pb;
- Slapi_PBlock mypb;
+ Slapi_PBlock *mypb = NULL;
const CSN *schema_csn;
PRUint32 schema_flags = DSE_SCHEMA_USER_DEFINED_ONLY;
- pblock_init(&mypb);
-
slapi_entry_attr_delete( pschema_info_e, "objectclasses");
slapi_entry_attr_delete( pschema_info_e, "attributetypes");
/* for write callbacks, no pb is supplied, so use our own */
if (!mypbptr) {
- mypbptr = &mypb;
+ mypb = slapi_pblock_new();
+ mypbptr = mypb;
}
slapi_pblock_set(mypbptr, SLAPI_SCHEMA_FLAGS, &schema_flags);
@@ -2445,8 +2444,9 @@ refresh_user_defined_schema( Slapi_PBlock *pb,
csn_as_string(schema_csn, PR_FALSE, csn_str);
slapi_entry_add_string(pschema_info_e, "nsschemacsn", csn_str);
}
- pblock_done(&mypb);
-
+ if (mypb != NULL) {
+ slapi_pblock_destroy(mypb);
+ }
return rc;
}
@@ -5346,15 +5346,15 @@ init_schema_dse_ext(char *schemadir, Slapi_Backend *be,
int dont_write = 1;
int merge = 1;
int dont_dup_check = 1;
- Slapi_PBlock pb = {0};
+ Slapi_PBlock *pb = slapi_pblock_new();
/* don't write out the file when reading */
- slapi_pblock_set(&pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING,
(void*)&dont_write);
+ slapi_pblock_set(pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING, (void*)&dont_write);
/* duplicate entries are allowed */
- slapi_pblock_set(&pb, SLAPI_DSE_MERGE_WHEN_ADDING, (void*)&merge);
+ slapi_pblock_set(pb, SLAPI_DSE_MERGE_WHEN_ADDING, (void*)&merge);
/* use the non duplicate checking str2entry */
- slapi_pblock_set(&pb, SLAPI_DSE_DONT_CHECK_DUPS,
(void*)&dont_dup_check);
+ slapi_pblock_set(pb, SLAPI_DSE_DONT_CHECK_DUPS, (void*)&dont_dup_check);
/* borrow the task flag space */
- slapi_pblock_set(&pb, SLAPI_SCHEMA_FLAGS, (void*)&schema_flags);
+ slapi_pblock_set(pb, SLAPI_SCHEMA_FLAGS, (void*)&schema_flags);
/* add the objectclass attribute so we can do some basic schema
checking during initialization; this will be overridden when
@@ -5388,7 +5388,8 @@ init_schema_dse_ext(char *schemadir, Slapi_Backend *be,
errorbuf);
}
- rc = dse_read_file(*local_pschemadse, &pb);
+ rc = dse_read_file(*local_pschemadse, pb);
+ slapi_pblock_destroy(pb);
}
if (rc && !(schema_flags & DSE_SCHEMA_NO_BACKEND))
diff --git a/ldap/servers/slapd/search.c b/ldap/servers/slapd/search.c
index ea8b479..72b4664 100644
--- a/ldap/servers/slapd/search.c
+++ b/ldap/servers/slapd/search.c
@@ -54,6 +54,7 @@ do_search( Slapi_PBlock *pb )
int strict = 0;
int minssf_exclude_rootdse = 0;
int filter_normalized = 0;
+ Connection *pb_conn = NULL;
slapi_log_err(SLAPI_LOG_TRACE, "do_search", "=>\n");
@@ -124,6 +125,8 @@ do_search( Slapi_PBlock *pb )
goto free_and_return;
}
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
/*
* If nsslapd-minssf-exclude-rootdse is on, the minssf check has been
* postponed till this moment since we need to know whether the basedn
@@ -138,9 +141,9 @@ do_search( Slapi_PBlock *pb )
int minssf = 0;
/* Check if the minimum SSF requirement has been met. */
minssf = config_get_minssf();
- if ((pb->pb_conn->c_sasl_ssf < minssf) &&
- (pb->pb_conn->c_ssl_ssf < minssf) &&
- (pb->pb_conn->c_local_ssf < minssf)) {
+ if ((pb_conn->c_sasl_ssf < minssf) &&
+ (pb_conn->c_ssl_ssf < minssf) &&
+ (pb_conn->c_local_ssf < minssf)) {
op_shared_log_error_access(pb, "SRCH", rawbase?rawbase:"",
"Minimum SSF not met");
send_ldap_result(pb, LDAP_UNWILLING_TO_PERFORM, NULL,
@@ -179,7 +182,7 @@ do_search( Slapi_PBlock *pb )
/* filter - returns a "normalized" version */
filter = NULL;
fstr = NULL;
- if ( (err = get_filter( pb->pb_conn, ber, scope, &filter, &fstr )) != 0 ) {
+ if ( (err = get_filter( pb_conn, ber, scope, &filter, &fstr )) != 0 ) {
char *errtxt;
if ( LDAP_UNWILLING_TO_PERFORM == err ) {
@@ -379,9 +382,13 @@ free_and_return:;
static void log_search_access (Slapi_PBlock *pb, const char *base, int scope, const char
*fstr, const char *msg)
{
+ Operation *pb_op;
+ Connection *pb_conn;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
slapi_log_access(LDAP_DEBUG_STATS,
"conn=%" PRIu64 " op=%d SRCH base=\"%s\" scope=%d
filter=\"%s\", %s\n",
- pb->pb_conn->c_connid, pb->pb_op->o_opid,
+ pb_conn->c_connid, pb_op->o_opid,
base, scope, fstr, msg ? msg : "");
}
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 475bd6c..5cba23e 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1753,173 +1753,20 @@ typedef struct passwordpolicyarray {
Slapi_DN **pw_admin_user;
} passwdPolicy;
-typedef struct slapi_pblock {
- /* common */
- Slapi_Backend *pb_backend;
- Connection *pb_conn;
- Operation *pb_op;
- struct slapdplugin *pb_plugin; /* plugin being called */
- int pb_opreturn;
- void* pb_object; /* points to data private to plugin */
- IFP pb_destroy_fn;
- int pb_requestor_isroot;
- /* config file */
- char *pb_config_fname;
- int pb_config_lineno;
- int pb_config_argc;
- char **pb_config_argv;
- int plugin_tracking;
-
- /* [pre|post]add arguments */
- struct slapi_entry *pb_target_entry; /* JCM - Duplicated */
- struct slapi_entry *pb_existing_dn_entry;
- struct slapi_entry *pb_existing_uniqueid_entry;
- struct slapi_entry *pb_parent_entry;
- struct slapi_entry *pb_newparent_entry;
-
- /* state of entry before and after add/delete/modify/moddn/modrdn */
- struct slapi_entry *pb_pre_op_entry;
- struct slapi_entry *pb_post_op_entry;
- /* seq access arguments */
- int pb_seq_type;
- char *pb_seq_attrname;
- char *pb_seq_val;
- /* dbverify argument */
- char *pb_dbverify_dbdir;
- /* ldif2db arguments */
- char *pb_ldif_file;
- int pb_removedupvals;
- char **pb_db2index_attrs;
- int pb_ldif2db_noattrindexes;
- /* db2ldif arguments */
- int pb_ldif_printkey;
- /* ldif2db/db2ldif/db2bak/bak2db args */
- char *pb_instance_name;
- Slapi_Task *pb_task;
- int pb_task_flags;
- /* matching rule arguments */
- mrFilterMatchFn pb_mr_filter_match_fn;
- IFP pb_mr_filter_index_fn;
- IFP pb_mr_filter_reset_fn;
- IFP pb_mr_index_fn; /* values and keys are struct berval ** */
- char* pb_mr_oid;
- char* pb_mr_type;
- struct berval* pb_mr_value;
- struct berval** pb_mr_values;
- struct berval** pb_mr_keys;
- unsigned int pb_mr_filter_reusable;
- int pb_mr_query_operator;
- unsigned int pb_mr_usage;
-
- /* arguments for password storage scheme (kexcoff) */
- char *pb_pwd_storage_scheme_user_passwd;
- char *pb_pwd_storage_scheme_db_passwd;
-
- /* controls we know about */
- int pb_managedsait;
-
- /* additional fields for plugin_internal_ldap_ops */
- /* result code of internal ldap_operation */
- int pb_internal_op_result;
- /* pointer to array of results returned on search */
- Slapi_Entry **pb_plugin_internal_search_op_entries;
- char **pb_plugin_internal_search_op_referrals;
- void *pb_plugin_identity; /* identifies plugin for internal operation */
- char *pb_plugin_config_area; /* optional config area */
- void *pb_parent_txn; /* parent transaction ID */
- void *pb_txn; /* transaction ID */
- IFP pb_txn_ruv_mods_fn; /* Function to fetch RUV mods for txn */
-
- /* Size of the database on disk, in kilobytes */
- unsigned int pb_dbsize;
-
- /* THINGS BELOW THIS LINE EXIST ONLY IN SLAPI v2 (slapd 4.0+) */
-
- /* ldif2db: array of files to import all at once */
- char **pb_ldif_files;
-
- char **pb_ldif_include;
- char **pb_ldif_exclude;
- int pb_ldif_dump_replica;
- int pb_ldif_dump_uniqueid; /* dump uniqueid during db2ldif */
- int pb_ldif_generate_uniqueid; /* generate uniqueid during db2ldif */
- char* pb_ldif_namespaceid; /* used for name based uniqueid generation */
- int pb_ldif_encrypt; /* used to enable encrypt/decrypt on import and export */
- /*
- * notes to log with RESULT line in the access log
- * these are actually stored as a bitmap; see slapi-plugin.h for
- * defined notes.
- */
- unsigned int pb_operation_notes;
- /*
- * slapd command line arguments
- */
- int pb_slapd_argc;
- char** pb_slapd_argv;
- char *pb_slapd_configdir; /* the config directory passed to slapd on the command line
*/
- LDAPControl **pb_ctrls_arg; /* allows to pass controls as arguments before
- operation object is created */
- int pb_dse_dont_add_write; /* if true, the dse is not written when an entry is added */
- int pb_dse_add_merge; /* if true, if a duplicate entry is found when adding, the
- new values are merged into the old entry */
- int pb_dse_dont_check_dups; /* if false, use the "enhanced" version of
str2entry to catch
- more errors when adding dse entries; this can only be done
- after the schema and syntax and matching rule plugins are
- running */
- int pb_dse_is_primary_file; /* for read callbacks: non-zero for primary file */
- int pb_schema_flags; /* schema flags */
- /* . check/load info (schema reload task) */
- /* . refresh user defined schema */
-
- /* NEW in 5.0 for getting back the backend result in frontend */
- int pb_result_code; /* operation result code */
- char * pb_result_text; /* result text when available */
- char * pb_result_matched; /* macthed dn when NO SUCH OBJECT error */
- int pb_nentries; /* number of entries to be returned */
- struct berval **urls; /* urls of referrals to be returned */
-
- /*
- * wire import (fast replica init) arguments
- */
- struct slapi_entry *pb_import_entry;
- int pb_import_state;
-
- int pb_destroy_content; /* flag to indicate that pblock content should be
- destroyed when pblock is destroyed */
- int pb_dse_reapply_mods; /* if true, dse_modify will reapply mods after modify callback
*/
- char * pb_urp_naming_collision_dn; /* replication naming conflict removal */
- char * pb_urp_tombstone_uniqueid; /* replication change tombstone */
- int pb_server_running; /* indicate that server is running */
- int pb_backend_count; /* instance count involved in the op */
-
- /* For password policy control */
- int pb_pwpolicy_ctrl;
- void *pb_vattr_context; /* hold the vattr_context for roles/cos */
-
- int *pb_substrlens; /* user specified minimum substr search key lengths:
- * nsSubStrBegin, nsSubStrMiddle, nsSubStrEnd
- */
- int pb_plugin_enabled; /* nsslapd-pluginEnabled: on|off */
- /* used in plugin init; pb_plugin is not ready, then */
- LDAPControl **pb_search_ctrls; /* for search operations, allows plugins to provide
- controls to pass for each entry or referral returned */
- IFP pb_mr_index_sv_fn; /* values and keys are Slapi_Value ** */
- int pb_syntax_filter_normalized; /* the syntax filter types/values are already
normalized */
- void *pb_syntax_filter_data; /* extra data to pass to a syntax plugin function */
- int pb_paged_results_index; /* stash SLAPI_PAGED_RESULTS_INDEX */
- int pb_paged_results_cookie; /* stash SLAPI_PAGED_RESULTS_COOKIE */
- passwdPolicy *pwdpolicy;
- void *op_stack_elem;
-
- /* For ACI Target Check */
- int pb_aci_target_check; /* this flag prevents duplicate checking of ACI's target
existence */
-
- struct slapi_entry *pb_pw_entry; /* stash dup'ed entry that shadow info is
added/replaced */
-#ifdef PBLOCK_ANALYTICS
- uint32_t analytics_init;
- PLHashTable *analytics;
-#endif
-} slapi_pblock;
+Slapi_PBlock * slapi_pblock_clone(Slapi_PBlock *pb) __attribute__((deprecated));
+
+passwdPolicy * slapi_pblock_get_pwdpolicy(Slapi_PBlock *pb);
+void slapi_pblock_set_pwdpolicy(Slapi_PBlock *pb, passwdPolicy *pwdpolicy);
+
+int32_t slapi_pblock_get_ldif_dump_replica(Slapi_PBlock *pb);
+void slapi_pblock_set_ldif_dump_replica(Slapi_PBlock *pb, int32_t dump_replica);
+
+void * slapi_pblock_get_vattr_context(Slapi_PBlock *pb);
+void slapi_pblock_set_vattr_context(Slapi_PBlock *pb, void *vattr_ctx);
+
+
+void * slapi_pblock_get_op_stack_elem(Slapi_PBlock *pb);
+void slapi_pblock_set_op_stack_elem(Slapi_PBlock *pb, void *stack_elem);
/* index if substrlens */
#define INDEX_SUBSTRBEGIN 0
@@ -2762,4 +2609,5 @@ extern char *attr_dataversion;
#define _SEC_PER_DAY 86400
#define _MAX_SHADOW 99999
+
#endif /* _slap_h_ */
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index ec8917d..8fe110b 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -528,7 +528,10 @@ NSPR_API(PRUint32) PR_fprintf(struct PRFileDesc* fd, const char *fmt,
...)
* The available parameters that you can use depends on the type of plug-in function
* you are writing.
*/
-typedef struct slapi_pblock Slapi_PBlock;
+// Shadow pointer for pblock
+struct slapi_pblock;
+
+typedef struct slapi_pblock Slapi_PBlock;
/**
* Represents an entry in the directory.
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index d9547d8..f7041bd 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -1410,6 +1410,10 @@ long util_get_hardware_threads(void);
*/
void slapi_create_errormsg(char *errorbuf, size_t len, const char *fmt, ...);
+struct slapi_entry * slapi_pblock_get_pw_entry(Slapi_PBlock *pb);
+void slapi_pblock_set_pw_entry(Slapi_PBlock *pb, struct slapi_entry *entry);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/ldap/servers/slapd/sort.c b/ldap/servers/slapd/sort.c
index 922c103..901172c 100644
--- a/ldap/servers/slapd/sort.c
+++ b/ldap/servers/slapd/sort.c
@@ -25,18 +25,18 @@ sort_make_sort_response_control ( Slapi_PBlock *pb, int code, char
*error_type)
int rc = -1;
ber_int_t control_code;
int pr_idx = -1;
+ Connection *pb_conn;
+ Slapi_Operation *operation;
slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ slapi_pblock_get(pb, SLAPI_OPERATION, &operation);
if (code == CONN_GET_SORT_RESULT_CODE) {
- code = pagedresults_get_sort_result_code(pb->pb_conn,
- pb->pb_op, pr_idx);
+ code = pagedresults_get_sort_result_code(pb_conn, operation, pr_idx);
} else {
- Slapi_Operation *operation;
- slapi_pblock_get (pb, SLAPI_OPERATION, &operation);
if (op_is_pagedresults(operation)) {
- pagedresults_set_sort_result_code(pb->pb_conn,
- pb->pb_op, code, pr_idx);
+ pagedresults_set_sort_result_code(pb_conn, operation, code, pr_idx);
}
}
diff --git a/ldap/servers/slapd/ssl.c b/ldap/servers/slapd/ssl.c
index 186c42b..01b708d 100644
--- a/ldap/servers/slapd/ssl.c
+++ b/ldap/servers/slapd/ssl.c
@@ -939,7 +939,7 @@ freeChildren( char **list ) {
static void
entrySetValue(Slapi_DN *sdn, char *type, char *value)
{
- Slapi_PBlock mypb = {0};
+ Slapi_PBlock *mypb = slapi_pblock_new();
LDAPMod attr;
LDAPMod *mods[2];
char *values[2];
@@ -955,9 +955,9 @@ entrySetValue(Slapi_DN *sdn, char *type, char *value)
mods[0] = &attr;
mods[1] = NULL;
- slapi_modify_internal_set_pb_ext(&mypb, sdn, mods, NULL, NULL, (void
*)plugin_get_default_component_id(), 0);
- slapi_modify_internal_pb(&mypb);
- pblock_done(&mypb);
+ slapi_modify_internal_set_pb_ext(mypb, sdn, mods, NULL, NULL, (void
*)plugin_get_default_component_id(), 0);
+ slapi_modify_internal_pb(mypb);
+ slapi_pblock_destroy(mypb);
}
/* Logs a warning and returns 1 if cert file doesn't exist. You
diff --git a/ldap/servers/slapd/start_tls_extop.c b/ldap/servers/slapd/start_tls_extop.c
index a80cd6f..1e09e47 100644
--- a/ldap/servers/slapd/start_tls_extop.c
+++ b/ldap/servers/slapd/start_tls_extop.c
@@ -127,6 +127,7 @@ start_tls( Slapi_PBlock *pb )
char *oid;
Connection *conn;
+ Operation *pb_op;
int ldaprc = LDAP_SUCCESS;
char *ldapmsg = NULL;
@@ -171,7 +172,7 @@ start_tls( Slapi_PBlock *pb )
/* At least we know that the request was indeed an Start TLS one. */
- conn = pb->pb_conn;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);
PR_EnterMonitor(conn->c_mutex);
/* cannot call slapi_send_ldap_result with mutex locked - will deadlock if ber_flush
returns error */
if ( conn->c_prfd == (PRFileDesc *) NULL ) {
@@ -182,8 +183,10 @@ start_tls( Slapi_PBlock *pb )
goto unlock_and_return;
}
+ slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op);
+
/* Check whether the Start TLS request can be accepted. */
- if ( connection_operations_pending( conn, pb->pb_op,
+ if ( connection_operations_pending( conn, pb_op,
1 /* check for ops where result not yet sent */ )) {
slapi_log_err(SLAPI_LOG_PLUGIN, "start_tls",
"Other operations are still pending on the connection.\n" );
@@ -270,13 +273,14 @@ start_tls_graceful_closure( Connection *c, Slapi_PBlock * pb, int
is_initiator )
struct slapdplugin *plugin;
int secure = 0;
PRFileDesc *ssl_fd;
+ Operation *pb_op = NULL;
if ( pblock == NULL ) {
pblock = slapi_pblock_new();
plugin = (struct slapdplugin *) slapi_ch_calloc( 1, sizeof( struct slapdplugin )
);
- pblock->pb_plugin = plugin;
- pblock->pb_conn = c;
- pblock->pb_op = c->c_ops;
+ slapi_pblock_set(pb, SLAPI_PLUGIN, plugin);
+ slapi_pblock_set(pb, SLAPI_CONNECTION, c);
+ slapi_pblock_set(pb, SLAPI_OPERATION, c->c_ops);
set_db_default_result_handlers( pblock );
if ( slapi_pblock_set( pblock, SLAPI_EXT_OP_RET_OID, START_TLS_OID ) != 0 ) {
slapi_log_err(SLAPI_LOG_PLUGIN, "start_tls",
@@ -288,10 +292,11 @@ start_tls_graceful_closure( Connection *c, Slapi_PBlock * pb, int
is_initiator )
slapi_ch_free( (void **) &plugin );
}
+ slapi_pblock_get(pblock, SLAPI_OPERATION, &pb_op);
/* First thing to do is to finish with whatever operation may be hanging on the
* encrypted session.
*/
- while ( connection_operations_pending( c, pblock->pb_op,
+ while ( connection_operations_pending( c, pb_op,
0 /* wait for all other ops to full complete */ )) {
slapi_log_err(SLAPI_LOG_PLUGIN, "start_tls",
"Still %d operations to be completed before closing the SSL
connection.\n",
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index b5a4c95..8bdf812 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -701,15 +701,15 @@ static Slapi_Entry *get_internal_entry(Slapi_PBlock *pb, char *dn)
static void modify_internal_entry(char *dn, LDAPMod **mods)
{
- Slapi_Operation *op;
int ret = 0;
int tries = 0;
int dont_write_file = 1;
do {
- Slapi_PBlock pb = {0};
+ Slapi_Operation *op;
+ Slapi_PBlock *pb = slapi_pblock_new();
- slapi_modify_internal_set_pb(&pb, dn, mods, NULL, NULL,
+ slapi_modify_internal_set_pb(pb, dn, mods, NULL, NULL,
(void *)plugin_get_default_component_id(), 0);
/* all modifications to the cn=tasks subtree are transient --
@@ -717,13 +717,13 @@ static void modify_internal_entry(char *dn, LDAPMod **mods)
* no need to save them in the dse file.
*/
- slapi_pblock_set(&pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING,
&dont_write_file);
+ slapi_pblock_set(pb, SLAPI_DSE_DONT_WRITE_WHEN_ADDING, &dont_write_file);
/* Make sure these mods are not logged in audit or changelog */
- slapi_pblock_get(&pb, SLAPI_OPERATION, &op);
+ slapi_pblock_get(pb, SLAPI_OPERATION, &op);
operation_set_flag(op, OP_FLAG_ACTION_NOLOG);
- slapi_modify_internal_pb(&pb);
- slapi_pblock_get(&pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
+ slapi_modify_internal_pb(pb);
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret);
if (ret != LDAP_SUCCESS) {
/* could be waiting for another thread to finish adding this
* entry -- try at least 3 times before giving up.
@@ -732,14 +732,13 @@ static void modify_internal_entry(char *dn, LDAPMod **mods)
if (tries == 3) {
slapi_log_err(SLAPI_LOG_WARNING, "modify_internal_entry",
"Can't modify task "
"entry '%s'; %s (%d)\n", dn,
ldap_err2string(ret), ret);
- pblock_done(&pb);
+ slapi_pblock_destroy(pb);
return;
}
DS_Sleep(PR_SecondsToInterval(1));
}
- pblock_done(&pb);
-
+ slapi_pblock_destroy(pb);
} while (ret != LDAP_SUCCESS);
}
@@ -770,7 +769,10 @@ static int task_deny(Slapi_PBlock *pb,
void *arg __attribute__((unused)))
{
/* internal operations (conn=NULL) are allowed to do whatever they want */
- if (pb->pb_conn == NULL) {
+ Connection *pb_conn = NULL;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+
+ if (pb_conn == NULL) {
*returncode = LDAP_SUCCESS;
return SLAPI_DSE_CALLBACK_OK;
}
@@ -791,7 +793,9 @@ static int task_modify(Slapi_PBlock *pb,
int i;
/* the connection block will be NULL for internal operations */
- if (pb->pb_conn == NULL) {
+ Connection *pb_conn = NULL;
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
+ if (pb_conn == NULL) {
*returncode = LDAP_SUCCESS;
return SLAPI_DSE_CALLBACK_OK;
}
@@ -846,7 +850,6 @@ static int task_import_add(Slapi_PBlock *pb __attribute__((unused)),
int idx, rv = 0;
const char *do_attr_indexes, *uniqueid_kind_str;
int uniqueid_kind = SLAPI_UNIQUEID_GENERATE_TIME_BASED;
- Slapi_PBlock mypb = {0};
Slapi_Task *task;
char *nameFrombe_name = NULL;
const char *encrypt_on_import = NULL;
@@ -988,31 +991,43 @@ static int task_import_add(Slapi_PBlock *pb
__attribute__((unused)),
goto out;
}
- mypb.pb_backend = be;
- mypb.pb_plugin = be->be_database;
- mypb.pb_removedupvals = atoi(fetch_attr(e, "nsImportChunkSize",
"0"));
- mypb.pb_ldif2db_noattrindexes =
- !(strcasecmp(do_attr_indexes, "true") == 0);
- mypb.pb_ldif_generate_uniqueid = uniqueid_kind;
- mypb.pb_ldif_namespaceid =
- (char *)fetch_attr(e, "nsUniqueIdGeneratorNamespace", NULL);
- mypb.pb_instance_name = (char *)instance_name;
- mypb.pb_ldif_files = ldif_file;
- mypb.pb_ldif_include = include;
- mypb.pb_ldif_exclude = exclude;
- mypb.pb_task = task;
- mypb.pb_task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+
+ Slapi_PBlock *mypb = slapi_pblock_new();
+ slapi_pblock_set(mypb, SLAPI_BACKEND, be);
+ slapi_pblock_set(mypb, SLAPI_PLUGIN, be->be_database);
+
+ int32_t removedupvals = atoi(fetch_attr(e, "nsImportChunkSize",
"0"));
+ slapi_pblock_set(mypb, SLAPI_LDIF2DB_REMOVEDUPVALS, &removedupvals);
+
+ int32_t noattrindexes = !(strcasecmp(do_attr_indexes, "true") == 0);
+ slapi_pblock_set(mypb, SLAPI_LDIF2DB_NOATTRINDEXES, &noattrindexes);
+
+ slapi_pblock_set(mypb, SLAPI_LDIF2DB_GENERATE_UNIQUEID, &uniqueid_kind);
+
+ char *namespaceid = (char *)fetch_attr(e, "nsUniqueIdGeneratorNamespace",
NULL);
+ slapi_pblock_set(mypb, SLAPI_LDIF2DB_NAMESPACEID, namespaceid);
+
+ slapi_pblock_set(mypb, SLAPI_BACKEND_INSTANCE_NAME, instance_name);
+ slapi_pblock_set(mypb, SLAPI_LDIF2DB_FILE, ldif_file);
+ slapi_pblock_set(mypb, SLAPI_LDIF2DB_INCLUDE, include);
+ slapi_pblock_set(mypb, SLAPI_LDIF2DB_EXCLUDE, exclude);
+ slapi_pblock_set(mypb, SLAPI_BACKEND_TASK, task);
+ int32_t task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+ slapi_pblock_set(mypb, SLAPI_TASK_FLAGS, &task_flags);
+
if (NULL != encrypt_on_import && 0 == strcasecmp(encrypt_on_import,
"true") ) {
- mypb.pb_ldif_encrypt = 1;
+ int32_t encrypt_on_import = 1;
+ slapi_pblock_set(mypb, SLAPI_LDIF2DB_ENCRYPT, &encrypt_on_import);
}
- rv = (*mypb.pb_plugin->plg_ldif2db)(&mypb);
+ rv = (be->be_database->plg_ldif2db)(mypb);
if (rv == 0) {
slapi_entry_attr_set_charptr(e, TASK_LOG_NAME, "");
slapi_entry_attr_set_charptr(e, TASK_STATUS_NAME, "");
slapi_entry_attr_set_int(e, TASK_PROGRESS_NAME, task->task_progress);
slapi_entry_attr_set_int(e, TASK_WORK_NAME, task->task_work);
}
+ slapi_pblock_destroy(mypb);
out:
slapi_ch_free_string(&nameFrombe_name);
@@ -1032,14 +1047,19 @@ out:
static void task_export_thread(void *arg)
{
Slapi_PBlock *pb = (Slapi_PBlock *)arg;
- char **instance_names = (char **)pb->pb_instance_name;
+ // I think someone is mis-using this point to store multiple names ...
+ char **instance_names = NULL;
char **inp;
- char *ldif_file = pb->pb_ldif_file;
+ char *ldif_file = NULL;
char *this_ldif_file = NULL;
Slapi_Backend *be = NULL;
int rv = -1;
int count;
- Slapi_Task *task = pb->pb_task;
+ Slapi_Task *task = NULL;
+
+ slapi_pblock_get(pb, SLAPI_BACKEND_INSTANCE_NAME, &instance_names);
+ slapi_pblock_get(pb, SLAPI_DB2LDIF_FILE, &ldif_file);
+ slapi_pblock_get(pb, SLAPI_BACKEND_TASK, &task);
g_incr_active_threadcnt();
for (count = 0, inp = instance_names; *inp; inp++, count++)
@@ -1057,17 +1077,21 @@ static void task_export_thread(void *arg)
continue;
}
- pb->pb_backend = be;
- pb->pb_plugin = be->be_database;
- pb->pb_instance_name = (char *)*inp;
+ slapi_pblock_set(pb, SLAPI_BACKEND, be);
+ slapi_pblock_set(pb, SLAPI_PLUGIN, be->be_database);
+ slapi_pblock_set(pb, SLAPI_BACKEND_INSTANCE_NAME, *inp);
+
+ int32_t printkey = 0;
+ slapi_pblock_get(pb, SLAPI_DB2LDIF_PRINTKEY, &printkey);
/* ldif_file name for each? */
- if (pb->pb_ldif_printkey & EXPORT_APPENDMODE) {
+ if (printkey & EXPORT_APPENDMODE) {
if (inp == instance_names) { /* first export */
- pb->pb_ldif_printkey |= EXPORT_APPENDMODE_1;
+ printkey |= EXPORT_APPENDMODE_1;
} else {
- pb->pb_ldif_printkey &= ~EXPORT_APPENDMODE_1;
+ printkey &= ~EXPORT_APPENDMODE_1;
}
+ slapi_pblock_set(pb, SLAPI_DB2LDIF_PRINTKEY, &printkey);
} else {
if (strcmp(ldif_file, "-")) { /* not '-' */
char *p;
@@ -1087,7 +1111,7 @@ static void task_export_thread(void *arg)
ldif_file, sep, *inp, q);
*p = sep;
}
- pb->pb_ldif_file = this_ldif_file;
+ slapi_pblock_set(pb, SLAPI_DB2LDIF_FILE, &this_ldif_file);
release_me = 1;
}
}
@@ -1095,7 +1119,7 @@ static void task_export_thread(void *arg)
slapi_task_log_notice(task, "Beginning export of '%s'", *inp);
slapi_log_err(SLAPI_LOG_INFO, "task_export_thread", "Beginning
export of '%s'\n", *inp);
- rv = (*pb->pb_plugin->plg_db2ldif)(pb);
+ rv = (be->be_database->plg_db2ldif)(pb);
if (rv != 0) {
slapi_task_log_notice(task, "backend '%s' export failed
(%d)",
*inp, rv);
@@ -1117,8 +1141,12 @@ static void task_export_thread(void *arg)
/* free the memory now */
charray_free(instance_names);
slapi_ch_free((void **)&ldif_file);
- charray_free(pb->pb_ldif_include);
- charray_free(pb->pb_ldif_exclude);
+ char **include;
+ char **exclude;
+ slapi_pblock_get(pb, SLAPI_LDIF2DB_INCLUDE, &include);
+ slapi_pblock_get(pb, SLAPI_LDIF2DB_EXCLUDE, &exclude);
+ charray_free(include);
+ charray_free(exclude);
slapi_pblock_destroy(pb);
if (rv == 0) {
@@ -1334,18 +1362,22 @@ static int task_export_add(Slapi_PBlock *pb
__attribute__((unused)),
rv = SLAPI_DSE_CALLBACK_ERROR;
goto out;
}
- mypb->pb_ldif_include = include;
- mypb->pb_ldif_exclude = exclude;
- mypb->pb_ldif_printkey = ldif_printkey_flag;
- mypb->pb_ldif_dump_replica = export_replica_flag;
- mypb->pb_ldif_dump_uniqueid = dump_uniqueid_flag;
- mypb->pb_ldif_file = ldif_file;
- /* horrible hack */
- mypb->pb_instance_name = (char *)instance_names;
- mypb->pb_task = task;
- mypb->pb_task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+ slapi_pblock_set(mypb, SLAPI_LDIF2DB_INCLUDE, include);
+ slapi_pblock_set(mypb, SLAPI_LDIF2DB_EXCLUDE, exclude);
+ slapi_pblock_set(mypb, SLAPI_BACKEND_TASK, task);
+ slapi_pblock_set(mypb, SLAPI_DB2LDIF_PRINTKEY, &ldif_printkey_flag);
+
+ slapi_pblock_set_ldif_dump_replica(mypb, export_replica_flag);
+
+ slapi_pblock_set(mypb, SLAPI_DB2LDIF_DUMP_UNIQUEID, &dump_uniqueid_flag);
+ slapi_pblock_set(mypb, SLAPI_DB2LDIF_FILE, ldif_file);
+ /* horrible hack, stuff a list of instance names into a field for one instance name.
*/
+ slapi_pblock_set(mypb, SLAPI_BACKEND_INSTANCE_NAME, (char **)instance_names);
+ int32_t task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+ slapi_pblock_set(mypb, SLAPI_TASK_FLAGS, &task_flags);
if (NULL != decrypt_on_export && 0 == strcasecmp(decrypt_on_export,
"true") ) {
- mypb->pb_ldif_encrypt = 1;
+ int32_t decrypt_on_export = 1;
+ slapi_pblock_set(mypb, SLAPI_DB2LDIF_DECRYPT, &decrypt_on_export);
}
/* start the export as a separate thread */
@@ -1382,18 +1414,22 @@ out:
static void task_backup_thread(void *arg)
{
Slapi_PBlock *pb = (Slapi_PBlock *)arg;
- Slapi_Task *task = pb->pb_task;
+ Slapi_Task *task = NULL;
+ struct slapdplugin *pb_plugin;
int rv;
+ slapi_pblock_get(pb, SLAPI_BACKEND_TASK, &task);
+ slapi_pblock_get(pb, SLAPI_PLUGIN, &pb_plugin);
+
g_incr_active_threadcnt();
slapi_task_begin(task, 1);
slapi_task_log_notice(task, "Beginning backup of '%s'",
- pb->pb_plugin->plg_name);
+ pb_plugin->plg_name);
slapi_log_err(SLAPI_LOG_INFO, "task_backup_thread", "Beginning backup
of '%s'\n",
- pb->pb_plugin->plg_name);
+ pb_plugin->plg_name);
- rv = (*pb->pb_plugin->plg_db2archive)(pb);
+ rv = (*pb_plugin->plg_db2archive)(pb);
if (rv != 0) {
slapi_task_log_notice(task, "Backup failed (error %d)", rv);
slapi_task_log_status(task, "Backup failed (error %d)", rv);
@@ -1405,7 +1441,9 @@ static void task_backup_thread(void *arg)
}
slapi_task_finish(task, rv);
- slapi_ch_free((void **)&pb->pb_seq_val);
+ char *seq_val = NULL;
+ slapi_pblock_get(pb, SLAPI_SEQ_VAL, &seq_val);
+ slapi_ch_free((void **)&seq_val);
slapi_pblock_destroy(pb);
g_decr_active_threadcnt();
}
@@ -1488,10 +1526,12 @@ static int task_backup_add(Slapi_PBlock *pb
__attribute__((unused)),
rv = SLAPI_DSE_CALLBACK_ERROR;
goto out;
}
- mypb->pb_seq_val = slapi_ch_strdup(archive_dir);
- mypb->pb_plugin = be->be_database;
- mypb->pb_task = task;
- mypb->pb_task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+ char *seq_val = slapi_ch_strdup(archive_dir);
+ slapi_pblock_set(mypb, SLAPI_SEQ_VAL, seq_val);
+ slapi_pblock_set(mypb, SLAPI_PLUGIN, (be->be_database));
+ slapi_pblock_set(mypb, SLAPI_BACKEND_TASK, task);
+ int32_t task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+ slapi_pblock_set(mypb, SLAPI_TASK_FLAGS, &task_flags);
/* start the backup as a separate thread */
thread = PR_CreateThread(PR_USER_THREAD, task_backup_thread,
@@ -1502,7 +1542,7 @@ static int task_backup_add(Slapi_PBlock *pb
__attribute__((unused)),
"task_backup_add", "Unable to create backup
thread!\n");
*returncode = LDAP_OPERATIONS_ERROR;
rv = SLAPI_DSE_CALLBACK_ERROR;
- slapi_ch_free((void **)&mypb->pb_seq_val);
+ slapi_ch_free((void **)&seq_val);
slapi_pblock_destroy(mypb);
goto out;
}
@@ -1521,18 +1561,22 @@ out:
static void task_restore_thread(void *arg)
{
Slapi_PBlock *pb = (Slapi_PBlock *)arg;
- Slapi_Task *task = pb->pb_task;
+ Slapi_Task *task = NULL;
+ struct slapdplugin *pb_plugin;
int rv;
+ slapi_pblock_get(pb, SLAPI_BACKEND_TASK, &task);
+ slapi_pblock_get(pb, SLAPI_PLUGIN, &pb_plugin);
+
g_incr_active_threadcnt();
slapi_task_begin(task, 1);
slapi_task_log_notice(task, "Beginning restore to '%s'",
- pb->pb_plugin->plg_name);
+ pb_plugin->plg_name);
slapi_log_err(SLAPI_LOG_INFO, "task_restore_thread", "Beginning
restore to '%s'\n",
- pb->pb_plugin->plg_name);
+ pb_plugin->plg_name);
- rv = (*pb->pb_plugin->plg_archive2db)(pb);
+ rv = (*pb_plugin->plg_archive2db)(pb);
if (rv != 0) {
slapi_task_log_notice(task, "Restore failed (error %d)", rv);
slapi_task_log_status(task, "Restore failed (error %d)", rv);
@@ -1544,8 +1588,15 @@ static void task_restore_thread(void *arg)
}
slapi_task_finish(task, rv);
- slapi_ch_free((void **)&pb->pb_seq_val);
- slapi_ch_free_string(&pb->pb_instance_name);
+
+ char *seq_val = NULL;
+ slapi_pblock_get(pb, SLAPI_SEQ_VAL, &seq_val);
+ slapi_ch_free((void **)&seq_val);
+
+ char *instance_name = NULL;
+ slapi_pblock_get(pb, SLAPI_BACKEND_INSTANCE_NAME, &instance_name);
+ slapi_ch_free_string(&instance_name);
+
slapi_pblock_destroy(pb);
g_decr_active_threadcnt();
}
@@ -1633,12 +1684,17 @@ static int task_restore_add(Slapi_PBlock *pb,
rv = SLAPI_DSE_CALLBACK_ERROR;
goto out;
}
- mypb->pb_seq_val = slapi_ch_strdup(archive_dir);
- mypb->pb_plugin = be->be_database;
- if (NULL != instance_name)
- mypb->pb_instance_name = slapi_ch_strdup(instance_name);
- mypb->pb_task = task;
- mypb->pb_task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+ char *pb_instance_name = NULL;
+ char *seq_val = slapi_ch_strdup(archive_dir);
+ slapi_pblock_set(mypb, SLAPI_SEQ_VAL, seq_val);
+ slapi_pblock_set(mypb, SLAPI_PLUGIN, be->be_database);
+ if (NULL != instance_name) {
+ pb_instance_name = slapi_ch_strdup(instance_name);
+ slapi_pblock_set(mypb, SLAPI_BACKEND_INSTANCE_NAME, pb_instance_name);
+ }
+ slapi_pblock_set(mypb, SLAPI_BACKEND_TASK, task);
+ int32_t task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+ slapi_pblock_set(mypb, SLAPI_TASK_FLAGS, &task_flags);
/* start the restore as a separate thread */
thread = PR_CreateThread(PR_USER_THREAD, task_restore_thread,
@@ -1649,8 +1705,10 @@ static int task_restore_add(Slapi_PBlock *pb,
"task_restore_add", "Unable to create restore
thread!\n");
*returncode = LDAP_OPERATIONS_ERROR;
rv = SLAPI_DSE_CALLBACK_ERROR;
- slapi_ch_free((void **)&mypb->pb_seq_val);
- slapi_ch_free_string(&pb->pb_instance_name);
+ slapi_ch_free((void **)&seq_val);
+ if (instance_name) {
+ slapi_ch_free_string(&pb_instance_name);
+ }
slapi_pblock_destroy(mypb);
goto out;
}
@@ -1669,13 +1727,21 @@ out:
static void task_index_thread(void *arg)
{
Slapi_PBlock *pb = (Slapi_PBlock *)arg;
- Slapi_Task *task = pb->pb_task;
+ char *instance_name = NULL;
+ char **db2index_attrs = NULL;
+ Slapi_Task *task = NULL;
+ struct slapdplugin *pb_plugin;
int rv;
+ slapi_pblock_get(pb, SLAPI_BACKEND_TASK, &task);
+ slapi_pblock_get(pb, SLAPI_PLUGIN, &pb_plugin);
+ slapi_pblock_get(pb, SLAPI_DB2INDEX_ATTRS, &db2index_attrs);
+ slapi_pblock_get(pb, SLAPI_BACKEND_INSTANCE_NAME, &instance_name);
+
g_incr_active_threadcnt();
slapi_task_begin(task, 1);
- rv = (*pb->pb_plugin->plg_db2index)(pb);
+ rv = (*pb_plugin->plg_db2index)(pb);
if (rv != 0) {
slapi_task_log_notice(task, "Index failed (error %d)", rv);
slapi_task_log_status(task, "Index failed (error %d)", rv);
@@ -1683,8 +1749,8 @@ static void task_index_thread(void *arg)
}
slapi_task_finish(task, rv);
- charray_free(pb->pb_db2index_attrs);
- slapi_ch_free((void **)&pb->pb_instance_name);
+ charray_free(db2index_attrs);
+ slapi_ch_free((void **)&instance_name);
slapi_pblock_destroy(pb);
g_decr_active_threadcnt();
}
@@ -1782,12 +1848,14 @@ static int task_index_add(Slapi_PBlock *pb
__attribute__((unused)),
rv = SLAPI_DSE_CALLBACK_ERROR;
goto out;
}
- mypb->pb_backend = be;
- mypb->pb_plugin = be->be_database;
- mypb->pb_instance_name = slapi_ch_strdup(instance_name);
- mypb->pb_db2index_attrs = indexlist;
- mypb->pb_task = task;
- mypb->pb_task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+ slapi_pblock_set(mypb, SLAPI_BACKEND, be);
+ slapi_pblock_set(mypb, SLAPI_PLUGIN, be->be_database);
+ slapi_pblock_set(mypb, SLAPI_BACKEND_TASK, task);
+ int32_t task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+ slapi_pblock_set(mypb, SLAPI_TASK_FLAGS, &task_flags);
+ char *copy_instance_name = slapi_ch_strdup(instance_name);
+ slapi_pblock_set(mypb, SLAPI_BACKEND_INSTANCE_NAME, copy_instance_name);
+ slapi_pblock_set(mypb, SLAPI_DB2INDEX_ATTRS, indexlist);
/* start the db2index as a separate thread */
thread = PR_CreateThread(PR_USER_THREAD, task_index_thread,
@@ -1797,7 +1865,7 @@ static int task_index_add(Slapi_PBlock *pb __attribute__((unused)),
slapi_log_err(SLAPI_LOG_ERR,
"task_index_add", "Unable to create index
thread!\n");
rv = SLAPI_DSE_CALLBACK_ERROR;
- slapi_ch_free((void **)&mypb->pb_instance_name);
+ slapi_ch_free((void **)©_instance_name);
slapi_pblock_destroy(mypb);
goto out;
}
@@ -1826,7 +1894,6 @@ task_upgradedb_add(Slapi_PBlock *pb __attribute__((unused)),
int rv = SLAPI_DSE_CALLBACK_OK;
Slapi_Backend *be = NULL;
Slapi_Task *task = NULL;
- Slapi_PBlock mypb = {0};
const char *archive_dir = NULL;
const char *force = NULL;
const char *database_type = "ldbm database";
@@ -1893,15 +1960,19 @@ task_upgradedb_add(Slapi_PBlock *pb __attribute__((unused)),
task->task_work = 1;
task->task_progress = 0;
- mypb.pb_backend = be;
- mypb.pb_plugin = be->be_database;
- if (force && 0 == strcasecmp(force, "true"))
- mypb.pb_seq_type = SLAPI_UPGRADEDB_FORCE; /* force; reindex all regardless the
dbversion */
- mypb.pb_seq_val = slapi_ch_strdup(archive_dir);
- mypb.pb_task = task;
- mypb.pb_task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+ Slapi_PBlock *mypb = slapi_pblock_new();
+ slapi_pblock_set(mypb, SLAPI_BACKEND, be);
+ slapi_pblock_set(mypb, SLAPI_PLUGIN, be->be_database);
+ if (force && 0 == strcasecmp(force, "true")) {
+ int32_t seq_type = SLAPI_UPGRADEDB_FORCE; /* force; reindex all regardless the
dbversion */
+ slapi_pblock_set(mypb, SLAPI_SEQ_TYPE, &seq_type);
+ }
+ char *seq_val = slapi_ch_strdup(archive_dir);
+ slapi_pblock_set(pb, SLAPI_BACKEND_TASK, task);
+ int32_t task_flags = SLAPI_TASK_RUNNING_AS_TASK;
+ slapi_pblock_set(mypb, SLAPI_TASK_FLAGS, &task_flags);
- rv = (mypb.pb_plugin->plg_upgradedb)(&mypb);
+ rv = (be->be_database->plg_upgradedb)(&mypb);
if (rv == 0) {
slapi_entry_attr_set_charptr(e, TASK_LOG_NAME, "");
slapi_entry_attr_set_charptr(e, TASK_STATUS_NAME, "");
@@ -1910,7 +1981,7 @@ task_upgradedb_add(Slapi_PBlock *pb __attribute__((unused)),
}
out:
- slapi_ch_free((void **)&mypb.pb_seq_val);
+ slapi_ch_free((void **)&seq_val);
if (rv != 0) {
if (task)
destroy_task(1, task);
diff --git a/ldap/servers/slapd/unbind.c b/ldap/servers/slapd/unbind.c
index 92dd905..232f9b3 100644
--- a/ldap/servers/slapd/unbind.c
+++ b/ldap/servers/slapd/unbind.c
@@ -35,6 +35,7 @@ void
do_unbind( Slapi_PBlock *pb )
{
Slapi_Operation *operation;
+ Connection *pb_conn;
BerElement *ber;
int err;
int ignore_criticality = 1;
@@ -42,6 +43,7 @@ do_unbind( Slapi_PBlock *pb )
slapi_log_err(SLAPI_LOG_TRACE, "do_unbind", "=>\n");
slapi_pblock_get( pb, SLAPI_OPERATION, &operation);
+ slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn);
ber = operation->o_ber;
/*
* Parse the unbind request. It looks like this:
@@ -51,7 +53,7 @@ do_unbind( Slapi_PBlock *pb )
if ( ber_get_null( ber ) == LBER_ERROR ) {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d
UNBIND,"
" decoding error: UnBindRequest not null\n",
- pb->pb_conn->c_connid, operation->o_opid );
+ pb_conn->c_connid, operation->o_opid );
/* LDAPv3 does not allow a response to an unbind... so just return. */
goto free_and_return;
}
@@ -66,27 +68,27 @@ do_unbind( Slapi_PBlock *pb )
if ( (err = get_ldapmessage_controls_ext( pb, ber, NULL, ignore_criticality )) != 0 ) {
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d
UNBIND,"
" error processing controls - error %d (%s)\n",
- pb->pb_conn->c_connid, operation->o_opid,
+ pb_conn->c_connid, operation->o_opid,
err, ldap_err2string( err ));
/* LDAPv3 does not allow a response to an unbind... so just return. */
goto free_and_return;
}
/* target spec is used to decide which plugins are applicable for the operation */
- PR_EnterMonitor(pb->pb_conn->c_mutex);
- operation_set_target_spec_str (operation, pb->pb_conn->c_dn);
- PR_ExitMonitor(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb_conn->c_mutex);
+ operation_set_target_spec_str (operation, pb_conn->c_dn);
+ PR_ExitMonitor(pb_conn->c_mutex);
/* ONREPL - plugins should be called and passed bind dn and, possibly, other data */
slapi_log_access( LDAP_DEBUG_STATS, "conn=%" PRIu64 " op=%d
UNBIND\n",
- pb->pb_conn->c_connid, operation->o_opid );
+ pb_conn->c_connid, operation->o_opid );
/* pass the unbind to all backends */
- be_unbindall( pb->pb_conn, operation );
+ be_unbindall( pb_conn, operation );
/* close the connection to the client */
- disconnect_server( pb->pb_conn, operation->o_connid, operation->o_opid,
SLAPD_DISCONNECT_UNBIND, 0);
+ disconnect_server( pb_conn, operation->o_connid, operation->o_opid,
SLAPD_DISCONNECT_UNBIND, 0);
free_and_return:;
}
diff --git a/ldap/servers/slapd/vattr.c b/ldap/servers/slapd/vattr.c
index 9109433..2ee6d54 100644
--- a/ldap/servers/slapd/vattr.c
+++ b/ldap/servers/slapd/vattr.c
@@ -272,9 +272,13 @@ static int vattr_helper_get_entry_conts_ex(Slapi_Entry *e,const char
*type, vatt
vattr_context *vattr_context_new( Slapi_PBlock *pb )
{
+ void *pb_vattr_context = NULL;
+ if (pb != NULL) {
+ pb_vattr_context = slapi_pblock_get_vattr_context(pb);
+ }
vattr_context *c = NULL;
- if (pb && pb->pb_vattr_context) {
- c = (vattr_context *)pb->pb_vattr_context;
+ if (pb_vattr_context) {
+ c = (vattr_context *)pb_vattr_context;
} else {
c = (vattr_context *)slapi_ch_calloc(1, sizeof(vattr_context));
}
@@ -282,8 +286,8 @@ vattr_context *vattr_context_new( Slapi_PBlock *pb )
if ( c ) {
c->pb = pb;
}
- if ( pb && c != (vattr_context *)pb->pb_vattr_context ) {
- pb->pb_vattr_context = (void *)c;
+ if ( pb && c != (vattr_context *)pb_vattr_context ) {
+ slapi_pblock_set_vattr_context(pb, (void *)c);
}
return c;
@@ -314,7 +318,7 @@ static void vattr_context_ungrok(vattr_context **c)
if (0 == vattr_context_unmark(*c)) {
/* If necessary, delete the structure */
if ((*c)->pb) {
- (*c)->pb->pb_vattr_context = NULL;
+ slapi_pblock_set_vattr_context((*c)->pb, NULL);
}
slapi_ch_free((void **)c);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.