summaryrefslogtreecommitdiffstats
path: root/src/back-shr.c
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-06-30 18:14:02 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-06-30 18:14:02 -0400
commit3feea09ddbed94e96c12934e23f94071d804db0a (patch)
tree4fce1a614e2744ded55664a24c21f2720d9a9315 /src/back-shr.c
parent38fcfada8270bf022d7bedc884fda7de79478a33 (diff)
- take out the need for a backend to provide a matching test
- start adding configuration for the schema plugin
Diffstat (limited to 'src/back-shr.c')
-rw-r--r--src/back-shr.c103
1 files changed, 56 insertions, 47 deletions
diff --git a/src/back-shr.c b/src/back-shr.c
index 6af8883..acc010d 100644
--- a/src/back-shr.c
+++ b/src/back-shr.c
@@ -243,6 +243,52 @@ backend_shr_set_config_entry_set_one_dn(struct plugin_state *state,
}
}
+/* Check if the given entry is somewhere beneath the NDN and matches the
+ * filter. */
+bool_t
+backend_shr_entry_matches(Slapi_PBlock *pb, Slapi_Entry *e,
+ const char *containing_ndn, int scope,
+ const char *check_filter)
+{
+ struct plugin_state *state;
+ Slapi_DN *entry_sdn, *containing_sdn;
+ Slapi_Filter *filter;
+ bool_t ret;
+
+ /* First, just do the scope test. The item should be a somewhere
+ * beneath the passed-in entry. */
+ entry_sdn = slapi_sdn_new_ndn_byref(slapi_entry_get_ndn(e));
+ if (entry_sdn == NULL) {
+ return FALSE;
+ } else {
+ containing_sdn = slapi_sdn_new_ndn_byval(containing_ndn);
+ if (containing_sdn == NULL) {
+ slapi_sdn_free(&entry_sdn);
+ return FALSE;
+ }
+ }
+ if (slapi_sdn_scope_test(entry_sdn, containing_sdn, scope) == 0) {
+ ret = FALSE;
+ } else {
+ ret = TRUE;
+ }
+ slapi_sdn_free(&containing_sdn);
+ slapi_sdn_free(&entry_sdn);
+
+ /* If it's actually in our configuration tree, check if it's a valid
+ * entry. */
+ if (ret) {
+ filter = slapi_str2filter((char *) check_filter);
+ if (filter != NULL) {
+ if (slapi_vattr_filter_test(pb, e, filter, 0) != 0) {
+ ret = FALSE;
+ }
+ slapi_filter_free(filter, 1);
+ }
+ }
+ return ret;
+}
+
/* Given a directory server entry which represents a set's configuration, set
* up and populate the set. */
static void
@@ -444,59 +490,22 @@ bool_t
backend_shr_entry_matches_set(struct backend_set_data *set_data,
Slapi_PBlock *pb, Slapi_Entry *e)
{
- Slapi_DN *base_sdn;
- const Slapi_DN *entry_sdn;
- Slapi_Filter *filter;
char **set_bases;
char *set_filter;
int i;
- /* Decide if the directory server entry belongs in this map. That
- * means that it must be contained by one of the bases of the map. */
- entry_sdn = slapi_sdn_new_ndn_byref(slapi_entry_get_ndn(e));
- if (entry_sdn == NULL) {
- return FALSE;
- } else {
- /* Check each base in turn. */
- set_bases = backend_set_config_get_bases(set_data);
- for (i = 0;
- (set_bases != NULL) && (set_bases[i] != NULL);
- i++) {
- base_sdn = slapi_sdn_new_dn_byval(set_bases[i]);
- if (base_sdn == NULL) {
- return FALSE;
- } else {
- if (slapi_sdn_scope_test(entry_sdn,
- base_sdn,
- LDAP_SCOPE_SUB) == 0) {
- /* The entry is not contained by the
- * base -- go on to try the next one. */
- slapi_sdn_free(&base_sdn);
- continue;
- }
- /* The entry is contained by the base. */
- slapi_sdn_free(&base_sdn);
- break;
- }
- }
- /* If we ran out of bases to check, it doesn't match. */
- if ((set_bases == NULL) || (set_bases[i] == NULL)) {
- return FALSE;
- }
- }
- /* If it's contained by a search base, compare it to the filter. */
+ set_bases = backend_set_config_get_bases(set_data);
set_filter = backend_set_config_get_filter(set_data);
- filter = slapi_str2filter(set_filter);
- if (filter == NULL) {
- return FALSE;
- } else {
- if (slapi_vattr_filter_test(pb, e, filter, 0) != 0) {
- /* Didn't match -- return. */
- slapi_filter_free(filter, 1);
- return FALSE;
+ if (set_bases != NULL) {
+ for (i = 0; set_bases[i] != NULL; i++) {
+ if (backend_shr_entry_matches(pb, e,
+ set_bases[i],
+ LDAP_SCOPE_SUB,
+ set_filter)) {
+ return TRUE;
+ }
}
- slapi_filter_free(filter, 1);
}
- return TRUE;
+ return FALSE;
}
/* Given an entry, return true if it describes a set. */