Commit d25d84eb authored by Mathieu Parent's avatar Mathieu Parent

New upstream version 1.3.2

parent 26bcbdd5
This diff is collapsed.
This diff is collapsed.
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 **)
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 **)
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):
if tsk.__class__.stat: ret = tsk.__class__.stat(tsk)
# actual call to task's run() function
else: ret = tsk.call_run()
except Exception, e:
except Exception as e:
tsk.err_msg = Utils.ex_stack()
tsk.hasrun = EXCEPTION
......@@ -177,7 +177,7 @@ class Parallel(object):
try:
st = tsk.runnable_status()
except Exception, e:
except Exception as e:
self.processed += 1
if self.stop and not Options.options.keep:
tsk.hasrun = SKIPPED
......
......@@ -454,7 +454,8 @@ def CHECK_CODE(conf, code, define,
@conf
def CHECK_STRUCTURE_MEMBER(conf, structname, member,
always=False, define=None, headers=None):
always=False, define=None, headers=None,
lib=None):
'''check for a structure member'''
if define is None:
define = 'HAVE_%s' % member.upper()
......@@ -463,6 +464,7 @@ def CHECK_STRUCTURE_MEMBER(conf, structname, member,
define,
execute=False,
link=False,
lib=lib,
always=always,
headers=headers,
local_include=False,
......@@ -473,10 +475,13 @@ def CHECK_STRUCTURE_MEMBER(conf, structname, member,
def CHECK_CFLAGS(conf, cflags, fragment='int main(void) { return 0; }\n'):
'''check if the given cflags are accepted by the compiler
'''
check_cflags = TO_LIST(cflags)
if 'WERROR_CFLAGS' in conf.env:
check_cflags.extend(conf.env['WERROR_CFLAGS'])
return conf.check(fragment=fragment,
execute=0,
type='nolink',
ccflags=cflags,
ccflags=check_cflags,
msg="Checking compiler accepts %s" % cflags)
@conf
......@@ -708,7 +713,9 @@ def SAMBA_CONFIG_H(conf, path=None):
testflags=True)
conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
conf.ADD_CFLAGS('-Werror=format-security -Wformat-security', testflags=True)
conf.ADD_CFLAGS('-Wno-format-zero-length', testflags=True)
conf.ADD_CFLAGS('-Werror=format-security -Wformat-security',
testflags=True, prereq_flags='-Wformat')
# This check is because for ldb_search(), a NULL format string
# is not an error, but some compilers complain about that.
if CHECK_CFLAGS(conf, ["-Werror=format", "-Wformat=2"], '''
......@@ -769,14 +776,15 @@ def CONFIG_PATH(conf, name, default):
conf.env[name] = conf.env['PREFIX'] + default
@conf
def ADD_NAMED_CFLAGS(conf, name, flags, testflags=False):
def ADD_NAMED_CFLAGS(conf, name, flags, testflags=False, prereq_flags=[]):
'''add some CFLAGS to the command line
optionally set testflags to ensure all the flags work
'''
prereq_flags = TO_LIST(prereq_flags)
if testflags:
ok_flags=[]
for f in flags.split():
if CHECK_CFLAGS(conf, f):
if CHECK_CFLAGS(conf, [f] + prereq_flags):
ok_flags.append(f)
flags = ok_flags
if not name in conf.env:
......@@ -784,11 +792,12 @@ def ADD_NAMED_CFLAGS(conf, name, flags, testflags=False):
conf.env[name].extend(TO_LIST(flags))
@conf
def ADD_CFLAGS(conf, flags, testflags=False):
def ADD_CFLAGS(conf, flags, testflags=False, prereq_flags=[]):
'''add some CFLAGS to the command line
optionally set testflags to ensure all the flags work
'''
ADD_NAMED_CFLAGS(conf, 'EXTRA_CFLAGS', flags, testflags=testflags)
ADD_NAMED_CFLAGS(conf, 'EXTRA_CFLAGS', flags, testflags=testflags,
prereq_flags=prereq_flags)
@conf
def ADD_LDFLAGS(conf, flags, testflags=False):
......
......@@ -50,7 +50,7 @@ def check(self, *k, **kw):
ret = None
try:
ret = self.run_c_code(*k, **kw)
except Configure.ConfigurationError, e:
except Configure.ConfigurationError as e:
self.check_message_2(kw['errmsg'], 'YELLOW')
if 'mandatory' in kw and kw['mandatory']:
if Logs.verbose > 1:
......
......@@ -115,7 +115,7 @@ def dist(appname='', version=''):
blacklisted = True
if blacklisted:
continue
if os.path.isdir(abspath):
if os.path.isdir(abspath) and not os.path.islink(abspath):
continue
if dstsubdir != '.':
f = dstsubdir + '/' + f
......@@ -167,7 +167,7 @@ def dist(appname='', version=''):
absdir = os.path.join(srcdir, dir)
try:
files = vcs_dir_contents(absdir)
except Exception, e:
except Exception as e:
Logs.error('unable to get contents of %s: %s' % (absdir, e))
sys.exit(1)
add_files_to_tarball(tar, srcdir, dir, dist_base, destdir, blacklist, files)
......@@ -182,7 +182,7 @@ def dist(appname='', version=''):
absfile = os.path.join(srcdir, file)
if os.path.isdir(absfile):
if os.path.isdir(absfile) and not os.path.islink(absfile):
destdir = destfile
dir = file
files = list_directory_files(dir)
......
......@@ -108,6 +108,7 @@ def write_build_options_header(fp):
fp.write(" output(screen,\" PIDDIR: %s\\n\", get_dyn_PIDDIR());\n")
fp.write(" output(screen,\" SMB_PASSWD_FILE: %s\\n\",get_dyn_SMB_PASSWD_FILE());\n")
fp.write(" output(screen,\" PRIVATE_DIR: %s\\n\",get_dyn_PRIVATE_DIR());\n")
fp.write(" output(screen,\" BINDDNS_DIR: %s\\n\",get_dyn_BINDDNS_DIR());\n")
fp.write("\n")
def write_build_options_footer(fp):
......
......@@ -109,6 +109,7 @@ def SAMBA_PYTHON(bld, name,
public_deps='',
realname=None,
cflags='',
cflags_end=None,
includes='',
init_function_sentinel=None,
local_include=True,
......@@ -154,6 +155,7 @@ def SAMBA_PYTHON(bld, name,
public_deps=public_deps,
includes=includes,
cflags=cflags,
cflags_end=cflags_end,
local_include=local_include,
vars=vars,
realname=realname,
......
......@@ -39,3 +39,28 @@ def CHECK_CMOCKA(conf):
return conf.CHECK_BUNDLED_SYSTEM_PKG('cmocka', minversion='1.1.1')
Build.BuildContext.CHECK_CMOCKA = CHECK_CMOCKA
@conf
def CHECK_SOCKET_WRAPPER(conf):
return conf.CHECK_BUNDLED_SYSTEM_PKG('socket_wrapper', minversion='1.1.9')
Build.BuildContext.CHECK_SOCKET_WRAPPER = CHECK_SOCKET_WRAPPER
@conf
def CHECK_NSS_WRAPPER(conf):
return conf.CHECK_BUNDLED_SYSTEM_PKG('nss_wrapper', minversion='1.1.3')
Build.BuildContext.CHECK_NSS_WRAPPER = CHECK_NSS_WRAPPER
@conf
def CHECK_RESOLV_WRAPPER(conf):
return conf.CHECK_BUNDLED_SYSTEM_PKG('resolv_wrapper', minversion='1.1.4')
Build.BuildContext.CHECK_RESOLV_WRAPPER = CHECK_RESOLV_WRAPPER
@conf
def CHECK_UID_WRAPPER(conf):
return conf.CHECK_BUNDLED_SYSTEM_PKG('uid_wrapper', minversion='1.2.4')
Build.BuildContext.CHECK_UID_WRAPPER = CHECK_UID_WRAPPER
@conf
def CHECK_PAM_WRAPPER(conf):
return conf.CHECK_BUNDLED_SYSTEM_PKG('pam_wrapper', minversion='1.0.4')
Build.BuildContext.CHECK_PAM_WRAPPER = CHECK_PAM_WRAPPER
......@@ -112,6 +112,7 @@ def SAMBA_LIBRARY(bld, libname, source,
vnum=None,
soname=None,
cflags='',
cflags_end=None,
ldflags='',
external_library=False,
realname=None,
......@@ -195,6 +196,7 @@ def SAMBA_LIBRARY(bld, libname, source,
private_headers= private_headers,
header_path = header_path,
cflags = cflags,
cflags_end = cflags_end,
group = subsystem_group,
autoproto = autoproto,
autoproto_extra_source=autoproto_extra_source,
......@@ -885,13 +887,30 @@ def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
python_fixup=python_fixup, base_name=trim_path)
Build.BuildContext.INSTALL_WILDCARD = INSTALL_WILDCARD
def INSTALL_DIR(bld, path, chmod=0o755, env=None):
"""Install a directory if it doesn't exist, always set permissions."""
def INSTALL_DIRS(bld, destdir, dirs):
if not path:
return []
destpath = bld.get_install_path(path, env)
if bld.is_install > 0:
if not os.path.isdir(destpath):
try:
os.makedirs(destpath)
os.chmod(destpath, chmod)
except OSError as e:
if not os.path.isdir(destpath):
raise Utils.WafError("Cannot create the folder '%s' (error: %s)" % (path, e))
Build.BuildContext.INSTALL_DIR = INSTALL_DIR
def INSTALL_DIRS(bld, destdir, dirs, chmod=0o755, env=None):
'''install a set of directories'''
destdir = bld.EXPAND_VARIABLES(destdir)
dirs = bld.EXPAND_VARIABLES(dirs)
for d in TO_LIST(dirs):
bld.install_dir(os.path.join(destdir, d))
INSTALL_DIR(bld, os.path.join(destdir, d), chmod, env)
Build.BuildContext.INSTALL_DIRS = INSTALL_DIRS
......
......@@ -313,10 +313,6 @@ def configure(conf):
conf.env.GIT_LOCAL_CHANGES = Options.options.GIT_LOCAL_CHANGES
conf.CHECK_COMMAND(['uname', '-a'],
msg='Checking build system',
define='BUILD_SYSTEM',
on_target=False)
conf.CHECK_UNAME()
# see if we can compile and run a simple C program
......
......@@ -395,3 +395,17 @@ void ldb_schema_set_override_indexlist(struct ldb_context *ldb,
ldb->schema.index_handler_override = true;
ldb->schema.one_level_indexes = one_level_indexes;
}
/*
* set that the GUID index mode is in operation
*
* The caller must ensure the supplied strings do not go out of
* scope (they are typically constant memory).
*/
void ldb_schema_set_override_GUID_index(struct ldb_context *ldb,
const char *GUID_index_attribute,
const char *GUID_index_dn_component)
{
ldb->schema.GUID_index_attribute = GUID_index_attribute;
ldb->schema.GUID_index_dn_component = GUID_index_dn_component;
}
......@@ -515,17 +515,18 @@ static int ldb_match_extended(struct ldb_context *ldb,
}
/*
return 0 if the given parse tree matches the given message. Assumes
the message is in sorted order
Check if a particular message will match the given filter
return 1 if it matches, and 0 if it doesn't match
set *matched to true if it matches, false otherwise
returns LDB_SUCCESS or an error
this is a recursive function, and does short-circuit evaluation
*/
static int ldb_match_message(struct ldb_context *ldb,
const struct ldb_message *msg,
const struct ldb_parse_tree *tree,
enum ldb_scope scope, bool *matched)
int ldb_match_message(struct ldb_context *ldb,
const struct ldb_message *msg,
const struct ldb_parse_tree *tree,
enum ldb_scope scope, bool *matched)
{
unsigned int i;
int ret;
......@@ -587,6 +588,13 @@ static int ldb_match_message(struct ldb_context *ldb,
return LDB_ERR_INAPPROPRIATE_MATCHING;
}
/*
return 0 if the given parse tree matches the given message. Assumes
the message is in sorted order
return 1 if it matches, and 0 if it doesn't match
*/
int ldb_match_msg(struct ldb_context *ldb,
const struct ldb_message *msg,
const struct ldb_parse_tree *tree,
......
......@@ -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)
{
int ret = ldb_modules_load_path(path, LDB_VERSION);
int ret = ldb_modules_load_dir(path, LDB_VERSION);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb, "Failed to load modules from: %s\n", path);
}
......
......@@ -87,6 +87,15 @@ struct ldb_module;
/* force single value checking on this attribute */
#define LDB_FLAG_INTERNAL_FORCE_SINGLE_VALUE_CHECK 0x80
/*
* ensure that this value is unique on an index
* (despite the index not otherwise being configured as UNIQUE).
* For example, all words starting with 'a' must be unique, but duplicates of
* words starting with b are allowed. This is specifically for Samba's
* objectSid index which is unique in the primary domain only.
*/
#define LDB_FLAG_INTERNAL_FORCE_UNIQUE_INDEX 0x100
/* an extended match rule that always fails to match */
#define SAMBA_LDAP_MATCH_ALWAYS_FALSE "1.3.6.1.4.1.7165.4.5.1"
......@@ -183,6 +192,22 @@ void ldb_schema_attribute_set_override_handler(struct ldb_context *ldb,
void ldb_schema_set_override_indexlist(struct ldb_context *ldb,
bool one_level_indexes);
/**
\param ldb The ldb context
\param GUID_index_attribute The globally attribute (eg objectGUID)
on each entry
\param GUID_index_attribute The DN component matching the
globally attribute on each entry (eg GUID)
The caller must ensure the supplied strings do not go out of
scope (they are typically constant memory).
*/
void ldb_schema_set_override_GUID_index(struct ldb_context *ldb,
const char *GUID_index_attribute,
const char *GUID_index_dn_component);
/* A useful function to build comparison functions with */
int ldb_any_comparison(struct ldb_context *ldb, void *mem_ctx,
ldb_attr_handler_t canonicalise_fn,
......
......@@ -98,6 +98,9 @@ struct ldb_schema {
*/
bool index_handler_override;
bool one_level_indexes;
const char *GUID_index_attribute;
const char *GUID_index_dn_component;
};
/*
......@@ -287,5 +290,24 @@ int ldb_msg_find_duplicate_val(struct ldb_context *ldb,
const struct ldb_message_element *el,
struct ldb_val **duplicate,
uint32_t options);
/**
Check if a particular message will match the given filter
\param ldb an ldb context
\param msg the message to be checked
\param tree the filter tree to check against
\param scope the scope to match against
(to avoid matching special DNs except on a base search)
\param matched a pointer to a boolean set true if it matches,
false otherwise
returns LDB_SUCCESS or an error
\note this is a recursive function, and does short-circuit evaluation
*/
int ldb_match_message(struct ldb_context *ldb,
const struct ldb_message *msg,
const struct ldb_parse_tree *tree,
enum ldb_scope scope, bool *matched);
#endif
......@@ -36,7 +36,7 @@
#define LTDB_FLAG_CASE_INSENSITIVE (1<<0)
#define LTDB_FLAG_INTEGER (1<<1)
#define LTDB_FLAG_HIDDEN (1<<2)
#define LTDB_FLAG_UNIQUE_INDEX (1<<2)
/* valid attribute flags */
static const struct {
......@@ -45,7 +45,8 @@ static const struct {
} ltdb_valid_attr_flags[] = {
{ "CASE_INSENSITIVE", LTDB_FLAG_CASE_INSENSITIVE },
{ "INTEGER", LTDB_FLAG_INTEGER },
{ "HIDDEN", LTDB_FLAG_HIDDEN },
{ "HIDDEN", 0 },
{ "UNIQUE_INDEX", LTDB_FLAG_UNIQUE_INDEX},
{ "NONE", 0 },
{ NULL, 0 }
};
......@@ -150,7 +151,7 @@ static int ltdb_attributes_load(struct ldb_module *module)
/* mapping these flags onto ldap 'syntaxes' isn't strictly correct,
but its close enough for now */
for (i=0;i<attrs_msg->num_elements;i++) {
unsigned flags;
unsigned flags = 0, attr_flags = 0;
const char *syntax;
const struct ldb_schema_syntax *s;
const struct ldb_schema_attribute *a =
......@@ -167,17 +168,20 @@ static int ltdb_attributes_load(struct ldb_module *module)
attrs_msg->elements[i].name);
goto failed;
}
switch (flags & ~LTDB_FLAG_HIDDEN) {
case 0:
syntax = LDB_SYNTAX_OCTET_STRING;
break;
case LTDB_FLAG_CASE_INSENSITIVE:
if (flags & LTDB_FLAG_UNIQUE_INDEX) {
attr_flags = LDB_ATTR_FLAG_UNIQUE_INDEX;
}
flags &= ~LTDB_FLAG_UNIQUE_INDEX;
/* These are not currently flags, each is exclusive */
if (flags == LTDB_FLAG_CASE_INSENSITIVE) {
syntax = LDB_SYNTAX_DIRECTORY_STRING;
break;
case LTDB_FLAG_INTEGER:
} else if (flags == LTDB_FLAG_INTEGER) {
syntax = LDB_SYNTAX_INTEGER;
break;
default:
} else if (flags == 0) {
syntax = LDB_SYNTAX_OCTET_STRING;
} else {
ldb_debug(ldb, LDB_DEBUG_ERROR,
"Invalid flag combination 0x%x for '%s' "
"in @ATTRIBUTES",
......@@ -194,12 +198,12 @@ static int ltdb_attributes_load(struct ldb_module *module)
goto failed;
}
flags |= LDB_ATTR_FLAG_ALLOCATED | LDB_ATTR_FLAG_FROM_DB;
attr_flags |= LDB_ATTR_FLAG_ALLOCATED | LDB_ATTR_FLAG_FROM_DB;
r = ldb_schema_attribute_fill_with_syntax(ldb,
attrs,
attrs_msg->elements[i].name,
flags, s,
attr_flags, s,
&attrs[num_loaded_attrs + ldb->schema.num_attributes]);
if (r != 0) {
goto failed;
......@@ -243,6 +247,10 @@ static int ltdb_index_load(struct ldb_module *module,
*/
ltdb->cache->attribute_indexes = true;
ltdb->cache->one_level_indexes = ldb->schema.one_level_indexes;
ltdb->cache->GUID_index_attribute
= ldb->schema.GUID_index_attribute;
ltdb->cache->GUID_index_dn_component
= ldb->schema.GUID_index_dn_component;
return 0;
}
......@@ -276,6 +284,12 @@ static int ltdb_index_load(struct ldb_module *module,
if (ldb_msg_find_element(ltdb->cache->indexlist, LTDB_IDXATTR) != NULL) {
ltdb->cache->attribute_indexes = true;
}
ltdb->cache->GUID_index_attribute
= ldb_msg_find_attr_as_string(ltdb->cache->indexlist,
LTDB_IDXGUID, NULL);
ltdb->cache->GUID_index_dn_component
= ldb_msg_find_attr_as_string(ltdb->cache->indexlist,
LTDB_IDX_DN_GUID, NULL);
return 0;
}
......@@ -371,6 +385,7 @@ int ltdb_cache_load(struct ldb_module *module)
struct ldb_dn *baseinfo_dn = NULL, *options_dn = NULL;
uint64_t seq;
struct ldb_message *baseinfo = NULL, *options = NULL;
const struct ldb_schema_attribute *a;
int r;
ldb = ldb_module_get_ctx(module);
......@@ -474,6 +489,17 @@ int ltdb_cache_load(struct ldb_module *module)
goto failed;
}
ltdb->GUID_index_syntax = NULL;
if (ltdb->cache->GUID_index_attribute != NULL) {
/*
* Now the attributes are loaded, set the guid_index_syntax.
* This can't fail, it will return a default at worst
*/
a = ldb_schema_attribute_by_name(ldb,
ltdb->cache->GUID_index_attribute);
ltdb->GUID_index_syntax = a->syntax;
}
done:
talloc_free(options);
talloc_free(baseinfo);
......
This diff is collapsed.
......@@ -113,26 +113,61 @@ static int msg_add_distinguished_name(struct ldb_message *msg)
return LDB_ERR_NO_SUCH_OBJECT on record-not-found
and LDB_SUCCESS on success
*/
static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
int ltdb_search_base(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
struct ldb_dn *dn,
struct ldb_dn **ret_dn)
{
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
TDB_DATA tdb_key;
int exists;
int ret;
struct ldb_message *msg = NULL;
if (ldb_dn_is_null(dn)) {
return LDB_ERR_NO_SUCH_OBJECT;
}
/* form the key */
tdb_key = ltdb_key(module, dn);
if (!tdb_key.dptr) {
/*
* We can't use tdb_exists() directly on a key when the TDB
* key is the GUID one, not the DN based one. So we just do a
* normal search and avoid most of the allocation with the
* LDB_UNPACK_DATA_FLAG_NO_DN and
* LDB_UNPACK_DATA_FLAG_NO_ATTRS flags
*/
msg = ldb_msg_new(module);
if (msg == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
exists = tdb_exists(ltdb->tdb, tdb_key);
talloc_free(tdb_key.dptr);
ret = ltdb_search_dn1(module, dn,
msg,
LDB_UNPACK_DATA_FLAG_NO_ATTRS);
if (ret == LDB_SUCCESS) {
const char *dn_linearized
= ldb_dn_get_linearized(dn);
const char *msg_dn_linearlized
= ldb_dn_get_linearized(msg->dn);
if (strcmp(dn_linearized, msg_dn_linearlized) == 0) {
/*
* Re-use the full incoming DN for
* subtree checks
*/
*ret_dn = dn;
} else {
/*
* Use the string DN from the unpack, so that
* we have a case-exact match of the base
*/
*ret_dn = talloc_steal(mem_ctx, msg->dn);
}
exists = true;
} else if (ret == LDB_ERR_NO_SUCH_OBJECT) {
exists = false;
} else {
talloc_free(msg);
return ret;
}
talloc_free(msg);
if (exists) {
return LDB_SUCCESS;
}
......@@ -200,25 +235,18 @@ static int ltdb_parse_data_unpack(TDB_DATA key, TDB_DATA data,
return LDB_ERR_NO_SUCH_OBJECT on record-not-found
and LDB_SUCCESS on success
*/
int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg,
int ltdb_search_key(struct ldb_module *module, struct ltdb_private *ltdb,
const struct TDB_DATA tdb_key,
struct ldb_message *msg,
unsigned int unpack_flags)
{
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
TDB_DATA tdb_key;
struct ltdb_parse_data_unpack_ctx ctx = {
.msg = msg,
.module = module,
.unpack_flags = unpack_flags
};
/* form the key */
tdb_key = ltdb_key(module, dn);
if (!tdb_key.dptr) {
return LDB_ERR_OPERATIONS_ERROR;
}
memset(msg, 0, sizeof(*msg));
msg->num_elements = 0;
......@@ -226,17 +254,92 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes
ret = tdb_parse_record(ltdb->tdb, tdb_key,
ltdb_parse_data_unpack, &ctx);
talloc_free(tdb_key.dptr);
if (ret == -1) {
if (tdb_error(ltdb->tdb) == TDB_ERR_NOEXIST) {
return LDB_ERR_NO_SUCH_OBJECT;
ret = ltdb_err_map(tdb_error(ltdb->tdb));
if (ret == LDB_SUCCESS) {
/*
* Just to be sure we don't turn errors
* into success
*/
return LDB_ERR_OPERATIONS_ERROR;
}
return LDB_ERR_OPERATIONS_ERROR;
return ret;
} else if (ret != LDB_SUCCESS) {
return ret;
}
return LDB_SUCCESS;
}
/*
search the database for a single simple dn, returning all attributes
in a single message
return LDB_ERR_NO_SUCH_OBJECT on record-not-found
and LDB_SUCCESS on success
*/
int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg,
unsigned int unpack_flags)
{
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
uint8_t guid_key[LTDB_GUID_KEY_SIZE];
TDB_DATA tdb_key = {
.dptr = guid_key,
.dsize = sizeof(guid_key)
};
TALLOC_CTX *tdb_key_ctx = NULL;
if (ltdb->cache->GUID_index_attribute == NULL) {
tdb_key_ctx = talloc_new(msg);
if (!tdb_key_ctx) {
return ldb_module_oom(module);
}
/* form the key */
tdb_key = ltdb_key_dn(module, tdb_key_ctx, dn);
if (!tdb_key.dptr) {
TALLOC_FREE(tdb_key_ctx);
return LDB_ERR_OPERATIONS_ERROR;
}
} else if (ldb_dn_is_special(dn)) {
tdb_key_ctx = talloc_new(msg);
if (!tdb_key_ctx) {
return ldb_module_oom(module);
}
/* form the key */
tdb_key = ltdb_key_dn(module, tdb_key_ctx, dn);
if (!tdb_key.dptr) {
TALLOC_FREE(tdb_key_ctx);
return LDB_ERR_OPERATIONS_ERROR;
}
} else {
/*
* Look in the index to find the key for this DN.
*
* the tdb_key memory is allocated above, msg is just
* used for internal memory.
*