]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backover.c
Use recursive mutex to avoid deadlocks
[openldap] / servers / slapd / backover.c
index 68415383c378d86f05bb1e231497b6030615d8f2..3128840ce9f541c2f470526ae947ab698f1d2327 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2005 The OpenLDAP Foundation.
+ * Copyright 2003-2006 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -239,7 +239,6 @@ over_back_response ( Operation *op, SlapReply *rs )
        return rc;
 }
 
-#ifdef SLAP_OVERLAY_ACCESS
 static int
 over_access_allowed(
        Operation               *op,
@@ -450,7 +449,6 @@ over_acl_attribute(
 
        return rc;
 }
-#endif /* SLAP_OVERLAY_ACCESS */
 
 /*
  * default return code in case of missing backend function
@@ -952,15 +950,33 @@ overlay_config( BackendDB *be, const char *ov )
         * overlay info structure
         */
        if ( !overlay_is_over( be ) ) {
+               int     isglobal = 0;
+
+               /* NOTE: the first time a global overlay is configured,
+                * frontendDB gets this flag; it is used later by overlays
+                * to determine if they're stacked on top of the frontendDB */
+               if ( be->bd_info == frontendDB->bd_info || SLAP_ISGLOBALOVERLAY( be ) ) {
+                       isglobal = 1;
+                       if ( on->on_bi.bi_flags & SLAPO_BFLAG_DBONLY ) {
+                               Debug( LDAP_DEBUG_ANY, "overlay_config(): "
+                                       "overlay \"%s\" cannot be global.\n",
+                                       ov, 0, 0 );
+                               return 1;
+                       }
+
+               } else if ( on->on_bi.bi_flags & SLAPO_BFLAG_GLOBONLY ) {
+                       Debug( LDAP_DEBUG_ANY, "overlay_config(): "
+                               "overlay \"%s\" can only be global.\n",
+                               ov, 0, 0 );
+                       return 1;
+               }
+
                oi = ch_malloc( sizeof( slap_overinfo ) );
                oi->oi_orig = be->bd_info;
                oi->oi_bi = *be->bd_info;
                oi->oi_origdb = be;
 
-               /* NOTE: the first time a global overlay is configured,
-                * frontendDB gets this flag; it is used later by overlays
-                * to determine if they're stacked on top of the frontendDB */
-               if ( oi->oi_orig == frontendDB->bd_info ) {
+               if ( isglobal ) {
                        SLAP_DBFLAGS( be ) |= SLAP_DBFLAG_GLOBAL_OVERLAY;
                }
 
@@ -1000,12 +1016,10 @@ overlay_config( BackendDB *be, const char *ov )
                bi->bi_chk_referrals = over_aux_chk_referrals;
                bi->bi_chk_controls = over_aux_chk_controls;
 
-#ifdef SLAP_OVERLAY_ACCESS
                /* these have specific arglists */
                bi->bi_access_allowed = over_access_allowed;
                bi->bi_acl_group = over_acl_group;
                bi->bi_acl_attribute = over_acl_attribute;
-#endif /* SLAP_OVERLAY_ACCESS */
                
                bi->bi_connection_init = over_connection_init;
                bi->bi_connection_destroy = over_connection_destroy;
@@ -1015,8 +1029,11 @@ overlay_config( BackendDB *be, const char *ov )
        } else {
                if ( overlay_is_inst( be, ov ) ) {
                        Debug( LDAP_DEBUG_ANY, "overlay_config(): "
-                                       "warning, overlay \"%s\" "
-                                       "already in list\n", ov, 0, 0 );
+                               "overlay \"%s\" already in list\n",
+                               ov, 0, 0 );
+                       if ( SLAPO_SINGLE( be ) ) {
+                               return 1;
+                       }
                }
 
                oi = be->bd_info->bi_private;