ber_dupbv LDAP_P((
struct berval *dst, LDAP_CONST struct berval *src ));
-#define ber_bvdup(bv) ber_dupbv(NULL, bv)
+LBER_F( struct berval * )
+ber_bvdup LDAP_P((
+ LDAP_CONST struct berval *src ));
LBER_F( struct berval * )
ber_str2bv LDAP_P((
return new;
}
+
+struct berval *
+ber_bvdup(
+ LDAP_CONST struct berval *src )
+{
+ return ber_dupbv( NULL, src );
+}
+
+
struct berval *
ber_str2bv(
LDAP_CONST char *s, ber_len_t len, int dup, struct berval *bv)
}
if ( e == NULL ) {
- struct berval *matched_dn = NULL;
+ struct berval matched_dn = { 0, NULL };
BVarray refs = NULL;
if ( matched != NULL ) {
BVarray erefs;
- matched_dn = ber_bvdup( &matched->e_name );
+
+ ber_dupbv( &matched_dn, &matched->e_name );
erefs = is_entry_referral( matched )
? get_entry_referrals( be, conn, op, matched )
matched = NULL;
if( erefs ) {
- refs = referral_rewrite( erefs, matched_dn,
+ refs = referral_rewrite( erefs, &matched_dn,
base, scope );
bvarray_free( erefs );
}
}
send_ldap_result( conn, op, rc=LDAP_REFERRAL ,
- matched_dn ? matched_dn->bv_val : NULL, text, refs, NULL );
+ matched_dn.bv_val, text, refs, NULL );
if ( refs ) bvarray_free( refs );
- if ( matched_dn ) ber_bvfree( matched_dn );
+ if ( matched_dn.bv_val ) ber_memfree( matched_dn.bv_val );
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 matched_dn;
+
+ ber_dupbv( &matched_dn, &e->e_name );
BVarray erefs = get_entry_referrals( be, conn, op, e );
BVarray refs = NULL;
e = NULL;
if( erefs ) {
- refs = referral_rewrite( erefs, matched_dn,
+ refs = referral_rewrite( erefs, &matched_dn,
base, scope );
bvarray_free( erefs );
}
0, 0, 0 );
send_ldap_result( conn, op, LDAP_REFERRAL,
- matched_dn->bv_val,
+ matched_dn.bv_val,
refs ? NULL : "bad referral object",
refs, NULL );
bvarray_free( refs );
- ber_bvfree( matched_dn );
+ ber_memfree( matched_dn.bv_val );
return 1;
}
}
if ( e == NULL ) {
- struct berval *matched_dn = NULL;
+ struct berval matched_dn = { 0, NULL };
BVarray refs = NULL;
if ( matched != NULL ) {
BVarray erefs;
- matched_dn = ber_bvdup( &matched->e_name );
+ ber_dupbv( &matched_dn, &matched->e_name );
erefs = is_entry_referral( matched )
? get_entry_referrals( be, conn, op, matched )
cache_return_entry_r( &li->li_cache, matched );
if( erefs ) {
- refs = referral_rewrite( erefs, matched_dn,
+ refs = referral_rewrite( erefs, &matched_dn,
base, scope );
bvarray_free( erefs );
NULL, base, scope );
}
- send_ldap_result( conn, op, err,
- matched_dn ? matched_dn->bv_val : NULL,
+ send_ldap_result( conn, op, err, matched_dn.bv_val,
text, refs, NULL );
bvarray_free( refs );
- ber_bvfree( matched_dn );
+ ber_memfree( matched_dn.bv_val );
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 matched_dn;
+
+ ber_dupbv( &matched_dn, &e->e_name );
BVarray erefs = get_entry_referrals( be, conn, op, e );
BVarray refs = NULL;
#endif
if( erefs ) {
- refs = referral_rewrite( erefs, matched_dn,
+ refs = referral_rewrite( erefs, &matched_dn,
base, scope );
bvarray_free( erefs );
if( refs ) {
send_ldap_result( conn, op, LDAP_REFERRAL,
- matched_dn->bv_val, NULL, refs, NULL );
+ matched_dn.bv_val, NULL, refs, NULL );
bvarray_free( refs );
} else {
send_ldap_result( conn, op, LDAP_OTHER,
- matched_dn->bv_val,
+ matched_dn.bv_val,
"bad referral object", NULL, NULL );
}
- ber_bvfree( matched_dn );
+ ber_memfree( matched_dn.bv_val );
return 1;
}
#define META_CANDIDATE 1
LDAP *ld;
- struct berval *bound_dn;
+ struct berval bound_dn;
int bound;
#define META_UNBOUND 0
#define META_BOUND 1
if ( rc != LDAP_SUCCESS ) {
rc = ldap_back_map_result( rc );
} else {
- lc->conns[ candidate ]->bound_dn = ber_bvdup( dn );
+ ber_dupbv( &lc->conns[ candidate ]->bound_dn, dn );
lc->conns[ candidate ]->bound = META_BOUND;
lc->bound_target = candidate;
* (note: if the target was already bound, the anonymous
* bind clears the previous bind).
*/
- rc = ldap_bind_s( lsc[ 0 ]->ld, lsc[ 0 ]->bound_dn->bv_val,
+ rc = ldap_bind_s( lsc[ 0 ]->ld, lsc[ 0 ]->bound_dn.bv_val,
NULL, LDAP_AUTH_SIMPLE );
if ( rc != LDAP_SUCCESS ) {
"meta_back_dobind: (anonymous)"
" bind as \"%s\" failed"
" with error \"%s\"\n",
- lsc[ 0 ]->bound_dn->bv_val,
+ lsc[ 0 ]->bound_dn.bv_val,
ldap_err2string( rc ) ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ANY,
"==>meta_back_dobind: (anonymous)"
" bind as \"%s\" failed"
" with error \"%s\"\n%s",
- lsc[ 0 ]->bound_dn->bv_val,
+ lsc[ 0 ]->bound_dn.bv_val,
ldap_err2string( rc ), "" );
#endif /* !NEW_LOGGING */
lsc->ld = NULL;
}
- if ( lsc->bound_dn != NULL ) {
- ber_bvfree( lsc->bound_dn );
- lsc->bound_dn = NULL;
+ if ( lsc->bound_dn.bv_val != NULL ) {
+ ber_memfree( lsc->bound_dn.bv_val );
+ lsc->bound_dn.bv_val = NULL;
+ lsc->bound_dn.bv_len = 0;
}
return 0;
* If the connection dn is not null, an attempt to rewrite it is made
*/
if ( conn->c_cdn != 0 ) {
- char *mdn = NULL;
/*
* Rewrite the bind dn if needed
*/
- lsc->bound_dn = NULL;
+ lsc->bound_dn.bv_val = NULL;
switch ( rewrite_session( lt->rwinfo, "bindDn",
- conn->c_cdn, conn, &mdn ) ) {
+ conn->c_cdn, conn,
+ &lsc->bound_dn.bv_val ) ) {
case REWRITE_REGEXEC_OK:
- if ( mdn == NULL ) {
- lsc->bound_dn = ber_bvstrdup( conn->c_cdn );
+ if ( lsc->bound_dn.bv_val == NULL ) {
+ ber_str2bv( conn->c_cdn, 0, 1, &lsc->bound_dn );
}
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
"[rw] bindDn: \"%s\" -> \"%s\"\n",
- conn->c_cdn, lsc->bound_dn->bv_val ));
+ conn->c_cdn, lsc->bound_dn.bv_val ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> bindDn: \"%s\" -> \"%s\"\n",
- conn->c_cdn, lsc->bound_dn->bv_val, 0 );
+ conn->c_cdn, lsc->bound_dn.bv_val, 0 );
#endif /* !NEW_LOGGING */
break;
return LDAP_OPERATIONS_ERROR;
}
- if ( mdn ) {
- lsc->bound_dn = ber_bvstr( mdn );
- } else {
- lsc->bound_dn = ber_bvstrdup( "" );
- }
+ assert( lsc->bound_dn.bv_val );
} else {
- lsc->bound_dn = ber_bvstrdup( "" );
+ ber_str2bv( "", 0, 1, &lsc->bound_dn );
}
lsc->bound = META_UNBOUND;
if ( lsc[ 0 ]->ld != NULL ) {
ldap_unbind( lsc[ 0 ]->ld );
}
- if ( lsc[ 0 ]->bound_dn ) {
- ber_bvfree( lsc[ 0 ]->bound_dn );
+ if ( lsc[ 0 ]->bound_dn.bv_val ) {
+ ber_memfree( lsc[ 0 ]->bound_dn.bv_val );
}
free( lsc[ 0 ] );
}
return -1;
}
- ber_bvecadd( &be->be_suffix, ber_bvdup( &dn ) );
+ ber_bvecadd( &be->be_suffix, ber_dupbv( NULL, &dn ) );
ber_bvecadd( &be->be_nsuffix, ndn );
mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
struct berval *in )
{
int rc;
- struct berval *dn;
+ struct berval dn;
if( in->bv_len == 0 ) return LDAP_SUCCESS;
- dn = ber_bvdup( in );
- if( !dn ) return LDAP_OTHER;
+ ber_dupbv( &dn, in );
+ if( !dn.bv_val ) return LDAP_OTHER;
- if( dn->bv_val[dn->bv_len-1] == 'B'
- && dn->bv_val[dn->bv_len-2] == '\'' )
+ if( dn.bv_val[dn.bv_len-1] == 'B'
+ && dn.bv_val[dn.bv_len-2] == '\'' )
{
/* assume presence of optional UID */
ber_len_t i;
- for(i=dn->bv_len-3; i>1; i--) {
- if( dn->bv_val[i] != '0' && dn->bv_val[i] != '1' ) {
+ for(i=dn.bv_len-3; i>1; i--) {
+ if( dn.bv_val[i] != '0' && dn.bv_val[i] != '1' ) {
break;
}
}
- if( dn->bv_val[i] != '\'' ||
- dn->bv_val[i-1] != '#' ) {
- ber_bvfree( dn );
+ if( dn.bv_val[i] != '\'' ||
+ dn.bv_val[i-1] != '#' ) {
+ ber_memfree( dn.bv_val );
return LDAP_INVALID_SYNTAX;
}
/* trim the UID to allow use of dnValidate */
- dn->bv_val[i-1] = '\0';
- dn->bv_len = i-1;
+ dn.bv_val[i-1] = '\0';
+ dn.bv_len = i-1;
}
- rc = dnValidate( NULL, dn );
+ rc = dnValidate( NULL, &dn );
- ber_bvfree( dn );
+ ber_memfree( &dn );
return rc;
}
bv.bv_len = end-begin+1;
bv.bv_val = begin;
- *serial = ber_bvdup(&bv);
+ *serial = ber_dupbv(NULL, &bv);
/* now extract the issuer, remember p was at the dollar sign */
begin = p+1;
#define FLAG_GETDN_AUTHCID 2
#define FLAG_GETDN_AUTHZID 4
-
LDAP_END_DECL
#include "proto-slap.h"