]> git.sur5r.net Git - openldap/commitdiff
another round replacing dn_parent ...
authorPierangelo Masarati <ando@openldap.org>
Thu, 17 Jan 2002 22:37:38 +0000 (22:37 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 17 Jan 2002 22:37:38 +0000 (22:37 +0000)
servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/dn2id.c

index b02e8de340418952bb2a2fed80954eb8e0713266..c3b4c198c7c92683b9260239e38714f1e8dbc91d 100644 (file)
@@ -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 ) {
index 5fa643a054919865a75f7d6b2621f65fb6c8dfcd..894fe8ad9d942719f887130a45a8e72414bb0822 100644 (file)
@@ -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;
index 0e63643474e81d83e8db83c2c079995ad656d264..ab8f23f76dfb802ef6f723e0585a7ce0b5847a16 100644 (file)
@@ -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,