]> git.sur5r.net Git - openldap/commitdiff
Add ITS#3309 fix
authorKurt Zeilenga <kurt@openldap.org>
Wed, 1 Sep 2004 04:13:18 +0000 (04:13 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 1 Sep 2004 04:13:18 +0000 (04:13 +0000)
Add syncrepl exattrs

CHANGES
servers/slapd/back-bdb/delete.c
servers/slapd/config.c
servers/slapd/slap.h
servers/slapd/syncrepl.c

diff --git a/CHANGES b/CHANGES
index c51101c58a76f1ff68b9989937779c58b7d80a63..6bb9f7a3278de6a8a75c2ce3d871e27adb8934aa 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -15,8 +15,11 @@ OpenLDAP 2.2.16 Engineering
        Fixed slapd permissive modify bug
        Fixed back-bdb CSN CTX bug (ITS#3301)
        Fixed back-bdb id2entry bug
+       Fixed back-bdb syncrepl psearch delete bug (ITS#3309)
        Fixed back-ldap/meta known controls bugs (ITS#3291)
+       Fixed back-monitor syncrepl bug (ITS#3265)
        Fixed slurpd replog error message bug (ITS#3275)
+       Added slapd syncrepl exattrs
        Updated LDAP C++ library
        Documentation
                Updated provided RFCs and I-Ds
index 148230ec01419f82c4c69cc716a66853a7647e82..c62a51cb53696d8df410ee97d116aa76db1dd9a3 100644 (file)
@@ -19,6 +19,8 @@
 #include <stdio.h>
 #include <ac/string.h>
 
+#include "lutil.h"
+
 #include "back-bdb.h"
 #include "external.h"
 
@@ -47,6 +49,8 @@ bdb_delete( Operation *op, SlapReply *rs )
        EntryInfo   *suffix_ei;
        Entry       *ctxcsn_e;
        int         ctxcsn_added = 0;
+       char            csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
+       struct berval   csn;
 
        LDAPControl **preread_ctrl = NULL;
        LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
@@ -65,6 +69,8 @@ bdb_delete( Operation *op, SlapReply *rs )
                op->o_req_dn.bv_val, 0, 0 );
 #endif
 
+       slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 );
+
        if( 0 ) {
 retry: /* transaction retry */
                if( e != NULL ) {
@@ -579,6 +585,19 @@ retry:     /* transaction retry */
                }
 
                if ( rs->sr_err == LDAP_SUCCESS && !op->o_no_psearch ) {
+                       Attribute *a;
+                       a = attr_find( e->e_attrs, slap_schema.si_ad_entryCSN );
+                       if ( a ) {
+                               if( (void *) e->e_attrs != (void *) (e+1)) {
+                                       attr_delete( &e->e_attrs, slap_schema.si_ad_entryCSN );
+                                       attr_merge_normalize_one( e, slap_schema.si_ad_entryCSN,
+                                       &csn, NULL );
+                               } else {
+                                       a->a_vals[0] = csn;
+                               }
+                       } else {
+                               /* Hm, the entryCSN ought to exist. ??? */
+                       }
                        ldap_pvt_thread_rdwr_wlock( &bdb->bi_pslist_rwlock );
                        LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
                                rc = bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_DELETE );
index afcfdcf1f7d3f687c3f1aeb775313541d7c3e676..354c1a902c4aef82f69604050c84e18f6d9d8832 100644 (file)
@@ -1324,7 +1324,7 @@ read_config( const char *fname, int depth )
                } else if ( strcasecmp( cargv[0], "allows" ) == 0 ||
                        strcasecmp( cargv[0], "allow" ) == 0 )
                {
-                       slap_mask_t     allows;
+                       slap_mask_t     allows = 0;
 
                        if ( be != NULL ) {
 #ifdef NEW_LOGGING
@@ -1353,8 +1353,6 @@ read_config( const char *fname, int depth )
                                return( 1 );
                        }
 
-                       allows = 0;
-
                        for( i=1; i < cargc; i++ ) {
                                if( strcasecmp( cargv[i], "bind_v2" ) == 0 ) {
                                        allows |= SLAP_ALLOW_BIND_V2;
@@ -1368,7 +1366,7 @@ read_config( const char *fname, int depth )
                                } else if( strcasecmp( cargv[i], "update_anon" ) == 0 ) {
                                        allows |= SLAP_ALLOW_UPDATE_ANON;
 
-                               } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
+                               } else {
 #ifdef NEW_LOGGING
                                        LDAP_LOG( CONFIG, CRIT, "%s: line %d: "
                                                "unknown feature %s in \"allow <features>\" line.\n",
@@ -1379,17 +1377,17 @@ read_config( const char *fname, int depth )
                                                fname, lineno, cargv[i] );
 #endif
 
-                                       return( 1 );
+                                       return 1;
                                }
                        }
 
-                       global_allows = allows;
+                       global_allows |= allows;
 
                /* disallow these features */
                } else if ( strcasecmp( cargv[0], "disallows" ) == 0 ||
                        strcasecmp( cargv[0], "disallow" ) == 0 )
                {
-                       slap_mask_t     disallows;
+                       slap_mask_t     disallows = 0; 
 
                        if ( be != NULL ) {
 #ifdef NEW_LOGGING
@@ -1418,8 +1416,6 @@ read_config( const char *fname, int depth )
                                return( 1 );
                        }
 
-                       disallows = 0;
-
                        for( i=1; i < cargc; i++ ) {
                                if( strcasecmp( cargv[i], "bind_anon" ) == 0 ) {
                                        disallows |= SLAP_DISALLOW_BIND_ANON;
@@ -1436,7 +1432,7 @@ read_config( const char *fname, int depth )
                                } else if( strcasecmp( cargv[i], "tls_authc" ) == 0 ) {
                                        disallows |= SLAP_DISALLOW_TLS_AUTHC;
 
-                               } else if( strcasecmp( cargv[i], "none" ) != 0 ) {
+                               } else {
 #ifdef NEW_LOGGING
                                        LDAP_LOG( CONFIG, CRIT, 
                                                "%s: line %d: unknown feature %s in "
@@ -1448,17 +1444,17 @@ read_config( const char *fname, int depth )
                                            fname, lineno, cargv[i] );
 #endif
 
-                                       return( 1 );
+                                       return 1;
                                }
                        }
 
-                       global_disallows = disallows;
+                       global_disallows |= disallows;
 
                /* require these features */
                } else if ( strcasecmp( cargv[0], "requires" ) == 0 ||
                        strcasecmp( cargv[0], "require" ) == 0 )
                {
-                       slap_mask_t     requires;
+                       slap_mask_t     requires = 0; 
 
                        if ( cargc < 2 ) {
 #ifdef NEW_LOGGING
@@ -1474,8 +1470,6 @@ read_config( const char *fname, int depth )
                                return( 1 );
                        }
 
-                       requires = 0;
-
                        for( i=1; i < cargc; i++ ) {
                                if( strcasecmp( cargv[i], "bind" ) == 0 ) {
                                        requires |= SLAP_REQUIRE_BIND;
@@ -2965,6 +2959,8 @@ add_syncrepl(
        si->si_attrsonly = 0;
        si->si_attrs = (char **) ch_calloc( 1, sizeof( char * ));
        si->si_attrs[0] = NULL;
+       si->si_exattrs = (char **) ch_calloc( 1, sizeof( char * ));
+       si->si_exattrs[0] = NULL;
        si->si_type = LDAP_SYNC_REFRESH_ONLY;
        si->si_interval = 86400;
        si->si_retryinterval = 0;
@@ -3023,6 +3019,14 @@ add_syncrepl(
                                }
                                ch_free( si_entry->si_attrs );
                        }
+                       if ( si_entry->si_exattrs ) {
+                               int i = 0;
+                               while ( si_entry->si_exattrs[i] != NULL ) {
+                                       ch_free( si_entry->si_exattrs[i] );
+                                       i++;
+                               }
+                               ch_free( si_entry->si_exattrs );
+                       }
                }
 
                while ( !LDAP_STAILQ_EMPTY( &be->be_syncinfo )) {
@@ -3076,6 +3080,7 @@ add_syncrepl(
 #define SCOPESTR               "scope"
 #define ATTRSSTR               "attrs"
 #define ATTRSONLYSTR   "attrsonly"
+#define EXATTRSSTR             "exattrs"
 #define TYPESTR                        "type"
 #define INTERVALSTR            "interval"
 #define LASTMODSTR             "lastmod"
@@ -3257,6 +3262,11 @@ parse_syncrepl_line(
                {
                        val = cargv[ i ] + sizeof( ATTRSSTR );
                        str2clist( &si->si_attrs, val, "," );
+               } else if ( !strncasecmp( cargv[ i ],
+                       EXATTRSSTR, sizeof( EXATTRSSTR ) - 1 ) )
+               {
+                       val = cargv[ i ] + sizeof( EXATTRSSTR );
+                       str2clist( &si->si_exattrs, val, "," );
                } else if ( !strncasecmp( cargv[ i ],
                        TYPESTR, sizeof( TYPESTR ) - 1 ) )
                {
index b44c156b20a58d5237edcb99b8bfad2a13750f11..63daf9438119e6d5bf90ebc5d106ef92704014b4 100644 (file)
@@ -1396,6 +1396,7 @@ typedef struct syncinfo_s {
         int                                    si_scope;
         int                                    si_attrsonly;
         char                           **si_attrs;
+        char                           **si_exattrs;
         int                                    si_type;
         time_t                         si_interval;
                time_t                          *si_retryinterval;
index 382bfda6004725d47d0795301cda700f98a77628..ed9d4c3d42710dc05d2915bb0603f1e12540f224 100644 (file)
@@ -109,6 +109,23 @@ init_syncrepl(syncinfo_t *si)
        }
        
        si->si_attrs = tmp;
+
+       for ( n = 0; si->si_exattrs[ n ] != NULL; n++ ) /* empty */;
+       if ( n ) {
+               /* Delete Attributes from exattrs list */
+               for ( i = 0; sync_descs[i] != NULL; i++ ) {
+                       for ( j = 0; si->si_exattrs[j] != NULL; j++ ) {
+                               if ( strcmp( si->si_exattrs[j], sync_descs[i]->ad_cname.bv_val )
+                                       == 0 )
+                               {
+                                       ch_free( si->si_exattrs[j] );
+                                       for ( k = j; si->si_exattrs[k] != NULL; k++ ) {
+                                               si->si_exattrs[k] = si->si_exattrs[k+1];
+                                       }
+                               }
+                       }
+               }
+       }
 }
 
 static int
@@ -1060,7 +1077,20 @@ syncrepl_message_to_entry(
                if ( mod->sml_desc->ad_type->sat_flags & SLAP_AT_DYNAMIC ) {
                        *modtail = mod->sml_next;
                        slap_mod_free( &mod->sml_mod, 0 );
-                       free( mod );
+                       ch_free( mod );
+               } else {
+                       modtail = &mod->sml_next;
+               }
+       }
+
+       /* Strip out attrs in exattrs list */
+       for ( modtail = modlist; *modtail ; ) {
+               mod = *modtail;
+               if ( ldap_charray_inlist( si->si_exattrs,
+                                       mod->sml_desc->ad_type->sat_cname.bv_val )) {
+                       *modtail = mod->sml_next;
+                       slap_mod_free( &mod->sml_mod, 0 );
+                       ch_free( mod );
                } else {
                        modtail = &mod->sml_next;
                }