]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backend.c
reject registrations when back-monitor is not configured
[openldap] / servers / slapd / backend.c
index 3840ea02e914d8d2001dca1a3ae1f14b973f3651..f6f868a30d52d0b061e65f49992eb8b010aba4c6 100644 (file)
@@ -196,7 +196,7 @@ int backend_startup_one(Backend *be)
        assert( be != NULL );
 
        be->be_pending_csn_list = (struct be_pcl *)
-               ch_calloc( 1, sizeof( struct be_pcl ));
+               ch_calloc( 1, sizeof( struct be_pcl ) );
 
        LDAP_TAILQ_INIT( be->be_pending_csn_list );
 
@@ -421,6 +421,18 @@ void backend_destroy_one( BackendDB *bd, int dynamic )
                free( bd->be_rootpw.bv_val );
        }
        acl_destroy( bd->be_acl, frontendDB->be_acl );
+       limits_destroy( bd->be_limits );
+       if ( bd->be_replogfile ) {
+               ch_free( bd->be_replogfile );
+       }
+       destroy_replica_info( bd );
+       if ( !BER_BVISNULL( &bd->be_update_ndn ) ) {
+               ch_free( bd->be_update_ndn.bv_val );
+       }
+       if ( bd->be_update_refs ) {
+               ber_bvarray_free( bd->be_update_refs );
+       }
+
        if ( dynamic ) {
                free( bd );
        }
@@ -464,6 +476,11 @@ int backend_destroy(void)
                        free( bd->be_rootpw.bv_val );
                }
                acl_destroy( bd->be_acl, frontendDB->be_acl );
+
+               if ( bd->be_replogfile != NULL ) {
+                       free( bd->be_replogfile );
+               }
+               assert( bd->be_replica == NULL );
        }
 
        return 0;
@@ -820,11 +837,14 @@ backend_check_controls(
                }
        }
 
+       /* temporarily removed */
+#if 0
        /* check should be generalized */
        if( get_manageDIT(op) && !be_isroot(op)) {
                rs->sr_text = "requires manager authorization";
                rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
        }
+#endif
 
 done:;
        return rs->sr_err;
@@ -1166,23 +1186,21 @@ be_entry_get_rw(
        int rw,
        Entry **e )
 {
-       int rc;
-
        *e = NULL;
 
-       if (op->o_bd == NULL) {
-               rc = LDAP_NO_SUCH_OBJECT;
-       } else if ( op->o_bd->be_fetch ) {
-               rc = ( op->o_bd->be_fetch )( op, ndn,
-                       oc, at, rw, e );
-       } else {
-               rc = LDAP_UNWILLING_TO_PERFORM;
+       if ( op->o_bd == NULL ) {
+               return LDAP_NO_SUCH_OBJECT;
        }
-       return rc;
+
+       if ( op->o_bd->be_fetch ) {
+               return op->o_bd->be_fetch( op, ndn, oc, at, rw, e );
+       }
+
+       return LDAP_UNWILLING_TO_PERFORM;
 }
 
 int 
-backend_group(
+fe_acl_group(
        Operation *op,
        Entry   *target,
        struct berval *gr_ndn,
@@ -1196,8 +1214,6 @@ backend_group(
        GroupAssertion *g;
        Backend *be = op->o_bd;
 
-       if ( op->o_abandon ) return SLAPD_ABANDON;
-
        op->o_bd = select_backend( gr_ndn, 0, 0 );
 
        for ( g = op->o_groups; g; g = g->ga_next ) {
@@ -1350,7 +1366,37 @@ done:
 }
 
 int 
-backend_attribute(
+backend_group(
+       Operation *op,
+       Entry   *target,
+       struct berval *gr_ndn,
+       struct berval *op_ndn,
+       ObjectClass *group_oc,
+       AttributeDescription *group_at )
+{
+       int                     rc;
+       BackendDB               *be_orig;
+
+       if ( op->o_abandon ) {
+               return SLAPD_ABANDON;
+       }
+
+       be_orig = op->o_bd;
+       op->o_bd = frontendDB;
+#ifdef SLAP_OVERLAY_ACCESS
+       rc = frontendDB->be_group( op, target, gr_ndn,
+               op_ndn, group_oc, group_at );
+#else /* ! SLAP_OVERLAY_ACCESS */
+       rc = fe_acl_group( op, target, gr_ndn,
+               op_ndn, group_oc, group_at );
+#endif /* ! SLAP_OVERLAY_ACCESS */
+       op->o_bd = be_orig;
+
+       return rc;
+}
+
+int 
+fe_acl_attribute(
        Operation *op,
        Entry   *target,
        struct berval   *edn,
@@ -1457,6 +1503,32 @@ freeit:          if ( e != target ) {
        return rc;
 }
 
+int 
+backend_attribute(
+       Operation *op,
+       Entry   *target,
+       struct berval   *edn,
+       AttributeDescription *entry_at,
+       BerVarray *vals,
+       slap_access_t access )
+{
+       int                     rc;
+       BackendDB               *be_orig;
+
+       be_orig = op->o_bd;
+       op->o_bd = frontendDB;
+#ifdef SLAP_OVERLAY_ACCESS
+       rc = frontendDB->be_attribute( op, target, edn,
+               entry_at, vals, access );
+#else /* !SLAP_OVERLAY_ACCESS */
+       rc = fe_acl_attribute( op, target, edn,
+               entry_at, vals, access );
+#endif /* !SLAP_OVERLAY_ACCESS */
+       op->o_bd = be_orig;
+
+       return rc;
+}
+
 int 
 backend_access(
        Operation               *op,
@@ -1558,13 +1630,14 @@ freeit:         if ( e != target ) {
        return rc;
 }
 
-int backend_operational(
+int
+fe_aux_operational(
        Operation *op,
        SlapReply *rs )
 {
-       Attribute       **ap;
-       int             rc = 0;
-       BackendDB       *be_orig;
+       Attribute               **ap;
+       int                     rc = 0;
+       BackendDB               *be_orig;
 
        for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next )
                /* just count them */ ;
@@ -1592,11 +1665,10 @@ int backend_operational(
        {
                /* Let the overlays have a chance at this */
                be_orig = op->o_bd;
-               if ( SLAP_ISOVERLAY( be_orig ) )
-                       op->o_bd = select_backend( be_orig->be_nsuffix, 0, 0 );
-
-               if ( ( SLAP_OPATTRS( rs->sr_attr_flags ) || rs->sr_attrs ) &&
-                       op->o_bd && op->o_bd->be_operational != NULL )
+               op->o_bd = select_backend( &op->o_req_ndn, 0, 0 );
+               if ( !be_match( op->o_bd, frontendDB ) &&
+                       ( SLAP_OPATTRS( rs->sr_attr_flags ) || rs->sr_attrs ) &&
+                       op->o_bd != NULL && op->o_bd->be_operational != NULL )
                {
                        rc = op->o_bd->be_operational( op, rs );
                }
@@ -1606,3 +1678,18 @@ int backend_operational(
        return rc;
 }
 
+int backend_operational( Operation *op, SlapReply *rs )
+{
+       int rc;
+       BackendDB *be_orig;
+
+       /* Moved this into the frontend so global overlays are called */
+
+       be_orig = op->o_bd;
+       op->o_bd = frontendDB;
+       rc = frontendDB->be_operational( op, rs );
+       op->o_bd = be_orig;
+
+       return rc;
+}
+