Commit d2ac9a3f authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Port fixed ndn handling to 1.1. will likely NOT fix ITS#29 or ITS#53

parent 1a8ebbd1
...@@ -20,22 +20,19 @@ ldbm_back_add( ...@@ -20,22 +20,19 @@ ldbm_back_add(
) )
{ {
struct ldbminfo *li = (struct ldbminfo *) be->be_private; struct ldbminfo *li = (struct ldbminfo *) be->be_private;
char *dn = NULL, *pdn; char *pdn;
Entry *p = NULL; Entry *p = NULL;
int rootlock = 0; int rootlock = 0;
int rc = -1; int rc = -1;
dn = dn_normalize( ch_strdup( e->e_dn ) ); Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n", e->e_ndn, 0, 0);
Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n", dn, 0, 0);
/* nobody else can add until we lock our parent */ /* nobody else can add until we lock our parent */
pthread_mutex_lock(&li->li_add_mutex); pthread_mutex_lock(&li->li_add_mutex);
if ( ( dn2id( be, dn ) ) != NOID ) { if ( ( dn2id( be, e->e_ndn ) ) != NOID ) {
pthread_mutex_unlock(&li->li_add_mutex); pthread_mutex_unlock(&li->li_add_mutex);
entry_free( e ); entry_free( e );
free( dn );
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" ); send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
return( -1 ); return( -1 );
} }
...@@ -47,7 +44,6 @@ ldbm_back_add( ...@@ -47,7 +44,6 @@ ldbm_back_add(
0, 0, 0 ); 0, 0, 0 );
entry_free( e ); entry_free( e );
free( dn );
send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, "", send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, "",
"" ); "" );
return( -1 ); return( -1 );
...@@ -59,7 +55,7 @@ ldbm_back_add( ...@@ -59,7 +55,7 @@ ldbm_back_add(
* add the entry. * add the entry.
*/ */
if ( (pdn = dn_parent( be, dn )) != NULL ) { if ( (pdn = dn_parent( be, e->e_ndn )) != NULL ) {
char *matched = NULL; char *matched = NULL;
/* get parent with writer lock */ /* get parent with writer lock */
...@@ -75,7 +71,6 @@ ldbm_back_add( ...@@ -75,7 +71,6 @@ ldbm_back_add(
} }
entry_free( e ); entry_free( e );
free( dn );
free( pdn ); free( pdn );
return -1; return -1;
} }
...@@ -101,7 +96,6 @@ ldbm_back_add( ...@@ -101,7 +96,6 @@ ldbm_back_add(
cache_return_entry_w( &li->li_cache, p ); cache_return_entry_w( &li->li_cache, p );
entry_free( e ); entry_free( e );
free( dn );
return -1; return -1;
} }
...@@ -115,7 +109,6 @@ ldbm_back_add( ...@@ -115,7 +109,6 @@ ldbm_back_add(
"", "" ); "", "" );
entry_free( e ); entry_free( e );
free( dn );
return -1; return -1;
} }
...@@ -144,7 +137,6 @@ ldbm_back_add( ...@@ -144,7 +137,6 @@ ldbm_back_add(
0, 0, 0 ); 0, 0, 0 );
entry_free(e); entry_free(e);
free( dn );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
return( -1 ); return( -1 );
...@@ -173,7 +165,6 @@ ldbm_back_add( ...@@ -173,7 +165,6 @@ ldbm_back_add(
entry_rdwr_unlock(e, 1);; entry_rdwr_unlock(e, 1);;
entry_free( e ); entry_free( e );
free( dn );
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" ); send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
return( -1 ); return( -1 );
...@@ -206,7 +197,7 @@ ldbm_back_add( ...@@ -206,7 +197,7 @@ ldbm_back_add(
} }
/* dn2id index */ /* dn2id index */
if ( dn2id_add( be, dn, e->e_id ) != 0 ) { if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) {
Debug( LDAP_DEBUG_TRACE, "dn2id_add failed\n", 0, Debug( LDAP_DEBUG_TRACE, "dn2id_add failed\n", 0,
0, 0 ); 0, 0 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
...@@ -218,7 +209,7 @@ ldbm_back_add( ...@@ -218,7 +209,7 @@ ldbm_back_add(
if ( id2entry_add( be, e ) != 0 ) { if ( id2entry_add( be, e ) != 0 ) {
Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0, Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0,
0, 0 ); 0, 0 );
(void) dn2id_delete( be, dn ); (void) dn2id_delete( be, e->e_ndn );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" ); send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
goto return_results; goto return_results;
...@@ -228,9 +219,6 @@ ldbm_back_add( ...@@ -228,9 +219,6 @@ ldbm_back_add(
rc = 0; rc = 0;
return_results:; return_results:;
if ( dn != NULL )
free( dn );
if (p != NULL) { if (p != NULL) {
/* free parent and writer lock */ /* free parent and writer lock */
cache_return_entry_w( &li->li_cache, p ); cache_return_entry_w( &li->li_cache, p );
......
...@@ -69,7 +69,7 @@ ldbm_back_delete( ...@@ -69,7 +69,7 @@ ldbm_back_delete(
e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0); e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0);
/* delete from parent's id2children entry */ /* delete from parent's id2children entry */
if( (pdn = dn_parent( be, dn )) != NULL ) { if( (pdn = dn_parent( be, e->e_ndn )) != NULL ) {
if( (p = dn2entry_w( be, pdn, &matched )) == NULL) { if( (p = dn2entry_w( be, pdn, &matched )) == NULL) {
Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", Debug( LDAP_DEBUG_TRACE, "parent does not exist\n",
0, 0, 0); 0, 0, 0);
...@@ -114,7 +114,7 @@ ldbm_back_delete( ...@@ -114,7 +114,7 @@ ldbm_back_delete(
} }
/* delete from dn2id mapping */ /* delete from dn2id mapping */
if ( dn2id_delete( be, e->e_dn ) != 0 ) { if ( dn2id_delete( be, e->e_ndn ) != 0 ) {
Debug(LDAP_DEBUG_ARGS, Debug(LDAP_DEBUG_ARGS,
"<=- ldbm_back_delete: operations error %s\n", "<=- ldbm_back_delete: operations error %s\n",
dn, 0, 0); dn, 0, 0);
......
...@@ -51,7 +51,7 @@ ldbm_back_modrdn( ...@@ -51,7 +51,7 @@ ldbm_back_modrdn(
} }
#endif #endif
if ( (pdn = dn_parent( be, dn )) != NULL ) { if ( (pdn = dn_parent( be, e->e_ndn )) != NULL ) {
/* parent + rdn + separator(s) + null */ /* parent + rdn + separator(s) + null */
if( (p = dn2entry_w( be, pdn, &matched )) == NULL) { if( (p = dn2entry_w( be, pdn, &matched )) == NULL) {
Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", Debug( LDAP_DEBUG_TRACE, "parent does not exist\n",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment