mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-16 11:57:39 -05:00
another round replacing dn_parent ...
This commit is contained in:
parent
3894bd332b
commit
e6332812e0
3 changed files with 66 additions and 16 deletions
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue