]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/dynlist.c
ITS#4720 release csn mutex before checkpointing.
[openldap] / servers / slapd / overlays / dynlist.c
index 7e895381177e18e8300fd80dc561dcc322ff6c3f..872ede5e7ae802df04311ab7539b273f0f682ea1 100644 (file)
@@ -1,7 +1,7 @@
 /* dynlist.c - dynamic list overlay */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2005 The OpenLDAP Foundation.
+ * Copyright 2003-2006 The OpenLDAP Foundation.
  * Portions Copyright 2004-2005 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -24,7 +24,7 @@
 
 #if LDAP_VENDOR_VERSION_MINOR != X && LDAP_VENDOR_VERSION_MINOR < 3
 #define OL_2_2_COMPAT
-#elif defined(LDAP_DEVEL) && SLAPD_OVER_DYNGROUP != SLAPD_MOD_STATIC
+#elif SLAPD_OVER_DYNGROUP != SLAPD_MOD_STATIC
 #define TAKEOVER_DYNGROUP
 #endif
 
@@ -350,7 +350,7 @@ dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
                        continue;
                }
 
-               if ( lud->lud_host ) {
+               if ( lud->lud_host != NULL ) {
                        /* FIXME: host not allowed; reject as illegal? */
                        Debug( LDAP_DEBUG_ANY, "dynlist_send_entry(\"%s\"): "
                                "illegal URI \"%s\"\n",
@@ -365,6 +365,7 @@ dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
                         * this can be useful in case of a database serving
                         * the empty suffix */
                        BER_BVSTR( &dn, "" );
+
                } else {
                        ber_str2bv( lud->lud_dn, 0, 0, &dn );
                }
@@ -376,6 +377,8 @@ dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
                o.ors_scope = lud->lud_scope;
 
                if ( dli->dli_member_ad != NULL ) {
+                       /* if ( lud->lud_attrs != NULL ),
+                        * the URL should be ignored */
                        o.ors_attrs = slap_anlist_no_attrs;
 
                } else if ( lud->lud_attrs == NULL ) {
@@ -433,6 +436,7 @@ dynlist_send_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
                if ( lud->lud_filter == NULL ) {
                        ber_dupbv_x( &o.ors_filterstr,
                                        &dli->dli_default_filter, op->o_tmpmemctx );
+
                } else {
                        struct berval   flt;
                        ber_str2bv( lud->lud_filter, 0, 0, &flt );
@@ -469,13 +473,9 @@ cleanup:;
                if ( !BER_BVISNULL( &o.o_req_ndn ) ) {
                        op->o_tmpfree( o.o_req_ndn.bv_val, op->o_tmpmemctx );
                }
-               if ( o.ors_filterstr.bv_val != lud->lud_filter ) {
-                       op->o_tmpfree( o.ors_filterstr.bv_val, op->o_tmpmemctx );
-                       lud->lud_filter = NULL;
-               }
-               if ( lud ) {
-                       ldap_free_urldesc( lud );
-               }
+               assert( o.ors_filterstr.bv_val != lud->lud_filter );
+               op->o_tmpfree( o.ors_filterstr.bv_val, op->o_tmpmemctx );
+               ldap_free_urldesc( lud );
        }
 
        rs->sr_entry = e;
@@ -530,6 +530,7 @@ dynlist_compare( Operation *op, SlapReply *rs )
                                 * the assertion is FALSE rather than
                                 * UNDEFINED */
                                rs->sr_err = LDAP_COMPARE_FALSE;
+                               break;
                        }
 
                        return SLAP_CB_CONTINUE;
@@ -693,7 +694,7 @@ dynlist_build_def_filter( dynlist_info_t *dli )
 
        dli->dli_default_filter.bv_len = STRLENOF( "(!(objectClass=" "))" )
                + dli->dli_oc->soc_cname.bv_len;
-       dli->dli_default_filter.bv_val = SLAP_MALLOC( dli->dli_default_filter.bv_len + 1 );
+       dli->dli_default_filter.bv_val = ch_malloc( dli->dli_default_filter.bv_len + 1 );
        if ( dli->dli_default_filter.bv_val == NULL ) {
                Debug( LDAP_DEBUG_ANY, "dynlist_db_open: malloc failed.\n",
                        0, 0, 0 );
@@ -777,7 +778,34 @@ dynlist_db_config(
 
                for ( dlip = (dynlist_info_t **)&on->on_bi.bi_private;
                        *dlip; dlip = &(*dlip)->dli_next )
-                       /* go to last */;
+               {
+                       /* The check on objectClass may be relaxed */
+#if 0
+                       if ( (*dlip)->dli_oc == oc ) {
+                               Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                                       "\"dynlist-attrset <oc> <URL-ad> [<member-ad>]\": "
+                                       "objectClass \"%s\" already mapped.\n",
+                                       fname, lineno, oc->soc_cname.bv_val );
+                               return 1;
+                       }
+#endif
+
+                       if ( (*dlip)->dli_ad == ad ) {
+                               Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                                       "\"dynlist-attrset <oc> <URL-ad> [<member-ad>]\": "
+                                       "URL attributeDescription \"%s\" already mapped.\n",
+                                       fname, lineno, ad->ad_cname.bv_val );
+                               return 1;
+                       }
+
+                       if ( member_ad != NULL && (*dlip)->dli_member_ad == member_ad ) {
+                               Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                                       "\"dynlist-attrset <oc> <URL-ad> [<member-ad>]\": "
+                                       "member attributeDescription \"%s\" already mapped.\n",
+                                       fname, lineno, member_ad->ad_cname.bv_val );
+                               return 1;
+                       }
+               }
 
                *dlip = (dynlist_info_t *)ch_calloc( 1, sizeof( dynlist_info_t ) );
                (*dlip)->dli_oc = oc;
@@ -845,7 +873,34 @@ dynlist_db_config(
 
                for ( dlip = (dynlist_info_t **)&on->on_bi.bi_private;
                        *dlip; dlip = &(*dlip)->dli_next )
-                       /* go to last */;
+               {
+#if 0
+                       /* The check on objectClass may be relaxed */
+                       if ( (*dlip)->dli_oc == oc ) {
+                               Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                                       "\"dynlist-attrpair <member-ad> <URL-ad>\": "
+                                       "objectClass \"%s\" already mapped.\n",
+                                       fname, lineno, oc->soc_cname.bv_val );
+                               return 1;
+                       }
+#endif
+
+                       if ( (*dlip)->dli_ad == ad ) {
+                               Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                                       "\"dynlist-attrpair <member-ad> <URL-ad>\": "
+                                       "URL attributeDescription \"%s\" already mapped.\n",
+                                       fname, lineno, ad->ad_cname.bv_val );
+                               return 1;
+                       }
+
+                       if ( member_ad != NULL && (*dlip)->dli_member_ad == member_ad ) {
+                               Debug( LDAP_DEBUG_ANY, "%s: line %d: "
+                                       "\"dynlist-attrpair <member-ad> <URL-ad>\": "
+                                       "member attributeDescription \"%s\" already mapped.\n",
+                                       fname, lineno, member_ad->ad_cname.bv_val );
+                               return 1;
+                       }
+               }
 
                *dlip = (dynlist_info_t *)ch_calloc( 1, sizeof( dynlist_info_t ) );
                (*dlip)->dli_oc = oc;
@@ -1056,6 +1111,43 @@ dl_cfgen( ConfigArgs *c )
                        }
                }
 
+               for ( dlip = (dynlist_info_t **)&on->on_bi.bi_private;
+                       *dlip; dlip = &(*dlip)->dli_next )
+               {
+                       /* The check on objectClass may be relaxed */
+#if 0
+                       if ( (*dlip)->dli_oc == oc ) {
+                               snprintf( c->msg, sizeof( c->msg ),
+                                       "\"dynlist-attrset <oc> <URL-ad> [<member-ad>]\": "
+                                       "objectClass \"%s\" already mapped.\n",
+                                       oc->soc_cname.bv_val );
+                               Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
+                                       c->log, c->msg, 0 );
+                               return 1;
+                       }
+#endif
+
+                       if ( (*dlip)->dli_ad == ad ) {
+                               snprintf( c->msg, sizeof( c->msg ),
+                                       "\"dynlist-attrset <oc> <URL-ad> [<member-ad>]\": "
+                                       "URL attributeDescription \"%s\" already mapped.\n",
+                                       ad->ad_cname.bv_val );
+                               Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
+                                       c->log, c->msg, 0 );
+                               return 1;
+                       }
+
+                       if ( member_ad != NULL && (*dlip)->dli_member_ad == member_ad ) {
+                               snprintf( c->msg, sizeof( c->msg ),
+                                       "\"dynlist-attrset <oc> <URL-ad> [<member-ad>]\": "
+                                       "member attributeDescription \"%s\" already mapped.\n",
+                                       member_ad->ad_cname.bv_val );
+                               Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
+                                       c->log, c->msg, 0 );
+                               return 1;
+                       }
+               }
+
                if ( c->valx > 0 ) {
                        int     i;
 
@@ -1151,7 +1243,40 @@ dl_cfgen( ConfigArgs *c )
 
                for ( dlip = (dynlist_info_t **)&on->on_bi.bi_private;
                        *dlip; dlip = &(*dlip)->dli_next )
-                               /* goto last */;
+               {
+                       /* The check on objectClass may be relaxed */
+#if 0
+                       if ( (*dlip)->dli_oc == oc ) {
+                               snprintf( c->msg, sizeof( c->msg ),
+                                       "\"dynlist-attrpair <member-ad> <URL-ad>\": "
+                                       "objectClass \"%s\" already mapped.\n",
+                                       oc->soc_cname.bv_val );
+                               Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
+                                       c->log, c->msg, 0 );
+                               return 1;
+                       }
+#endif
+
+                       if ( (*dlip)->dli_ad == ad ) {
+                               snprintf( c->msg, sizeof( c->msg ),
+                                       "\"dynlist-attrpair <member-ad> <URL-ad>\": "
+                                       "URL attributeDescription \"%s\" already mapped.\n",
+                                       ad->ad_cname.bv_val );
+                               Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
+                                       c->log, c->msg, 0 );
+                               return 1;
+                       }
+
+                       if ( member_ad != NULL && (*dlip)->dli_member_ad == member_ad ) {
+                               snprintf( c->msg, sizeof( c->msg ),
+                                       "\"dynlist-attrpair <member-ad> <URL-ad>\": "
+                                       "member attributeDescription \"%s\" already mapped.\n",
+                                       member_ad->ad_cname.bv_val );
+                               Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
+                                       c->log, c->msg, 0 );
+                               return 1;
+                       }
+               }
 
                *dlip = (dynlist_info_t *)ch_calloc( 1, sizeof( dynlist_info_t ) );
 
@@ -1218,9 +1343,11 @@ dynlist_db_open(
                        dli->dli_ad = ad;                       
                }
 
-               rc = dynlist_build_def_filter( dli );
-               if ( rc != 0 ) {
-                       return rc;
+               if ( BER_BVISNULL( &dli->dli_default_filter ) ) {
+                       rc = dynlist_build_def_filter( dli );
+                       if ( rc != 0 ) {
+                               return rc;
+                       }
                }
        }
 
@@ -1249,10 +1376,12 @@ dynlist_db_destroy(
 }
 
 static slap_overinst   dynlist = { { NULL } };
+#ifdef TAKEOVER_DYNGROUP
 static char            *obsolete_names[] = {
        "dyngroup",
        NULL
 };
+#endif
 
 #if SLAPD_OVER_DYNLIST == SLAPD_MOD_DYNAMIC
 static