This passes down a struct loadparm_context to allow these
parameters to be checked. This may be s3 or s4 context, allowing the
#if _SAMBA_BUILD_ macro to go away safely.
Andrew Bartlett
15 files changed:
#include "includes.h"
#include "lib/util/dlinklist.h"
#include "lib/util/tdb_wrap.h"
#include "includes.h"
#include "lib/util/dlinklist.h"
#include "lib/util/tdb_wrap.h"
+#include "lib/param/param.h"
/* FIXME: TDB2 does this internally, so no need to wrap multiple opens! */
#if BUILD_TDB2
/* FIXME: TDB2 does this internally, so no need to wrap multiple opens! */
#if BUILD_TDB2
int hash_size,
int tdb_flags,
int open_flags,
int hash_size,
int tdb_flags,
int open_flags,
+ mode_t mode,
+ struct loadparm_context *lp_ctx)
{
struct tdb_wrap_private *result;
{
struct tdb_wrap_private *result;
-#if _SAMBA_BUILD_ == 3
- /* This #if _SAMBA_BUILD == 3 is very unfortunate, as it means
- * that in the top level build, these options are not
- * available for these databases. However, having two
- * different tdb_wrap lists is a worse fate, so this will do
- * for now */
-
- if (!lp_use_mmap()) {
+ if (!lpcfg_use_mmap(lp_ctx)) {
tdb_flags |= TDB_NOMMAP;
}
tdb_flags |= TDB_NOMMAP;
}
- hash_size = lp_parm_int(-1, "tdb_hashsize", base, 0);
+ hash_size = lpcfg_parm_int(lp_ctx, NULL, "tdb_hashsize", base, 0);
result->tdb = tdb_open_compat(name, hash_size, tdb_flags,
open_flags, mode, tdb_wrap_log, NULL);
result->tdb = tdb_open_compat(name, hash_size, tdb_flags,
open_flags, mode, tdb_wrap_log, NULL);
*/
struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
const char *name, int hash_size, int tdb_flags,
*/
struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
const char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode)
+ int open_flags, mode_t mode,
+ struct loadparm_context *lp_ctx)
{
struct tdb_wrap *result;
struct tdb_wrap_private *w;
{
struct tdb_wrap *result;
struct tdb_wrap_private *w;
if (w == NULL) {
w = tdb_wrap_private_open(result, name, hash_size, tdb_flags,
if (w == NULL) {
w = tdb_wrap_private_open(result, name, hash_size, tdb_flags,
+ open_flags, mode, lp_ctx);
} else {
/*
* Correctly use talloc_reference: The tdb will be
} else {
/*
* Correctly use talloc_reference: The tdb will be
struct tdb_context *tdb;
};
struct tdb_context *tdb;
};
+struct loadparm_context;
+
struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
const char *name, int hash_size, int tdb_flags,
struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx,
const char *name, int hash_size, int tdb_flags,
- int open_flags, mode_t mode);
+ int open_flags, mode_t mode,
+ struct loadparm_context *lp_ctx);
#endif /* _TDB_WRAP_H_ */
#endif /* _TDB_WRAP_H_ */
bld.SAMBA_LIBRARY('tdb-wrap',
source='tdb_wrap.c',
bld.SAMBA_LIBRARY('tdb-wrap',
source='tdb_wrap.c',
- deps='tdb_compat talloc samba-util',
+ deps='tdb_compat talloc samba-util samba-hostconfig',
private_library=True,
local_include=False
)
private_library=True,
local_include=False
)
- tdb_sc = tdb_wrap_open(mem_ctx, fname, 0, TDB_CLEAR_IF_FIRST|TDB_NOSYNC, O_RDWR|O_CREAT, 0600);
+ tdb_sc = tdb_wrap_open(mem_ctx, fname, 0, TDB_CLEAR_IF_FIRST|TDB_NOSYNC, O_RDWR|O_CREAT, 0600, lp_ctx);
if (!tdb_sc) {
DEBUG(0,("open_schannel_session_store: Failed to open %s - %s\n",
if (!tdb_sc) {
DEBUG(0,("open_schannel_session_store: Failed to open %s - %s\n",
#include "dbwrap/dbwrap_private.h"
#include "dbwrap/dbwrap_tdb.h"
#include "lib/util/tdb_wrap.h"
#include "dbwrap/dbwrap_private.h"
#include "dbwrap/dbwrap_tdb.h"
#include "lib/util/tdb_wrap.h"
+#include "lib/param/param.h"
struct db_tdb_ctx {
struct tdb_wrap *wtdb;
struct db_tdb_ctx {
struct tdb_wrap *wtdb;
{
struct db_context *result = NULL;
struct db_tdb_ctx *db_tdb;
{
struct db_context *result = NULL;
struct db_tdb_ctx *db_tdb;
+ struct loadparm_context *lp_ctx;
+
result = talloc_zero(mem_ctx, struct db_context);
if (result == NULL) {
DEBUG(0, ("talloc failed\n"));
goto fail;
}
result = talloc_zero(mem_ctx, struct db_context);
if (result == NULL) {
DEBUG(0, ("talloc failed\n"));
goto fail;
}
+ lp_ctx = loadparm_init_s3(result, loadparm_s3_context());
result->private_data = db_tdb = talloc(result, struct db_tdb_ctx);
if (db_tdb == NULL) {
result->private_data = db_tdb = talloc(result, struct db_tdb_ctx);
if (db_tdb == NULL) {
}
db_tdb->wtdb = tdb_wrap_open(db_tdb, name, hash_size, tdb_flags,
}
db_tdb->wtdb = tdb_wrap_open(db_tdb, name, hash_size, tdb_flags,
+ open_flags, mode, lp_ctx);
+ talloc_unlink(result, lp_ctx);
if (db_tdb->wtdb == NULL) {
DEBUG(3, ("Could not open tdb: %s\n", strerror(errno)));
goto fail;
if (db_tdb->wtdb == NULL) {
DEBUG(3, ("Could not open tdb: %s\n", strerror(errno)));
goto fail;
#include "system/filesys.h"
#include "messages.h"
#include "lib/util/tdb_wrap.h"
#include "system/filesys.h"
#include "messages.h"
#include "lib/util/tdb_wrap.h"
+#include "lib/param/param.h"
struct messaging_tdb_context {
struct messaging_context *msg_ctx;
struct messaging_tdb_context {
struct messaging_context *msg_ctx;
{
struct messaging_backend *result;
struct messaging_tdb_context *ctx;
{
struct messaging_backend *result;
struct messaging_tdb_context *ctx;
+ struct loadparm_context *lp_ctx;
if (!(result = talloc(mem_ctx, struct messaging_backend))) {
DEBUG(0, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
if (!(result = talloc(mem_ctx, struct messaging_backend))) {
DEBUG(0, ("talloc failed\n"));
return NT_STATUS_NO_MEMORY;
}
+ lp_ctx = loadparm_init_s3(result, loadparm_s3_context());
+ if (lp_ctx == NULL) {
+ DEBUG(0, ("loadparm_init_s3 failed\n"));
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
ctx = talloc_zero(result, struct messaging_tdb_context);
if (!ctx) {
DEBUG(0, ("talloc failed\n"));
ctx = talloc_zero(result, struct messaging_tdb_context);
if (!ctx) {
DEBUG(0, ("talloc failed\n"));
ctx->tdb = tdb_wrap_open(ctx, lock_path("messages.tdb"), 0,
TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE|TDB_INCOMPATIBLE_HASH,
ctx->tdb = tdb_wrap_open(ctx, lock_path("messages.tdb"), 0,
TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE|TDB_INCOMPATIBLE_HASH,
+ O_RDWR|O_CREAT,0600, lp_ctx);
+ talloc_unlink(result, lp_ctx);
if (!ctx->tdb) {
NTSTATUS status = map_nt_error_from_unix(errno);
if (!ctx->tdb) {
NTSTATUS status = map_nt_error_from_unix(errno);
bool messaging_tdb_parent_init(TALLOC_CTX *mem_ctx)
{
struct tdb_wrap *db;
bool messaging_tdb_parent_init(TALLOC_CTX *mem_ctx)
{
struct tdb_wrap *db;
+ struct loadparm_context *lp_ctx;
+
+ lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_context());
+ if (lp_ctx == NULL) {
+ DEBUG(0, ("loadparm_init_s3 failed\n"));
+ return false;
+ }
/*
* Open the tdb in the parent process (smbd) so that our
/*
* Open the tdb in the parent process (smbd) so that our
db = tdb_wrap_open(mem_ctx, lock_path("messages.tdb"), 0,
TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE|TDB_INCOMPATIBLE_HASH,
db = tdb_wrap_open(mem_ctx, lock_path("messages.tdb"), 0,
TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE|TDB_INCOMPATIBLE_HASH,
+ O_RDWR|O_CREAT,0600, lp_ctx);
+ talloc_unlink(mem_ctx, lp_ctx);
if (db == NULL) {
DEBUG(1, ("could not open messaging.tdb: %s\n",
strerror(errno)));
if (db == NULL) {
DEBUG(1, ("could not open messaging.tdb: %s\n",
strerror(errno)));
#include "system/filesys.h"
#include "lib/util/tdb_wrap.h"
#include "util_tdb.h"
#include "system/filesys.h"
#include "lib/util/tdb_wrap.h"
#include "util_tdb.h"
+#include "lib/param/param.h"
/* For reasons known only to MS, many of their NT/Win2k versions
need serialised access only. Two connections at the same time
/* For reasons known only to MS, many of their NT/Win2k versions
need serialised access only. Two connections at the same time
int timeout)
{
struct named_mutex *result;
int timeout)
{
struct named_mutex *result;
+ struct loadparm_context *lp_ctx;
result = talloc(mem_ctx, struct named_mutex);
if (result == NULL) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
result = talloc(mem_ctx, struct named_mutex);
if (result == NULL) {
DEBUG(0, ("talloc failed\n"));
return NULL;
}
+ lp_ctx = loadparm_init_s3(result, loadparm_s3_context());
+ if (lp_ctx == NULL) {
+ DEBUG(0, ("loadparm_init_s3 failed\n"));
+ talloc_free(result);
+ return NULL;
+ }
+
result->name = talloc_strdup(result, name);
if (result->name == NULL) {
DEBUG(0, ("talloc failed\n"));
result->name = talloc_strdup(result, name);
if (result->name == NULL) {
DEBUG(0, ("talloc failed\n"));
}
result->tdb = tdb_wrap_open(result, lock_path("mutex.tdb"), 0,
}
result->tdb = tdb_wrap_open(result, lock_path("mutex.tdb"), 0,
- TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+ TDB_DEFAULT, O_RDWR|O_CREAT, 0600, lp_ctx);
+ talloc_unlink(result, lp_ctx);
if (result->tdb == NULL) {
DEBUG(1, ("Could not open mutex.tdb: %s\n",
strerror(errno)));
if (result->tdb == NULL) {
DEBUG(1, ("Could not open mutex.tdb: %s\n",
strerror(errno)));
#include "dbwrap/dbwrap.h"
#include "dbwrap/dbwrap_open.h"
#include "lib/util/tdb_wrap.h"
#include "dbwrap/dbwrap.h"
#include "dbwrap/dbwrap_open.h"
#include "lib/util/tdb_wrap.h"
+#include "lib/param/param.h"
struct serverid_key {
pid_t pid;
struct serverid_key {
pid_t pid;
bool serverid_parent_init(TALLOC_CTX *mem_ctx)
{
struct tdb_wrap *db;
bool serverid_parent_init(TALLOC_CTX *mem_ctx)
{
struct tdb_wrap *db;
+ struct loadparm_context *lp_ctx;
+
+ lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_context());
+ if (lp_ctx == NULL) {
+ DEBUG(0, ("loadparm_init_s3 failed\n"));
+ return false;
+ }
/*
* Open the tdb in the parent process (smbd) so that our
/*
* Open the tdb in the parent process (smbd) so that our
db = tdb_wrap_open(mem_ctx, lock_path("serverid.tdb"),
0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT,
db = tdb_wrap_open(mem_ctx, lock_path("serverid.tdb"),
0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT,
+ 0644, lp_ctx);
+ talloc_unlink(mem_ctx, lp_ctx);
if (db == NULL) {
DEBUG(1, ("could not open serverid.tdb: %s\n",
strerror(errno)));
if (db == NULL) {
DEBUG(1, ("could not open serverid.tdb: %s\n",
strerror(errno)));
#include "messages.h"
#include "lib/util/tdb_wrap.h"
#include "util_tdb.h"
#include "messages.h"
#include "lib/util/tdb_wrap.h"
#include "util_tdb.h"
+#include "lib/param/param.h"
struct notify_context {
struct db_context *db_recursive;
struct notify_context {
struct db_context *db_recursive;
bool notify_internal_parent_init(TALLOC_CTX *mem_ctx)
{
struct tdb_wrap *db1, *db2;
bool notify_internal_parent_init(TALLOC_CTX *mem_ctx)
{
struct tdb_wrap *db1, *db2;
+ struct loadparm_context *lp_ctx;
if (lp_clustering()) {
return true;
}
if (lp_clustering()) {
return true;
}
+ lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_context());
+ if (lp_ctx == NULL) {
+ DEBUG(0, ("loadparm_init_s3 failed\n"));
+ return false;
+ }
/*
* Open the tdbs in the parent process (smbd) so that our
* CLEAR_IF_FIRST optimization in tdb_reopen_all can properly
/*
* Open the tdbs in the parent process (smbd) so that our
* CLEAR_IF_FIRST optimization in tdb_reopen_all can properly
db1 = tdb_wrap_open(mem_ctx, lock_path("notify.tdb"),
0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
db1 = tdb_wrap_open(mem_ctx, lock_path("notify.tdb"),
0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
+ O_RDWR|O_CREAT, 0644, lp_ctx);
+ talloc_unlink(mem_ctx, lp_ctx);
DEBUG(1, ("could not open notify.tdb: %s\n", strerror(errno)));
return false;
}
db2 = tdb_wrap_open(mem_ctx, lock_path("notify_onelevel.tdb"),
DEBUG(1, ("could not open notify.tdb: %s\n", strerror(errno)));
return false;
}
db2 = tdb_wrap_open(mem_ctx, lock_path("notify_onelevel.tdb"),
- 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0644);
+ 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0644, lp_ctx);
+ talloc_unlink(mem_ctx, lp_ctx);
if (db2 == NULL) {
DEBUG(1, ("could not open notify_onelevel.tdb: %s\n",
strerror(errno)));
if (db2 == NULL) {
DEBUG(1, ("could not open notify_onelevel.tdb: %s\n",
strerror(errno)));
char *path = smbd_tmp_path(mem_ctx, lp_ctx, dbname);
struct tdb_wrap *w;
w = tdb_wrap_open(mem_ctx, path, 0, 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_free(path);
return w;
}
struct socket_context *sock;
const char *base_path;
const char *path;
struct socket_context *sock;
const char *base_path;
const char *path;
+ struct loadparm_context *lp_ctx;
struct dispatch_fn **dispatch;
uint32_t num_types;
struct idr_context *dispatch_tree;
struct dispatch_fn **dispatch;
uint32_t num_types;
struct idr_context *dispatch_tree;
/* create the messaging directory if needed */
/* create the messaging directory if needed */
+ msg->lp_ctx = talloc_reference(msg, lp_ctx);
+ if (!msg->lp_ctx) {
+ talloc_free(msg);
+ return NULL;
+ }
+
msg->base_path = lpcfg_imessaging_path(msg, lp_ctx);
mkdir(msg->base_path, 0700);
msg->base_path = lpcfg_imessaging_path(msg, lp_ctx);
mkdir(msg->base_path, 0700);
if (path == NULL) {
return NULL;
}
if (path == NULL) {
return NULL;
}
- t = tdb_wrap_open(msg_ctx, path, 0, 0, O_RDWR|O_CREAT, 0660);
+ t = tdb_wrap_open(msg_ctx, path, 0, 0, O_RDWR|O_CREAT, 0660, msg_ctx->lp_ctx);
talloc_free(path);
return t;
}
talloc_free(path);
return t;
}
#include "lib/util/wrap_xattr.h"
#include "ntvfs/posix/vfs_posix.h"
#include "libcli/util/pyerrors.h"
#include "lib/util/wrap_xattr.h"
#include "ntvfs/posix/vfs_posix.h"
#include "libcli/util/pyerrors.h"
+#include "param/pyparam.h"
void initxattr_tdb(void);
void initxattr_tdb(void);
blob.length = blobsize;
mem_ctx = talloc_new(NULL);
eadb = tdb_wrap_open(mem_ctx, tdbname, 50000,
blob.length = blobsize;
mem_ctx = talloc_new(NULL);
eadb = tdb_wrap_open(mem_ctx, tdbname, 50000,
- TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+ TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
+ py_default_loadparm_context(mem_ctx));
if (eadb == NULL) {
PyErr_SetFromErrno(PyExc_IOError);
if (eadb == NULL) {
PyErr_SetFromErrno(PyExc_IOError);
mem_ctx = talloc_new(NULL);
eadb = tdb_wrap_open(mem_ctx, tdbname, 50000,
mem_ctx = talloc_new(NULL);
eadb = tdb_wrap_open(mem_ctx, tdbname, 50000,
- TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+ TDB_DEFAULT, O_RDWR|O_CREAT, 0600, py_default_loadparm_context(mem_ctx));
if (eadb == NULL) {
PyErr_SetFromErrno(PyExc_IOError);
talloc_free(mem_ctx);
if (eadb == NULL) {
PyErr_SetFromErrno(PyExc_IOError);
talloc_free(mem_ctx);
eadb = share_string_option(scfg, PVFS_EADB, NULL);
if (eadb != NULL) {
pvfs->ea_db = tdb_wrap_open(pvfs, eadb, 50000,
eadb = share_string_option(scfg, PVFS_EADB, NULL);
if (eadb != NULL) {
pvfs->ea_db = tdb_wrap_open(pvfs, eadb, 50000,
- TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+ TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
+ pvfs->ntvfs->ctx->lp_ctx);
if (pvfs->ea_db != NULL) {
pvfs->flags |= PVFS_FLAG_XATTR_ENABLE;
} else {
if (pvfs->ea_db != NULL) {
pvfs->flags |= PVFS_FLAG_XATTR_ENABLE;
} else {
fname = lpcfg_private_path(mem_ctx, lp_ctx, "randseed.tdb");
fname = lpcfg_private_path(mem_ctx, lp_ctx, "randseed.tdb");
- tdb = tdb_wrap_open(mem_ctx, fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+ tdb = tdb_wrap_open(mem_ctx, fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600, lp_ctx);
if (!tdb) {
DEBUG(0,("Failed to open %s\n", fname));
if (!tdb) {
DEBUG(0,("Failed to open %s\n", fname));
torture_comment(torture, "Testing tdb speed for sidmap\n");
tdbw = tdb_wrap_open(tmp_ctx, "test.tdb",
torture_comment(torture, "Testing tdb speed for sidmap\n");
tdbw = tdb_wrap_open(tmp_ctx, "test.tdb",
- 10000, 0, O_RDWR|O_CREAT|O_TRUNC, 0600);
+ 10000, 0, O_RDWR|O_CREAT|O_TRUNC, 0600, torture->lp_ctx);
if (!tdbw) {
torture_result(torture, TORTURE_FAIL, "Failed to open test.tdb");
goto failed;
if (!tdbw) {
torture_result(torture, TORTURE_FAIL, "Failed to open test.tdb");
goto failed;