SLAPI fixes

This commit is contained in:
Luke Howard 2003-03-31 04:56:17 +00:00
parent 4dd53084a0
commit 6c2f47ecd5
6 changed files with 216 additions and 225 deletions

View file

@ -521,12 +521,12 @@ slap_mods2entry(
}
#ifdef LDAP_SLAPI
static void Slapi_PBlock *initAddPlugin( Operation *op,
static void initAddPlugin( Operation *op,
struct berval *dn, Entry *e, int manageDSAit )
{
slapi_x_backend_set_pb( pb, op->o_bd );
slapi_x_connection_set_pb( pb, op->o_conn );
slapi_x_operation_set_pb( pb, op );
slapi_x_backend_set_pb( op->o_pb, op->o_bd );
slapi_x_connection_set_pb( op->o_pb, op->o_conn );
slapi_x_operation_set_pb( op->o_pb, op );
slapi_pblock_set( op->o_pb, SLAPI_ADD_TARGET, (void *)dn->bv_val );
slapi_pblock_set( op->o_pb, SLAPI_ADD_ENTRY, (void *)e );
@ -559,7 +559,7 @@ static int doPreAddPluginFNs( Operation *op )
return rc;
}
static void doPostAddPluginFNs( Operation *op );
static void doPostAddPluginFNs( Operation *op )
{
int rc;

View file

@ -275,13 +275,13 @@ do_extended(
} else {
rs->sr_err = slapi_pblock_get( pb, SLAPI_EXT_OP_RET_OID,
&rs->sr_resoid);
&rs->sr_rspoid);
if ( rs->sr_err != LDAP_SUCCESS ) {
goto done2;
}
rs->sr_err = slapi_pblock_get( pb, SLAPI_EXT_OP_RET_VALUE,
&rs->sr_resdata);
&rs->sr_rspdata);
if ( rs->sr_err != LDAP_SUCCESS ) {
goto done2;
}
@ -296,12 +296,12 @@ done2:;
send_ldap_result( op, rs );
}
if ( op->oq_extended.rs_resoid != NULL ) {
free( op->oq_extended.rs_resoid );
if ( op->oq_extended.rs_reqoid.bv_val != NULL ) {
slapi_ch_free( (void **)&op->oq_extended.rs_reqoid.bv_val );
}
if ( op->oq_extended.rs_resdata != NULL ) {
ber_bvfree( op->oq_extended.rs_resdata );
if ( op->oq_extended.rs_reqdata != NULL ) {
ber_bvfree( op->oq_extended.rs_reqdata );
}
} /* end of Netscape extended operation */

View file

@ -324,15 +324,15 @@ do_modify(
}
#if defined( LDAP_SLAPI )
slapi_x_backend_set_pb( pb, be );
slapi_x_connection_set_pb( pb, conn );
slapi_x_backend_set_pb( pb, op->o_bd );
slapi_x_connection_set_pb( pb, op->o_conn );
slapi_x_operation_set_pb( pb, op );
slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
modv = slapi_x_modifications2ldapmods( &modlist );
slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
rs->sr_err = doPluginFNs( be, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
if ( rs->sr_err != 0 ) {
/*
* A preoperation plugin failure will abort the

View file

@ -1080,7 +1080,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
}
if ( rc == 1 ) {
ber_free_buf( ber );
send_ldap_error( op, LDAP_OTHER, "computed attribute error" );
send_ldap_error( op, rs, LDAP_OTHER, "computed attribute error" );
goto error_return;
}
#endif /* LDAP_SLAPI */

View file

@ -29,32 +29,22 @@ int bvptr2obj( struct berval **bvptr, struct berval **bvobj );
static void
internal_result_v3(
Connection *conn,
Operation *op,
ber_int_t err,
const char *matched,
const char *text,
BerVarray referrals,
LDAPControl **ctrls )
SlapReply *rs )
{
return;
}
static int
internal_search_entry(
Backend *be,
Connection *conn,
Operation *op,
Entry *e,
AttributeName *attrs,
int attrsonly,
LDAPControl **ctrls )
Operation *op,
SlapReply *rs )
{
char *ent2str = NULL;
int nentries = 0, len = 0, i = 0;
Slapi_Entry **head = NULL, **tp;
ent2str = slapi_entry2str( e, &len );
ent2str = slapi_entry2str( rs->sr_entry, &len );
if ( ent2str == NULL ) {
return 1;
}
@ -99,45 +89,27 @@ internal_search_entry(
static void
internal_search_result(
Connection *conn,
Operation *op,
ber_int_t err,
const char *matched,
const char *text,
BerVarray refs,
LDAPControl **ctrls,
int nentries )
SlapReply *sr )
{
slapi_pblock_set( (Slapi_PBlock *)op->o_pb,
SLAPI_NENTRIES, (void *)nentries );
SLAPI_NENTRIES, (void *)sr->sr_nentries );
return;
}
static void
internal_result_ext(
Connection *conn,
Operation *op,
ber_int_t errnum,
const char *matched,
const char *text,
BerVarray refs,
const char *rspoid,
struct berval *rspdata,
LDAPControl **ctrls )
Operation *op,
SlapReply *sr )
{
return;
}
static int
internal_search_reference(
Backend *be,
Connection *conn,
Operation *op,
Entry *e,
BerVarray refs,
LDAPControl **ctrls,
BerVarray *v2refs )
Operation *op,
SlapReply *sr )
{
return LDAP_SUCCESS;
}
@ -435,7 +407,7 @@ LDAPModToEntry(
}
if ( !repl_user ) {
rc = slap_mods_opattrs( be, op,
rc = slap_mods_opattrs( op,
modlist, modtail, &text,
textbuf, textlen );
if ( rc != LDAP_SUCCESS) {
@ -497,10 +469,9 @@ slapi_delete_internal(
Operation *op = NULL;
Slapi_PBlock *pPB = NULL;
Slapi_PBlock *pSavePB = NULL;
SlapReply rs = { REP_RESULT };
struct berval dn = { 0, NULL };
struct berval pdn = { 0, NULL };
struct berval ndn = { 0, NULL };
int rc=LDAP_SUCCESS;
int manageDsaIt = 0;
@ -522,8 +493,8 @@ slapi_delete_internal(
op->o_ctrls = controls;
dn.bv_val = slapi_ch_strdup(ldn);
dn.bv_len = slapi_strlen(ldn);
rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
dn.bv_len = strlen(ldn);
rc = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn );
if ( rc != LDAP_SUCCESS ) goto cleanup;
if ( slapi_control_present( controls,
@ -531,7 +502,7 @@ slapi_delete_internal(
manageDsaIt = 1;
}
be = select_backend( &ndn, manageDsaIt, 0 );
be = select_backend( &op->o_req_ndn, manageDsaIt, 0 );
if ( be == NULL ) {
rc = LDAP_PARTIAL_RESULTS;
goto cleanup;
@ -543,10 +514,10 @@ slapi_delete_internal(
if ( be->be_delete ) {
int repl_user = be_isupdate( be, &op->o_ndn );
if ( !be->be_update_ndn.bv_len || repl_user ) {
rc = (*be->be_delete)( be, pConn, op, &pdn, &ndn );
rc = (*be->be_delete)( op, &rs );
if ( rc == 0 ) {
if (log_change) {
replog( be, op, &pdn, &ndn, NULL );
replog( op );
}
rc = LDAP_SUCCESS;
} else {
@ -563,9 +534,12 @@ cleanup:
if (pPB != NULL)
slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
if (dn.bv_val) slapi_ch_free( (void **)&dn.bv_val );
if (pdn.bv_val) slapi_ch_free( (void **)&pdn.bv_val );
if (ndn.bv_val) slapi_ch_free( (void **)&ndn.bv_val );
if ( dn.bv_val )
slapi_ch_free( (void **)&dn.bv_val );
if ( op->o_req_dn.bv_val )
slapi_ch_free( (void **)&op->o_req_dn.bv_val );
if ( op->o_req_ndn.bv_val )
slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
if ( pConn != NULL ) {
if ( pConn->c_sb != NULL ) ber_sockbuf_free( pConn->c_sb );
@ -594,6 +568,7 @@ slapi_add_entry_internal(
int manageDsaIt = 0;
int isCritical;
int rc = LDAP_SUCCESS;
SlapReply rs = { REP_RESULT };
if ( e == NULL ) {
rc = LDAP_PARAM_ERROR;
@ -623,14 +598,14 @@ slapi_add_entry_internal(
op->o_dn = pConn->c_dn = be->be_rootdn;
op->o_ndn = pConn->c_ndn = be->be_rootndn;
op->oq_add.rs_e = e;
if ( be->be_add ) {
int repl_user = be_isupdate( be, &op->o_ndn );
if ( !be->be_update_ndn.bv_len || repl_user ){
if ( (*be->be_add)( be, pConn, op, e ) == 0 ) {
if ( (*be->be_add)( op, &rs ) == 0 ) {
if ( log_changes ) {
replog( be, op, &e->e_name,
&e->e_nname, e );
replog( op );
}
rc = LDAP_SUCCESS;
}
@ -729,62 +704,16 @@ slapi_modrdn_internal(
{
#if defined(LDAP_SLAPI)
int rc = LDAP_SUCCESS;
struct berval dn = { 0, NULL };
struct berval pdn = { 0, NULL };
struct berval ndn = { 0, NULL };
struct berval newrdn = { 0, NULL };
struct berval pnewrdn = { 0, NULL };
struct berval nnewrdn = { 0, NULL };
#if 0 /* currently unused */
struct berval newSuperior = { 0, NULL };
#endif
struct berval pnewSuperior = { 0, NULL };
#if 0 /* currently unused */
struct berval nnewSuperior = { 0, NULL };
#endif
struct berval *pnewS = NULL;
struct berval *nnewS = NULL;
Connection *pConn = NULL;
Operation *op = NULL;
Slapi_PBlock *pPB = NULL;
Slapi_PBlock *pSavePB = NULL;
Backend *be;
#if 0 /* currently unused */
Backend *newSuperior_be = NULL;
#endif
int manageDsaIt = 0;
int isCritical;
#if 0 /* currently unused */
const char *text = NULL;
#endif
dn.bv_val = slapi_ch_strdup(olddn);
dn.bv_len = slapi_ch_stlen(olddn);
rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
if ( rc != LDAP_SUCCESS ) goto cleanup;
if ( ndn.bv_len == 0 ) {
rc = LDAP_UNWILLING_TO_PERFORM;
goto cleanup;
}
newrdn.bv_val = slapi_ch_strdup( lnewrdn );
newrdn.bv_len = slapi_ch_stlen( lnewrdn );
rc = dnPrettyNormal( NULL, &newrdn, &pnewrdn, &nnewrdn );
if ( rc != LDAP_SUCCESS ) goto cleanup;
if ( rdnValidate( &pnewrdn ) != LDAP_SUCCESS ) goto cleanup;
SlapReply rs = { REP_RESULT };
pConn = fakeConnection( NULL, LDAP_REQ_MODRDN);
if ( pConn == NULL) {
@ -801,7 +730,7 @@ slapi_modrdn_internal(
manageDsaIt = 1;
}
be = select_backend( &ndn, manageDsaIt, 0 );
be = select_backend( &op->o_req_ndn, manageDsaIt, 0 );
if ( be == NULL ) {
rc = LDAP_PARTIAL_RESULTS;
goto cleanup;
@ -810,19 +739,42 @@ slapi_modrdn_internal(
op->o_dn = pConn->c_dn = be->be_rootdn;
op->o_ndn = pConn->c_ndn = be->be_rootndn;
dn.bv_val = slapi_ch_strdup( olddn );
dn.bv_len = strlen( olddn );
rc = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn );
if ( rc != LDAP_SUCCESS ) {
goto cleanup;
}
if ( op->o_req_dn.bv_len == 0 ) {
rc = LDAP_UNWILLING_TO_PERFORM;
goto cleanup;
}
newrdn.bv_val = slapi_ch_strdup( lnewrdn );
newrdn.bv_len = strlen( lnewrdn );
rc = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn );
if ( rc != LDAP_SUCCESS ) {
goto cleanup;
}
if ( rdnValidate( &op->oq_modrdn.rs_nnewrdn ) != LDAP_SUCCESS ) {
goto cleanup;
}
op->oq_modrdn.rs_newSup = NULL;
op->oq_modrdn.rs_nnewSup = NULL;
op->oq_modrdn.rs_deleteoldrdn = deloldrdn;
if ( be->be_modrdn ) {
int repl_user = be_isupdate( be, &op->o_ndn );
if ( !be->be_update_ndn.bv_len || repl_user ) {
rc = (*be->be_modrdn)( be, pConn, op, &pdn, &ndn,
&pnewrdn, &nnewrdn, deloldrdn, pnewS,
nnewS );
rc = (*be->be_modrdn)( op, &rs );
if ( rc == 0 ) {
struct slap_replog_moddn moddn;
moddn.newrdn = &pnewrdn;
moddn.deloldrdn = deloldrdn;
moddn.newsup = &pnewSuperior;
if ( log_change ) {
replog( be, op, &pdn, &ndn, &moddn );
replog( op );
}
rc = LDAP_SUCCESS;
@ -844,17 +796,25 @@ cleanup:
slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
}
if ( dn.bv_val ) ch_free( dn.bv_val );
if ( pdn.bv_val ) ch_free( pdn.bv_val );
if ( ndn.bv_val ) ch_free( ndn.bv_val );
if ( dn.bv_val )
slapi_ch_free( (void **)&dn.bv_val );
if ( op->o_req_dn.bv_val )
slapi_ch_free( (void **)&op->o_req_dn.bv_val );
if ( op->o_req_ndn.bv_val )
slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
if ( newrdn.bv_val ) ch_free( newrdn.bv_val );
if ( pnewrdn.bv_val ) ch_free( newrdn.bv_val );
if ( nnewrdn.bv_val ) ch_free( newrdn.bv_val );
if ( newrdn.bv_val )
slapi_ch_free( (void **)&newrdn.bv_val );
if ( op->oq_modrdn.rs_newrdn.bv_val )
slapi_ch_free( (void **)&op->oq_modrdn.rs_newrdn.bv_val );
if ( op->oq_modrdn.rs_nnewrdn.bv_val )
slapi_ch_free( (void **)&op->oq_modrdn.rs_nnewrdn.bv_val );
if ( pConn != NULL ) {
if ( pConn->c_sb != NULL ) ber_sockbuf_free( pConn->c_sb );
if ( op != NULL ) slapi_ch_free( (void **)&op );
if ( pConn->c_sb != NULL )
ber_sockbuf_free( pConn->c_sb );
if ( op != NULL )
slapi_ch_free( (void **)&op );
pSavePB = pPB;
free( pConn );
}
@ -889,8 +849,6 @@ slapi_modify_internal(
Slapi_PBlock *pSavePB = NULL;
struct berval dn = { 0, NULL };
struct berval pdn = { 0, NULL };
struct berval ndn = { 0, NULL };
int manageDsaIt = 0;
int isCritical;
@ -902,6 +860,8 @@ slapi_modify_internal(
Modifications **modtail = &modlist;
Modifications tmp;
SlapReply rs = { REP_RESULT };
if ( mods == NULL || *mods == NULL || ldn == NULL ) {
rc = LDAP_PARAM_ERROR ;
goto cleanup;
@ -918,16 +878,18 @@ slapi_modify_internal(
op->o_ctrls = controls;
dn.bv_val = slapi_ch_strdup( ldn );
dn.bv_len = slapi_strlen( ldn );
rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
if ( rc != LDAP_SUCCESS ) goto cleanup;
dn.bv_len = strlen( ldn );
rc = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn );
if ( rc != LDAP_SUCCESS ) {
goto cleanup;
}
if ( slapi_control_present( controls,
SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical ) ) {
manageDsaIt = 1;
}
be = select_backend( &ndn, manageDsaIt, 0 );
be = select_backend( &op->o_req_ndn, manageDsaIt, 0 );
if ( be == NULL ) {
rc = LDAP_PARTIAL_RESULTS;
goto cleanup;
@ -1007,11 +969,13 @@ slapi_modify_internal(
}
*modtail = NULL;
if ( ndn.bv_len == 0 ) {
if ( op->o_req_ndn.bv_len == 0 ) {
rc = LDAP_UNWILLING_TO_PERFORM;
goto cleanup;
}
op->oq_modify.rs_modlist = modlist;
if ( be->be_modify ) {
int repl_user = be_isupdate( be, &op->o_ndn );
if ( !be->be_update_ndn.bv_len || repl_user ) {
@ -1027,18 +991,17 @@ slapi_modify_internal(
}
if ( !repl_user ) {
rc = slap_mods_opattrs( be, op, modlist,
rc = slap_mods_opattrs( op, modlist,
modtail, &text, textbuf,
textlen );
if (rc != LDAP_SUCCESS) {
goto cleanup;
}
}
rc = (*be->be_modify)( be, pConn, op,
&pdn, &ndn, modlist );
rc = (*be->be_modify)( op, &rs );
if ( rc == 0 ) {
if ( log_change ) {
replog( be, op, &pdn, &ndn, modlist );
replog( op );
}
rc = LDAP_SUCCESS;
} else {
@ -1056,9 +1019,12 @@ cleanup:
if ( pPB != NULL )
slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
if ( dn.bv_val ) ch_free( dn.bv_val );
if ( pdn.bv_val ) ch_free( pdn.bv_val );
if ( ndn.bv_val ) ch_free( ndn.bv_val );
if ( dn.bv_val )
slapi_ch_free( (void **)&dn.bv_val );
if ( op->o_req_dn.bv_val )
slapi_ch_free( (void **)&op->o_req_dn.bv_val );
if ( op->o_req_ndn.bv_val )
slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
if ( modlist != NULL ) freeMods( modlist );
@ -1092,21 +1058,18 @@ slapi_search_internal_bind(
Slapi_PBlock *ptr = NULL;
Slapi_PBlock *pSavePB = NULL;
struct berval dn = { 0, NULL };
struct berval pdn = { 0, NULL };
struct berval ndn = { 0, NULL };
Filter *filter=NULL;
struct berval fstr = { 0, NULL };
AttributeName *an = NULL;
const char *text = NULL;
int deref=0;
int sizelimit=-1, timelimit=-1;
int manageDsaIt = 0;
int isCritical;
int i, rc = LDAP_SUCCESS;
SlapReply rs = { REP_RESULT };
c = fakeConnection( NULL, LDAP_REQ_SEARCH );
if (c == NULL) {
rc = LDAP_NO_MEMORY;
@ -1118,10 +1081,12 @@ slapi_search_internal_bind(
op->o_ctrls = controls;
dn.bv_val = slapi_ch_strdup(ldn);
dn.bv_len = slapi_strlen(ldn);
dn.bv_len = strlen(ldn);
rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
if (rc != LDAP_SUCCESS) goto cleanup;
rc = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn );
if ( rc != LDAP_SUCCESS ) {
goto cleanup;
}
if ( scope != LDAP_SCOPE_BASE &&
scope != LDAP_SCOPE_ONELEVEL &&
@ -1148,34 +1113,43 @@ slapi_search_internal_bind(
an[i].an_desc = NULL;
an[i].an_oc = NULL;
an[i].an_name.bv_val = slapi_ch_strdup(attrs[i]);
an[i].an_name.bv_len = slapi_strlen(attrs[i]);
an[i].an_name.bv_len = strlen(attrs[i]);
slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text );
}
an[i].an_name.bv_val = NULL;
}
if ( scope == LDAP_SCOPE_BASE ) {
Entry *entry = NULL;
memset( &rs, 0, sizeof(rs) );
rs.sr_type = REP_RESULT;
rs.sr_err = LDAP_OTHER;
if ( ndn.bv_len == 0 ) {
rc = root_dse_info( c, &entry, &text );
if ( scope == LDAP_SCOPE_BASE ) {
rs.sr_entry = NULL;
if ( op->o_req_ndn.bv_len == 0 ) {
rs.sr_err = root_dse_info( c, &rs.sr_entry, &rs.sr_text );
}
if( rc != LDAP_SUCCESS ) {
send_ldap_result( c, op, rc, NULL, text, NULL, NULL );
if( rs.sr_err != LDAP_SUCCESS ) {
send_ldap_result( op, &rs );
goto cleanup;
} else if ( entry != NULL ) {
rc = test_filter( NULL, c, op, entry, filter );
} else if ( rs.sr_entry != NULL ) {
rc = test_filter( op, rs.sr_entry, filter );
if( rc == LDAP_COMPARE_TRUE ) {
send_search_entry( NULL, c, op, entry,
an, attrsonly, NULL );
rs.sr_type = REP_SEARCH;
rs.sr_err = LDAP_SUCCESS;
rs.sr_attrs = an;
send_search_entry( op, &rs );
}
entry_free( entry );
entry_free( rs.sr_entry );
send_ldap_result( c, op, LDAP_SUCCESS,
NULL, NULL, NULL, NULL );
rs.sr_type = REP_RESULT;
rs.sr_err = LDAP_SUCCESS;
send_ldap_result( op, &rs );
rc = LDAP_SUCCESS;
@ -1183,12 +1157,12 @@ slapi_search_internal_bind(
}
}
if ( !ndn.bv_len && default_search_nbase.bv_len ) {
ch_free( pdn.bv_val );
ch_free( ndn.bv_val );
if ( !op->o_req_ndn.bv_len && default_search_nbase.bv_len ) {
slapi_ch_free( (void **)op->o_req_dn.bv_val );
slapi_ch_free( (void **)op->o_req_ndn.bv_val );
ber_dupbv( &pdn, &default_search_base );
ber_dupbv( &ndn, &default_search_nbase );
ber_dupbv( &op->o_req_dn, &default_search_base );
ber_dupbv( &op->o_req_ndn, &default_search_nbase );
}
if ( slapi_control_present( controls,
@ -1196,7 +1170,7 @@ slapi_search_internal_bind(
manageDsaIt = 1;
}
be = select_backend( &ndn, manageDsaIt, 0 );
be = select_backend( &op->o_req_ndn, manageDsaIt, 0 );
if ( be == NULL ) {
if ( manageDsaIt == 1 ) {
rc = LDAP_NO_SUCH_OBJECT;
@ -1209,10 +1183,17 @@ slapi_search_internal_bind(
op->o_dn = c->c_dn = be->be_rootdn;
op->o_ndn = c->c_ndn = be->be_rootndn;
op->oq_search.rs_scope = scope;
op->oq_search.rs_deref = 0;
op->oq_search.rs_slimit = LDAP_NO_LIMIT;
op->oq_search.rs_tlimit = LDAP_NO_LIMIT;
op->oq_search.rs_attrsonly = attrsonly;
op->oq_search.rs_attrs = an;
op->oq_search.rs_filter = filter;
op->oq_search.rs_filterstr = fstr;
if ( be->be_search ) {
rc = (*be->be_search)( be, c, op, &pdn, &ndn,
scope, deref, sizelimit, timelimit,
filter, &fstr, an, attrsonly );
rc = (*be->be_search)( op, &rs );
if ( rc == 0 ) {
rc = LDAP_SUCCESS;
} else {
@ -1227,9 +1208,12 @@ cleanup:
if ( ptr != NULL )
slapi_pblock_set( ptr, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
if ( dn.bv_val ) free( dn.bv_val );
if ( ndn.bv_val ) free( ndn.bv_val );
if ( pdn.bv_val ) free( pdn.bv_val );
if ( dn.bv_val )
slapi_ch_free( (void **)&dn.bv_val );
if ( op->o_req_dn.bv_val )
slapi_ch_free( (void **)&op->o_req_dn.bv_val );
if ( op->o_req_ndn.bv_val )
slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
if ( filter ) slapi_filter_free( filter, 1 );
if ( fstr.bv_val ) free ( fstr.bv_val );

View file

@ -1202,10 +1202,9 @@ slapiControlOp2SlapControlMask(unsigned long slapi_mask,
static int
parseSlapiControl(
Connection *conn,
Operation *op,
LDAPControl *ctrl,
const char **text)
SlapReply *rs,
LDAPControl *ctrl )
{
/* Plugins must deal with controls themselves. */
@ -1349,31 +1348,42 @@ slapi_send_ldap_result(
struct berval **urls )
{
#ifdef LDAP_SLAPI
Connection *conn;
Operation *op;
struct berval *s;
char *extOID = NULL;
struct berval *extValue = NULL;
int rc;
SlapReply rs;
slapi_pblock_get( pb, SLAPI_CONNECTION, &conn );
slapi_pblock_get( pb, SLAPI_OPERATION, &op );
rs.sr_err = err;
rs.sr_matched = matched;
rs.sr_text = text;
rs.sr_ref = NULL;
rs.sr_ctrls = NULL;
if ( err == LDAP_SASL_BIND_IN_PROGRESS ) {
slapi_pblock_get( pb, SLAPI_BIND_RET_SASLCREDS, &s );
rc = LDAP_SASL_BIND_IN_PROGRESS;
send_ldap_sasl( conn, op, rc, NULL, NULL, NULL, NULL, s );
rs.sr_type = REP_SASL;
slapi_pblock_get( pb, SLAPI_BIND_RET_SASLCREDS, (void *) &rs.sr_sasldata );
send_ldap_sasl( op, &rs );
return;
}
slapi_pblock_get( pb, SLAPI_EXT_OP_RET_OID, &extOID );
if ( extOID != NULL ) {
slapi_pblock_get( pb, SLAPI_EXT_OP_RET_VALUE, &extValue );
slapi_send_ldap_extended_response( conn, op, err, extOID,
extValue );
rs.sr_type = REP_EXTENDED;
rs.sr_rspoid = extOID;
slapi_pblock_get( pb, SLAPI_EXT_OP_RET_VALUE, &rs.sr_rspdata );
send_ldap_response( op, &rs );
return;
}
send_ldap_result( conn, op, err, matched, text, NULL, NULL );
rs.sr_type = REP_RESULT;
slapi_pblock_get( pb, SLAPI_RESCONTROLS, &rs.sr_ctrls );
send_ldap_result( op, &rs );
#endif /* LDAP_SLAPI */
}
@ -1390,7 +1400,7 @@ slapi_send_ldap_search_entry(
Connection *pConn;
Operation *pOp;
int rc;
SlapReply rs;
int i;
AttributeName *an = NULL;
const char *text;
@ -1412,12 +1422,20 @@ slapi_send_ldap_search_entry(
an[i].an_name.bv_val = NULL;
}
if ( ( rc = slapi_pblock_get( pb, SLAPI_BACKEND, (void *)&be ) != 0 ) ||
( rc = slapi_pblock_get( pb, SLAPI_CONNECTION, (void *)&pConn) != 0 ) ||
( rc = slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&pOp) != 0 ) ) {
rs.sr_type = REP_SEARCH;
rs.sr_err = LDAP_SUCCESS;
rs.sr_matched = NULL;
rs.sr_text = NULL;
rs.sr_ref = NULL;
rs.sr_ctrls = ectrls;
rs.sr_attrs = an;
rs.sr_entry = e;
rs.sr_v2ref = NULL;
if ( rc = slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&pOp) != 0 ) {
rc = LDAP_OTHER;
} else {
rc = send_search_entry( be, pConn, pOp, e, an, attrsonly, NULL );
rc = send_search_entry( pOp, &rs );
}
return rc;
@ -1751,7 +1769,7 @@ slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f,
* According to acl.c it is safe to call test_filter() with
* NULL arguments...
*/
rc = test_filter( be, conn, op, e, f );
rc = test_filter( op, e, f );
switch (rc) {
case LDAP_COMPARE_TRUE:
rc = 0;
@ -1841,8 +1859,19 @@ slapi_send_ldap_extended_response(
struct berval *response )
{
#ifdef LDAP_SLAPI
send_ldap_extended( conn,op, errornum, NULL, NULL, NULL,
respName,response, NULL );
SlapReply rs;
rs.sr_type = REP_EXTENDED;
rs.sr_err = errornum;
rs.sr_matched = NULL;
rs.sr_text = NULL;
rs.sr_ref = NULL;
rs.sr_ctrls = NULL;
rs.sr_rspoid = respName;
rs.sr_rspdata = response;
send_ldap_extended( op, &rs );
return LDAP_SUCCESS;
#else /* LDAP_SLAPI */
return -1;
@ -3072,21 +3101,11 @@ int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr,
int slapi_acl_check_mods(Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, char **errbuf)
{
#ifdef LDAP_SLAPI
Backend *be;
Connection *conn;
Operation *op;
int ret;
Modifications *ml;
Modifications *next;
if ( slapi_pblock_get( pb, SLAPI_BACKEND, (void *)&be ) != 0 ) {
return LDAP_PARAM_ERROR;
}
if ( slapi_pblock_get( pb, SLAPI_CONNECTION, (void *)&conn ) != 0 ) {
return LDAP_PARAM_ERROR;
}
if ( slapi_pblock_get( pb, SLAPI_OPERATION, (void *)&op ) != 0 ) {
return LDAP_PARAM_ERROR;
}
@ -3096,7 +3115,7 @@ int slapi_acl_check_mods(Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, char
return LDAP_OTHER;
}
ret = acl_check_modlist( be, conn, op, e, ml );
ret = acl_check_modlist( op, e, ml );
/* Careful when freeing the modlist because it has pointers into the mods array. */
for ( ; ml != NULL; ml = next ) {
@ -3294,8 +3313,6 @@ void slapi_x_free_ldapmods (LDAPMod **mods)
int slapi_x_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_Entry *e)
{
#ifdef LDAP_SLAPI
Backend *be = NULL;
Connection *conn = NULL;
Operation *op = NULL;
BerElement *ber;
AttributeDescription *desc = NULL;
@ -3314,16 +3331,6 @@ int slapi_x_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_En
return 1;
}
rc = slapi_pblock_get( c->cac_pb, SLAPI_BACKEND, (void *)&be );
if ( rc != 0 ) {
be = NULL; /* no backend for root DSE */
}
rc = slapi_pblock_get( c->cac_pb, SLAPI_CONNECTION, (void *)&conn );
if ( rc != 0 || conn == NULL ) {
return rc;
}
rc = slapi_pblock_get( c->cac_pb, SLAPI_OPERATION, (void *)&op );
if ( rc != 0 || op == NULL ) {
return rc;
@ -3350,7 +3357,7 @@ int slapi_x_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_En
}
}
if ( !access_allowed( be, conn, op, e, desc, NULL, ACL_READ, &c->cac_acl_state) ) {
if ( !access_allowed( op, e, desc, NULL, ACL_READ, &c->cac_acl_state) ) {
slapi_log_error( SLAPI_LOG_ACL, "SLAPI_COMPUTE",
"acl: access to attribute %s not allowed\n",
desc->ad_cname.bv_val );
@ -3366,7 +3373,7 @@ int slapi_x_compute_output_ber(computed_attr_context *c, Slapi_Attr *a, Slapi_En
if ( !c->cac_attrsonly ) {
for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
if ( !access_allowed( be, conn, op, e,
if ( !access_allowed( op, e,
desc, &a->a_vals[i], ACL_READ, &c->cac_acl_state)) {
slapi_log_error( SLAPI_LOG_ACL, "SLAPI_COMPUTE",
"slapi_x_compute_output_ber: conn %lu "