BerElementBuffer berbuf;
BerElement *ber = (BerElement *) &berbuf;
struct berval ctrlval;
- LDAPControl *ctrl, *ctrlsp[2];
+ LDAPControl *ctrl;
ber_init2( ber, NULL, LBER_USE_DER );
ber_free_buf( ber );
- ctrlsp[0] = ctrl;
- ctrlsp[1] = NULL;
- slap_add_ctrls( op, rs, ctrlsp );
+ slap_add_ctrl( op, rs, ctrl );
return SLAP_CB_CONTINUE;
}
int i, rc = LDAP_SUCCESS;
for ( i = 0; i < valnum[level].ap->a_numvals; i++ ) {
- LDAPControl *ctrl = NULL, *ctrlsp[2];
+ LDAPControl *ctrl;
valnum[level].a.a_vals[0] = valnum[level].ap->a_vals[i];
if ( valnum[level].ap->a_nvals != valnum[level].ap->a_vals ) {
ctrl->ldctl_oid = LDAP_CONTROL_DUPENT_ENTRY;
ctrl->ldctl_iscritical = 0;
- ctrlsp[0] = ctrl;
- ctrlsp[1] = NULL;
- slap_add_ctrls( op, rs, ctrlsp );
+ slap_add_ctrl( op, rs, ctrl );
/* do the real send */
rs->sr_entry = e;
BerElementBuffer berbuf;
BerElement *ber = (BerElement *) &berbuf;
struct berval ctrlval;
- LDAPControl *ctrl, *ctrlsp[2];
+ LDAPControl *ctrl;
int rc = rs->sr_err;
if ( nc->nc_save_slimit >= 0 && nc->nc_nentries >= nc->nc_save_slimit ) {
ber_free_buf( ber );
- ctrlsp[0] = ctrl;
- ctrlsp[1] = NULL;
- slap_add_ctrls( op, rs, ctrlsp );
+ slap_add_ctrl( op, rs, ctrl );
}
return SLAP_CB_CONTINUE;
}
ID *lastid,
int tentries )
{
- LDAPControl *ctrls[2];
+ LDAPControl *ctrl;
BerElementBuffer berbuf;
BerElement *ber = (BerElement *)&berbuf;
PagedResultsCookie respcookie;
"send_paged_response: lastid=0x%08lx nentries=%d\n",
lastid ? *lastid : 0, rs->sr_nentries );
- ctrls[1] = NULL;
-
ber_init2( ber, NULL, LBER_USE_DER );
if ( lastid ) {
/* return size of 0 -- no estimate */
ber_printf( ber, "{iO}", 0, &cookie );
- ctrls[0] = op->o_tmpalloc( sizeof(LDAPControl), op->o_tmpmemctx );
- if ( ber_flatten2( ber, &ctrls[0]->ldctl_value, 0 ) == -1 ) {
+ ctrl = op->o_tmpalloc( sizeof(LDAPControl), op->o_tmpmemctx );
+ if ( ber_flatten2( ber, &ctrl->ldctl_value, 0 ) == -1 ) {
goto done;
}
- ctrls[0]->ldctl_oid = LDAP_CONTROL_PAGEDRESULTS;
- ctrls[0]->ldctl_iscritical = 0;
+ ctrl->ldctl_oid = LDAP_CONTROL_PAGEDRESULTS;
+ ctrl->ldctl_iscritical = 0;
- slap_add_ctrls( op, rs, ctrls );
+ slap_add_ctrl( op, rs, ctrl );
rs->sr_err = LDAP_SUCCESS;
send_ldap_result( op, rs );
ID *lastid,
int tentries )
{
- LDAPControl *ctrls[2];
+ LDAPControl *ctrl;
BerElementBuffer berbuf;
BerElement *ber = (BerElement *)&berbuf;
PagedResultsCookie respcookie;
"send_paged_response: lastid=0x%08lx nentries=%d\n",
lastid ? *lastid : 0, rs->sr_nentries );
- ctrls[1] = NULL;
-
ber_init2( ber, NULL, LBER_USE_DER );
if ( lastid ) {
/* return size of 0 -- no estimate */
ber_printf( ber, "{iO}", 0, &cookie );
- ctrls[0] = op->o_tmpalloc( sizeof(LDAPControl), op->o_tmpmemctx );
- if ( ber_flatten2( ber, &ctrls[0]->ldctl_value, 0 ) == -1 ) {
+ ctrl = op->o_tmpalloc( sizeof(LDAPControl), op->o_tmpmemctx );
+ if ( ber_flatten2( ber, &ctrl->ldctl_value, 0 ) == -1 ) {
goto done;
}
- ctrls[0]->ldctl_oid = LDAP_CONTROL_PAGEDRESULTS;
- ctrls[0]->ldctl_iscritical = 0;
+ ctrl->ldctl_oid = LDAP_CONTROL_PAGEDRESULTS;
+ ctrl->ldctl_iscritical = 0;
- slap_add_ctrls( op, rs, ctrls );
+ slap_add_ctrl( op, rs, ctrl );
rs->sr_err = LDAP_SUCCESS;
send_ldap_result( op, rs );
int slap_add_ctrls(
Operation *op,
SlapReply *rs,
- LDAPControl **ctrls )
+ LDAPControl **ctrls,
+ int numctrls )
{
int i = 0, j;
LDAPControl **ctrlsp;
for ( ; rs->sr_ctrls[ i ]; i++ ) ;
}
- for ( j=0; ctrls[j]; j++ ) ;
+ if ( numctrls ) {
+ j = numctrls;
+ } else {
+ for ( j=0; ctrls[j]; j++ ) ;
+ numctrls = j;
+ }
ctrlsp = op->o_tmpalloc(( i+j+1 )*sizeof(LDAPControl *), op->o_tmpmemctx );
i = 0;
for ( ; rs->sr_ctrls[i]; i++ )
ctrlsp[i] = rs->sr_ctrls[i];
}
- for ( j=0; ctrls[j]; j++)
+ for ( j=0; j < numctrls; j++)
ctrlsp[i++] = ctrls[j];
ctrlsp[i] = NULL;
return i;
}
+int
+slap_add_ctrl(
+ Operation *op,
+ SlapReply *rs,
+ LDAPControl *ctrl )
+{
+ return slap_add_ctrls( op, rs, &ctrl, 1 );
+}
+
int slap_parse_ctrl(
Operation *op,
SlapReply *rs,
struct berval bv = BER_BVNULL;
int nDerefRes = 0, nDerefVals = 0, nAttrs = 0, nVals = 0;
struct berval ctrlval;
- LDAPControl *ctrl, *ctrlsp[2];
+ LDAPControl *ctrl;
AccessControlState acl_state = ACL_STATE_INIT;
static char dummy = '\0';
Entry *ebase;
ber_free_buf( ber );
- ctrlsp[0] = ctrl;
- ctrlsp[1] = NULL;
- slap_add_ctrls( op, rs, ctrlsp );
+ slap_add_ctrl( op, rs, ctrl );
rc = SLAP_CB_CONTINUE;
{
BerElementBuffer berbuf;
BerElement *ber = (BerElement *) &berbuf;
- LDAPControl c = { 0 }, *cp = NULL, *ctrls[2] = { NULL, NULL };
+ LDAPControl c = { 0 }, *ctrl;
int rc = -1;
BER_BVZERO( &c.ldctl_value );
goto fail;
}
- cp = op->o_tmpalloc( sizeof( LDAPControl ) + c.ldctl_value.bv_len, op->o_tmpmemctx );
- if ( !cp ) {
+ ctrl = op->o_tmpalloc( sizeof( LDAPControl ) + c.ldctl_value.bv_len, op->o_tmpmemctx );
+ if ( !ctrl ) {
goto fail;
}
- cp->ldctl_oid = (char *)ppolicy_account_ctrl_oid;
- cp->ldctl_iscritical = 0;
- cp->ldctl_value.bv_val = (char *)&cp[1];
- cp->ldctl_value.bv_len = c.ldctl_value.bv_len;
- AC_MEMCPY( cp->ldctl_value.bv_val, c.ldctl_value.bv_val, c.ldctl_value.bv_len );
+ ctrl->ldctl_oid = (char *)ppolicy_account_ctrl_oid;
+ ctrl->ldctl_iscritical = 0;
+ ctrl->ldctl_value.bv_val = (char *)&ctrl[1];
+ ctrl->ldctl_value.bv_len = c.ldctl_value.bv_len;
+ AC_MEMCPY( ctrl->ldctl_value.bv_val, c.ldctl_value.bv_val, c.ldctl_value.bv_len );
- /* TODO: ITS#10013 Use something like slap_add_ctrl when it exists */
- ctrls[ 0 ] = cp;
- slap_add_ctrls( op, rs, ctrls );
+ slap_add_ctrl( op, rs, ctrl );
rc = LDAP_SUCCESS;
fail:
char nowstr_usec[ LDAP_LUTIL_GENTIME_BUFSIZE+8 ];
struct berval timestamp, timestamp_usec;
BackendDB *be = op->o_bd;
- LDAPControl *ctrls[2] = { NULL, NULL };
+ LDAPControl *ctrl = NULL;
Entry *e;
ldap_pvt_thread_mutex_lock( &pi->pwdFailureTime_mutex );
if ( ppb->pErr == PP_accountLocked && !pi->use_lockout ) {
ppb->pErr = PP_noError;
}
- ctrls[0] = create_passcontrol( op, warn, ngut, ppb->pErr );
+ ctrl = create_passcontrol( op, warn, ngut, ppb->pErr );
} else if ( pi->send_netscape_controls ) {
if ( ppb->pErr != PP_noError || pwExpired ) {
- ctrls[0] = create_passexpiry( op, 1, 0 );
+ ctrl = create_passexpiry( op, 1, 0 );
} else if ( warn > 0 ) {
- ctrls[0] = create_passexpiry( op, 0, warn );
+ ctrl = create_passexpiry( op, 0, warn );
}
}
- if ( ctrls[0] ) {
- slap_add_ctrls( op, rs, ctrls );
+ if ( ctrl ) {
+ slap_add_ctrl( op, rs, ctrl );
op->o_callback->sc_cleanup = ppolicy_ctrls_cleanup;
}
out:
Debug( LDAP_DEBUG_TRACE,
"connection restricted to password changing only\n" );
if ( send_ctrl ) {
- LDAPControl *ctrls[2] = { NULL, NULL };
- ctrls[0] = create_passcontrol( op, -1, -1, PP_changeAfterReset );
- slap_add_ctrls( op, rs, ctrls );
+ LDAPControl *ctrl;
+ ctrl = create_passcontrol( op, -1, -1, PP_changeAfterReset );
+ slap_add_ctrl( op, rs, ctrl );
}
op->o_bd->bd_info = (BackendInfo *)on->on_info;
send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS,
char *txt = errmsg.bv_val;
op->o_bd->bd_info = (BackendInfo *)on->on_info;
if ( send_ctrl ) {
- LDAPControl *ctrls[2] = { NULL, NULL };
- ctrls[0] = create_passcontrol( op, -1, -1, pErr );
- slap_add_ctrls( op, rs, ctrls );
+ LDAPControl *ctrl;
+ ctrl = create_passcontrol( op, -1, -1, pErr );
+ slap_add_ctrl( op, rs, ctrl );
}
send_ldap_error( op, rs, rc, txt && txt[0] ? txt : "Password fails quality checking policy" );
if ( txt != errbuf ) {
struct berval newpw = BER_BVNULL, oldpw = BER_BVNULL,
*bv, cr[2];
LDAPPasswordPolicyError pErr = PP_noError;
- LDAPControl *ctrls[2] = { NULL, NULL };
+ LDAPControl *ctrl = NULL;
int is_pwdexop = 0, is_pwdadmin = 0;
int got_del_grace = 0, got_del_lock = 0, got_pw = 0, got_del_fail = 0,
got_del_success = 0;
op->o_bd->bd_info = (BackendInfo *)on->on_info;
be_entry_release_r( op, e );
if ( send_ctrl ) {
- ctrls[0] = create_passcontrol( op, -1, -1, pErr );
- slap_add_ctrls( op, rs, ctrls );
+ ctrl = create_passcontrol( op, -1, -1, pErr );
+ slap_add_ctrl( op, rs, ctrl );
if ( is_pwdexop ) {
/* Retain controls for the actual response */
rs->sr_flags &= ~REP_CTRLS_MUSTBEFREED;
Operation *op,
SlapReply *rs,
sort_op *so,
- LDAPControl **ctrlsp )
+ LDAPControl **ctrlp )
{
LDAPControl *ctrl;
BerElementBuffer berbuf;
ctrl->ldctl_value.bv_val = (char *)(ctrl+1);
ctrl->ldctl_value.bv_len = bv.bv_len;
AC_MEMCPY( ctrl->ldctl_value.bv_val, bv.bv_val, bv.bv_len );
- ctrlsp[0] = ctrl;
+ *ctrlp = ctrl;
} else {
- ctrlsp[0] = NULL;
+ *ctrlp = NULL;
rs->sr_err = LDAP_OTHER;
}
int i, j, dir, rc;
BackendDB *be;
Entry *e;
- LDAPControl *ctrls[2];
+ LDAPControl *ctrl;
rs->sr_attrs = op->ors_attrs;
if ( vc->vc_offset > so->so_nentries ) {
range_err:
so->so_vlv_rc = LDAP_VLV_RANGE_ERROR;
- pack_vlv_response_control( op, rs, so, ctrls );
- ctrls[1] = NULL;
- slap_add_ctrls( op, rs, ctrls );
+ pack_vlv_response_control( op, rs, so, &ctrl );
+ slap_add_ctrl( op, rs, ctrl );
rs->sr_err = LDAP_VLV_ERROR;
return;
}
mr->smr_syntax, mr, &vc->vc_value, &bv, op->o_tmpmemctx );
if ( rc ) {
so->so_vlv_rc = LDAP_INAPPROPRIATE_MATCHING;
- pack_vlv_response_control( op, rs, so, ctrls );
- ctrls[1] = NULL;
- slap_add_ctrls( op, rs, ctrls );
+ pack_vlv_response_control( op, rs, so, &ctrl );
+ slap_add_ctrl( op, rs, ctrl );
rs->sr_err = LDAP_VLV_ERROR;
return;
}
LDAPControl *ctrls[3];
int rc, i = 0;
- rc = pack_sss_response_control( op, rs, ctrls );
+ rc = pack_sss_response_control( op, rs, &ctrls[i] );
if ( rc == LDAP_SUCCESS ) {
i++;
rc = -1;
if ( so->so_paged > SLAP_CONTROL_IGNORED ) {
- rc = pack_pagedresult_response_control( op, rs, so, ctrls+1 );
+ rc = pack_pagedresult_response_control( op, rs, so, &ctrls[i] );
} else if ( so->so_vlv > SLAP_CONTROL_IGNORED ) {
- rc = pack_vlv_response_control( op, rs, so, ctrls+1 );
+ rc = pack_vlv_response_control( op, rs, so, &ctrls[i] );
}
if ( rc == LDAP_SUCCESS )
i++;
}
ctrls[i] = NULL;
- if ( ctrls[0] != NULL )
- slap_add_ctrls( op, rs, ctrls );
+ if ( i )
+ slap_add_ctrls( op, rs, ctrls, i );
send_ldap_result( op, rs );
if ( so->so_tree == NULL ) {
if ( op->o_ctrlflag[sss_cid] <= SLAP_CONTROL_IGNORED ) {
if ( op->o_ctrlflag[vlv_cid] > SLAP_CONTROL_IGNORED ) {
- LDAPControl *ctrls[2];
+ LDAPControl *ctrl;
so2.so_vcontext = 0;
so2.so_vlv_target = 0;
so2.so_nentries = 0;
so2.so_vlv_rc = LDAP_VLV_SSS_MISSING;
so2.so_vlv = op->o_ctrlflag[vlv_cid];
- rc = pack_vlv_response_control( op, rs, &so2, ctrls );
+ rc = pack_vlv_response_control( op, rs, &so2, &ctrl );
if ( rc == LDAP_SUCCESS ) {
- ctrls[1] = NULL;
- slap_add_ctrls( op, rs, ctrls );
+ slap_add_ctrl( op, rs, ctrl );
}
rs->sr_err = LDAP_VLV_ERROR;
rs->sr_text = "Sort control is required with VLV";
LDAP_SLAPD_F (int) slap_add_ctrls LDAP_P((
Operation *op,
SlapReply *rs,
- LDAPControl **ctrls ));
+ LDAPControl **ctrls,
+ int numctrls ));
+LDAP_SLAPD_F (int) slap_add_ctrl LDAP_P((
+ Operation *op,
+ SlapReply *rs,
+ LDAPControl *ctrl ));
LDAP_SLAPD_F (int) slap_parse_ctrl LDAP_P((
Operation *op,
SlapReply *rs,