From 02870e815b4d4e5fe5274ddfbcb6ee30d0ec41da Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 22 Jul 2005 16:57:20 +0000 Subject: [PATCH] renamed slapi_int_init_connection => slapi_int_connection_init for consistency; blind fix to ITS#3879 --- servers/slapd/slapi/proto-slapi.h | 2 +- servers/slapd/slapi/slapi_ops.c | 45 ++++++++++++++----------------- servers/slapd/slapi/slapi_utils.c | 10 ++++--- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/servers/slapd/slapi/proto-slapi.h b/servers/slapd/slapi/proto-slapi.h index 180d353f22..ae4499f611 100644 --- a/servers/slapd/slapi/proto-slapi.h +++ b/servers/slapd/slapi/proto-slapi.h @@ -42,7 +42,7 @@ LDAP_SLAPI_F (int) slapi_int_access_allowed LDAP_P((Operation *op, LDAP_SLAPI_F (char **) slapi_get_supported_extended_ops LDAP_P((void)); /* slapi_ops.c */ -LDAP_SLAPI_F (int) slapi_int_init_connection LDAP_P((Slapi_PBlock *pb, SlapReply *rs, int OpType, Connection **pConn)); +LDAP_SLAPI_F (int) slapi_int_connection_init LDAP_P((Slapi_PBlock *pb, SlapReply *rs, int OpType, Connection **pConn)); LDAP_SLAPI_F (void) slapi_int_connection_destroy LDAP_P(( Connection **pConn )); /* slapi_pblock.c */ diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c index 734183d9da..4967159e3a 100644 --- a/servers/slapd/slapi/slapi_ops.c +++ b/servers/slapd/slapi/slapi_ops.c @@ -215,16 +215,16 @@ slapi_int_pblock_get_connection( Slapi_PBlock *pb, Operation *op ) slapi_pblock_get( pb, SLAPI_X_CONN_SSF, (void **)&conn->c_ssf ); slapi_pblock_get( pb, SLAPI_X_CONN_SASL_CONTEXT, (void **)&conn->c_sasl_authctx ); - if ( slapi_pblock_get( pb, SLAPI_CONN_DN, (void **)&connDn ) != 0 || - connDn == NULL ) { + if ( slapi_pblock_get( pb, SLAPI_CONN_DN, (void **)&connDn ) != 0 + || connDn == NULL ) + { /* default to operation DN */ conn->c_ndn = op->o_ndn; conn->c_dn = op->o_ndn; + } else { /* NB: conn DN must be normalized */ - conn->c_ndn.bv_val = connDn; - conn->c_ndn.bv_len = strlen( connDn ); - + ber_str2bv( connDn, 0, 0, &conn->c_ndn ); conn->c_dn = conn->c_ndn; } @@ -242,8 +242,9 @@ slapi_int_pblock_get_operation( Slapi_PBlock *pb, Operation *op, SlapReply *rs ) int rc; /* All internal operations must specify a target DN */ - if ( slapi_pblock_get( pb, SLAPI_TARGET_DN, (void **)&targetDn.bv_val ) != 0 || - targetDn.bv_val == NULL ) { + if ( slapi_pblock_get( pb, SLAPI_TARGET_DN, (void **)&targetDn.bv_val ) != 0 + || targetDn.bv_val == NULL ) + { return LDAP_PARAM_ERROR; } @@ -270,8 +271,7 @@ slapi_int_pblock_get_operation( Slapi_PBlock *pb, Operation *op, SlapReply *rs ) op->o_ndn = op->o_bd->be_rootndn; isRoot = 1; } else { - op->o_ndn.bv_val = requestorDn; - op->o_ndn.bv_len = strlen( requestorDn ); + ber_str2bv( requestorDn, 0, 0, &op->o_ndn ); op->o_dn = op->o_ndn; } @@ -293,7 +293,7 @@ slapi_int_pblock_get_operation( Slapi_PBlock *pb, Operation *op, SlapReply *rs ) } int -slapi_int_init_connection( Slapi_PBlock *pb, +slapi_int_connection_init( Slapi_PBlock *pb, SlapReply *rs, int OpType, Connection **pConn ) @@ -323,12 +323,9 @@ slapi_int_init_connection( Slapi_PBlock *pb, /* connection object authorization information */ conn->c_authtype = LDAP_AUTH_NONE; - conn->c_authmech.bv_val = NULL; - conn->c_authmech.bv_len = 0; - conn->c_dn.bv_val = NULL; - conn->c_dn.bv_len = 0; - conn->c_ndn.bv_val = NULL; - conn->c_ndn.bv_len = 0; + BER_BVZERO( &conn->c_authmech ); + BER_BVZERO( &conn->c_dn ); + BER_BVZERO( &conn->c_ndn ); conn->c_listener = &slap_unknown_listener; ber_dupbv( &conn->c_peer_domain, (struct berval *)&slap_unknown_bv ); @@ -336,8 +333,7 @@ slapi_int_init_connection( Slapi_PBlock *pb, LDAP_STAILQ_INIT( &conn->c_ops ); - conn->c_sasl_bind_mech.bv_val = NULL; - conn->c_sasl_bind_mech.bv_len = 0; + BER_BVZERO( &conn->c_sasl_bind_mech ); conn->c_sasl_authctx = NULL; conn->c_sasl_sockctx = NULL; conn->c_sasl_extra = NULL; @@ -392,8 +388,7 @@ slapi_int_init_connection( Slapi_PBlock *pb, /* operation object */ op->o_tag = OpType; op->o_protocol = LDAP_VERSION3; - op->o_authmech.bv_val = NULL; - op->o_authmech.bv_len = 0; + BER_BVZERO( &op->o_authmech ); op->o_time = slap_get_time(); op->o_do_not_cache = 1; op->o_threadctx = ldap_pvt_thread_pool_context(); @@ -713,7 +708,7 @@ slapi_delete_internal_pb( Slapi_PBlock *pb ) slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, &operation_flags ); - rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_DELETE, &conn ); + rs.sr_err = slapi_int_connection_init( pb, &rs, LDAP_REQ_DELETE, &conn ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -787,7 +782,7 @@ slapi_add_internal_pb( Slapi_PBlock *pb ) slapi_pblock_set( pb, SLAPI_ADD_TARGET, &entry->e_nname.bv_val ); } - rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_ADD, &conn ); + rs.sr_err = slapi_int_connection_init( pb, &rs, LDAP_REQ_ADD, &conn ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -884,7 +879,7 @@ slapi_modrdn_internal_pb( Slapi_PBlock *pb ) slapi_pblock_get( pb, SLAPI_MODRDN_DELOLDRDN, (void **)&deloldrdn ); slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags ); - rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_MODRDN, &conn ); + rs.sr_err = slapi_int_connection_init( pb, &rs, LDAP_REQ_MODRDN, &conn ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -996,7 +991,7 @@ int slapi_modify_internal_pb( Slapi_PBlock *pb ) goto cleanup; } - rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_MODIFY, &conn ); + rs.sr_err = slapi_int_connection_init( pb, &rs, LDAP_REQ_MODIFY, &conn ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -1237,7 +1232,7 @@ int slapi_search_internal_callback_pb( Slapi_PBlock *pb, slapi_pblock_get( pb, SLAPI_TARGET_UNIQUEID, (void **)&uniqueid ); slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags ); - rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_SEARCH, &conn ); + rs.sr_err = slapi_int_connection_init( pb, &rs, LDAP_REQ_SEARCH, &conn ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 12a9a3ffe1..a873ea8290 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -541,15 +541,19 @@ slapi_entry_has_children(const Slapi_Entry *e) pb = slapi_pblock_new(); - slapi_pblock_set( pb, SLAPI_TARGET_DN, slapi_entry_get_dn((Entry *)e) ); + slapi_pblock_set( pb, SLAPI_TARGET_DN, slapi_entry_get_dn( (Entry *)e ) ); - rc = slapi_int_init_connection( pb, &rs, LDAP_REQ_SEARCH, &conn ); + rc = slapi_int_connection_init( pb, &rs, LDAP_REQ_SEARCH, &conn ); if ( rc != LDAP_SUCCESS ) { slapi_pblock_destroy( pb ); return 0; } - op->o_bd->be_has_subordinates( op, (Entry *)e, &hasSubordinates ); + op = conn->c_pending_ops.stqh_first; + op->o_bd = select_backend( &e->e_ndn, 0, 0 ); + if ( op->o_bd != NULL ) { + op->o_bd->be_has_subordinates( op, (Entry *)e, &hasSubordinates ); + } slapi_int_connection_destroy( &conn ); slapi_pblock_destroy( pb );