summaryrefslogtreecommitdiff
path: root/source4/cluster
diff options
context:
space:
mode:
Diffstat (limited to 'source4/cluster')
-rw-r--r--source4/cluster/cluster.c4
-rw-r--r--source4/cluster/cluster.h2
-rw-r--r--source4/cluster/cluster_private.h4
-rw-r--r--source4/cluster/local.c32
-rw-r--r--source4/cluster/wscript_build2
5 files changed, 26 insertions, 18 deletions
diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c
index 757489ebce..11c4194d9a 100644
--- a/source4/cluster/cluster.c
+++ b/source4/cluster/cluster.c
@@ -59,10 +59,10 @@ struct server_id cluster_id(uint64_t pid, uint32_t task_id)
/*
open a temporary tdb in a cluster friendly manner
*/
-struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbname, int flags)
+struct db_context *cluster_db_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbbase, int flags)
{
cluster_init();
- return ops->cluster_tdb_tmp_open(ops, mem_ctx, lp_ctx, dbname, flags);
+ return ops->cluster_db_tmp_open(ops, mem_ctx, lp_ctx, dbbase, flags);
}
diff --git a/source4/cluster/cluster.h b/source4/cluster/cluster.h
index 3dd9f4ce7c..2bbbea2660 100644
--- a/source4/cluster/cluster.h
+++ b/source4/cluster/cluster.h
@@ -41,7 +41,7 @@ typedef void (*cluster_message_fn_t)(struct imessaging_context *, DATA_BLOB);
/* prototypes */
struct server_id cluster_id(uint64_t id, uint32_t task_id);
-struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbname, int flags);
+struct db_context *cluster_db_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbbase, int flags);
void *cluster_backend_handle(void);
NTSTATUS cluster_message_init(struct imessaging_context *msg, struct server_id server,
diff --git a/source4/cluster/cluster_private.h b/source4/cluster/cluster_private.h
index 6f68ad62bd..2b799228fb 100644
--- a/source4/cluster/cluster_private.h
+++ b/source4/cluster/cluster_private.h
@@ -24,8 +24,8 @@
struct cluster_ops {
struct server_id (*cluster_id)(struct cluster_ops *ops, uint64_t id, uint32_t id2);
- struct tdb_wrap *(*cluster_tdb_tmp_open)(struct cluster_ops *,
- TALLOC_CTX *,
+ struct db_context *(*cluster_db_tmp_open)(struct cluster_ops *,
+ TALLOC_CTX *,
struct loadparm_context *,
const char *, int);
void *(*backend_handle)(struct cluster_ops *);
diff --git a/source4/cluster/local.c b/source4/cluster/local.c
index 0e59321f64..aa0fd7def4 100644
--- a/source4/cluster/local.c
+++ b/source4/cluster/local.c
@@ -22,7 +22,7 @@
#include "includes.h"
#include "cluster/cluster.h"
#include "cluster/cluster_private.h"
-#include "lib/tdb_wrap/tdb_wrap.h"
+#include "dbwrap/dbwrap.h"
#include "system/filesys.h"
#include "param/param.h"
#include "librpc/gen_ndr/server_id.h"
@@ -47,17 +47,25 @@ static struct server_id local_id(struct cluster_ops *ops, uint64_t pid, uint32_t
open a tmp tdb for the local node. By using smbd_tmp_path() we don't need
TDB_CLEAR_IF_FIRST as the tmp path is wiped at startup
*/
-static struct tdb_wrap *local_tdb_tmp_open(struct cluster_ops *ops,
- TALLOC_CTX *mem_ctx,
- struct loadparm_context *lp_ctx,
- const char *dbname, int flags)
+static struct db_context *local_db_tmp_open(struct cluster_ops *ops,
+ TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ const char *dbbase, int flags)
{
- char *path = smbd_tmp_path(mem_ctx, lp_ctx, dbname);
- struct tdb_wrap *w;
- w = tdb_wrap_open(mem_ctx, path, 0, flags,
- O_RDWR|O_CREAT, 0600, lp_ctx);
- talloc_free(path);
- return w;
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ char *path, *dbname;
+ struct db_context *db;
+
+ if (lpcfg_use_ntdb(lp_ctx))
+ dbname = talloc_asprintf(mem_ctx, "%s.ntdb", dbbase);
+ else
+ dbname = talloc_asprintf(mem_ctx, "%s.tdb", dbbase);
+
+ path = smbd_tmp_path(tmp_ctx, lp_ctx, dbname);
+ db = dbwrap_local_open(mem_ctx, lp_ctx, path, 0, flags, O_RDWR|O_CREAT,
+ 0600, 0);
+ talloc_free(tmp_ctx);
+ return db;
}
/*
@@ -90,7 +98,7 @@ static NTSTATUS local_message_send(struct cluster_ops *ops,
static struct cluster_ops cluster_local_ops = {
.cluster_id = local_id,
- .cluster_tdb_tmp_open = local_tdb_tmp_open,
+ .cluster_db_tmp_open = local_db_tmp_open,
.backend_handle = local_backend_handle,
.message_init = local_message_init,
.message_send = local_message_send,
diff --git a/source4/cluster/wscript_build b/source4/cluster/wscript_build
index 995e166eca..b8a91ccad7 100644
--- a/source4/cluster/wscript_build
+++ b/source4/cluster/wscript_build
@@ -2,7 +2,7 @@
bld.SAMBA_LIBRARY('cluster',
source='cluster.c local.c',
- deps='tdb-wrap samba-hostconfig talloc',
+ deps='dbwrap samba-hostconfig talloc',
private_library=True
)