Commit a8a37bd5 authored by Mathieu Parent's avatar Mathieu Parent

Updated version 2:1.1.27 from 'upstream/2%1.1.27'

with Debian dir b5c9ec3a87bb391807618a3eca119240509dd119
parents 1c5e2b34 6461ad6d
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 **)
......@@ -725,6 +725,7 @@ int main(void) {
if Options.options.picky_developer:
conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Werror -Wno-error=deprecated-declarations', testflags=True)
conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Wno-error=tautological-compare', testflags=True)
if Options.options.fatal_errors:
conf.ADD_CFLAGS('-Wfatal-errors', testflags=True)
......
......@@ -402,6 +402,22 @@ def configure(conf):
addmain=False,
msg='Checking for library destructor support')
conf.CHECK_CODE('''
void test_attribute(void) __attribute__ (());
void test_attribute(void)
{
return;
}
int main(void) {
return 0;
}
''',
'HAVE___ATTRIBUTE__',
addmain=False,
msg='Checking for __attribute__')
if sys.platform.startswith('aix'):
conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
# Might not be needed if ALL_SOURCE is defined
......
......@@ -284,15 +284,17 @@ void ldb_set_errstring(struct ldb_context *ldb, const char *err_string)
void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...)
{
va_list ap;
char *old_err_string = NULL;
if (ldb->err_string) {
talloc_free(ldb->err_string);
old_err_string = ldb->err_string;
}
va_start(ap, format);
ldb->err_string = talloc_vasprintf(ldb, format, ap);
va_end(ap);
TALLOC_FREE(old_err_string);
if (ldb->flags & LDB_FLG_ENABLE_TRACING) {
ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_asprintf/set_errstring: %s",
ldb->err_string);
......@@ -594,7 +596,9 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
if ((handle->status != LDB_SUCCESS) &&
(handle->ldb->err_string == NULL)) {
/* if no error string was setup by the backend */
ldb_asprintf_errstring(handle->ldb, "ldb_wait: %s (%d)",
ldb_asprintf_errstring(handle->ldb,
"ldb_wait from %s with LDB_ASYNC_DONE: %s (%d)",
handle->location,
ldb_strerror(handle->status),
handle->status);
}
......@@ -612,19 +616,21 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
if (ret != 0) {
return ldb_operr(handle->ldb);
}
if (handle->status != LDB_SUCCESS) {
if (handle->ldb->err_string == NULL) {
/*
* if no error string was setup by the backend
*/
ldb_asprintf_errstring(handle->ldb,
"ldb_wait: %s (%d)",
ldb_strerror(handle->status),
handle->status);
}
if (handle->status == LDB_SUCCESS) {
return LDB_SUCCESS;
}
if (handle->ldb->err_string != NULL) {
return handle->status;
}
break;
/*
* if no error string was setup by the backend
*/
ldb_asprintf_errstring(handle->ldb,
"ldb_wait from %s with LDB_WAIT_NONE: %s (%d)",
handle->location,
ldb_strerror(handle->status),
handle->status);
return handle->status;
case LDB_WAIT_ALL:
while (handle->state != LDB_ASYNC_DONE) {
......@@ -633,32 +639,38 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
return ldb_operr(handle->ldb);
}
if (handle->status != LDB_SUCCESS) {
if (handle->ldb->err_string == NULL) {
/*
* if no error string was setup by the
* backend
*/
ldb_asprintf_errstring(handle->ldb,
"ldb_wait: %s (%d)",
ldb_strerror(handle->status),
handle->status);
if (handle->ldb->err_string != NULL) {
return handle->status;
}
return handle->status;
}
}
if (handle->status != LDB_SUCCESS) {
if (handle->ldb->err_string == NULL) {
/*
* if no error string was setup by the backend
* if no error string was setup by the
* backend
*/
ldb_asprintf_errstring(handle->ldb,
"ldb_wait: %s (%d)",
"ldb_wait from %s with "
"LDB_WAIT_ALL: %s (%d)",
handle->location,
ldb_strerror(handle->status),
handle->status);
return handle->status;
}
}
if (handle->status == LDB_SUCCESS) {
return LDB_SUCCESS;
}
if (handle->ldb->err_string != NULL) {
return handle->status;
}
break;
/*
* if no error string was setup by the backend
*/
ldb_asprintf_errstring(handle->ldb,
"ldb_wait from %s with LDB_WAIT_ALL,"
" LDB_ASYNC_DONE: %s (%d)",
handle->location,
ldb_strerror(handle->status),
handle->status);
return handle->status;
}
return LDB_SUCCESS;
......
This diff is collapsed.
......@@ -54,7 +54,7 @@ struct ldb_dn_component {
struct ldb_dn_ext_component {
char *name;
const char *name;
struct ldb_val value;
};
......@@ -171,7 +171,7 @@ struct ldb_dn *ldb_dn_new_fmt(TALLOC_CTX *mem_ctx,
char *strdn;
va_list ap;
if ( (! mem_ctx) || (! ldb)) return NULL;
if (! ldb) return NULL;
va_start(ap, new_fmt);
strdn = talloc_vasprintf(mem_ctx, new_fmt, ap);
......@@ -408,11 +408,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
goto failed;
}
dn->ext_components[dn->ext_comp_num].name = talloc_strdup(dn->ext_components, ex_name);
if (!dn->ext_components[dn->ext_comp_num].name) {
/* ouch */
goto failed;
}
dn->ext_components[dn->ext_comp_num].name = ext_syntax->name;
ret = ext_syntax->read_fn(dn->ldb, dn->ext_components,
&ex_val, &dn->ext_components[dn->ext_comp_num].value);
if (ret != LDB_SUCCESS) {
......@@ -1990,12 +1986,14 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
struct ldb_dn_ext_component *p;
unsigned int i;
struct ldb_val v2;
const struct ldb_dn_extended_syntax *ext_syntax;
if ( ! ldb_dn_validate(dn)) {
return LDB_ERR_OTHER;
}
if (!ldb_dn_extended_syntax_by_name(dn->ldb, name)) {
ext_syntax = ldb_dn_extended_syntax_by_name(dn->ldb, name);
if (ext_syntax == NULL) {
/* We don't know how to handle this type of thing */
return LDB_ERR_INVALID_DN_SYNTAX;
}
......@@ -2006,10 +2004,8 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
dn->ext_components[i].value =
ldb_val_dup(dn->ext_components, val);
dn->ext_components[i].name =
talloc_strdup(dn->ext_components, name);
if (!dn->ext_components[i].name ||
!dn->ext_components[i].value.data) {
dn->ext_components[i].name = ext_syntax->name;
if (!dn->ext_components[i].value.data) {
ldb_dn_mark_invalid(dn);
return LDB_ERR_OPERATIONS_ERROR;
}
......@@ -2170,7 +2166,6 @@ bool ldb_dn_minimise(struct ldb_dn *dn)
*/
for (i = 1; i < dn->ext_comp_num; i++) {
LDB_FREE(dn->ext_components[i].name);
LDB_FREE(dn->ext_components[i].value.data);
}
dn->ext_comp_num = 1;
......
......@@ -211,20 +211,20 @@ static bool ldb_consume_element_data(uint8_t **pp, size_t *premaining)
return true;
}
/*
* Unpack a ldb message from a linear buffer in ldb_val
*
* Providing a list of attributes to this function allows selective unpacking.
* Giving a NULL list (or a list_size of 0) unpacks all the attributes.
*
* Free with ldb_unpack_data_free()
*/
int ldb_unpack_data_only_attr_list(struct ldb_context *ldb,
const struct ldb_val *data,
struct ldb_message *message,
const char * const *list,
unsigned int list_size,
unsigned int *nb_elements_in_db)
int ldb_unpack_data_only_attr_list_flags(struct ldb_context *ldb,
const struct ldb_val *data,
struct ldb_message *message,
const char * const *list,
unsigned int list_size,
unsigned int flags,
unsigned int *nb_elements_in_db)
{
uint8_t *p;
size_t remaining;
......@@ -271,10 +271,14 @@ int ldb_unpack_data_only_attr_list(struct ldb_context *ldb,
errno = EIO;
goto failed;
}
message->dn = ldb_dn_new(message, ldb, (char *)p);
if (message->dn == NULL) {
errno = ENOMEM;
goto failed;
if (flags & LDB_UNPACK_DATA_FLAG_NO_DN) {
message->dn = NULL;
} else {
message->dn = ldb_dn_new(message, ldb, (char *)p);
if (message->dn == NULL) {
errno = ENOMEM;
goto failed;
}
}
/*
* Redundant: by definition, remaining must be more
......@@ -373,11 +377,15 @@ int ldb_unpack_data_only_attr_list(struct ldb_context *ldb,
}
}
element = &message->elements[nelem];
element->name = talloc_memdup(message->elements, attr, attr_len+1);
if (flags & LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC) {
element->name = attr;
} else {
element->name = talloc_memdup(message->elements, attr, attr_len+1);
if (element->name == NULL) {
errno = ENOMEM;
goto failed;
if (element->name == NULL) {
errno = ENOMEM;
goto failed;
}
}
element->flags = 0;
......@@ -422,15 +430,18 @@ int ldb_unpack_data_only_attr_list(struct ldb_context *ldb,
}
element->values[j].length = len;
element->values[j].data = talloc_size(element->values, len+1);
if (element->values[j].data == NULL) {
errno = ENOMEM;
goto failed;
if (flags & LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC) {
element->values[j].data = p + 4;
} else {
element->values[j].data = talloc_size(element->values, len+1);
if (element->values[j].data == NULL) {
errno = ENOMEM;
goto failed;
}
memcpy(element->values[j].data, p + 4,
len);
element->values[j].data[len] = 0;
}
memcpy(element->values[j].data, p + 4,
len);
element->values[j].data[len] = 0;
remaining -= len;
p += len+4+1;
}
......@@ -463,6 +474,30 @@ failed:
return -1;
}
/*
* Unpack a ldb message from a linear buffer in ldb_val
*
* Providing a list of attributes to this function allows selective unpacking.
* Giving a NULL list (or a list_size of 0) unpacks all the attributes.
*
* Free with ldb_unpack_data_free()
*/
int ldb_unpack_data_only_attr_list(struct ldb_context *ldb,
const struct ldb_val *data,
struct ldb_message *message,
const char * const *list,
unsigned int list_size,
unsigned int *nb_elements_in_db)
{
return ldb_unpack_data_only_attr_list_flags(ldb,
data,
message,
list,
list_size,
0,
nb_elements_in_db);
}
int ldb_unpack_data(struct ldb_context *ldb,
const struct ldb_val *data,
struct ldb_message *message)
......
......@@ -849,7 +849,7 @@ struct ldb_vlv_req_control {
} gtOrEq;
} match;
int ctxid_len;
char *contextId;
uint8_t *contextId;
};
struct ldb_vlv_resp_control {
......@@ -857,7 +857,7 @@ struct ldb_vlv_resp_control {
int contentCount;
int vlv_result;
int ctxid_len;
char *contextId;
uint8_t *contextId;
};
struct ldb_verify_name_control {
......
......@@ -390,6 +390,12 @@ int ldb_register_extended_match_rule(struct ldb_context *ldb,
int ldb_pack_data(struct ldb_context *ldb,
const struct ldb_message *message,
struct ldb_val *data);
/*
* Unpack a ldb message from a linear buffer in ldb_val
*
* Providing a list of attributes to this function allows selective unpacking.
* Giving a NULL list (or a list_size of 0) unpacks all the attributes.
*/
int ldb_unpack_data_only_attr_list(struct ldb_context *ldb,
const struct ldb_val *data,
struct ldb_message *message,
......@@ -399,5 +405,27 @@ int ldb_unpack_data_only_attr_list(struct ldb_context *ldb,
int ldb_unpack_data(struct ldb_context *ldb,
const struct ldb_val *data,
struct ldb_message *message);
/*
* Unpack a ldb message from a linear buffer in ldb_val
*
* Providing a list of attributes to this function allows selective unpacking.
* Giving a NULL list (or a list_size of 0) unpacks all the attributes.
*
* Flags allow control of allocation, so that if
* LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC is specified, then values are
* not allocate, instead they point into the supplier constant buffer.
*
* Likewise if LDB_UNPACK_DATA_FLAG_NO_DN is specified, the DN is omitted.
*/
int ldb_unpack_data_only_attr_list_flags(struct ldb_context *ldb,
const struct ldb_val *data,
struct ldb_message *message,
const char * const *list,
unsigned int list_size,
unsigned int flags,
unsigned int *nb_elements_in_db);
#define LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC 0x0001
#define LDB_UNPACK_DATA_FLAG_NO_DN 0x0002
#endif
......@@ -727,6 +727,7 @@ static void map_objectclass_generate_remote(struct ldb_module *module, const cha
struct ldb_val val;
bool found_extensibleObject = false;
unsigned int i;
int ret;
ldb = ldb_module_get_ctx(module);
......@@ -774,7 +775,11 @@ static void map_objectclass_generate_remote(struct ldb_module *module, const cha
}
/* Add new objectClass to remote message */
ldb_msg_add(remote, el, 0);
ret = ldb_msg_add(remote, el, 0);
if (ret != LDB_SUCCESS) {
ldb_oom(ldb);
return;
}
}
/* Map an objectClass into the local partition. */
......
......@@ -126,7 +126,7 @@ static int ltdb_attributes_load(struct ldb_module *module)
dn = ldb_dn_new(module, ldb, LTDB_ATTRIBUTES);
if (dn == NULL) goto failed;
r = ltdb_search_dn1(module, dn, msg);
r = ltdb_search_dn1(module, dn, msg, 0);
talloc_free(dn);
if (r != LDB_SUCCESS && r != LDB_ERR_NO_SUCH_OBJECT) {
goto failed;
......@@ -301,7 +301,7 @@ int ltdb_cache_load(struct ldb_module *module)
baseinfo_dn = ldb_dn_new(baseinfo, ldb, LTDB_BASEINFO);
if (baseinfo_dn == NULL) goto failed;
r= ltdb_search_dn1(module, baseinfo_dn, baseinfo);
r= ltdb_search_dn1(module, baseinfo_dn, baseinfo, 0);
if (r != LDB_SUCCESS && r != LDB_ERR_NO_SUCH_OBJECT) {
goto failed;
}
......@@ -319,7 +319,7 @@ int ltdb_cache_load(struct ldb_module *module)
tdb_transaction_commit(ltdb->tdb);
if (ltdb_search_dn1(module, baseinfo_dn, baseinfo) != LDB_SUCCESS) {
if (ltdb_search_dn1(module, baseinfo_dn, baseinfo, 0) != LDB_SUCCESS) {
goto failed;
}
}
......@@ -341,7 +341,7 @@ int ltdb_cache_load(struct ldb_module *module)
options_dn = ldb_dn_new(options, ldb, LTDB_OPTIONS);
if (options_dn == NULL) goto failed;
r= ltdb_search_dn1(module, options_dn, options);
r= ltdb_search_dn1(module, options_dn, options, 0);
if (r != LDB_SUCCESS && r != LDB_ERR_NO_SUCH_OBJECT) {
goto failed;
}
......@@ -374,7 +374,7 @@ int ltdb_cache_load(struct ldb_module *module)
indexlist_dn = ldb_dn_new(module, ldb, LTDB_INDEXLIST);
if (indexlist_dn == NULL) goto failed;
r = ltdb_search_dn1(module, indexlist_dn, ltdb->cache->indexlist);
r = ltdb_search_dn1(module, indexlist_dn, ltdb->cache->indexlist, 0);
if (r != LDB_SUCCESS && r != LDB_ERR_NO_SUCH_OBJECT) {
goto failed;
}
......
This diff is collapsed.
......@@ -238,16 +238,50 @@ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
struct ltdb_parse_data_unpack_ctx {
struct ldb_message *msg;
struct ldb_module *module;
unsigned int unpack_flags;
};
static int ltdb_parse_data_unpack(TDB_DATA key, TDB_DATA data,
void *private_data)
{
struct ltdb_parse_data_unpack_ctx *ctx = private_data;
unsigned int nb_elements_in_db;
int ret;
struct ldb_context *ldb = ldb_module_get_ctx(ctx->module);
int ret = ldb_unpack_data(ldb, (struct ldb_val *)&data, ctx->msg);
struct ldb_val data_parse = {
.data = data.dptr,
.length = data.dsize
};
if (ctx->unpack_flags & LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC) {
/*
* If we got LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC
* we need at least do a memdup on the whole
* data buffer as that may change later
* and the caller needs a stable result.
*/
data_parse.data = talloc_memdup(ctx->msg,
data.dptr,
data.dsize);
if (data_parse.data == NULL) {
ldb_debug(ldb, LDB_DEBUG_ERROR,
"Unable to allocate data(%d) for %*.*s\n",
(int)data.dsize,
(int)key.dsize, (int)key.dsize, key.dptr);
return LDB_ERR_OPERATIONS_ERROR;
}
}
ret = ldb_unpack_data_only_attr_list_flags(ldb, &data_parse,
ctx->msg,
NULL, 0,
ctx->unpack_flags,
&nb_elements_in_db);
if (ret == -1) {
if (data_parse.data != data.dptr) {
talloc_free(data_parse.data);
}
ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid data for index %*.*s\n",
(int)key.dsize, (int)key.dsize, key.dptr);
return LDB_ERR_OPERATIONS_ERROR;
......@@ -262,7 +296,8 @@ 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_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);
......@@ -270,7 +305,8 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes
TDB_DATA tdb_key;
struct ltdb_parse_data_unpack_ctx ctx = {
.msg = msg,
.module = module
.module = module,
.unpack_flags = unpack_flags
};
/* form the key */
......@@ -296,12 +332,14 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes
} else if (ret != LDB_SUCCESS) {
return ret;
}
if (!msg->dn) {
msg->dn = ldb_dn_copy(msg, dn);
}
if (!msg->dn) {
return LDB_ERR_OPERATIONS_ERROR;
if ((unpack_flags & LDB_UNPACK_DATA_FLAG_NO_DN) == 0) {
if (!msg->dn) {
msg->dn = ldb_dn_copy(msg, dn);
}
if (!msg->dn) {
return LDB_ERR_OPERATIONS_ERROR;
}
}
return LDB_SUCCESS;
......@@ -432,6 +470,10 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
struct ldb_context *ldb;
struct ltdb_context *ac;
struct ldb_message *msg;
const struct ldb_val val = {
.data = data.dptr,
.length = data.dsize,
};
int ret;
bool matched;
......@@ -450,7 +492,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
}
/* unpack the record */
ret = ldb_unpack_data(ldb, (struct ldb_val *)&data, msg);
ret = ldb_unpack_data(ldb, &val, msg);
if (ret == -1) {
talloc_free(msg);
ac->error = LDB_ERR_OPERATIONS_ERROR;
......
......@@ -449,7 +449,7 @@ static int ltdb_delete_internal(struct ldb_module *module, struct ldb_dn *dn)
/* in case any attribute of the message was indexed, we need
to fetch the old record */
ret = ltdb_search_dn1(module, dn, msg);
ret = ltdb_search_dn1(module, dn, msg, LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC);
if (ret != LDB_SUCCESS) {
/* not finding the old record is an error */
goto done;
......@@ -858,14 +858,22 @@ int ltdb_modify_internal(struct ldb_module *module,
goto done;
}
/* TODO: This is O(n^2) - replace with more efficient check */
for (j=0; j<el->num_values; j++) {
if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
ldb_asprintf_errstring(ldb,
"attribute '%s': value #%u on '%s' provided more than once",
el->name, j, ldb_dn_get_linearized(msg2->dn));
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto done;
/*
* We don't need to check this if we have been
* pre-screened by the repl_meta_data module
* in Samba, or someone else who can claim to
* know what they are doing.
*/
if (!(el->flags & LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK)) {
/* TODO: This is O(n^2) - replace with more efficient check */
for (j=0; j<el->num_values; j++) {
if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
ldb_asprintf_errstring(ldb,
"attribute '%s': value #%u on '%s' provided more than once",
el->name, j, ldb_dn_get_linearized(msg2->dn));
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto done;
}
}
}
......@@ -1025,7 +1033,8 @@ static int ltdb_rename(struct ltdb_context *ctx)
}
/* we need to fetch the old record to re-add under the new name */
ret = ltdb_search_dn1(module, req->op.rename.olddn, msg);
ret = ltdb_search_dn1(module, req->op.rename.olddn, msg,
LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC);
if (ret != LDB_SUCCESS) {
/* not finding the old record is an error */
return ret;
......@@ -1054,7 +1063,7 @@ static int ltdb_rename(struct ltdb_context *ctx)
talloc_free(tdb_key.dptr);
ldb_asprintf_errstring(ldb_module_get_ctx(module),
"Entry %s already exists",
ldb_dn_get_linearized(msg->dn));
ldb_dn_get_linearized(req->op.rename.newdn));
/* finding the new record already in the DB is an error */
talloc_free(msg);
return LDB_ERR_ENTRY_ALREADY_EXISTS;
......@@ -1224,7 +1233,7 @@ static int ltdb_sequence_number(struct ltdb_context *ctx,
goto done;
}
ret = ltdb_search_dn1(module, dn, msg);
ret = ltdb_search_dn1(module, dn, msg, 0);
if (ret != LDB_SUCCESS) {
goto done;
}
......
......@@ -101,7 +101,8 @@ int ltdb_index_transaction_cancel(struct ldb_module *module);
int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name,
const struct ldb_val *val);
void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg);
int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg,
unsigned int unpack_flags);
int ltdb_add_attr_results(struct ldb_module *module,
TALLOC_CTX *mem_ctx,
struct ldb_message *msg,
......
<
/*
* Unix SMB/CIFS implementation.
* Samba utility functions
* Copyright (C) Volker Lendecke 2016
*
* ** NOTE! The following LGPL license applies to the replace
* ** 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
* Library 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 "replace.h"
#include <dirent.h>
#include <unistd.h>
#include <limits.h>
static int closefrom_sysconf(int lower)
{
long max_files, fd;
max_files = sysconf(_SC_OPEN_MAX);
if (max_files == -1) {
max_files = 65536;
}
for (fd=lower; fd<max_files; fd++) {
close(fd);
}
return 0;
}
static int closefrom_procfs(int lower)
{
DIR *dirp;
int dir_fd;
struct dirent *dp;