]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/add.c
return structuralObjectClass errors
[openldap] / servers / slapd / back-bdb / add.c
index fabf6b12c6ab917b2bcb3654b2362126c43e6d8e..b66f19f6db0f36154bf0f5b0def3f8d6a2b68170 100644 (file)
@@ -93,11 +93,17 @@ txnReturn:
 
        /* add opattrs to shadow as well, only missing attrs will actually
         * be added; helps compatibility with older OL versions */
-       slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
+       rs->sr_err = slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
+               Debug( LDAP_DEBUG_TRACE,
+                       LDAP_XSTRING(bdb_add) ": entry failed op attrs add: "
+                       "%s (%d)\n", rs->sr_text, rs->sr_err, 0 );
+               goto return_results;
+       }
 
        /* check entry's schema */
        rs->sr_err = entry_schema_check( op, op->oq_add.rs_e, NULL,
-               get_manageDIT(op), &rs->sr_text, textbuf, textlen );
+               get_relax(op), &rs->sr_text, textbuf, textlen );
        if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE,
                        LDAP_XSTRING(bdb_add) ": entry failed schema check: "
@@ -125,7 +131,9 @@ txnReturn:
 retry: /* transaction retry */
                if( p ) {
                        /* free parent and reader lock */
-                       bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
+                       if ( p != (Entry *)&slap_entry_root ) {
+                               bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
+                       }
                        p = NULL;
                }
                rs->sr_err = TXN_ABORT( ltid );
@@ -197,42 +205,45 @@ retry:    /* transaction retry */
        }
 
        p = ei->bei_e;
-       if ( p ) {
-               if ( !bvmatch( &pdn, &p->e_nname ) ) {
-                       rs->sr_matched = ber_strdup_x( p->e_name.bv_val,
-                               op->o_tmpmemctx );
-                       rs->sr_ref = is_entry_referral( p )
-                               ? get_entry_referrals( op, p )
-                               : NULL;
-                       bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
-                       p = NULL;
-                       Debug( LDAP_DEBUG_TRACE,
-                               LDAP_XSTRING(bdb_add) ": parent "
-                               "does not exist\n", 0, 0, 0 );
-
-                       rs->sr_err = LDAP_REFERRAL;
-                       rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
-                       goto return_results;
-               }
+       if ( !p )
+               p = (Entry *)&slap_entry_root;
+
+       if ( !bvmatch( &pdn, &p->e_nname ) ) {
+               rs->sr_matched = ber_strdup_x( p->e_name.bv_val,
+                       op->o_tmpmemctx );
+               rs->sr_ref = is_entry_referral( p )
+                       ? get_entry_referrals( op, p )
+                       : NULL;
+               bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
+               p = NULL;
+               Debug( LDAP_DEBUG_TRACE,
+                       LDAP_XSTRING(bdb_add) ": parent "
+                       "does not exist\n", 0, 0, 0 );
 
-               rs->sr_err = access_allowed( op, p,
-                       children, NULL, ACL_WADD, NULL );
+               rs->sr_err = LDAP_REFERRAL;
+               rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
+               goto return_results;
+       }
 
-               if ( ! rs->sr_err ) {
-                       switch( opinfo.boi_err ) {
-                       case DB_LOCK_DEADLOCK:
-                       case DB_LOCK_NOTGRANTED:
-                               goto retry;
-                       }
+       rs->sr_err = access_allowed( op, p,
+               children, NULL, ACL_WADD, NULL );
 
-                       Debug( LDAP_DEBUG_TRACE,
-                               LDAP_XSTRING(bdb_add) ": no write access to parent\n",
-                               0, 0, 0 );
-                       rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
-                       rs->sr_text = "no write access to parent";
-                       goto return_results;;
+       if ( ! rs->sr_err ) {
+               switch( opinfo.boi_err ) {
+               case DB_LOCK_DEADLOCK:
+               case DB_LOCK_NOTGRANTED:
+                       goto retry;
                }
 
+               Debug( LDAP_DEBUG_TRACE,
+                       LDAP_XSTRING(bdb_add) ": no write access to parent\n",
+                       0, 0, 0 );
+               rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+               rs->sr_text = "no write access to parent";
+               goto return_results;;
+       }
+
+       if ( p != (Entry *)&slap_entry_root ) {
                if ( is_entry_subentry( p ) ) {
                        /* parent is a subentry, don't allow add */
                        Debug( LDAP_DEBUG_TRACE,
@@ -242,6 +253,7 @@ retry:      /* transaction retry */
                        rs->sr_text = "parent is a subentry";
                        goto return_results;;
                }
+
                if ( is_entry_alias( p ) ) {
                        /* parent is an alias, don't allow add */
                        Debug( LDAP_DEBUG_TRACE,
@@ -272,27 +284,13 @@ retry:    /* transaction retry */
                        /* FIXME: */
                        /* parent must be an administrative point of the required kind */
                }
+       }
 
-               /* free parent and reader lock */
+       /* free parent and reader lock */
+       if ( p != (Entry *)&slap_entry_root ) {
                bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
-               p = NULL;
-
-       } else {
-               /*
-                * no parent!
-                *  if not attempting to add entry at suffix or with parent ""
-                */
-               if ((( !be_isroot( op ) && !be_shadow_update(op) )
-                       || pdn.bv_len > 0 ) && !is_entry_glue( op->oq_add.rs_e ))
-               {
-                       Debug( LDAP_DEBUG_TRACE,
-                               LDAP_XSTRING(bdb_add) ": %s denied\n",
-                               pdn.bv_len == 0 ? "suffix" : "entry at root",
-                               0, 0 );
-                       rs->sr_err = LDAP_NO_SUCH_OBJECT;
-                       goto return_results;
-               }
        }
+       p = NULL;
 
        rs->sr_err = access_allowed( op, op->oq_add.rs_e,
                entry, NULL, ACL_WADD, NULL );