]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/add.c
use slab memory for proxyauthz
[openldap] / servers / slapd / back-ldbm / add.c
index a64a0a878e2f8d15d62e3df751fc23dace5d5be8..c44f1eb13df09bbd7d449c844c5ab4b8446dd9f9 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2005 The OpenLDAP Foundation.
+ * Copyright 1998-2006 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include "back-ldbm.h"
 #include "proto-back-ldbm.h"
 
+static int
+ldbm_csn_cb(
+       Operation *op,
+       SlapReply *rs )
+{
+       op->o_callback = op->o_callback->sc_next;
+       slap_graduate_commit_csn( op );
+       return SLAP_CB_CONTINUE;
+}
+
 int
 ldbm_back_add(
     Operation  *op,
@@ -38,15 +48,20 @@ ldbm_back_add(
        AttributeDescription *entry = slap_schema.si_ad_entry;
        char textbuf[SLAP_TEXT_BUFLEN];
        size_t textlen = sizeof textbuf;
-#ifdef LDBM_SUBENTRIES
+       slap_callback cb = { NULL };
        int subentry;
-#endif
 
        Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n",
                op->o_req_dn.bv_val, 0, 0);
        
-       rs->sr_err = entry_schema_check( op->o_bd, op->oq_add.rs_e, NULL,
-               &rs->sr_text, textbuf, textlen );
+       slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
+
+       cb.sc_cleanup = ldbm_csn_cb;
+       cb.sc_next = op->o_callback;
+       op->o_callback = &cb;
+
+       rs->sr_err = entry_schema_check( op, op->oq_add.rs_e, NULL,
+               get_manageDIT(op), &rs->sr_text, textbuf, textlen );
 
        if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "entry failed schema check: %s\n",
@@ -55,13 +70,12 @@ ldbm_back_add(
                send_ldap_result( op, rs );
                return rs->sr_err;
        }
+       rs->sr_text = NULL;
 
-#ifdef LDBM_SUBENTRIES
        subentry = is_entry_subentry( op->oq_add.rs_e );
-#endif
 
        if ( !access_allowed( op, op->oq_add.rs_e,
-                               entry, NULL, ACL_WRITE, NULL ) )
+                               entry, NULL, ACL_WADD, NULL ) )
        {
                Debug( LDAP_DEBUG_TRACE, "no write access to entry\n", 0,
                    0, 0 );
@@ -130,7 +144,7 @@ ldbm_back_add(
                        return rs->sr_err;
                }
 
-               if ( ! access_allowed( op, p, children, NULL, ACL_WRITE, NULL ) ) {
+               if ( ! access_allowed( op, p, children, NULL, ACL_WADD, NULL ) ) {
                        /* free parent and writer lock */
                        cache_return_entry_w( &li->li_cache, p ); 
                        ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
@@ -144,7 +158,6 @@ ldbm_back_add(
                        return LDAP_INSUFFICIENT_ACCESS;
                }
 
-#ifdef LDBM_SUBENTRIES
                if ( is_entry_subentry( p )) {
                        Debug( LDAP_DEBUG_TRACE, "bdb_add: parent is subentry\n",
                                0, 0, 0 );
@@ -152,7 +165,6 @@ ldbm_back_add(
                        rs->sr_text = "parent is a subentry";
                        goto return_results;
                }
-#endif
 
                if ( is_entry_alias( p ) ) {
                        /* parent is an alias, don't allow add */
@@ -193,12 +205,10 @@ ldbm_back_add(
                        return rs->sr_err;
                }
 
-#ifdef LDBM_SUBENTRIES
                if ( subentry ) {
                        /* FIXME: */
                        /* parent must be an administrative point of the required kind */
                }
-#endif
 
        } else {
                assert( pdn.bv_val == NULL || *pdn.bv_val == '\0' );