diff options
Diffstat (limited to 'src/back-shr.c')
-rw-r--r-- | src/back-shr.c | 113 |
1 files changed, 72 insertions, 41 deletions
diff --git a/src/back-shr.c b/src/back-shr.c index 00ca097..63ed700 100644 --- a/src/back-shr.c +++ b/src/back-shr.c @@ -284,6 +284,30 @@ backend_shr_set_entry_cb(Slapi_Entry *e, void *callback_data) backend_shr_set_entry(cbdata->pb, e, cbdata->set_data); return 0; } +void +backend_shr_add_sdnlist(const Slapi_DN ***sdnlist, const char *dn) +{ + const Slapi_DN **ret; + int i = 0; + if (dn == NULL) { + return NULL; + } + if ((sdnlist != NULL) && (*sdnlist != NULL)) { + for (i = 0; (*sdnlist)[i] != NULL; i++) { + continue; + } + } + ret = calloc(i + 2, sizeof(ret[0])); + if (ret != NULL) { + if ((sdnlist != NULL) && (*sdnlist != NULL)) { + memcpy(ret, *sdnlist, (i + 1) * sizeof(ret[0])); + free(*sdnlist); + } + ret[i] = slapi_sdn_new_dn_byval(dn); + ret[i + 1] = NULL; + *sdnlist = ret; + } +} static const Slapi_DN ** backend_shr_dup_sdnlist_n(const Slapi_DN **sdnlist, int n) { @@ -791,48 +815,54 @@ static bool_t backend_shr_entry_matches_set(struct backend_shr_set_data *set_data, Slapi_PBlock *pb, Slapi_Entry *e) { - const Slapi_DN **relevant_subtrees, **ignore_subtrees; + const Slapi_DN **restrict_subtrees, **ignore_subtrees; char **set_bases; char *set_filter; int i; - relevant_subtrees = set_data->relevant_subtrees; + restrict_subtrees = set_data->restrict_subtrees; 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 (relevant_subtrees != NULL) { - for (i = 0; relevant_subtrees[i] != NULL; i++) { - if (slapi_sdn_scope_test(slapi_entry_get_sdn_const(e), - relevant_subtrees[i], - LDAP_SCOPE_SUBTREE) != 0) { - break; - } - } - if (relevant_subtrees[i] == NULL) { - /* Non-empty list, but no match. */ - return FALSE; - } - } - if (set_bases != NULL) { + /* Check if it's in the map's configured area(s). */ for (i = 0; set_bases[i] != NULL; i++) { if (backend_shr_entry_matches(pb, e, set_bases[i], LDAP_SCOPE_SUBTREE, set_filter)) { - return TRUE; + break; } } + if (set_bases[i] != NULL) { + /* If it is, then check that it's in the subtrees we're + * restricting updates to... */ + if (restrict_subtrees != NULL) { + for (i = 0; restrict_subtrees[i] != NULL; i++) { + if (slapi_sdn_scope_test(slapi_entry_get_sdn_const(e), + restrict_subtrees[i], + LDAP_SCOPE_SUBTREE) != 0) { + break; + } + } + if (restrict_subtrees[i] == NULL) { + /* Non-empty list, but no match. */ + return FALSE; + } + } + /* ... and not in one that we intend to ignore. */ + 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; + } + } + } + return TRUE; + } } return FALSE; @@ -1015,30 +1045,31 @@ 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 it is, then check that it's in one of the subtrees we're + * restricting updates to... */ + if (set_data->restrict_subtrees != NULL) { + for (i = 0; set_data->restrict_subtrees[i] != NULL; i++) { if (slapi_sdn_scope_test(slapi_entry_get_sdn_const(cbdata->e), - set_data->ignore_subtrees[i], + set_data->restrict_subtrees[i], LDAP_SCOPE_SUBTREE) != 0) { - /* Yeah, we're done here. */ - return TRUE; + break; } } + if (set_data->restrict_subtrees[i] == NULL) { + /* Non-empty list, but no match. */ + return TRUE; + } } - if (set_data->relevant_subtrees != NULL) { - for (i = 0; set_data->relevant_subtrees[i] != NULL; i++) { + /* ... and not in one that we intend 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->relevant_subtrees[i], + set_data->ignore_subtrees[i], LDAP_SCOPE_SUBTREE) != 0) { - break; + /* Yeah, we're done here. */ + return TRUE; } } - if (set_data->relevant_subtrees[i] == NULL) { - /* Non-empty list, but no match. */ - return TRUE; - } } /* If the entry didn't change any attributes which are at all relevant |