summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-04-08 23:18:49 +1000
committerAndrew Bartlett <abartlet@samba.org>2009-04-08 23:18:49 +1000
commitdb29383797e10496dab16fc4729272dcfe090858 (patch)
tree7e388e2feaaf0052956ce5a27c66610a84d841a0 /source4/dsdb/schema
parent54f7523db1848d75f61a8f02968de30bd6c49804 (diff)
downloadsamba-db29383797e10496dab16fc4729272dcfe090858.tar.gz
samba-db29383797e10496dab16fc4729272dcfe090858.tar.bz2
samba-db29383797e10496dab16fc4729272dcfe090858.zip
Make the schema_inferiors generation code to compile
Sadly it still segfaults at this stage Andrew Bartlett
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r--source4/dsdb/schema/schema.h6
-rw-r--r--source4/dsdb/schema/schema_inferiors.c143
-rw-r--r--source4/dsdb/schema/schema_set.c19
3 files changed, 99 insertions, 69 deletions
diff --git a/source4/dsdb/schema/schema.h b/source4/dsdb/schema/schema.h
index 98ccf5ed9e..92cfe113d4 100644
--- a/source4/dsdb/schema/schema.h
+++ b/source4/dsdb/schema/schema.h
@@ -132,6 +132,12 @@ struct dsdb_class {
bool defaultHidingValue;
bool isDefunct;
bool systemOnly;
+
+ char **supclasses;
+ char **subclasses;
+ char **subclasses_direct;
+ char **posssuperiors;
+ char **possible_inferiors;
};
struct dsdb_schema_oid_prefix {
diff --git a/source4/dsdb/schema/schema_inferiors.c b/source4/dsdb/schema/schema_inferiors.c
index d9afff24a3..abd8f7e4b0 100644
--- a/source4/dsdb/schema/schema_inferiors.c
+++ b/source4/dsdb/schema/schema_inferiors.c
@@ -35,11 +35,14 @@
/*
create the SUPCLASSES() list
*/
-static char **schema_supclasses(struct dsdb_schema *schema,
- TALLOC_CTX *mem_ctx, const char *oc)
+static char * const *schema_supclasses(struct dsdb_schema *schema,
+ TALLOC_CTX *mem_ctx, struct dsdb_class *schema_class)
{
- char **list;
- const struct dsdb_class *class;
+ char * const *list;
+
+ if (schema_class->supclasses) {
+ return schema_class->supclasses;
+ }
list = str_list_make(mem_ctx, NULL, NULL);
if (list == NULL) {
@@ -47,28 +50,21 @@ static char **schema_supclasses(struct dsdb_schema *schema,
return NULL;
}
- if (strcmp(oc, "top") == 0) {
+ /* Cope with 'top SUP top', ie top is subClassOf top */
+ if (strcmp(schema_class->lDAPDisplayName, schema_class->subClassOf) == 0) {
+ schema_class->supclasses = list;
return list;
}
- class = dsdb_class_by_lDAPDisplayName(schema, oc);
- if (class == NULL) {
- DEBUG(0,(__location__ " objectClass '%s' does not exist\n", oc));
- return NULL;
- }
-
- if (class->supclasses) {
- return class->supclasses;
- }
-
- if (class->subClassOf) {
+ if (schema_class->subClassOf) {
char **list2;
- list = str_list_add(list, class->subClassOf);
- list2 = schema_supclasses(schema, mem_ctx, class->subClassOf);
+ list = str_list_add(list, schema_class->subClassOf);
+
+ list2 = schema_supclasses(schema, mem_ctx, dsdb_class_by_lDAPDisplayName(schema, schema_class->subClassOf));
list = str_list_append(list, list2);
}
- class->supclasses = list;
+ schema_class->supclasses = list;
return list;
}
@@ -78,15 +74,14 @@ static char **schema_supclasses(struct dsdb_schema *schema,
matches SUBCLASSES() python function
*/
static char **schema_subclasses(struct dsdb_schema *schema, TALLOC_CTX *mem_ctx,
- const char **oclist)
+ const char * const *oclist)
{
- const char *oc;
char **list = str_list_make(mem_ctx, NULL, NULL);
int i;
for (i=0; oclist && oclist[i]; i++) {
- struct dsdb_class *class = dsdb_class_by_lDAPDisplayName(schema, oclist[i]);
- list = str_list_append(list, class->subclasses);
+ struct dsdb_class *schema_class = dsdb_class_by_lDAPDisplayName(schema, oclist[i]);
+ list = str_list_append(list, schema_class->subclasses);
}
return list;
}
@@ -96,77 +91,87 @@ static char **schema_subclasses(struct dsdb_schema *schema, TALLOC_CTX *mem_ctx,
equivalent of the POSSSUPERIORS() python function
*/
static char **schema_posssuperiors(struct dsdb_schema *schema, TALLOC_CTX *mem_ctx,
- const char **oclist)
+ struct dsdb_class *schema_class)
{
- const char *oc;
char **list = str_list_make(mem_ctx, NULL, NULL);
- int i;
- for (i=0; oclist && oclist[i]; i++) {
- struct dsdb_class *class = dsdb_class_by_lDAPDisplayName(schema, oclist[i]);
- if (class->posssuperiors) {
- list = str_list_append(list, class->posssuperiors);
- } else {
- char **list2 = str_list_make(mem_ctx, NULL, NULL);
- list2 = str_list_append(list2, class->systemPossSuperiors);
- list2 = str_list_append(list2, class->possSuperiors);
- list2 = str_list_append(list2, schema_supclasses(schema, list2, oclist[i]));
- list2 = str_list_append(list2, schema_subclasses(schema, list2, list2));
- class->posssuperiors = list2;
- list = str_list_append(list, list2);
- }
+ if (schema_class->posssuperiors) {
+ return schema_class->posssuperiors;
+ } else {
+ char * const *list2 = str_list_make(mem_ctx, NULL, NULL);
+ list2 = str_list_append(list2, schema_class->systemPossSuperiors);
+ list2 = str_list_append(list2, schema_class->possSuperiors);
+ list2 = str_list_append(list2, schema_supclasses(schema, list2, schema_class));
+ list2 = str_list_append(list2, schema_subclasses(schema, list2, list2));
+
+ schema_class->posssuperiors = list2;
+ return schema_class->posssuperiors;
}
return list;
}
-static char **schema_subclasses_recurse(struct dsdb_schema *schema, struct dsdb_class *class)
+static char **schema_subclasses_recurse(struct dsdb_schema *schema, struct dsdb_class *schema_class)
{
- char **list = str_list_copy(class, class->subclasses_direct);
+ char * const *list = str_list_copy(schema_class, schema_class->subclasses_direct);
int i;
for (i=0;list && list[i]; i++) {
- struct dsdb_class *class2 = dsdb_class_by_lDAPDisplayName(schema, list[i]);
- list = str_list_append(list, schema_subclasses_recurse(schema, class2));
+ struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, list[i]);
+ if (schema_class != schema_class2) {
+ list = str_list_append(list, schema_subclasses_recurse(schema, schema_class2));
+ }
}
return list;
}
static void schema_create_subclasses(struct dsdb_schema *schema)
{
- struct dsdb_class *class;
-
- for (class=schema->classes; class; class=class->next) {
- struct dsdb_class *class2 = dsdb_class_by_lDAPDisplayName(schema, class->subClassOf);
- class->subclasses_direct = str_list_make(class, NULL, NULL);
- if (class != class2) {
- if (class2->subclasses_direct == NULL) {
- class2->subclasses_direct = str_list_make(class2, NULL, NULL);
+ struct dsdb_class *schema_class;
+
+ for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) {
+ struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, schema_class->subClassOf);
+ schema_class->subclasses_direct = str_list_make(schema_class, NULL, NULL);
+ if (schema_class != schema_class2) {
+ if (schema_class2->subclasses_direct == NULL) {
+ schema_class2->subclasses_direct = str_list_make(schema_class2, NULL, NULL);
}
- class2->subclasses_direct = str_list_add(class2->subclasses_direct,
- class->subClassOf);
+ schema_class2->subclasses_direct = str_list_add(schema_class2->subclasses_direct,
+ schema_class->subClassOf);
}
}
- for (class=schema->classes; class; class=class->next) {
- class->subclasses = schema_subclasses_recurse(schema, class);
+ for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) {
+ schema_class->subclasses = schema_subclasses_recurse(schema, schema_class);
}
}
-void schema_fill_possible_inferiors(struct dsdb_schema *schema, struct dsdb_class *class)
+static void schema_fill_possible_inferiors(struct dsdb_schema *schema, struct dsdb_class *schema_class)
{
struct dsdb_class *c2;
-
+
+ for (c2=schema->classes; c2; c2=c2->next) {
+ char **superiors = schema_posssuperiors(schema, c2, c2);
+ if (c2->systemOnly == false
+ && c2->objectClassCategory != 2
+ && c2->objectClassCategory != 3
+ && str_list_check(superiors, schema_class->lDAPDisplayName)) {
+ if (c2->possible_inferiors == NULL) {
+ c2->possible_inferiors = str_list_make(c2, NULL, NULL);
+ }
+ c2->possible_inferiors = str_list_add_unique(c2->possible_inferiors,
+ schema_class->lDAPDisplayName);
+ }
+ talloc_free(superiors);
+ }
}
-def possible_inferiors_constructed(db, classinfo, c):
- list = []
- for oc in classinfo:
- superiors = POSSSUPERIORS(classinfo, [oc])
- if (is_in_list(superiors, c) and
- classinfo[oc]["systemOnly"] == False and
- classinfo[oc]["objectClassCategory"] != 2 and
- classinfo[oc]["objectClassCategory"] != 3):
- list.append(oc)
- list = uniq_list(list)
- list.sort()
- return list
+void schema_fill_constructed(struct dsdb_schema *schema)
+{
+ struct dsdb_class *schema_class;
+
+ schema_create_subclasses(schema);
+
+ for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) {
+ schema_fill_possible_inferiors(schema, schema_class);
+ }
+}
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index 725fe845ad..dcaeb4fc89 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -309,6 +309,23 @@ failed:
return LDB_ERR_OPERATIONS_ERROR;
}
+int dsdb_setup_schema_inversion(struct ldb_context *ldb, struct dsdb_schema *schema)
+{
+ /* Walk the list of schema classes */
+
+ /* For each subClassOf, add us to subclasses of the parent */
+
+ /* collect these subclasses into a recursive list of total subclasses, preserving order */
+
+ /* For each subclass under 'top', write the index from it's
+ * order as an integer in the dsdb_class (for sorting
+ * objectClass lists efficiently) */
+
+ /* Walk the list of scheam classes */
+
+ /* Create a 'total possible superiors' on each class */
+ return LDB_SUCCESS;
+}
/**
* Attach the schema to an opaque pointer on the ldb, so ldb modules
@@ -324,6 +341,8 @@ int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
return ret;
}
+ schema_fill_constructed(schema);
+
ret = ldb_set_opaque(ldb, "dsdb_schema", schema);
if (ret != LDB_SUCCESS) {
return ret;