From: Pierangelo Masarati Date: Thu, 17 Jan 2002 22:37:38 +0000 (+0000) Subject: another round replacing dn_parent ... X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~87 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e6332812e041a47ba9811fa04f50690ed1e84f19;p=openldap another round replacing dn_parent ... --- diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index b02e8de340..c3b4c198c7 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -96,11 +96,16 @@ retry: rc = txn_abort( ltid ); * If the parent does not exist, only allow the "root" user to * add the entry. */ - pdn.bv_val = dn_parent( be, e->e_ndn ); - if (pdn.bv_val && *pdn.bv_val) { - pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_ndn); - } else { + if ( be_issuffix( be, e->e_nname.bv_val ) ) { pdn.bv_len = 0; + pdn.bv_val = ""; + } else { + rc = dnParent( e->e_nname.bv_val, &pdn.bv_val ); + if ( rc != LDAP_SUCCESS ) { + text = "internal error"; + goto return_results; + } + pdn.bv_len = e->e_nname.bv_len - (pdn.bv_val - e->e_nname.bv_val); } if( pdn.bv_len != 0 ) { diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 5fa643a054..894fe8ad9d 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -117,7 +117,15 @@ retry: /* transaction retry */ goto done; } - pdn = dn_parent( be, ndn->bv_val ); + if ( be_issuffix( be, ndn->bv_val ) ) { + pdn = NULL; + } else { + rc = dnParent( ndn->bv_val, &pdn ); + if ( rc != LDAP_SUCCESS ) { + text = "internal error"; + goto return_results; + } + } if( pdn != NULL && *pdn != '\0' ) { struct berval pbv; diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 0e63643474..ab8f23f76d 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -51,6 +51,7 @@ bdb_dn2id_add( goto done; } + pdn = NULL; if( !be_issuffix( be, ptr )) { buf[0] = DN_SUBTREE_PREFIX; rc = bdb_idl_insert_key( be, db, txn, &key, e->e_id ); @@ -60,11 +61,15 @@ bdb_dn2id_add( ptr, rc, 0 ); goto done; } - } - - pdn = dn_parent( be, ptr ); - - if( pdn != NULL ) { + + rc = dnParent( ptr, (const char **)&pdn ); + if ( rc != LDAP_SUCCESS ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_dn2id_add: dnParent(\"%s\") failed\n", + ptr, 0, 0 ); + goto done; + } + key.size -= pdn - ptr; pdn[-1] = DN_ONE_PREFIX; key.data = pdn - 1; @@ -93,7 +98,17 @@ bdb_dn2id_add( break; } ptr = pdn; - pdn = dn_parent( be, pdn ); + if ( be_issuffix( be, pdn ) ) { + break; + } + rc = dnParent( pdn, &pdn ); + if ( rc != LDAP_SUCCESS ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_dn2id_add: dnParent(\"%s\") failed\n", + ptr, 0, 0 ); + goto done; + } + key.size -= pdn - ptr; key.data = pdn - 1; } @@ -137,6 +152,7 @@ bdb_dn2id_delete( goto done; } + pdn = NULL; if( !be_issuffix( be, ptr )) { buf[0] = DN_SUBTREE_PREFIX; rc = bdb_idl_delete_key( be, db, txn, &key, e->e_id ); @@ -146,11 +162,15 @@ bdb_dn2id_delete( ptr, rc, 0 ); goto done; } - } - pdn = dn_parent( be, ptr ); + rc = dnParent( ptr, &pdn ); + if ( rc != LDAP_SUCCESS ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_dn2id_delete: dnParent(\"%s\") failed\n", + ptr, 0, 0 ); + goto done; + } - if( pdn != NULL ) { key.size -= pdn - ptr; pdn[-1] = DN_ONE_PREFIX; key.data = pdn - 1; @@ -179,7 +199,14 @@ bdb_dn2id_delete( goto done; } ptr = pdn; - pdn = dn_parent( be, pdn ); + rc = dnParent( pdn, &pdn ); + if ( rc != LDAP_SUCCESS ) { + Debug( LDAP_DEBUG_ANY, + "=> bdb_dn2id_delete: dnParent(\"%s\") failed\n", + ptr, 0, 0 ); + goto done; + } + key.size -= pdn - ptr; key.data = pdn - 1; } @@ -269,7 +296,17 @@ bdb_dn2id_matched( rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags ); if( rc == DB_NOTFOUND ) { - char *pdn = dn_parent( be, dn ); + char *pdn = NULL; + + if ( ! be_issuffix( be, dn ) ) { + rc = dnParent( dn, &pdn ); + if ( rc != LDAP_SUCCESS ) { + Debug( LDAP_DEBUG_TRACE, + "<= bdb_dn2id_matched: dnParent(\"%s\") failed\n", + dn, 0, 0 ); + break; + } + } if( pdn == NULL || *pdn == '\0' ) { Debug( LDAP_DEBUG_TRACE,