From eacb3c96ad2ae9e448ee547a796154d27e985b7f Mon Sep 17 00:00:00 2001 From: William Brown Date: Apr 20 2017 23:01:50 +0000 Subject: Ticket 49097 - whitespace fixes for pblock change Bug Description: While fixing the pblock, I added a number of whitespace errors. This resolves them. Fix Description: Fix the whitespace in the changes. https://pagure.io/389-ds-base/issue/49097 Author: wibrown Review by: mreynolds (Thanks!) --- diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c index fc6f726..c06dae1 100644 --- a/ldap/servers/plugins/acl/acleffectiverights.c +++ b/ldap/servers/plugins/acl/acleffectiverights.c @@ -104,8 +104,8 @@ _ger_g_permission_granted ( else { slapi_ch_free_string(&proxydn); /* this could still have been set - free it */ - Operation *pb_op; - slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); + 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/slapd/abandon.c b/ldap/servers/slapd/abandon.c index 779ec49..581b6d2 100644 --- a/ldap/servers/slapd/abandon.c +++ b/ldap/servers/slapd/abandon.c @@ -35,12 +35,12 @@ do_abandon( Slapi_PBlock *pb ) { int err, suppressed_by_plugin = 0; ber_int_t id; - Connection *pb_conn = NULL; - Operation *pb_op = NULL; + Connection *pb_conn = NULL; + Operation *pb_op = NULL; Operation *o; - slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); - slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); + slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); + slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); BerElement *ber = pb_op->o_ber; @@ -100,9 +100,9 @@ do_abandon( Slapi_PBlock *pb ) are applicable for the operation */ ts = operation_get_target_spec (o); if (ts) { - operation_set_target_spec (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"); + slapi_log_err(SLAPI_LOG_TRACE, "do_abandon", "no target spec of abandoned operation\n"); } operation_set_abandoned_op (pb_op, o->o_abandoned_op); diff --git a/ldap/servers/slapd/add.c b/ldap/servers/slapd/add.c index 1286b89..7fa5444 100644 --- a/ldap/servers/slapd/add.c +++ b/ldap/servers/slapd/add.c @@ -60,11 +60,11 @@ do_add( Slapi_PBlock *pb ) int err; int rc; PRBool searchsubentry=PR_TRUE; - Connection *pb_conn = NULL; + 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_CONNECTION, &pb_conn); slapi_pblock_get( pb, SLAPI_OPERATION, &operation); ber = operation->o_ber; @@ -284,9 +284,9 @@ done: Slapi_PBlock * slapi_add_entry_internal(Slapi_Entry *e, LDAPControl **controls, int dummy __attribute__((unused))) { - Slapi_PBlock *pb = slapi_pblock_new(); - Slapi_PBlock *result_pb = NULL; - int opresult; + Slapi_PBlock *pb = slapi_pblock_new(); + Slapi_PBlock *result_pb = NULL; + int opresult; slapi_add_entry_internal_set_pb (pb, e, controls, plugin_get_default_component_id(), 0); @@ -298,9 +298,9 @@ slapi_add_entry_internal(Slapi_Entry *e, LDAPControl **controls, int dummy __att slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); slapi_pblock_set(result_pb, SLAPI_PLUGIN_INTOP_RESULT, &opresult); } - slapi_pblock_destroy(pb); + slapi_pblock_destroy(pb); - return result_pb; + return result_pb; } /* This is new style API to issue internal add operation. @@ -431,10 +431,10 @@ static void op_shared_add (Slapi_PBlock *pb) char *errtext = NULL; Slapi_DN *sdn = NULL; passwdPolicy *pwpolicy; - Connection *pb_conn = NULL; + Connection *pb_conn = NULL; slapi_pblock_get (pb, SLAPI_OPERATION, &operation); - slapi_pblock_get (pb, SLAPI_CONNECTION, &pb_conn); + 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); @@ -446,8 +446,8 @@ static void op_shared_add (Slapi_PBlock *pb) if ((err = slapi_entry_add_rdn_values(e)) != LDAP_SUCCESS) { - send_ldap_result(pb, err, NULL, "failed to add RDN values", 0, NULL); - goto done; + send_ldap_result(pb, err, NULL, "failed to add RDN values", 0, NULL); + goto done; } /* get the proxy auth dn if the proxy auth control is present */ diff --git a/ldap/servers/slapd/back-ldbm/findentry.c b/ldap/servers/slapd/back-ldbm/findentry.c index 7565c43..c29579e 100644 --- a/ldap/servers/slapd/back-ldbm/findentry.c +++ b/ldap/servers/slapd/back-ldbm/findentry.c @@ -159,8 +159,8 @@ find_entry_internal_dn( struct backentry *me; Slapi_DN ancestorsdn; slapi_sdn_init(&ancestorsdn); - Slapi_Backend *pb_backend; - slapi_pblock_get(pb, SLAPI_BACKEND, &pb_backend); + 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 ) { diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c index bb34c3f..a3dac66 100644 --- a/ldap/servers/slapd/back-ldbm/index.c +++ b/ldap/servers/slapd/back-ldbm/index.c @@ -2022,9 +2022,8 @@ index_addordel_values_ext_sv( } ainfo_get( be, basetype, &ai ); - if ( ai == NULL || ai->ai_indexmask == 0 - || ai->ai_indexmask == INDEX_OFFLINE ) { - slapi_ch_free_string( &basetmp ); + if ( ai == NULL || ai->ai_indexmask == 0 || ai->ai_indexmask == INDEX_OFFLINE ) { + slapi_ch_free_string( &basetmp ); return( 0 ); } slapi_log_err(SLAPI_LOG_ARGS, "index_addordel_values_ext_sv", "indexmask 0x%x\n", @@ -2033,7 +2032,7 @@ index_addordel_values_ext_sv( slapi_log_err(SLAPI_LOG_ERR, "index_addordel_values_ext_sv", "index_read NULL (could not open index attr %s)\n", basetype); - slapi_ch_free_string( &basetmp ); + slapi_ch_free_string( &basetmp ); if ( err != 0 ) { ldbm_nasty("index_addordel_values_ext_sv", errmsg, 1210, err); } @@ -2101,10 +2100,10 @@ index_addordel_values_ext_sv( Slapi_Value **esubvals = NULL; Slapi_Value **substresult = NULL; Slapi_Value **origvals = NULL; - Slapi_PBlock *pipb = slapi_pblock_new(); + Slapi_PBlock *pipb = slapi_pblock_new(); - /* prepare pblock to pass ai_substr_lens */ - slapi_pblock_set( pipb, SLAPI_SYNTAX_SUBSTRLENS, ai->ai_substr_lens ); + /* prepare pblock to pass ai_substr_lens */ + 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; @@ -2154,8 +2153,8 @@ index_addordel_values_ext_sv( matchrule_values_to_keys_sv(pb,vals,&keys); /* the matching rule indexer owns keys now */ if(keys != NULL && keys[0] != NULL) - { - /* we've computed keys */ + { + /* we've computed keys */ err = addordel_values_sv (be, db, basetype, officialOID, keys, id, flags, txn, ai, idl_disposition, NULL); if ( err != 0 ) { diff --git a/ldap/servers/slapd/back-ldbm/ldbm_delete.c b/ldap/servers/slapd/back-ldbm/ldbm_delete.c index 65b0cce..cfc18b0 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_delete.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_delete.c @@ -78,7 +78,7 @@ ldbm_back_delete( Slapi_PBlock *pb ) ID ep_id = 0; ID tomb_ep_id = 0; int result_sent = 0; - Connection *pb_conn; + Connection *pb_conn; if (slapi_pblock_get(pb, SLAPI_CONN_ID, &conn_id) < 0) { conn_id = 0; /* connection is NULL */ @@ -91,7 +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_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); slapi_sdn_init(&nscpEntrySDN); slapi_sdn_init(&parentsdn); diff --git a/ldap/servers/slapd/back-ldbm/vlv.c b/ldap/servers/slapd/back-ldbm/vlv.c index 4840be2..37cf25d 100644 --- a/ldap/servers/slapd/back-ldbm/vlv.c +++ b/ldap/servers/slapd/back-ldbm/vlv.c @@ -1198,33 +1198,32 @@ vlv_search_build_candidate_list(Slapi_PBlock *pb, const Slapi_DN *base, int *vlv backend *be; int scope, rc=LDAP_SUCCESS; char *fstr; - back_txn txn = {NULL}; + back_txn txn = {NULL}; - slapi_pblock_get( pb, SLAPI_TXN, &txn.back_txn_txn ); + slapi_pblock_get( pb, SLAPI_TXN, &txn.back_txn_txn ); slapi_pblock_get( pb, SLAPI_BACKEND, &be ); - slapi_pblock_get( pb, SLAPI_SEARCH_SCOPE, &scope ); - slapi_pblock_get( pb, SLAPI_SEARCH_STRFILTER, &fstr ); + slapi_pblock_get( pb, SLAPI_SEARCH_SCOPE, &scope ); + slapi_pblock_get( pb, SLAPI_SEARCH_STRFILTER, &fstr ); slapi_rwlock_rdlock(be->vlvSearchList_lock); 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; + 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 ); + slapi_pblock_get( pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx ); + slapi_rwlock_unlock(be->vlvSearchList_lock); + 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_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; + 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); + slapi_rwlock_unlock(be->vlvSearchList_lock); rc = VLV_ACCESS_DENIED; - } else if ((*vlv_rc=vlv_build_candidate_list(be,pi,vlv_request_control,candidates, - vlv_response_control, 1, &txn)) != LDAP_SUCCESS) { + } else if ((*vlv_rc=vlv_build_candidate_list(be,pi,vlv_request_control,candidates, vlv_response_control, 1, &txn)) != LDAP_SUCCESS) { rc = VLV_BLD_LIST_FAILED; vlv_response_control->result=*vlv_rc; } diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c index 41e112e..7f4414f 100644 --- a/ldap/servers/slapd/bind.c +++ b/ldap/servers/slapd/bind.c @@ -59,16 +59,16 @@ do_bind( Slapi_PBlock *pb ) 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; - int auth_response_requested = 0; - int pw_response_requested = 0; - char *rawdn = NULL; - const char *dn = NULL; - char *saslmech = NULL; - struct berval cred = {0}; + BerElement *ber = pb_op->o_ber; + int err, isroot; + ber_tag_t method = LBER_DEFAULT; + ber_int_t version = -1; + int auth_response_requested = 0; + int pw_response_requested = 0; + char *rawdn = NULL; + const char *dn = NULL; + char *saslmech = NULL; + struct berval cred = {0}; ber_tag_t ber_rc; int rc = 0; Slapi_DN *sdn = NULL; diff --git a/ldap/servers/slapd/compare.c b/ldap/servers/slapd/compare.c index d66bf3b..6903027 100644 --- a/ldap/servers/slapd/compare.c +++ b/ldap/servers/slapd/compare.c @@ -33,10 +33,10 @@ void do_compare( Slapi_PBlock *pb ) { - Operation *pb_op = NULL; - Connection *pb_conn = NULL; - slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); - slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); + 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; @@ -54,7 +54,7 @@ do_compare( Slapi_PBlock *pb ) slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsCompareOps); /* have to init this here so we can "done" it below if we short circuit */ - slapi_sdn_init(&sdn); + slapi_sdn_init(&sdn); /* * Parse the compare request. It looks like this: @@ -91,14 +91,14 @@ do_compare( Slapi_PBlock *pb ) } slapi_sdn_init_dn_passin(&sdn, rawdn); dn = slapi_sdn_get_dn(&sdn); - if (rawdn && (strlen(rawdn) > 0) && (NULL == dn)) { - /* normalization failed */ - op_shared_log_error_access(pb, "CMP", rawdn, "invalid dn"); - send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX, NULL, - "invalid dn", 0, NULL); - slapi_sdn_done(&sdn); - return; - } + if (rawdn && (strlen(rawdn) > 0) && (NULL == dn)) { + /* normalization failed */ + op_shared_log_error_access(pb, "CMP", rawdn, "invalid dn"); + send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX, NULL, + "invalid dn", 0, NULL); + slapi_sdn_done(&sdn); + return; + } /* * in LDAPv3 there can be optional control extensions on * the end of an LDAPMessage. we need to read them in and @@ -148,8 +148,8 @@ do_compare( Slapi_PBlock *pb ) } if ( be->be_compare != NULL ) { - int isroot; - + int isroot; + slapi_pblock_set( pb, SLAPI_BACKEND, be ); isroot = pb_op->o_isroot; @@ -181,8 +181,9 @@ do_compare( Slapi_PBlock *pb ) } free_and_return:; - if (be) + if (be) { slapi_be_Unlock(be); + } slapi_sdn_done(&sdn); ava_done( &ava ); } diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c index 3b2f6d5..7aa2716 100644 --- a/ldap/servers/slapd/connection.c +++ b/ldap/servers/slapd/connection.c @@ -949,10 +949,10 @@ void connection_make_new_pb(Slapi_PBlock *pb, Connection *conn) */ /* *ppb = (Slapi_PBlock *) slapi_ch_calloc( 1, sizeof(Slapi_PBlock) ); */ /* *ppb = slapi_pblock_new(); */ - slapi_pblock_set(pb, SLAPI_CONNECTION, conn); + slapi_pblock_set(pb, SLAPI_CONNECTION, conn); stack_obj = connection_get_operation(); - slapi_pblock_set(pb, SLAPI_OPERATION, stack_obj->op); - slapi_pblock_set_op_stack_elem(pb, stack_obj); + 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 ); } @@ -1506,8 +1506,8 @@ connection_threadmain() int maxthreads = 0; int enable_nunc_stans = 0; long bypasspollcnt = 0; - Connection *pb_conn = NULL; - Operation *pb_op = NULL; + Connection *pb_conn = NULL; + Operation *pb_op = NULL; #ifdef ENABLE_NUNC_STANS enable_nunc_stans = config_get_enable_nunc_stans(); @@ -1535,11 +1535,11 @@ connection_threadmain() [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); + /* + * 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: @@ -1606,8 +1606,8 @@ connection_threadmain() } } /* Once we're here we have a pb */ - slapi_pblock_get(pb, SLAPI_CONNECTION, &conn); - slapi_pblock_get(pb, SLAPI_OPERATION, &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); @@ -2057,9 +2057,9 @@ void connection_remove_operation_ext( Slapi_PBlock *pb, Connection *conn, Operation *op ) { connection_remove_operation(conn, op); - void *op_stack_elem = slapi_pblock_get_op_stack_elem(pb); + 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_set(pb, SLAPI_OPERATION, NULL); slapi_pblock_init(pb); } @@ -2162,9 +2162,8 @@ connection_set_ssl_ssf(Connection *conn) static int is_ber_too_big(const Connection *conn, ber_len_t ber_len) { - ber_len_t maxbersize = config_get_maxbersize(); - if(ber_len > maxbersize) - { + ber_len_t maxbersize = config_get_maxbersize(); + if (ber_len > maxbersize) { log_ber_too_big_error(conn, ber_len, maxbersize); return 1; } @@ -2220,7 +2219,7 @@ static ps_wakeup_all_fn_ptr ps_wakeup_all_fn = NULL; void disconnect_server_nomutex_ext( Connection *conn, PRUint64 opconnid, int opid, PRErrorCode reason, PRInt32 error, int schedule_closure_job ) { - if ( ( conn->c_sd != SLAPD_INVALID_SOCKET && + if ( ( conn->c_sd != SLAPD_INVALID_SOCKET && conn->c_connid == opconnid ) && !(conn->c_flags & CONN_FLAG_CLOSING) ) { slapi_log_err(SLAPI_LOG_CONNS, "disconnect_server_nomutex_ext", "Setting conn %" PRIu64 " fd=%d " diff --git a/ldap/servers/slapd/control.c b/ldap/servers/slapd/control.c index 981dca1..c302e4b 100644 --- a/ldap/servers/slapd/control.c +++ b/ldap/servers/slapd/control.c @@ -176,12 +176,12 @@ get_ldapmessage_controls_ext( { LDAPControl **ctrls, *new; ber_tag_t tag; - /* ber_len_t is uint, cannot be -1 */ + /* ber_len_t is uint, cannot be -1 */ ber_len_t len = LBER_ERROR; int rc, maxcontrols, curcontrols; char *last; int managedsait, pwpolicy_ctrl; - Connection *pb_conn = NULL; + Connection *pb_conn = NULL; /* * Each LDAPMessage can have a set of controls appended diff --git a/ldap/servers/slapd/defbackend.c b/ldap/servers/slapd/defbackend.c index 57290ee..8da702a 100644 --- a/ldap/servers/slapd/defbackend.c +++ b/ldap/servers/slapd/defbackend.c @@ -91,27 +91,27 @@ defbackend_init( void ) */ errmsg = "slapi_pblock_set handlers failed"; rc = slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, - (void *)SLAPI_PLUGIN_CURRENT_VERSION ); + (void *)SLAPI_PLUGIN_CURRENT_VERSION ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_BIND_FN, - (void *)defbackend_bind ); + (void *)defbackend_bind ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_UNBIND_FN, - (void *)defbackend_noop ); + (void *)defbackend_noop ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_SEARCH_FN, - (void *)defbackend_default ); + (void *)defbackend_default ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN, - (void *)defbackend_next_search_entry ); + (void *)defbackend_next_search_entry ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_COMPARE_FN, - (void *)defbackend_default ); + (void *)defbackend_default ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_MODIFY_FN, - (void *)defbackend_default ); + (void *)defbackend_default ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_MODRDN_FN, - (void *)defbackend_default ); + (void *)defbackend_default ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_ADD_FN, - (void *)defbackend_default ); + (void *)defbackend_default ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_DELETE_FN, - (void *)defbackend_default ); + (void *)defbackend_default ); rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DB_ABANDON_FN, - (void *)defbackend_abandon ); + (void *)defbackend_abandon ); cleanup_and_return: diff --git a/ldap/servers/slapd/delete.c b/ldap/servers/slapd/delete.c index fbcca6a..6ce74bb 100644 --- a/ldap/servers/slapd/delete.c +++ b/ldap/servers/slapd/delete.c @@ -260,10 +260,10 @@ 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); + 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_conn->c_connid, pb_op->o_opid, diff --git a/ldap/servers/slapd/fedse.c b/ldap/servers/slapd/fedse.c index 04fab98..c3dfdc7 100644 --- a/ldap/servers/slapd/fedse.c +++ b/ldap/servers/slapd/fedse.c @@ -1542,7 +1542,7 @@ internal_add_helper(Slapi_Entry *e, int dont_write_file) operation_set_flag(op, OP_FLAG_ACTION_NOLOG); slapi_add_internal_pb(newpb); - slapi_pblock_destroy(newpb); + slapi_pblock_destroy(newpb); } /* @@ -1566,22 +1566,22 @@ 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)", - load_plugin_entry, NULL, NULL); - dse_register_callback(pfedse,DSE_OPERATION_READ,DSE_FLAG_PREOP,config, - LDAP_SCOPE_BASE,"(objectclass=*)", - load_config_dse,NULL, NULL); - - 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); + int dont_write = 1; + dse_register_callback(pfedse,DSE_OPERATION_READ,DSE_FLAG_PREOP,config, + LDAP_SCOPE_SUBTREE,"(objectclass=nsslapdPlugin)", + load_plugin_entry, NULL, NULL); + dse_register_callback(pfedse,DSE_OPERATION_READ,DSE_FLAG_PREOP,config, + LDAP_SCOPE_BASE,"(objectclass=*)", + load_config_dse,NULL, NULL); + + 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_log_err(SLAPI_LOG_ERR, "init_dse_file", - "Could not load config file [%s]\n", - DSE_FILENAME ); + slapi_log_err(SLAPI_LOG_ERR, "init_dse_file", + "Could not load config file [%s]\n", + DSE_FILENAME ); } slapi_pblock_destroy(pb); } diff --git a/ldap/servers/slapd/filter.c b/ldap/servers/slapd/filter.c index 58e55b7..949e409 100644 --- a/ldap/servers/slapd/filter.c +++ b/ldap/servers/slapd/filter.c @@ -774,11 +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 = 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); + 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/main.c b/ldap/servers/slapd/main.c index 08156fb..2d8c9f8 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -2134,95 +2134,95 @@ slapd_exemode_db2ldif(int argc, char** argv) int return_value= 0; struct slapdplugin *plugin; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); - char *my_ldiffile; - char **instp; + char *my_ldiffile; + char **instp; /* this should be the first time this are called! if the init order * is ever changed, these lines should be changed (or erased)! */ mapping_tree_init(); - /* - * if instance is given, just pass it to the backend. - * otherwise, we use included/excluded suffix list to specify a backend. - */ + /* + * if instance is given, just pass it to the backend. + * otherwise, we use included/excluded suffix list to specify a backend. + */ if (NULL == cmd_line_instance_names) { - char **instances, **ip; - int counter; + char **instances, **ip; + int counter; - if (lookup_instance_name_by_suffixes(db2ldif_include, db2ldif_exclude, - &instances) < 0) { - slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", - "Backend instances name [-n ] or " - "included suffix [-s ] need to be specified.\n"); - return 1; - } + if (lookup_instance_name_by_suffixes(db2ldif_include, db2ldif_exclude, + &instances) < 0) { + slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", + "Backend instances name [-n ] or " + "included suffix [-s ] need to be specified.\n"); + return 1; + } - if (instances) { - for (ip = instances, counter = 0; ip && *ip; ip++, counter++) - ; + if (instances) { + for (ip = instances, counter = 0; ip && *ip; ip++, counter++) + ; - if (counter == 0) { - slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", - "There is no backend instance to export from.\n"); - return 1; - } else { - slapi_log_err(SLAPI_LOG_INFO, "slapd_exemode_db2ldif", "db2ldif - Backend Instance(s): \n"); - for (ip = instances, counter = 0; ip && *ip; ip++, counter++) { - slapi_log_err(SLAPI_LOG_INFO, "slapd_exemode_db2ldif", "db2ldif - %s\n", *ip); - } - cmd_line_instance_names = instances; - } - } else { - slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", - "There is no backend instances to export from.\n"); - return 1; - } + if (counter == 0) { + slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", + "There is no backend instance to export from.\n"); + return 1; + } else { + slapi_log_err(SLAPI_LOG_INFO, "slapd_exemode_db2ldif", "db2ldif - Backend Instance(s): \n"); + for (ip = instances, counter = 0; ip && *ip; ip++, counter++) { + slapi_log_err(SLAPI_LOG_INFO, "slapd_exemode_db2ldif", "db2ldif - %s\n", *ip); + } + cmd_line_instance_names = instances; + } + } else { + slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", + "There is no backend instances to export from.\n"); + return 1; + } } - /* [622984] db2lidf -r changes database file ownership - * should call setuid before "db2ldif_dump_replica" */ - main_setuid(slapdFrontendConfig->localuser); - for (instp = cmd_line_instance_names; instp && *instp; instp++) { - int release_me = 0; + /* [622984] db2lidf -r changes database file ownership + * should call setuid before "db2ldif_dump_replica" */ + main_setuid(slapdFrontendConfig->localuser); + for (instp = cmd_line_instance_names; instp && *instp; instp++) { + int release_me = 0; - plugin = lookup_plugin_by_instance_name(*instp); - if (plugin == NULL) { - slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", - "Could not find backend '%s'.\n", *instp); - return 1; - } - - if (plugin->plg_db2ldif == NULL) { - slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", - "No db2ldif function defined for backend %s - cannot export\n", *instp); - return 1; - } + plugin = lookup_plugin_by_instance_name(*instp); + if (plugin == NULL) { + slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", + "Could not find backend '%s'.\n", *instp); + return 1; + } + + if (plugin->plg_db2ldif == NULL) { + slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", + "No db2ldif function defined for backend %s - cannot export\n", *instp); + return 1; + } - /* Make sure we aren't going to run slapd in - * a mode that is going to conflict with other - * slapd processes that are currently running - */ - if ( add_new_slapd_process(slapd_exemode, db2ldif_dump_replica, - skip_db_protect_check) == -1 ) { - slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", - "Shutting down due to possible conflicts " - "with other slapd processes\n"); - return 1; - } - - if (! (SLAPI_PLUGIN_IS_V2(plugin))) { - slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", - "%s is too old to do exports.\n", plugin->plg_name); - return 1; - } - - if (!is_quiet) { - slapd_ldap_debug |= LDAP_DEBUG_BACKLDBM; - } - if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) { - g_set_detached(1); - } + /* Make sure we aren't going to run slapd in + * a mode that is going to conflict with other + * slapd processes that are currently running + */ + if ( add_new_slapd_process(slapd_exemode, db2ldif_dump_replica, + skip_db_protect_check) == -1 ) { + slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", + "Shutting down due to possible conflicts " + "with other slapd processes\n"); + return 1; + } + + if (! (SLAPI_PLUGIN_IS_V2(plugin))) { + slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2ldif", + "%s is too old to do exports.\n", plugin->plg_name); + return 1; + } + + if (!is_quiet) { + slapd_ldap_debug |= LDAP_DEBUG_BACKLDBM; + } + if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) { + g_set_detached(1); + } Slapi_PBlock *pb = slapi_pblock_new(); slapi_pblock_set(pb, SLAPI_BACKEND, NULL); slapi_pblock_set(pb, SLAPI_PLUGIN, plugin); @@ -2235,80 +2235,80 @@ slapd_exemode_db2ldif(int argc, char** argv) 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()) { + 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; - char *repl_plg_name = "Multimaster Replication Plugin"; - - /* - * Only start the necessary plugins for "db2ldif -r" - * - * We need replication, but replication has its own - * dependencies - */ - plugin_get_plugin_dependencies(repl_plg_name, &plugin_list); - - eq_init(); /* must be done before plugins started */ - ps_init_psearch_system(); /* must come before plugin_startall() */ - plugin_startall(argc, argv, plugin_list); - eq_start(); /* must be done after plugins started */ - charray_free(plugin_list); - } - - if ( archive_name ) { /* redirect stdout to this file: */ + + if (db2ldif_dump_replica) { + char **plugin_list = NULL; + char *repl_plg_name = "Multimaster Replication Plugin"; + + /* + * Only start the necessary plugins for "db2ldif -r" + * + * We need replication, but replication has its own + * dependencies + */ + plugin_get_plugin_dependencies(repl_plg_name, &plugin_list); + + eq_init(); /* must be done before plugins started */ + ps_init_psearch_system(); /* must come before plugin_startall() */ + plugin_startall(argc, argv, plugin_list); + eq_start(); /* must be done after plugins started */ + charray_free(plugin_list); + } + + if ( archive_name ) { /* redirect stdout to this file: */ char *p, *q; - char sep = '/'; - - my_ldiffile = archive_name; - if (ldif_printkey & EXPORT_APPENDMODE) { - if (instp == cmd_line_instance_names) { /* first export */ - ldif_printkey |= EXPORT_APPENDMODE_1; - } else { - ldif_printkey &= ~EXPORT_APPENDMODE_1; - } - } else { /* not APPENDMODE */ - if (strcmp(archive_name, "-")) { /* not '-' */ - my_ldiffile = - (char *)slapi_ch_malloc((unsigned long)(strlen(archive_name) - + strlen(*instp) + 2)); - p = strrchr(archive_name, sep); - if (NULL == p) { - sprintf(my_ldiffile, "%s_%s", *instp, archive_name); - } else { - q = p + 1; - *p = '\0'; - sprintf(my_ldiffile, "%s%c%s_%s", - archive_name, sep, *instp, q); - *p = sep; - } - release_me = 1; - } - } + char sep = '/'; + + my_ldiffile = archive_name; + if (ldif_printkey & EXPORT_APPENDMODE) { + if (instp == cmd_line_instance_names) { /* first export */ + ldif_printkey |= EXPORT_APPENDMODE_1; + } else { + ldif_printkey &= ~EXPORT_APPENDMODE_1; + } + } else { /* not APPENDMODE */ + if (strcmp(archive_name, "-")) { /* not '-' */ + my_ldiffile = + (char *)slapi_ch_malloc((unsigned long)(strlen(archive_name) + + strlen(*instp) + 2)); + p = strrchr(archive_name, sep); + if (NULL == p) { + sprintf(my_ldiffile, "%s_%s", *instp, archive_name); + } else { + q = p + 1; + *p = '\0'; + sprintf(my_ldiffile, "%s%c%s_%s", + archive_name, sep, *instp, q); + *p = sep; + } + release_me = 1; + } + } - if (!is_quiet) { - fprintf(stderr, "ldiffile: %s\n", my_ldiffile); - } - /* just send the filename to the backend and let - * the backend open it (so they can do special - * stuff for 64-bit fs) - */ + if (!is_quiet) { + fprintf(stderr, "ldiffile: %s\n", my_ldiffile); + } + /* just send the filename to the backend and let + * the backend open it (so they can do special + * stuff for 64-bit fs) + */ 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); - } - } - slapi_ch_free( (void**)&myname ); + if (release_me) { + slapi_ch_free((void **)&my_ldiffile); + } + } + slapi_ch_free( (void**)&myname ); if (db2ldif_dump_replica) { eq_stop(); /* event queue should be shutdown before closing all plugins (especailly, replication plugin) */ @@ -2440,7 +2440,7 @@ static int slapd_exemode_db2index(void) static int slapd_exemode_db2archive(void) { - int return_value= 0; + int return_value= 0; struct slapdplugin *backend_plugin; slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig(); @@ -2460,10 +2460,10 @@ slapd_exemode_db2archive(void) * slapd processes that are currently running */ if ( add_new_slapd_process(slapd_exemode, db2ldif_dump_replica, - skip_db_protect_check) == -1 ) { + skip_db_protect_check) == -1 ) { slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2archive", - "Shutting down due to possible conflicts with other slapd processes\n"); - return 1; + "Shutting down due to possible conflicts with other slapd processes\n"); + return 1; } if (compute_init()) { slapi_log_err(SLAPI_LOG_ERR, "slapd_exemode_db2archive", @@ -2478,14 +2478,14 @@ slapd_exemode_db2archive(void) } 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, 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 ); - slapi_pblock_destroy(pb); + slapi_pblock_destroy(pb); return return_value; } diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c index 0991e83..447c9e3 100644 --- a/ldap/servers/slapd/modify.c +++ b/ldap/servers/slapd/modify.c @@ -98,7 +98,7 @@ void do_modify( Slapi_PBlock *pb ) { Slapi_Operation *operation = NULL; - Connection *pb_conn = NULL; + Connection *pb_conn = NULL; Slapi_Mods smods; BerElement *ber; ber_tag_t tag; @@ -120,7 +120,7 @@ do_modify( Slapi_PBlock *pb ) slapi_pblock_get( pb, SLAPI_OPERATION, &operation); ber = operation->o_ber; - slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); + slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); /* count the modify request */ slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsModifyEntryOps); @@ -631,7 +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; + Connection *pb_conn; char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE]; int err; LDAPMod *lc_mod = NULL; @@ -649,7 +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); + slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); if (sdn) { passin_sdn = 1; diff --git a/ldap/servers/slapd/modrdn.c b/ldap/servers/slapd/modrdn.c index 1b6ae8c..bd893ee 100644 --- a/ldap/servers/slapd/modrdn.c +++ b/ldap/servers/slapd/modrdn.c @@ -401,7 +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; + Connection *pb_conn; slapi_pblock_get(pb, SLAPI_ORIGINAL_TARGET, &dn); slapi_pblock_get(pb, SLAPI_MODRDN_NEWRDN, &newrdn); @@ -411,7 +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); + slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); /* * If ownership has not been passed to this function, we replace the diff --git a/ldap/servers/slapd/passwd_extop.c b/ldap/servers/slapd/passwd_extop.c index de1c8c2..58ee58c 100644 --- a/ldap/servers/slapd/passwd_extop.c +++ b/ldap/servers/slapd/passwd_extop.c @@ -132,7 +132,7 @@ passwd_apply_mods(Slapi_PBlock *pb_orig, const Slapi_DN *sdn, Slapi_Mods *mods, slapi_add_controls(&req_controls_copy, req_controls, 1); } - Slapi_PBlock *pb = slapi_pblock_new(); + 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 */ @@ -145,16 +145,16 @@ 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. */ - Connection *pb_conn = NULL; - slapi_pblock_get(pb_orig, SLAPI_CONNECTION, &pb_conn); - slapi_pblock_set(pb, SLAPI_CONNECTION, 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); /* We now clean up the connection that we copied into the * new pblock. We want to leave it untouched. */ - slapi_pblock_set(pb, SLAPI_CONNECTION, NULL); - + slapi_pblock_set(pb, SLAPI_CONNECTION, NULL); + slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &ret); /* Retrieve and duplicate the response controls since they will be @@ -170,12 +170,12 @@ passwd_apply_mods(Slapi_PBlock *pb_orig, const Slapi_DN *sdn, Slapi_Mods *mods, ret, slapi_sdn_get_dn(sdn)); } - slapi_pblock_destroy(pb); - } + slapi_pblock_destroy(pb); + } - slapi_log_err(SLAPI_LOG_TRACE, "passwd_apply_mods", "<= %d\n", ret); + slapi_log_err(SLAPI_LOG_TRACE, "passwd_apply_mods", "<= %d\n", ret); - return ret; + return ret; } @@ -772,8 +772,8 @@ parse_req_done: * this here since the normal modify code doesn't perform this check for * internal operations. */ - Connection *pb_conn; - slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); + 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/plugin.c b/ldap/servers/slapd/plugin.c index 63ac056..77043ff 100644 --- a/ldap/servers/slapd/plugin.c +++ b/ldap/servers/slapd/plugin.c @@ -1569,7 +1569,7 @@ plugin_dependency_startall(int argc, char** argv, char *errmsg __attribute__((un } } - pb = slapi_pblock_new(); + pb = slapi_pblock_new(); slapi_pblock_set( pb, SLAPI_ARGC, &argc); slapi_pblock_set( pb, SLAPI_ARGV, &argv); @@ -1821,10 +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. */ - /* This is freed in free_plugin_dep_config */ - /* + /* This is freed in free_plugin_dep_config */ + /* slapi_pblock_destroy(config[plugin_index].pb); - */ + */ /* Add this plugin to the shutdown list */ @@ -3082,7 +3082,7 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group, PR_snprintf(attrname, sizeof(attrname), "%s%d", ATTR_PLUGIN_ARG, ++ii); } while (skipped < MAXSKIPPED); - pb = slapi_pblock_new(); + pb = slapi_pblock_new(); slapi_pblock_set(pb, SLAPI_PLUGIN, plugin); slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, (void *)SLAPI_PLUGIN_CURRENT_VERSION); @@ -3726,16 +3726,16 @@ static PRBool plugin_invoke_plugin_pb (struct slapdplugin *plugin, int operation, Slapi_PBlock *pb) { Slapi_DN *target_spec; - Operation *pb_op = NULL; + Operation *pb_op = NULL; PRBool rc; PR_ASSERT (plugin); PR_ASSERT (pb); /* we always allow initialization and cleanup operations */ - if (operation == SLAPI_PLUGIN_START_FN || + if (operation == SLAPI_PLUGIN_START_FN || operation == SLAPI_PLUGIN_POSTSTART_FN || - operation == SLAPI_PLUGIN_CLOSE_FN || + operation == SLAPI_PLUGIN_CLOSE_FN || operation == SLAPI_PLUGIN_CLEANUP_FN || operation == SLAPI_PLUGIN_BE_PRE_CLOSE_FN || operation == SLAPI_PLUGIN_BE_POST_OPEN_FN || @@ -3743,9 +3743,9 @@ plugin_invoke_plugin_pb (struct slapdplugin *plugin, int operation, Slapi_PBlock operation == SLAPI_PLUGIN_BE_POST_BACKUP_FN) return PR_TRUE; - slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); + slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); + - PR_ASSERT (pb_op); target_spec = operation_get_target_spec (pb_op); @@ -3774,8 +3774,8 @@ plugin_invoke_plugin_sdn (struct slapdplugin *plugin, int operation __attribute_ return PR_FALSE; } - Operation *pb_op; - slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); + Operation *pb_op; + slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); /* get configuration from the group plugin if necessary */ config = plugin_get_config (plugin); @@ -3788,7 +3788,7 @@ plugin_invoke_plugin_sdn (struct slapdplugin *plugin, int operation __attribute_ slapi_pblock_get (pb, SLAPI_IS_REPLICATED_OPERATION, &repl_op); if (repl_op) { return PR_FALSE; - } + } } if (pb_op) @@ -4484,11 +4484,11 @@ slapi_get_plugin_default_config(char *type, Slapi_ValueSet **valueset) /* retrieve attribute values from the entry */ Slapi_Attr *attr = NULL; rc = slapi_entry_attr_find(*entries, type, &attr); - if (0 == rc) { /* type value exists */ - rc = slapi_attr_get_valueset(attr, valueset); - } else { - rc = LDAP_NO_SUCH_ATTRIBUTE; - } + if (0 == rc) { /* type value exists */ + rc = slapi_attr_get_valueset(attr, valueset); + } else { + rc = LDAP_NO_SUCH_ATTRIBUTE; + } } slapi_free_search_results_internal(pb); slapi_pblock_destroy(pb); diff --git a/ldap/servers/slapd/plugin_internal_op.c b/ldap/servers/slapd/plugin_internal_op.c index c401918..0d18b5d 100644 --- a/ldap/servers/slapd/plugin_internal_op.c +++ b/ldap/servers/slapd/plugin_internal_op.c @@ -201,23 +201,22 @@ slapi_seq_callback( const char *ibase, plugin_search_entry_callback srch_callback, plugin_referral_entry_callback ref_callback) { - int r; + int r; - if (ibase == NULL) - { - slapi_log_err(SLAPI_LOG_ERR, "slapi_seq_callback", - "NULL parameter\n"); - return -1; - } + if (ibase == NULL) { + slapi_log_err(SLAPI_LOG_ERR, "slapi_seq_callback", + "NULL parameter\n"); + return -1; + } 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); + 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); slapi_pblock_destroy(pb); - return r; + return r; } @@ -444,11 +443,11 @@ slapi_search_internal_callback(const char *ibase, Slapi_PBlock *pb = slapi_pblock_new(); int rc = 0; - 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, - srch_callback, ref_callback); + 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, + srch_callback, ref_callback); slapi_pblock_destroy(pb); return (rc); } @@ -461,19 +460,16 @@ slapi_search_internal(const char *base, char **attrs, int attrsonly) { - - Slapi_PBlock *pb; + Slapi_PBlock *pb; /* initialize pb */ pb = slapi_pblock_new(); - if (pb) - { - slapi_search_internal_set_pb (pb, base, scope, filter, attrs, attrsonly, controls, - NULL, plugin_get_default_component_id(), 0); - - search_internal_pb (pb); - } - + if (pb) + { + slapi_search_internal_set_pb (pb, base, scope, filter, attrs, attrsonly, controls, + NULL, plugin_get_default_component_id(), 0); + search_internal_pb (pb); + } return pb; } diff --git a/ldap/servers/slapd/plugin_syntax.c b/ldap/servers/slapd/plugin_syntax.c index f0d1167..b89e85c 100644 --- a/ldap/servers/slapd/plugin_syntax.c +++ b/ldap/servers/slapd/plugin_syntax.c @@ -190,7 +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); + slapi_pblock_destroy(pipb); return( rc ); } @@ -263,9 +263,9 @@ plugin_call_syntax_filter_sub_sv( 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); + /* 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 ); } @@ -798,7 +798,7 @@ slapi_attr_assertion2keys_ava_sv( if ( a2k_fn != NULL ) { rc = (*a2k_fn)( pipb, val, ivals, ftype ); } - slapi_pblock_destroy(pipb); + slapi_pblock_destroy(pipb); done: slapi_log_err(SLAPI_LOG_FILTER, "slapi_attr_assertion2keys_ava_sv", "=> %d\n", rc); @@ -866,7 +866,7 @@ slapi_call_syntax_assertion2keys_sub_sv( final, ivals ); } - slapi_pblock_destroy(pipb); + slapi_pblock_destroy(pipb); slapi_log_err(SLAPI_LOG_FILTER, "slapi_call_syntax_assertion2keys_sub_sv", "<= %d\n", rc); diff --git a/ldap/servers/slapd/psearch.c b/ldap/servers/slapd/psearch.c index 9b9393d..7398fd8 100644 --- a/ldap/servers/slapd/psearch.c +++ b/ldap/servers/slapd/psearch.c @@ -256,17 +256,17 @@ static void ps_send_results( void *arg ) { PSearch *ps = (PSearch *)arg; - PSEQNode *peq, *peqnext; - struct slapi_filter *filter = 0; - char *base = NULL; - Slapi_DN *sdn = NULL; - char *fstr = NULL; - char **pbattrs = NULL; - int conn_acq_flag = 0; - Slapi_Connection *conn = NULL; + PSEQNode *peq, *peqnext; + struct slapi_filter *filter = 0; + char *base = NULL; + Slapi_DN *sdn = NULL; + char *fstr = NULL; + 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); @@ -278,87 +278,87 @@ ps_send_results( void *arg ) 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", - pb_conn->c_connid, pb_op->o_opid); - } + 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", + 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 ( 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", - pb_conn->c_connid, pb_op->o_opid); - break; - } - if ( NULL == ps->ps_eq_head ) { - /* Nothing to do */ - PR_WaitCondVar( psearch_list->pl_cvar, PR_INTERVAL_NO_TIMEOUT ); - } else { - /* dequeue the item */ - int attrsonly; - char **attrs; - LDAPControl **ectrls; - Slapi_Entry *ec; - Slapi_Filter *f = NULL; - - PR_Lock( ps->ps_lock ); - - peq = ps->ps_eq_head; - ps->ps_eq_head = peq->pe_next; - if ( NULL == ps->ps_eq_head ) { - ps->ps_eq_tail = NULL; - } - - PR_Unlock( ps->ps_lock ); - - /* Get all the information we need to send the result */ - ec = peq->pe_entry; - slapi_pblock_get( ps->ps_pblock, SLAPI_SEARCH_ATTRS, &attrs ); - slapi_pblock_get( ps->ps_pblock, SLAPI_SEARCH_ATTRSONLY, &attrsonly ); - if ( !ps->ps_send_entchg_controls || peq->pe_ctrls[0] == NULL ) { - ectrls = NULL; - } else { - ectrls = peq->pe_ctrls; - } - - /* - * Send the result. Since send_ldap_search_entry can block for - * up to 30 minutes, we relinquish all locks before calling it. - */ - PR_Unlock(psearch_list->pl_cvarlock); + /* Check for an abandoned operation */ + 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", + pb_conn->c_connid, pb_op->o_opid); + break; + } + if ( NULL == ps->ps_eq_head ) { + /* Nothing to do */ + PR_WaitCondVar( psearch_list->pl_cvar, PR_INTERVAL_NO_TIMEOUT ); + } else { + /* dequeue the item */ + int attrsonly; + char **attrs; + LDAPControl **ectrls; + Slapi_Entry *ec; + Slapi_Filter *f = NULL; + + PR_Lock( ps->ps_lock ); + + peq = ps->ps_eq_head; + ps->ps_eq_head = peq->pe_next; + if ( NULL == ps->ps_eq_head ) { + ps->ps_eq_tail = NULL; + } - /* - * The entry is in the right scope and matches the filter - * but we need to redo the filter test here to check access - * controls. See the comments at the slapi_filter_test() - * call in ps_service_persistent_searches(). - */ - slapi_pblock_get( ps->ps_pblock, SLAPI_SEARCH_FILTER, &f ); - - /* See if the entry meets the filter and ACL criteria */ - if ( slapi_vattr_filter_test( ps->ps_pblock, ec, f, - 1 /* verify_access */ ) == 0 ) { - int rc = 0; - slapi_pblock_set( ps->ps_pblock, SLAPI_SEARCH_RESULT_ENTRY, ec ); - rc = send_ldap_search_entry( ps->ps_pblock, ec, - ectrls, attrs, attrsonly ); - 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", - pb_conn->c_connid, pb_op->o_opid, - rc, slapi_entry_get_dn_const(ec), pb_op->o_status); - } - } - - PR_Lock(psearch_list->pl_cvarlock); + PR_Unlock( ps->ps_lock ); - /* Deallocate our wrapper for this entry */ - pe_ch_free( &peq ); - } + /* Get all the information we need to send the result */ + ec = peq->pe_entry; + slapi_pblock_get( ps->ps_pblock, SLAPI_SEARCH_ATTRS, &attrs ); + slapi_pblock_get( ps->ps_pblock, SLAPI_SEARCH_ATTRSONLY, &attrsonly ); + if ( !ps->ps_send_entchg_controls || peq->pe_ctrls[0] == NULL ) { + ectrls = NULL; + } else { + ectrls = peq->pe_ctrls; + } + + /* + * Send the result. Since send_ldap_search_entry can block for + * up to 30 minutes, we relinquish all locks before calling it. + */ + PR_Unlock(psearch_list->pl_cvarlock); + + /* + * The entry is in the right scope and matches the filter + * but we need to redo the filter test here to check access + * controls. See the comments at the slapi_filter_test() + * call in ps_service_persistent_searches(). + */ + slapi_pblock_get( ps->ps_pblock, SLAPI_SEARCH_FILTER, &f ); + + /* See if the entry meets the filter and ACL criteria */ + if ( slapi_vattr_filter_test( ps->ps_pblock, ec, f, + 1 /* verify_access */ ) == 0 ) { + int rc = 0; + slapi_pblock_set( ps->ps_pblock, SLAPI_SEARCH_RESULT_ENTRY, ec ); + rc = send_ldap_search_entry( ps->ps_pblock, ec, + ectrls, attrs, attrsonly ); + 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", + pb_conn->c_connid, pb_op->o_opid, + rc, slapi_entry_get_dn_const(ec), pb_op->o_status); + } + } + + PR_Lock(psearch_list->pl_cvarlock); + + /* Deallocate our wrapper for this entry */ + pe_ch_free( &peq ); + } } PR_Unlock( psearch_list->pl_cvarlock ); ps_remove( ps ); @@ -366,39 +366,39 @@ ps_send_results( void *arg ) /* indicate the end of search */ plugin_call_plugins( ps->ps_pblock , SLAPI_PLUGIN_POST_SEARCH_FN ); - /* free things from the pblock that were not free'd in do_search() */ - /* we strdup'd this in search.c - need to free */ - slapi_pblock_get( ps->ps_pblock, SLAPI_ORIGINAL_TARGET_DN, &base ); - slapi_pblock_set( ps->ps_pblock, SLAPI_ORIGINAL_TARGET_DN, NULL ); - slapi_ch_free_string(&base); + /* free things from the pblock that were not free'd in do_search() */ + /* we strdup'd this in search.c - need to free */ + slapi_pblock_get( ps->ps_pblock, SLAPI_ORIGINAL_TARGET_DN, &base ); + slapi_pblock_set( ps->ps_pblock, SLAPI_ORIGINAL_TARGET_DN, NULL ); + slapi_ch_free_string(&base); - /* Free SLAPI_SEARCH_* before deleting op since those are held by op */ - slapi_pblock_get( ps->ps_pblock, SLAPI_SEARCH_TARGET_SDN, &sdn ); - slapi_pblock_set( ps->ps_pblock, SLAPI_SEARCH_TARGET_SDN, NULL ); - slapi_sdn_free(&sdn); + /* Free SLAPI_SEARCH_* before deleting op since those are held by op */ + slapi_pblock_get( ps->ps_pblock, SLAPI_SEARCH_TARGET_SDN, &sdn ); + slapi_pblock_set( ps->ps_pblock, SLAPI_SEARCH_TARGET_SDN, NULL ); + slapi_sdn_free(&sdn); slapi_pblock_get( ps->ps_pblock, SLAPI_SEARCH_STRFILTER, &fstr ); slapi_pblock_set( ps->ps_pblock, SLAPI_SEARCH_STRFILTER, NULL ); - slapi_ch_free_string(&fstr); + slapi_ch_free_string(&fstr); slapi_pblock_get( ps->ps_pblock, SLAPI_SEARCH_ATTRS, &pbattrs ); slapi_pblock_set( ps->ps_pblock, SLAPI_SEARCH_ATTRS, NULL ); - if ( pbattrs != NULL ) - { - charray_free( pbattrs ); - } - - slapi_pblock_get(ps->ps_pblock, SLAPI_SEARCH_FILTER, &filter ); - slapi_pblock_set(ps->ps_pblock, SLAPI_SEARCH_FILTER, NULL ); - slapi_filter_free(filter, 1); + if ( pbattrs != NULL ) + { + charray_free( pbattrs ); + } + + slapi_pblock_get(ps->ps_pblock, SLAPI_SEARCH_FILTER, &filter ); + slapi_pblock_set(ps->ps_pblock, SLAPI_SEARCH_FILTER, NULL ); + slapi_filter_free(filter, 1); 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, pb_op->o_opid); + slapi_log_err(SLAPI_LOG_CONNS, "ps_send_results", + "conn=%" PRIu64 " op=%d Releasing the connection and operation\n", + conn->c_connid, pb_op->o_opid); /* Delete this op from the connection's list */ connection_remove_operation_ext( ps->ps_pblock, conn, pb_op ); @@ -413,10 +413,10 @@ ps_send_results( void *arg ) ps->ps_lock = NULL; slapi_ch_free((void **) &ps->ps_pblock ); - for ( peq = ps->ps_eq_head; peq; peq = peqnext) { - peqnext = peq->pe_next; - pe_ch_free( &peq ); - } + for ( peq = ps->ps_eq_head; peq; peq = peqnext) { + peqnext = peq->pe_next; + pe_ch_free( &peq ); + } slapi_ch_free((void **) &ps ); g_decr_active_threadcnt(); } @@ -521,11 +521,11 @@ 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; + 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); + 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() diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c index e6a1484..0ebc448 100644 --- a/ldap/servers/slapd/pw.c +++ b/ldap/servers/slapd/pw.c @@ -594,7 +594,7 @@ int update_pw_info ( Slapi_PBlock *pb , char *old_pw) { Slapi_Operation *operation = NULL; - Connection *pb_conn; + Connection *pb_conn; Slapi_Entry *e = NULL; Slapi_DN *sdn = NULL; Slapi_Mods smods; @@ -606,7 +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_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); @@ -734,11 +734,11 @@ 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; + Operation *pb_op; pwpolicy = new_passwdPolicy(pb, dn); slapi_pblock_get ( pb, SLAPI_PWPOLICY, &pwresponse_req ); - slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); + slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); if (!pb_op->o_isroot && pwpolicy->pw_minage) { @@ -759,7 +759,7 @@ check_pw_minage ( Slapi_PBlock *pb, const Slapi_DN *sdn, struct berval **vals __ char *cur_time_str = NULL; pw_allowchange_date = parse_genTime(passwordAllowChangeTime); - slapi_ch_free((void **) &passwordAllowChangeTime ); + slapi_ch_free((void **) &passwordAllowChangeTime ); /* check if allow to change the password */ cur_time_str = format_genTime ( current_time() ); @@ -777,7 +777,7 @@ check_pw_minage ( Slapi_PBlock *pb, const Slapi_DN *sdn, struct berval **vals __ } slapi_ch_free((void **) &cur_time_str ); } - slapi_entry_free( e ); + slapi_entry_free( e ); } return ( 0 ); } @@ -1237,7 +1237,7 @@ update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char *old_pw ) list_of_mods[0] = &attribute; list_of_mods[1] = NULL; - mod_pb = slapi_pblock_new(); + 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); @@ -1245,7 +1245,7 @@ update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char *old_pw ) slapi_log_err(SLAPI_LOG_ERR, "update_pw_history", "Modify error %d on entry '%s'\n", res, dn); } - slapi_pblock_destroy(mod_pb); + slapi_pblock_destroy(mod_pb); slapi_ch_free_string(&str); bail: slapi_ch_array_free(values_replace); @@ -1678,12 +1678,12 @@ new_passwdPolicy(Slapi_PBlock *pb, const char *dn) int optype = -1; /* If we already allocated a pw policy, return it */ - if (pb != NULL) { - passwdPolicy *pwdpolicy = slapi_pblock_get_pwdpolicy(pb); - if (pwdpolicy != NULL) { - return pwdpolicy; - } - } + if (pb != NULL) { + passwdPolicy *pwdpolicy = slapi_pblock_get_pwdpolicy(pb); + if (pwdpolicy != NULL) { + return pwdpolicy; + } + } if (g_get_active_threadcnt() == 0){ /* @@ -2038,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) { - slapi_pblock_set_pwdpolicy(pb, pwdpolicy); - } + if (pb) { + slapi_pblock_set_pwdpolicy(pb, pwdpolicy); + } return pwdpolicy; diff --git a/ldap/servers/slapd/pw_mgmt.c b/ldap/servers/slapd/pw_mgmt.c index 8707392..a01afc5 100644 --- a/ldap/servers/slapd/pw_mgmt.c +++ b/ldap/servers/slapd/pw_mgmt.c @@ -37,7 +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; + Connection *pb_conn = NULL; if (NULL == e) { return (-1); @@ -87,7 +87,7 @@ 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); + slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); /* Check if password has been reset */ if ( pw_exp_date == NO_TIME ) { @@ -180,8 +180,8 @@ skip: create a pb for unbind operation. Also do_unbind calls pre and post ops. Maybe we don't want to call them */ if (pb_conn && (LDAP_VERSION2 == pb_conn->c_ldapversion)) { - Operation *pb_op = NULL; - slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); + Operation *pb_op = NULL; + slapi_pblock_get(pb, SLAPI_OPERATION, &pb_op); /* We close the connection only with LDAPv2 connections */ disconnect_server( pb_conn, pb_op->o_connid, pb_op->o_opid, SLAPD_DISCONNECT_UNBIND, 0); @@ -228,12 +228,10 @@ skip: if (pwresponse_req) { /* check for "changeafterreset" condition */ if (pb_conn->c_needpw == 1) { - slapi_pwpolicy_make_response_control( pb, *t, -1, - LDAP_PWPOLICY_CHGAFTERRESET); - } else { - slapi_pwpolicy_make_response_control( pb, *t, -1, - -1); - } + slapi_pwpolicy_make_response_control( pb, *t, -1, LDAP_PWPOLICY_CHGAFTERRESET); + } else { + slapi_pwpolicy_make_response_control( pb, *t, -1, -1); + } } if (pb_conn->c_needpw == 1) { diff --git a/ldap/servers/slapd/pw_retry.c b/ldap/servers/slapd/pw_retry.c index a54c784..cb283ba 100644 --- a/ldap/servers/slapd/pw_retry.c +++ b/ldap/servers/slapd/pw_retry.c @@ -230,7 +230,7 @@ pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods) if (mods && (slapi_mods_get_num_mods(mods) > 0)) { - Slapi_PBlock *pb = slapi_pblock_new(); + 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, @@ -248,7 +248,7 @@ pw_apply_mods(const Slapi_DN *sdn, Slapi_Mods *mods) res, slapi_sdn_get_dn(sdn)); } - slapi_pblock_destroy(pb); + slapi_pblock_destroy(pb); } return; diff --git a/ldap/servers/slapd/referral.c b/ldap/servers/slapd/referral.c index 2e0aea0..632dd19 100644 --- a/ldap/servers/slapd/referral.c +++ b/ldap/servers/slapd/referral.c @@ -408,117 +408,114 @@ dn_is_below( const char *dn_norm, const char *ancestor_norm ) struct berval ** get_data_source(Slapi_PBlock *pb, const Slapi_DN *sdn, int orc, void *cfrp) { - int walker; - struct berval **bvp; - struct berval *bv; - int found_it; - Ref_Array *grefs = NULL; - Ref_Array *the_refs = NULL; - Ref_Array *cf_refs = (Ref_Array *)cfrp; - - /* If no Ref_Array is given, use global_referrals */ - if (cf_refs == NULL) { - grefs = g_get_global_referrals(); - the_refs = grefs; - GR_LOCK_READ(); - } else { - the_refs = cf_refs; - } - - /* optimization: if orc is 1 (a read), then check the readcount*/ - if (orc && the_refs->ra_readcount == 0) { + int walker; + struct berval **bvp; + struct berval *bv; + int found_it; + Ref_Array *grefs = NULL; + Ref_Array *the_refs = NULL; + Ref_Array *cf_refs = (Ref_Array *)cfrp; + + /* If no Ref_Array is given, use global_referrals */ if (cf_refs == NULL) { - GR_UNLOCK_READ(); + grefs = g_get_global_referrals(); + the_refs = grefs; + GR_LOCK_READ(); + } else { + the_refs = cf_refs; } - return (NULL); - } - - bvp = NULL; - bv = NULL; - found_it = 0; + /* optimization: if orc is 1 (a read), then check the readcount*/ + if (orc && the_refs->ra_readcount == 0) { + if (cf_refs == NULL) { + GR_UNLOCK_READ(); + } + return (NULL); + } - /* Walk down the array, testing each dn to make see if it's a parent of "dn" */ - for (walker = 0; walker < the_refs->ra_nextindex; walker++){ - if ( slapi_dn_issuffix(slapi_sdn_get_ndn(sdn), the_refs->ra_refs[walker]->ref_dn)) { - found_it = 1; - break; + bvp = NULL; + bv = NULL; + found_it = 0; + /* Walk down the array, testing each dn to make see if it's a parent of "dn" */ + for (walker = 0; walker < the_refs->ra_nextindex; walker++){ + if ( slapi_dn_issuffix(slapi_sdn_get_ndn(sdn), the_refs->ra_refs[walker]->ref_dn)) { + found_it = 1; + break; + } } - } - - /* no referral, so return NULL */ - if (!found_it) { - if (cf_refs == NULL) { - GR_UNLOCK_READ(); + /* no referral, so return NULL */ + if (!found_it) { + if (cf_refs == NULL) { + GR_UNLOCK_READ(); + } + return (NULL); } - return (NULL); - } - - /* - * Gotta make sure we're returning the right one. If orc is 1, then - * only return a read referral. if orc is 0, then only return a - * write referral. - */ - if (orc && the_refs->ra_refs[walker]->ref_reads != 1) { - if (cf_refs == NULL) { - GR_UNLOCK_READ(); + + /* + * Gotta make sure we're returning the right one. If orc is 1, then + * only return a read referral. if orc is 0, then only return a + * write referral. + */ + if (orc && the_refs->ra_refs[walker]->ref_reads != 1) { + if (cf_refs == NULL) { + GR_UNLOCK_READ(); + } + return (NULL); } - return (NULL); - } - if (!orc && the_refs->ra_refs[walker]->ref_writes != 1) { - if (cf_refs == NULL) { - GR_UNLOCK_READ(); + if (!orc && the_refs->ra_refs[walker]->ref_writes != 1) { + if (cf_refs == NULL) { + GR_UNLOCK_READ(); + } + return (NULL); } - 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_conn->c_flags & CONN_FLAG_SSL )) { - /* SSL connection */ - char * old_referral_string = NULL; - char * new_referral_string = NULL; - char *p = NULL; - /* Get the basic referral */ - bv = slapi_ch_bvdup(the_refs->ra_refs[walker]->ref_referral); - old_referral_string = bv->bv_val; - /* Re-write it to replace ldap with ldaps, and remove the port information */ - /* The original string will look like this: ldap://host:port */ - /* We need to make it look like this: ldaps://host */ - /* Potentially the ":port" part might be missing from the original */ - new_referral_string = slapi_ch_smprintf("%s%s" , LDAPS_URL_PREFIX, old_referral_string + strlen(LDAP_URL_PREFIX) ); - /* Go looking for the port */ - p = new_referral_string + (strlen(LDAPS_URL_PREFIX) + 1); - while (*p != '\0' && *p != ':') p++; - if (':' == *p) { - /* It had a port, zap it */ - *p = '\0'; - } - /* Fix the bv to point to this new string */ - bv->bv_val = new_referral_string; - /* Fix its length */ - bv->bv_len = strlen(bv->bv_val); - /* Free the copy we made of the original */ - slapi_ch_free((void**)&old_referral_string); - } else { - /* regular connection */ - bv = (struct berval *) slapi_ch_bvdup(the_refs->ra_refs[walker]->ref_referral); - } + if ( 0 != ( pb_conn->c_flags & CONN_FLAG_SSL )) { + /* SSL connection */ + char * old_referral_string = NULL; + char * new_referral_string = NULL; + char *p = NULL; + /* Get the basic referral */ + bv = slapi_ch_bvdup(the_refs->ra_refs[walker]->ref_referral); + old_referral_string = bv->bv_val; + /* Re-write it to replace ldap with ldaps, and remove the port information */ + /* The original string will look like this: ldap://host:port */ + /* We need to make it look like this: ldaps://host */ + /* Potentially the ":port" part might be missing from the original */ + new_referral_string = slapi_ch_smprintf("%s%s" , LDAPS_URL_PREFIX, old_referral_string + strlen(LDAP_URL_PREFIX) ); + /* Go looking for the port */ + p = new_referral_string + (strlen(LDAPS_URL_PREFIX) + 1); + while (*p != '\0' && *p != ':') p++; + if (':' == *p) { + /* It had a port, zap it */ + *p = '\0'; + } + /* Fix the bv to point to this new string */ + bv->bv_val = new_referral_string; + /* Fix its length */ + bv->bv_len = strlen(bv->bv_val); + /* Free the copy we made of the original */ + slapi_ch_free((void**)&old_referral_string); + } else { + /* regular connection */ + bv = (struct berval *) slapi_ch_bvdup(the_refs->ra_refs[walker]->ref_referral); + } - /* Package it up and send that puppy. */ - bvp = (struct berval **) slapi_ch_malloc( 2 * sizeof(struct berval *) ); - bvp[0] = bv; - bvp[1] = NULL; + /* Package it up and send that puppy. */ + bvp = (struct berval **) slapi_ch_malloc( 2 * sizeof(struct berval *) ); + bvp[0] = bv; + bvp[1] = NULL; - if (cf_refs == NULL) { - GR_UNLOCK_READ(); - } + if (cf_refs == NULL) { + GR_UNLOCK_READ(); + } - return(bvp); + return(bvp); } diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c index 9c802a9..90b8887 100644 --- a/ldap/servers/slapd/result.c +++ b/ldap/servers/slapd/result.c @@ -349,7 +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); + slapi_pblock_get(pb, SLAPI_CONNECTION, &conn); if (operation->o_status == SLAPI_OP_STATUS_RESULT_SENT) { return; /* result already sent */ @@ -817,11 +817,11 @@ send_ldapv3_referral( BerElement *ber; int i, rc, logit = 0; Slapi_Operation *operation; - Slapi_Backend *pb_backend; + 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_pblock_get(pb, SLAPI_CONNECTION, &conn); + slapi_pblock_get(pb, SLAPI_BACKEND, &pb_backend); slapi_log_err(SLAPI_LOG_TRACE, "send_ldapv3_referral", "=>\n"); @@ -909,7 +909,7 @@ send_ldap_referral ( char *refAttr = "ref"; char *attrs[2] = { NULL, NULL }; - Connection *pb_conn; + Connection *pb_conn; /* count the referral */ slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsReferrals); @@ -921,6 +921,8 @@ send_ldap_referral ( != LDAP_SUCCESS ) { return( 0 ); } + + slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); if ( pb_conn && pb_conn->c_ldapversion > LDAP_VERSION2 ) { /* * v3 connection - send the referral(s) in a @@ -1495,7 +1497,7 @@ send_ldap_search_entry_ext( LDAPControl **searchctrlp = NULL; - slapi_pblock_get(pb, SLAPI_CONNECTION, &conn); + 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", @@ -1522,8 +1524,8 @@ send_ldap_search_entry_ext( slapi_pblock_get(pb, SLAPI_SEARCH_CTRLS, &searchctrlp); if ( conn == NULL && e ) { - Slapi_Backend *pb_backend; - slapi_pblock_get(pb, SLAPI_BACKEND, &pb_backend); + 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)( @@ -1949,7 +1951,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; + uint32_t operation_notes; slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx); slapi_pblock_get(pb, SLAPI_PAGED_RESULTS_COOKIE, &pr_cookie); @@ -1964,7 +1966,7 @@ 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); } - slapi_pblock_get(pb, SLAPI_OPERATION_NOTES, &operation_notes); + slapi_pblock_get(pb, SLAPI_OPERATION_NOTES, &operation_notes); if ( 0 == operation_notes ) { notes_str = ""; diff --git a/ldap/servers/slapd/search.c b/ldap/servers/slapd/search.c index 72b4664..7b2b462 100644 --- a/ldap/servers/slapd/search.c +++ b/ldap/servers/slapd/search.c @@ -54,7 +54,7 @@ do_search( Slapi_PBlock *pb ) int strict = 0; int minssf_exclude_rootdse = 0; int filter_normalized = 0; - Connection *pb_conn = NULL; + Connection *pb_conn = NULL; slapi_log_err(SLAPI_LOG_TRACE, "do_search", "=>\n"); @@ -125,7 +125,7 @@ do_search( Slapi_PBlock *pb ) goto free_and_return; } - slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); + slapi_pblock_get(pb, SLAPI_CONNECTION, &pb_conn); /* * If nsslapd-minssf-exclude-rootdse is on, the minssf check has been