]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/dynlist.c
More for prev commit - set entryCSN as well.
[openldap] / servers / slapd / overlays / dynlist.c
index 7f7cc287f561eec8bcae9e028488957a830388e1..5ccccaf3b965ab97227c47b042ecfe9296568c95 100644 (file)
 /* FIXME: the code differs if SLAP_OPATTRS is defined or not;
  * SLAP_OPATTRS is not defined in 2.2 yet, while this overlay
  * expects HEAD code at least later than August 6, 2004. */
+/* FIXME: slap_anlist_no_attrs was introduced in 2.3; here it
+ * is anticipated to allow using this overlay with 2.2. */
+
+#if LDAP_VENDOR_VERSION_MINOR != X && LDAP_VENDOR_VERSION_MINOR < 3
+static AttributeName anlist_no_attrs[] = {
+       { BER_BVC( LDAP_NO_ATTRS ), NULL, 0, NULL },
+       { BER_BVNULL, NULL, 0, NULL }
+};
+
+static AttributeName *slap_anlist_no_attrs = anlist_no_attrs;
+#endif
 
 typedef struct dynlist_info {
        ObjectClass             *dli_oc;
@@ -76,8 +87,8 @@ dynlist_make_filter( Operation *op, struct berval *oldf, struct berval *newf )
 
        char            *ptr;
 
-       assert( oldf );
-       assert( newf );
+       assert( oldf != NULL );
+       assert( newf != NULL );
        assert( !BER_BVISNULL( oldf ) );
        assert( !BER_BVISEMPTY( oldf ) );
 
@@ -211,7 +222,7 @@ dynlist_sc_update( Operation *op, SlapReply *rs )
 
                /* test access to attribute */
                for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ )
-                       /* jst count */ ;
+                       /* just count */ ;
 
                vals = op->o_tmpalloc( ( i + 1 ) * sizeof( struct berval ), op->o_tmpmemctx );
                if ( a->a_nvals != a->a_vals ) {
@@ -275,10 +286,10 @@ dynlist_send_entry( Operation *op, SlapReply *rs )
        Attribute       *a;
        slap_callback   cb;
        Operation       o = *op;
-       SlapReply       r = *rs;
+       SlapReply       r = { REP_SEARCH };
        struct berval   *url;
        Entry           *e;
-       int             e_flags;
+       slap_mask_t     e_flags;
        int             opattrs,
                        userattrs;
        dynlist_sc_t    dlc = { 0 };
@@ -577,7 +588,17 @@ dynlist_response( Operation *op, SlapReply *rs )
                break;
 
        case LDAP_REQ_COMPARE:
-               if ( rs->sr_err == LDAP_NO_SUCH_ATTRIBUTE ) {
+               switch ( rs->sr_err ) {
+               /* NOTE: we waste a few cycles running the dynamic list
+                * also when the result is FALSE, which occurs if the
+                * dynamic entry itself contains the AVA attribute  */
+               /* FIXME: this approach is less than optimal; a dedicated
+                * compare op should be implemented, that fetches the
+                * entry, checks if it has the appropriate objectClass
+                * and, in case, runs a compare thru all the URIs,
+                * stopping at the first positive occurrence; see ITS#3756 */
+               case LDAP_COMPARE_FALSE:
+               case LDAP_NO_SUCH_ATTRIBUTE:
                        return dynlist_compare( op, rs );
                }
                break;
@@ -591,12 +612,11 @@ dynlist_response( Operation *op, SlapReply *rs )
 
 static int
 dynlist_db_config(
-    BackendDB  *be,
-    const char *fname,
-    int                lineno,
-    int                argc,
-    char       **argv
-)
+       BackendDB       *be,
+       const char      *fname,
+       int             lineno,
+       int             argc,
+       char            **argv )
 {
        slap_overinst   *on = (slap_overinst *)be->bd_info;
        dynlist_info    *dli = (dynlist_info *)on->on_bi.bi_private;
@@ -657,8 +677,7 @@ dynlist_db_config(
 
 static int
 dynlist_db_init(
-       BackendDB *be
-)
+       BackendDB       *be )
 {
        slap_overinst   *on = (slap_overinst *) be->bd_info;
        dynlist_info    *dli;
@@ -673,23 +692,21 @@ dynlist_db_init(
 
 static int
 dynlist_db_open(
-       BackendDB *be
-)
+       BackendDB       *be )
 {
        slap_overinst   *on = (slap_overinst *) be->bd_info;
        dynlist_info    *dli = (dynlist_info *)on->on_bi.bi_private;
-       int             rc = 0;
        ber_len_t       len;
        char            *ptr;
 
        if ( dli->dli_oc == NULL ) {
                fprintf( stderr, "dynlist_db_open(): missing \"dynlist-oc <ObjectClass>\"\n" );
-               rc = -1;
+               return -1;
        }
 
        if ( dli->dli_ad == NULL ) {
                fprintf( stderr, "dynlist_db_open(): missing \"dynlist-ad <AttributeDescription>\"\n" );
-               rc = -1;
+               return -1;
        }
 
        len = STRLENOF( "(!(objectClass=" "))" )
@@ -704,13 +721,12 @@ dynlist_db_open(
        ptr = lutil_strcopy( ptr, "))" );
        dli->dli_default_filter.bv_len = ptr - dli->dli_default_filter.bv_val;
 
-       return rc;
+       return 0;
 }
 
 static int
 dynlist_db_destroy(
-       BackendDB *be
-)
+       BackendDB       *be )
 {
        slap_overinst   *on = (slap_overinst *) be->bd_info;
        int             rc = 0;
@@ -729,8 +745,11 @@ dynlist_db_destroy(
 
 static slap_overinst dynlist = { { NULL } };
 
+#if SLAPD_OVER_DYNLIST == SLAPD_MOD_DYNAMIC
+static
+#endif /* SLAPD_OVER_DYNLIST == SLAPD_MOD_DYNAMIC */
 int
-dynlist_init(void)
+dynlist_initialize(void)
 {
        dynlist.on_bi.bi_type = "dynlist";
        dynlist.on_bi.bi_db_init = dynlist_db_init;
@@ -747,7 +766,7 @@ dynlist_init(void)
 int
 init_module( int argc, char *argv[] )
 {
-       return dynlist_init();
+       return dynlist_initialize();
 }
 #endif