]> git.sur5r.net Git - openldap/commitdiff
ITS#3289 - exattrs support
authorJong Hyuk Choi <jongchoi@openldap.org>
Sun, 29 Aug 2004 22:28:28 +0000 (22:28 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Sun, 29 Aug 2004 22:28:28 +0000 (22:28 +0000)
servers/slapd/config.c
servers/slapd/slap.h
servers/slapd/syncrepl.c

index 396a90321d58720c9e4914afe4f74c2b1b6af3b0..0057cf0b82433f0ba8872047194cfbe7d31a7af7 100644 (file)
@@ -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 ) )
                {
index 822de99a02288d4852c51667bd758b73851d12fc..cab135a846f045d390a30fbc310c025989dae3f2 100644 (file)
@@ -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;
index b92f3d2f9848e97a9d91c37684005e2f301fcdf5..557ab5b5670cb82086fbd05bbb73cb53d65f39e3 100644 (file)
@@ -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;
                }