summaryrefslogtreecommitdiffstats
path: root/src/back-shr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/back-shr.c')
-rw-r--r--src/back-shr.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/src/back-shr.c b/src/back-shr.c
index 5b7c6ec..cabd01c 100644
--- a/src/back-shr.c
+++ b/src/back-shr.c
@@ -284,6 +284,44 @@ backend_shr_set_entry_cb(Slapi_Entry *e, void *callback_data)
backend_shr_set_entry(cbdata->pb, e, cbdata->set_data);
return 0;
}
+static const Slapi_DN **
+backend_shr_dup_sdnlist_n(const Slapi_DN **sdnlist, int n)
+{
+ const Slapi_DN **ret;
+ int i;
+ /* Handle the NULL case. */
+ if (sdnlist == NULL) {
+ return NULL;
+ }
+ /* No DNs = no list. */
+ if (n == 0) {
+ return NULL;
+ }
+ ret = calloc(n + 1, sizeof(ret[0]));
+ for (i = 0; (sdnlist[i] != NULL) && (i < n); i++) {
+ ret[i] = slapi_sdn_dup(sdnlist[i]);
+ }
+ return ret;
+}
+const Slapi_DN **
+backend_shr_dup_sdnlist(const Slapi_DN **sdnlist)
+{
+ int i;
+ for (i = 0; (sdnlist != NULL) && (sdnlist[i] != NULL); i++) {
+ continue;
+ }
+ return backend_shr_dup_sdnlist_n(sdnlist, i);
+}
+void
+backend_shr_free_sdnlist(const Slapi_DN **sdnlist)
+{
+ int i;
+ for (i = 0; (sdnlist != NULL) && (sdnlist[i] != NULL); i++) {
+ slapi_sdn_free(&sdnlist[i]);
+ sdnlist[i] = NULL;
+ }
+ free(sdnlist);
+}
/* Set or unset the named entry using information in the callback data. */
static void
@@ -569,6 +607,38 @@ backend_shr_get_vattr_boolean(struct plugin_state *state,
return ret;
}
+const Slapi_DN **
+backend_shr_get_vattr_sdnlist(struct plugin_state *state,
+ Slapi_Entry *e, const char *attribute)
+{
+ Slapi_ValueSet *values;
+ Slapi_Value *value;
+ int disposition, buffer_flags;
+ char *actual_attr;
+ const Slapi_DN **ret;
+ int i, j;
+ ret = NULL;
+ if (slapi_vattr_values_get(e, (char *) attribute,
+ &values, &disposition, &actual_attr,
+ 0, &buffer_flags) == 0) {
+ ret = malloc(sizeof(ret[0]) *
+ (slapi_valueset_count(values) + 1));
+ if (ret != NULL) {
+ j = 0;
+ for (i = slapi_valueset_first_value(values, &value);
+ i != -1;
+ i = slapi_valueset_next_value(values, i, &value)) {
+ if (slapi_value_get_length(value) > 0) {
+ ret[j++] = slapi_sdn_new_dn_byval(slapi_value_get_string(value));
+ }
+ }
+ ret[j] = NULL;
+ }
+ slapi_vattr_values_free(&values, &actual_attr, buffer_flags);
+ }
+ return ret;
+}
+
/* Scan for the list of configured groups and sets. */
void
backend_shr_startup(struct plugin_state *state,
@@ -721,11 +791,25 @@ static bool_t
backend_shr_entry_matches_set(struct backend_shr_set_data *set_data,
Slapi_PBlock *pb, Slapi_Entry *e)
{
+ const Slapi_DN **ignore_subtrees;
char **set_bases;
char *set_filter;
int i;
+
+ ignore_subtrees = set_data->ignore_subtrees;
set_bases = set_data->bases;
set_filter = set_data->entry_filter;
+
+ if (ignore_subtrees != NULL) {
+ for (i = 0; ignore_subtrees[i] != NULL; i++) {
+ if (slapi_sdn_scope_test(slapi_entry_get_sdn_const(e),
+ ignore_subtrees[i],
+ LDAP_SCOPE_SUBTREE) != 0) {
+ return FALSE;
+ }
+ }
+ }
+
if (set_bases != NULL) {
for (i = 0; set_bases[i] != NULL; i++) {
if (backend_shr_entry_matches(pb, e,
@@ -736,6 +820,7 @@ backend_shr_entry_matches_set(struct backend_shr_set_data *set_data,
}
}
}
+
return FALSE;
}
@@ -916,6 +1001,19 @@ backend_shr_update_references_cb(const char *group, const char *set,
cbdata = cbdata_ptr;
state = set_data->state;
+ /* Check if this entry is in one of the areas we've been specifically
+ * told to ignore. */
+ if (set_data->ignore_subtrees != NULL) {
+ for (i = 0; set_data->ignore_subtrees[i] != NULL; i++) {
+ if (slapi_sdn_scope_test(slapi_entry_get_sdn_const(cbdata->e),
+ set_data->ignore_subtrees[i],
+ LDAP_SCOPE_SUBTREE) != 0) {
+ /* Yeah, we're done here. */
+ return TRUE;
+ }
+ }
+ }
+
/* If the entry didn't change any attributes which are at all relevant
* to this map, then we don't need to recompute anything. */
if (set_data->skip_uninteresting_updates &&