]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backend.c
Fixup bdb_entry_release now that entry_decode uses two memory blocks
[openldap] / servers / slapd / backend.c
index c2edb362758751b265331096fc7a744e78ac8813..85ce0983744751b6114445373d94cdaa05739039 100644 (file)
@@ -33,6 +33,9 @@
 #ifdef SLAPD_META
 #include "back-meta/external.h"
 #endif
+#ifdef SLAPD_MONITOR
+#include "back-monitor/external.h"
+#endif
 #ifdef SLAPD_PASSWD
 #include "back-passwd/external.h"
 #endif
@@ -68,6 +71,9 @@ static BackendInfo binfo[] = {
 #if defined(SLAPD_META) && !defined(SLAPD_META_DYNAMIC)
        {"meta",        meta_back_initialize},
 #endif
+#if defined(SLAPD_MONITOR) && !defined(SLAPD_MONITOR_DYNAMIC)
+       {"monitor",     monitor_back_initialize},
+#endif
 #if defined(SLAPD_PASSWD) && !defined(SLAPD_PASSWD_DYNAMIC)
        {"passwd",      passwd_back_initialize},
 #endif
@@ -121,12 +127,12 @@ int backend_init(void)
                if(rc != 0) {
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
-                                  "backend_init:  initialized for type \"%s\"\n",
-                                  binfo[nBackendInfo].bi_type ));
+                               "backend_init:  initialized for type \"%s\"\n",
+                               binfo[nBackendInfo].bi_type ));
 #else
                        Debug( LDAP_DEBUG_ANY,
                                "backend_init: initialized for type \"%s\"\n",
-                                       binfo[nBackendInfo].bi_type, 0, 0 );
+                               binfo[nBackendInfo].bi_type, 0, 0 );
 #endif
                        /* destroy those we've already inited */
                        for( nBackendInfo--;
@@ -152,10 +158,10 @@ int backend_init(void)
 #else
 
 #ifdef NEW_LOGGING
-        LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
-                   "backend_init: failed\n" ));
+       LDAP_LOG(( "backend", LDAP_LEVEL_ERR,
+               "backend_init: failed\n" ));
 #else
-        Debug( LDAP_DEBUG_ANY,
+       Debug( LDAP_DEBUG_ANY,
                "backend_init: failed\n",
                0, 0, 0 );
 #endif
@@ -463,8 +469,7 @@ backend_db_init(
        be = &backends[nbackends++];
 
        be->bd_info = bi;
-       be->be_sizelimit = defsize;
-       be->be_timelimit = deftime;
+       be->be_def_limit = deflimit;
        be->be_dfltaccess = global_default_access;
 
        be->be_restrictops = global_restrictops;
@@ -520,7 +525,7 @@ select_backend(
                        }
 
                        
-                       if ( len && len < dnlen && !DN_SEPARATOR( dn[(dnlen-len)-1] ) ) {
+                       if ( len && len < dnlen && ( !DN_SEPARATOR( dn[(dnlen-len)-1] ) || DN_ESCAPE( dn[(dnlen-len)-2] ) ) ) {
                                /* make sure we have a separator */
                                continue;
                        }
@@ -579,6 +584,24 @@ be_isroot( Backend *be, const char *ndn )
        return(rc);
 }
 
+int
+be_isupdate( Backend *be, const char *ndn )
+{
+       int rc;
+
+       if ( ndn == NULL || *ndn == '\0' ) {
+               return( 0 );
+       }
+
+       if ( be->be_update_ndn == NULL || *be->be_update_ndn == '\0' ) {
+               return( 0 );
+       }
+
+       rc = strcmp( be->be_update_ndn, ndn ) ? 0 : 1;
+
+       return(rc);
+}
+
 char *
 be_root_dn( Backend *be )
 {
@@ -948,6 +971,16 @@ backend_group(
        AttributeDescription *group_at
 )
 {
+       GroupAssertion *g;
+       int len = strlen(gr_ndn);
+       int i;
+
+       ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
+       i = op->o_abandon;
+       ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
+       if (i)
+               return SLAPD_ABANDON;
+
        if( strcmp( target->e_ndn, gr_ndn ) != 0 ) {
                /* we won't attempt to send it to a different backend */
                
@@ -958,10 +991,38 @@ backend_group(
                }
        } 
 
+       ldap_pvt_thread_mutex_lock( &conn->c_mutex );
+       for (g = conn->c_groups; g; g=g->next) {
+               if (g->be != be || g->oc != group_oc || g->at != group_at ||
+                   g->len != len)
+                       continue;
+               if (strcmp( g->ndn, gr_ndn ) == 0)
+                       break;
+       }
+       ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
+       if (g)
+               return g->res;
+
        if( be->be_group ) {
-               return be->be_group( be, conn, op,
+               int res = be->be_group( be, conn, op,
                        target, gr_ndn, op_ndn,
                        group_oc, group_at );
+               
+               if (op->o_tag != LDAP_REQ_BIND) {
+                       g = ch_malloc(sizeof(GroupAssertion) + len);
+                       g->be = be;
+                       g->oc = group_oc;
+                       g->at = group_at;
+                       g->res = res;
+                       g->len = len;
+                       strcpy(g->ndn, gr_ndn);
+                       ldap_pvt_thread_mutex_lock( &conn->c_mutex );
+                       g->next = conn->c_groups;
+                       conn->c_groups = g;
+                       ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
+               }
+
+               return res;
        }
 
        return LDAP_UNWILLING_TO_PERFORM;
@@ -1006,7 +1067,7 @@ Attribute *backend_operational(
 
 #ifdef SLAPD_SCHEMA_DN
        a = ch_malloc( sizeof( Attribute ) );
-       a->a_desc = ad_dup( slap_schema.si_ad_subschemaSubentry );
+       a->a_desc = slap_schema.si_ad_subschemaSubentry;
 
        /* Should be backend specific */
        a->a_vals = ch_malloc( 2 * sizeof( struct berval * ) );