mirror of
https://github.com/samba-team/samba.git
synced 2025-02-19 21:57:57 +03:00
Cleanup,
Remove trailing spaces and try to fit 80 columns where possible (This used to be commit edf6b77a1314d8f91839836855ae049393f73aca)
This commit is contained in:
parent
21943bf0af
commit
4d8804f26c
@ -1,15 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
ldb database library
|
ldb database library
|
||||||
|
|
||||||
Copyright (C) Andrew Tridgell 2004
|
Copyright (C) Andrew Tridgell 2004
|
||||||
Copyright (C) Stefan Metzmacher 2004
|
Copyright (C) Stefan Metzmacher 2004
|
||||||
Copyright (C) Simo Sorce 2006
|
Copyright (C) Simo Sorce 2006
|
||||||
|
|
||||||
|
|
||||||
** NOTE! The following LGPL license applies to the ldb
|
** NOTE! The following LGPL license applies to the ldb
|
||||||
** library. This does NOT imply that all of Samba is released
|
** library. This does NOT imply that all of Samba is released
|
||||||
** under the LGPL
|
** under the LGPL
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
@ -76,7 +76,8 @@ static int ltdb_err_map(enum TDB_ERROR tdb_code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module,
|
struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb,
|
||||||
|
struct ldb_module *module,
|
||||||
struct ldb_request *req)
|
struct ldb_request *req)
|
||||||
{
|
{
|
||||||
struct ltdb_context *ac;
|
struct ltdb_context *ac;
|
||||||
@ -113,7 +114,7 @@ struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module
|
|||||||
form a TDB_DATA for a record key
|
form a TDB_DATA for a record key
|
||||||
caller frees
|
caller frees
|
||||||
|
|
||||||
note that the key for a record can depend on whether the
|
note that the key for a record can depend on whether the
|
||||||
dn refers to a case sensitive index record or not
|
dn refers to a case sensitive index record or not
|
||||||
*/
|
*/
|
||||||
struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn)
|
struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn)
|
||||||
@ -131,8 +132,8 @@ struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn)
|
|||||||
|
|
||||||
1) if the dn doesn't start with @ then uppercase the attribute
|
1) if the dn doesn't start with @ then uppercase the attribute
|
||||||
names and the attributes values of case insensitive attributes
|
names and the attributes values of case insensitive attributes
|
||||||
2) if the dn starts with @ then leave it alone - the indexing code handles
|
2) if the dn starts with @ then leave it alone -
|
||||||
the rest
|
the indexing code handles the rest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dn_folded = ldb_dn_get_casefold(dn);
|
dn_folded = ldb_dn_get_casefold(dn);
|
||||||
@ -166,10 +167,11 @@ failed:
|
|||||||
check special dn's have valid attributes
|
check special dn's have valid attributes
|
||||||
currently only @ATTRIBUTES is checked
|
currently only @ATTRIBUTES is checked
|
||||||
*/
|
*/
|
||||||
int ltdb_check_special_dn(struct ldb_module *module, const struct ldb_message *msg)
|
int ltdb_check_special_dn(struct ldb_module *module,
|
||||||
|
const struct ldb_message *msg)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if (! ldb_dn_is_special(msg->dn) ||
|
if (! ldb_dn_is_special(msg->dn) ||
|
||||||
! ldb_dn_check_special(msg->dn, LTDB_ATTRIBUTES)) {
|
! ldb_dn_check_special(msg->dn, LTDB_ATTRIBUTES)) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -191,7 +193,7 @@ int ltdb_check_special_dn(struct ldb_module *module, const struct ldb_message *m
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
we've made a modification to a dn - possibly reindex and
|
we've made a modification to a dn - possibly reindex and
|
||||||
update sequence number
|
update sequence number
|
||||||
*/
|
*/
|
||||||
static int ltdb_modified(struct ldb_module *module, struct ldb_dn *dn)
|
static int ltdb_modified(struct ldb_module *module, struct ldb_dn *dn)
|
||||||
@ -239,7 +241,7 @@ int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flg
|
|||||||
ret = ltdb_err_map(tdb_error(ltdb->tdb));
|
ret = ltdb_err_map(tdb_error(ltdb->tdb));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ltdb_index_add(module, msg);
|
ret = ltdb_index_add(module, msg);
|
||||||
if (ret != LDB_SUCCESS) {
|
if (ret != LDB_SUCCESS) {
|
||||||
tdb_delete(ltdb->tdb, tdb_key);
|
tdb_delete(ltdb->tdb, tdb_key);
|
||||||
@ -253,15 +255,16 @@ done:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message *msg)
|
static int ltdb_add_internal(struct ldb_module *module,
|
||||||
|
const struct ldb_message *msg)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = ltdb_check_special_dn(module, msg);
|
ret = ltdb_check_special_dn(module, msg);
|
||||||
if (ret != LDB_SUCCESS) {
|
if (ret != LDB_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ltdb_cache_load(module) != 0) {
|
if (ltdb_cache_load(module) != 0) {
|
||||||
return LDB_ERR_OPERATIONS_ERROR;
|
return LDB_ERR_OPERATIONS_ERROR;
|
||||||
}
|
}
|
||||||
@ -269,10 +272,12 @@ static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message
|
|||||||
ret = ltdb_store(module, msg, TDB_INSERT);
|
ret = ltdb_store(module, msg, TDB_INSERT);
|
||||||
|
|
||||||
if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
|
if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
|
||||||
ldb_asprintf_errstring(module->ldb, "Entry %s already exists", ldb_dn_get_linearized(msg->dn));
|
ldb_asprintf_errstring(module->ldb,
|
||||||
|
"Entry %s already exists",
|
||||||
|
ldb_dn_get_linearized(msg->dn));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == LDB_SUCCESS) {
|
if (ret == LDB_SUCCESS) {
|
||||||
ret = ltdb_index_one(module, msg, 1);
|
ret = ltdb_index_one(module, msg, 1);
|
||||||
if (ret != LDB_SUCCESS) {
|
if (ret != LDB_SUCCESS) {
|
||||||
@ -293,14 +298,16 @@ static int ltdb_add_internal(struct ldb_module *module, const struct ldb_message
|
|||||||
*/
|
*/
|
||||||
static int ltdb_add(struct ldb_module *module, struct ldb_request *req)
|
static int ltdb_add(struct ldb_module *module, struct ldb_request *req)
|
||||||
{
|
{
|
||||||
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
|
struct ltdb_private *ltdb;
|
||||||
struct ltdb_context *ltdb_ac;
|
struct ltdb_context *ltdb_ac;
|
||||||
int tret, ret = LDB_SUCCESS;
|
int tret, ret = LDB_SUCCESS;
|
||||||
|
|
||||||
|
ltdb = talloc_get_type(module->private_data, struct ltdb_private);
|
||||||
|
|
||||||
if (check_critical_controls(req->controls)) {
|
if (check_critical_controls(req->controls)) {
|
||||||
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
|
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->handle = init_ltdb_handle(ltdb, module, req);
|
req->handle = init_ltdb_handle(ltdb, module, req);
|
||||||
if (req->handle == NULL) {
|
if (req->handle == NULL) {
|
||||||
return LDB_ERR_OPERATIONS_ERROR;
|
return LDB_ERR_OPERATIONS_ERROR;
|
||||||
@ -312,7 +319,7 @@ static int ltdb_add(struct ldb_module *module, struct ldb_request *req)
|
|||||||
req->handle->status = tret;
|
req->handle->status = tret;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ltdb_ac->callback) {
|
if (ltdb_ac->callback) {
|
||||||
ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
|
ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
|
||||||
}
|
}
|
||||||
@ -397,14 +404,16 @@ done:
|
|||||||
*/
|
*/
|
||||||
static int ltdb_delete(struct ldb_module *module, struct ldb_request *req)
|
static int ltdb_delete(struct ldb_module *module, struct ldb_request *req)
|
||||||
{
|
{
|
||||||
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
|
struct ltdb_private *ltdb;
|
||||||
struct ltdb_context *ltdb_ac;
|
struct ltdb_context *ltdb_ac;
|
||||||
int tret, ret = LDB_SUCCESS;
|
int tret, ret = LDB_SUCCESS;
|
||||||
|
|
||||||
|
ltdb = talloc_get_type(module->private_data, struct ltdb_private);
|
||||||
|
|
||||||
if (check_critical_controls(req->controls)) {
|
if (check_critical_controls(req->controls)) {
|
||||||
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
|
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->handle = NULL;
|
req->handle = NULL;
|
||||||
|
|
||||||
if (ltdb_cache_load(module) != 0) {
|
if (ltdb_cache_load(module) != 0) {
|
||||||
@ -419,7 +428,7 @@ static int ltdb_delete(struct ldb_module *module, struct ldb_request *req)
|
|||||||
|
|
||||||
tret = ltdb_delete_internal(module, req->op.del.dn);
|
tret = ltdb_delete_internal(module, req->op.del.dn);
|
||||||
if (tret != LDB_SUCCESS) {
|
if (tret != LDB_SUCCESS) {
|
||||||
req->handle->status = tret;
|
req->handle->status = tret;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,9 +441,9 @@ done:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
find an element by attribute name. At the moment this does a linear search, it should
|
find an element by attribute name. At the moment this does a linear search,
|
||||||
be re-coded to use a binary search once all places that modify records guarantee
|
it should be re-coded to use a binary search once all places that modify
|
||||||
sorted order
|
records guarantee sorted order
|
||||||
|
|
||||||
return the index of the first matching element if found, otherwise -1
|
return the index of the first matching element if found, otherwise -1
|
||||||
*/
|
*/
|
||||||
@ -452,18 +461,19 @@ static int find_element(const struct ldb_message *msg, const char *name)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
add an element to an existing record. Assumes a elements array that we
|
add an element to an existing record. Assumes a elements array that we
|
||||||
can call re-alloc on, and assumed that we can re-use the data pointers from the
|
can call re-alloc on, and assumed that we can re-use the data pointers from
|
||||||
passed in additional values. Use with care!
|
the passed in additional values. Use with care!
|
||||||
|
|
||||||
returns 0 on success, -1 on failure (and sets errno)
|
returns 0 on success, -1 on failure (and sets errno)
|
||||||
*/
|
*/
|
||||||
static int msg_add_element(struct ldb_context *ldb,
|
static int msg_add_element(struct ldb_context *ldb,
|
||||||
struct ldb_message *msg, struct ldb_message_element *el)
|
struct ldb_message *msg,
|
||||||
|
struct ldb_message_element *el)
|
||||||
{
|
{
|
||||||
struct ldb_message_element *e2;
|
struct ldb_message_element *e2;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
e2 = talloc_realloc(msg, msg->elements, struct ldb_message_element,
|
e2 = talloc_realloc(msg, msg->elements, struct ldb_message_element,
|
||||||
msg->num_elements+1);
|
msg->num_elements+1);
|
||||||
if (!e2) {
|
if (!e2) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
@ -478,7 +488,8 @@ static int msg_add_element(struct ldb_context *ldb,
|
|||||||
e2->flags = el->flags;
|
e2->flags = el->flags;
|
||||||
e2->values = NULL;
|
e2->values = NULL;
|
||||||
if (el->num_values != 0) {
|
if (el->num_values != 0) {
|
||||||
e2->values = talloc_array(msg->elements, struct ldb_val, el->num_values);
|
e2->values = talloc_array(msg->elements,
|
||||||
|
struct ldb_val, el->num_values);
|
||||||
if (!e2->values) {
|
if (!e2->values) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return -1;
|
return -1;
|
||||||
@ -512,20 +523,21 @@ static int msg_delete_attribute(struct ldb_module *module,
|
|||||||
for (i=0;i<msg->num_elements;i++) {
|
for (i=0;i<msg->num_elements;i++) {
|
||||||
if (ldb_attr_cmp(msg->elements[i].name, name) == 0) {
|
if (ldb_attr_cmp(msg->elements[i].name, name) == 0) {
|
||||||
for (j=0;j<msg->elements[i].num_values;j++) {
|
for (j=0;j<msg->elements[i].num_values;j++) {
|
||||||
ltdb_index_del_value(module, dn, &msg->elements[i], j);
|
ltdb_index_del_value(module, dn,
|
||||||
|
&msg->elements[i], j);
|
||||||
}
|
}
|
||||||
talloc_free(msg->elements[i].values);
|
talloc_free(msg->elements[i].values);
|
||||||
if (msg->num_elements > (i+1)) {
|
if (msg->num_elements > (i+1)) {
|
||||||
memmove(&msg->elements[i],
|
memmove(&msg->elements[i],
|
||||||
&msg->elements[i+1],
|
&msg->elements[i+1],
|
||||||
sizeof(struct ldb_message_element)*
|
sizeof(struct ldb_message_element)*
|
||||||
(msg->num_elements - (i+1)));
|
(msg->num_elements - (i+1)));
|
||||||
}
|
}
|
||||||
msg->num_elements--;
|
msg->num_elements--;
|
||||||
i--;
|
i--;
|
||||||
msg->elements = talloc_realloc(msg, msg->elements,
|
msg->elements = talloc_realloc(msg, msg->elements,
|
||||||
struct ldb_message_element,
|
struct ldb_message_element,
|
||||||
msg->num_elements);
|
msg->num_elements);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,12 +545,12 @@ static int msg_delete_attribute(struct ldb_module *module,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
delete all elements matching an attribute name/value
|
delete all elements matching an attribute name/value
|
||||||
|
|
||||||
return 0 on success, -1 on failure
|
return 0 on success, -1 on failure
|
||||||
*/
|
*/
|
||||||
static int msg_delete_element(struct ldb_module *module,
|
static int msg_delete_element(struct ldb_module *module,
|
||||||
struct ldb_message *msg,
|
struct ldb_message *msg,
|
||||||
const char *name,
|
const char *name,
|
||||||
const struct ldb_val *val)
|
const struct ldb_val *val)
|
||||||
{
|
{
|
||||||
@ -558,14 +570,17 @@ static int msg_delete_element(struct ldb_module *module,
|
|||||||
a = ldb_schema_attribute_by_name(ldb, el->name);
|
a = ldb_schema_attribute_by_name(ldb, el->name);
|
||||||
|
|
||||||
for (i=0;i<el->num_values;i++) {
|
for (i=0;i<el->num_values;i++) {
|
||||||
if (a->syntax->comparison_fn(ldb, ldb, &el->values[i], val) == 0) {
|
if (a->syntax->comparison_fn(ldb, ldb,
|
||||||
|
&el->values[i], val) == 0) {
|
||||||
if (i<el->num_values-1) {
|
if (i<el->num_values-1) {
|
||||||
memmove(&el->values[i], &el->values[i+1],
|
memmove(&el->values[i], &el->values[i+1],
|
||||||
sizeof(el->values[i])*(el->num_values-(i+1)));
|
sizeof(el->values[i])*
|
||||||
|
(el->num_values-(i+1)));
|
||||||
}
|
}
|
||||||
el->num_values--;
|
el->num_values--;
|
||||||
if (el->num_values == 0) {
|
if (el->num_values == 0) {
|
||||||
return msg_delete_attribute(module, ldb, msg, name);
|
return msg_delete_attribute(module, ldb,
|
||||||
|
msg, name);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -579,10 +594,11 @@ static int msg_delete_element(struct ldb_module *module,
|
|||||||
modify a record - internal interface
|
modify a record - internal interface
|
||||||
|
|
||||||
yuck - this is O(n^2). Luckily n is usually small so we probably
|
yuck - this is O(n^2). Luckily n is usually small so we probably
|
||||||
get away with it, but if we ever have really large attribute lists
|
get away with it, but if we ever have really large attribute lists
|
||||||
then we'll need to look at this again
|
then we'll need to look at this again
|
||||||
*/
|
*/
|
||||||
int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg)
|
int ltdb_modify_internal(struct ldb_module *module,
|
||||||
|
const struct ldb_message *msg)
|
||||||
{
|
{
|
||||||
struct ldb_context *ldb = module->ldb;
|
struct ldb_context *ldb = module->ldb;
|
||||||
struct ltdb_private *ltdb =
|
struct ltdb_private *ltdb =
|
||||||
@ -734,15 +750,17 @@ int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *ms
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ldb_asprintf_errstring(module->ldb, "Invalid ldb_modify flags on %s: 0x%x",
|
ldb_asprintf_errstring(module->ldb,
|
||||||
msg->elements[i].name,
|
"Invalid ldb_modify flags on %s: 0x%x",
|
||||||
msg->elements[i].flags & LDB_FLAG_MOD_MASK);
|
msg->elements[i].name,
|
||||||
|
msg->elements[i].flags & LDB_FLAG_MOD_MASK);
|
||||||
ret = LDB_ERR_PROTOCOL_ERROR;
|
ret = LDB_ERR_PROTOCOL_ERROR;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we've made all the mods - save the modified record back into the database */
|
/* we've made all the mods
|
||||||
|
* save the modified record back into the database */
|
||||||
ret = ltdb_store(module, msg2, TDB_MODIFY);
|
ret = ltdb_store(module, msg2, TDB_MODIFY);
|
||||||
if (ret != LDB_SUCCESS) {
|
if (ret != LDB_SUCCESS) {
|
||||||
goto failed;
|
goto failed;
|
||||||
@ -768,14 +786,16 @@ failed:
|
|||||||
*/
|
*/
|
||||||
static int ltdb_modify(struct ldb_module *module, struct ldb_request *req)
|
static int ltdb_modify(struct ldb_module *module, struct ldb_request *req)
|
||||||
{
|
{
|
||||||
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
|
struct ltdb_private *ltdb;
|
||||||
struct ltdb_context *ltdb_ac;
|
struct ltdb_context *ltdb_ac;
|
||||||
int tret, ret = LDB_SUCCESS;
|
int tret, ret = LDB_SUCCESS;
|
||||||
|
|
||||||
|
ltdb = talloc_get_type(module->private_data, struct ltdb_private);
|
||||||
|
|
||||||
if (check_critical_controls(req->controls)) {
|
if (check_critical_controls(req->controls)) {
|
||||||
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
|
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->handle = NULL;
|
req->handle = NULL;
|
||||||
|
|
||||||
req->handle = init_ltdb_handle(ltdb, module, req);
|
req->handle = init_ltdb_handle(ltdb, module, req);
|
||||||
@ -789,7 +809,7 @@ static int ltdb_modify(struct ldb_module *module, struct ldb_request *req)
|
|||||||
req->handle->status = tret;
|
req->handle->status = tret;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ltdb_cache_load(module) != 0) {
|
if (ltdb_cache_load(module) != 0) {
|
||||||
ret = LDB_ERR_OPERATIONS_ERROR;
|
ret = LDB_ERR_OPERATIONS_ERROR;
|
||||||
goto done;
|
goto done;
|
||||||
@ -814,15 +834,17 @@ done:
|
|||||||
*/
|
*/
|
||||||
static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
|
static int ltdb_rename(struct ldb_module *module, struct ldb_request *req)
|
||||||
{
|
{
|
||||||
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
|
struct ltdb_private *ltdb;
|
||||||
struct ltdb_context *ltdb_ac;
|
struct ltdb_context *ltdb_ac;
|
||||||
struct ldb_message *msg;
|
struct ldb_message *msg;
|
||||||
int tret, ret = LDB_SUCCESS;
|
int tret, ret = LDB_SUCCESS;
|
||||||
|
|
||||||
|
ltdb = talloc_get_type(module->private_data, struct ltdb_private);
|
||||||
|
|
||||||
if (check_critical_controls(req->controls)) {
|
if (check_critical_controls(req->controls)) {
|
||||||
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
|
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->handle = NULL;
|
req->handle = NULL;
|
||||||
|
|
||||||
if (ltdb_cache_load(module) != 0) {
|
if (ltdb_cache_load(module) != 0) {
|
||||||
@ -947,19 +969,22 @@ static int ltdb_wait(struct ldb_handle *handle, enum ldb_wait_type type)
|
|||||||
|
|
||||||
static int ltdb_request(struct ldb_module *module, struct ldb_request *req)
|
static int ltdb_request(struct ldb_module *module, struct ldb_request *req)
|
||||||
{
|
{
|
||||||
/* check for oustanding critical controls and return an error if found */
|
/* check for oustanding critical controls
|
||||||
|
* and return an error if found */
|
||||||
if (check_critical_controls(req->controls)) {
|
if (check_critical_controls(req->controls)) {
|
||||||
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
|
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* search, add, modify, delete, rename are handled by their own, no other op supported */
|
/* search, add, modify, delete, rename are handled by their own,
|
||||||
|
* no other op supported */
|
||||||
return LDB_ERR_OPERATIONS_ERROR;
|
return LDB_ERR_OPERATIONS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
return sequenceNumber from @BASEINFO
|
return sequenceNumber from @BASEINFO
|
||||||
*/
|
*/
|
||||||
static int ltdb_sequence_number(struct ldb_module *module, struct ldb_request *req)
|
static int ltdb_sequence_number(struct ldb_module *module,
|
||||||
|
struct ldb_request *req)
|
||||||
{
|
{
|
||||||
TALLOC_CTX *tmp_ctx;
|
TALLOC_CTX *tmp_ctx;
|
||||||
struct ldb_message *msg = NULL;
|
struct ldb_message *msg = NULL;
|
||||||
@ -1031,7 +1056,7 @@ static const struct ldb_module_ops ltdb_ops = {
|
|||||||
/*
|
/*
|
||||||
connect to the database
|
connect to the database
|
||||||
*/
|
*/
|
||||||
static int ltdb_connect(struct ldb_context *ldb, const char *url,
|
static int ltdb_connect(struct ldb_context *ldb, const char *url,
|
||||||
unsigned int flags, const char *options[],
|
unsigned int flags, const char *options[],
|
||||||
struct ldb_module **module)
|
struct ldb_module **module)
|
||||||
{
|
{
|
||||||
@ -1042,7 +1067,8 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
|
|||||||
/* parse the url */
|
/* parse the url */
|
||||||
if (strchr(url, ':')) {
|
if (strchr(url, ':')) {
|
||||||
if (strncmp(url, "tdb://", 6) != 0) {
|
if (strncmp(url, "tdb://", 6) != 0) {
|
||||||
ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid tdb URL '%s'", url);
|
ldb_debug(ldb, LDB_DEBUG_ERROR,
|
||||||
|
"Invalid tdb URL '%s'", url);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
path = url+6;
|
path = url+6;
|
||||||
@ -1075,11 +1101,12 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* note that we use quite a large default hash size */
|
/* note that we use quite a large default hash size */
|
||||||
ltdb->tdb = ltdb_wrap_open(ltdb, path, 10000,
|
ltdb->tdb = ltdb_wrap_open(ltdb, path, 10000,
|
||||||
tdb_flags, open_flags,
|
tdb_flags, open_flags,
|
||||||
ldb->create_perms, ldb);
|
ldb->create_perms, ldb);
|
||||||
if (!ltdb->tdb) {
|
if (!ltdb->tdb) {
|
||||||
ldb_debug(ldb, LDB_DEBUG_ERROR, "Unable to open tdb '%s'\n", path);
|
ldb_debug(ldb, LDB_DEBUG_ERROR,
|
||||||
|
"Unable to open tdb '%s'\n", path);
|
||||||
talloc_free(ltdb);
|
talloc_free(ltdb);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user