static int slapi_over_compute_output( computed_attr_context *c, Slapi_Attr *attribute, Slapi_Entry *entry ) { Attribute **a; AttributeDescription *desc; SlapReply *rs; if ( c == NULL || attribute == NULL || entry == NULL ) { return 0; } rs = (SlapReply *)c->cac_private; assert( rs->sr_entry == entry ); desc = attribute->a_desc; if ( rs->sr_attrs == NULL ) { /* All attrs request, skip operational attributes */ if ( is_at_operational( desc->ad_type ) ) { return 0; } } else { /* Specific attributes requested */ if ( is_at_operational( desc->ad_type ) ) { if ( !SLAP_OPATTRS( rs->sr_attr_flags ) && !ad_inlist( desc, rs->sr_attrs ) ) { return 0; } } else { if ( !SLAP_USERATTRS( rs->sr_attr_flags ) && !ad_inlist( desc, rs->sr_attrs ) ) { return 0; } } } /* XXX perhaps we should check for existing attributes and merge */ for ( a = &rs->sr_operational_attrs; *a != NULL; a = &(*a)->a_next ) ; *a = slapi_attr_dup( attribute ); return 0; }
/* * memberof_copy_config() * * Makes a copy of the config in src. This function will free the * elements of dest if they already exist. This should only be called * if you hold the memberof config lock if src was obtained with * memberof_get_config(). */ void memberof_copy_config(MemberOfConfig *dest, MemberOfConfig *src) { if (dest && src) { /* Check if the copy is already up to date */ if (src->groupattrs) { int i = 0, j = 0; /* Copy group attributes string list. */ slapi_ch_array_free(dest->groupattrs); dest->groupattrs = slapi_ch_array_dup(src->groupattrs); /* Copy group check filter. */ slapi_filter_free(dest->group_filter, 1); dest->group_filter = slapi_filter_dup(src->group_filter); /* Copy group attributes Slapi_Attr list. * First free the old list. */ for (i = 0; dest->group_slapiattrs && dest->group_slapiattrs[i]; i++) { slapi_attr_free(&dest->group_slapiattrs[i]); } /* Count how many values we have in the source list. */ for (j = 0; src->group_slapiattrs[j]; j++) { /* Do nothing. */ } /* Realloc dest if necessary. */ if (i < j) { dest->group_slapiattrs = (Slapi_Attr **)slapi_ch_realloc((char *)dest->group_slapiattrs, sizeof(Slapi_Attr *) * (j + 1)); } /* Copy the attributes. */ for (i = 0; src->group_slapiattrs[i]; i++) { dest->group_slapiattrs[i] = slapi_attr_dup(src->group_slapiattrs[i]); } /* Terminate the array. */ dest->group_slapiattrs[i] = NULL; } if (src->memberof_attr) { slapi_ch_free_string(&dest->memberof_attr); dest->memberof_attr = slapi_ch_strdup(src->memberof_attr); } if(src->skip_nested){ dest->skip_nested = src->skip_nested; } if(src->allBackends) { dest->allBackends = src->allBackends; } slapi_ch_free_string(&dest->auto_add_oc); dest->auto_add_oc = slapi_ch_strdup(src->auto_add_oc); if(src->entryScopes){ int num_vals = 0; dest->entryScopes = (Slapi_DN **)slapi_ch_calloc(sizeof(Slapi_DN *),src->entryScopeCount+1); for(num_vals = 0; src->entryScopes[num_vals]; num_vals++){ dest->entryScopes[num_vals] = slapi_sdn_dup(src->entryScopes[num_vals]); } } if(src->entryScopeExcludeSubtrees){ int num_vals = 0; dest->entryScopeExcludeSubtrees = (Slapi_DN **)slapi_ch_calloc(sizeof(Slapi_DN *),src->entryExcludeScopeCount+1); for(num_vals = 0; src->entryScopeExcludeSubtrees[num_vals]; num_vals++){ dest->entryScopeExcludeSubtrees[num_vals] = slapi_sdn_dup(src->entryScopeExcludeSubtrees[num_vals]); } } } }