From: Kurt Zeilenga Date: Wed, 1 Sep 2004 04:13:18 +0000 (+0000) Subject: Add ITS#3309 fix X-Git-Tag: OPENLDAP_REL_ENG_2_2_16~10 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=af4f2eda9a53d03cbc1ae33898d23300ee207e58;p=openldap Add ITS#3309 fix Add syncrepl exattrs --- diff --git a/CHANGES b/CHANGES index c51101c58a..6bb9f7a327 100644 --- 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 diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 148230ec01..c62a51cb53 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -19,6 +19,8 @@ #include #include +#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 ); diff --git a/servers/slapd/config.c b/servers/slapd/config.c index afcfdcf1f7..354c1a902c 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -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 \" 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 ) ) { diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index b44c156b20..63daf94381 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -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; diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 382bfda600..ed9d4c3d42 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -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; }