Operation *op;
} AciSetCookie;
-char **aci_set_gather (void *cookie, char *name, struct berval *attr);
+BVarray aci_set_gather (void *cookie, char *name, struct berval *attr);
static int aci_match_set ( struct berval *subj, Backend *be,
Entry *e, Connection *conn, Operation *op, int setref );
Modifications *mlist
)
{
- int i;
+ struct berval *bv;
assert( be != NULL );
if ( mlist->sml_bvalues == NULL ) {
break;
}
- for ( i = 0; mlist->sml_bvalues[i] != NULL; i++ ) {
+ for ( bv = mlist->sml_bvalues; bv->bv_val != NULL; bv++ ) {
if ( ! access_allowed( be, conn, op, e,
- mlist->sml_desc, mlist->sml_bvalues[i], ACL_WRITE ) )
+ mlist->sml_desc, bv, ACL_WRITE ) )
{
return( 0 );
}
}
break;
}
- for ( i = 0; mlist->sml_bvalues[i] != NULL; i++ ) {
+ for ( bv = mlist->sml_bvalues; bv->bv_val != NULL; bv++ ) {
if ( ! access_allowed( be, conn, op, e,
- mlist->sml_desc, mlist->sml_bvalues[i], ACL_WRITE ) )
+ mlist->sml_desc, bv, ACL_WRITE ) )
{
return( 0 );
}
return(bv->bv_len);
}
-char **
+BVarray
aci_set_gather (void *cookie, char *name, struct berval *attr)
{
AciSetCookie *cp = cookie;
- struct berval **bvals = NULL;
- char **vals = NULL;
+ BVarray bvals = NULL;
struct berval bv, ndn;
int i;
if (slap_bv2ad(attr, &desc, &text) == LDAP_SUCCESS) {
backend_attribute(cp->be, NULL, NULL,
cp->e, &ndn, desc, &bvals);
- if (bvals != NULL) {
- for (i = 0; bvals[i] != NULL; i++) { }
- vals = ch_calloc(i + 1, sizeof(char *));
- if (vals != NULL) {
- while (--i >= 0) {
- vals[i] = bvals[i]->bv_val;
- bvals[i]->bv_val = NULL;
- }
- }
- ber_bvecfree(bvals);
- }
}
free(ndn.bv_val);
}
- return(vals);
+ return(bvals);
}
static int
int setref
)
{
- char *set = NULL;
+ struct berval set = { 0, NULL };
int rc = 0;
AciSetCookie cookie;
if (setref == 0) {
- set = aci_bvstrdup(subj);
+ ber_dupbv( &set, subj );
} else {
struct berval subjdn, ndn = { 0, NULL };
struct berval setat;
- struct berval **bvals;
+ BVarray bvals;
const char *text;
AttributeDescription *desc = NULL;
backend_attribute(be, NULL, NULL, e,
&ndn, desc, &bvals);
if ( bvals != NULL ) {
- if ( bvals[0] != NULL )
- set = ch_strdup(bvals[0]->bv_val);
- ber_bvecfree(bvals);
+ if ( bvals[0].bv_val != NULL ) {
+ int i;
+ set = bvals[0];
+ bvals[0].bv_val = NULL;
+ for (i=1;bvals[i].bv_val;i++);
+ bvals[0].bv_val = bvals[i-1].bv_val;
+ bvals[i-1].bv_val = NULL;
+ }
+ bvarray_free(bvals);
}
}
if (ndn.bv_val)
ch_free(subjdn.bv_val);
}
- if (set != NULL) {
+ if (set.bv_val != NULL) {
cookie.be = be;
cookie.e = e;
cookie.conn = conn;
cookie.op = op;
- rc = (set_filter(aci_set_gather, &cookie, set, op->o_ndn.bv_val, e->e_ndn, NULL) > 0);
- ch_free(set);
+ rc = (set_filter(aci_set_gather, &cookie, &set, op->o_ndn.bv_val, e->e_ndn, NULL) > 0);
+ ch_free(set.bv_val);
}
return(rc);
}
{
int rc;
- struct berval val;
- struct berval *vals[2];
+ struct berval vals[2];
- val.bv_val = b->a_group_oc->soc_oid;
- val.bv_len = strlen(val.bv_val);
- vals[0] = &val;
- vals[1] = NULL;
+ vals[0].bv_val = b->a_group_oc->soc_oid;
+ vals[0].bv_len = strlen(vals[0].bv_val);
+ vals[1].bv_val = NULL;
rc = oc_check_allowed( b->a_group_at->ad_type, vals, NULL );
ber_tag_t tag;
Entry *e;
Backend *be;
- LDAPModList *modlist = NULL;
- LDAPModList **modtail = &modlist;
- Modifications *mods = NULL;
+ Modifications *modlist = NULL;
+ Modifications **modtail = &modlist;
+ Modifications tmp;
const char *text;
int rc = LDAP_SUCCESS;
int manageDSAit;
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
tag = ber_next_element( ber, &len, last ) )
{
- LDAPModList *mod = (LDAPModList *) ch_malloc( sizeof(LDAPModList) );
- mod->ml_op = LDAP_MOD_ADD;
- mod->ml_next = NULL;
+ Modifications *mod;
- rc = ber_scanf( ber, "{a{V}}", &mod->ml_type, &mod->ml_bvalues );
+ rc = ber_scanf( ber, "{o{W}}", &tmp.sml_type, &tmp.sml_bvalues );
if ( rc == LBER_ERROR ) {
#ifdef NEW_LOGGING
send_ldap_disconnect( conn, op,
LDAP_PROTOCOL_ERROR, "decoding error" );
rc = -1;
- free( mod );
goto done;
}
- if ( mod->ml_bvalues == NULL ) {
+ if ( tmp.sml_bvalues == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
"do_add: conn %d no values for type %s\n",
- conn->c_connid, mod->ml_type ));
+ conn->c_connid, tmp.sml_type.bv_val ));
#else
Debug( LDAP_DEBUG_ANY, "no values for type %s\n",
- mod->ml_type, 0, 0 );
+ tmp.sml_type.bv_val, 0, 0 );
#endif
send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
NULL, "no values for attribute type", NULL, NULL );
- free( mod->ml_type );
- free( mod );
+ free( tmp.sml_type.bv_val );
goto done;
}
+ mod = (Modifications *) ch_malloc( sizeof(Modifications)
+ + tmp.sml_type.bv_len + 1);
+
+ mod->sml_op = LDAP_MOD_ADD;
+ mod->sml_next = NULL;
+ mod->sml_desc = NULL;
+ mod->sml_type.bv_val = (char *)(mod+1);
+ strcpy(mod->sml_type.bv_val, tmp.sml_type.bv_val);
+ mod->sml_type.bv_len = tmp.sml_type.bv_len;
+ mod->sml_bvalues = tmp.sml_bvalues;
*modtail = mod;
- modtail = &mod->ml_next;
+ modtail = &mod->sml_next;
}
if ( ber_scanf( ber, /*{*/ "}") == LBER_ERROR ) {
Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d ADD dn=\"%s\"\n",
op->o_connid, op->o_opid, e->e_dn, 0, 0 );
- if( e->e_ndn == NULL || *e->e_ndn == '\0' ) {
+ if( e->e_nname.bv_len == 0 ) {
/* protocolError may be a more appropriate error */
send_ldap_result( conn, op, rc = LDAP_ALREADY_EXISTS,
NULL, "root DSE already exists",
*/
be = select_backend( &e->e_nname, manageDSAit, 0 );
if ( be == NULL ) {
- struct berval **ref = referral_rewrite( default_referral,
+ BVarray ref = referral_rewrite( default_referral,
NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
NULL, NULL, ref ? ref : default_referral, NULL );
- ber_bvecfree( ref );
+ bvarray_free( ref );
goto done;
}
char textbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof textbuf;
- rc = slap_modlist2mods( modlist, update, &mods, &text,
+ rc = slap_mods_check( modlist, update, &text,
textbuf, textlen );
if( rc != LDAP_SUCCESS ) {
if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
global_lastmod == ON)) && !repl_user )
{
- Modifications **modstail;
- for( modstail = &mods;
- *modstail != NULL;
- modstail = &(*modstail)->sml_next )
+ for( modtail = &modlist;
+ *modtail != NULL;
+ modtail = &(*modtail)->sml_next )
{
- assert( (*modstail)->sml_op == LDAP_MOD_ADD );
- assert( (*modstail)->sml_desc != NULL );
+ assert( (*modtail)->sml_op == LDAP_MOD_ADD );
+ assert( (*modtail)->sml_desc != NULL );
}
- rc = slap_mods_opattrs( op, mods, modstail, &text,
+ rc = slap_mods_opattrs( op, modlist, modtail, &text,
textbuf, textlen );
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
}
}
- rc = slap_mods2entry( mods, &e, &text );
+ rc = slap_mods2entry( modlist, &e, &text );
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
NULL, text, NULL, NULL );
#ifndef SLAPD_MULTIMASTER
} else {
- struct berval **defref = be->be_update_refs
+ BVarray defref = be->be_update_refs
? be->be_update_refs : default_referral;
- struct berval **ref = referral_rewrite( defref,
+ BVarray ref = referral_rewrite( defref,
NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
ref ? ref : defref, NULL );
- ber_bvecfree( ref );
+ bvarray_free( ref );
#endif
}
} else {
free( dn.bv_val );
if( modlist != NULL ) {
- slap_modlist_free( modlist );
- }
- if( mods != NULL ) {
- slap_mods_free( mods );
+ slap_mods_free( modlist );
}
if( e != NULL ) {
entry_free( e );
#ifdef SLURPD_FRIENDLY
ber_len_t i,j;
- for( i=0; attr->a_vals[i]; i++ ) {
+ for( i=0; attr->a_vals[i].bv_val; i++ ) {
/* count them */
}
- for( j=0; mods->sml_bvalues[j]; j++ ) {
+ for( j=0; mods->sml_bvalues[j].bv_val; j++ ) {
/* count them */
}
j++; /* NULL */
attr->a_vals = ch_realloc( attr->a_vals,
- sizeof( struct berval * ) * (i+j) );
+ sizeof( struct berval ) * (i+j) );
/* should check for duplicates */
AC_MEMCPY( &attr->a_vals[i], mods->sml_bvalues,
- sizeof( struct berval * ) * j );
+ sizeof( struct berval ) * j );
/* trim the mods array */
ch_free( mods->sml_bvalues );
int
at_schema_info( Entry *e )
{
- struct berval val;
- struct berval *vals[2];
+ struct berval vals[2];
AttributeType *at;
AttributeDescription *ad_attributeTypes = slap_schema.si_ad_attributeTypes;
- vals[0] = &val;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
for ( at = attr_list; at; at = at->sat_next ) {
- if ( ldap_attributetype2bv( &at->sat_atype, &val ) == NULL ) {
+ if ( ldap_attributetype2bv( &at->sat_atype, vals ) == NULL ) {
return -1;
}
#if 0
Debug( LDAP_DEBUG_TRACE, "Merging at [%ld] %s\n",
- (long) val.bv_len, val.bv_val, 0 );
+ (long) vals[0].bv_len, vals[0].bv_val, 0 );
#endif
attr_merge( e, ad_attributeTypes, vals );
- ldap_memfree( val.bv_val );
+ ldap_memfree( vals[0].bv_val );
}
return 0;
}
void
attr_free( Attribute *a )
{
- ber_bvecfree( a->a_vals );
+ bvarray_free( a->a_vals );
free( a );
}
if( a->a_vals != NULL ) {
int i;
- for( i=0; a->a_vals[i] != NULL; i++ ) {
+ for( i=0; a->a_vals[i].bv_val != NULL; i++ ) {
/* EMPTY */ ;
}
- tmp->a_vals = ch_malloc((i+1) * sizeof(struct berval*));
+ tmp->a_vals = ch_malloc((i+1) * sizeof(struct berval));
- for( i=0; a->a_vals[i] != NULL; i++ ) {
- tmp->a_vals[i] = ber_bvdup( a->a_vals[i] );
-
- if( tmp->a_vals[i] == NULL ) break;
+ for( i=0; a->a_vals[i].bv_val != NULL; i++ ) {
+ ber_dupbv( &tmp->a_vals[i], &a->a_vals[i] );
+ if( tmp->a_vals[i].bv_val == NULL ) break;
}
- tmp->a_vals[i] = NULL;
+ tmp->a_vals[i].bv_val = NULL;
} else {
tmp->a_vals = NULL;
attr_merge(
Entry *e,
AttributeDescription *desc,
- struct berval **vals )
+ BVarray vals )
{
Attribute **a;
if ( p == NULL ) {
char *matched_dn = NULL;
- struct berval **refs;
+ BVarray refs;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
ch_free( matched_dn );
goto done;
if ( is_entry_referral( p ) ) {
/* parent is a referral, don't allow add */
char *matched_dn = ch_strdup( p->e_dn );
- struct berval **refs = is_entry_referral( p )
+ BVarray refs = is_entry_referral( p )
? get_entry_referrals( be, conn, op, p )
: NULL;
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
free( matched_dn );
goto done;
}
Entry *target,
struct berval *entry_ndn,
AttributeDescription *entry_at,
- struct berval ***vals )
+ BVarray *vals )
{
struct bdbinfo *li = (struct bdbinfo *) be->be_private;
Entry *e;
int i, j, rc;
Attribute *attr;
- struct berval **v;
+ BVarray v;
const char *entry_at_name = entry_at->ad_cname.bv_val;
#ifdef NEW_LOGGING
goto return_results;
}
- for ( i = 0; attr->a_vals[i] != NULL; i++ ) {
+ for ( i = 0; attr->a_vals[i].bv_val != NULL; i++ ) {
/* count them */
}
- v = (struct berval **) ch_malloc( sizeof(struct berval *) * (i+1) );
+ v = (BVarray) ch_malloc( sizeof(struct berval) * (i+1) );
- for ( i=0, j=0; attr->a_vals[i] != NULL; i++ ) {
+ for ( i=0, j=0; attr->a_vals[i].bv_val != NULL; i++ ) {
if( conn != NULL
&& op != NULL
&& access_allowed(be, conn, op, e, entry_at,
- attr->a_vals[i], ACL_READ) == 0)
+ &attr->a_vals[i], ACL_READ) == 0)
{
continue;
}
- v[j] = ber_bvdup( attr->a_vals[i] );
+ ber_dupbv( &v[j], &attr->a_vals[i] );
- if( v[j] != NULL ) j++;
+ if( v[j].bv_val != NULL ) j++;
}
if( j == 0 ) {
*vals = NULL;
rc = LDAP_INSUFFICIENT_ACCESS;
} else {
- v[j] = NULL;
+ v[j].bv_val = NULL;
+ v[j].bv_len = 0;
*vals = v;
rc = LDAP_SUCCESS;
}
/* get entry with reader lock */
if ( e == NULL ) {
char *matched_dn = NULL;
- struct berval **refs;
+ BVarray refs;
if( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
NULL, NULL, NULL, NULL );
}
- ber_bvecfree( refs );
+ bvarray_free( refs );
free( matched_dn );
return rc;
if ( is_entry_referral( e ) ) {
/* entry is a referral, don't allow bind */
- struct berval **refs = get_entry_referrals( be,
+ BVarray refs = get_entry_referrals( be,
conn, op, e );
Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
NULL, NULL, NULL, NULL );
}
- ber_bvecfree( refs );
+ bvarray_free( refs );
goto done;
}
if ( e == NULL ) {
char *matched_dn = NULL;
- struct berval **refs;
+ BVarray refs;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
free( matched_dn );
goto done;
if (!manageDSAit && is_entry_referral( e ) ) {
/* entry is a referral, don't allow add */
- struct berval **refs = get_entry_referrals( be,
+ BVarray refs = get_entry_referrals( be,
conn, op, e );
Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
goto done;
}
if ( e == NULL ) {
char *matched_dn = NULL;
- struct berval **refs;
+ BVarray refs;
Debug( LDAP_DEBUG_ARGS,
"<=- bdb_delete: no such object %s\n",
send_ldap_result( conn, op, LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
free( matched_dn );
rc = -1;
if ( !manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
- struct berval **refs = get_entry_referrals( be,
+ BVarray refs = get_entry_referrals( be,
conn, op, e );
Debug( LDAP_DEBUG_TRACE,
send_ldap_result( conn, op, LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
rc = 1;
goto done;
struct berval **rspdata,
LDAPControl *** rspctrls,
const char** text,
- struct berval *** refs
+ BVarray *refs
)
{
int i;
DB_TXN *txn,
char *dbname,
struct berval *atname,
- struct berval **vals,
+ BVarray vals,
ID id,
int op,
slap_mask_t mask )
DB_TXN *txn,
AttributeType *type,
struct berval *lang,
- struct berval **vals,
+ BVarray vals,
ID id,
int op,
char ** dbnamep,
Backend *be,
DB_TXN *txn,
AttributeDescription *desc,
- struct berval **vals,
+ BVarray vals,
ID id,
int op )
{
/* acquire and lock entry */
if ( e == NULL ) {
char* matched_dn = NULL;
- struct berval **refs;
+ BVarray refs;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
free( matched_dn );
return rc;
if ( !manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
- struct berval **refs = get_entry_referrals( be,
+ BVarray refs = get_entry_referrals( be,
conn, op, e );
Debug( LDAP_DEBUG_TRACE,
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
goto done;
}
return LDAP_INAPPROPRIATE_MATCHING;
}
- for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+ for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
int rc;
int j;
const char *text = NULL;
rc = value_normalize( mod->sm_desc,
SLAP_MR_EQUALITY,
- mod->sm_bvalues[i],
+ &mod->sm_bvalues[i],
&asserted,
&text );
if( rc != LDAP_SUCCESS ) return rc;
- for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_VALUE_SYNTAX_MATCH,
- a->a_vals[j], &asserted, &text );
+ &a->a_vals[j], &asserted, &text );
if( rc == LDAP_SUCCESS && match == 0 ) {
free( asserted.bv_val );
/* no - add them */
if( attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 ) {
- /* this should return result return of attr_merge */
+ /* this should return result of attr_merge */
return LDAP_OTHER;
}
}
/* find each value to delete */
- for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+ for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
int rc;
const char *text = NULL;
rc = value_normalize( mod->sm_desc,
SLAP_MR_EQUALITY,
- mod->sm_bvalues[i],
+ &mod->sm_bvalues[i],
&asserted,
&text );
if( rc != LDAP_SUCCESS ) return rc;
found = 0;
- for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_VALUE_SYNTAX_MATCH,
- a->a_vals[j], &asserted, &text );
+ &a->a_vals[j], &asserted, &text );
if( rc == LDAP_SUCCESS && match != 0 ) {
continue;
found = 1;
/* delete it */
- ber_bvfree( a->a_vals[j] );
- for ( k = j + 1; a->a_vals[k] != NULL; k++ ) {
+ free( a->a_vals[j].bv_val );
+ for ( k = j + 1; a->a_vals[k].bv_val != NULL; k++ ) {
a->a_vals[k - 1] = a->a_vals[k];
}
- a->a_vals[k - 1] = NULL;
+ a->a_vals[k - 1].bv_val = NULL;
+ a->a_vals[k - 1].bv_len = 0;
break;
}
}
/* if no values remain, delete the entire attribute */
- if ( a->a_vals[0] == NULL ) {
+ if ( a->a_vals[0].bv_val == NULL ) {
Debug( LDAP_DEBUG_TRACE,
"bdb_modify_delete: removing entire attribute %s\n",
desc, 0, 0 );
if ( e == NULL ) {
char* matched_dn = NULL;
- struct berval** refs;
+ BVarray refs;
if( matched != NULL ) {
matched_dn = strdup( matched->e_dn );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
free( matched_dn );
goto done;
if (!manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
- struct berval **refs = get_entry_referrals( be,
+ BVarray refs = get_entry_referrals( be,
conn, op, e );
Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: entry %s is referral\n",
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
goto done;
}
/* Apply modification */
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
- + 2 * sizeof( struct berval * ) );
+ + 2 * sizeof( struct berval ) );
mod_tmp->sml_desc = desc;
- mod_tmp->sml_bvalues = ( struct berval ** )( mod_tmp + 1 );
- mod_tmp->sml_bvalues[ 0 ] = &new_rdn[0][ a_cnt ]->la_value;
- mod_tmp->sml_bvalues[ 1 ] = NULL;
+ mod_tmp->sml_bvalues = ( BVarray )( mod_tmp + 1 );
+ mod_tmp->sml_bvalues[ 0 ] = new_rdn[0][ a_cnt ]->la_value;
+ mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
mod_tmp->sml_op = SLAP_MOD_SOFTADD;
mod_tmp->sml_next = mod;
mod = mod_tmp;
/* Apply modification */
mod_tmp = ( Modifications * )ch_malloc( sizeof( Modifications )
- + 2 * sizeof ( struct berval * ) );
+ + 2 * sizeof ( struct berval ) );
mod_tmp->sml_desc = desc;
- mod_tmp->sml_bvalues = ( struct berval ** )(mod_tmp+1);
- mod_tmp->sml_bvalues[ 0 ] = &old_rdn[0][ d_cnt ]->la_value;
- mod_tmp->sml_bvalues[ 1 ] = NULL;
+ mod_tmp->sml_bvalues = ( BVarray )(mod_tmp+1);
+ mod_tmp->sml_bvalues[ 0 ] = old_rdn[0][ d_cnt ]->la_value;
+ mod_tmp->sml_bvalues[ 1 ].bv_val = NULL;
mod_tmp->sml_op = LDAP_MOD_DELETE;
mod_tmp->sml_next = mod;
mod = mod_tmp;
struct berval **rspdata,
LDAPControl *** rspctrls,
const char **text,
- struct berval *** refs )
+ BVarray *refs )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
int rc;
Entry *e = NULL;
- struct berval *hash = NULL;
+ struct berval hash = { 0, NULL };
DB_TXN *ltid = NULL;
struct bdb_op_info opinfo;
char textbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof textbuf;
- struct berval *id = NULL;
- struct berval *new = NULL;
+ struct berval id = { 0, NULL };
+ struct berval new = { 0, NULL };
struct berval *dn;
&id, NULL, &new, text );
Debug( LDAP_DEBUG_ARGS, "==> bdb_exop_passwd: \"%s\"\n",
- id ? id->bv_val : "", 0, 0 );
+ id.bv_val ? id.bv_val : "", 0, 0 );
if( rc != LDAP_SUCCESS ) {
goto done;
}
- if( new == NULL || new->bv_len == 0 ) {
- new = slap_passwd_generate();
+ if( new.bv_len == 0 ) {
+ slap_passwd_generate(&new);
- if( new == NULL || new->bv_len == 0 ) {
+ if( new.bv_len == 0 ) {
*text = "password generation failed.";
rc = LDAP_OTHER;
goto done;
}
- *rspdata = slap_passwd_return( new );
+ *rspdata = slap_passwd_return( &new );
}
- hash = slap_passwd_hash( new );
+ slap_passwd_hash( &new, &hash );
- if( hash == NULL || hash->bv_len == 0 ) {
+ if( hash.bv_len == 0 ) {
*text = "password hash failed";
rc = LDAP_OTHER;
goto done;
}
- dn = id ? id : &op->o_dn;
+ dn = id.bv_val ? &id : &op->o_dn;
Debug( LDAP_DEBUG_TRACE, "bdb_exop_passwd: \"%s\"%s\n",
- dn->bv_val, id ? " (proxy)" : "", 0 );
+ dn->bv_val, id.bv_val ? " (proxy)" : "", 0 );
if( dn->bv_len == 0 ) {
*text = "No password is associated with the Root DSE";
{
Modifications ml;
- struct berval *vals[2];
+ struct berval vals[2];
vals[0] = hash;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
ml.sml_desc = slap_schema.si_ad_userPassword;
ml.sml_bvalues = vals;
bdb_entry_return( be, e );
}
- if( id != NULL ) {
- ber_bvfree( id );
+ if( id.bv_val != NULL ) {
+ free( id.bv_val );
}
- if( new != NULL ) {
- ber_bvfree( new );
+ if( new.bv_val != NULL ) {
+ free( new.bv_val );
}
- if( hash != NULL ) {
- ber_bvfree( hash );
+ if( hash.bv_val != NULL ) {
+ free( hash.bv_val );
}
if( ltid != NULL ) {
Backend *be,
DB_TXN *txn,
AttributeDescription *desc,
- struct berval **vals,
+ BVarray vals,
ID id,
int op ));
if ( e == NULL ) {
char *matched_dn = NULL;
- struct berval **refs = NULL;
+ BVarray refs = NULL;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
/* send referrals */
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
} else if ( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc, matched_dn,
matched_dn ? "bad referral object" : NULL,
if ( is_entry_referral( e ) ) {
/* entry is a referral */
- struct berval **refs = get_entry_referrals( be,
- conn, op, e );
- struct berval **rrefs = referral_rewrite(
+ BVarray refs = get_entry_referrals( be, conn, op, e );
+ BVarray rrefs = referral_rewrite(
refs, &e->e_name, dn, LDAP_SCOPE_DEFAULT );
Debug( LDAP_DEBUG_TRACE,
if( rrefs != NULL ) {
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
e->e_dn, NULL, rrefs, NULL );
- ber_bvecfree( rrefs );
+ bvarray_free( rrefs );
} else {
send_ldap_result( conn, op, rc = LDAP_OTHER, e->e_dn,
"bad referral object", NULL, NULL );
}
- ber_bvecfree( refs );
+ bvarray_free( refs );
}
bdb_entry_return( be, e );
int slimit,
int tlimit,
Filter *filter,
- const char *filterstr,
+ struct berval *filterstr,
AttributeName *attrs,
int attrsonly )
{
ID id, cursor;
ID candidates[BDB_IDL_UM_SIZE];
Entry *e = NULL;
- struct berval **v2refs = NULL;
+ BVarray v2refs = NULL;
Entry *matched = NULL;
struct berval realbase = { 0, NULL };
int nentries = 0;
if ( e == NULL ) {
struct berval *matched_dn = NULL;
- struct berval **refs = NULL;
+ BVarray refs = NULL;
if ( matched != NULL ) {
- struct berval **erefs;
+ BVarray erefs;
matched_dn = ber_bvdup( &matched->e_name );
erefs = is_entry_referral( matched )
if( erefs ) {
refs = referral_rewrite( erefs, matched_dn,
base, scope );
- ber_bvecfree( erefs );
+ bvarray_free( erefs );
}
} else {
send_ldap_result( conn, op, rc=LDAP_REFERRAL ,
matched_dn ? matched_dn->bv_val : NULL, text, refs, NULL );
- if ( refs ) ber_bvecfree( refs );
+ if ( refs ) bvarray_free( refs );
if ( matched_dn ) ber_bvfree( matched_dn );
return rc;
}
if (!manageDSAit && e != &slap_entry_root && is_entry_referral( e ) ) {
/* entry is a referral, don't allow add */
struct berval *matched_dn = ber_bvdup( &e->e_name );
- struct berval **erefs = get_entry_referrals( be,
- conn, op, e );
- struct berval **refs = NULL;
+ BVarray erefs = get_entry_referrals( be, conn, op, e );
+ BVarray refs = NULL;
bdb_entry_return( be, e );
e = NULL;
if( erefs ) {
refs = referral_rewrite( erefs, matched_dn,
base, scope );
- ber_bvecfree( erefs );
+ bvarray_free( erefs );
}
Debug( LDAP_DEBUG_TRACE, "bdb_search: entry is referral\n",
refs ? NULL : "bad referral object",
refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
ber_bvfree( matched_dn );
return 1;
}
if ( !manageDSAit && scope != LDAP_SCOPE_BASE &&
is_entry_referral( e ) )
{
- struct berval **erefs = get_entry_referrals(
+ BVarray erefs = get_entry_referrals(
be, conn, op, e );
- struct berval **refs = referral_rewrite( erefs,
+ BVarray refs = referral_rewrite( erefs,
&e->e_name, NULL,
scope == LDAP_SCOPE_SUBTREE
? LDAP_SCOPE_SUBTREE
send_search_reference( be, conn, op,
e, refs, NULL, &v2refs );
- ber_bvecfree( refs );
+ bvarray_free( refs );
goto loop_continue;
}
rc = 0;
done:
- ber_bvecfree( v2refs );
+ if( v2refs ) bvarray_free( v2refs );
if( realbase.bv_val ) ch_free( realbase.bv_val );
return rc;
{
struct ldapinfo *li = (struct ldapinfo *) be->be_private;
struct ldapconn *lc;
- int i;
+ int i, j;
Attribute *a;
LDAPMod **attrs;
- char *mapped;
+ struct berval mapped;
struct berval mdn = { 0, NULL };
#ifdef NEW_LOGGING
}
#endif
- mapped = ldap_back_map(&li->at_map, a->a_desc->ad_cname.bv_val, 0);
- if (mapped == NULL) {
+ ldap_back_map(&li->at_map, &a->a_desc->ad_cname, &mapped, 0);
+ if (mapped.bv_val == NULL) {
continue;
}
}
attrs[i]->mod_op = LDAP_MOD_BVALUES;
- attrs[i]->mod_type = mapped;
+ attrs[i]->mod_type = mapped.bv_val;
#ifdef ENABLE_REWRITE
/*
}
#endif /* ENABLE_REWRITE */
- attrs[i]->mod_vals.modv_bvals = a->a_vals;
+ for (j=0; a->a_vals[j].bv_val; j++);
+ attrs[i]->mod_vals.modv_bvals = ch_malloc((j+1)*sizeof(struct berval *));
+ for (j=0; a->a_vals[j].bv_val; j++)
+ attrs[i]->mod_vals.modv_bvals[j] = &a->a_vals[j];
i++;
}
attrs[i] = NULL;
ldap_add_s(lc->ld, mdn.bv_val, attrs);
- for (--i; i>= 0; --i)
+ for (--i; i>= 0; --i) {
+ free(attrs[i]->mod_vals.modv_bvals);
free(attrs[i]);
+ }
free(attrs);
if ( mdn.bv_val != e->e_dn ) {
free( mdn.bv_val );
Entry *target,
struct berval *ndn,
AttributeDescription *entry_at,
- struct berval ***vals
+ BVarray *vals
)
{
struct ldapinfo *li = (struct ldapinfo *) be->be_private;
int rc = 1, i, j, count, is_oc;
Attribute *attr;
- struct berval **abv, **v;
- char **vs, *mapped;
+ BVarray abv, v;
+ struct berval mapped;
+ char **vs;
LDAPMessage *result, *e;
char *gattr[2];
LDAP *ld;
if ((attr = attr_find(target->e_attrs, entry_at)) == NULL)
return(1);
- for ( count = 0; attr->a_vals[count] != NULL; count++ ) { }
- v = (struct berval **) ch_calloc( (count + 1), sizeof(struct berval *) );
+ for ( count = 0; attr->a_vals[count].bv_val != NULL; count++ ) { }
+ v = (BVarray) ch_calloc( (count + 1), sizeof(struct berval) );
if (v != NULL) {
for ( j = 0, abv = attr->a_vals; --count >= 0; abv++ ) {
- if ( (*abv)->bv_len > 0 ) {
- v[j] = ber_bvdup( *abv );
- if( v[j] == NULL )
+ if ( abv->bv_len > 0 ) {
+ ber_dupbv( &v[j], abv );
+ if( v[j].bv_val == NULL )
break;
}
}
- v[j] = NULL;
+ v[j].bv_val = NULL;
*vals = v;
rc = 0;
}
} else {
- mapped = ldap_back_map(&li->at_map, entry_at->ad_cname.bv_val, 0);
- if (mapped == NULL)
+ ldap_back_map(&li->at_map, &entry_at->ad_cname, &mapped, 0);
+ if (mapped.bv_val == NULL)
return(1);
if (ldap_initialize(&ld, li->url) != LDAP_SUCCESS) {
}
if (ldap_bind_s(ld, li->binddn, li->bindpw, LDAP_AUTH_SIMPLE) == LDAP_SUCCESS) {
- gattr[0] = mapped;
+ gattr[0] = mapped.bv_val;
gattr[1] = NULL;
if (ldap_search_ext_s(ld, ndn->bv_val, LDAP_SCOPE_BASE, "(objectclass=*)",
gattr, 0, NULL, NULL, LDAP_NO_LIMIT,
LDAP_NO_LIMIT, &result) == LDAP_SUCCESS)
{
if ((e = ldap_first_entry(ld, result)) != NULL) {
- vs = ldap_get_values(ld, e, mapped);
+ vs = ldap_get_values(ld, e, mapped.bv_val);
if (vs != NULL) {
for ( count = 0; vs[count] != NULL; count++ ) { }
- v = (struct berval **) ch_calloc( (count + 1), sizeof(struct berval *) );
+ v = (BVarray) ch_calloc( (count + 1), sizeof(struct berval) );
if (v == NULL) {
ldap_value_free(vs);
} else {
- is_oc = (strcasecmp("objectclass", mapped) == 0);
+ is_oc = (strcasecmp("objectclass", mapped.bv_val) == 0);
for ( i = 0, j = 0; i < count; i++) {
+ ber_str2bv(vs[i], 0, 0, &v[j] );
if (!is_oc) {
- v[j] = ber_bvstr( vs[i] );
- if( v[j] == NULL )
+ if( v[j].bv_val == NULL )
ch_free(vs[i]);
else
j++;
} else {
- mapped = ldap_back_map(&li->oc_map, vs[i], 1);
- if (mapped) {
- mapped = ch_strdup( mapped );
- if (mapped) {
- v[j] = ber_bvstr( mapped );
- if (v[j])
- j++;
- }
+ ldap_back_map(&li->oc_map, &v[j], &mapped, 1);
+ if (mapped.bv_val) {
+ ber_dupbv( &v[j], &mapped );
+ if (v[j].bv_val)
+ j++;
}
ch_free(vs[i]);
}
}
- v[j] = NULL;
+ v[j].bv_val = NULL;
*vals = v;
rc = 0;
ch_free(vs);
};
struct ldapmapping {
- char *src;
- char *dst;
+ struct berval src;
+ struct berval dst;
};
struct ldapinfo {
int mapping_cmp (const void *, const void *);
int mapping_dup (void *, void *);
-char *ldap_back_map ( struct ldapmap *map, char *s, int remap );
+void ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *m,
+ int remap );
char *
ldap_back_map_filter(
struct ldapmap *at_map,
struct ldapmap *oc_map,
- char *f,
+ struct berval *f,
int remap
);
char **
{
struct ldapinfo *li = (struct ldapinfo *) be->be_private;
struct ldapconn *lc;
- char *mapped_oc, *mapped_at;
+ struct berval mapped_oc, mapped_at;
struct berval mdn = { 0, NULL };
lc = ldap_back_getconn(li, conn, op);
}
#endif /* !ENABLE_REWRITE */
- mapped_oc = ldap_back_map(&li->oc_map, ava->aa_desc->ad_cname.bv_val, 0);
- if (mapped_oc == NULL)
+ ldap_back_map(&li->oc_map, &ava->aa_desc->ad_cname, &mapped_oc, 0);
+ if (mapped_oc.bv_val == NULL)
return( -1 );
- mapped_at = ldap_back_map(&li->at_map, ava->aa_value.bv_val, 0);
- if (mapped_at == NULL)
+ ldap_back_map(&li->at_map, &ava->aa_value, &mapped_at, 0);
+ if (mapped_at.bv_val == NULL)
return( -1 );
- ldap_compare_s( lc->ld, mdn.bv_val, mapped_oc, mapped_at );
+ ldap_compare_s( lc->ld, mdn.bv_val, mapped_oc.bv_val, mapped_at.bv_val );
if ( mdn.bv_val != dn->bv_val ) {
free( mdn.bv_val );
fname, lineno );
return( 1 );
}
- mapping->src = ch_strdup(src);
- mapping->dst = ch_strdup(dst);
+ ber_str2bv( src, 0, 1, &mapping->src );
+ ber_str2bv( dst, 0, 1, &mapping->dst );
if ( *dst != 0 ) {
mapping[1].src = mapping->dst;
mapping[1].dst = mapping->src;
{
struct ldapmapping *map1 = (struct ldapmapping *)c1;
struct ldapmapping *map2 = (struct ldapmapping *)c2;
-
- return ( strcasecmp(map1->src, map2->src) );
+ int rc = map1->src.bv_len - map2->src.bv_len;
+ if (rc) return rc;
+ return ( strcasecmp(map1->src.bv_val, map2->src.bv_val) );
}
int
struct ldapmapping *map1 = (struct ldapmapping *)c1;
struct ldapmapping *map2 = (struct ldapmapping *)c2;
- return( ( strcasecmp(map1->src, map2->src) == 0 ) ? -1 : 0 );
+ return( ( strcasecmp(map1->src.bv_val, map2->src.bv_val) == 0 ) ? -1 : 0 );
}
-char *
-ldap_back_map ( struct ldapmap *map, char *s, int remap )
+void
+ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *bv,
+ int remap )
{
Avlnode *tree;
struct ldapmapping *mapping, fmapping;
else
tree = map->map;
- fmapping.src = s;
+ bv->bv_len = 0;
+ bv->bv_val = NULL;
+ fmapping.src = *s;
mapping = (struct ldapmapping *)avl_find( tree, (caddr_t)&fmapping, mapping_cmp );
if (mapping != NULL) {
- if ( *mapping->dst == 0 )
- return(NULL);
- return(mapping->dst);
+ if ( mapping->dst.bv_val )
+ *bv = mapping->dst;
+ return;
}
- if (map->drop_missing)
- return(NULL);
+ if (!map->drop_missing)
+ *bv = *s;
- return(s);
+ return;
}
char *
ldap_back_map_filter(
struct ldapmap *at_map,
struct ldapmap *oc_map,
- char *f,
+ struct berval *f,
int remap
)
{
- char *nf, *m, *p, *q, *s, c;
+ char *nf, *p, *q, *s, c;
int len, extra, plen, in_quote;
+ struct berval m, tmp;
if (f == NULL)
return(NULL);
- len = strlen(f);
+ len = f->bv_len;
extra = len;
len *= 2;
nf = ch_malloc( len + 1 );
s = nf;
q = NULL;
in_quote = 0;
- for (p = f; (c = *p); p++) {
+ for (p = f->bv_val; (c = *p); p++) {
if (c == '"') {
in_quote = !in_quote;
if (q != NULL) {
} else {
if (q != NULL) {
*p = 0;
- m = ldap_back_map(at_map, q, remap);
- if (m == NULL)
- m = ldap_back_map(oc_map, q, remap);
- if (m == NULL) {
- m = q;
+ tmp.bv_len = p - q;
+ tmp.bv_val = q;
+ ldap_back_map(at_map, &tmp, &m, remap);
+ if (m.bv_val == NULL)
+ ldap_back_map(oc_map, &tmp, &m, remap);
+ if (m.bv_val == NULL) {
+ m = tmp;
}
extra += p - q;
- plen = strlen(m);
+ plen = m.bv_len;
extra -= plen;
if (extra < 0) {
while (extra < 0) {
}
s += (long)nf;
}
- memcpy(s, m, plen);
+ memcpy(s, m.bv_val, plen);
s += plen;
*p = c;
q = NULL;
)
{
int i;
- char *mapped, **na;
+ char **na;
AttributeName *an;
+ struct berval mapped;
if (a == NULL)
return(NULL);
return(NULL);
for (i = 0, an=a; an; an=an->an_next) {
- mapped = ldap_back_map(at_map, an->an_name.bv_val, remap);
- if (mapped != NULL) {
- na[i] = mapped;
+ ldap_back_map(at_map, &an->an_name, &mapped, remap);
+ if (mapped.bv_val != NULL) {
+ na[i] = mapped.bv_val;
i++;
}
}
struct berval mop_ndn = { 0, NULL }, mgr_ndn = { 0, NULL };
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
- char *group_oc_name = NULL;
- char *group_at_name = group_at->ad_cname.bv_val;
+ struct berval group_oc_name = {0, NULL};
+ struct berval group_at_name = group_at->ad_cname;
if( group_oc->soc_names && group_oc->soc_names[0] ) {
- group_oc_name = group_oc->soc_names[0];
+ group_oc_name.bv_val = group_oc->soc_names[0];
} else {
- group_oc_name = group_oc->soc_oid;
+ group_oc_name.bv_val = group_oc->soc_oid;
}
+ if (group_oc_name.bv_val)
+ group_oc_name.bv_len = strlen(group_oc_name.bv_val);
if (target != NULL && target->e_nname.bv_len == gr_ndn->bv_len &&
strcmp(target->e_nname.bv_val, gr_ndn->bv_val) == 0) {
}
#endif /* !ENABLE_REWRITE */
- group_oc_name = ldap_back_map(&li->oc_map, group_oc_name, 0);
- if (group_oc_name == NULL)
+ ldap_back_map(&li->oc_map, &group_oc_name, &group_oc_name, 0);
+ if (group_oc_name.bv_val == NULL)
goto cleanup;
- group_at_name = ldap_back_map(&li->at_map, group_at_name, 0);
- if (group_at_name == NULL)
+ ldap_back_map(&li->at_map, &group_at_name, &group_at_name, 0);
+ if (group_at_name.bv_val == NULL)
goto cleanup;
filter = ch_malloc(sizeof("(&(objectclass=)(=))")
- + strlen(group_oc_name)
- + strlen(group_at_name)
+ + group_oc_name.bv_len
+ + group_at_name.bv_len
+ mop_ndn.bv_len + 1);
if (filter == NULL)
goto cleanup;
}
ptr = slap_strcopy(filter, "(&(objectclass=");
- ptr = slap_strcopy(ptr, group_oc_name);
+ ptr = slap_strcopy(ptr, group_oc_name.bv_val);
ptr = slap_strcopy(ptr, ")(");
- ptr = slap_strcopy(ptr, group_at_name);
+ ptr = slap_strcopy(ptr, group_at_name.bv_val);
ptr = slap_strcopy(ptr, "=");
ptr = slap_strcopy(ptr, mop_ndn.bv_val);
strcpy(ptr, "))");
mapping = (struct ldapmapping *)ch_calloc( 2, sizeof(struct ldapmapping) );
if ( mapping != NULL ) {
- mapping->src = ch_strdup("objectclass");
- mapping->dst = ch_strdup("objectclass");
+ ber_str2bv( "objectclass", sizeof("objectclass")-1, 1, &mapping->src);
+ ber_dupbv( &mapping->dst, &mapping->src );
mapping[1].src = mapping->src;
mapping[1].dst = mapping->dst;
void
mapping_free ( struct ldapmapping *mapping )
{
- ch_free( mapping->src );
- ch_free( mapping->dst );
+ ch_free( mapping->src.bv_val );
+ ch_free( mapping->dst.bv_val );
ch_free( mapping );
}
LDAPMod **modv = NULL;
LDAPMod *mods;
Modifications *ml;
- int i;
- char *mapped;
+ int i, j;
+ struct berval mapped;
struct berval mdn = { 0, NULL };
lc = ldap_back_getconn(li, conn, op);
}
for (i=0, ml=modlist; ml; ml=ml->sml_next) {
- mapped = ldap_back_map(&li->at_map, ml->sml_desc->ad_cname.bv_val, 0);
- if (mapped == NULL) {
+ ldap_back_map(&li->at_map, &ml->sml_desc->ad_cname, &mapped, 0);
+ if (mapped.bv_val == NULL) {
continue;
}
modv[i] = &mods[i];
mods[i].mod_op = ml->sml_op | LDAP_MOD_BVALUES;
- mods[i].mod_type = mapped;
+ mods[i].mod_type = mapped.bv_val;
#ifdef ENABLE_REWRITE
/*
}
#endif /* ENABLE_REWRITE */
- mods[i].mod_bvalues = ml->sml_bvalues;
+ for (j = 0; ml->sml_bvalues[j].bv_val; j++);
+ mods[i].mod_bvalues = (struct berval **)ch_malloc((j+1) *
+ sizeof(struct berval *));
+ for (j = 0; ml->sml_bvalues[j].bv_val; j++)
+ mods[i].mod_bvalues[j] = &ml->sml_bvalues[j];
+ mods[i].mod_bvalues[j] = NULL;
i++;
}
modv[i] = 0;
#ifdef ENABLE_REWRITE
}
#endif /* ENABLE_REWRITE */
+ for (i=0; modv[i]; i++)
+ free(modv[i]->mod_bvalues);
free(mods);
free(modv);
return( ldap_back_op_result( lc, op ));
#include "slap.h"
#include "back-ldap.h"
+#include "../../../libraries/libldap/ldap-int.h"
static void ldap_send_entry( Backend *be, Operation *op, struct ldapconn *lc,
LDAPMessage *e, AttributeName *attrs, int attrsonly );
int slimit,
int tlimit,
Filter *filter,
- const char *filterstr,
+ struct berval *filterstr,
AttributeName *attrs,
int attrsonly
)
char *mapped_filter = NULL, **mapped_attrs = NULL;
struct berval mbase;
#ifdef ENABLE_REWRITE
- char *mfilter = NULL, *mmatch = NULL;
+ char *mmatch = NULL;
+ struct berval mfilter = { 0, NULL };
#endif /* ENABLE_REWRITE */
struct slap_limits_set *limit = NULL;
int isroot = 0;
* Rewrite the search filter, if required
*/
switch ( rewrite_session( li->rwinfo, "searchFilter",
- filterstr, conn, &mfilter ) ) {
+ filterstr->bv_val, conn, &mfilter.bv_val ) ) {
case REWRITE_REGEXEC_OK:
- if ( mfilter == NULL || mfilter[0] == '\0') {
- if ( mfilter != NULL ) {
- free( mfilter );
+ if ( mfilter.bv_val == NULL || mfilter.bv_val[0] == '\0') {
+ if ( mfilter.bv_val != NULL ) {
+ free( mfilter.bv_val );
}
- mfilter = ( char * )filterstr;
+ mfilter = *filterstr;
}
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
"[rw] searchFilter: \"%s\" -> \"%s\"\n",
- filterstr, mfilter ));
+ filterstr->bv_val, mfilter.bv_val ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> searchFilter: \"%s\" -> \"%s\"\n%s",
- filterstr, mfilter, "" );
+ filterstr->bv_val, mfilter.bv_val, "" );
#endif /* !NEW_LOGGING */
break;
mapped_filter = ldap_back_map_filter(&li->at_map, &li->oc_map,
#ifdef ENABLE_REWRITE
- (char *)mfilter,
+ &mfilter,
#else /* !ENABLE_REWRITE */
- (char *)filterstr,
+ filterstr,
#endif /* !ENABLE_REWRITE */
0);
if ( mapped_filter == NULL ) {
#ifdef ENABLE_REWRITE
- mapped_filter = (char *)mfilter;
+ mapped_filter = mfilter.bv_val;
#else /* !ENABLE_REWRITE */
- mapped_filter = (char *)filterstr;
+ mapped_filter = filterstr->bv_val;
#endif /* !ENABLE_REWRITE */
}
free( mapped_attrs );
}
#ifdef ENABLE_REWRITE
- if ( mapped_filter != mfilter ) {
+ if ( mapped_filter != mfilter.bv_val ) {
free( mapped_filter );
}
- if ( mfilter != filterstr ) {
- free( mfilter );
+ if ( mfilter.bv_val != filterstr.bv_val ) {
+ free( mfilter.bv_val );
}
#else /* !ENABLE_REWRITE */
- if ( mapped_filter != filterstr ) {
+ if ( mapped_filter != filterstr->bv_val ) {
free( mapped_filter );
}
#endif /* !ENABLE_REWRITE */
)
{
struct ldapinfo *li = (struct ldapinfo *) be->be_private;
- char *a, *mapped;
+ struct berval a, mapped;
Entry ent;
- BerElement *ber = NULL;
+ BerElement ber = *e->lm_ber;
Attribute *attr, **attrp;
- struct berval *dummy = NULL;
+ struct berval dummy = { 0, NULL };
struct berval *bv, bdn;
const char *text;
-#ifdef ENABLE_REWRITE
- char *dn;
-
- dn = ldap_get_dn(lc->ld, e);
- if ( dn == NULL ) {
+ if ( ber_scanf( &ber, "{o", &bdn ) == LBER_ERROR ) {
return;
}
+#ifdef ENABLE_REWRITE
/*
* Rewrite the dn of the result, if needed
*/
switch ( rewrite_session( li->rwinfo, "searchResult",
- dn, lc->conn, &ent.e_name.bv_val ) ) {
+ dn.bv_val, lc->conn, &ent.e_name.bv_val ) ) {
case REWRITE_REGEXEC_OK:
if ( ent.e_name.bv_val == NULL ) {
- ent.e_name.bv_val = dn;
+ ent.e_name = bdn;
} else {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
"[rw] searchResult: \"%s\""
- " -> \"%s\"\n", dn, ent.e_dn ));
+ " -> \"%s\"\n", dn.bv_val, ent.e_dn ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS, "rw> searchResult: \"%s\""
- " -> \"%s\"\n%s", dn, ent.e_dn, "" );
+ " -> \"%s\"\n%s", dn.bv_val, ent.e_dn, "" );
#endif /* !NEW_LOGGING */
- free( dn );
- dn = NULL;
+ free( dn.bv_val );
+ dn.bv_val = NULL;
+ ent.e_name.bv_len = strlen( ent.e_name.bv_val );
}
- ent.e_name.bv_len = strlen( ent.e_name.bv_val );
break;
case REWRITE_REGEXEC_ERR:
return;
}
#else /* !ENABLE_REWRITE */
- ber_str2bv( ldap_get_dn(lc->ld, e), 0, 0, &bdn );
ldap_back_dn_massage( li, &bdn, &ent.e_name, 0, 0 );
#endif /* !ENABLE_REWRITE */
ent.e_private = 0;
attrp = &ent.e_attrs;
- for ( a = ldap_first_attribute(lc->ld, e, &ber);
- a != NULL;
- a = ldap_next_attribute(lc->ld, e, ber))
- {
- mapped = ldap_back_map(&li->at_map, a, 1);
- if (mapped == NULL)
+ while ( ber_scanf( &ber, "{{o", &a ) != LBER_ERROR ) {
+ ldap_back_map(&li->at_map, &a, &mapped, 1);
+ if (mapped.bv_val == NULL)
continue;
attr = (Attribute *)ch_malloc( sizeof(Attribute) );
if (attr == NULL)
continue;
attr->a_next = 0;
attr->a_desc = NULL;
- if (slap_str2ad(mapped, &attr->a_desc, &text) != LDAP_SUCCESS) {
- if (slap_str2undef_ad(mapped, &attr->a_desc, &text)
+ if (slap_bv2ad(&mapped, &attr->a_desc, &text) != LDAP_SUCCESS) {
+ if (slap_bv2undef_ad(&mapped, &attr->a_desc, &text)
!= LDAP_SUCCESS) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
"slap_str2undef_ad(%s): "
- "%s\n", mapped, text ));
+ "%s\n", mapped.bv_val, text ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ANY,
"slap_str2undef_ad(%s): "
- "%s\n%s", mapped, text, "" );
+ "%s\n%s", mapped.bv_val, text, "" );
#endif /* !NEW_LOGGING */
ch_free(attr);
continue;
}
}
- attr->a_vals = ldap_get_values_len(lc->ld, e, a);
- if (!attr->a_vals) {
+ if (ber_scanf( &ber, "[W]", &attr->a_vals ) == LBER_ERROR ) {
attr->a_vals = &dummy;
- } else if ( strcasecmp( mapped, "objectclass" ) == 0 ) {
+ } else if ( strcasecmp( mapped.bv_val, "objectclass" ) == 0 ) {
int i, last;
- for ( last = 0; attr->a_vals[last]; last++ ) ;
- for ( i = 0; ( bv = attr->a_vals[i] ); i++ ) {
- mapped = ldap_back_map(&li->oc_map, bv->bv_val, 1);
- if (mapped == NULL) {
- ber_bvfree(attr->a_vals[i]);
- attr->a_vals[i] = NULL;
+ for ( last = 0; attr->a_vals[last].bv_val; last++ ) ;
+ for ( i = 0; ( bv = &attr->a_vals[i] ); i++ ) {
+ ldap_back_map(&li->oc_map, bv, &mapped, 1);
+ if (mapped.bv_val == NULL) {
+ free(attr->a_vals[i].bv_val);
+ attr->a_vals[i].bv_val = NULL;
if (--last < 0)
break;
attr->a_vals[i] = attr->a_vals[last];
- attr->a_vals[last] = NULL;
+ attr->a_vals[last].bv_val = NULL;
i--;
- } else if ( mapped != bv->bv_val ) {
+ } else if ( mapped.bv_val != bv->bv_val ) {
ch_free(bv->bv_val);
- ber_str2bv( mapped, 0, 1, bv );
+ ber_dupbv( bv, &mapped );
}
}
} else if ( strcmp( attr->a_desc->ad_type->sat_syntax->ssyn_oid,
SLAPD_DN_SYNTAX ) == 0 ) {
int i;
- for ( i = 0; ( bv = attr->a_vals[ i ] ); i++ ) {
+ for ( i = 0; ( bv = &attr->a_vals[ i ] ); i++ ) {
char *newval;
switch ( rewrite_session( li->rwinfo,
attr = ent.e_attrs;
ent.e_attrs = attr->a_next;
if (attr->a_vals != &dummy)
- ber_bvecfree(attr->a_vals);
+ bvarray_free(attr->a_vals);
free(attr);
}
- if (ber)
- ber_free(ber,0);
if ( ent.e_dn )
free( ent.e_dn );
/* get parent with writer lock */
if ( (p = dn2entry_w( be, &pdn, &matched )) == NULL ) {
char *matched_dn = NULL;
- struct berval **refs;
+ BVarray refs;
ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
refs == NULL ? "parent does not exist" : "parent is referral",
refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
free( matched_dn );
return -1;
if ( is_entry_referral( p ) ) {
/* parent is a referral, don't allow add */
char *matched_dn = ch_strdup( p->e_dn );
- struct berval **refs = is_entry_referral( p )
+ BVarray refs = is_entry_referral( p )
? get_entry_referrals( be, conn, op, p )
: NULL;
send_ldap_result( conn, op, LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
free( matched_dn );
return -1;
}
/*
* aliasedObjectName should be SINGLE-VALUED with a single value.
*/
- if ( a->a_vals[0] == NULL || a->a_vals[0]->bv_val == NULL ) {
+ if ( a->a_vals[0].bv_val == NULL ) {
/*
* there was an aliasedobjectname defined but no data.
*/
return -1;
}
- if( a->a_vals[1] != NULL ) {
+ if( a->a_vals[1].bv_val != NULL ) {
*err = LDAP_ALIAS_PROBLEM;
*errmsg = "alias has multivalued aliasedObjectName";
return -1;
}
- rc = dnNormalize2( NULL, a->a_vals[0], ndn );
+ rc = dnNormalize2( NULL, &a->a_vals[0], ndn );
if( rc != LDAP_SUCCESS ) {
*err = LDAP_ALIAS_PROBLEM;
*errmsg = "alias aliasedObjectName value is invalid";
Entry *target,
struct berval *entry_ndn,
AttributeDescription *entry_at,
- struct berval ***vals )
+ BVarray *vals )
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
Entry *e;
int i, j, rc;
Attribute *attr;
- struct berval **v;
+ BVarray v;
const char *entry_at_name = entry_at->ad_cname.bv_val;
+ struct berval *iv, *jv;
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ARGS,
goto return_results;
}
- for ( i = 0; attr->a_vals[i] != NULL; i++ ) {
+ for ( i = 0; attr->a_vals[i].bv_val != NULL; i++ ) {
/* count them */
}
- v = (struct berval **) ch_malloc( sizeof(struct berval *) * (i+1) );
+ v = (BVarray) ch_malloc( sizeof(struct berval) * (i+1) );
- for ( i=0, j=0; attr->a_vals[i] != NULL; i++ ) {
+ for ( iv=attr->a_vals, jv=v; iv->bv_val; iv++ ) {
if( conn != NULL
&& op != NULL
&& access_allowed(be, conn, op, e, entry_at,
- attr->a_vals[i], ACL_READ) == 0)
+ iv, ACL_READ) == 0)
{
continue;
}
- v[j] = ber_bvdup( attr->a_vals[i] );
+ ber_dupbv( jv, iv );
- if( v[j] != NULL ) j++;
+ if( jv->bv_val != NULL ) jv++;
}
- if( j == 0 ) {
+ if( jv == v ) {
ch_free( v );
*vals = NULL;
rc = LDAP_INSUFFICIENT_ACCESS;
} else {
- v[j] = NULL;
+ jv->bv_val = NULL;
*vals = v;
rc = LDAP_SUCCESS;
}
/* get entry with reader lock */
if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
char *matched_dn = NULL;
- struct berval **refs = NULL;
+ BVarray refs = NULL;
if( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
NULL, NULL, NULL, NULL );
}
- if ( refs ) ber_bvecfree( refs );
+ if ( refs ) bvarray_free( refs );
if ( matched_dn ) free( matched_dn );
return( rc );
}
if ( is_entry_referral( e ) ) {
/* entry is a referral, don't allow bind */
- struct berval **refs = get_entry_referrals( be,
+ BVarray refs = get_entry_referrals( be,
conn, op, e );
#ifdef NEW_LOGGING
NULL, NULL, NULL, NULL );
}
- ber_bvecfree( refs );
+ bvarray_free( refs );
rc = 1;
goto return_results;
/* get entry with reader lock */
if ( (e = dn2entry_r( be, ndn, &matched )) == NULL ) {
char *matched_dn = NULL;
- struct berval **refs = NULL;
+ BVarray refs = NULL;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
send_ldap_result( conn, op, LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ if ( refs ) bvarray_free( refs );
free( matched_dn );
return( 1 );
if (!manageDSAit && is_entry_referral( e ) ) {
/* entry is a referral, don't allow add */
- struct berval **refs = get_entry_referrals( be,
+ BVarray refs = get_entry_referrals( be,
conn, op, e );
#ifdef NEW_LOGGING
send_ldap_result( conn, op, LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ if (refs ) bvarray_free( refs );
rc = 1;
goto return_results;
/* get entry with writer lock */
if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) {
char *matched_dn = NULL;
- struct berval **refs;
+ BVarray refs;
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
send_ldap_result( conn, op, LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ if ( refs ) bvarray_free( refs );
free( matched_dn );
return( -1 );
if ( !manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
- struct berval **refs = get_entry_referrals( be,
+ BVarray refs = get_entry_referrals( be,
conn, op, e );
#ifdef NEW_LOGGING
send_ldap_result( conn, op, LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ if ( refs ) bvarray_free( refs );
rc = 1;
goto return_results;
*idlp = NULL;
if ( prefix == DN_SUBTREE_PREFIX && be_issuffix(be, dn->bv_val) ) {
- *idlp = ch_malloc( sizeof(ID) );
- **idlp = ID_BLOCK_ALLIDS_VALUE;
+ *idlp = ch_malloc( 2*sizeof(ID) );
+ (*idlp)[0] = ID_BLOCK_ALLIDS_VALUE;
+ (*idlp)[1] = 0;
return 0;
}
struct berval **rspdata,
LDAPControl *** rspctrls,
const char** text,
- struct berval *** refs
+ BVarray *refs
)
{
int i;
Backend *be,
char *dbname,
struct berval *atname,
- struct berval **vals,
+ BVarray vals,
ID id,
int op,
slap_mask_t mask )
Backend *be,
AttributeType *type,
struct berval *lang,
- struct berval **vals,
+ BVarray vals,
ID id,
int op,
char ** dbnamep,
int index_values(
Backend *be,
AttributeDescription *desc,
- struct berval **vals,
+ BVarray vals,
ID id,
int op )
{
/* acquire and lock entry */
if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) {
char* matched_dn = NULL;
- struct berval **refs;
+ BVarray refs;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
send_ldap_result( conn, op, LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ if ( refs ) bvarray_free( refs );
free( matched_dn );
return( -1 );
if ( !manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
- struct berval **refs = get_entry_referrals( be,
+ BVarray refs = get_entry_referrals( be,
conn, op, e );
#ifdef NEW_LOGGING
send_ldap_result( conn, op, LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ if ( refs ) bvarray_free( refs );
goto error_return;
}
return LDAP_INAPPROPRIATE_MATCHING;
}
- for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+ for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
int rc;
int j;
const char *text = NULL;
rc = value_normalize( mod->sm_desc,
SLAP_MR_EQUALITY,
- mod->sm_bvalues[i],
+ &mod->sm_bvalues[i],
&asserted,
&text );
if( rc != LDAP_SUCCESS ) return rc;
- for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_VALUE_SYNTAX_MATCH,
- a->a_vals[j], &asserted, &text );
+ &a->a_vals[j], &asserted, &text );
if( rc == LDAP_SUCCESS && match == 0 ) {
free( asserted.bv_val );
}
/* find each value to delete */
- for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+ for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
int rc;
const char *text = NULL;
rc = value_normalize( mod->sm_desc,
SLAP_MR_EQUALITY,
- mod->sm_bvalues[i],
+ &mod->sm_bvalues[i],
&asserted,
&text );
if( rc != LDAP_SUCCESS ) return rc;
found = 0;
- for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_VALUE_SYNTAX_MATCH,
- a->a_vals[j], &asserted, &text );
+ &a->a_vals[j], &asserted, &text );
if( rc == LDAP_SUCCESS && match != 0 ) {
continue;
found = 1;
/* delete it */
- ber_bvfree( a->a_vals[j] );
- for ( k = j + 1; a->a_vals[k] != NULL; k++ ) {
+ free( a->a_vals[j].bv_val );
+ for ( k = j + 1; a->a_vals[k].bv_val != NULL; k++ ) {
a->a_vals[k - 1] = a->a_vals[k];
}
- a->a_vals[k - 1] = NULL;
+ a->a_vals[k - 1].bv_val = NULL;
break;
}
}
/* if no values remain, delete the entire attribute */
- if ( a->a_vals[0] == NULL ) {
+ if ( a->a_vals[0].bv_val == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
"delete_values: removing entire attribute %s\n", desc ));
/* get entry with writer lock */
if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) {
char* matched_dn = NULL;
- struct berval** refs;
+ BVarray refs;
if( matched != NULL ) {
matched_dn = strdup( matched->e_dn );
send_ldap_result( conn, op, LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ if ( refs ) bvarray_free( refs );
free( matched_dn );
return( -1 );
if (!manageDSAit && is_entry_referral( e ) ) {
/* parent is a referral, don't allow add */
/* parent is an alias, don't allow add */
- struct berval **refs = get_entry_referrals( be,
+ BVarray refs = get_entry_referrals( be,
conn, op, e );
#ifdef NEW_LOGGING
send_ldap_result( conn, op, LDAP_REFERRAL,
e->e_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ if ( refs ) bvarray_free( refs );
goto return_results;
}
}
mod_tmp = (Modifications *)ch_malloc( sizeof( Modifications )
- + 2 * sizeof( struct berval * ) );
+ + 2 * sizeof( struct berval ) );
mod_tmp->sml_desc = desc;
- mod_tmp->sml_bvalues = (struct berval **)( mod_tmp + 1 );
- mod_tmp->sml_bvalues[0] = &new_rdn[0][a_cnt]->la_value;
- mod_tmp->sml_bvalues[1] = NULL;
+ mod_tmp->sml_bvalues = (BVarray)( mod_tmp + 1 );
+ mod_tmp->sml_bvalues[0] = new_rdn[0][a_cnt]->la_value;
+ mod_tmp->sml_bvalues[1].bv_val = NULL;
mod_tmp->sml_op = SLAP_MOD_SOFTADD;
mod_tmp->sml_next = mod;
mod = mod_tmp;
/* Remove old value of rdn as an attribute. */
mod_tmp = (Modifications *)ch_malloc( sizeof( Modifications )
- + 2 * sizeof( struct berval * ) );
+ + 2 * sizeof( struct berval ) );
mod_tmp->sml_desc = desc;
- mod_tmp->sml_bvalues = (struct berval **)(mod_tmp+1);
- mod_tmp->sml_bvalues[0] = &old_rdn[0][d_cnt]->la_value;
- mod_tmp->sml_bvalues[1] = NULL;
+ mod_tmp->sml_bvalues = (BVarray)(mod_tmp+1);
+ mod_tmp->sml_bvalues[0] = old_rdn[0][d_cnt]->la_value;
+ mod_tmp->sml_bvalues[1].bv_val = NULL;
mod_tmp->sml_op = LDAP_MOD_DELETE;
mod_tmp->sml_next = mod;
mod = mod_tmp;
struct berval **rspdata,
LDAPControl *** rspctrls,
const char **text,
- struct berval *** refs
+ BVarray *refs
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
int rc;
Entry *e = NULL;
- struct berval *hash = NULL;
+ struct berval hash = { 0, NULL };
- struct berval *id = NULL;
- struct berval *new = NULL;
+ struct berval id = { 0, NULL };
+ struct berval new = { 0, NULL };
struct berval dn;
struct berval ndn;
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
"ldbm_back_exop_passwd: \"%s\"\n",
- id ? id->bv_val : "" ));
+ id.bv_val ? id.bv_val : "" ));
#else
Debug( LDAP_DEBUG_ARGS, "==> ldbm_back_exop_passwd: \"%s\"\n",
- id ? id->bv_val : "", 0, 0 );
+ id.bv_val ? id.bv_val : "", 0, 0 );
#endif
goto done;
}
- if( new == NULL || new->bv_len == 0 ) {
- new = slap_passwd_generate();
+ if( new.bv_len == 0 ) {
+ slap_passwd_generate(&new);
- if( new == NULL || new->bv_len == 0 ) {
+ if( new.bv_len == 0 ) {
*text = "password generation failed.";
rc = LDAP_OTHER;
goto done;
}
- *rspdata = slap_passwd_return( new );
+ *rspdata = slap_passwd_return( &new );
}
- hash = slap_passwd_hash( new );
+ slap_passwd_hash( &new, &hash );
- if( hash == NULL || hash->bv_len == 0 ) {
+ if( hash.bv_len == 0 ) {
*text = "password hash failed";
rc = LDAP_OTHER;
goto done;
}
- if( id ) {
- dn = *id;
+ if( id.bv_len ) {
+ dn = id;
} else {
dn = op->o_dn;
}
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
"ldbm_back_exop_passwd: \"%s\"%s\n",
- dn.bv_val, id ? " (proxy)" : "" ));
+ dn.bv_val, id.bv_len ? " (proxy)" : "" ));
#else
Debug( LDAP_DEBUG_TRACE, "passwd: \"%s\"%s\n",
- dn.bv_val, id ? " (proxy)" : "", 0 );
+ dn.bv_val, id.bv_len ? " (proxy)" : "", 0 );
#endif
if( dn.bv_len == 0 ) {
{
Modifications ml;
- struct berval *vals[2];
+ struct berval vals[2];
char textbuf[SLAP_TEXT_BUFLEN]; /* non-returnable */
vals[0] = hash;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
ml.sml_desc = slap_schema.si_ad_userPassword;
ml.sml_bvalues = vals;
cache_return_entry_w( &li->li_cache, e );
}
- if( id != NULL ) {
- ber_bvfree( id );
+ if( id.bv_val != NULL ) {
+ free( id.bv_val );
}
- if( new != NULL ) {
- ber_bvfree( new );
+ if( new.bv_val != NULL ) {
+ free( new.bv_val );
}
- if( hash != NULL ) {
- ber_bvfree( hash );
+ if( hash.bv_val != NULL ) {
+ free( hash.bv_val );
}
if( ndn.bv_val != NULL ) {
index_values LDAP_P((
Backend *be,
AttributeDescription *desc,
- struct berval **vals,
+ BVarray vals,
ID id,
int op ));
/*
* passwd.c
*/
-extern int ldbm_back_exop_passwd LDAP_P(( BackendDB *bd,
- Connection *conn, Operation *op,
- const char *reqoid,
- struct berval *reqdata,
- char **rspoid,
- struct berval **rspdata,
- LDAPControl ***rspctrls,
- const char **text,
- struct berval *** refs ));
-
+extern BI_op_extended ldbm_back_exop_passwd;
/*
* modify.c
e = dn2entry_r( be, ndn, &matched );
if ( e == NULL ) {
char *matched_dn = NULL;
- struct berval **refs = NULL;
+ BVarray refs = NULL;
if ( matched != NULL ) {
matched_dn = ch_strdup( matched->e_dn );
/* send referrals */
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
matched_dn, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
} else if ( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc, matched_dn,
if ( is_entry_referral( e ) ) {
/* entry is a referral */
- struct berval **refs = get_entry_referrals( be,
- conn, op, e );
- struct berval **rrefs = referral_rewrite(
+ BVarray refs = get_entry_referrals( be, conn, op, e );
+ BVarray rrefs = referral_rewrite(
refs, &e->e_name, dn, LDAP_SCOPE_DEFAULT );
#ifdef NEW_LOGGING
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
e->e_dn, NULL, rrefs, NULL );
- ber_bvecfree( rrefs );
+ bvarray_free( rrefs );
} else {
send_ldap_result( conn, op, rc = LDAP_OTHER, e->e_dn,
"bad referral object", NULL, NULL );
}
- if( refs != NULL ) ber_bvecfree( refs );
+ if( refs != NULL ) bvarray_free( refs );
}
cache_return_entry_r( &li->li_cache, e );
int slimit,
int tlimit,
Filter *filter,
- const char *filterstr,
+ struct berval *filterstr,
AttributeName *attrs,
int attrsonly )
{
ID_BLOCK *candidates;
ID id, cursor;
Entry *e;
- struct berval **v2refs = NULL;
+ BVarray v2refs = NULL;
Entry *matched = NULL;
struct berval realbase = { 0, NULL };
int nentries = 0;
if ( e == NULL ) {
struct berval *matched_dn = NULL;
- struct berval **refs = NULL;
+ BVarray refs = NULL;
if ( matched != NULL ) {
- struct berval **erefs;
+ BVarray erefs;
matched_dn = ber_bvdup( &matched->e_name );
erefs = is_entry_referral( matched )
refs = referral_rewrite( erefs, matched_dn,
base, scope );
- ber_bvecfree( erefs );
+ bvarray_free( erefs );
}
} else {
matched_dn ? matched_dn->bv_val : NULL,
text, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
ber_bvfree( matched_dn );
return 1;
}
if (!manageDSAit && is_entry_referral( e ) ) {
/* entry is a referral, don't allow add */
struct berval *matched_dn = ber_bvdup( &e->e_name );
- struct berval **erefs = get_entry_referrals( be,
- conn, op, e );
- struct berval **refs = NULL;
+ BVarray erefs = get_entry_referrals( be, conn, op, e );
+ BVarray refs = NULL;
cache_return_entry_r( &li->li_cache, e );
refs = referral_rewrite( erefs, matched_dn,
base, scope );
- ber_bvecfree( erefs );
+ bvarray_free( erefs );
}
if( refs ) {
send_ldap_result( conn, op, LDAP_REFERRAL,
matched_dn->bv_val, NULL, refs, NULL );
- ber_bvecfree( refs );
+ bvarray_free( refs );
} else {
send_ldap_result( conn, op, LDAP_OTHER,
}
if( scopeok ) {
- struct berval **erefs = get_entry_referrals(
+ BVarray erefs = get_entry_referrals(
be, conn, op, e );
- struct berval **refs = referral_rewrite( erefs,
+ BVarray refs = referral_rewrite( erefs,
&e->e_name, NULL,
scope == LDAP_SCOPE_SUBTREE
? LDAP_SCOPE_SUBTREE
send_search_reference( be, conn, op,
e, refs, NULL, &v2refs );
- ber_bvecfree( refs );
+ bvarray_free( refs );
} else {
#ifdef NEW_LOGGING
if( candidates != NULL )
idl_free( candidates );
- if( v2refs ) ber_bvecfree( v2refs );
+ if( v2refs ) bvarray_free( v2refs );
if( realbase.bv_val ) free( realbase.bv_val );
return rc;
Entry *target,
struct berval *edn,
AttributeDescription *entry_at,
- struct berval ***vals
+ BVarray *vals
)
{
if( target == NULL || target->e_nname.bv_len != edn->bv_len ||
int matchlen;
char *matched;
int nrefs;
- struct berval **refs;
+ BVarray refs;
} glue_state;
static void
ber_int_t err,
const char *matched,
const char *text,
- struct berval **ref,
+ BVarray ref,
const char *resoid,
struct berval *resdata,
struct berval *sasldata,
}
if (ref) {
int i, j, k;
- struct berval **new;
+ BVarray new;
- for (i=0; ref[i]; i++);
+ for (i=0; ref[i].bv_val; i++);
j = gs->nrefs;
if (!j) {
- new = ch_malloc ((i+1)*sizeof(struct berval *));
+ new = ch_malloc ((i+1)*sizeof(struct berval));
} else {
new = ch_realloc(gs->refs,
- (j+i+1)*sizeof(struct berval *));
+ (j+i+1)*sizeof(struct berval));
}
for (k=0; k<i; j++,k++) {
- new[j] = ber_bvdup(ref[k]);
+ ber_dupbv( &new[j], &ref[k] );
}
- new[j] = NULL;
+ new[j].bv_val = NULL;
gs->nrefs = j;
gs->refs = new;
}
ber_int_t err,
const char *matched,
const char *text,
- struct berval **refs,
+ BVarray refs,
LDAPControl **ctrls,
int nentries
)
int slimit,
int tlimit,
Filter *filter,
- const char *filterstr,
+ struct berval *filterstr,
AttributeName *attrs,
int attrsonly
)
if (gs.matched)
free (gs.matched);
if (gs.refs)
- ber_bvecfree(gs.refs);
+ bvarray_free(gs.refs);
return rc;
}
Entry *target,
struct berval *ndn,
AttributeDescription *ad,
- struct berval ***vals
+ BVarray *vals
)
{
BackendDB *be;
if ( (be = select_backend( &ndn, 0, 0 )) == NULL ) {
if ( default_referral ) {
- struct berval **ref = referral_rewrite( default_referral,
+ BVarray ref = referral_rewrite( default_referral,
NULL, &pdn, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
NULL, NULL, ref ? ref : default_referral, NULL );
- ber_bvecfree( ref );
+ bvarray_free( ref );
} else {
/* noSuchObject is not allowed to be returned by bind */
* if we don't hold it.
*/
if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
- struct berval **ref = referral_rewrite( default_referral,
+ BVarray ref = referral_rewrite( default_referral,
NULL, &pdn, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
NULL, NULL, ref ? ref : default_referral, NULL );
- ber_bvecfree( ref );
+ bvarray_free( ref );
rc = 0;
goto cleanup;
}
char *cargv[MAXARGS+1];
int lineno, i;
int rc;
- struct berval *vals[2];
- struct berval val;
+ struct berval vals[2];
static BackendInfo *bi = NULL;
static BackendDB *be = NULL;
- vals[0] = &val;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
if ( (fp = fopen( fname, "r" )) == NULL ) {
ldap_syslog = 1;
return 1;
}
- vals[0]->bv_val = cargv[1];
- vals[0]->bv_len = strlen( vals[0]->bv_val );
+ vals[0].bv_val = cargv[1];
+ vals[0].bv_len = strlen( vals[0].bv_val );
value_add( &default_referral, vals );
#ifdef NEW_LOGGING
return 1;
}
- vals[0]->bv_val = cargv[1];
- vals[0]->bv_len = strlen( vals[0]->bv_val );
+ vals[0].bv_val = cargv[1];
+ vals[0].bv_len = strlen( vals[0].bv_val );
value_add( &be->be_update_refs, vals );
/* replication log file to which changes are appended */
* if we don't hold it.
*/
if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
- struct berval **ref = referral_rewrite( default_referral,
+ BVarray ref = referral_rewrite( default_referral,
NULL, &pdn, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
NULL, NULL, ref ? ref : default_referral, NULL );
- ber_bvecfree( ref );
+ bvarray_free( ref );
goto cleanup;
}
}
#ifndef SLAPD_MULTIMASTER
} else {
- struct berval **defref = be->be_update_refs
+ BVarray defref = be->be_update_refs
? be->be_update_refs : default_referral;
- struct berval **ref = referral_rewrite( default_referral,
+ BVarray ref = referral_rewrite( default_referral,
NULL, &pdn, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
ref ? ref : defref, NULL );
- ber_bvecfree( ref );
+ bvarray_free( ref );
#endif
}
int rc;
Entry *e;
char *type;
- struct berval value;
- struct berval *vals[2];
+ struct berval vals[2];
AttributeDescription *ad;
const char *text;
char *next;
e->e_private = NULL;
/* dn + attributes */
- vals[0] = &value;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
next = s;
while ( (s = ldif_getline( &next )) != NULL ) {
break;
}
- if ( ldif_parse_line( s, &type, &value.bv_val, &value.bv_len ) != 0 ) {
+ if ( ldif_parse_line( s, &type, &vals[0].bv_val, &vals[0].bv_len ) != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
"str2entry: NULL (parse_line)\n" ));
LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, "str2entry: "
"entry %ld has multiple DNs \"%s\" and \"%s\"\n",
(long) e->e_id, e->e_dn,
- value.bv_val != NULL ? value.bv_val : "" ));
+ vals[0].bv_val != NULL ? vals[0].bv_val : "" ));
#else
Debug( LDAP_DEBUG_ANY, "str2entry: "
"entry %ld has multiple DNs \"%s\" and \"%s\"\n",
(long) e->e_id, e->e_dn,
- value.bv_val != NULL ? value.bv_val : "" );
+ vals[0].bv_val != NULL ? vals[0].bv_val : "" );
#endif
- if( value.bv_val != NULL ) free( value.bv_val );
+ if( vals[0].bv_val != NULL ) free( vals[0].bv_val );
entry_free( e );
return NULL;
}
- rc = dnPrettyNormal( NULL, &value, &e->e_name, &e->e_nname );
- free( value.bv_val );
+ rc = dnPrettyNormal( NULL, &vals[0], &e->e_name, &e->e_nname );
+ free( vals[0].bv_val );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, "str2entry: "
#endif
if( slapMode & SLAP_TOOL_MODE ) {
entry_free( e );
- free( value.bv_val );
+ free( vals[0].bv_val );
free( type );
return NULL;
}
type, text, 0 );
#endif
entry_free( e );
- free( value.bv_val );
+ free( vals[0].bv_val );
free( type );
return NULL;
}
if( pretty ) {
rc = pretty( ad->ad_type->sat_syntax,
- &value, &pval );
+ &vals[0], &pval );
} else if( validate ) {
/*
* validate value per syntax
*/
- rc = validate( ad->ad_type->sat_syntax, &value );
+ rc = validate( ad->ad_type->sat_syntax, &vals[0] );
} else {
#ifdef NEW_LOGGING
ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
#endif
entry_free( e );
- free( value.bv_val );
+ free( vals[0].bv_val );
free( type );
return NULL;
}
ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
#endif
entry_free( e );
- free( value.bv_val );
+ free( vals[0].bv_val );
free( type );
return NULL;
}
if( pretty ) {
- free( value.bv_val );
- value = pval;
+ free( vals[0].bv_val );
+ vals[0] = pval;
}
}
"<= str2entry NULL (attr_merge)\n", 0, 0, 0 );
#endif
entry_free( e );
- free( value.bv_val );
+ free( vals[0].bv_val );
free( type );
return( NULL );
}
free( type );
- free( value.bv_val );
+ free( vals[0].bv_val );
}
/* check to make sure there was a dn: line */
/* put the attributes */
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
/* put "<type>:[:] <value>" line for each value */
- for ( i = 0; a->a_vals[i] != NULL; i++ ) {
- bv = a->a_vals[i];
+ for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
+ bv = &a->a_vals[i];
tmplen = a->a_desc->ad_cname.bv_len;
MAKE_SPACE( LDIF_SIZE_NEEDED( tmplen, bv->bv_len ));
ldif_sput( (char **) &ecur, LDIF_PUT_VALUE,
entry_dn_cmp( Entry *e1, Entry *e2 )
{
/* compare their normalized UPPERCASED dn's */
+ int rc = e1->e_nname.bv_len - e2->e_nname.bv_len;
+ if (rc) return rc;
return( strcmp( e1->e_ndn, e2->e_ndn ) );
}
siz += sizeof(Attribute);
len += a->a_desc->ad_cname.bv_len+1;
len += entry_lenlen(a->a_desc->ad_cname.bv_len);
- for (i=0; a->a_vals[i]; i++) {
- siz += sizeof(struct berval *);
+ for (i=0; a->a_vals[i].bv_val; i++) {
siz += sizeof(struct berval);
- len += a->a_vals[i]->bv_len + 1;
- len += entry_lenlen(a->a_vals[i]->bv_len);
+ len += a->a_vals[i].bv_len + 1;
+ len += entry_lenlen(a->a_vals[i].bv_len);
}
len += entry_lenlen(i);
- siz += sizeof(struct berval *); /* NULL pointer at end */
+ siz += sizeof(struct berval); /* empty berval at end */
}
len += 1; /* NUL byte at end */
len += entry_lenlen(siz);
ptr += a->a_desc->ad_cname.bv_len;
*ptr++ = '\0';
if (a->a_vals) {
- for (i=0; a->a_vals[i]; i++);
+ for (i=0; a->a_vals[i].bv_val; i++);
entry_putlen(&ptr, i);
- for (i=0; a->a_vals[i]; i++) {
- entry_putlen(&ptr, a->a_vals[i]->bv_len);
- memcpy(ptr, a->a_vals[i]->bv_val,
- a->a_vals[i]->bv_len);
- ptr += a->a_vals[i]->bv_len;
+ for (i=0; a->a_vals[i].bv_val; i++) {
+ entry_putlen(&ptr, a->a_vals[i].bv_len);
+ memcpy(ptr, a->a_vals[i].bv_val,
+ a->a_vals[i].bv_len);
+ ptr += a->a_vals[i].bv_len;
*ptr++ = '\0';
}
}
const char *text;
AttributeDescription *ad;
unsigned char *ptr = (unsigned char *)bv->bv_val;
- struct berval **bptr;
- struct berval *vptr;
+ BVarray bptr;
i = entry_getlen(&ptr);
x = ch_malloc(i);
* pointer can never be NULL
*/
x->e_attrs = (Attribute *)(x+1);
- bptr = (struct berval **)x->e_attrs;
+ bptr = (BVarray)x->e_attrs;
a = NULL;
while (i = entry_getlen(&ptr)) {
+ struct berval bv = { i, ptr };
if (a) {
a->a_next = (Attribute *)bptr;
}
a = (Attribute *)bptr;
ad = NULL;
- rc = slap_str2ad( ptr, &ad, &text );
+ rc = slap_bv2ad( &bv, &ad, &text );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
Debug( LDAP_DEBUG_TRACE,
"<= entry_decode: str2ad(%s): %s\n", ptr, text, 0 );
#endif
- rc = slap_str2undef_ad( ptr, &ad, &text );
+ rc = slap_bv2undef_ad( &bv, &ad, &text );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
}
ptr += i + 1;
a->a_desc = ad;
- bptr = (struct berval **)(a+1);
+ bptr = (BVarray)(a+1);
a->a_vals = bptr;
j = entry_getlen(&ptr);
- a->a_vals[j] = NULL;
- vptr = (struct berval *)(bptr + j + 1);
+ a->a_vals[j].bv_val = NULL;
while (j) {
i = entry_getlen(&ptr);
- *bptr = vptr;
- vptr->bv_len = i;
- vptr->bv_val = (char *)ptr;
+ bptr->bv_len = i;
+ bptr->bv_val = (char *)ptr;
ptr += i+1;
bptr++;
- vptr++;
j--;
}
- bptr = (struct berval **)vptr;
}
if (a)
a->a_next = NULL;
typedef struct extop_list_t {
struct extop_list_t *next;
char *oid;
- SLAP_EXTOP_MAIN_FN ext_main;
+ SLAP_EXTOP_MAIN_FN *ext_main;
} extop_list_t;
extop_list_t *supp_ext_list = NULL;
*/
struct {
char *oid;
- SLAP_EXTOP_MAIN_FN ext_main;
+ SLAP_EXTOP_MAIN_FN *ext_main;
} builtin_extops[] = {
#ifdef HAVE_TLS
{ LDAP_EXOP_START_TLS, starttls_extop },
ber_len_t len;
extop_list_t *ext;
const char *text;
- struct berval **refs;
+ BVarray refs;
char *rspoid;
struct berval *rspdata;
LDAPControl **rspctrls;
send_ldap_extended( conn, op, rc, NULL, text, refs,
rspoid, rspdata, rspctrls );
- ber_bvecfree( refs );
+ bvarray_free( refs );
}
if ( rspoid != NULL ) {
int
load_extop(
const char *ext_oid,
- SLAP_EXTOP_MAIN_FN ext_main )
+ SLAP_EXTOP_MAIN_FN *ext_main )
{
extop_list_t *ext;
Entry *e,
MatchingRuleAssertion *mra )
{
- int i;
Attribute *a;
if( !access_allowed( be, conn, op, e,
a != NULL;
a = attrs_find( a->a_next, mra->ma_desc ) )
{
- for ( i = 0; a->a_vals[i] != NULL; i++ ) {
+ struct berval *bv;
+ for ( bv = a->a_vals; bv->bv_val != NULL; bv++ ) {
int ret;
int rc;
const char *text;
rc = value_match( &ret, a->a_desc, mra->ma_rule,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
- a->a_vals[i], &mra->ma_value,
+ bv, &mra->ma_value,
&text );
if( rc != LDAP_SUCCESS ) {
int type
)
{
- int i;
Attribute *a;
if ( !access_allowed( be, conn, op, e,
a = attrs_find( a->a_next, ava->aa_desc ) )
{
MatchingRule *mr;
+ struct berval *bv;
switch ( type ) {
case LDAP_FILTER_APPROX:
continue;
}
- for ( i = 0; a->a_vals[i] != NULL; i++ ) {
+ for ( bv = a->a_vals; bv->bv_val != NULL; bv++ ) {
int ret;
int rc;
const char *text;
rc = value_match( &ret, a->a_desc, mr,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
- a->a_vals[i], &ava->aa_value,
- &text );
+ bv, &ava->aa_value, &text );
if( rc != LDAP_SUCCESS ) {
return rc;
a != NULL;
a = attrs_find( a->a_next, f->f_sub_desc ) )
{
- int i;
MatchingRule *mr = a->a_desc->ad_type->sat_substr;
+ struct berval *bv;
if( mr == NULL ) {
continue;
}
- for ( i = 0; a->a_vals[i] != NULL; i++ ) {
+ for ( bv = a->a_vals; bv->bv_val != NULL; bv++ ) {
int ret;
int rc;
const char *text;
rc = value_match( &ret, a->a_desc, mr,
SLAP_MR_ASSERTION_SYNTAX_MATCH,
- a->a_vals[i], f->f_sub,
- &text );
+ bv, f->f_sub, &text );
if( rc != LDAP_SUCCESS ) {
return rc;
int ldap_syslog_level = LOG_DEBUG;
#endif
-struct berval **default_referral = NULL;
+BVarray default_referral = NULL;
/*
* global variables that need mutex protection
char *last;
ber_tag_t tag;
ber_len_t len;
- LDAPModList *modlist = NULL;
- LDAPModList **modtail = &modlist;
+ Modifications *modlist = NULL;
+ Modifications **modtail = &modlist;
#ifdef LDAP_DEBUG
- LDAPModList *tmp;
+ Modifications *tmp;
#endif
- Modifications *mods = NULL;
Backend *be;
int rc;
const char *text;
tag = ber_next_element( op->o_ber, &len, last ) )
{
ber_int_t mop;
+ Modifications tmp, *mod;
- (*modtail) = (LDAPModList *) ch_calloc( 1, sizeof(LDAPModList) );
- if ( ber_scanf( op->o_ber, "{i{a[V]}}", &mop,
- &(*modtail)->ml_type, &(*modtail)->ml_bvalues )
+ if ( ber_scanf( op->o_ber, "{i{o[W]}}", &mop,
+ &tmp.sml_type, &tmp.sml_bvalues )
== LBER_ERROR )
{
send_ldap_disconnect( conn, op,
goto cleanup;
}
+ mod = (Modifications *) ch_malloc( sizeof(Modifications)
+ + tmp.sml_type.bv_len + 1);
+ mod->sml_type.bv_val = (char *)(mod+1);
+ strcpy(mod->sml_type.bv_val, tmp.sml_type.bv_val);
+ mod->sml_type.bv_len = tmp.sml_type.bv_len;
+ mod->sml_bvalues = tmp.sml_bvalues;
+ mod->sml_desc = NULL;
+ *modtail = mod;
+
switch( mop ) {
case LDAP_MOD_ADD:
- if ( (*modtail)->ml_bvalues == NULL ) {
+ if ( mod->sml_bvalues == NULL ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
"do_modify: modify/add operation (%ld) requires values\n",
}
}
- (*modtail)->ml_op = mop;
- modtail = &(*modtail)->ml_next;
+ mod->sml_op = mop;
+ modtail = &mod->sml_next;
}
*modtail = NULL;
Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
#endif
- for ( tmp = modlist; tmp != NULL; tmp = tmp->ml_next ) {
+ for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
- "\t%s: %s\n", tmp->ml_op == LDAP_MOD_ADD ?
- "add" : (tmp->ml_op == LDAP_MOD_DELETE ?
- "delete" : "replace"), tmp->ml_type ));
+ "\t%s: %s\n", tmp->sml_op == LDAP_MOD_ADD ?
+ "add" : (tmp->sml_op == LDAP_MOD_DELETE ?
+ "delete" : "replace"), tmp->sml_type.bv_val ));
- if ( tmp->ml_bvalues == NULL ) {
+ if ( tmp->sml_bvalues == NULL ) {
LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
"\t\tno values" ));
- } else if ( tmp->ml_bvalues[0] == NULL ) {
+ } else if ( tmp->sml_bvalues[0].bv_val == NULL ) {
LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
"\t\tzero values" ));
- } else if ( tmp->ml_bvalues[1] == NULL ) {
+ } else if ( tmp->sml_bvalues[1].bv_val == NULL ) {
LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
"\t\tone value" ));
} else {
#else
Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
- tmp->ml_op == LDAP_MOD_ADD
- ? "add" : (tmp->ml_op == LDAP_MOD_DELETE
- ? "delete" : "replace"), tmp->ml_type, 0 );
+ tmp->sml_op == LDAP_MOD_ADD
+ ? "add" : (tmp->sml_op == LDAP_MOD_DELETE
+ ? "delete" : "replace"), tmp->sml_type.bv_val, 0 );
- if ( tmp->ml_bvalues == NULL ) {
+ if ( tmp->sml_bvalues == NULL ) {
Debug( LDAP_DEBUG_ARGS, "%s\n",
"\t\tno values", NULL, NULL );
- } else if ( tmp->ml_bvalues[0] == NULL ) {
+ } else if ( tmp->sml_bvalues[0].bv_val == NULL ) {
Debug( LDAP_DEBUG_ARGS, "%s\n",
"\t\tzero values", NULL, NULL );
- } else if ( tmp->ml_bvalues[1] == NULL ) {
+ } else if ( tmp->sml_bvalues[1].bv_val == NULL ) {
Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
- "\t\tone value", (long) tmp->ml_bvalues[0]->bv_len, NULL );
+ "\t\tone value", (long) tmp->sml_bvalues[0].bv_len, NULL );
} else {
Debug( LDAP_DEBUG_ARGS, "%s\n",
"\t\tmultiple values", NULL, NULL );
* if we don't hold it.
*/
if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
- struct berval **ref = referral_rewrite( default_referral,
+ BVarray ref = referral_rewrite( default_referral,
NULL, &pdn, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
NULL, NULL, ref ? ref : default_referral, NULL );
- ber_bvecfree( ref );
+ bvarray_free( ref );
goto cleanup;
}
char textbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof textbuf;
- rc = slap_modlist2mods( modlist, update, &mods, &text,
+ rc = slap_mods_check( modlist, update, &text,
textbuf, textlen );
if( rc != LDAP_SUCCESS ) {
if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
global_lastmod == ON)) && !repl_user )
{
- Modifications **modstail;
- for( modstail = &mods;
- *modstail != NULL;
- modstail = &(*modstail)->sml_next )
+ for( modtail = &modlist;
+ *modtail != NULL;
+ modtail = &(*modtail)->sml_next )
{
/* empty */
}
- rc = slap_mods_opattrs( op, mods, modstail, &text,
+ rc = slap_mods_opattrs( op, modlist, modtail, &text,
textbuf, textlen );
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc,
}
}
- if ( (*be->be_modify)( be, conn, op, &pdn, &ndn, mods ) == 0
+ if ( (*be->be_modify)( be, conn, op, &pdn, &ndn, modlist ) == 0
#ifdef SLAPD_MULTIMASTER
&& !repl_user
#endif
) {
/* but we log only the ones not from a replicator user */
- replog( be, op, &pdn, &ndn, mods );
+ replog( be, op, &pdn, &ndn, modlist );
}
#ifndef SLAPD_MULTIMASTER
/* send a referral */
} else {
- struct berval **defref = be->be_update_refs
+ BVarray defref = be->be_update_refs
? be->be_update_refs : default_referral;
- struct berval **ref = referral_rewrite( defref,
+ BVarray ref = referral_rewrite( defref,
NULL, &pdn, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
ref ? ref : defref, NULL );
- ber_bvecfree( ref );
+ bvarray_free( ref );
#endif
}
} else {
free( pdn.bv_val );
free( ndn.bv_val );
if ( modlist != NULL )
- slap_modlist_free( modlist );
- if ( mods != NULL )
- slap_mods_free( mods );
+ slap_mods_free( modlist );
return rc;
}
/*
- * convert a raw list of modifications to internal format
* Do basic attribute type checking and syntax validation.
*/
-int slap_modlist2mods(
- LDAPModList *ml,
+int slap_mods_check(
+ Modifications *ml,
int update,
- Modifications **mods,
const char **text,
char *textbuf,
size_t textlen )
{
int rc;
- Modifications **modtail = mods;
- for( ; ml != NULL; ml = ml->ml_next ) {
- Modifications *mod;
+ for( ; ml != NULL; ml = ml->sml_next ) {
AttributeDescription *ad = NULL;
- mod = (Modifications *)
- ch_calloc( 1, sizeof(Modifications) );
-
- /* copy the op */
- mod->sml_op = ml->ml_op;
-
/* convert to attribute description */
- rc = slap_str2ad( ml->ml_type, &mod->sml_desc, text );
+ rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
if( rc != LDAP_SUCCESS ) {
- slap_mods_free( mod );
snprintf( textbuf, textlen, "%s: %s",
- ml->ml_type, *text );
+ ml->sml_type.bv_val, *text );
*text = textbuf;
return rc;
}
- ad = mod->sml_desc;
+ ad = ml->sml_desc;
if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
&& !slap_ad_is_binary( ad ))
{
/* attribute requires binary transfer */
- slap_mods_free( mod );
-
snprintf( textbuf, textlen,
"%s: requires ;binary transfer",
- ml->ml_type );
+ ml->sml_type.bv_val );
*text = textbuf;
return LDAP_UNDEFINED_TYPE;
}
&& slap_ad_is_binary( ad ))
{
/* attribute requires binary transfer */
- slap_mods_free( mod );
snprintf( textbuf, textlen,
"%s: disallows ;binary transfer",
- ml->ml_type );
+ ml->sml_type.bv_val );
*text = textbuf;
return LDAP_UNDEFINED_TYPE;
}
if (!update && is_at_no_user_mod( ad->ad_type )) {
/* user modification disallowed */
- slap_mods_free( mod );
snprintf( textbuf, textlen,
"%s: no user modification allowed",
- ml->ml_type );
+ ml->sml_type.bv_val );
*text = textbuf;
return LDAP_CONSTRAINT_VIOLATION;
}
if ( is_at_obsolete( ad->ad_type ) &&
- ( mod->sml_op == LDAP_MOD_ADD || ml->ml_bvalues != NULL ) )
+ ( ml->sml_op == LDAP_MOD_ADD || ml->sml_bvalues != NULL ) )
{
/*
* attribute is obsolete,
* only allow replace/delete with no values
*/
- slap_mods_free( mod );
snprintf( textbuf, textlen,
"%s: attribute is obsolete",
- ml->ml_type );
+ ml->sml_type.bv_val );
*text = textbuf;
return LDAP_CONSTRAINT_VIOLATION;
}
/*
* check values
*/
- if( ml->ml_bvalues != NULL ) {
+ if( ml->sml_bvalues != NULL ) {
ber_len_t nvals;
slap_syntax_validate_func *validate =
ad->ad_type->sat_syntax->ssyn_validate;
ad->ad_type->sat_syntax->ssyn_pretty;
if( !pretty && !validate ) {
- slap_mods_free( mod );
*text = "no validator for syntax";
snprintf( textbuf, textlen,
"%s: no validator for syntax %s",
- ml->ml_type,
+ ml->sml_type.bv_val,
ad->ad_type->sat_syntax->ssyn_oid );
*text = textbuf;
return LDAP_INVALID_SYNTAX;
* check that each value is valid per syntax
* and pretty if appropriate
*/
- for( nvals = 0; ml->ml_bvalues[nvals]; nvals++ ) {
+ for( nvals = 0; ml->sml_bvalues[nvals].bv_val; nvals++ ) {
struct berval pval;
if( pretty ) {
rc = pretty( ad->ad_type->sat_syntax,
- ml->ml_bvalues[nvals], &pval );
+ &ml->sml_bvalues[nvals], &pval );
} else {
rc = validate( ad->ad_type->sat_syntax,
- ml->ml_bvalues[nvals] );
+ &ml->sml_bvalues[nvals] );
}
if( rc != 0 ) {
- slap_mods_free( mod );
snprintf( textbuf, textlen,
"%s: value #%ld invalid per syntax",
- ml->ml_type, (long) nvals );
+ ml->sml_type.bv_val, (long) nvals );
*text = textbuf;
return LDAP_INVALID_SYNTAX;
}
if( pretty ) {
- ber_memfree( ml->ml_bvalues[nvals]->bv_val );
- *ml->ml_bvalues[nvals] = pval;
+ ber_memfree( ml->sml_bvalues[nvals].bv_val );
+ ml->sml_bvalues[nvals] = pval;
}
}
* a rough single value check... an additional check is needed
* to catch add of single value to existing single valued attribute
*/
- if( ( mod->sml_op == LDAP_MOD_ADD || mod->sml_op == LDAP_MOD_REPLACE )
+ if( ( ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE )
&& nvals > 1 && is_at_single_value( ad->ad_type ))
{
- slap_mods_free( mod );
snprintf( textbuf, textlen,
"%s: multiple value provided",
- ml->ml_type );
+ ml->sml_type.bv_val );
*text = textbuf;
return LDAP_CONSTRAINT_VIOLATION;
}
}
-
- mod->sml_bvalues = ml->ml_bvalues;
- ml->ml_values = NULL;
-
- *modtail = mod;
- modtail = &mod->sml_next;
}
return LDAP_SUCCESS;
return rc;
}
if ( tmpval.bv_len ) {
- mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
+ mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
- mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
- mod->sml_bvalues[0] = ber_bvdup( &tmpval );
- mod->sml_bvalues[1] = NULL;
- assert( mod->sml_bvalues[0] );
+ mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( &mod->sml_bvalues[0], &tmpval );
+ mod->sml_bvalues[1].bv_val = NULL;
+ assert( mod->sml_bvalues[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
}
tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
tmpval.bv_val = uuidbuf;
- mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
+ mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_entryUUID;
- mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
- mod->sml_bvalues[0] = ber_bvdup( &tmpval );
- mod->sml_bvalues[1] = NULL;
- assert( mod->sml_bvalues[0] );
+ mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( &mod->sml_bvalues[0], &tmpval );
+ mod->sml_bvalues[1].bv_val = NULL;
+ assert( mod->sml_bvalues[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
- mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
+ mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_creatorsName;
- mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
- mod->sml_bvalues[0] = ber_bvdup( &name );
- mod->sml_bvalues[1] = NULL;
- assert( mod->sml_bvalues[0] );
+ mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( &mod->sml_bvalues[0], &name );
+ mod->sml_bvalues[1].bv_val = NULL;
+ assert( mod->sml_bvalues[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
- mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
+ mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_createTimestamp;
- mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
- mod->sml_bvalues[0] = ber_bvdup( ×tamp );
- mod->sml_bvalues[1] = NULL;
- assert( mod->sml_bvalues[0] );
+ mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( &mod->sml_bvalues[0], ×tamp );
+ mod->sml_bvalues[1].bv_val = NULL;
+ assert( mod->sml_bvalues[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
}
- mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
+ mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_entryCSN;
- mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
- mod->sml_bvalues[0] = ber_bvdup( &csn );
- mod->sml_bvalues[1] = NULL;
- assert( mod->sml_bvalues[0] );
+ mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( &mod->sml_bvalues[0], &csn );
+ mod->sml_bvalues[1].bv_val = NULL;
+ assert( mod->sml_bvalues[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
- mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
+ mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_modifiersName;
- mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
- mod->sml_bvalues[0] = ber_bvdup( &name );
- mod->sml_bvalues[1] = NULL;
- assert( mod->sml_bvalues[0] );
+ mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( &mod->sml_bvalues[0], &name );
+ mod->sml_bvalues[1].bv_val = NULL;
+ assert( mod->sml_bvalues[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
- mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
+ mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
mod->sml_op = mop;
mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
- mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
- mod->sml_bvalues[0] = ber_bvdup( ×tamp );
- mod->sml_bvalues[1] = NULL;
- assert( mod->sml_bvalues[0] );
+ mod->sml_bvalues = (BVarray) ch_malloc( 2 * sizeof( struct berval ) );
+ ber_dupbv( &mod->sml_bvalues[0], ×tamp );
+ mod->sml_bvalues[1].bv_val = NULL;
+ assert( mod->sml_bvalues[0].bv_val );
*modtail = mod;
modtail = &mod->sml_next;
+ *modtail = NULL;
+
return LDAP_SUCCESS;
}
-
* if we don't hold it.
*/
if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
- struct berval **ref = referral_rewrite( default_referral,
+ BVarray ref = referral_rewrite( default_referral,
NULL, &pdn, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
NULL, NULL, ref ? ref : default_referral, NULL );
- ber_bvecfree( ref );
+ bvarray_free( ref );
goto cleanup;
}
}
#ifndef SLAPD_MULTIMASTER
} else {
- struct berval **defref = be->be_update_refs
+ BVarray defref = be->be_update_refs
? be->be_update_refs : default_referral;
- struct berval **ref = referral_rewrite( defref,
+ BVarray ref = referral_rewrite( defref,
NULL, &pdn, LDAP_SCOPE_DEFAULT );
send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
ref ? ref : defref, NULL );
- ber_bvecfree( ref );
+ bvarray_free( ref );
#endif
}
} else {
)
{
if ( mod->sm_bvalues != NULL )
- ber_bvecfree( mod->sm_bvalues );
+ bvarray_free( mod->sm_bvalues );
if( freeit )
free( mod );
const char *file_name
)
{
- SLAP_EXTOP_MAIN_FN ext_main;
+ SLAP_EXTOP_MAIN_FN *ext_main;
int (*ext_getoid)(int index, char *oid, int blen);
char *oid;
int rc;
- ext_main = (SLAP_EXTOP_MAIN_FN)module_resolve(module, "ext_main");
+ ext_main = (SLAP_EXTOP_MAIN_FN *)module_resolve(module, "ext_main");
if (ext_main == NULL) {
return(-1);
}
int mr_schema_info( Entry *e )
{
- struct berval val;
- struct berval *vals[2];
+ struct berval vals[2];
MatchingRule *mr;
AttributeDescription *ad_matchingRules = slap_schema.si_ad_matchingRules;
- vals[0] = &val;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
for ( mr = mr_list; mr; mr = mr->smr_next ) {
if ( ! mr->smr_match ) {
continue;
}
- if ( ldap_matchingrule2bv( &mr->smr_mrule, &val ) == NULL ) {
+ if ( ldap_matchingrule2bv( &mr->smr_mrule, vals ) == NULL ) {
return -1;
}
#if 0
Debug( LDAP_DEBUG_TRACE, "Merging mr [%ld] %s\n",
- (long) val.bv_len, val.bv_val, 0 );
+ (long) vals[0].bv_len, vals[0].bv_val, 0 );
#endif
attr_merge( e, ad_matchingRules, vals );
- ldap_memfree( val.bv_val );
+ ldap_memfree( vals[0].bv_val );
}
return 0;
}
ObjectClass *oc )
{
Attribute *attr;
- int i;
+ struct berval *bv;
AttributeDescription *objectClass = slap_schema.si_ad_objectClass;
assert(!( e == NULL || oc == NULL ));
return 0;
}
- for( i=0; attr->a_vals[i]; i++ ) {
- ObjectClass *objectClass = oc_bvfind( attr->a_vals[i] );
+ for( bv=attr->a_vals; bv->bv_val; bv++ ) {
+ ObjectClass *objectClass = oc_bvfind( bv );
if( objectClass == oc ) {
return 1;
int
oc_schema_info( Entry *e )
{
- struct berval val;
- struct berval *vals[2];
+ struct berval vals[2];
ObjectClass *oc;
AttributeDescription *ad_objectClasses = slap_schema.si_ad_objectClasses;
- vals[0] = &val;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
for ( oc = oc_list; oc; oc = oc->soc_next ) {
- if ( ldap_objectclass2bv( &oc->soc_oclass, &val ) == NULL ) {
+ if ( ldap_objectclass2bv( &oc->soc_oclass, vals ) == NULL ) {
return -1;
}
#if 0
Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n",
- (long) val.bv_len, val.bv_val, 0 );
+ (long) vals[0].bv_len, vals[0].bv_val, 0 );
#endif
attr_merge( e, ad_objectClasses, vals );
- ldap_memfree( val.bv_val );
+ ldap_memfree( vals[0].bv_val );
}
return 0;
}
a->a_desc = slap_schema.si_ad_subschemaSubentry;
/* Should be backend specific */
- a->a_vals = ch_malloc( 2 * sizeof( struct berval * ) );
- a->a_vals[0] = ber_bvstrdup( SLAPD_SCHEMA_DN );
- a->a_vals[1] = NULL;
+ a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
+ ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1, a->a_vals );
+ a->a_vals[1].bv_val = NULL;
a->a_next = NULL;
a = ch_malloc( sizeof( Attribute ) );
a->a_desc = slap_schema.si_ad_hasSubordinates;
- a->a_vals = ch_malloc( 2 * sizeof( struct berval * ) );
- a->a_vals[0] = ber_bvstrdup( hs ? "TRUE" : "FALSE" );
- a->a_vals[1] = NULL;
+ a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
+ ber_str2bv( hs ? "TRUE" : "FALSE", 0, 1, a->a_vals );
+ a->a_vals[1].bv_val = NULL;
a->a_next = NULL;
struct berval **rspdata,
LDAPControl ***rspctrls,
const char **text,
- struct berval ***refs )
+ BVarray *refs )
{
int rc;
}
int slap_passwd_parse( struct berval *reqdata,
- struct berval **id,
- struct berval **oldpass,
- struct berval **newpass,
+ struct berval *id,
+ struct berval *oldpass,
+ struct berval *newpass,
const char **text )
{
int rc = LDAP_SUCCESS;
goto done;
}
- tag = ber_scanf( ber, "O", id );
+ tag = ber_scanf( ber, "o", id );
if( tag == LBER_ERROR ) {
#ifdef NEW_LOGGING
goto done;
}
- tag = ber_scanf( ber, "O", oldpass );
+ tag = ber_scanf( ber, "o", oldpass );
if( tag == LBER_ERROR ) {
#ifdef NEW_LOGGING
goto done;
}
- tag = ber_scanf( ber, "O", newpass );
+ tag = ber_scanf( ber, "o", newpass );
if( tag == LBER_ERROR ) {
#ifdef NEW_LOGGING
done:
if( rc != LDAP_SUCCESS ) {
- if( id != NULL ) {
- ber_bvfree( *id );
- *id = NULL;
+ if( id && id->bv_val != NULL ) {
+ free( id->bv_val );
+ id->bv_val = NULL;
}
- if( oldpass != NULL ) {
- ber_bvfree( *oldpass );
- *oldpass = NULL;
+ if( oldpass && oldpass->bv_val != NULL ) {
+ free( oldpass->bv_val );
+ oldpass->bv_val = NULL;
}
- if( newpass != NULL ) {
- ber_bvfree( *newpass );
- *newpass = NULL;
+ if( newpass && newpass->bv_val != NULL ) {
+ free( newpass->bv_val );
+ newpass->bv_val = NULL;
}
}
Attribute *a,
struct berval *cred )
{
- int i;
int result = 1;
+ struct berval *bv;
#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
ldap_pvt_thread_mutex_lock( &passwd_mutex );
#endif
#endif
- for ( i = 0; a->a_vals[i] != NULL; i++ ) {
- if( !lutil_passwd( a->a_vals[i], cred, NULL ) ) {
+ for ( bv = a->a_vals; bv->bv_val != NULL; bv++ ) {
+ if( !lutil_passwd( bv, cred, NULL ) ) {
result = 0;
break;
}
return result;
}
-struct berval * slap_passwd_generate( void )
+void
+slap_passwd_generate( struct berval *pass )
{
+ struct berval *tmp;
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
"slap_passwd_generate: begin\n" ));
#else
Debug( LDAP_DEBUG_TRACE, "slap_passwd_generate\n", 0, 0, 0 );
#endif
-
-
/*
* generate passwords of only 8 characters as some getpass(3)
* implementations truncate at 8 characters.
*/
- return lutil_passwd_generate( 8 );
+ tmp = lutil_passwd_generate( 8 );
+ if (tmp) {
+ *pass = *tmp;
+ free(tmp);
+ } else {
+ pass->bv_val = NULL;
+ pass->bv_len = 0;
+ }
}
-struct berval * slap_passwd_hash(
- struct berval * cred )
+void
+slap_passwd_hash(
+ struct berval * cred,
+ struct berval * new )
{
+ struct berval *tmp;
#ifdef LUTIL_SHA1_BYTES
char* hash = default_passwd_hash ? default_passwd_hash : "{SSHA}";
#else
#endif
- struct berval *new;
-
#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
ldap_pvt_thread_mutex_lock( &passwd_mutex );
#endif
- new = lutil_passwd_hash( cred , hash );
+ tmp = lutil_passwd_hash( cred , hash );
#if defined( SLAPD_CRYPT ) || defined( SLAPD_SPASSWD )
ldap_pvt_thread_mutex_unlock( &passwd_mutex );
#endif
+ *new = *tmp;
+ free( tmp );
- return new;
+ return;
}
LDAP_SLAPD_F (int) attr_merge LDAP_P(( Entry *e,
AttributeDescription *desc,
- struct berval **vals ));
+ BVarray vals ));
LDAP_SLAPD_F (Attribute *) attrs_find LDAP_P((
Attribute *a, AttributeDescription *desc ));
LDAP_SLAPD_F (Attribute *) attr_find LDAP_P((
Entry *target,
struct berval *entry_ndn,
AttributeDescription *entry_at,
- struct berval ***vals
+ BVarray *vals
));
LDAP_SLAPD_F (Attribute *) backend_operational(
LDAP_SLAPD_F (int) charray_strcmp LDAP_P(( const char **a1, const char **a2 ));
LDAP_SLAPD_F (int) charray_strcasecmp LDAP_P(( const char **a1, const char **a2 ));
-LDAP_SLAPD_F (void) bvarray_add LDAP_P(( struct berval **a, struct berval *bv ));
+LDAP_SLAPD_F (void) bvarray_add LDAP_P(( BVarray *a, struct berval *bv ));
LDAP_SLAPD_F (void) bvarray_free LDAP_P(( struct berval *a ));
LDAP_SLAPD_F (char *) slap_strcopy LDAP_P((
* extended.c
*/
-typedef int (*SLAP_EXTOP_MAIN_FN) LDAP_P((
+typedef int (SLAP_EXTOP_MAIN_FN) LDAP_P((
Connection *conn, Operation *op,
const char * reqoid,
struct berval * reqdata,
struct berval ** rspdata,
LDAPControl *** rspctrls,
const char ** text,
- struct berval *** refs ));
+ BVarray *refs ));
-typedef int (*SLAP_EXTOP_GETOID_FN) LDAP_P((
+typedef int (SLAP_EXTOP_GETOID_FN) LDAP_P((
int index, char *oid, int blen ));
LDAP_SLAPD_F (int) load_extension LDAP_P((
LDAP_SLAPD_F (int) load_extop LDAP_P((
const char *ext_oid,
- SLAP_EXTOP_MAIN_FN ext_main ));
+ SLAP_EXTOP_MAIN_FN *ext_main ));
LDAP_SLAPD_F (int) extops_init LDAP_P(( void ));
LDAP_SLAPD_F( void ) slap_mods_free( Modifications *mods );
LDAP_SLAPD_F( void ) slap_modlist_free( LDAPModList *ml );
+LDAP_SLAPD_F( int ) slap_mods_check(
+ Modifications *ml,
+ int update,
+ const char **text,
+ char *textbuf, size_t textlen );
+
LDAP_SLAPD_F( int ) slap_modlist2mods(
LDAPModList *ml,
int update,
LDAP_SLAPD_F (int) validate_global_referral LDAP_P((
const char *url ));
-LDAP_SLAPD_F (struct berval **) get_entry_referrals LDAP_P((
+LDAP_SLAPD_F (BVarray) get_entry_referrals LDAP_P((
Backend *be, Connection *conn, Operation *op, Entry *e ));
-LDAP_SLAPD_F (struct berval **) referral_rewrite LDAP_P((
- struct berval **refs,
+LDAP_SLAPD_F (BVarray) referral_rewrite LDAP_P((
+ BVarray refs,
struct berval *base,
struct berval *target,
int scope ));
LDAP_SLAPD_F (void) send_ldap_result LDAP_P((
Connection *conn, Operation *op,
ber_int_t err, const char *matched, const char *text,
- struct berval **refs,
+ BVarray refs,
LDAPControl **ctrls ));
LDAP_SLAPD_F (void) send_ldap_sasl LDAP_P((
Connection *conn, Operation *op,
ber_int_t err, const char *matched,
const char *text,
- struct berval **refs,
+ BVarray refs,
LDAPControl **ctrls,
struct berval *cred ));
LDAP_SLAPD_F (void) send_ldap_extended LDAP_P((
Connection *conn, Operation *op,
ber_int_t err, const char *matched,
- const char *text, struct berval **refs,
+ const char *text, BVarray refs,
const char *rspoid, struct berval *rspdata,
LDAPControl **ctrls ));
LDAP_SLAPD_F (void) send_search_result LDAP_P((
Connection *conn, Operation *op,
ber_int_t err, const char *matched, const char *text,
- struct berval **refs,
+ BVarray refs,
LDAPControl **ctrls,
int nentries ));
LDAP_SLAPD_F (int) send_search_reference LDAP_P((
Backend *be, Connection *conn, Operation *op,
- Entry *e, struct berval **refs,
+ Entry *e, BVarray refs,
LDAPControl **ctrls,
- struct berval ***v2refs ));
+ BVarray *v2refs ));
LDAP_SLAPD_F (int) send_search_entry LDAP_P((
Backend *be, Connection *conn, Operation *op,
*/
LDAP_SLAPD_F( int ) oc_check_allowed(
AttributeType *type,
- struct berval **oclist,
+ BVarray oclist,
ObjectClass *sc );
LDAP_SLAPD_F( int ) structural_class(
- struct berval **ocs,
+ BVarray ocs,
struct berval *scbv,
const char **text,
char *textbuf, size_t textlen );
/*
* starttls.c
*/
-
-LDAP_SLAPD_F (int) starttls_extop LDAP_P((
- Connection *conn, Operation *op,
- const char * reqoid,
- struct berval * reqdata,
- char ** rspoid,
- struct berval ** rspdata,
- LDAPControl ***rspctrls,
- const char ** text,
- struct berval *** refs ));
+LDAP_SLAPD_F (SLAP_EXTOP_MAIN_FN) starttls_extop;
/*
LDAP_SLAPD_F (int) value_find_ex LDAP_P((
AttributeDescription *ad,
unsigned flags,
- struct berval **values,
+ BVarray values,
struct berval *value ));
LDAP_SLAPD_F (int) value_add LDAP_P((
- struct berval ***vals,
- struct berval **addvals ));
+ BVarray *vals,
+ BVarray addvals ));
/*
* user.c
/*
* passwd.c
*/
-LDAP_SLAPD_F (int) passwd_extop LDAP_P((
- Connection *conn, Operation *op,
- const char * reqoid,
- struct berval * reqdata,
- char ** rspoid,
- struct berval ** rspdata,
- LDAPControl *** rspctrls,
- const char ** text,
- struct berval *** refs ));
+LDAP_SLAPD_F (SLAP_EXTOP_MAIN_FN) passwd_extop;
LDAP_SLAPD_F (int) slap_passwd_check(
Connection *conn,
Attribute *attr,
struct berval *cred );
-LDAP_SLAPD_F (struct berval *) slap_passwd_generate( void );
+LDAP_SLAPD_F (void) slap_passwd_generate( struct berval * );
-LDAP_SLAPD_F (struct berval *) slap_passwd_hash(
- struct berval *cred );
+LDAP_SLAPD_F (void) slap_passwd_hash(
+ struct berval *cred,
+ struct berval *hash );
LDAP_SLAPD_F (struct berval *) slap_passwd_return(
struct berval *cred );
LDAP_SLAPD_F (int) slap_passwd_parse(
struct berval *reqdata,
- struct berval **id,
- struct berval **oldpass,
- struct berval **newpass,
+ struct berval *id,
+ struct berval *oldpass,
+ struct berval *newpass,
const char **text );
/*
LDAP_SLAPD_V (slap_mask_t) global_requires;
LDAP_SLAPD_V (slap_ssf_set_t) global_ssf_set;
-LDAP_SLAPD_V (struct berval **) default_referral;
+LDAP_SLAPD_V (BVarray) default_referral;
LDAP_SLAPD_V (char *) replogfile;
LDAP_SLAPD_V (const char) Versionstr[];
LDAP_SLAPD_V (struct slap_limits_set) deflimit;
return rc;
}
-struct berval ** referral_rewrite(
- struct berval **in,
+BVarray referral_rewrite(
+ BVarray in,
struct berval *base,
struct berval *target,
int scope )
{
- int i, j;
- struct berval **refs;
+ int i;
+ BVarray refs;
+ struct berval *iv, *jv;
if( in == NULL ) return NULL;
- for( i=0; in[i] != NULL ; i++ ) {
+ for( i=0; in[i].bv_val != NULL ; i++ ) {
/* just count them */
}
if( i < 1 ) return NULL;
- refs = ch_malloc( (i+1) * sizeof( struct berval * ) );
+ refs = ch_malloc( (i+1) * sizeof( struct berval ) );
- for( i=0,j=0; in[i] != NULL ; i++ ) {
+ for( iv=in,jv=refs; iv->bv_val != NULL ; iv++ ) {
LDAPURLDesc *url;
- int rc = ldap_url_parse_ext( in[i]->bv_val, &url );
+ int rc = ldap_url_parse_ext( iv->bv_val, &url );
if( rc == LDAP_URL_ERR_BADSCHEME ) {
- refs[j++] = ber_bvdup( in[i] );
+ ber_dupbv( jv++, iv );
continue;
} else if( rc != LDAP_URL_SUCCESS ) {
url->lud_scope = scope;
}
- refs[j] = ch_malloc( sizeof( struct berval ) );
-
- refs[j]->bv_val = ldap_url_desc2str( url );
- refs[j]->bv_len = strlen( refs[j]->bv_val );
+ jv->bv_val = ldap_url_desc2str( url );
+ jv->bv_len = strlen( jv->bv_val );
ldap_free_urldesc( url );
- j++;
+ jv++;
}
- if( j == 0 ) {
+ if( jv == refs ) {
ch_free( refs );
refs = NULL;
} else {
- refs[j] = NULL;
+ jv->bv_val = NULL;
}
return refs;
}
-struct berval **get_entry_referrals(
+BVarray get_entry_referrals(
Backend *be,
Connection *conn,
Operation *op,
Entry *e )
{
Attribute *attr;
- struct berval **refs;
- unsigned i, j;
+ BVarray refs;
+ unsigned i;
+ struct berval *iv, *jv;
AttributeDescription *ad_ref = slap_schema.si_ad_ref;
if( attr == NULL ) return NULL;
- for( i=0; attr->a_vals[i] != NULL; i++ ) {
+ for( i=0; attr->a_vals[i].bv_val != NULL; i++ ) {
/* count references */
}
if( i < 1 ) return NULL;
- refs = ch_malloc( (i + 1) * sizeof(struct berval *));
+ refs = ch_malloc( (i + 1) * sizeof(struct berval));
- for( i=0, j=0; attr->a_vals[i] != NULL; i++ ) {
+ for( iv=attr->a_vals, jv=refs; iv->bv_val != NULL; iv++ ) {
unsigned k;
- struct berval *ref = ber_bvdup( attr->a_vals[i] );
+ ber_dupbv( jv, iv );
/* trim the label */
- for( k=0; k<ref->bv_len; k++ ) {
- if( isspace(ref->bv_val[k]) ) {
- ref->bv_val[k] = '\0';
- ref->bv_len = k;
+ for( k=0; k<jv->bv_len; k++ ) {
+ if( isspace(jv->bv_val[k]) ) {
+ jv->bv_val[k] = '\0';
+ jv->bv_len = k;
break;
}
}
- if( ref->bv_len > 0 ) {
- refs[j++] = ref;
-
+ if( jv->bv_len > 0 ) {
+ jv++;
} else {
- ber_bvfree( ref );
+ free( jv->bv_val );
}
}
- if( j == 0 ) {
- ber_bvecfree( refs );
+ if( jv == refs ) {
+ free( refs );
refs = NULL;
} else {
- refs[j] = NULL;
+ jv->bv_val = NULL;
}
/* we should check that a referral value exists... */
ml = change;
for ( ; ml != NULL; ml = ml->sml_next ) {
char *type;
+ struct berval *bv;
type = ml->sml_desc->ad_cname.bv_val;
switch ( ml->sml_op ) {
case LDAP_MOD_ADD:
break;
}
- for ( i = 0; ml->sml_bvalues != NULL &&
- ml->sml_bvalues[i] != NULL; i++ )
+ for ( bv = ml->sml_bvalues; bv && bv->bv_val; bv++ )
{
char *buf, *bufp;
len = ml->sml_desc->ad_cname.bv_len;
len = LDIF_SIZE_NEEDED( len,
- ml->sml_bvalues[i]->bv_len ) + 1;
+ bv->bv_len ) + 1;
buf = (char *) ch_malloc( len );
bufp = buf;
ldif_sput( &bufp, LDIF_PUT_VALUE, type,
- ml->sml_bvalues[i]->bv_val,
- ml->sml_bvalues[i]->bv_len );
+ bv->bv_val, bv->bv_len );
*bufp = '\0';
fputs( buf, fp );
#include "slap.h"
-static char *v2ref( struct berval **ref, const char *text )
+static char *v2ref( BVarray ref, const char *text )
{
size_t len = 0, i = 0;
char *v2;
strcpy( v2+len, "Referral:" );
len += sizeof("Referral:");
- for( i=0; ref[i] != NULL; i++ ) {
- v2 = ch_realloc( v2, len + ref[i]->bv_len + 1 );
+ for( i=0; ref[i].bv_val != NULL; i++ ) {
+ v2 = ch_realloc( v2, len + ref[i].bv_len + 1 );
v2[len-1] = '\n';
- AC_MEMCPY(&v2[len], ref[i]->bv_val, ref[i]->bv_len );
- len += ref[i]->bv_len;
- if (ref[i]->bv_val[ref[i]->bv_len-1] != '/') {
+ AC_MEMCPY(&v2[len], ref[i].bv_val, ref[i].bv_len );
+ len += ref[i].bv_len;
+ if (ref[i].bv_val[ref[i].bv_len-1] != '/') {
++len;
}
}
ber_int_t err,
const char *matched,
const char *text,
- struct berval **ref,
+ BVarray ref,
const char *resoid,
struct berval *resdata,
struct berval *sasldata,
LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
"send_ldap_response: conn %d ref=\"%s\"\n",
conn ? conn->c_connid : 0,
- ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL" ));
+ ref[0].bv_val ? ref[0].bv_val : "NULL" ));
#else
Debug( LDAP_DEBUG_ARGS, "send_ldap_response: ref=\"%s\"\n",
- ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL",
+ ref[0].bv_val ? ref[0].bv_val : "NULL",
NULL, NULL );
#endif
if( rc != -1 ) {
if ( ref != NULL ) {
assert( err == LDAP_REFERRAL );
- rc = ber_printf( ber, "t{V}",
+ rc = ber_printf( ber, "t{W}",
LDAP_TAG_REFERRAL, ref );
} else {
assert( err != LDAP_REFERRAL );
ber_int_t err,
const char *matched,
const char *text,
- struct berval **ref,
+ BVarray ref,
LDAPControl **ctrls
)
{
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
"send_ldap_result: referral=\"%s\"\n",
- ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL" ));
+ ref[0].bv_val ? ref[0].bv_val : "NULL" ));
#else
Debug( LDAP_DEBUG_ARGS,
"send_ldap_result: referral=\"%s\"\n",
- ref[0] && ref[0]->bv_val ? ref[0]->bv_val : "NULL",
+ ref[0].bv_val ? ref[0].bv_val : "NULL",
NULL, NULL );
#endif
}
ber_int_t err,
const char *matched,
const char *text,
- struct berval **ref,
+ BVarray ref,
LDAPControl **ctrls,
struct berval *cred
)
ber_int_t err,
const char *matched,
const char *text,
- struct berval **refs,
+ BVarray refs,
const char *rspoid,
struct berval *rspdata,
LDAPControl **ctrls
ber_int_t err,
const char *matched,
const char *text,
- struct berval **refs,
+ BVarray refs,
LDAPControl **ctrls,
int nentries
)
}
if ( ! attrsonly ) {
- for ( i = 0; a->a_vals[i] != NULL; i++ ) {
+ for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
if ( ! access_allowed( be, conn, op, e,
- desc, a->a_vals[i], ACL_READ ) )
+ desc, &a->a_vals[i], ACL_READ ) )
{
#ifdef NEW_LOGGING
LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
continue;
}
- if (( rc = ber_printf( ber, "O", a->a_vals[i] )) == -1 ) {
+ if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
"send_search_entry: conn %d ber_printf failed.\n",
}
if ( ! attrsonly ) {
- for ( i = 0; a->a_vals[i] != NULL; i++ ) {
+ for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
if ( ! access_allowed( be, conn, op, e,
- desc, a->a_vals[i], ACL_READ ) )
+ desc, &a->a_vals[i], ACL_READ ) )
{
#ifdef NEW_LOGGING
LDAP_LOG(( "acl", LDAP_LEVEL_INFO,
}
- if (( rc = ber_printf( ber, "O", a->a_vals[i] )) == -1 ) {
+ if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
"send_search_entry: conn %d ber_printf failed\n",
Connection *conn,
Operation *op,
Entry *e,
- struct berval **refs,
+ BVarray refs,
LDAPControl **ctrls,
- struct berval ***v2refs
+ BVarray *v2refs
)
{
char berbuf[256];
if( op->o_protocol < LDAP_VERSION3 ) {
/* save the references for the result */
- if( *refs != NULL ) {
+ if( refs[0].bv_val != NULL ) {
value_add( v2refs, refs );
}
return 0;
ber_init_w_nullc( ber, LBER_USE_DER );
- rc = ber_printf( ber, "{it{V}N}", op->o_msgid,
+ rc = ber_printf( ber, "{it{W}N}", op->o_msgid,
LDAP_RES_SEARCH_REFERENCE, refs );
if ( rc == -1 ) {
{
char buf[BUFSIZ];
Entry *e;
- struct berval val;
- struct berval *vals[2];
+ struct berval vals[2];
int i, j;
char ** supportedSASLMechanisms;
Attribute *a;
- vals[0] = &val;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
e->e_private = NULL;
- val.bv_val = "OpenLDAProotDSE";
- val.bv_len = sizeof("OpenLDAProotDSE")-1;
+ vals[0].bv_val = "OpenLDAProotDSE";
+ vals[0].bv_len = sizeof("OpenLDAProotDSE")-1;
attr_merge( e, ad_structuralObjectClass, vals );
- val.bv_val = "top";
- val.bv_len = sizeof("top")-1;
+ vals[0].bv_val = "top";
+ vals[0].bv_len = sizeof("top")-1;
attr_merge( e, ad_objectClass, vals );
- val.bv_val = "OpenLDAProotDSE";
- val.bv_len = sizeof("OpenLDAProotDSE")-1;
+ vals[0].bv_val = "OpenLDAProotDSE";
+ vals[0].bv_len = sizeof("OpenLDAProotDSE")-1;
attr_merge( e, ad_objectClass, vals );
for ( i = 0; i < nbackends; i++ ) {
if ( backends[i].be_glueflags & SLAP_GLUE_SUBORDINATE )
continue;
for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) {
- val = *backends[i].be_suffix[j];
+ vals[0] = *backends[i].be_suffix[j];
attr_merge( e, ad_namingContexts, vals );
}
}
/* supportedControl */
for ( i=0; supportedControls[i] != NULL; i++ ) {
- val.bv_val = supportedControls[i];
- val.bv_len = strlen( val.bv_val );
+ vals[0].bv_val = supportedControls[i];
+ vals[0].bv_len = strlen( vals[0].bv_val );
attr_merge( e, ad_supportedControl, vals );
}
/* supportedExtension */
- for ( i=0; (val.bv_val = get_supported_extop(i)) != NULL; i++ ) {
- val.bv_len = strlen( val.bv_val );
+ for ( i=0; (vals[0].bv_val = get_supported_extop(i)) != NULL; i++ ) {
+ vals[0].bv_len = strlen( vals[0].bv_val );
attr_merge( e, ad_supportedExtension, vals );
}
/* supportedFeatures */
for ( i=0; supportedFeatures[i] != NULL; i++ ) {
- val.bv_val = supportedFeatures[i];
- val.bv_len = strlen( val.bv_val );
+ vals[0].bv_val = supportedFeatures[i];
+ vals[0].bv_len = strlen( vals[0].bv_val );
attr_merge( e, ad_supportedFeatures, vals );
}
continue;
}
sprintf(buf,"%d",i);
- val.bv_val = buf;
- val.bv_len = strlen( val.bv_val );
+ vals[0].bv_val = buf;
+ vals[0].bv_len = strlen( vals[0].bv_val );
attr_merge( e, ad_supportedLDAPVersion, vals );
}
if( supportedSASLMechanisms != NULL ) {
for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
- val.bv_val = supportedSASLMechanisms[i];
- val.bv_len = strlen( val.bv_val );
+ vals[0].bv_val = supportedSASLMechanisms[i];
+ vals[0].bv_len = strlen( vals[0].bv_val );
attr_merge( e, ad_supportedSASLMechanisms, vals );
}
charray_free( supportedSASLMechanisms );
{
const char *errmsg;
int i, rc;
- struct berval **vals=NULL;
+ BVarray vals=NULL;
AttributeDescription *ad=NULL;
struct berval bv;
goto COMPLETE;
/* Check if the *assertDN matches any **vals */
- for( i=0; vals[i] != NULL; i++ ) {
- rc = slap_sasl_match( vals[i]->bv_val, assertDN+3, authc );
+ for( i=0; vals[i].bv_val != NULL; i++ ) {
+ rc = slap_sasl_match( vals[i].bv_val, assertDN+3, authc );
if ( rc == LDAP_SUCCESS )
goto COMPLETE;
}
rc = LDAP_INAPPROPRIATE_AUTH;
COMPLETE:
- if( vals ) ber_bvecfree( vals );
+ if( vals ) bvarray_free( vals );
#ifdef NEW_LOGGING
LDAP_LOG(( "sasl", LDAP_LEVEL_ENTRY,
= slap_schema.si_ad_objectClass;
Entry *e;
- struct berval val;
- struct berval *vals[2];
+ struct berval vals[2];
- vals[0] = &val;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
(void) dnNormalize2( NULL, &e->e_name, &e->e_nname );
e->e_private = NULL;
- val.bv_val = "LDAPsubentry";
- val.bv_len = sizeof("LDAPsubentry")-1;
+ vals[0].bv_val = "LDAPsubentry";
+ vals[0].bv_len = sizeof("LDAPsubentry")-1;
attr_merge( e, ad_structuralObjectClass, vals );
- val.bv_val = "top";
- val.bv_len = sizeof("top")-1;
+ vals[0].bv_val = "top";
+ vals[0].bv_len = sizeof("top")-1;
attr_merge( e, ad_objectClass, vals );
- val.bv_val = "LDAPsubentry";
- val.bv_len = sizeof("LDAPsubentry")-1;
+ vals[0].bv_val = "LDAPsubentry";
+ vals[0].bv_len = sizeof("LDAPsubentry")-1;
attr_merge( e, ad_objectClass, vals );
- val.bv_val = "subschema";
- val.bv_len = sizeof("subschema")-1;
+ vals[0].bv_val = "subschema";
+ vals[0].bv_len = sizeof("subschema")-1;
attr_merge( e, ad_objectClass, vals );
- val.bv_val = "extensibleObject";
- val.bv_len = sizeof("extensibleObject")-1;
+ vals[0].bv_val = "extensibleObject";
+ vals[0].bv_len = sizeof("extensibleObject")-1;
attr_merge( e, ad_objectClass, vals );
{
AttributeDescription *desc = NULL;
struct berval rdn = { sizeof(SLAPD_SCHEMA_DN)-1,
SLAPD_SCHEMA_DN };
- val.bv_val = strchr( rdn.bv_val, '=' );
+ vals[0].bv_val = strchr( rdn.bv_val, '=' );
- if( val.bv_val == NULL ) {
+ if( vals[0].bv_val == NULL ) {
*text = "improperly configured subschema subentry";
return LDAP_OTHER;
}
- val.bv_val++;
- val.bv_len = rdn.bv_len - (val.bv_val - rdn.bv_val);
- rdn.bv_len -= val.bv_len + 1;
+ vals[0].bv_val++;
+ vals[0].bv_len = rdn.bv_len - (vals[0].bv_val - rdn.bv_val);
+ rdn.bv_len -= vals[0].bv_len + 1;
rc = slap_bv2ad( &rdn, &desc, text );
return LDAP_SUCCESS;
}
#endif
-
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
/* there should be at least one value */
assert( a->a_vals );
- assert( a->a_vals[0] != NULL );
+ assert( a->a_vals[0].bv_val != NULL );
/* if single value type, check for multiple values */
if( is_at_single_value( a->a_desc->ad_type ) &&
- a->a_vals[1] != NULL )
+ a->a_vals[1].bv_val != NULL )
{
char *type = a->a_desc->ad_cname.bv_val;
}
assert( asc->a_vals != NULL );
- assert( asc->a_vals[0] != NULL );
- assert( asc->a_vals[1] == NULL );
+ assert( asc->a_vals[0].bv_val != NULL );
+ assert( asc->a_vals[1].bv_val == NULL );
- sc = oc_bvfind( asc->a_vals[0] );
+ sc = oc_bvfind( &asc->a_vals[0] );
if( sc == NULL ) {
snprintf( textbuf, textlen,
"unrecognized structuralObjectClass '%s'",
- aoc->a_vals[0]->bv_val );
+ aoc->a_vals[0].bv_val );
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_INFO,
if( sc->soc_kind != LDAP_SCHEMA_STRUCTURAL ) {
snprintf( textbuf, textlen,
"structuralObjectClass '%s' is not STRUCTURAL",
- aoc->a_vals[0]->bv_val );
+ aoc->a_vals[0].bv_val );
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_INFO,
}
assert( aoc->a_vals != NULL );
- assert( aoc->a_vals[0] != NULL );
+ assert( aoc->a_vals[0].bv_val != NULL );
rc = structural_class( aoc->a_vals, &nsc, text, textbuf, textlen );
if( rc != LDAP_SUCCESS ) {
if ( oc == NULL ) {
snprintf( textbuf, textlen,
"unrecognized objectClass '%s'",
- aoc->a_vals[i]->bv_val );
+ aoc->a_vals[i].bv_val );
return LDAP_OBJECT_CLASS_VIOLATION;
} else if ( sc != oc ) {
snprintf( textbuf, textlen,
"structuralObjectClass modification from '%s' to '%s' not allowed",
- asc->a_vals[0]->bv_val, nsc.bv_val );
+ asc->a_vals[0].bv_val, nsc.bv_val );
return LDAP_NO_OBJECT_CLASS_MODS;
}
/* check that the entry has required attrs for each oc */
- for ( i = 0; aoc->a_vals[i] != NULL; i++ ) {
- if ( (oc = oc_bvfind( aoc->a_vals[i] )) == NULL ) {
+ for ( i = 0; aoc->a_vals[i].bv_val != NULL; i++ ) {
+ if ( (oc = oc_bvfind( &aoc->a_vals[i] )) == NULL ) {
snprintf( textbuf, textlen,
"unrecognized objectClass '%s'",
- aoc->a_vals[i]->bv_val );
+ aoc->a_vals[i].bv_val );
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_INFO,
{
int j;
ObjectClass *xc = NULL;
- for( j=0; aoc->a_vals[j]; j++ ) {
+ for( j=0; aoc->a_vals[j].bv_val; j++ ) {
if( i != j ) {
- xc = oc_bvfind( aoc->a_vals[i] );
+ xc = oc_bvfind( &aoc->a_vals[i] );
if( xc == NULL ) {
snprintf( textbuf, textlen,
"unrecognized objectClass '%s'",
- aoc->a_vals[i]->bv_val );
+ aoc->a_vals[i].bv_val );
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_INFO,
if( xc == NULL ) {
snprintf( textbuf, textlen, "instanstantiation of "
"abstract objectClass '%s' not allowed",
- aoc->a_vals[i]->bv_val );
+ aoc->a_vals[i].bv_val );
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_INFO,
}
} else if ( oc->soc_kind != LDAP_SCHEMA_STRUCTURAL || oc == sc ) {
- char *s = oc_check_required( e, oc, aoc->a_vals[i] );
+ char *s = oc_check_required( e, oc, &aoc->a_vals[i] );
if (s != NULL) {
snprintf( textbuf, textlen,
"object class '%s' requires attribute '%s'",
- aoc->a_vals[i]->bv_val, s );
+ aoc->a_vals[i].bv_val, s );
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_INFO,
int oc_check_allowed(
AttributeType *at,
- struct berval **ocl,
+ BVarray ocl,
ObjectClass *sc )
{
int i, j;
}
/* check that the type appears as req or opt in at least one oc */
- for ( i = 0; ocl[i] != NULL; i++ ) {
+ for ( i = 0; ocl[i].bv_val != NULL; i++ ) {
/* if we know about the oc */
- ObjectClass *oc = oc_bvfind( ocl[i] );
+ ObjectClass *oc = oc_bvfind( &ocl[i] );
if ( oc != NULL && oc->soc_kind != LDAP_SCHEMA_ABSTRACT &&
( sc == NULL || oc->soc_kind == LDAP_SCHEMA_AUXILIARY ))
{
* Determine the structural object class from a set of OIDs
*/
int structural_class(
- struct berval **ocs,
+ BVarray ocs,
struct berval *scbv,
const char **text,
char *textbuf, size_t textlen )
*text = "structural_class: internal error";
scbv->bv_len = 0;
- for( i=0; ocs[i]; i++ ) {
- oc = oc_bvfind( ocs[i] );
+ for( i=0; ocs[i].bv_val; i++ ) {
+ oc = oc_bvfind( &ocs[i] );
if( oc == NULL ) {
snprintf( textbuf, textlen,
"unrecongized objectClass '%s'",
- ocs[i]->bv_val );
+ ocs[i].bv_val );
*text = textbuf;
return LDAP_OBJECT_CLASS_VIOLATION;
}
ObjectClass *xc = NULL;
/* find common superior */
- for( j=i+1; ocs[j]; j++ ) {
- xc = oc_bvfind( ocs[j] );
+ for( j=i+1; ocs[j].bv_val; j++ ) {
+ xc = oc_bvfind( &ocs[j] );
if( xc == NULL ) {
snprintf( textbuf, textlen,
"unrecongized objectClass '%s'",
- ocs[i]->bv_val );
+ ocs[i].bv_val );
*text = textbuf;
return LDAP_OBJECT_CLASS_VIOLATION;
}
/* no common subclass */
snprintf( textbuf, textlen,
"invalid structural object class chain (%s/%s)",
- ocs[scn]->bv_val, ocs[i]->bv_val );
+ ocs[scn].bv_val, ocs[i].bv_val );
*text = textbuf;
return LDAP_OBJECT_CLASS_VIOLATION;
}
return LDAP_OBJECT_CLASS_VIOLATION;
}
- *scbv = *ocs[scn];
+ *scbv = ocs[scn];
return LDAP_SUCCESS;
}
return LDAP_OBJECT_CLASS_VIOLATION;
}
- if( ocmod->sml_bvalues == NULL || ocmod->sml_bvalues[0] == NULL ) {
+ if( ocmod->sml_bvalues == NULL || ocmod->sml_bvalues[0].bv_val == NULL ) {
*text = "objectClass attribute has no values";
return LDAP_OBJECT_CLASS_VIOLATION;
}
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keysp )
+ BVarray values,
+ BVarray *keysp )
{
int i;
size_t slen, mlen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval digest;
digest.bv_val = HASHdigest;
digest.bv_len = sizeof(HASHdigest);
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* just count them */
}
slen = syntax->ssyn_oidlen;
mlen = mr->smr_oidlen;
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
HASH_Init( &HASHcontext );
if( prefix != NULL && prefix->bv_len > 0 ) {
HASH_Update( &HASHcontext,
HASH_Update( &HASHcontext,
mr->smr_oid, mlen );
HASH_Update( &HASHcontext,
- values[i]->bv_val, values[i]->bv_len );
+ values[i].bv_val, values[i].bv_len );
HASH_Final( HASHdigest, &HASHcontext );
ber_dupbv( &keys[i], &digest );
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keysp )
+ BVarray *keysp )
{
size_t slen, mlen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval *value = (struct berval *) assertValue;
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keysp )
+ BVarray values,
+ BVarray *keysp )
{
char *val, *c;
int i,j, len, wordcount, keycount=0;
- struct berval *newkeys, *keys=NULL;
+ struct berval *newkeys;
+ BVarray keys=NULL;
- for( j=0; values[j] != NULL; j++ ) {
+ for( j=0; values[j].bv_val != NULL; j++ ) {
/* Yes, this is necessary */
- val = UTF8normalize( values[j], UTF8_NOCASEFOLD );
+ val = UTF8normalize( &values[j], UTF8_NOCASEFOLD );
strip8bitChars( val );
/* Isolate how many words there are. There will be a key for each */
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keysp )
+ BVarray *keysp )
{
char *val, *c;
int i, count, len;
- struct berval *keys;
+ BVarray keys;
/* Yes, this is necessary */
val = UTF8normalize( ((struct berval *)assertValue),
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keysp )
+ BVarray values,
+ BVarray *keysp )
{
int i;
- struct berval *keys;
+ BVarray *keys;
char *s;
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* empty - just count them */
}
keys = (struct berval *)ch_malloc( sizeof( struct berval ) * (i+1) );
/* Copy each value and run it through phonetic() */
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* Yes, this is necessary */
- s = UTF8normalize( values[i], UTF8_NOCASEFOLD );
+ s = UTF8normalize( &values[i], UTF8_NOCASEFOLD );
/* strip 8-bit chars and run through phonetic() */
ber_str2bv( phonetic( strip8bitChars( s ) ), 0, 0, &keys[i] );
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keysp )
+ BVarray *keysp )
{
- struct berval *keys;
+ BVarray keys;
char *s;
keys = (struct berval *)ch_malloc( sizeof( struct berval * ) * 2 );
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keysp )
+ BVarray values,
+ BVarray *keysp )
{
int i;
char casefold;
size_t slen, mlen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval digest;
digest.bv_val = HASHdigest;
digest.bv_len = sizeof(HASHdigest);
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* empty - just count them */
}
casefold = strcmp( mr->smr_oid, caseExactMatchOID )
? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
struct berval value;
- ber_str2bv( UTF8normalize( values[i], casefold ), 0, 0,
+ ber_str2bv( UTF8normalize( &values[i], casefold ), 0, 0,
&value );
HASH_Init( &HASHcontext );
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keysp )
+ BVarray *keysp )
{
char casefold;
size_t slen, mlen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval value;
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keysp )
+ BVarray values,
+ BVarray *keysp )
{
char casefold;
ber_len_t i, nkeys;
size_t slen, mlen;
- struct berval *keys;
- struct berval **nvalues;
+ BVarray keys;
+ BVarray nvalues;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
nkeys=0;
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* empty - just count them */
}
casefold = strcmp( mr->smr_oid, caseExactSubstringsMatchOID )
? UTF8_CASEFOLD : UTF8_NOCASEFOLD;
- nvalues = ch_malloc( sizeof( struct berval * ) * (i+1) );
- for( i=0; values[i] != NULL; i++ ) {
- nvalues[i] = ber_str2bv( UTF8normalize( values[i], casefold ),
- 0, 0, NULL );
+ nvalues = ch_malloc( sizeof( struct berval ) * (i+1) );
+ for( i=0; values[i].bv_val != NULL; i++ ) {
+ ber_str2bv( UTF8normalize( &values[i], casefold ),
+ 0, 0, &nvalues[i] );
}
- nvalues[i] = NULL;
+ nvalues[i].bv_val = NULL;
values = nvalues;
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* count number of indices to generate */
- if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
+ if( values[i].bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
continue;
}
if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
} else {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+ nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
}
}
if( flags & SLAP_INDEX_SUBSTR_ANY ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
+ if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
}
}
if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
} else {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+ nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
}
}
}
if( nkeys == 0 ) {
/* no keys to generate */
*keysp = NULL;
- ber_bvecfree( nvalues );
+ bvarray_free( nvalues );
return LDAP_SUCCESS;
}
mlen = mr->smr_oidlen;
nkeys=0;
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
ber_len_t j,max;
- if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
+ if( values[i].bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
- ( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
+ ( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
{
char pre = SLAP_INDEX_SUBSTR_PREFIX;
- max = values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1);
+ max = values[i].bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1);
for( j=0; j<max; j++ ) {
HASH_Init( &HASHcontext );
HASH_Update( &HASHcontext,
mr->smr_oid, mlen );
HASH_Update( &HASHcontext,
- &values[i]->bv_val[j],
+ &values[i].bv_val[j],
SLAP_INDEX_SUBSTR_MAXLEN );
HASH_Final( HASHdigest, &HASHcontext );
}
}
- max = SLAP_INDEX_SUBSTR_MAXLEN < values[i]->bv_len
- ? SLAP_INDEX_SUBSTR_MAXLEN : values[i]->bv_len;
+ max = SLAP_INDEX_SUBSTR_MAXLEN < values[i].bv_len
+ ? SLAP_INDEX_SUBSTR_MAXLEN : values[i].bv_len;
for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) {
char pre;
HASH_Update( &HASHcontext,
mr->smr_oid, mlen );
HASH_Update( &HASHcontext,
- values[i]->bv_val, j );
+ values[i].bv_val, j );
HASH_Final( HASHdigest, &HASHcontext );
ber_dupbv( &keys[nkeys++], &digest );
HASH_Update( &HASHcontext,
mr->smr_oid, mlen );
HASH_Update( &HASHcontext,
- &values[i]->bv_val[values[i]->bv_len-j], j );
+ &values[i].bv_val[values[i].bv_len-j], j );
HASH_Final( HASHdigest, &HASHcontext );
ber_dupbv( &keys[nkeys++], &digest );
*keysp = NULL;
}
- ber_bvecfree( nvalues );
+ bvarray_free( nvalues );
return LDAP_SUCCESS;
}
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keysp )
+ BVarray *keysp )
{
SubstringsAssertion *sa;
char pre, casefold;
ber_len_t nkeys = 0;
size_t slen, mlen, klen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval *value;
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keysp )
+ BVarray values,
+ BVarray *keysp )
{
int i;
- struct berval *keys;
+ BVarray keys;
/* we should have at least one value at this point */
- assert( values != NULL && values[0] != NULL );
+ assert( values != NULL && values[0].bv_val != NULL );
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* empty -- just count them */
}
keys = ch_malloc( sizeof( struct berval ) * (i+1) );
- for( i=0; values[i] != NULL; i++ ) {
- integerNormalize( syntax, values[i], &keys[i] );
+ for( i=0; values[i].bv_val != NULL; i++ ) {
+ integerNormalize( syntax, &values[i], &keys[i] );
}
keys[i].bv_val = NULL;
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keysp )
+ BVarray *keysp )
{
- struct berval *keys;
+ BVarray keys;
keys = ch_malloc( sizeof( struct berval ) * 2 );
integerNormalize( syntax, assertValue, &keys[0] );
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keysp )
+ BVarray values,
+ BVarray *keysp )
{
int i;
size_t slen, mlen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval digest;
digest.bv_val = HASHdigest;
digest.bv_len = sizeof(HASHdigest);
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* empty - just count them */
}
slen = syntax->ssyn_oidlen;
mlen = mr->smr_oidlen;
- for( i=0; values[i] != NULL; i++ ) {
- struct berval *value = values[i];
+ for( i=0; values[i].bv_val != NULL; i++ ) {
+ struct berval *value = &values[i];
HASH_Init( &HASHcontext );
if( prefix != NULL && prefix->bv_len > 0 ) {
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keysp )
+ BVarray *keysp )
{
size_t slen, mlen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval *value;
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keysp )
+ BVarray values,
+ BVarray *keysp )
{
ber_len_t i, nkeys;
size_t slen, mlen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval digest;
digest.bv_len = sizeof(HASHdigest);
/* we should have at least one value at this point */
- assert( values != NULL && values[0] != NULL );
+ assert( values != NULL && values[0].bv_val != NULL );
nkeys=0;
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* count number of indices to generate */
- if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
+ if( values[i].bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
continue;
}
if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
} else {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+ nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
}
}
if( flags & SLAP_INDEX_SUBSTR_ANY ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
+ if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
}
}
if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
} else {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+ nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
}
}
}
mlen = mr->smr_oidlen;
nkeys=0;
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
ber_len_t j,max;
struct berval *value;
- value = values[i];
+ value = &values[i];
if( value->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keysp )
+ BVarray *keysp )
{
SubstringsAssertion *sa = assertValue;
char pre;
ber_len_t nkeys = 0;
size_t slen, mlen, klen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval *value;
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keysp )
+ BVarray values,
+ BVarray *keysp )
{
int i;
size_t slen, mlen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval digest;
digest.bv_len = sizeof(HASHdigest);
/* we should have at least one value at this point */
- assert( values != NULL && values[0] != NULL );
+ assert( values != NULL && values[0].bv_val != NULL );
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* just count them */
}
slen = syntax->ssyn_oidlen;
mlen = mr->smr_oidlen;
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
struct berval value;
- ber_dupbv( &value, values[i] );
+ ber_dupbv( &value, &values[i] );
ldap_pvt_str2upper( value.bv_val );
HASH_Init( &HASHcontext );
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keysp )
+ BVarray *keysp )
{
size_t slen, mlen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval value;
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keysp )
+ BVarray values,
+ BVarray *keysp )
{
ber_len_t i, nkeys;
size_t slen, mlen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval digest;
digest.bv_len = sizeof(HASHdigest);
/* we should have at least one value at this point */
- assert( values != NULL && values[0] != NULL );
+ assert( values != NULL && values[0].bv_val != NULL );
nkeys=0;
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* count number of indices to generate */
- if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
+ if( values[i].bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
continue;
}
if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
} else {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+ nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
}
}
if( flags & SLAP_INDEX_SUBSTR_ANY ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
+ if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
}
}
if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( values[i].bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
} else {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+ nkeys += values[i].bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
}
}
}
mlen = mr->smr_oidlen;
nkeys=0;
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
int j,max;
struct berval value;
- if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
+ if( values[i].bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
- ber_dupbv( &value, values[i] );
+ ber_dupbv( &value, &values[i] );
ldap_pvt_str2upper( value.bv_val );
if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keysp )
+ BVarray *keysp )
{
SubstringsAssertion *sa = assertValue;
char pre;
ber_len_t nkeys = 0;
size_t slen, mlen, klen;
- struct berval *keys;
+ BVarray keys;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
struct berval value;
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keysp )
+ BVarray values,
+ BVarray *keysp )
{
int i;
- struct berval *keys;
+ BVarray keys;
X509 *xcert;
unsigned char *p;
struct berval * serial;
/* we should have at least one value at this point */
- assert( values != NULL && values[0] != NULL );
+ assert( values != NULL && values[0].bv_val != NULL );
- for( i=0; values[i] != NULL; i++ ) {
+ for( i=0; values[i].bv_val != NULL; i++ ) {
/* empty -- just count them */
}
keys = ch_malloc( sizeof( struct berval ) * (i+1) );
- for( i=0; values[i] != NULL; i++ ) {
- p = values[i]->bv_val;
- xcert = d2i_X509(NULL, &p, values[i]->bv_len);
+ for( i=0; values[i].bv_val != NULL; i++ ) {
+ p = values[i].bv_val;
+ xcert = d2i_X509(NULL, &p, values[i].bv_len);
if ( !xcert ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
MatchingRule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keysp )
+ BVarray *keysp )
{
- struct berval *keys;
+ BVarray keys;
struct berval *asserted_serial;
struct berval *asserted_issuer_dn;
* if we don't hold it.
*/
if ( (be = select_backend( &nbase, manageDSAit, 1 )) == NULL ) {
- struct berval **ref = referral_rewrite( default_referral,
+ BVarray ref = referral_rewrite( default_referral,
NULL, &pbase, scope );
send_ldap_result( conn, op, rc = LDAP_REFERRAL,
NULL, NULL, ref ? ref : default_referral, NULL );
- ber_bvecfree( ref );
+ bvarray_free( ref );
goto return_results;
}
if ( be->be_search ) {
(*be->be_search)( be, conn, op, &pbase, &nbase,
scope, deref, sizelimit,
- timelimit, filter, fstr.bv_val, al, attrsonly );
+ timelimit, filter, &fstr, al, attrsonly );
} else {
send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
NULL, "operation not supported within namingContext", NULL, NULL );
#include "slap.h"
#include "sets.h"
-static char **set_join (char **lset, int op, char **rset);
-static char **set_chase (SET_GATHER gatherer,
- void *cookie, char **set, char *attr, int attrlen, int closure);
+static BVarray set_join (BVarray lset, int op, BVarray rset);
+static BVarray set_chase (SET_GATHER gatherer,
+ void *cookie, BVarray set, struct berval *attr, int closure);
static int set_samedn (char *dn1, char *dn2);
long
-set_size (char **set)
+set_size (BVarray set)
{
int i;
i = 0;
if (set != NULL) {
- while (set[i])
+ while (set[i].bv_val)
i++;
}
return(i);
}
void
-set_dispose (char **set)
+set_dispose (BVarray set)
{
- int i;
-
- if (set != NULL) {
- for (i = 0; set[i]; i++)
- ch_free(set[i]);
- ch_free(set);
- }
+ bvarray_free(set);
}
-static char **
-set_join (char **lset, int op, char **rset)
+static BVarray
+set_join (BVarray lset, int op, BVarray rset)
{
- char **set;
+ BVarray set;
long i, j, last;
set = NULL;
if (op == '|') {
- if (lset == NULL || *lset == NULL) {
+ if (lset == NULL || lset->bv_val == NULL) {
if (rset == NULL) {
if (lset == NULL)
- return(ch_calloc(1, sizeof(char *)));
+ return(ch_calloc(1, sizeof(struct berval)));
return(lset);
}
set_dispose(lset);
return(rset);
}
- if (rset == NULL || *rset == NULL) {
+ if (rset == NULL || rset->bv_val == NULL) {
set_dispose(rset);
return(lset);
}
i = set_size(lset) + set_size(rset) + 1;
- set = ch_calloc(i, sizeof(char *));
+ set = ch_calloc(i, sizeof(struct berval));
if (set != NULL) {
/* set_chase() depends on this routine to
* keep the first elements of the result
* set the same (and in the same order)
* as the left-set.
*/
- for (i = 0; lset[i]; i++)
+ for (i = 0; lset[i].bv_val; i++)
set[i] = lset[i];
ch_free(lset);
- for (i = 0; rset[i]; i++) {
- for (j = 0; set[j]; j++) {
- if (set_samedn(rset[i], set[j])) {
- ch_free(rset[i]);
- rset[i] = NULL;
+ for (i = 0; rset[i].bv_val; i++) {
+ for (j = 0; set[j].bv_val; j++) {
+ if (set_samedn(rset[i].bv_val, set[j].bv_val)) {
+ ch_free(rset[i].bv_val);
+ rset[i].bv_val = NULL;
break;
}
}
- if (rset[i])
+ if (rset[i].bv_val)
set[j] = rset[i];
}
ch_free(rset);
}
if (op == '&') {
- if (lset == NULL || *lset == NULL || rset == NULL || *rset == NULL) {
- set = ch_calloc(1, sizeof(char *));
+ if (lset == NULL || lset->bv_val == NULL || rset == NULL || rset->bv_val == NULL) {
+ set = ch_calloc(1, sizeof(struct berval));
} else {
set = lset;
lset = NULL;
last = set_size(set) - 1;
- for (i = 0; set[i]; i++) {
- for (j = 0; rset[j]; j++) {
- if (set_samedn(set[i], rset[j]))
+ for (i = 0; set[i].bv_val; i++) {
+ for (j = 0; rset[j].bv_val; j++) {
+ if (set_samedn(set[i].bv_val, rset[j].bv_val))
break;
}
- if (rset[j] == NULL) {
- ch_free(set[i]);
+ if (rset[j].bv_val == NULL) {
+ ch_free(set[i].bv_val);
set[i] = set[last];
- set[last] = NULL;
+ set[last].bv_val = NULL;
last--;
i--;
}
return(set);
}
-static char **
+static BVarray
set_chase (SET_GATHER gatherer,
- void *cookie, char **set, char *attr, int attrlen, int closure)
+ void *cookie, BVarray set, struct berval *attr, int closure)
{
- char **vals, **nset;
+ BVarray vals, nset;
char attrstr[32];
- struct berval bv = {attrlen, attrstr};
+ struct berval bv = {attr->bv_len, attrstr};
int i;
if (set == NULL)
- return(ch_calloc(1, sizeof(char *)));
+ return(ch_calloc(1, sizeof(struct berval)));
- if (*set == NULL)
+ if (set->bv_val == NULL)
return(set);
- if (attrlen > (sizeof(attrstr) - 1)) {
+ if (attr->bv_len > (sizeof(attrstr) - 1)) {
set_dispose(set);
return(NULL);
}
- AC_MEMCPY(attrstr, attr, attrlen);
- attrstr[attrlen] = 0;
+ AC_MEMCPY(attrstr, attr->bv_val, attr->bv_len);
+ attrstr[attr->bv_len] = 0;
- nset = ch_calloc(1, sizeof(char *));
+ nset = ch_calloc(1, sizeof(struct berval));
if (nset == NULL) {
set_dispose(set);
return(NULL);
}
- for (i = 0; set[i]; i++) {
- vals = (gatherer)(cookie, set[i], &bv);
+ for (i = 0; set[i].bv_val; i++) {
+ vals = (gatherer)(cookie, set[i].bv_val, &bv);
if (vals != NULL)
nset = set_join(nset, '|', vals);
}
set_dispose(set);
if (closure) {
- for (i = 0; nset[i]; i++) {
- vals = (gatherer)(cookie, nset[i], &bv);
+ for (i = 0; nset[i].bv_val; i++) {
+ vals = (gatherer)(cookie, nset[i].bv_val, &bv);
if (vals != NULL) {
nset = set_join(nset, '|', vals);
if (nset == NULL)
int
set_filter (SET_GATHER gatherer,
- void *cookie, char *filter, char *user, char *this, char ***results)
+ void *cookie, struct berval *fbv, char *user, char *this, BVarray *results)
{
#define IS_SET(x) ( (long)(x) >= 256 )
#define IS_OP(x) ( (long)(x) < 256 )
#define SF_ERROR(x) do { rc = -1; goto _error; } while (0)
-#define SF_TOP() ( (char **)( (stp < 0) ? 0 : stack[stp] ) )
-#define SF_POP() ( (char **)( (stp < 0) ? 0 : stack[stp--] ) )
+#define SF_TOP() ( (BVarray)( (stp < 0) ? 0 : stack[stp] ) )
+#define SF_POP() ( (BVarray)( (stp < 0) ? 0 : stack[stp--] ) )
#define SF_PUSH(x) do { \
if (stp >= 63) SF_ERROR(overflow); \
- stack[++stp] = (char **)(long)(x); \
+ stack[++stp] = (BVarray)(long)(x); \
} while (0)
- char c;
- char **set, **lset;
+ BVarray set, lset;
+ BVarray stack[64];
int len, op, rc, stp;
- char **stack[64];
+ char c, *filter = fbv->bv_val;
if (results)
*results = NULL;
if (c == 0)
SF_ERROR(syntax);
- set = ch_calloc(2, sizeof(char *));
+ set = ch_calloc(2, sizeof(struct berval));
if (set == NULL)
SF_ERROR(memory);
- *set = ch_calloc(len + 1, sizeof(char));
- if (*set == NULL)
+ set->bv_val = ch_calloc(len + 1, sizeof(char));
+ if (set->bv_val == NULL)
SF_ERROR(memory);
- AC_MEMCPY(*set, &filter[-len - 1], len);
+ AC_MEMCPY(set->bv_val, &filter[-len - 1], len);
+ set->bv_len = len;
SF_PUSH(set);
set = NULL;
break;
{
if ((SF_TOP() == (void *)'/') || IS_SET(SF_TOP()))
SF_ERROR(syntax);
- set = ch_calloc(2, sizeof(char *));
+ set = ch_calloc(2, sizeof(struct berval));
if (set == NULL)
SF_ERROR(memory);
- *set = ch_strdup(this);
- if (*set == NULL)
+ ber_str2bv( this, 0, 1, set );
+ if (set->bv_val == NULL)
SF_ERROR(memory);
} else if (len == 4
&& memcmp("user", filter, len) == 0)
{
if ((SF_TOP() == (void *)'/') || IS_SET(SF_TOP()))
SF_ERROR(syntax);
- set = ch_calloc(2, sizeof(char *));
+ set = ch_calloc(2, sizeof(struct berval));
if (set == NULL)
SF_ERROR(memory);
- *set = ch_strdup(user);
- if (*set == NULL)
+ ber_str2bv( user, 0, 1, set );
+ if (set->bv_val == NULL)
SF_ERROR(memory);
} else if (SF_TOP() != (void *)'/') {
SF_ERROR(syntax);
} else {
SF_POP();
+ struct berval fb2;
+ fb2.bv_val = filter;
+ fb2.bv_len = len;
set = set_chase(gatherer,
- cookie, SF_POP(), filter, len, c == '*');
+ cookie, SF_POP(), &fb2, c == '*');
if (set == NULL)
SF_ERROR(memory);
if (c == '*')
* also return the syntax or some "comparison cookie"
* that is used by set_filter.
*/
-typedef char **(*SET_GATHER) (void *cookie, char *name, struct berval *attr);
+typedef BVarray (SET_GATHER) (void *cookie, char *name, struct berval *attr);
-LDAP_SLAPD_F (long) set_size (char **set);
-LDAP_SLAPD_F (void) set_dispose (char **set);
+LDAP_SLAPD_F (long) set_size (BVarray set);
+LDAP_SLAPD_F (void) set_dispose (BVarray set);
LDAP_SLAPD_F (int)
-set_filter (SET_GATHER gatherer, void *cookie, char *filter,
- char *user, char *this, char ***results);
+set_filter (SET_GATHER gatherer, void *cookie, struct berval *filter,
+ char *user, char *this, BVarray *results);
struct slap_syntax *syntax, /* syntax of stored value */
struct slap_matching_rule *mr,
struct berval *prefix,
- struct berval **values,
- struct berval **keys ));
+ BVarray values,
+ BVarray *keys ));
/* Filter index function */
typedef int slap_mr_filter_func LDAP_P((
struct slap_matching_rule *mr,
struct berval *prefix,
void * assertValue,
- struct berval **keys ));
+ BVarray *keys ));
typedef struct slap_matching_rule {
LDAPMatchingRule smr_mrule;
*/
typedef struct slap_attr {
AttributeDescription *a_desc;
- struct berval **a_vals;
+ BVarray a_vals;
struct slap_attr *a_next;
} Attribute;
typedef struct slap_mod {
int sm_op;
AttributeDescription *sm_desc;
- struct berval **sm_bvalues;
+ struct berval sm_type;
+ BVarray sm_bvalues;
} Modification;
typedef struct slap_mod_list {
Modification sml_mod;
#define sml_op sml_mod.sm_op
#define sml_desc sml_mod.sm_desc
+#define sml_type sml_mod.sm_type
#define sml_bvalues sml_mod.sm_bvalues
struct slap_mod_list *sml_next;
} Modifications;
struct slap_replica_info **be_replica; /* replicas of this backend (in master) */
char *be_replogfile; /* replication log file (in master) */
struct berval be_update_ndn; /* allowed to make changes (in replicas) */
- struct berval **be_update_refs; /* where to refer modifying clients to */
+ BVarray be_update_refs; /* where to refer modifying clients to */
char *be_realm;
int be_lastmod; /* keep track of lastmodified{by,time} */
struct berval *base, struct berval *nbase,
int scope, int deref,
int slimit, int tlimit,
- Filter *f, const char *filterstr,
+ Filter *f, struct berval *filterstr,
AttributeName *attrs, int attrsonly));
typedef int (BI_op_compare)LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
struct berval ** rspdata,
LDAPControl *** rspctrls,
const char ** text,
- struct berval *** refs ));
+ BVarray *refs ));
typedef int (BI_entry_release_rw) LDAP_P((BackendDB *bd,
struct slap_conn *c, struct slap_op *o,
struct slap_conn *c, struct slap_op *o,
Entry *e, struct berval *edn,
AttributeDescription *entry_at,
- struct berval ***vals ));
+ BVarray *vals ));
typedef int (BI_operational) LDAP_P((Backend *bd,
struct slap_conn *c, struct slap_op *o,
typedef void (slap_response)( struct slap_conn *, struct slap_op *,
ber_tag_t, ber_int_t, ber_int_t, const char *, const char *,
- struct berval **, const char *, struct berval *,
+ BVarray, const char *, struct berval *,
struct berval *, LDAPControl ** );
typedef void (slap_sresult)( struct slap_conn *, struct slap_op *,
- ber_int_t, const char *, const char *, struct berval **,
+ ber_int_t, const char *, const char *, BVarray,
LDAPControl **, int nentries);
/*
struct berval ** rspdata,
LDAPControl ***rspctrls,
const char ** text,
- struct berval *** refs )
+ BVarray * refs )
{
void *ctx;
int rc;
int
syn_schema_info( Entry *e )
{
- struct berval val;
- struct berval *vals[2];
+ struct berval vals[2];
Syntax *syn;
AttributeDescription *ad_ldapSyntaxes = slap_schema.si_ad_ldapSyntaxes;
- vals[0] = &val;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
for ( syn = syn_list; syn; syn = syn->ssyn_next ) {
if ( ! syn->ssyn_validate ) {
continue;
}
- if ( ldap_syntax2bv( &syn->ssyn_syn, &val ) == NULL ) {
+ if ( ldap_syntax2bv( &syn->ssyn_syn, vals ) == NULL ) {
return -1;
}
#if 0
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
"syn_schema_info: Merging syn [%ld] %s\n",
- (long)val.bv_len, val.bv_val ));
+ (long)vals[0].bv_len, vals[0].bv_val ));
#else
Debug( LDAP_DEBUG_TRACE, "Merging syn [%ld] %s\n",
- (long) val.bv_len, val.bv_val, 0 );
+ (long) vals[0].bv_len, vals[0].bv_val, 0 );
#endif
#endif
attr_merge( e, ad_ldapSyntaxes, vals );
- ldap_memfree( val.bv_val );
+ ldap_memfree( vals[0].bv_val );
}
return 0;
}
ber_int_t err,
const char *matched,
const char *text,
- struct berval **refs,
+ BVarray refs,
const char *rspoid,
struct berval *rspdata,
LDAPControl **ctrls
ber_int_t err,
const char *matched,
const char *text,
- struct berval **refs,
+ BVarray refs,
LDAPControl **ctrls,
struct berval *cred
)
ber_int_t err,
const char *matched,
const char *text,
- struct berval **refs,
+ BVarray refs,
LDAPControl **ctrls
)
{
ber_int_t err,
const char *matched,
const char *text,
- struct berval **refs,
+ BVarray refs,
LDAPControl **ctrls,
int nentries
)
Connection *conn,
Operation *op,
Entry *e,
- struct berval **refs,
+ BVarray refs,
LDAPControl **ctrls,
- struct berval ***v2refs
+ BVarray *v2refs
)
{
assert(0);
}
if( sc == NULL ) {
- struct berval *vals[2];
- struct berval scbv;
+ struct berval vals[2];
int ret = structural_class(
- oc->a_vals, &scbv, &text, textbuf, textlen );
+ oc->a_vals, vals, &text, textbuf, textlen );
- if( scbv.bv_len == 0 ) {
+ if( vals[0].bv_len == 0 ) {
fprintf( stderr, "%s: dn=\"%s\" (line=%d): %s\n",
progname, e->e_dn, lineno, text );
rc = EXIT_FAILURE;
break;
}
- vals[0] = &scbv;
- vals[1] = NULL;
+ vals[1].bv_val = NULL;
attr_merge( e, slap_schema.si_ad_structuralObjectClass,
vals );
}
int
value_add(
- struct berval ***vals,
- struct berval **addvals
+ BVarray *vals,
+ BVarray addvals
)
{
int n, nn, i, j;
+ BVarray v2;
- for ( nn = 0; addvals != NULL && addvals[nn] != NULL; nn++ )
+ for ( nn = 0; addvals != NULL && addvals[nn].bv_val != NULL; nn++ )
; /* NULL */
if ( *vals == NULL ) {
- *vals = (struct berval **) ch_malloc( (nn + 1)
- * sizeof(struct berval *) );
+ *vals = (BVarray) ch_malloc( (nn + 1)
+ * sizeof(struct berval) );
n = 0;
-
} else {
- for ( n = 0; (*vals)[n] != NULL; n++ )
+ for ( n = 0; (*vals)[n].bv_val != NULL; n++ )
; /* NULL */
- *vals = (struct berval **) ch_realloc( (char *) *vals,
- (n + nn + 1) * sizeof(struct berval *) );
+ *vals = (BVarray) ch_realloc( (char *) *vals,
+ (n + nn + 1) * sizeof(struct berval) );
}
- for ( i = 0, j = 0; i < nn; i++ ) {
- (*vals)[n + j] = ber_bvdup( addvals[i] );
- if( (*vals)[n + j++] == NULL ) break;
+ v2 = *vals + n;
+ for ( ; addvals->bv_val; v2++, addvals++ ) {
+ ber_dupbv(v2, addvals);
+ if (v2->bv_val == NULL) break;
}
- (*vals)[n + j] = NULL;
+ v2->bv_val = NULL;
+ v2->bv_len = 0;
return LDAP_SUCCESS;
}
int value_find_ex(
AttributeDescription *ad,
unsigned flags,
- struct berval **vals,
+ BVarray vals,
struct berval *val )
{
int i;
}
}
- for ( i = 0; vals[i] != NULL; i++ ) {
+ for ( i = 0; vals[i].bv_val != NULL; i++ ) {
int match;
const char *text;
rc = value_match( &match, ad, mr, flags,
- vals[i], nval.bv_val == NULL ? val : &nval, &text );
+ &vals[i], nval.bv_val == NULL ? val : &nval, &text );
if( rc == LDAP_SUCCESS && match == 0 ) {
free( nval.bv_val );