[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Mon Nov 23 06:16:40 MST 2009


The branch, master has been updated
       via  401ba9c... s4:dsdb Move module configuration from each ldb into samba_dsdb.c
       via  e297af0... s4:provision Simplify the module list
       via  83b41aa... s4/schema(tort): Refactor DSDB-SYNTAX test for better performance
       via  cf2bb28... s4/schema: Handle Object(OR-Name) syntax in extended_dn_out module
       via  1bf31f3... s4/schema: Object(OR-Name) syntax handling for DRS calls
       via  bef4e25... s4/schema(tort): Inject authOrig attribute into schema loaded for tests
       via  d03d15d... s4/schema(tort): Add test for Object(OR-Name) syntax
       via  aa238ff... s4/schema(tort): Test LDB_SYNTAX_DN with extended_dn in [GUID;SID;DN] form
       via  65e95b8... s4/drs(tort): DSSYNC test to print what is different in drs_msg also
      from  0608d6b... s4-smbtorture: fix spoolss_EnumPrinterKey client in RPC-SPOOLSS-WIN.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 401ba9c9cf357d6b420a7401fc1a915871d96f8d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Nov 23 20:30:35 2009 +1100

    s4:dsdb Move module configuration from each ldb into samba_dsdb.c
    
    This makes getting the module order correct, the obligation of Samba4
    developers, and not system administrators.  In particular, once an ldb
    is updated to use only the 'samba_dsdb' module, no further changes to the
    ldb should be required when upgrading to later Samba4 versions.
    
    (thanks to metze for the suggestion of samba_dsdb as a long-term
    stable name for the module)
    
    Andrew Bartlett

commit e297af00fad2032e79f1889fd6d2713932249bb0
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Nov 20 12:16:33 2009 +1100

    s4:provision Simplify the module list
    
    This makes the member server much more like the DC, the objectGUID
    module replaces the repl_meta_data module.
    
    We also generally rework the construction of the list, building a full
    list in python, and then transforming it into a string, rather than
    playing string concatonation games
    
    Andrew Bartlett

commit 83b41aa959d1c71b26f7e9c327b5956ddfe0a267
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date:   Sun Nov 22 22:21:12 2009 +0200

    s4/schema(tort): Refactor DSDB-SYNTAX test for better performance
    
    Test was implemented as a test fixture so that setup/teardown
    occurs only once.
    This should impact test performace as long as provision_get_schema()
    is a slow function (especially when debugging)

commit cf2bb28014b2687bc5d971bf47f57aeb75b600c0
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date:   Sun Nov 22 17:48:32 2009 +0200

    s4/schema: Handle Object(OR-Name) syntax in extended_dn_out module
    
    Windows displays attribute values with Object(OR-Name) syntax
    in plain DN format when queried through LDAP.
    Hence, we need to post-process such values specially
    in extended_dn_out.c module so they are always shown as plain DN,
    no matter what controls are passed for search request.

commit 1bf31f343c1e01b970a9f887bf7a8bac6334e54a
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date:   Sun Nov 22 14:41:25 2009 +0200

    s4/schema: Object(OR-Name) syntax handling for DRS calls
    
    OR-Name syntax through DRS calls looks like DN-Binary syntax

commit bef4e25b1f1c82b49029e7d0d46b386395a4c10e
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date:   Fri Nov 20 03:07:41 2009 +0200

    s4/schema(tort): Inject authOrig attribute into schema loaded for tests

commit d03d15d0cb9003fa92be5d6d8dfb5fb652a354ae
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date:   Sun Nov 22 14:46:09 2009 +0200

    s4/schema(tort): Add test for Object(OR-Name) syntax

commit aa238ff6ea64b50027542563418d27fab2c3556c
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date:   Fri Nov 20 03:15:38 2009 +0200

    s4/schema(tort): Test LDB_SYNTAX_DN with extended_dn in [GUID;SID;DN] form

commit 65e95b8aa91cdd4de99bb3b698687e425026021f
Author: Kamen Mazdrashki <kamen.mazdrashki at postpath.com>
Date:   Mon Nov 16 23:49:51 2009 +0200

    s4/drs(tort): DSSYNC test to print what is different in drs_msg also

-----------------------------------------------------------------------

Summary of changes:
 source4/dsdb/common/dsdb_dn.c                    |    2 +
 source4/dsdb/common/dsdb_dn.h                    |    5 +-
 source4/dsdb/samdb/ldb_modules/config.mk         |   11 +
 source4/dsdb/samdb/ldb_modules/extended_dn_out.c |   16 +-
 source4/dsdb/samdb/ldb_modules/partition.h       |    2 +
 source4/dsdb/samdb/ldb_modules/partition_init.c  |   27 ++-
 source4/dsdb/samdb/ldb_modules/samba_dsdb.c      |  360 ++++++++++++++++++++++
 source4/dsdb/samdb/samdb.h                       |    2 +
 source4/dsdb/schema/schema_syntax.c              |   10 +-
 source4/dsdb/schema/tests/schema_syntax.c        |  168 +++++++++--
 source4/scripting/python/samba/provision.py      |   73 +----
 source4/setup/provision_init.ldif                |    7 +
 source4/setup/provision_partitions.ldif          |    6 -
 source4/torture/rpc/dssync.c                     |    8 +-
 14 files changed, 577 insertions(+), 120 deletions(-)
 create mode 100644 source4/dsdb/samdb/ldb_modules/samba_dsdb.c


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/common/dsdb_dn.c b/source4/dsdb/common/dsdb_dn.c
index dbc63a9..660eaf7 100644
--- a/source4/dsdb/common/dsdb_dn.c
+++ b/source4/dsdb/common/dsdb_dn.c
@@ -31,6 +31,8 @@ enum dsdb_dn_format dsdb_dn_oid_to_format(const char *oid)
 		return DSDB_BINARY_DN;
 	} else if (strcmp(oid, DSDB_SYNTAX_STRING_DN) == 0) {
 		return DSDB_STRING_DN;
+	} else if (strcmp(oid, DSDB_SYNTAX_OR_NAME) == 0) {
+		return DSDB_NORMAL_DN;
 	} else {
 		return DSDB_INVALID_DN;
 	}
diff --git a/source4/dsdb/common/dsdb_dn.h b/source4/dsdb/common/dsdb_dn.h
index 55b5c0b..53e1053 100644
--- a/source4/dsdb/common/dsdb_dn.h
+++ b/source4/dsdb/common/dsdb_dn.h
@@ -12,5 +12,6 @@ struct dsdb_dn {
 	const char *oid;
 };
 
-#define DSDB_SYNTAX_BINARY_DN "1.2.840.113556.1.4.903"
-#define DSDB_SYNTAX_STRING_DN  "1.2.840.113556.1.4.904"
+#define DSDB_SYNTAX_BINARY_DN	"1.2.840.113556.1.4.903"
+#define DSDB_SYNTAX_STRING_DN	"1.2.840.113556.1.4.904"
+#define DSDB_SYNTAX_OR_NAME	"1.2.840.113556.1.4.1221"
diff --git a/source4/dsdb/samdb/ldb_modules/config.mk b/source4/dsdb/samdb/ldb_modules/config.mk
index 93c248b..1849c69 100644
--- a/source4/dsdb/samdb/ldb_modules/config.mk
+++ b/source4/dsdb/samdb/ldb_modules/config.mk
@@ -9,6 +9,17 @@ $(eval $(call proto_header_template,$(dsdbsrcdir)/samdb/ldb_modules/util_proto.h
 
 
 ################################################
+# Start MODULE ldb_samba_dsdb
+[MODULE::ldb_samba_dsdb]
+SUBSYSTEM = LIBLDB
+PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBEVENTS LIBNDR
+INIT_FUNCTION = LDB_MODULE(samba_dsdb)
+# End MODULE ldb_samba_dsdb
+################################################
+
+ldb_samba_dsdb_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/samba_dsdb.o
+
+################################################
 # Start MODULE ldb_objectguid
 [MODULE::ldb_objectguid]
 SUBSYSTEM = LIBLDB
diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c
index 1249a9c..c52953c 100644
--- a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c
+++ b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c
@@ -398,6 +398,7 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares,
 
 	/* Walk the retruned elements (but only if we have a schema to interpret the list with) */
 	for (i = 0; ac->schema && i < msg->num_elements; i++) {
+		bool make_extended_dn;
 		const struct dsdb_attribute *attribute;
 		attribute = dsdb_attribute_by_lDAPDisplayName(ac->schema, msg->elements[i].name);
 		if (!attribute) {
@@ -425,6 +426,13 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares,
 			continue;
 		}
 
+		make_extended_dn = ac->inject;
+
+		/* Always show plain DN in case of Object(OR-Name) syntax */
+		if (make_extended_dn) {
+			make_extended_dn = (strcmp(attribute->syntax->ldap_oid, DSDB_SYNTAX_OR_NAME) != 0);
+		}
+
 		for (j = 0; j < msg->elements[i].num_values; j++) {
 			const char *dn_str;
 			struct ldb_dn *dn;
@@ -470,12 +478,12 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares,
 				}
 			}
 			
-			if (!ac->inject) {
+			if (make_extended_dn) {
+				dn_str = dsdb_dn_get_extended_linearized(msg->elements[i].values,
+									 dsdb_dn, ac->extended_type);
+			} else {
 				dn_str = dsdb_dn_get_linearized(msg->elements[i].values, 
 								dsdb_dn);
-			} else {
-				dn_str = dsdb_dn_get_extended_linearized(msg->elements[i].values, 
-									 dsdb_dn, ac->extended_type);
 			}
 			
 			if (!dn_str) {
diff --git a/source4/dsdb/samdb/ldb_modules/partition.h b/source4/dsdb/samdb/ldb_modules/partition.h
index 241501d..1d4e8e4 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.h
+++ b/source4/dsdb/samdb/ldb_modules/partition.h
@@ -47,6 +47,8 @@ struct partition_private_data {
 
 	uint64_t metadata_seq;
 	uint32_t in_transaction;
+
+	struct ldb_message *forced_module_msg;
 };
 
 #include "dsdb/samdb/ldb_modules/partition_proto.h"
diff --git a/source4/dsdb/samdb/ldb_modules/partition_init.c b/source4/dsdb/samdb/ldb_modules/partition_init.c
index 416648c..c791c6f 100644
--- a/source4/dsdb/samdb/ldb_modules/partition_init.c
+++ b/source4/dsdb/samdb/ldb_modules/partition_init.c
@@ -129,7 +129,7 @@ static int partition_load_modules(struct ldb_context *ldb,
 static int partition_reload_metadata(struct ldb_module *module, struct partition_private_data *data, TALLOC_CTX *mem_ctx, struct ldb_message **_msg) 
 {
 	int ret;
-	struct ldb_message *msg;
+	struct ldb_message *msg, *module_msg;
 	struct ldb_result *res;
 	struct ldb_context *ldb = ldb_module_get_ctx(module);
 	const char *attrs[] = { "partition", "replicateEntries", "modules", "ldapBackend", NULL };
@@ -148,7 +148,16 @@ static int partition_reload_metadata(struct ldb_module *module, struct partition
 		return ret;
 	}
 
-	ret = partition_load_modules(ldb, data, msg);			
+	/* When used from Samba4, this message is set by the samba4
+	 * module, as a fixed value not read from the DB.  This avoids
+	 * listing modules in the DB */
+	if (data->forced_module_msg) {
+		module_msg = data->forced_module_msg;
+	} else {
+		module_msg = msg;
+	}
+
+	ret = partition_load_modules(ldb, data, module_msg);
 	if (ret != LDB_SUCCESS) {
 		return ret;
 	}
@@ -790,7 +799,7 @@ int partition_init(struct ldb_module *module)
 {
 	int ret;
 	TALLOC_CTX *mem_ctx = talloc_new(module);
-
+	struct ldb_context *ldb = ldb_module_get_ctx(module);
 	struct partition_private_data *data;
 
 	if (!mem_ctx) {
@@ -802,6 +811,14 @@ int partition_init(struct ldb_module *module)
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
+	/* When used from Samba4, this message is set by the samba4
+	 * module, as a fixed value not read from the DB.  This avoids
+	 * listing modules in the DB */
+	data->forced_module_msg = talloc_get_type(
+		ldb_get_opaque(ldb,
+			       DSDB_OPAQUE_PARTITION_MODULE_MSG_OPAQUE_NAME),
+		struct ldb_message);
+
 	/* This loads the partitions */
 	ret = partition_reload_if_required(module, data);
 	if (ret != LDB_SUCCESS) {
@@ -813,14 +830,14 @@ int partition_init(struct ldb_module *module)
 
 	ret = ldb_mod_register_control(module, LDB_CONTROL_DOMAIN_SCOPE_OID);
 	if (ret != LDB_SUCCESS) {
-		ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_ERROR,
+		ldb_debug(ldb, LDB_DEBUG_ERROR,
 			"partition: Unable to register control with rootdse!\n");
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
 	ret = ldb_mod_register_control(module, LDB_CONTROL_SEARCH_OPTIONS_OID);
 	if (ret != LDB_SUCCESS) {
-		ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_ERROR,
+		ldb_debug(ldb, LDB_DEBUG_ERROR,
 			"partition: Unable to register control with rootdse!\n");
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
diff --git a/source4/dsdb/samdb/ldb_modules/samba_dsdb.c b/source4/dsdb/samdb/ldb_modules/samba_dsdb.c
new file mode 100644
index 0000000..bb3f8af
--- /dev/null
+++ b/source4/dsdb/samdb/ldb_modules/samba_dsdb.c
@@ -0,0 +1,360 @@
+/*
+   Samba4 module loading module
+
+   Copyright (C) Andrew Bartlett <abartlet at samba.org> 2009
+
+   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/>.
+*/
+
+/*
+ *  Name: ldb
+ *
+ *  Component: Samba4 module loading module
+ *
+ *  Description: Implement a single 'module' in the ldb database,
+ *  which loads the remaining modules based on 'choice of configuration' attributes
+ *
+ *  This is to avoid forcing a reprovision of the ldb databases when we change the internal structure of the code
+ *
+ *  Author: Andrew Bartlett
+ */
+
+#include "includes.h"
+#include "lib/ldb/include/ldb.h"
+#include "lib/ldb/include/ldb_errors.h"
+#include "lib/ldb/include/ldb_module.h"
+#include "lib/ldb/include/ldb_private.h"
+
+#include "dsdb/samdb/ldb_modules/util.h"
+#include "dsdb/samdb/samdb.h"
+
+static int read_at_rootdse_record(struct ldb_context *ldb, struct ldb_module *module, TALLOC_CTX *mem_ctx,
+				  struct ldb_message **msg)
+{
+	int ret;
+	static const char *rootdse_attrs[] = { "defaultNamingContext", "configurationNamingContext", "schemaNamingContext", NULL };
+	struct ldb_result *rootdse_res;
+	struct ldb_dn *rootdse_dn;
+	TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+	if (!tmp_ctx) {
+		ldb_oom(ldb);
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
+	rootdse_dn = ldb_dn_new(tmp_ctx, ldb, "@ROOTDSE");
+	if (!rootdse_dn) {
+		talloc_free(tmp_ctx);
+		ldb_oom(ldb);
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
+	ret = dsdb_module_search_dn(module, tmp_ctx, &rootdse_res, rootdse_dn, rootdse_attrs, 0);
+	if (ret != LDB_SUCCESS) {
+		talloc_free(tmp_ctx);
+		return ret;
+	}
+
+	talloc_steal(mem_ctx, rootdse_res->msgs);
+	*msg = rootdse_res->msgs[0];
+
+	talloc_free(tmp_ctx);
+
+	return ret;
+}
+
+static int prepare_modules_line(struct ldb_context *ldb,
+				TALLOC_CTX *mem_ctx,
+				const struct ldb_message *rootdse_msg,
+				struct ldb_message *msg, const char *backend_attr,
+				const char *backend_mod, const char **backend_mod_list)
+{
+	int ret;
+	const char **backend_full_list;
+	const char *backend_dn;
+	char *mod_list_string;
+	char *full_string;
+	TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+	if (!tmp_ctx) {
+		ldb_oom(ldb);
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
+	if (backend_attr) {
+		backend_dn = ldb_msg_find_attr_as_string(rootdse_msg, backend_attr, NULL);
+		if (!backend_dn) {
+			ldb_asprintf_errstring(ldb,
+					       "samba_dsdb_init: "
+					       "unable to read %s from %s:%s",
+					       backend_attr, ldb_dn_get_linearized(rootdse_msg->dn),
+					       ldb_errstring(ldb));
+			return LDB_ERR_CONSTRAINT_VIOLATION;
+		}
+	} else {
+		backend_dn = "*";
+	}
+
+	if (backend_mod) {
+		backend_full_list = (const char **)str_list_make_single(tmp_ctx, backend_mod);
+	} else {
+		backend_full_list = (const char **)str_list_make_empty(tmp_ctx);
+	}
+	if (!backend_full_list) {
+		talloc_free(tmp_ctx);
+		ldb_oom(ldb);
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
+	backend_full_list = str_list_append_const(backend_full_list, backend_mod_list);
+	if (!backend_full_list) {
+		talloc_free(tmp_ctx);
+		ldb_oom(ldb);
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
+	mod_list_string = str_list_join(tmp_ctx, backend_full_list, ',');
+	if (!mod_list_string) {
+		talloc_free(tmp_ctx);
+		ldb_oom(ldb);
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
+	full_string = talloc_asprintf(tmp_ctx, "%s:%s", backend_dn, mod_list_string);
+	ret = ldb_msg_add_steal_string(msg, "modules", full_string);
+	talloc_free(tmp_ctx);
+	return ret;
+}
+
+static int samba_dsdb_init(struct ldb_module *module)
+{
+	struct ldb_context *ldb = ldb_module_get_ctx(module);
+	int ret, len, i;
+	TALLOC_CTX *tmp_ctx = talloc_new(module);
+	struct ldb_result *res;
+	struct ldb_message *rootdse_msg, *partition_msg;
+	struct ldb_dn *samba_dsdb_dn;
+	struct ldb_module *backend_module, *module_chain;
+	const char **final_module_list, **reverse_module_list;
+	/*
+	  Add modules to the list to activate them by default
+	  beware often order is important
+
+	  Some Known ordering constraints:
+	  - rootdse must be first, as it makes redirects from "" -> cn=rootdse
+	  - extended_dn_in must be before objectclass.c, as it resolves the DN
+	  - objectclass must be before password_hash, because password_hash checks
+	    that the objectclass is of type person (filled in by objectclass
+	    module when expanding the objectclass list)
+	  - partition must be last
+	  - each partition has its own module list then
+
+	  The list is presented here as a set of declarations to show the
+	  stack visually - the code below then handles the creation of the list
+	  based on the parameters loaded from the database.
+	*/
+	static const char *modules_list[] = {"resolve_oids",
+					     "rootdse",
+					     "lazy_commit",
+					     "paged_results",
+					     "ranged_results",
+					     "anr",
+					     "server_sort",
+					     "asq",
+					     "extended_dn_store",
+					     "extended_dn_in",
+					     "rdn_name",
+					     "objectclass",
+					     "descriptor",
+					     "acl",
+					     "samldb",
+					     "password_hash",
+					     "operational",
+					     "kludge_acl",
+					     "schema_load",
+					     "instancetype",
+					     NULL };
+
+	const char *objectguid_module;
+	/* if serverrole == "domain controller": */
+	const char *repl_meta_data = "repl_meta_data";
+	/*    else: */
+        const char *objectguid = "objectguid";
+
+	const char **link_modules;
+	static const char *tdb_modules_list[] = {
+		"subtree_rename",
+		"subtree_delete",
+		"linked_attributes",
+		NULL};
+
+	const char *extended_dn_module;
+	const char *extended_dn_module_ldb = "extended_dn_out_ldb";
+	const char *extended_dn_module_fds = "extended_dn_out_ldb";
+	const char *extended_dn_module_openldap = "extended_dn_out_ldb";
+
+	static const char *modules_list2[] = {"show_deleted",
+					      "new_partition",
+					      "partition",
+					      NULL };
+
+	const char **backend_modules;
+	static const char *fedora_ds_backend_modules[] = {
+		"nsuniqueid", "paged_searches", NULL };
+	static const char *openldap_backend_modules[] = {
+		"nsuniqueid", "paged_searches", NULL };
+
+	static const char *samba_dsdb_attrs[] = { "backendType", "serverRole", NULL };
+	const char *backendType, *serverRole;
+
+	if (!tmp_ctx) {
+		ldb_oom(ldb);
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
+	samba_dsdb_dn = ldb_dn_new(tmp_ctx, ldb, "@SAMBA_DSDB");
+	if (!samba_dsdb_dn) {
+		talloc_free(tmp_ctx);
+		ldb_oom(ldb);
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
+#define CHECK_LDB_RET(check_ret)				\
+	do {							\
+		if (check_ret != LDB_SUCCESS) {			\
+			talloc_free(tmp_ctx);			\
+			return check_ret;			\
+		}						\
+	} while (0)
+
+	ret = dsdb_module_search_dn(module, tmp_ctx, &res, samba_dsdb_dn, samba_dsdb_attrs, 0);
+	if (ret != LDB_SUCCESS) {
+		talloc_free(tmp_ctx);
+		return ret;
+	}
+
+	backendType = ldb_msg_find_attr_as_string(res->msgs[0], "backendType", "ldb");
+	serverRole = ldb_msg_find_attr_as_string(res->msgs[0], "serverRole", NULL);
+
+	backend_modules = NULL;
+	if (strcasecmp(backendType, "ldb") == 0) {
+		if (strcasecmp(serverRole, "dc") == 0 || strcasecmp(serverRole, "domain controller") == 0) {
+			objectguid_module = repl_meta_data;
+		} else {
+			objectguid_module = objectguid;
+		}
+		extended_dn_module = extended_dn_module_ldb;
+		link_modules = tdb_modules_list;
+	} else {
+		objectguid_module = NULL;
+		link_modules = NULL;
+		if (strcasecmp(backendType, "fedora-ds")) {
+			backend_modules = fedora_ds_backend_modules;
+			extended_dn_module = extended_dn_module_fds;
+		} else if (strcasecmp(backendType, "openldap")) {
+			backend_modules = openldap_backend_modules;
+			extended_dn_module = extended_dn_module_openldap;
+		}
+	}
+
+#define CHECK_MODULE_LIST \
+	do {							\
+		if (!final_module_list) {			\
+			talloc_free(tmp_ctx);			\
+			ldb_oom(ldb);				\
+			return LDB_ERR_OPERATIONS_ERROR;	\
+		}						\
+	} while (0)
+
+	final_module_list = str_list_copy_const(tmp_ctx, modules_list);
+	CHECK_MODULE_LIST;
+
+	final_module_list = str_list_add_const(final_module_list, objectguid_module);
+	CHECK_MODULE_LIST;
+
+	final_module_list = str_list_append_const(final_module_list, link_modules);
+	CHECK_MODULE_LIST;
+
+	final_module_list = str_list_add_const(final_module_list, extended_dn_module);
+	CHECK_MODULE_LIST;
+
+	final_module_list = str_list_append_const(final_module_list, modules_list2);
+	CHECK_MODULE_LIST;
+
+
+	ret = read_at_rootdse_record(ldb, module, tmp_ctx, &rootdse_msg);
+	CHECK_LDB_RET(ret);
+
+	partition_msg = ldb_msg_new(tmp_ctx);
+	partition_msg->dn = ldb_dn_new(partition_msg, ldb, "@" DSDB_OPAQUE_PARTITION_MODULE_MSG_OPAQUE_NAME);
+
+	ret = prepare_modules_line(ldb, tmp_ctx,
+				   rootdse_msg,
+				   partition_msg, "defaultNamingContext",
+				   "pdc_fsmo", backend_modules);
+	CHECK_LDB_RET(ret);
+
+	ret = prepare_modules_line(ldb, tmp_ctx,
+				   rootdse_msg,
+				   partition_msg, "configurationNamingContext",
+				   "naming_fsmo", backend_modules);
+	CHECK_LDB_RET(ret);
+
+	ret = prepare_modules_line(ldb, tmp_ctx,
+				   rootdse_msg,
+				   partition_msg, "schemaNamingContext",
+				   "schema_data", backend_modules);
+	CHECK_LDB_RET(ret);
+
+	ret = prepare_modules_line(ldb, tmp_ctx,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list