Commit bf91eb5a authored by Mathieu Parent's avatar Mathieu Parent

Update upstream source from tag 'upstream/1.4.2'

Update to upstream version '1.4.2'
with Debian dir b57de67ef3bcc717b7700abb585d662360ee08d9
parents a64143b3 4cd41985
This diff is collapsed.
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
...@@ -43,7 +43,7 @@ def process(tsk): ...@@ -43,7 +43,7 @@ def process(tsk):
if tsk.__class__.stat: ret = tsk.__class__.stat(tsk) if tsk.__class__.stat: ret = tsk.__class__.stat(tsk)
# actual call to task's run() function # actual call to task's run() function
else: ret = tsk.call_run() else: ret = tsk.call_run()
except Exception, e: except Exception as e:
tsk.err_msg = Utils.ex_stack() tsk.err_msg = Utils.ex_stack()
tsk.hasrun = EXCEPTION tsk.hasrun = EXCEPTION
...@@ -177,7 +177,7 @@ class Parallel(object): ...@@ -177,7 +177,7 @@ class Parallel(object):
try: try:
st = tsk.runnable_status() st = tsk.runnable_status()
except Exception, e: except Exception as e:
self.processed += 1 self.processed += 1
if self.stop and not Options.options.keep: if self.stop and not Options.options.keep:
tsk.hasrun = SKIPPED tsk.hasrun = SKIPPED
......
...@@ -721,6 +721,10 @@ def SAMBA_CONFIG_H(conf, path=None): ...@@ -721,6 +721,10 @@ def SAMBA_CONFIG_H(conf, path=None):
testflags=True) testflags=True)
conf.ADD_CFLAGS('-Werror=uninitialized -Wuninitialized', conf.ADD_CFLAGS('-Werror=uninitialized -Wuninitialized',
testflags=True) testflags=True)
conf.ADD_CFLAGS('-Wimplicit-fallthrough',
testflags=True)
conf.ADD_CFLAGS('-Werror=strict-overflow -Wstrict-overflow=2',
testflags=True)
conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True) conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
conf.ADD_CFLAGS('-Wno-format-zero-length', testflags=True) conf.ADD_CFLAGS('-Wno-format-zero-length', testflags=True)
......
...@@ -85,6 +85,8 @@ def minimum_library_version(conf, libname, default): ...@@ -85,6 +85,8 @@ def minimum_library_version(conf, libname, default):
@conf @conf
def LIB_MAY_BE_BUNDLED(conf, libname): def LIB_MAY_BE_BUNDLED(conf, libname):
if libname in conf.env.SYSTEM_LIBS:
return False
if libname in conf.env.BUNDLED_LIBS: if libname in conf.env.BUNDLED_LIBS:
return True return True
if '!%s' % libname in conf.env.BUNDLED_LIBS: if '!%s' % libname in conf.env.BUNDLED_LIBS:
......
...@@ -50,7 +50,7 @@ def check(self, *k, **kw): ...@@ -50,7 +50,7 @@ def check(self, *k, **kw):
ret = None ret = None
try: try:
ret = self.run_c_code(*k, **kw) ret = self.run_c_code(*k, **kw)
except Configure.ConfigurationError, e: except Configure.ConfigurationError as e:
self.check_message_2(kw['errmsg'], 'YELLOW') self.check_message_2(kw['errmsg'], 'YELLOW')
if 'mandatory' in kw and kw['mandatory']: if 'mandatory' in kw and kw['mandatory']:
if Logs.verbose > 1: if Logs.verbose > 1:
......
...@@ -167,7 +167,7 @@ def dist(appname='', version=''): ...@@ -167,7 +167,7 @@ def dist(appname='', version=''):
absdir = os.path.join(srcdir, dir) absdir = os.path.join(srcdir, dir)
try: try:
files = vcs_dir_contents(absdir) files = vcs_dir_contents(absdir)
except Exception, e: except Exception as e:
Logs.error('unable to get contents of %s: %s' % (absdir, e)) Logs.error('unable to get contents of %s: %s' % (absdir, e))
sys.exit(1) sys.exit(1)
add_files_to_tarball(tar, srcdir, dir, dist_base, destdir, blacklist, files) add_files_to_tarball(tar, srcdir, dir, dist_base, destdir, blacklist, files)
......
...@@ -95,7 +95,7 @@ also accepted as dictionary entries here ...@@ -95,7 +95,7 @@ also accepted as dictionary entries here
self.VENDOR_SUFFIX=None self.VENDOR_SUFFIX=None
self.VENDOR_PATCH=None self.VENDOR_PATCH=None
for a, b in version_dict.iteritems(): for a, b in version_dict.items():
if a.startswith("SAMBA_VERSION_"): if a.startswith("SAMBA_VERSION_"):
setattr(self, a[14:], b) setattr(self, a[14:], b)
else: else:
......
...@@ -353,6 +353,7 @@ def SAMBA_BINARY(bld, binname, source, ...@@ -353,6 +353,7 @@ def SAMBA_BINARY(bld, binname, source,
modules=None, modules=None,
ldflags=None, ldflags=None,
cflags='', cflags='',
cflags_end=None,
autoproto=None, autoproto=None,
use_hostcc=False, use_hostcc=False,
use_global_deps=True, use_global_deps=True,
...@@ -410,6 +411,7 @@ def SAMBA_BINARY(bld, binname, source, ...@@ -410,6 +411,7 @@ def SAMBA_BINARY(bld, binname, source,
deps = deps, deps = deps,
includes = includes, includes = includes,
cflags = pie_cflags, cflags = pie_cflags,
cflags_end = cflags_end,
group = subsystem_group, group = subsystem_group,
autoproto = autoproto, autoproto = autoproto,
subsystem_name = subsystem_name, subsystem_name = subsystem_name,
...@@ -458,6 +460,7 @@ def SAMBA_MODULE(bld, modname, source, ...@@ -458,6 +460,7 @@ def SAMBA_MODULE(bld, modname, source,
autoproto=None, autoproto=None,
autoproto_extra_source='', autoproto_extra_source='',
cflags='', cflags='',
cflags_end=None,
internal_module=True, internal_module=True,
local_include=True, local_include=True,
global_include=True, global_include=True,
...@@ -488,6 +491,7 @@ def SAMBA_MODULE(bld, modname, source, ...@@ -488,6 +491,7 @@ def SAMBA_MODULE(bld, modname, source,
autoproto=autoproto, autoproto=autoproto,
autoproto_extra_source=autoproto_extra_source, autoproto_extra_source=autoproto_extra_source,
cflags=cflags, cflags=cflags,
cflags_end=cflags_end,
local_include=local_include, local_include=local_include,
global_include=global_include, global_include=global_include,
allow_warnings=allow_warnings, allow_warnings=allow_warnings,
...@@ -527,6 +531,7 @@ def SAMBA_MODULE(bld, modname, source, ...@@ -527,6 +531,7 @@ def SAMBA_MODULE(bld, modname, source,
deps=deps, deps=deps,
includes=includes, includes=includes,
cflags=cflags, cflags=cflags,
cflags_end=cflags_end,
realname = realname, realname = realname,
autoproto = autoproto, autoproto = autoproto,
local_include=local_include, local_include=local_include,
...@@ -900,7 +905,7 @@ def INSTALL_DIR(bld, path, chmod=0o755, env=None): ...@@ -900,7 +905,7 @@ def INSTALL_DIR(bld, path, chmod=0o755, env=None):
try: try:
os.makedirs(destpath) os.makedirs(destpath)
os.chmod(destpath, chmod) os.chmod(destpath, chmod)
except OSError, e: except OSError as e:
if not os.path.isdir(destpath): if not os.path.isdir(destpath):
raise Utils.WafError("Cannot create the folder '%s' (error: %s)" % (path, e)) raise Utils.WafError("Cannot create the folder '%s' (error: %s)" % (path, e))
Build.BuildContext.INSTALL_DIR = INSTALL_DIR Build.BuildContext.INSTALL_DIR = INSTALL_DIR
......
...@@ -269,6 +269,7 @@ def configure(conf): ...@@ -269,6 +269,7 @@ def configure(conf):
conf.env.MODULESDIR = Options.options.MODULESDIR conf.env.MODULESDIR = Options.options.MODULESDIR
conf.env.PRIVATELIBDIR = Options.options.PRIVATELIBDIR conf.env.PRIVATELIBDIR = Options.options.PRIVATELIBDIR
conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',') conf.env.BUNDLED_LIBS = Options.options.BUNDLED_LIBS.split(',')
conf.env.SYSTEM_LIBS = ()
conf.env.PRIVATE_LIBS = Options.options.PRIVATE_LIBS.split(',') conf.env.PRIVATE_LIBS = Options.options.PRIVATE_LIBS.split(',')
conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',') conf.env.BUILTIN_LIBRARIES = Options.options.BUILTIN_LIBRARIES.split(',')
conf.env.NONSHARED_BINARIES = Options.options.NONSHARED_BINARIES.split(',') conf.env.NONSHARED_BINARIES = Options.options.NONSHARED_BINARIES.split(',')
......
...@@ -379,6 +379,7 @@ int ldb_transaction_start(struct ldb_context *ldb) ...@@ -379,6 +379,7 @@ int ldb_transaction_start(struct ldb_context *ldb)
"ldb transaction start: %s (%d)", "ldb transaction start: %s (%d)",
ldb_strerror(status), ldb_strerror(status),
status); status);
ldb->transaction_active--;
} }
if ((next_module && next_module->ldb->flags & LDB_FLG_ENABLE_TRACING)) { if ((next_module && next_module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(next_module->ldb, LDB_DEBUG_TRACE, "start ldb transaction error: %s", ldb_debug(next_module->ldb, LDB_DEBUG_TRACE, "start ldb transaction error: %s",
...@@ -424,6 +425,8 @@ int ldb_transaction_prepare_commit(struct ldb_context *ldb) ...@@ -424,6 +425,8 @@ int ldb_transaction_prepare_commit(struct ldb_context *ldb)
return LDB_SUCCESS; return LDB_SUCCESS;
} }
ldb_reset_err_string(ldb);
status = next_module->ops->prepare_commit(next_module); status = next_module->ops->prepare_commit(next_module);
if (status != LDB_SUCCESS) { if (status != LDB_SUCCESS) {
ldb->transaction_active--; ldb->transaction_active--;
......
...@@ -629,7 +629,8 @@ static bool ldb_dn_explode(struct ldb_dn *dn) ...@@ -629,7 +629,8 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
l++; l++;
break; break;
} }
/* fall through */
FALL_THROUGH;
case '\"': case '\"':
case '<': case '<':
case '>': case '>':
......
...@@ -216,7 +216,8 @@ static int fold_string(int (*fprintf_fn)(void *, const char *, ...), void *priva ...@@ -216,7 +216,8 @@ static int fold_string(int (*fprintf_fn)(void *, const char *, ...), void *priva
const char *buf, size_t length, int start_pos) const char *buf, size_t length, int start_pos)
{ {
size_t i; size_t i;
int total=0, ret; size_t total = 0;
int ret;
for (i=0;i<length;i++) { for (i=0;i<length;i++) {
ret = fprintf_fn(private_data, "%c", buf[i]); ret = fprintf_fn(private_data, "%c", buf[i]);
...@@ -280,7 +281,8 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb, ...@@ -280,7 +281,8 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb,
{ {
TALLOC_CTX *mem_ctx; TALLOC_CTX *mem_ctx;
unsigned int i, j; unsigned int i, j;
int total=0, ret; size_t total = 0;
int ret;
char *p; char *p;
const struct ldb_message *msg; const struct ldb_message *msg;
const char * const * secret_attributes = ldb_get_opaque(ldb, LDB_SECRET_ATTRIBUTE_LIST_OPAQUE); const char * const * secret_attributes = ldb_get_opaque(ldb, LDB_SECRET_ATTRIBUTE_LIST_OPAQUE);
......
...@@ -1103,7 +1103,7 @@ static int ldb_modules_load_dir(const char *modules_dir, const char *version) ...@@ -1103,7 +1103,7 @@ static int ldb_modules_load_dir(const char *modules_dir, const char *version)
*/ */
void ldb_set_modules_dir(struct ldb_context *ldb, const char *path) void ldb_set_modules_dir(struct ldb_context *ldb, const char *path)
{ {
int ret = ldb_modules_load_path(path, LDB_VERSION); int ret = ldb_modules_load_dir(path, LDB_VERSION);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb, "Failed to load modules from: %s\n", path); ldb_asprintf_errstring(ldb, "Failed to load modules from: %s\n", path);
} }
......
...@@ -59,9 +59,8 @@ typedef struct ...@@ -59,9 +59,8 @@ typedef struct
#define CHAR_BIT 8 #define CHAR_BIT 8
#endif #endif
#define STACK_SIZE (CHAR_BIT * sizeof(size_t)) #define STACK_SIZE (CHAR_BIT * sizeof(size_t))
#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) #define PUSH(low, high) ((void) ((stack[i].lo = (low)), (stack[i].hi = (high)), i++))
#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) #define POP(low, high) ((void) (i--, (low = stack[i].lo), (high = stack[i].hi)))
#define STACK_NOT_EMPTY (stack < top)
/* Order size using quicksort. This implementation incorporates /* Order size using quicksort. This implementation incorporates
...@@ -104,11 +103,11 @@ void ldb_qsort (void *const pbase, size_t total_elems, size_t size, ...@@ -104,11 +103,11 @@ void ldb_qsort (void *const pbase, size_t total_elems, size_t size,
char *lo = base_ptr; char *lo = base_ptr;
char *hi = &lo[size * (total_elems - 1)]; char *hi = &lo[size * (total_elems - 1)];
stack_node stack[STACK_SIZE]; stack_node stack[STACK_SIZE];
stack_node *top = stack; size_t i = 0;
PUSH (NULL, NULL); PUSH (NULL, NULL);
while (STACK_NOT_EMPTY) do
{ {
char *left_ptr; char *left_ptr;
char *right_ptr; char *right_ptr;
...@@ -194,6 +193,7 @@ void ldb_qsort (void *const pbase, size_t total_elems, size_t size, ...@@ -194,6 +193,7 @@ void ldb_qsort (void *const pbase, size_t total_elems, size_t size,
hi = right_ptr; hi = right_ptr;
} }
} }
while (i > 0 && i < STACK_SIZE);
} }
/* Once the BASE_PTR array is partially sorted by quicksort the rest /* Once the BASE_PTR array is partially sorted by quicksort the rest
......
...@@ -54,18 +54,18 @@ ...@@ -54,18 +54,18 @@
#endif #endif
/* /*
* Only Samba versions which expect ldb >= 1.2.0 * Only Samba versions which expect ldb >= 1.4.0
* are compatible with read_[un]lock() behaviour. * reopen the ldb after each fork().
* *
* See https://bugzilla.samba.org/show_bug.cgi?id=12859 * See https://bugzilla.samba.org/show_bug.cgi?id=13519
*/ */
#if EXPECTED_SYSTEM_LDB_VERSION_MAJOR > 1 #if EXPECTED_SYSTEM_LDB_VERSION_MAJOR > 1
#define __LDB_READ_LOCK_COMPATIBLE__ 1 #define __LDB_FORK_COMPATIBLE__ 1
#elif EXPECTED_SYSTEM_LDB_VERSION_MINOR > 1 #elif EXPECTED_SYSTEM_LDB_VERSION_MINOR > 3
#define __LDB_READ_LOCK_COMPATIBLE__ 1 #define __LDB_FORK_COMPATIBLE__ 1
#endif #endif
#ifndef __LDB_READ_LOCK_COMPATIBLE__ #ifndef __LDB_FORK_COMPATIBLE__
#error "Samba < 4.7 is not compatible with this version of ldb due to assumptions around read locks" #error "Samba < 4.9 is not compatible with this version of ldb due to assumptions around fork() behaviour"
#endif #endif
#endif /* defined(_SAMBA_BUILD_) && defined(USING_SYSTEM_LDB) */ #endif /* defined(_SAMBA_BUILD_) && defined(USING_SYSTEM_LDB) */
......
/*
* ldb connection and module initialisation
*
* Copyright (C) Andrew Bartlett <abartlet@samba.org> 2018
*
* 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/>.
*
*/
#include "ldb_private.h"
#include "../ldb_tdb/ldb_tdb.h"
#ifdef HAVE_LMDB
#include "../ldb_mdb/ldb_mdb.h"
#endif /* HAVE_LMDB */
/*
connect to the database
*/
static int lldb_connect(struct ldb_context *ldb,
const char *url,
unsigned int flags,
const char *options[],
struct ldb_module **module)
{
const char *path;
int ret;
/*
* Check and remove the url prefix
*/
if (strchr(url, ':')) {
if (strncmp(url, "ldb://", 6) != 0) {
ldb_debug(ldb, LDB_DEBUG_ERROR,
"Invalid ldb URL '%s'", url);
return LDB_ERR_OPERATIONS_ERROR;
}
path = url+6;
} else {
path = url;
}
/*
* Don't create the database if it's not there
*/
flags |= LDB_FLG_DONT_CREATE_DB;
#ifdef HAVE_LMDB
/*
* Try opening the database as an lmdb
*/
ret = lmdb_connect(ldb, path, flags, options, module);
if (ret == LDB_SUCCESS) {
return ret;
}
if (ret != LDB_ERR_UNAVAILABLE) {
return ret;
}
/*
* Not mdb so try as tdb
*/
#endif /* HAVE_LMDB */
ret = ltdb_connect(ldb, path, flags, options, module);
return ret;
}
int ldb_ldb_init(const char *version)
{
LDB_MODULE_CHECK_VERSION(version);
return ldb_register_backend("ldb", lldb_connect, false);
}
...@@ -523,7 +523,8 @@ struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct ...@@ -523,7 +523,8 @@ struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct
"used in DN!", ldb_dn_get_component_name(dn, i)); "used in DN!", ldb_dn_get_component_name(dn, i));
goto failed; goto failed;
} }
/* fall through */
FALL_THROUGH;
case LDB_MAP_KEEP: case LDB_MAP_KEEP:
case LDB_MAP_RENAME: case LDB_MAP_RENAME:
case LDB_MAP_RENDROP: case LDB_MAP_RENDROP:
...@@ -599,7 +600,8 @@ struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struc ...@@ -599,7 +600,8 @@ struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struc
"used in DN!", ldb_dn_get_component_name(dn, i)); "used in DN!", ldb_dn_get_component_name(dn, i));
goto failed; goto failed;
} }
/* fall through */
FALL_THROUGH;
case LDB_MAP_KEEP: case LDB_MAP_KEEP:
case LDB_MAP_RENAME: case LDB_MAP_RENAME:
case LDB_MAP_RENDROP: case LDB_MAP_RENDROP:
......
...@@ -87,7 +87,8 @@ static int ldb_msg_el_partition(struct ldb_module *module, enum ldb_request_type ...@@ -87,7 +87,8 @@ static int ldb_msg_el_partition(struct ldb_module *module, enum ldb_request_type
el = ldb_msg_el_map_local(module, remote, map, old); el = ldb_msg_el_map_local(module, remote, map, old);
break; break;
} }
/* fall through */
FALL_THROUGH;
case LDB_MAP_IGNORE: case LDB_MAP_IGNORE:
goto local; goto local;
...@@ -99,7 +100,8 @@ static int ldb_msg_el_partition(struct ldb_module *module, enum ldb_request_type ...@@ -99,7 +100,8 @@ static int ldb_msg_el_partition(struct ldb_module *module, enum ldb_request_type
map->local_name); map->local_name);
goto local; goto local;
} }
/* fall through */
FALL_THROUGH;
case LDB_MAP_KEEP: case LDB_MAP_KEEP:
case LDB_MAP_RENAME: case LDB_MAP_RENAME:
el = ldb_msg_el_map_local(module, remote, map, old); el = ldb_msg_el_map_local(module, remote, map, old);
......
...@@ -330,7 +330,8 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local ...@@ -330,7 +330,8 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
attr_name); attr_name);
return LDB_SUCCESS; return LDB_SUCCESS;
} }
/* fall through */
FALL_THROUGH;
case LDB_MAP_KEEP: case LDB_MAP_KEEP:
case LDB_MAP_RENAME: case LDB_MAP_RENAME:
case LDB_MAP_RENDROP: case LDB_MAP_RENDROP:
......
This diff is collapsed.
/*
ldb database library using mdb back end - transaction operations
Copyright (C) Jakub Hrozek 2015
Copyright (C) Catalyst.Net Ltd 2017
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _LDB_MDB_H_
#define _LDB_MDB_H_
#include "ldb_private.h"
#include <lmdb.h>
struct lmdb_private {
struct ldb_context *ldb;
MDB_env *env;
struct lmdb_trans *txlist;
struct ldb_mdb_metadata {
struct ldb_message *attributes;
unsigned seqnum;
} *meta;
int error;
MDB_txn *read_txn;
pid_t pid;
};
struct lmdb_trans {
struct lmdb_trans *next;
struct lmdb_trans *prev;
MDB_txn *tx;
};
int ldb_mdb_err_map(int lmdb_err);
int lmdb_connect(struct ldb_context *ldb, const char *url,
unsigned int flags, const char *options[],
struct ldb_module **_module);
#endif /* _LDB_MDB_H_ */
/*
ldb database library using mdb back end
Copyright (C) Jakub Hrozek 2014
Copyright (C) Catalyst.Net Ltd 2017
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "ldb_mdb.h"
int ldb_mdb_init(const char *version)
{
LDB_MODULE_CHECK_VERSION(version);
return ldb_register_backend("mdb", lmdb_connect, false);
}
...@@ -238,7 +238,7 @@ static int ltdb_index_load(struct ldb_module *module, ...@@ -238,7 +238,7 @@ static int ltdb_index_load(struct ldb_module *module,
{ {
struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_context *ldb = ldb_module_get_ctx(module);
struct ldb_dn *indexlist_dn; struct ldb_dn *indexlist_dn;
int r; int r, lmdb_subdb_version;
if (ldb->schema.index_handler_override) { if (ldb->schema.index_handler_override) {
/* /*
...@@ -291,6 +291,20 @@ static int ltdb_index_load(struct ldb_module *module, ...@@ -291,6 +291,20 @@ static int ltdb_index_load(struct ldb_module *module,
= ldb_msg_find_attr_as_string(ltdb->cache->indexlist, = ldb_msg_find_attr_as_string(ltdb->cache->indexlist,
LTDB_IDX_DN_GUID, NULL); LTDB_IDX_DN_GUID, NULL);
lmdb_subdb_version
= ldb_msg_find_attr_as_int(ltdb->cache->indexlist,
LTDB_IDX_LMDB_SUBDB, 0);
if (lmdb_subdb_version != 0) {
ldb_set_errstring(ldb,
"FATAL: This ldb_mdb database has "
"been written in a new verson of LDB "
"using a sub-database index that "
"is not understood by ldb "
LDB_VERSION);
return -1;
}
return 0; return 0;
} }
...@@ -386,13 +400,13 @@ int ltdb_cache_load(struct ldb_module *module) ...@@ -386,13 +400,13 @@ int ltdb_cache_load(struct ldb_module *module)
uint64_t seq; uint64_t seq;
struct ldb_message *baseinfo = NULL, *options = NULL; struct ldb_message *baseinfo = NULL, *options = NULL;
const struct ldb_schema_attribute *a; const struct ldb_schema_attribute *a;
bool have_write_txn = false;
int r; int r;
ldb = ldb_module_get_ctx(module); ldb = ldb_module_get_ctx(module);
/* a very fast check to avoid extra database reads */ /* a very fast check to avoid extra database reads */
if (ltdb->cache != NULL && if (ltdb->cache != NULL && !ltdb->kv_ops->has_changed(ltdb)) {
tdb_get_seqnum(ltdb->tdb) == ltdb->tdb_seqnum) {
return 0; return 0;
}