From 6f9025423fc5451fd83c5cc40e9cc8c743e82671 Mon Sep 17 00:00:00 2001 From: Jong Hyuk Choi Date: Sun, 29 Aug 2004 22:28:28 +0000 Subject: [PATCH] ITS#3289 - exattrs support --- servers/slapd/config.c | 16 ++++++++++++++++ servers/slapd/slap.h | 1 + servers/slapd/syncrepl.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 396a90321d..0057cf0b82 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -3164,6 +3164,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; @@ -3222,6 +3224,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 )) { @@ -3275,6 +3285,7 @@ add_syncrepl( #define SCOPESTR "scope" #define ATTRSSTR "attrs" #define ATTRSONLYSTR "attrsonly" +#define EXATTRSSTR "exattrs" #define TYPESTR "type" #define INTERVALSTR "interval" #define LASTMODSTR "lastmod" @@ -3456,6 +3467,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 822de99a02..cab135a846 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -1437,6 +1437,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 b92f3d2f98..557ab5b567 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -110,6 +110,22 @@ 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 @@ -1077,7 +1093,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; } -- 2.39.5