[SCM] Samba Shared Repository - branch v4-0-test updated -
release-4-0-0alpha5-278-gb4b14b7
Andrew Bartlett
abartlet at samba.org
Fri Aug 15 10:42:10 GMT 2008
The branch, v4-0-test has been updated
via b4b14b748e6babc93faee23fe8f5c03ec2d25cbb (commit)
via c7c32ec7b42bdf0f7b669644516438c71b364e60 (commit)
via e3591a6a35ddb60398a03a4fa0545cc6158946ef (commit)
via 7d2a890a7077e446e45527847f78bba84d22bc4c (commit)
via e711f7d26a632ec93c1e2a3db52c37e1c0de4214 (commit)
from d548f5dee5980eae0aea25f1314238eb4f963568 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test
- Log -----------------------------------------------------------------
commit b4b14b748e6babc93faee23fe8f5c03ec2d25cbb
Merge: c7c32ec7b42bdf0f7b669644516438c71b364e60 d548f5dee5980eae0aea25f1314238eb4f963568
Author: Andrew Bartlett <abartlet at samba.org>
Date: Fri Aug 15 20:41:50 2008 +1000
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into 4-0-abartlet
commit c7c32ec7b42bdf0f7b669644516438c71b364e60
Author: Andrew Bartlett <abartlet at samba.org>
Date: Fri Aug 15 20:40:57 2008 +1000
Generate the subSchema in cn=Aggregate
This reads the schema from the in-memory structure, when the magic
attributes are requested. The code is a modified version of that used
in the ad2oLschema tool (now shared).
The schema_fsmo module handles the insertion of the generated result.
As such, this commit also removes these entries from the setup/schema.ldif
Metze's previous stub of this functionality is also removed.
Andrew Bartlett
commit e3591a6a35ddb60398a03a4fa0545cc6158946ef
Author: Andrew Bartlett <abartlet at samba.org>
Date: Fri Aug 15 13:18:48 2008 +1000
Rework generation of the objectClass and attributeType lines.
Now that these are subroutines, we can factor them out into a file the
CN=Aggregate schema code can also use.
Andrew Bartlett
commit 7d2a890a7077e446e45527847f78bba84d22bc4c
Author: Andrew Bartlett <abartlet at samba.org>
Date: Fri Aug 15 12:08:10 2008 +1000
Paramaterise the seperator in ad2OLschema
This will allow me to add a new mode, with the CN=Aggregate schema
format automatically generated.
Andrew Bartlett
commit e711f7d26a632ec93c1e2a3db52c37e1c0de4214
Author: Andrew Bartlett <abartlet at samba.org>
Date: Fri Aug 15 09:46:51 2008 +1000
Don't segfault in RPC-ATSVC.
-----------------------------------------------------------------------
Summary of changes:
source/dsdb/config.mk | 3 +-
source/dsdb/samdb/ldb_modules/schema_fsmo.c | 206 ++++++++++-
source/dsdb/schema/schema.h | 14 +
source/dsdb/schema/schema_constructed.c | 186 ---------
source/dsdb/schema/schema_convert.c | 160 ++++++++
source/dsdb/schema/schema_convert.h | 10 +
source/dsdb/schema/schema_description.c | 316 +++++++++++++++
source/dsdb/schema/schema_init.c | 97 +++--
source/lib/ldb/tests/python/ldap.py | 30 ++
source/setup/schema.ldif | 549 ---------------------------
source/torture/rpc/atsvc.c | 4 +-
source/utils/ad2oLschema.c | 255 ++++---------
source/utils/config.mk | 6 +-
source/utils/schema_convert.c | 173 ---------
source/utils/schema_convert.h | 10 -
testprogs/ejs/minschema.js | 41 +--
16 files changed, 862 insertions(+), 1198 deletions(-)
delete mode 100644 source/dsdb/schema/schema_constructed.c
create mode 100644 source/dsdb/schema/schema_convert.c
create mode 100644 source/dsdb/schema/schema_convert.h
create mode 100644 source/dsdb/schema/schema_description.c
delete mode 100644 source/utils/schema_convert.c
delete mode 100644 source/utils/schema_convert.h
Changeset truncated at 500 lines:
diff --git a/source/dsdb/config.mk b/source/dsdb/config.mk
index 7b700fd..d430c3f 100644
--- a/source/dsdb/config.mk
+++ b/source/dsdb/config.mk
@@ -35,7 +35,8 @@ PRIVATE_DEPENDENCIES = SAMDB_COMMON NDR_DRSUAPI NDR_DRSBLOBS
SAMDB_SCHEMA_OBJ_FILES = $(addprefix $(dsdbsrcdir)/schema/, \
schema_init.o \
schema_syntax.o \
- schema_constructed.o)
+ schema_description.o \
+ schema_convert.o)
$(eval $(call proto_header_template,$(dsdbsrcdir)/schema/proto.h,$(SAMDB_SCHEMA_OBJ_FILES:.o=.c)))
# PUBLIC_HEADERS += dsdb/schema/schema.h
diff --git a/source/dsdb/samdb/ldb_modules/schema_fsmo.c b/source/dsdb/samdb/ldb_modules/schema_fsmo.c
index 87ada85..706b7b1 100644
--- a/source/dsdb/samdb/ldb_modules/schema_fsmo.c
+++ b/source/dsdb/samdb/ldb_modules/schema_fsmo.c
@@ -32,6 +32,40 @@
#include "lib/util/dlinklist.h"
#include "param/param.h"
+static int generate_objectClasses(struct ldb_context *ldb, struct ldb_message *msg,
+ const struct dsdb_schema *schema);
+static int generate_attributeTypes(struct ldb_context *ldb, struct ldb_message *msg,
+ const struct dsdb_schema *schema);
+static int generate_dITContentRules(struct ldb_context *ldb, struct ldb_message *msg,
+ const struct dsdb_schema *schema);
+
+static const struct {
+ const char *attr;
+ int (*fn)(struct ldb_context *, struct ldb_message *, const struct dsdb_schema *);
+} generated_attrs[] = {
+ {
+ .attr = "objectClasses",
+ .fn = generate_objectClasses
+ },
+ {
+ .attr = "attributeTypes",
+ .fn = generate_attributeTypes
+ },
+ {
+ .attr = "dITContentRules",
+ .fn = generate_dITContentRules
+ }
+};
+
+struct schema_fsmo_private_data {
+ struct ldb_dn *aggregate_dn;
+};
+
+struct schema_fsmo_search_data {
+ struct schema_fsmo_private_data *module_context;
+ struct ldb_request *orig_req;
+};
+
static int schema_fsmo_init(struct ldb_module *module)
{
TALLOC_CTX *mem_ctx;
@@ -39,10 +73,7 @@ static int schema_fsmo_init(struct ldb_module *module)
struct dsdb_schema *schema;
char *error_string = NULL;
int ret;
-
- if (dsdb_get_schema(module->ldb)) {
- return ldb_next_init(module);
- }
+ struct schema_fsmo_private_data *data;
schema_dn = samdb_schema_dn(module->ldb);
if (!schema_dn) {
@@ -52,6 +83,25 @@ static int schema_fsmo_init(struct ldb_module *module)
return ldb_next_init(module);
}
+ data = talloc(module, struct schema_fsmo_private_data);
+ if (data == NULL) {
+ ldb_oom(module->ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ /* Check to see if this is a result on the CN=Aggregate schema */
+ data->aggregate_dn = ldb_dn_copy(data, schema_dn);
+ if (!ldb_dn_add_child_fmt(data->aggregate_dn, "CN=Aggregate")) {
+ ldb_oom(module->ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ module->private_data = data;
+
+ if (dsdb_get_schema(module->ldb)) {
+ return ldb_next_init(module);
+ }
+
mem_ctx = talloc_new(module);
if (!mem_ctx) {
ldb_oom(module->ldb);
@@ -208,9 +258,155 @@ static int schema_fsmo_extended(struct ldb_module *module, struct ldb_request *r
return LDB_SUCCESS;
}
+static int generate_objectClasses(struct ldb_context *ldb, struct ldb_message *msg,
+ const struct dsdb_schema *schema)
+{
+ const struct dsdb_class *class;
+ int ret;
+
+ for (class = schema->classes; class; class = class->next) {
+ ret = ldb_msg_add_string(msg, "objectClasses", schema_class_to_description(msg, class));
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+ return LDB_SUCCESS;
+}
+static int generate_attributeTypes(struct ldb_context *ldb, struct ldb_message *msg,
+ const struct dsdb_schema *schema)
+{
+ const struct dsdb_attribute *attribute;
+ int ret;
+
+ for (attribute = schema->attributes; attribute; attribute = attribute->next) {
+ ret = ldb_msg_add_string(msg, "attributeTypes", schema_attribute_to_description(msg, attribute));
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+ return LDB_SUCCESS;
+}
+
+static int generate_dITContentRules(struct ldb_context *ldb, struct ldb_message *msg,
+ const struct dsdb_schema *schema)
+{
+ const struct dsdb_class *class;
+ int ret;
+
+ for (class = schema->classes; class; class = class->next) {
+ if (class->auxiliaryClass || class->systemAuxiliaryClass) {
+ char *ditcontentrule = schema_class_to_dITContentRule(msg, class, schema);
+ if (!ditcontentrule) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ret = ldb_msg_add_steal_string(msg, "dITContentRules", ditcontentrule);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+ }
+ return 0;
+}
+
+
+
+/* Add objectClasses, attributeTypes and dITContentRules from the
+ schema object (they are not stored in the database)
+ */
+static int schema_fsmo_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares)
+{
+ const struct dsdb_schema *schema = dsdb_get_schema(ldb);
+ struct schema_fsmo_search_data *search_data = talloc_get_type(context, struct schema_fsmo_search_data);
+ struct ldb_request *orig_req = search_data->orig_req;
+ TALLOC_CTX *mem_ctx;
+ int i, ret;
+
+ /* Only entries are interesting, and we handle the case of the parent seperatly */
+ if (ares->type != LDB_REPLY_ENTRY) {
+ return orig_req->callback(ldb, orig_req->context, ares);
+ }
+
+ if (ldb_dn_compare(ares->message->dn, search_data->module_context->aggregate_dn) != 0) {
+ talloc_free(mem_ctx);
+ return orig_req->callback(ldb, orig_req->context, ares);
+ }
+
+ mem_ctx = talloc_new(ares);
+ if (!mem_ctx) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ for (i=0; i < ARRAY_SIZE(generated_attrs); i++) {
+ if (ldb_attr_in_list(orig_req->op.search.attrs, generated_attrs[i].attr)) {
+ ret = generated_attrs[i].fn(ldb, ares->message, schema);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+ }
+ }
+
+ talloc_free(mem_ctx);
+ return orig_req->callback(ldb, orig_req->context, ares);
+}
+
+/* search */
+static int schema_fsmo_search(struct ldb_module *module, struct ldb_request *req)
+{
+ int i, ret;
+ struct schema_fsmo_search_data *search_context;
+ struct ldb_request *down_req;
+ struct dsdb_schema *schema = dsdb_get_schema(module->ldb);
+
+ if (!schema || !module->private_data) {
+ /* If there is no schema, there is little we can do */
+ return ldb_next_request(module, req);
+ }
+ for (i=0; i < ARRAY_SIZE(generated_attrs); i++) {
+ if (ldb_attr_in_list(req->op.search.attrs, generated_attrs[i].attr)) {
+ break;
+ }
+ }
+ if (i == ARRAY_SIZE(generated_attrs)) {
+ /* No request for a generated attr found, nothing to
+ * see here, move along... */
+ return ldb_next_request(module, req);
+ }
+
+ search_context = talloc(req, struct schema_fsmo_search_data);
+ if (!search_context) {
+ ldb_oom(module->ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ down_req = talloc(req, struct ldb_request);
+ if (!down_req) {
+ ldb_oom(module->ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ *down_req = *req;
+ search_context->orig_req = req;
+ search_context->module_context = talloc_get_type(module->private_data, struct schema_fsmo_private_data);
+ down_req->context = search_context;
+
+ down_req->callback = schema_fsmo_search_callback;
+
+ ret = ldb_next_request(module, down_req);
+
+ /* do not free down_req as the call results may be linked to it,
+ * it will be freed when the upper level request get freed */
+ if (ret == LDB_SUCCESS) {
+ req->handle = down_req->handle;
+ }
+ return ret;
+}
+
+
_PUBLIC_ const struct ldb_module_ops ldb_schema_fsmo_module_ops = {
.name = "schema_fsmo",
.init_context = schema_fsmo_init,
.add = schema_fsmo_add,
- .extended = schema_fsmo_extended
+ .extended = schema_fsmo_extended,
+ .search = schema_fsmo_search
};
diff --git a/source/dsdb/schema/schema.h b/source/dsdb/schema/schema.h
index a4e455a..cd714e9 100644
--- a/source/dsdb/schema/schema.h
+++ b/source/dsdb/schema/schema.h
@@ -168,6 +168,20 @@ enum dsdb_attr_list_query {
DSDB_SCHEMA_ALL
};
+enum dsdb_schema_convert_target {
+ TARGET_OPENLDAP,
+ TARGET_FEDORA_DS,
+ TARGET_AD_SCHEMA_SUBENTRY
+};
+
+struct dsdb_syntax_map {
+ const char *Standard_OID;
+ const char *AD_OID;
+ const char *equality;
+ const char *substring;
+ const char *comment;
+};
+
#include "dsdb/schema/proto.h"
#endif /* _DSDB_SCHEMA_H */
diff --git a/source/dsdb/schema/schema_constructed.c b/source/dsdb/schema/schema_constructed.c
deleted file mode 100644
index 5134381..0000000
--- a/source/dsdb/schema/schema_constructed.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- Unix SMB/CIFS mplementation.
- DSDB schema constructed attributes
- attributeTypes, objectClasses, dITContentRules...
-
- Copyright (C) Stefan Metzmacher 2006
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
-#include "includes.h"
-#include "dsdb/samdb/samdb.h"
-#include "librpc/gen_ndr/ndr_drsuapi.h"
-#include "lib/ldb/include/ldb.h"
-#include "system/time.h"
-#include "lib/charset/charset.h"
-#include "librpc/ndr/libndr.h"
-
-static char *dsdb_subSchema_list_append(char *v, const char *list_name)
-{
- bool first = true;
- uint32_t i;
- const char *attrs[] = {
- "attr1",
- "attr2",
- "attr3",
- NULL
- };
-
- v = talloc_asprintf_append(v, "%s ( ", list_name);
- if (!v) return NULL;
-
- for (i=0; attrs[i]; i++) {
- v = talloc_asprintf_append(v, "%s%s ",
- (!first ? "$ " : ""),
- attrs[i]);
- if (!v) return NULL;
- first = false;
- }
-
- v = talloc_asprintf_append(v, ") ");
- if (!v) return NULL;
-
- return v;
-}
-
-WERROR dsdb_subSchema_attributeTypes(const struct dsdb_schema *schema,
- TALLOC_CTX *mem_ctx)
-{
- struct ldb_message_element *e;
- struct dsdb_attribute *a;
-
- e = talloc_zero(mem_ctx, struct ldb_message_element);
- W_ERROR_HAVE_NO_MEMORY(e);
-
- for (a = schema->attributes; a; a = a->next) {
- char *v;
-
- v = talloc_asprintf(e, "( %s NAME '%s' SYNTAX '%s' ",
- a->attributeID_oid, a->lDAPDisplayName,
- a->syntax->ldap_oid);
- W_ERROR_HAVE_NO_MEMORY(v);
-
- if (a->isSingleValued) {
- v = talloc_asprintf_append(v, "SINGLE-VALUE ");
- W_ERROR_HAVE_NO_MEMORY(v);
- }
-
- if (a->systemOnly) {
- v = talloc_asprintf_append(v, "NO-USER-MODIFICATION ");
- W_ERROR_HAVE_NO_MEMORY(v);
- }
-
- v = talloc_asprintf_append(v, ")");
- W_ERROR_HAVE_NO_MEMORY(v);
-
- DEBUG(0,("%s\n", v));
- }
-
- return WERR_FOOBAR;
-}
-
-WERROR dsdb_subSchema_objectClasses(const struct dsdb_schema *schema,
- TALLOC_CTX *mem_ctx)
-{
- struct ldb_message_element *e;
- struct dsdb_class *c;
-
- e = talloc_zero(mem_ctx, struct ldb_message_element);
- W_ERROR_HAVE_NO_MEMORY(e);
-
- for (c = schema->classes; c; c = c->next) {
- const char *class_type;
- char *v;
-
- switch (c->objectClassCategory) {
- case 0:
- /*
- * NOTE: this is an type 88 class
- * e.g. 2.5.6.6 NAME 'person'
- * but w2k3 gives STRUCTURAL here!
- */
- class_type = "STRUCTURAL";
- break;
- case 1:
- class_type = "STRUCTURAL";
- break;
- case 2:
- class_type = "ABSTRACT";
- break;
- case 3:
- class_type = "AUXILIARY";
- break;
- default:
- class_type = "UNKNOWN";
- break;
- }
-
- v = talloc_asprintf(e, "( %s NAME '%s' SUB %s %s ",
- c->governsID_oid, c->lDAPDisplayName,
- c->subClassOf, class_type);
- W_ERROR_HAVE_NO_MEMORY(v);
-
- v = dsdb_subSchema_list_append(v, "MUST");
- W_ERROR_HAVE_NO_MEMORY(v);
-
- v = dsdb_subSchema_list_append(v, "MAY");
- W_ERROR_HAVE_NO_MEMORY(v);
-
- v = talloc_asprintf_append(v, ")");
- W_ERROR_HAVE_NO_MEMORY(v);
-
- DEBUG(0,("%s\n", v));
- }
-
- return WERR_FOOBAR;
-}
-
-WERROR dsdb_subSchema_dITContentRules(const struct dsdb_schema *schema,
- TALLOC_CTX *mem_ctx)
-{
- struct ldb_message_element *e;
- struct dsdb_class *c;
-
- e = talloc_zero(mem_ctx, struct ldb_message_element);
- W_ERROR_HAVE_NO_MEMORY(e);
-
- for (c = schema->classes; c; c = c->next) {
- char *v;
-
- /*
- * TODO: filter out classes without auxiliary classes
- */
-
- v = talloc_asprintf(e, "( %s NAME '%s' ",
- c->governsID_oid, c->lDAPDisplayName);
- W_ERROR_HAVE_NO_MEMORY(v);
-
- v = dsdb_subSchema_list_append(v, "AUX");
- W_ERROR_HAVE_NO_MEMORY(v);
-
- v = dsdb_subSchema_list_append(v, "MUST");
- W_ERROR_HAVE_NO_MEMORY(v);
-
- v = dsdb_subSchema_list_append(v, "MAY");
- W_ERROR_HAVE_NO_MEMORY(v);
-
- v = talloc_asprintf_append(v, ")");
- W_ERROR_HAVE_NO_MEMORY(v);
-
- DEBUG(0,("%s\n", v));
- }
-
- return WERR_FOOBAR;
-}
diff --git a/source/dsdb/schema/schema_convert.c b/source/dsdb/schema/schema_convert.c
new file mode 100644
index 0000000..673e7a3
--- /dev/null
+++ b/source/dsdb/schema/schema_convert.c
@@ -0,0 +1,160 @@
+/*
+ ldb database library
+
+ Copyright (C) Simo Sorce 2005
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "dsdb/samdb/samdb.h"
+
+/* Shared map for converting syntax between formats */
--
Samba Shared Repository
More information about the samba-cvs
mailing list