* 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 ) {
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 );
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;
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;
}
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 );
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;
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;
}
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,