summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-11-24 10:36:28 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-11-24 10:41:45 +1100
commit625856f2cf784f5ba39929567796d3225e1c6c3f (patch)
treed60a42ee825777b318c8bb26e2da185b5c677699 /source4/dsdb
parent9aeaf31cfe338b0e7f5b7fe243190f38ce09d9ac (diff)
downloadsamba-625856f2cf784f5ba39929567796d3225e1c6c3f.tar.gz
samba-625856f2cf784f5ba39929567796d3225e1c6c3f.tar.bz2
samba-625856f2cf784f5ba39929567796d3225e1c6c3f.zip
s4:provision Move secrets.ldb over to .c file module lists, like sam.ldb
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/config.mk11
-rw-r--r--source4/dsdb/samdb/ldb_modules/samba_secrets.c100
2 files changed, 111 insertions, 0 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/config.mk b/source4/dsdb/samdb/ldb_modules/config.mk
index 1849c69813..3bd38606ea 100644
--- a/source4/dsdb/samdb/ldb_modules/config.mk
+++ b/source4/dsdb/samdb/ldb_modules/config.mk
@@ -20,6 +20,17 @@ INIT_FUNCTION = LDB_MODULE(samba_dsdb)
ldb_samba_dsdb_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/samba_dsdb.o
################################################
+# Start MODULE ldb_samba_secrets
+[MODULE::ldb_samba_secrets]
+SUBSYSTEM = LIBLDB
+PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBEVENTS LIBNDR
+INIT_FUNCTION = LDB_MODULE(samba_secrets)
+# End MODULE ldb_samba_secrets
+################################################
+
+ldb_samba_secrets_OBJ_FILES = $(dsdbsrcdir)/samdb/ldb_modules/samba_secrets.o
+
+################################################
# Start MODULE ldb_objectguid
[MODULE::ldb_objectguid]
SUBSYSTEM = LIBLDB
diff --git a/source4/dsdb/samdb/ldb_modules/samba_secrets.c b/source4/dsdb/samdb/ldb_modules/samba_secrets.c
new file mode 100644
index 0000000000..1045bb9102
--- /dev/null
+++ b/source4/dsdb/samdb/ldb_modules/samba_secrets.c
@@ -0,0 +1,100 @@
+/*
+ Samba4 module loading module (for secrets)
+
+ Copyright (C) Andrew Bartlett <abartlet@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 (for secrets.ldb)
+ *
+ * Description: Implement a single 'module' in the secrets.ldb database
+ *
+ * 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 samba_secrets_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_module *backend_module, *module_chain;
+ const char **reverse_module_list;
+ /*
+ Add modules to the list to activate them by default
+ beware often order is important
+
+ The list is presented here as a set of declarations to show the
+ stack visually
+ */
+ static const char *modules_list[] = {"update_keytab",
+ "objectguid",
+ "rdn_name",
+ NULL };
+
+ if (!tmp_ctx) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ /* Now prepare the module chain. Oddly, we must give it to ldb_load_modules_list in REVERSE */
+ for (len = 0; modules_list[len]; len++) { /* noop */};
+
+ reverse_module_list = talloc_array(tmp_ctx, const char *, len+1);
+ if (!reverse_module_list) {
+ talloc_free(tmp_ctx);
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ for (i=0; i < len; i++) {
+ reverse_module_list[i] = modules_list[(len - 1) - i];
+ }
+ reverse_module_list[i] = NULL;
+
+ /* The backend (at least until the partitions module
+ * reconfigures things) is the next module in the currently
+ * loaded chain */
+ backend_module = module->next;
+ ret = ldb_load_modules_list(ldb, reverse_module_list, backend_module, &module_chain);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
+ return ret;
+ }
+
+ talloc_free(tmp_ctx);
+ /* Set this as the 'next' module, so that we effectivly append it to module chain */
+ module->next = module_chain;
+
+ return ldb_next_init(module);
+}
+
+const struct ldb_module_ops ldb_samba_secrets_module_ops = {
+ .name = "samba_secrets",
+ .init_context = samba_secrets_init,
+};