mirror of
https://github.com/samba-team/samba.git
synced 2025-02-23 09:57:40 +03:00
TDB2: make SAMBA use tdb1 again for the moment.
Otherwise the following surgery will break the SAMBA build and testsuite. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
5bad913938
commit
6244f668a3
@ -61,18 +61,11 @@ def s3_fix_kwargs(bld, kwargs):
|
||||
'../source4/heimdal_build',
|
||||
'../bin/default/source4/heimdal/lib/asn1' ]
|
||||
|
||||
if bld.CONFIG_SET('BUILD_TDB2'):
|
||||
if bld.CONFIG_SET('USING_SYSTEM_TDB2'):
|
||||
(tdb2_includes, tdb2_ldflags, tdb2_cpppath) = library_flags(bld, 'tdb')
|
||||
extra_includes += tdb2_cpppath
|
||||
else:
|
||||
extra_includes += [ '../lib/tdb2' ]
|
||||
if bld.CONFIG_SET('USING_SYSTEM_TDB'):
|
||||
(tdb_includes, tdb_ldflags, tdb_cpppath) = library_flags(bld, 'tdb')
|
||||
extra_includes += tdb_cpppath
|
||||
else:
|
||||
if bld.CONFIG_SET('USING_SYSTEM_TDB'):
|
||||
(tdb_includes, tdb_ldflags, tdb_cpppath) = library_flags(bld, 'tdb')
|
||||
extra_includes += tdb_cpppath
|
||||
else:
|
||||
extra_includes += [ '../lib/tdb/include' ]
|
||||
extra_includes += [ '../lib/tdb/include' ]
|
||||
|
||||
if bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
|
||||
(tevent_includes, tevent_ldflags, tevent_cpppath) = library_flags(bld, 'tevent')
|
||||
|
@ -74,13 +74,9 @@ int ltdb_err_map(enum TDB_ERROR tdb_code)
|
||||
case TDB_ERR_IO:
|
||||
return LDB_ERR_PROTOCOL_ERROR;
|
||||
case TDB_ERR_LOCK:
|
||||
#ifndef BUILD_TDB2
|
||||
case TDB_ERR_NOLOCK:
|
||||
#endif
|
||||
return LDB_ERR_BUSY;
|
||||
#ifndef BUILD_TDB2
|
||||
case TDB_ERR_LOCK_TIMEOUT:
|
||||
#endif
|
||||
return LDB_ERR_TIME_LIMIT_EXCEEDED;
|
||||
case TDB_ERR_EXISTS:
|
||||
return LDB_ERR_ENTRY_ALREADY_EXISTS;
|
||||
|
@ -24,32 +24,6 @@
|
||||
#include "ldb_tdb.h"
|
||||
#include "dlinklist.h"
|
||||
|
||||
/* FIXME: TDB2 does this internally, so no need to wrap multiple opens! */
|
||||
#if BUILD_TDB2
|
||||
static void ltdb_log_fn(struct tdb_context *tdb,
|
||||
enum tdb_log_level level,
|
||||
enum TDB_ERROR ecode,
|
||||
const char *message,
|
||||
struct ldb_context *ldb)
|
||||
{
|
||||
enum ldb_debug_level ldb_level;
|
||||
const char *name = tdb_name(tdb);
|
||||
|
||||
switch (level) {
|
||||
case TDB_LOG_WARNING:
|
||||
ldb_level = LDB_DEBUG_WARNING;
|
||||
case TDB_LOG_USE_ERROR:
|
||||
case TDB_LOG_ERROR:
|
||||
ldb_level = LDB_DEBUG_FATAL;
|
||||
break;
|
||||
default:
|
||||
ldb_level = LDB_DEBUG_FATAL;
|
||||
}
|
||||
|
||||
ldb_debug(ldb, ldb_level, "ltdb: tdb(%s): %s: %s", name,
|
||||
tdb_errorstr(ecode), message);
|
||||
}
|
||||
#else /* !TDB2 */
|
||||
static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
|
||||
static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...)
|
||||
{
|
||||
@ -86,7 +60,6 @@ static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, con
|
||||
ldb_debug(ldb, ldb_level, "ltdb: tdb(%s): %s", name, message);
|
||||
talloc_free(message);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
the purpose of this code is to work around the braindead posix locking
|
||||
|
@ -1,224 +1,2 @@
|
||||
#include <tdb_compat.h>
|
||||
|
||||
/* Note: for the moment, we only need this file for TDB2, so we can
|
||||
* assume waf. */
|
||||
#if BUILD_TDB2
|
||||
TDB_DATA tdb_null = { NULL, 0 };
|
||||
|
||||
/* Proxy which sets waitflag to false so we never block. */
|
||||
static int lock_nonblock(int fd, int rw, off_t off, off_t len, bool waitflag,
|
||||
void *_orig)
|
||||
{
|
||||
struct tdb_attribute_flock *orig = _orig;
|
||||
|
||||
return orig->lock(fd, rw, off, len, false, orig->data);
|
||||
}
|
||||
|
||||
enum TDB_ERROR tdb_transaction_start_nonblock(struct tdb_context *tdb)
|
||||
{
|
||||
union tdb_attribute locking, orig;
|
||||
enum TDB_ERROR ecode;
|
||||
|
||||
orig.base.attr = TDB_ATTRIBUTE_FLOCK;
|
||||
ecode = tdb_get_attribute(tdb, &orig);
|
||||
if (ecode != TDB_SUCCESS)
|
||||
return ecode;
|
||||
|
||||
/* Replace locking function with our own. */
|
||||
locking = orig;
|
||||
locking.flock.data = &orig;
|
||||
locking.flock.lock = lock_nonblock;
|
||||
|
||||
ecode = tdb_set_attribute(tdb, &locking);
|
||||
if (ecode != TDB_SUCCESS)
|
||||
return ecode;
|
||||
|
||||
ecode = tdb_transaction_start(tdb);
|
||||
tdb_unset_attribute(tdb, TDB_ATTRIBUTE_FLOCK);
|
||||
return ecode;
|
||||
}
|
||||
|
||||
enum TDB_ERROR tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key)
|
||||
{
|
||||
union tdb_attribute locking, orig;
|
||||
enum TDB_ERROR ecode;
|
||||
|
||||
orig.base.attr = TDB_ATTRIBUTE_FLOCK;
|
||||
ecode = tdb_get_attribute(tdb, &orig);
|
||||
if (ecode != TDB_SUCCESS)
|
||||
return ecode;
|
||||
|
||||
/* Replace locking function with our own. */
|
||||
locking = orig;
|
||||
locking.flock.data = &orig;
|
||||
locking.flock.lock = lock_nonblock;
|
||||
|
||||
ecode = tdb_set_attribute(tdb, &locking);
|
||||
if (ecode != TDB_SUCCESS)
|
||||
return ecode;
|
||||
|
||||
ecode = tdb_chainlock(tdb, key);
|
||||
tdb_unset_attribute(tdb, TDB_ATTRIBUTE_FLOCK);
|
||||
return ecode;
|
||||
}
|
||||
|
||||
/* For TDB1 tdbs, read traverse vs normal matters: write traverse
|
||||
locks the entire thing! */
|
||||
int64_t tdb_traverse_read_(struct tdb_context *tdb,
|
||||
int (*fn)(struct tdb_context *,
|
||||
TDB_DATA, TDB_DATA,
|
||||
void *),
|
||||
void *p)
|
||||
{
|
||||
int64_t ret;
|
||||
|
||||
if (tdb_get_flags(tdb) & TDB_RDONLY) {
|
||||
return tdb_traverse(tdb, fn, p);
|
||||
}
|
||||
|
||||
tdb_add_flag(tdb, TDB_RDONLY);
|
||||
ret = tdb_traverse(tdb, fn, p);
|
||||
tdb_remove_flag(tdb, TDB_RDONLY);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* This handles TDB_CLEAR_IF_FIRST.
|
||||
*/
|
||||
static enum TDB_ERROR clear_if_first(int fd, void *unused)
|
||||
{
|
||||
/* We hold a lock offset 4 always, so we can tell if anyone else is. */
|
||||
struct flock fl;
|
||||
|
||||
fl.l_type = F_WRLCK;
|
||||
fl.l_whence = SEEK_SET;
|
||||
fl.l_start = 4; /* ACTIVE_LOCK */
|
||||
fl.l_len = 1;
|
||||
|
||||
if (fcntl(fd, F_SETLK, &fl) == 0) {
|
||||
/* We must be first ones to open it w/ TDB_CLEAR_IF_FIRST! */
|
||||
if (ftruncate(fd, 0) != 0) {
|
||||
return TDB_ERR_IO;
|
||||
}
|
||||
}
|
||||
fl.l_type = F_RDLCK;
|
||||
if (fcntl(fd, F_SETLKW, &fl) != 0) {
|
||||
return TDB_ERR_IO;
|
||||
}
|
||||
return TDB_SUCCESS;
|
||||
}
|
||||
|
||||
struct tdb_context *
|
||||
tdb_open_compat_(const char *name, int hash_size,
|
||||
int tdb_flags, int open_flags, mode_t mode,
|
||||
void (*log_fn)(struct tdb_context *,
|
||||
enum tdb_log_level,
|
||||
enum TDB_ERROR,
|
||||
const char *message,
|
||||
void *data),
|
||||
void *log_data)
|
||||
{
|
||||
union tdb_attribute cif, log, hash, max_dead, hsize, *attr = NULL;
|
||||
|
||||
if (!getenv("TDB_COMPAT_USE_TDB2")) {
|
||||
tdb_flags |= TDB_VERSION1;
|
||||
}
|
||||
|
||||
if (log_fn) {
|
||||
log.log.base.attr = TDB_ATTRIBUTE_LOG;
|
||||
log.log.base.next = NULL;
|
||||
log.log.fn = log_fn;
|
||||
log.log.data = log_data;
|
||||
attr = &log;
|
||||
}
|
||||
|
||||
if (tdb_flags & TDB_CLEAR_IF_FIRST) {
|
||||
cif.openhook.base.attr = TDB_ATTRIBUTE_OPENHOOK;
|
||||
cif.openhook.base.next = attr;
|
||||
cif.openhook.fn = clear_if_first;
|
||||
attr = &cif;
|
||||
tdb_flags &= ~TDB_CLEAR_IF_FIRST;
|
||||
}
|
||||
|
||||
if (tdb_flags & TDB_INCOMPATIBLE_HASH) {
|
||||
if (tdb_flags & TDB_VERSION1) {
|
||||
hash.hash.base.attr = TDB_ATTRIBUTE_HASH;
|
||||
hash.hash.base.next = attr;
|
||||
hash.hash.fn = tdb1_incompatible_hash;
|
||||
attr = &hash;
|
||||
}
|
||||
tdb_flags &= ~TDB_INCOMPATIBLE_HASH;
|
||||
}
|
||||
|
||||
if (tdb_flags & TDB_VOLATILE) {
|
||||
if (tdb_flags & TDB_VERSION1) {
|
||||
max_dead.base.attr = TDB_ATTRIBUTE_TDB1_MAX_DEAD;
|
||||
max_dead.base.next = attr;
|
||||
max_dead.tdb1_max_dead.max_dead = 5;
|
||||
attr = &max_dead;
|
||||
}
|
||||
tdb_flags &= ~TDB_VOLATILE;
|
||||
}
|
||||
|
||||
if (hash_size && (tdb_flags & TDB_VERSION1) && (open_flags & O_CREAT)) {
|
||||
hsize.base.attr = TDB_ATTRIBUTE_TDB1_HASHSIZE;
|
||||
hsize.base.next = attr;
|
||||
hsize.tdb1_hashsize.hsize = hash_size;
|
||||
attr = &hsize;
|
||||
}
|
||||
|
||||
/* Testsuite uses this to speed things up. */
|
||||
if (getenv("TDB_NO_FSYNC")) {
|
||||
tdb_flags |= TDB_NOSYNC;
|
||||
}
|
||||
|
||||
return tdb_open(name, tdb_flags|TDB_ALLOW_NESTING, open_flags, mode,
|
||||
attr);
|
||||
}
|
||||
|
||||
/* We only need these for the CLEAR_IF_FIRST lock. */
|
||||
static int reacquire_cif_lock(struct tdb_context *tdb, bool *fail)
|
||||
{
|
||||
struct flock fl;
|
||||
union tdb_attribute cif;
|
||||
|
||||
cif.openhook.base.attr = TDB_ATTRIBUTE_OPENHOOK;
|
||||
cif.openhook.base.next = NULL;
|
||||
|
||||
if (tdb_get_attribute(tdb, &cif) != TDB_SUCCESS
|
||||
|| cif.openhook.fn != clear_if_first) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We hold a lock offset 4 always, so we can tell if anyone else is. */
|
||||
fl.l_type = F_RDLCK;
|
||||
fl.l_whence = SEEK_SET;
|
||||
fl.l_start = 4; /* ACTIVE_LOCK */
|
||||
fl.l_len = 1;
|
||||
if (fcntl(tdb_fd(tdb), F_SETLKW, &fl) != 0) {
|
||||
*fail = true;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tdb_reopen(struct tdb_context *tdb)
|
||||
{
|
||||
bool unused;
|
||||
return reacquire_cif_lock(tdb, &unused);
|
||||
}
|
||||
|
||||
int tdb_reopen_all(int parent_longlived)
|
||||
{
|
||||
bool fail = false;
|
||||
|
||||
if (parent_longlived) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
tdb_foreach(reacquire_cif_lock, &fail);
|
||||
if (fail)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -27,90 +27,6 @@
|
||||
|
||||
#include "replace.h"
|
||||
#include <ccan/typesafe_cb/typesafe_cb.h>
|
||||
#if BUILD_TDB2
|
||||
#include <tdb2.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern TDB_DATA tdb_null;
|
||||
|
||||
/* Old-style tdb_fetch. */
|
||||
static inline TDB_DATA tdb_fetch_compat(struct tdb_context *tdb, TDB_DATA k)
|
||||
{
|
||||
TDB_DATA dbuf;
|
||||
if (tdb_fetch(tdb, k, &dbuf) != TDB_SUCCESS) {
|
||||
return tdb_null;
|
||||
}
|
||||
return dbuf;
|
||||
}
|
||||
|
||||
static inline TDB_DATA tdb_firstkey_compat(struct tdb_context *tdb)
|
||||
{
|
||||
TDB_DATA k;
|
||||
if (tdb_firstkey(tdb, &k) != TDB_SUCCESS) {
|
||||
return tdb_null;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
/* Note: this frees the old key.dptr. */
|
||||
static inline TDB_DATA tdb_nextkey_compat(struct tdb_context *tdb, TDB_DATA k)
|
||||
{
|
||||
if (tdb_nextkey(tdb, &k) != TDB_SUCCESS) {
|
||||
return tdb_null;
|
||||
}
|
||||
return k;
|
||||
}
|
||||
|
||||
#define tdb_traverse_read(tdb, fn, p) \
|
||||
tdb_traverse_read_(tdb, typesafe_cb_preargs(int, void *, (fn), (p), \
|
||||
struct tdb_context *, \
|
||||
TDB_DATA, TDB_DATA), (p))
|
||||
int64_t tdb_traverse_read_(struct tdb_context *tdb,
|
||||
int (*fn)(struct tdb_context *,
|
||||
TDB_DATA, TDB_DATA, void *), void *p);
|
||||
|
||||
/* Old-style tdb_errorstr */
|
||||
#define tdb_errorstr_compat(tdb) tdb_errorstr(tdb_error(tdb))
|
||||
|
||||
/* This typedef doesn't exist in TDB2. */
|
||||
typedef struct tdb_context TDB_CONTEXT;
|
||||
|
||||
/* We only need these for the CLEAR_IF_FIRST lock. */
|
||||
int tdb_reopen(struct tdb_context *tdb);
|
||||
int tdb_reopen_all(int parent_longlived);
|
||||
|
||||
/* These no longer exist in tdb2. */
|
||||
#define TDB_CLEAR_IF_FIRST 1048576
|
||||
#define TDB_INCOMPATIBLE_HASH 2097152
|
||||
#define TDB_VOLATILE 4194304
|
||||
|
||||
/* tdb2 does nonblocking functions via attibutes. */
|
||||
enum TDB_ERROR tdb_transaction_start_nonblock(struct tdb_context *tdb);
|
||||
enum TDB_ERROR tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key);
|
||||
|
||||
|
||||
/* Convenient (typesafe) wrapper for tdb open with logging */
|
||||
#define tdb_open_compat(name, hsize, tdb_fl, open_fl, mode, log_fn, log_data) \
|
||||
tdb_open_compat_((name), (hsize), (tdb_fl), (open_fl), (mode), \
|
||||
typesafe_cb_preargs(void, void *, \
|
||||
(log_fn), (log_data), \
|
||||
struct tdb_context *, \
|
||||
enum tdb_log_level, \
|
||||
enum TDB_ERROR, \
|
||||
const char *), \
|
||||
(log_data))
|
||||
|
||||
struct tdb_context *
|
||||
tdb_open_compat_(const char *name, int hash_size,
|
||||
int tdb_flags, int open_flags, mode_t mode,
|
||||
void (*log_fn)(struct tdb_context *,
|
||||
enum tdb_log_level,
|
||||
enum TDB_ERROR ecode,
|
||||
const char *message,
|
||||
void *data),
|
||||
void *log_data);
|
||||
#else
|
||||
#include <tdb.h>
|
||||
|
||||
/* FIXME: Inlining this is a bit lazy, but eases S3 build. */
|
||||
@ -140,6 +56,5 @@ static inline TDB_DATA tdb_nextkey_compat(struct tdb_context *tdb, TDB_DATA k)
|
||||
}
|
||||
#define tdb_errorstr_compat(tdb) tdb_errorstr(tdb)
|
||||
#define tdb_fetch_compat tdb_fetch
|
||||
#endif
|
||||
|
||||
#endif /* TDB_COMPAT_H */
|
||||
|
@ -3,22 +3,15 @@
|
||||
import Options
|
||||
|
||||
def set_options(opt):
|
||||
opt.RECURSE('lib/tdb2')
|
||||
opt.RECURSE('lib/tdb')
|
||||
|
||||
def configure(conf):
|
||||
if getattr(Options.options, 'BUILD_TDB2', False):
|
||||
conf.RECURSE('lib/tdb2')
|
||||
else:
|
||||
conf.RECURSE('lib/tdb')
|
||||
conf.RECURSE('lib/tdb')
|
||||
conf.RECURSE('lib/ccan')
|
||||
|
||||
def build(bld):
|
||||
bld.RECURSE('lib/ccan')
|
||||
if bld.env.BUILD_TDB2:
|
||||
bld.RECURSE('lib/tdb2')
|
||||
else:
|
||||
bld.RECURSE('lib/tdb')
|
||||
bld.RECURSE('lib/tdb')
|
||||
bld.SAMBA_LIBRARY('tdb_compat',
|
||||
source='tdb_compat.c',
|
||||
deps='replace tdb ccan',
|
||||
|
@ -24,33 +24,6 @@
|
||||
#include "lib/tdb_wrap/tdb_wrap.h"
|
||||
#include "lib/param/param.h"
|
||||
|
||||
/* FIXME: TDB2 does this internally, so no need to wrap multiple opens! */
|
||||
#if BUILD_TDB2
|
||||
static void tdb_wrap_log(struct tdb_context *tdb,
|
||||
enum tdb_log_level level,
|
||||
enum TDB_ERROR ecode,
|
||||
const char *message,
|
||||
void *unused)
|
||||
{
|
||||
int dl;
|
||||
const char *name = tdb_name(tdb);
|
||||
|
||||
switch (level) {
|
||||
case TDB_LOG_USE_ERROR:
|
||||
case TDB_LOG_ERROR:
|
||||
dl = 0;
|
||||
break;
|
||||
case TDB_LOG_WARNING:
|
||||
dl = 2;
|
||||
break;
|
||||
default:
|
||||
dl = 0;
|
||||
}
|
||||
|
||||
DEBUG(dl, ("tdb(%s):%s: %s", name ? name : "unnamed",
|
||||
tdb_errorstr(ecode), message));
|
||||
}
|
||||
#else
|
||||
/*
|
||||
Log tdb messages via DEBUG().
|
||||
*/
|
||||
@ -92,7 +65,6 @@ static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level,
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
struct tdb_wrap_private {
|
||||
struct tdb_context *tdb;
|
||||
|
@ -388,7 +388,6 @@ NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err)
|
||||
result = NT_STATUS_FILE_LOCK_CONFLICT;
|
||||
break;
|
||||
|
||||
#ifndef BUILD_TDB2
|
||||
case TDB_ERR_NOLOCK:
|
||||
case TDB_ERR_LOCK_TIMEOUT:
|
||||
/*
|
||||
@ -396,7 +395,6 @@ NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err)
|
||||
*/
|
||||
result = NT_STATUS_FILE_LOCK_CONFLICT;
|
||||
break;
|
||||
#endif
|
||||
case TDB_ERR_NOEXIST:
|
||||
result = NT_STATUS_NOT_FOUND;
|
||||
break;
|
||||
@ -406,11 +404,9 @@ NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err)
|
||||
case TDB_ERR_RDONLY:
|
||||
result = NT_STATUS_ACCESS_DENIED;
|
||||
break;
|
||||
#ifndef BUILD_TDB2
|
||||
case TDB_ERR_NESTING:
|
||||
result = NT_STATUS_INTERNAL_ERROR;
|
||||
break;
|
||||
#endif
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ builddirs = {
|
||||
"samba4-libs" : ".",
|
||||
"ldb" : "lib/ldb",
|
||||
"tdb" : "lib/tdb",
|
||||
"tdb2" : "lib/tdb2",
|
||||
"talloc" : "lib/talloc",
|
||||
"replace" : "lib/replace",
|
||||
"tevent" : "lib/tevent",
|
||||
@ -31,7 +30,7 @@ builddirs = {
|
||||
"retry" : "."
|
||||
}
|
||||
|
||||
defaulttasks = [ "samba3", "samba4", "samba4-libs", "ldb", "tdb", "tdb2", "talloc", "replace", "tevent", "pidl" ]
|
||||
defaulttasks = [ "samba3", "samba4", "samba4-libs", "ldb", "tdb", "talloc", "replace", "tevent", "pidl" ]
|
||||
|
||||
tasks = {
|
||||
"samba3" : [ ("autogen", "./autogen.sh", "text/plain"),
|
||||
@ -67,11 +66,11 @@ tasks = {
|
||||
("tevent-make", "cd lib/tevent && make -j", "text/plain"),
|
||||
("tevent-install", "cd lib/tevent && make install", "text/plain"),
|
||||
|
||||
("ldb-configure", "cd lib/ldb && PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=NONE --disable-tdb2 --abi-check --enable-debug -C ${PREFIX}", "text/plain"),
|
||||
("ldb-configure", "cd lib/ldb && PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=NONE --abi-check --enable-debug -C ${PREFIX}", "text/plain"),
|
||||
("ldb-make", "cd lib/ldb && make -j", "text/plain"),
|
||||
("ldb-install", "cd lib/ldb && make install", "text/plain"),
|
||||
|
||||
("configure", "PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=!talloc,!tdb,!pytdb,!ldb,!pyldb,!tevent,!pytevent --disable-tdb2 --abi-check --enable-debug -C ${PREFIX}", "text/plain"),
|
||||
("configure", "PYTHONPATH=${PYTHON_PREFIX}/site-packages:$PYTHONPATH PKG_CONFIG_PATH=$PKG_CONFIG_PATH:${PREFIX_DIR}/lib/pkgconfig ./configure --bundled-libraries=!talloc,!tdb,!pytdb,!ldb,!pyldb,!tevent,!pytevent --abi-check --enable-debug -C ${PREFIX}", "text/plain"),
|
||||
("make", "make -j", "text/plain"),
|
||||
("install", "make install", "text/plain")],
|
||||
|
||||
@ -92,14 +91,6 @@ tasks = {
|
||||
("distcheck", "make distcheck", "text/plain"),
|
||||
("clean", "make clean", "text/plain") ],
|
||||
|
||||
"tdb2" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
|
||||
("make", "make -j", "text/plain"),
|
||||
("install", "make install", "text/plain"),
|
||||
("test", "make test", "text/plain"),
|
||||
("check-clean-tree", "../../script/clean-source-tree.sh", "text/plain"),
|
||||
("distcheck", "make distcheck", "text/plain"),
|
||||
("clean", "make clean", "text/plain") ],
|
||||
|
||||
"talloc" : [ ("configure", "./configure --enable-developer -C ${PREFIX}", "text/plain"),
|
||||
("make", "make -j", "text/plain"),
|
||||
("install", "make install", "text/plain"),
|
||||
|
@ -165,9 +165,6 @@ def cmd_testonly(opt):
|
||||
if env.USING_SYSTEM_LDB:
|
||||
os.environ['LDB_MODULES_PATH'] = 'bin/modules/ldb'
|
||||
|
||||
if env.BUILD_TDB2:
|
||||
os.environ['BUILD_TDB2'] = '1'
|
||||
|
||||
# tell build system where to find config.h
|
||||
os.environ['VFSLIBDIR'] = os.path.abspath('bin/modules/vfs')
|
||||
os.environ['CONFIG_H'] = 'bin/default/include/config.h'
|
||||
|
@ -6,7 +6,7 @@ SAMBA4_BINARIES="smbtorture,ndrdump"
|
||||
samba4-configure:
|
||||
@(cd .. && \
|
||||
CFLAGS='' $(WAF) reconfigure || \
|
||||
CFLAGS='' $(WAF) configure --enable-socket-wrapper --enable-nss-wrapper --enable-uid-wrapper --nonshared-binary=$(SAMBA4_BINARIES) --enable-auto-reconfigure --enable-debug --disable-tdb2)
|
||||
CFLAGS='' $(WAF) configure --enable-socket-wrapper --enable-nss-wrapper --enable-uid-wrapper --nonshared-binary=$(SAMBA4_BINARIES) --enable-auto-reconfigure --enable-debug)
|
||||
|
||||
.PHONY: samba4-configure
|
||||
|
||||
|
@ -462,12 +462,7 @@ bool gencache_stabilize(void)
|
||||
|
||||
res = tdb_transaction_start_nonblock(cache);
|
||||
if (res != 0) {
|
||||
|
||||
#if BUILD_TDB2
|
||||
if (res == TDB_ERR_LOCK)
|
||||
#else
|
||||
if (tdb_error(cache) == TDB_ERR_NOLOCK)
|
||||
#endif
|
||||
{
|
||||
/*
|
||||
* Someone else already does the stabilize,
|
||||
|
@ -57,7 +57,6 @@ static int tdb_validate_child(struct tdb_context *tdb,
|
||||
goto out;
|
||||
}
|
||||
|
||||
#ifndef BUILD_TDB2
|
||||
/* Check if the tdb's freelist is good. */
|
||||
if (tdb_validate_freelist(tdb, &num_entries) == -1) {
|
||||
v_status.bad_freelist = True;
|
||||
@ -67,7 +66,6 @@ static int tdb_validate_child(struct tdb_context *tdb,
|
||||
|
||||
DEBUG(10,("tdb_validate_child: tdb %s freelist has %d entries\n",
|
||||
tdb_name(tdb), num_entries));
|
||||
#endif
|
||||
|
||||
/* Now traverse the tdb to validate it. */
|
||||
num_entries = tdb_traverse(tdb, validate_fn, (void *)&v_status);
|
||||
@ -292,11 +290,9 @@ static int tdb_backup(TALLOC_CTX *ctx, const char *src_path,
|
||||
|
||||
unlink(tmp_path);
|
||||
|
||||
#ifndef BUILD_TDB2
|
||||
if (!hash_size) {
|
||||
hash_size = tdb_hash_size(src_tdb);
|
||||
}
|
||||
#endif
|
||||
|
||||
dst_tdb = tdb_open_log(tmp_path, hash_size,
|
||||
TDB_DEFAULT, O_RDWR | O_CREAT | O_EXCL,
|
||||
|
@ -28,101 +28,6 @@
|
||||
#undef calloc
|
||||
#undef strdup
|
||||
|
||||
#ifdef BUILD_TDB2
|
||||
static struct flock flock_struct;
|
||||
|
||||
/* Return a value which is none of v1, v2 or v3. */
|
||||
static inline short int invalid_value(short int v1, short int v2, short int v3)
|
||||
{
|
||||
short int try = (v1+v2+v3)^((v1+v2+v3) << 16);
|
||||
while (try == v1 || try == v2 || try == v3)
|
||||
try++;
|
||||
return try;
|
||||
}
|
||||
|
||||
/* We invalidate in as many ways as we can, so the OS rejects it */
|
||||
static void invalidate_flock_struct(int signum)
|
||||
{
|
||||
flock_struct.l_type = invalid_value(F_RDLCK, F_WRLCK, F_UNLCK);
|
||||
flock_struct.l_whence = invalid_value(SEEK_SET, SEEK_CUR, SEEK_END);
|
||||
flock_struct.l_start = -1;
|
||||
/* A large negative. */
|
||||
flock_struct.l_len = (((off_t)1 << (sizeof(off_t)*CHAR_BIT - 1)) + 1);
|
||||
}
|
||||
|
||||
static int timeout_lock(int fd, int rw, off_t off, off_t len, bool waitflag,
|
||||
void *_timeout)
|
||||
{
|
||||
int ret, saved_errno;
|
||||
unsigned int timeout = *(unsigned int *)_timeout;
|
||||
|
||||
flock_struct.l_type = rw;
|
||||
flock_struct.l_whence = SEEK_SET;
|
||||
flock_struct.l_start = off;
|
||||
flock_struct.l_len = len;
|
||||
|
||||
CatchSignal(SIGALRM, invalidate_flock_struct);
|
||||
alarm(timeout);
|
||||
|
||||
for (;;) {
|
||||
if (waitflag)
|
||||
ret = fcntl(fd, F_SETLKW, &flock_struct);
|
||||
else
|
||||
ret = fcntl(fd, F_SETLK, &flock_struct);
|
||||
|
||||
if (ret == 0)
|
||||
break;
|
||||
|
||||
/* Not signalled? Something else went wrong. */
|
||||
if (flock_struct.l_len == len) {
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
continue;
|
||||
saved_errno = errno;
|
||||
break;
|
||||
} else {
|
||||
saved_errno = EINTR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
alarm(0);
|
||||
errno = saved_errno;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int tdb_chainlock_with_timeout_internal(struct tdb_context *tdb,
|
||||
TDB_DATA key,
|
||||
unsigned int timeout,
|
||||
int rw_type)
|
||||
{
|
||||
union tdb_attribute locking;
|
||||
enum TDB_ERROR ecode;
|
||||
|
||||
if (timeout) {
|
||||
locking.base.attr = TDB_ATTRIBUTE_FLOCK;
|
||||
ecode = tdb_get_attribute(tdb, &locking);
|
||||
if (ecode != TDB_SUCCESS)
|
||||
return -1;
|
||||
|
||||
/* Replace locking function with our own. */
|
||||
locking.flock.data = &timeout;
|
||||
locking.flock.lock = timeout_lock;
|
||||
|
||||
ecode = tdb_set_attribute(tdb, &locking);
|
||||
if (ecode != TDB_SUCCESS)
|
||||
return -1;
|
||||
}
|
||||
if (rw_type == F_RDLCK)
|
||||
ecode = tdb_chainlock_read(tdb, key);
|
||||
else
|
||||
ecode = tdb_chainlock(tdb, key);
|
||||
|
||||
if (timeout) {
|
||||
tdb_unset_attribute(tdb, TDB_ATTRIBUTE_FLOCK);
|
||||
}
|
||||
return ecode == TDB_SUCCESS ? 0 : -1;
|
||||
}
|
||||
#else
|
||||
/* these are little tdb utility functions that are meant to make
|
||||
dealing with a tdb database a little less cumbersome in Samba */
|
||||
|
||||
@ -175,7 +80,6 @@ static int tdb_chainlock_with_timeout_internal( TDB_CONTEXT *tdb, TDB_DATA key,
|
||||
|
||||
return ret == 0 ? 0 : -1;
|
||||
}
|
||||
#endif /* TDB1 */
|
||||
|
||||
/****************************************************************************
|
||||
Write lock a chain. Return non-zero if timeout or lock failed.
|
||||
@ -470,15 +374,6 @@ int tdb_unpack(const uint8 *buf, int bufsize, const char *fmt, ...)
|
||||
Log tdb messages via DEBUG().
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef BUILD_TDB2
|
||||
static void tdb_log(TDB_CONTEXT *tdb, enum tdb_log_level level,
|
||||
enum TDB_ERROR ecode, const char *message, void *unused)
|
||||
{
|
||||
DEBUG((int)level, ("tdb(%s):%s: %s",
|
||||
tdb_name(tdb) ? tdb_name(tdb) : "unnamed",
|
||||
tdb_errorstr(ecode), message));
|
||||
}
|
||||
#else
|
||||
static void tdb_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@ -495,7 +390,6 @@ static void tdb_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, const char *fo
|
||||
DEBUG((int)level, ("tdb(%s): %s", tdb_name(tdb) ? tdb_name(tdb) : "unnamed", ptr));
|
||||
SAFE_FREE(ptr);
|
||||
}
|
||||
#endif /* TDB1 */
|
||||
|
||||
/****************************************************************************
|
||||
Like tdb_open() but also setup a logging function that redirects to
|
||||
|
@ -764,13 +764,8 @@ const struct mangle_fns *mangle_hash_init(void)
|
||||
mangle_reset();
|
||||
|
||||
/* Create the in-memory tdb using our custom hash function. */
|
||||
#ifndef BUILD_TDB2
|
||||
tdb_mangled_cache = tdb_open_ex("mangled_cache", 1031, TDB_INTERNAL,
|
||||
(O_RDWR|O_CREAT), 0644, NULL, fast_string_hash);
|
||||
#else
|
||||
/* FIXME: We should *never* open a tdb without logging! */
|
||||
tdb_mangled_cache = tdb_open("mangled_cache", TDB_INTERNAL, 0, 0, NULL);
|
||||
#endif
|
||||
|
||||
return &mangle_hash_fns;
|
||||
}
|
||||
|
@ -1047,13 +1047,8 @@ void smbd_send_stat_cache_delete_message(struct messaging_context *msg_ctx,
|
||||
void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
|
||||
const char *name);
|
||||
void stat_cache_delete(const char *name);
|
||||
#if BUILD_TDB2
|
||||
struct tdb_data;
|
||||
unsigned int fast_string_hash(struct tdb_data *key);
|
||||
#else
|
||||
struct TDB_DATA;
|
||||
unsigned int fast_string_hash(struct TDB_DATA *key);
|
||||
#endif
|
||||
bool reset_stat_cache( void );
|
||||
|
||||
/* The following definitions come from smbd/statvfs.c */
|
||||
|
@ -150,7 +150,6 @@ static bool idmap_tdb_upgrade(struct idmap_domain *dom, struct db_context *db)
|
||||
struct convert_fn_state s;
|
||||
NTSTATUS status;
|
||||
|
||||
#if BUILD_TDB2
|
||||
/* If we are bigendian, tdb is bigendian if NOT converted. */
|
||||
union {
|
||||
uint16 large;
|
||||
@ -163,9 +162,6 @@ static bool idmap_tdb_upgrade(struct idmap_domain *dom, struct db_context *db)
|
||||
assert(u.small[0] == 0x02);
|
||||
bigendianheader = (dbwrap_get_flags(db) & TDB_CONVERT);
|
||||
}
|
||||
#else
|
||||
bigendianheader = (dbwrap_get_flags(db) & TDB_BIGENDIAN) ? True : False;
|
||||
#endif
|
||||
DEBUG(0, ("Upgrading winbindd_idmap.tdb from an old version\n"));
|
||||
|
||||
status = dbwrap_fetch_int32_bystring(db, "IDMAP_VERSION", &vers);
|
||||
|
Loading…
x
Reference in New Issue
Block a user