More struct berval conversions

This commit is contained in:
Howard Chu 2002-01-01 13:31:20 +00:00
parent dc4fe01758
commit affa8f5a65
16 changed files with 137 additions and 177 deletions

View file

@ -25,7 +25,7 @@ ldbm_back_add(
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
char *pdn;
struct berval pdn;
Entry *p = NULL;
int rootlock = 0;
int rc;
@ -45,7 +45,7 @@ ldbm_back_add(
/* nobody else can add until we lock our parent */
ldap_pvt_thread_mutex_lock(&li->li_add_mutex);
if ( ( rc = dn2id( be, e->e_ndn, &id ) ) || id != NOID ) {
if ( ( rc = dn2id( be, &e->e_nname, &id ) ) || id != NOID ) {
/* if (rc) something bad happened to ldbm cache */
ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
send_ldap_result( conn, op,
@ -80,15 +80,17 @@ ldbm_back_add(
* add the entry.
*/
pdn = dn_parent( be, e->e_ndn );
pdn.bv_val = dn_parent( be, e->e_ndn );
if (pdn.bv_val && pdn.bv_val[0])
pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_ndn);
else
pdn.bv_len = 0;
if( pdn != NULL && *pdn != '\0' ) {
if( pdn.bv_len ) {
Entry *matched = NULL;
assert( *pdn != '\0' );
/* get parent with writer lock */
if ( (p = dn2entry_w( be, pdn, &matched )) == NULL ) {
if ( (p = dn2entry_w( be, &pdn, &matched )) == NULL ) {
char *matched_dn = NULL;
struct berval **refs;
@ -198,8 +200,8 @@ ldbm_back_add(
}
} else {
if(pdn != NULL) {
assert( *pdn == '\0' );
if(pdn.bv_val != NULL) {
assert( *pdn.bv_val == '\0' );
}
/* no parent, must be adding entry to root */
@ -239,11 +241,11 @@ ldbm_back_add(
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
"ldbm_back_add: %s add denied.\n",
pdn == NULL ? "suffix"
pdn.bv_val == NULL ? "suffix"
: "entry at root" ));
#else
Debug( LDAP_DEBUG_TRACE, "%s add denied\n",
pdn == NULL ? "suffix"
pdn.bv_val == NULL ? "suffix"
: "entry at root", 0, 0 );
#endif
@ -340,7 +342,7 @@ ldbm_back_add(
}
/* dn2id index */
if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) {
if ( dn2id_add( be, &e->e_nname, e->e_id ) != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
"ldbm_back_add: dn2id_add failed.\n" ));
@ -367,7 +369,7 @@ ldbm_back_add(
#endif
/* FIXME: delete attr indices? */
(void) dn2id_delete( be, e->e_ndn, e->e_id );
(void) dn2id_delete( be, &e->e_nname, e->e_id );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "entry store failed", NULL, NULL );

View file

@ -14,19 +14,21 @@
#include "proto-back-ldbm.h"
static char* get_alias_dn(
static int get_alias_dn(
Entry *e,
struct berval *al,
int *err,
const char **errmsg );
static char* new_superior(
const char *dn,
const char *oldSup,
const char *newSup );
static void new_superior(
struct berval *dn,
struct berval *oldSup,
struct berval *newSup,
struct berval *res );
static int dnlist_subordinate(
char** dnlist,
const char *dn );
BVarray dnlist,
struct berval *dn );
Entry *deref_internal_r(
Backend* be,
@ -36,12 +38,12 @@ Entry *deref_internal_r(
Entry** matched,
const char** text )
{
char *dn;
struct berval dn;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
Entry *entry;
Entry *sup;
unsigned depth;
char **dnlist;
BVarray dnlist;
assert( ( alias != NULL && dn_in == NULL )
|| ( alias == NULL && dn_in != NULL ) );
@ -51,22 +53,22 @@ Entry *deref_internal_r(
*text = NULL;
if( alias == NULL ) {
dn = ch_strdup( dn_in->bv_val );
entry = dn2entry_r( be, dn, &sup );
ber_dupbv( &dn, dn_in );
entry = dn2entry_r( be, &dn, &sup );
} else {
dn = ch_strdup( alias->e_ndn );
ber_dupbv( &dn, &alias->e_nname );
entry = alias;
sup = NULL;
}
dnlist = NULL;
charray_add( &dnlist, dn );
bvarray_add( &dnlist, &dn );
for( depth=0 ; ; depth++ ) {
if( entry != NULL ) {
Entry *newe;
char *aliasDN;
struct berval aliasDN;
/* have entry, may be an alias */
@ -85,17 +87,15 @@ Entry *deref_internal_r(
}
/* deref entry */
aliasDN = get_alias_dn( entry, err, text );
if( aliasDN == NULL ) {
if( get_alias_dn( entry, &aliasDN, err, text )) {
*matched = entry;
entry = NULL;
break;
}
/* check if aliasDN is a subordinate of any DN in our list */
if( dnlist_subordinate( dnlist, aliasDN ) ) {
ch_free( aliasDN );
if( dnlist_subordinate( dnlist, &aliasDN ) ) {
ch_free( aliasDN.bv_val );
*matched = entry;
entry = NULL;
*err = LDAP_ALIAS_PROBLEM;
@ -105,15 +105,15 @@ Entry *deref_internal_r(
/* attempt to dereference alias */
newe = dn2entry_r( be, aliasDN, &sup );
ch_free( aliasDN );
newe = dn2entry_r( be, &aliasDN, &sup );
ch_free( aliasDN.bv_val );
if( newe != NULL ) {
free( dn );
free( dn.bv_val );
cache_return_entry_r(&li->li_cache, entry );
entry = newe;
dn = ch_strdup( entry->e_ndn );
charray_add( &dnlist, dn );
ber_dupbv( &dn, &entry->e_nname );
bvarray_add( &dnlist, &dn );
continue;
}
@ -130,8 +130,8 @@ Entry *deref_internal_r(
/* have superior, may be an alias */
Entry *newe;
Entry *newSup;
char *supDN;
char *aliasDN;
struct berval supDN;
struct berval aliasDN;
if( !is_entry_alias( sup ) ) {
/* entry is not an alias */
@ -150,27 +150,17 @@ Entry *deref_internal_r(
}
/* deref entry */
supDN = get_alias_dn( sup, err, text );
if( supDN == NULL ) {
if( get_alias_dn( sup, &supDN, err, text )) {
*matched = sup;
break;
}
aliasDN = new_superior( dn, sup->e_ndn, supDN );
free(supDN);
if( aliasDN == NULL ) {
free(aliasDN);
*matched = sup;
*err = LDAP_ALIAS_PROBLEM;
*text = "superior alias problem";
break;
}
new_superior( &dn, &sup->e_nname, &supDN, &aliasDN );
free(supDN.bv_val);
/* check if aliasDN is a subordinate of any DN in our list */
if( dnlist_subordinate( dnlist, aliasDN ) ) {
free(aliasDN);
if( dnlist_subordinate( dnlist, &aliasDN ) ) {
free(aliasDN.bv_val);
*matched = entry;
entry = NULL;
*err = LDAP_ALIAS_PROBLEM;
@ -179,24 +169,23 @@ Entry *deref_internal_r(
}
/* attempt to dereference alias */
newe = dn2entry_r( be, aliasDN, &newSup );
newe = dn2entry_r( be, &aliasDN, &newSup );
if( newe != NULL ) {
free(aliasDN);
free( dn );
free(aliasDN.bv_val);
free( dn.bv_val );
cache_return_entry_r(&li->li_cache, sup );
entry = newe;
dn = ch_strdup( entry->e_ndn );
charray_add( &dnlist, dn );
ber_dupbv( &dn, &entry->e_nname );
bvarray_add( &dnlist, &dn );
continue;
}
if ( newSup != NULL ) {
free( dn );
free( dn.bv_val );
cache_return_entry_r(&li->li_cache, sup );
sup = newSup;
dn = aliasDN;
ber_dupbv( &dn, &aliasDN );
continue;
}
@ -208,19 +197,19 @@ Entry *deref_internal_r(
}
}
free( dn );
charray_free( dnlist );
free( dn.bv_val );
bvarray_free( dnlist );
return entry;
}
static char* get_alias_dn(
static int get_alias_dn(
Entry *e,
struct berval *ndn,
int *err,
const char **errmsg )
{
int rc;
struct berval ndn;
Attribute *a;
AttributeDescription *aliasedObjectName
= slap_schema.si_ad_aliasedObjectName;
@ -233,7 +222,7 @@ static char* get_alias_dn(
*/
*err = LDAP_ALIAS_PROBLEM;
*errmsg = "alias missing aliasedObjectName attribute";
return NULL;
return -1;
}
/*
@ -245,60 +234,58 @@ static char* get_alias_dn(
*/
*err = LDAP_ALIAS_PROBLEM;
*errmsg = "alias missing aliasedObjectName value";
return NULL;
return -1;
}
if( a->a_vals[1] != NULL ) {
*err = LDAP_ALIAS_PROBLEM;
*errmsg = "alias has multivalued aliasedObjectName";
return NULL;
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";
return NULL;
return -1;
}
return ndn.bv_val;
return 0;
}
static char* new_superior(
const char *dn,
const char *oldSup,
const char *newSup )
static void new_superior(
struct berval *dn,
struct berval *oldSup,
struct berval *newSup,
struct berval *newDN )
{
char *newDN;
size_t dnlen, olen, nlen;
assert( dn && oldSup && newSup );
assert( dn && oldSup && newSup && newDN );
dnlen = strlen( dn );
olen = strlen( oldSup );
nlen = strlen( newSup );
dnlen = dn->bv_len;
olen = oldSup->bv_len;
nlen = newSup->bv_len;
newDN = ch_malloc( dnlen - olen + nlen + 1 );
newDN->bv_val = ch_malloc( dnlen - olen + nlen + 1 );
AC_MEMCPY( newDN, dn, dnlen - olen );
AC_MEMCPY( &newDN[dnlen - olen], newSup, nlen );
newDN[dnlen - olen + nlen] = '\0';
AC_MEMCPY( newDN->bv_val, dn->bv_val, dnlen - olen );
AC_MEMCPY( &newDN->bv_val[dnlen - olen], newSup->bv_val, nlen );
newDN->bv_val[dnlen - olen + nlen] = '\0';
return newDN;
return;
}
static int dnlist_subordinate(
char** dnlist,
const char *dn )
BVarray dnlist,
struct berval *dn )
{
int i;
assert( dnlist );
for( i = 0; dnlist[i] != NULL; i++ ) {
if( dn_issuffix( dnlist[i], dn ) ) {
for( ; dnlist->bv_val != NULL; dnlist++ ) {
if( dnIsSuffix( dnlist, dn ) ) {
return 1;
}
}
return 0;
}

View file

@ -74,7 +74,7 @@ ldbm_back_attribute(
} else {
/* can we find entry with reader lock */
if ((e = dn2entry_r(be, entry_ndn->bv_val, NULL )) == NULL) {
if ((e = dn2entry_r(be, entry_ndn, NULL )) == NULL) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"ldbm_back_attribute: cannot find entry (%s)\n",

View file

@ -54,7 +54,7 @@ ldbm_back_bind(
dn = ndn;
/* get entry with reader lock */
if ( (e = dn2entry_r( be, dn->bv_val, &matched )) == NULL ) {
if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
char *matched_dn = NULL;
struct berval **refs = NULL;

View file

@ -563,41 +563,11 @@ cache_update_entry(
return( 0 );
}
/*
* cache_find_entry_dn2id - find an entry in the cache, given dn
*/
ID
cache_find_entry_dn2id(
Backend *be,
Cache *cache,
const char *dn
)
{
int rc;
struct berval bv;
struct berval ndn;
ID id;
bv.bv_val = (char *)dn;
bv.bv_len = strlen( dn );
rc = dnNormalize2( NULL, &bv, &ndn );
if( rc != LDAP_SUCCESS ) {
return NOID;
}
id = cache_find_entry_ndn2id( be, cache, ndn.bv_val );
free( ndn.bv_val );
return ( id );
}
ID
cache_find_entry_ndn2id(
Backend *be,
Cache *cache,
const char *ndn
struct berval *ndn
)
{
Entry e, *ep;
@ -605,7 +575,7 @@ cache_find_entry_ndn2id(
int count = 0;
/* this function is always called with normalized DN */
e.e_ndn = (char *)ndn;
e.e_nname = *ndn;
try_again:
/* set cache mutex */

View file

@ -34,7 +34,7 @@ ldbm_back_compare(
int manageDSAit = get_manageDSAit( op );
/* get entry with reader lock */
if ( (e = dn2entry_r( be, ndn->bv_val, &matched )) == NULL ) {
if ( (e = dn2entry_r( be, ndn, &matched )) == NULL ) {
char *matched_dn = NULL;
struct berval **refs = NULL;

View file

@ -27,7 +27,7 @@ ldbm_back_delete(
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
Entry *matched;
char *pdn = NULL;
struct berval pdn;
Entry *e, *p = NULL;
int rootlock = 0;
int rc = -1;
@ -42,7 +42,7 @@ ldbm_back_delete(
#endif
/* get entry with writer lock */
if ( (e = dn2entry_w( be, ndn->bv_val, &matched )) == NULL ) {
if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) {
char *matched_dn = NULL;
struct berval **refs;
@ -115,8 +115,9 @@ ldbm_back_delete(
}
/* delete from parent's id2children entry */
if( (pdn = dn_parent( be, e->e_ndn )) != NULL && pdn[ 0 ] != '\0' ) {
if( (p = dn2entry_w( be, pdn, NULL )) == NULL) {
if( (pdn.bv_val = dn_parent( be, e->e_ndn )) != NULL && pdn.bv_val[ 0 ] != '\0' ) {
pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_ndn);
if( (p = dn2entry_w( be, &pdn, NULL )) == NULL) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
"ldbm_back_delete: parent of (%s) does not exist\n", dn ));
@ -201,7 +202,7 @@ ldbm_back_delete(
}
/* delete from dn2id mapping */
if ( dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
if ( dn2id_delete( be, &e->e_nname, e->e_id ) != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
"ldbm_back_delete: (%s) operations error\n",

View file

@ -19,7 +19,7 @@
int
dn2id_add(
Backend *be,
const char *dn,
struct berval *dn,
ID id
)
{
@ -30,9 +30,9 @@ dn2id_add(
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
"dn2id_add: (%s):%ld\n", dn, id ));
"dn2id_add: (%s):%ld\n", dn->bv_val, id ));
#else
Debug( LDAP_DEBUG_TRACE, "=> dn2id_add( \"%s\", %ld )\n", dn, id, 0 );
Debug( LDAP_DEBUG_TRACE, "=> dn2id_add( \"%s\", %ld )\n", dn->bv_val, id, 0 );
#endif
assert( id != NOID );
@ -51,12 +51,12 @@ dn2id_add(
}
ldbm_datum_init( key );
key.dsize = strlen( dn ) + 2;
key.dsize = dn->bv_len + 2;
buf = ch_malloc( key.dsize );
key.dptr = buf;
buf[0] = DN_BASE_PREFIX;
ptr = buf + 1;
strcpy( ptr, dn );
strcpy( ptr, dn->bv_val );
ldbm_datum_init( data );
data.dptr = (char *) &id;
@ -118,7 +118,7 @@ dn2id_add(
int
dn2id(
Backend *be,
const char *dn,
struct berval *dn,
ID *idp
)
{
@ -128,9 +128,9 @@ dn2id(
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
"dn2id: (%s)\n", dn ));
"dn2id: (%s)\n", dn->bv_val ));
#else
Debug( LDAP_DEBUG_TRACE, "=> dn2id( \"%s\" )\n", dn, 0, 0 );
Debug( LDAP_DEBUG_TRACE, "=> dn2id( \"%s\" )\n", dn->bv_val, 0, 0 );
#endif
assert( idp );
@ -167,9 +167,9 @@ dn2id(
ldbm_datum_init( key );
key.dsize = strlen( dn ) + 2;
key.dsize = dn->bv_len + 2;
key.dptr = ch_malloc( key.dsize );
sprintf( key.dptr, "%c%s", DN_BASE_PREFIX, dn );
sprintf( key.dptr, "%c%s", DN_BASE_PREFIX, dn->bv_val );
data = ldbm_cache_fetch( db, key );
@ -264,7 +264,7 @@ dn2idl(
int
dn2id_delete(
Backend *be,
const char *dn,
struct berval *dn,
ID id
)
{
@ -275,9 +275,9 @@ dn2id_delete(
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
"dn2id_delete: (%s)%ld\n", dn, id ));
"dn2id_delete: (%s)%ld\n", dn->bv_val, id ));
#else
Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\", %ld )\n", dn, id, 0 );
Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\", %ld )\n", dn->bv_val, id, 0 );
#endif
@ -298,12 +298,12 @@ dn2id_delete(
}
ldbm_datum_init( key );
key.dsize = strlen( dn ) + 2;
key.dsize = dn->bv_len + 2;
buf = ch_malloc( key.dsize );
key.dptr = buf;
buf[0] = DN_BASE_PREFIX;
ptr = buf + 1;
strcpy( ptr, dn );
strcpy( ptr, dn->bv_val );
rc = ldbm_cache_delete( db, key );
@ -364,22 +364,22 @@ dn2id_delete(
Entry *
dn2entry_rw(
Backend *be,
const char *dn,
struct berval *dn,
Entry **matched,
int rw
)
{
ID id;
Entry *e = NULL;
char *pdn;
struct berval pdn;
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
"dn2entry_rw: %s entry %s\n", rw ? "w" : "r",
dn ));
dn->bv_val ));
#else
Debug(LDAP_DEBUG_TRACE, "dn2entry_%s: dn: \"%s\"\n",
rw ? "w" : "r", dn, 0);
rw ? "w" : "r", dn->bv_val, 0);
#endif
@ -401,11 +401,11 @@ dn2entry_rw(
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
"dn2entry_rw: no entry for valid id (%ld), dn (%s)\n",
id, dn ));
id, dn->bv_val ));
#else
Debug(LDAP_DEBUG_ANY,
"dn2entry_%s: no entry for valid id (%ld), dn \"%s\"\n",
rw ? "w" : "r", id, dn);
rw ? "w" : "r", id, dn->bv_val);
#endif
/* must have been deleted from underneath us */
@ -417,9 +417,10 @@ dn2entry_rw(
/* entry does not exist - see how much of the dn does exist */
/* dn_parent checks returns NULL if dn is suffix */
if ( (pdn = dn_parent( be, dn )) != NULL ) {
if ( (pdn.bv_val = dn_parent( be, dn->bv_val )) != NULL && *pdn.bv_val ) {
pdn.bv_len = dn->bv_len - (pdn.bv_val - dn->bv_val);
/* get entry with reader lock */
if ( (e = dn2entry_r( be, pdn, matched )) != NULL ) {
if ( (e = dn2entry_r( be, &pdn, matched )) != NULL ) {
*matched = e;
}
}

View file

@ -84,7 +84,7 @@ ldbm_back_group(
} else {
/* can we find group entry with reader lock */
if ((e = dn2entry_r(be, gr_ndn->bv_val, NULL )) == NULL) {
if ((e = dn2entry_r(be, gr_ndn, NULL )) == NULL) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
"ldbm_back_group: cannot find group (%s)\n",

View file

@ -268,7 +268,7 @@ ldbm_back_modify(
/* acquire and lock entry */
if ( (e = dn2entry_w( be, ndn->bv_val, &matched )) == NULL ) {
if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) {
char* matched_dn = NULL;
struct berval **refs;

View file

@ -89,7 +89,7 @@ ldbm_back_modrdn(
#endif
/* get entry with writer lock */
if ( (e = dn2entry_w( be, ndn->bv_val, &matched )) == NULL ) {
if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) {
char* matched_dn = NULL;
struct berval** refs;
@ -159,7 +159,7 @@ ldbm_back_modrdn(
* children.
*/
if( (p = dn2entry_w( be, p_ndn.bv_val, NULL )) == NULL) {
if( (p = dn2entry_w( be, &p_ndn, NULL )) == NULL) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
"ldbm_back_modrdn: parent of %s does not exist\n", e->e_ndn ));
@ -314,7 +314,7 @@ ldbm_back_modrdn(
/* Get Entry with dn=newSuperior. Does newSuperior exist? */
if ( nnewSuperior->bv_len ) {
if( (np = dn2entry_w( be, np_ndn->bv_val, NULL )) == NULL) {
if( (np = dn2entry_w( be, np_ndn, NULL )) == NULL) {
#ifdef NEW_LOGGING
LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
"ldbm_back_modrdn: newSup(ndn=%s) not found.\n", np_ndn->bv_val ));
@ -475,7 +475,7 @@ ldbm_back_modrdn(
}
ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
if ( ( rc_id = dn2id ( be, new_ndn.bv_val, &id ) ) || id != NOID ) {
if ( ( rc_id = dn2id ( be, &new_ndn, &id ) ) || id != NOID ) {
/* if (rc_id) something bad happened to ldbm cache */
send_ldap_result( conn, op,
rc_id ? LDAP_OPERATIONS_ERROR : LDAP_ALREADY_EXISTS,
@ -712,7 +712,7 @@ ldbm_back_modrdn(
ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
/* delete old one */
if ( dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
if ( dn2id_delete( be, &e->e_nname, e->e_id ) != 0 ) {
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "DN index delete fail", NULL, NULL );
goto return_results;
@ -731,7 +731,7 @@ ldbm_back_modrdn(
new_ndn.bv_val = NULL;
/* add new one */
if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) {
if ( dn2id_add( be, &e->e_nname, e->e_id ) != 0 ) {
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "DN index add failed", NULL, NULL );
goto return_results;
@ -748,7 +748,7 @@ ldbm_back_modrdn(
}
/* here we may try to delete the newly added dn */
if ( dn2id_delete( be, e->e_ndn, e->e_id ) != 0 ) {
if ( dn2id_delete( be, &e->e_nname, e->e_id ) != 0 ) {
/* we already are in trouble ... */
;
}

View file

@ -108,7 +108,7 @@ ldbm_back_exop_passwd(
goto done;
}
e = dn2entry_w( be, ndn.bv_val, NULL );
e = dn2entry_w( be, &ndn, NULL );
if( e == NULL ) {
*text = "could not locate authorization entry";
rc = LDAP_NO_SUCH_OBJECT;

View file

@ -53,8 +53,7 @@ void cache_return_entry_rw LDAP_P(( Cache *cache, Entry *e, int rw ));
#define cache_return_entry_w(c, e) cache_return_entry_rw((c), (e), 1)
void cache_entry_commit LDAP_P(( Entry *e ));
ID cache_find_entry_dn2id LDAP_P(( Backend *be, Cache *cache, const char *dn ));
ID cache_find_entry_ndn2id LDAP_P(( Backend *be, Cache *cache, const char *ndn ));
ID cache_find_entry_ndn2id LDAP_P(( Backend *be, Cache *cache, struct berval *ndn ));
Entry * cache_find_entry_id LDAP_P(( Cache *cache, ID id, int rw ));
int cache_delete_entry LDAP_P(( Cache *cache, Entry *e ));
void cache_release_all LDAP_P(( Cache *cache ));
@ -78,12 +77,12 @@ void *ldbm_cache_sync_daemon LDAP_P(( void *));
* dn2id.c
*/
int dn2id_add LDAP_P(( Backend *be, const char *dn, ID id ));
int dn2id LDAP_P(( Backend *be, const char *dn, ID *idp ));
int dn2id_add LDAP_P(( Backend *be, struct berval *dn, ID id ));
int dn2id LDAP_P(( Backend *be, struct berval *dn, ID *idp ));
int dn2idl LDAP_P(( Backend *be, struct berval *dn, int prefix, ID_BLOCK **idlp ));
int dn2id_delete LDAP_P(( Backend *be, const char *dn, ID id ));
int dn2id_delete LDAP_P(( Backend *be, struct berval *dn, ID id ));
Entry * dn2entry_rw LDAP_P(( Backend *be, const char *dn, Entry **matched, int rw ));
Entry * dn2entry_rw LDAP_P(( Backend *be, struct berval *dn, Entry **matched, int rw ));
#define dn2entry_r(be, dn, m) dn2entry_rw((be), (dn), (m), 0)
#define dn2entry_w(be, dn, m) dn2entry_rw((be), (dn), (m), 1)

View file

@ -39,7 +39,7 @@ ldbm_back_referrals(
}
/* get entry with reader lock */
e = dn2entry_r( be, ndn->bv_val, &matched );
e = dn2entry_r( be, ndn, &matched );
if ( e == NULL ) {
char *matched_dn = NULL;
struct berval **refs = NULL;

View file

@ -85,7 +85,7 @@ ldbm_back_search(
} else {
/* get entry with reader lock */
e = dn2entry_r( be, nbase->bv_val, &matched );
e = dn2entry_r( be, nbase, &matched );
err = e != NULL ? LDAP_SUCCESS : LDAP_REFERRAL;
text = NULL;
}

View file

@ -190,7 +190,7 @@ ID ldbm_tool_entry_put(
e->e_id, e->e_dn, 0 );
#endif
if ( dn2id( be, e->e_ndn, &id ) ) {
if ( dn2id( be, &e->e_nname, &id ) ) {
/* something bad happened to ldbm cache */
return NOID;
}
@ -213,7 +213,7 @@ ID ldbm_tool_entry_put(
return NOID;
}
rc = dn2id_add( be, e->e_ndn, e->e_id );
rc = dn2id_add( be, &e->e_nname, e->e_id );
if( rc != 0 ) {
return NOID;
}
@ -236,7 +236,7 @@ ID ldbm_tool_entry_put(
rc = ldbm_cache_store( id2entry, key, data, LDBM_REPLACE );
if( rc != 0 ) {
(void) dn2id_delete( be, e->e_ndn, e->e_id );
(void) dn2id_delete( be, &e->e_nname, e->e_id );
return NOID;
}
@ -290,7 +290,7 @@ int ldbm_tool_entry_reindex(
id, e->e_dn, 0 );
#endif
dn2id_add( be, e->e_ndn, e->e_id );
dn2id_add( be, &e->e_nname, e->e_id );
rc = index_entry_add( be, e, e->e_attrs );
entry_free( e );