summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin@dahyabhai.net>2013-09-12 15:32:27 -0400
committerNalin Dahyabhai <nalin@dahyabhai.net>2013-09-12 15:32:27 -0400
commitfc646c3c86afc0c7817207bb598deb0df11387fa (patch)
treeb54902510bb308fe5b61496bf1ed9f6cf7eac704
parenteb43fd14cbe47e014139838200f31e01e1fc8a10 (diff)
downloadslapi-nis-fc646c3c86afc0c7817207bb598deb0df11387fa.tar.gz
slapi-nis-fc646c3c86afc0c7817207bb598deb0df11387fa.tar.xz
slapi-nis-fc646c3c86afc0c7817207bb598deb0df11387fa.zip
Add schema-compat-relevant-subtree
Add a schema-compat-relevant-subtree configuration option, listing the only parts of the DIT that we should ever look at, either as source entries or as other entries which contain data which might be pulled in as part of computing the contents of compat entries. This is more or less the whitelist to schema-compat-ignore-subtree's blacklist.
-rw-r--r--configure.ac7
-rw-r--r--src/back-nis.c3
-rw-r--r--src/back-sch.c8
-rw-r--r--src/back-shr.c31
-rw-r--r--src/backend.h3
5 files changed, 47 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 0d05c1f..44a665e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -466,9 +466,12 @@ AC_DEFINE_UNQUOTED(SCH_CONTAINER_CONFIGURATION_ACCESS_ATTR,"$checkaciattr",
schbaseattr=schema-compat-search-base
AC_DEFINE_UNQUOTED(SCH_CONTAINER_CONFIGURATION_BASE_ATTR,"$schbaseattr",
[Define to name of the attribute which lists the containers to search when locating entries to be used for constructing entries for a given container.])
-schignoreattr=schema-compat-ignore-subtree
-AC_DEFINE_UNQUOTED(SCH_CONTAINER_CONFIGURATION_IGNORE_SUBTREES_ATTR,"$schignoreattr",
+schignoresubtreeattr=schema-compat-ignore-subtree
+AC_DEFINE_UNQUOTED(SCH_CONTAINER_CONFIGURATION_IGNORE_SUBTREES_ATTR,"$schignoresubtreeattr",
[Define to name of the attribute which lists the subtrees to ignore when locating entries and reading data to be used for constructing entries for a given container.])
+schrelevantsubtreeattr=schema-compat-relevant-subtree
+AC_DEFINE_UNQUOTED(SCH_CONTAINER_CONFIGURATION_RELEVANT_SUBTREES_ATTR,"$schrelevantsubtreeattr",
+ [Define to name of the attribute which lists the only subtrees which are relevant when locating entries and reading data to be used for constructing entries for a given container.])
schfilterattr=schema-compat-search-filter
AC_DEFINE_UNQUOTED(SCH_CONTAINER_CONFIGURATION_FILTER_ATTR,"$schfilterattr",
[Define to name of the attribute which holds the filter for selecting entries to be used for constructing entries for a given container.])
diff --git a/src/back-nis.c b/src/back-nis.c
index f747f49..69a9c73 100644
--- a/src/back-nis.c
+++ b/src/back-nis.c
@@ -121,6 +121,7 @@ backend_copy_set_data(const struct backend_set_data *data)
ret->common.set = strdup(data->common.set);
ret->common.bases = backend_shr_dup_strlist(data->common.bases);
ret->common.entry_filter = strdup(data->common.entry_filter);
+ ret->common.relevant_subtrees = NULL;
ret->common.ignore_subtrees = NULL;
ret->common.rel_attrs = data->common.rel_attrs ?
format_dup_attr_list(data->common.rel_attrs) :
@@ -605,6 +606,7 @@ backend_set_config_read_config(struct plugin_state *state, Slapi_Entry *e,
ret.common.set = strdup(map);
ret.common.bases = use_bases;
ret.common.entry_filter = use_entry_filter;
+ ret.common.relevant_subtrees = NULL;
ret.common.ignore_subtrees = NULL;
ret.common.rel_attrs = NULL;
ret.common.rel_attr_list = NULL;
@@ -706,6 +708,7 @@ backend_set_config_read_config(struct plugin_state *state, Slapi_Entry *e,
free(ret.common.group);
free(ret.common.set);
backend_shr_free_strlist(ret.common.bases);
+ backend_shr_free_sdnlist(ret.common.relevant_subtrees);
free(ret.disallowed_chars);
free(ret.common.entry_filter);
backend_shr_free_strlist(ret.key_formats);
diff --git a/src/back-sch.c b/src/back-sch.c
index 047f2dc..3130fbc 100644
--- a/src/back-sch.c
+++ b/src/back-sch.c
@@ -79,6 +79,7 @@ backend_set_config_free_config_contents(void *data)
free(set_data->common.group);
free(set_data->common.set);
free(set_data->common.bases);
+ backend_shr_free_sdnlist(set_data->common.relevant_subtrees);
backend_shr_free_sdnlist(set_data->common.ignore_subtrees);
format_free_attr_list(set_data->common.rel_attrs);
free(set_data->common.rel_attr_list);
@@ -111,6 +112,7 @@ backend_copy_set_config(const struct backend_set_data *data)
ret->common.group = strdup(data->common.group);
ret->common.set = strdup(data->common.set);
ret->common.bases = backend_shr_dup_strlist(data->common.bases);
+ ret->common.relevant_subtrees = backend_shr_dup_sdnlist(data->common.relevant_subtrees);
ret->common.ignore_subtrees = backend_shr_dup_sdnlist(data->common.ignore_subtrees);
ret->common.rel_attrs = data->common.rel_attrs ?
format_dup_attr_list(data->common.rel_attrs) :
@@ -162,11 +164,13 @@ backend_set_config_read_config(struct plugin_state *state, Slapi_Entry *e,
bool_t check_access;
struct backend_set_data ret;
Slapi_DN *tmp_sdn;
- const Slapi_DN **ignore_subtrees;
+ const Slapi_DN **relevant_subtrees, **ignore_subtrees;
/* Read the values from the configuration entry. */
bases = backend_shr_get_vattr_strlist(state, e,
SCH_CONTAINER_CONFIGURATION_BASE_ATTR);
+ relevant_subtrees = backend_shr_get_vattr_sdnlist(state, e,
+ SCH_CONTAINER_CONFIGURATION_RELEVANT_SUBTREES_ATTR);
ignore_subtrees = backend_shr_get_vattr_sdnlist(state, e,
SCH_CONTAINER_CONFIGURATION_IGNORE_SUBTREES_ATTR);
entry_filter = backend_shr_get_vattr_filter(state, e,
@@ -189,6 +193,7 @@ backend_set_config_read_config(struct plugin_state *state, Slapi_Entry *e,
slapi_sdn_free(&tmp_sdn);
ret.common.set = strdup(container);
ret.common.bases = bases;
+ ret.common.relevant_subtrees = relevant_subtrees;
ret.common.ignore_subtrees = ignore_subtrees;
ret.common.entry_filter = entry_filter;
ret.common.rel_attrs = NULL;
@@ -254,6 +259,7 @@ backend_set_config_read_config(struct plugin_state *state, Slapi_Entry *e,
free(ret.common.group);
free(ret.common.set);
backend_shr_free_strlist(ret.common.bases);
+ backend_shr_free_sdnlist(ret.common.relevant_subtrees);
backend_shr_free_sdnlist(ret.common.ignore_subtrees);
free(ret.common.entry_filter);
slapi_sdn_free(&ret.container_sdn);
diff --git a/src/back-shr.c b/src/back-shr.c
index cabd01c..00ca097 100644
--- a/src/back-shr.c
+++ b/src/back-shr.c
@@ -317,7 +317,7 @@ backend_shr_free_sdnlist(const Slapi_DN **sdnlist)
{
int i;
for (i = 0; (sdnlist != NULL) && (sdnlist[i] != NULL); i++) {
- slapi_sdn_free(&sdnlist[i]);
+ slapi_sdn_free((Slapi_DN **) &sdnlist[i]);
sdnlist[i] = NULL;
}
free(sdnlist);
@@ -791,11 +791,12 @@ 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;
+ const Slapi_DN **relevant_subtrees, **ignore_subtrees;
char **set_bases;
char *set_filter;
int i;
+ relevant_subtrees = set_data->relevant_subtrees;
ignore_subtrees = set_data->ignore_subtrees;
set_bases = set_data->bases;
set_filter = set_data->entry_filter;
@@ -809,6 +810,19 @@ backend_shr_entry_matches_set(struct backend_shr_set_data *set_data,
}
}
}
+ 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) {
for (i = 0; set_bases[i] != NULL; i++) {
@@ -1013,6 +1027,19 @@ backend_shr_update_references_cb(const char *group, const char *set,
}
}
}
+ if (set_data->relevant_subtrees != NULL) {
+ for (i = 0; set_data->relevant_subtrees[i] != NULL; i++) {
+ if (slapi_sdn_scope_test(slapi_entry_get_sdn_const(cbdata->e),
+ set_data->relevant_subtrees[i],
+ LDAP_SCOPE_SUBTREE) != 0) {
+ break;
+ }
+ }
+ 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
* to this map, then we don't need to recompute anything. */
diff --git a/src/backend.h b/src/backend.h
index be6693d..8c00dd4 100644
--- a/src/backend.h
+++ b/src/backend.h
@@ -46,6 +46,9 @@ struct backend_shr_set_data {
/* Configuration flag indicating whether or not we try to skip
* recomputing data in this map. */
unsigned int skip_uninteresting_updates:1;
+ /* Subtrees under which all of the contents that we care about will be
+ * stored. Other locaoins will be silently ignored. */
+ const struct slapi_dn **relevant_subtrees;
/* Subtrees under which we ignore contents. */
const struct slapi_dn **ignore_subtrees;
struct backend_set_data *self;