1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s4-dsdb: removed the use of ldb_private.h from s4

this will allow s4 to use a system version of ldb
This commit is contained in:
Andrew Tridgell 2010-11-02 10:41:28 +11:00
parent 8a2142773f
commit 4a08b2d172
10 changed files with 59 additions and 125 deletions

View File

@ -1,48 +0,0 @@
/*
Unix SMB/CIFS mplementation.
The Module that loads some DSDB related things
into memory. E.g. it loads the dsdb_schema structure
Copyright (C) Stefan Metzmacher 2007
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 "includes.h"
#include "lib/ldb/include/ldb.h"
#include "lib/ldb/include/ldb_errors.h"
#include "lib/ldb/include/ldb_private.h"
#include "dsdb/samdb/samdb.h"
#include "librpc/gen_ndr/ndr_misc.h"
#include "librpc/gen_ndr/ndr_drsuapi.h"
#include "librpc/gen_ndr/ndr_drsblobs.h"
static int dsdb_cache_init(struct ldb_module *module)
{
/* TODO: load the schema */
return ldb_next_init(module);
}
static const struct ldb_module_ops ldb_dsdb_cache_module_ops = {
.name = "dsdb_cache",
.init_context = dsdb_cache_init
};
int ldb_dsdb_cache_module_init(const char *version)
{
LDB_MODULE_CHECK_VERSION(version);
return ldb_register_module(&ldb_dsdb_cache_module_ops);
}

View File

@ -68,7 +68,7 @@ static struct partition_context *partition_init_ctx(struct ldb_module *module, s
*/
int partition_request(struct ldb_module *module, struct ldb_request *request)
{
if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) { \
if ((module && ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING)) { \
const struct dsdb_control_current_partition *partition = NULL;
struct ldb_control *partition_ctrl = ldb_request_get_control(request, DSDB_CONTROL_CURRENT_PARTITION_OID);
if (partition_ctrl) {
@ -77,10 +77,10 @@ int partition_request(struct ldb_module *module, struct ldb_request *request)
}
if (partition != NULL) {
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_request() -> %s",
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_request() -> %s",
ldb_dn_get_linearized(partition->dn));
} else {
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_request() -> (metadata partition)");
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_request() -> (metadata partition)");
}
}
@ -138,7 +138,7 @@ static int partition_req_callback(struct ldb_request *req,
struct ldb_control *partition_ctrl;
ac = talloc_get_type(req->context, struct partition_context);
data = talloc_get_type(ac->module->private_data, struct partition_private_data);
data = talloc_get_type(ldb_module_get_private(ac->module), struct partition_private_data);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@ -369,7 +369,7 @@ static int partition_send_all(struct ldb_module *module,
struct ldb_request *req)
{
unsigned int i;
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data *data = talloc_get_type(ldb_module_get_private(module),
struct partition_private_data);
int ret = partition_prep_request(ac, NULL);
if (ret != LDB_SUCCESS) {
@ -396,7 +396,7 @@ static int partition_replicate(struct ldb_module *module, struct ldb_request *re
unsigned int i;
int ret;
struct dsdb_partition *partition;
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data *data = talloc_get_type(ldb_module_get_private(module),
struct partition_private_data);
if (!data || !data->partitions) {
return ldb_next_request(module, req);
@ -454,7 +454,7 @@ static int partition_search(struct ldb_module *module, struct ldb_request *req)
{
struct ldb_control **saved_controls;
/* Find backend */
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data *data = talloc_get_type(ldb_module_get_private(module),
struct partition_private_data);
struct partition_context *ac;
struct ldb_context *ldb;
@ -677,7 +677,7 @@ static int partition_rename(struct ldb_module *module, struct ldb_request *req)
/* Find backend */
struct dsdb_partition *backend, *backend2;
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data *data = talloc_get_type(ldb_module_get_private(module),
struct partition_private_data);
/* Skip the lot if 'data' isn't here yet (initialisation) */
@ -711,13 +711,13 @@ static int partition_start_trans(struct ldb_module *module)
{
unsigned int i;
int ret;
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data *data = talloc_get_type(ldb_module_get_private(module),
struct partition_private_data);
/* Look at base DN */
/* Figure out which partition it is under */
/* Skip the lot if 'data' isn't here yet (initialization) */
if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_start_trans() -> (metadata partition)");
if ((module && ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_start_trans() -> (metadata partition)");
}
ret = ldb_next_start_trans(module);
if (ret != LDB_SUCCESS) {
@ -730,8 +730,8 @@ static int partition_start_trans(struct ldb_module *module)
}
for (i=0; data && data->partitions && data->partitions[i]; i++) {
if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_start_trans() -> %s",
if ((module && ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_start_trans() -> %s",
ldb_dn_get_linearized(data->partitions[i]->ctrl->dn));
}
ret = ldb_next_start_trans(data->partitions[i]->module);
@ -754,27 +754,27 @@ static int partition_start_trans(struct ldb_module *module)
static int partition_prepare_commit(struct ldb_module *module)
{
unsigned int i;
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data *data = talloc_get_type(ldb_module_get_private(module),
struct partition_private_data);
for (i=0; data && data->partitions && data->partitions[i]; i++) {
int ret;
if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_prepare_commit() -> %s",
if ((module && ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_prepare_commit() -> %s",
ldb_dn_get_linearized(data->partitions[i]->ctrl->dn));
}
ret = ldb_next_prepare_commit(data->partitions[i]->module);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(module->ldb, "prepare_commit error on %s: %s",
ldb_asprintf_errstring(ldb_module_get_ctx(module), "prepare_commit error on %s: %s",
ldb_dn_get_linearized(data->partitions[i]->ctrl->dn),
ldb_errstring(module->ldb));
ldb_errstring(ldb_module_get_ctx(module)));
return ret;
}
}
if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_prepare_commit() -> (metadata partition)");
if ((module && ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_prepare_commit() -> (metadata partition)");
}
return ldb_next_prepare_commit(module);
}
@ -785,7 +785,7 @@ static int partition_end_trans(struct ldb_module *module)
{
int ret, ret2;
unsigned int i;
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data *data = talloc_get_type(ldb_module_get_private(module),
struct partition_private_data);
ret = LDB_SUCCESS;
@ -798,21 +798,21 @@ static int partition_end_trans(struct ldb_module *module)
}
for (i=0; data && data->partitions && data->partitions[i]; i++) {
if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_end_trans() -> %s",
if ((module && ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_end_trans() -> %s",
ldb_dn_get_linearized(data->partitions[i]->ctrl->dn));
}
ret2 = ldb_next_end_trans(data->partitions[i]->module);
if (ret2 != LDB_SUCCESS) {
ldb_asprintf_errstring(module->ldb, "end_trans error on %s: %s",
ldb_asprintf_errstring(ldb_module_get_ctx(module), "end_trans error on %s: %s",
ldb_dn_get_linearized(data->partitions[i]->ctrl->dn),
ldb_errstring(module->ldb));
ldb_errstring(ldb_module_get_ctx(module)));
ret = ret2;
}
}
if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_end_trans() -> (metadata partition)");
if ((module && ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_end_trans() -> (metadata partition)");
}
ret2 = ldb_next_end_trans(module);
if (ret2 != LDB_SUCCESS) {
@ -826,18 +826,18 @@ static int partition_del_trans(struct ldb_module *module)
{
int ret, final_ret = LDB_SUCCESS;
unsigned int i;
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data *data = talloc_get_type(ldb_module_get_private(module),
struct partition_private_data);
for (i=0; data && data->partitions && data->partitions[i]; i++) {
if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_del_trans() -> %s",
if ((module && ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_del_trans() -> %s",
ldb_dn_get_linearized(data->partitions[i]->ctrl->dn));
}
ret = ldb_next_del_trans(data->partitions[i]->module);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(module->ldb, "del_trans error on %s: %s",
ldb_asprintf_errstring(ldb_module_get_ctx(module), "del_trans error on %s: %s",
ldb_dn_get_linearized(data->partitions[i]->ctrl->dn),
ldb_errstring(module->ldb));
ldb_errstring(ldb_module_get_ctx(module)));
final_ret = ret;
}
}
@ -848,8 +848,8 @@ static int partition_del_trans(struct ldb_module *module)
}
data->in_transaction--;
if ((module && module->ldb->flags & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "partition_del_trans() -> (metadata partition)");
if ((module && ldb_module_flags(ldb_module_get_ctx(module)) & LDB_FLG_ENABLE_TRACING)) {
ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_TRACE, "partition_del_trans() -> (metadata partition)");
}
ret = ldb_next_del_trans(module);
if (ret != LDB_SUCCESS) {
@ -923,7 +923,7 @@ static int partition_sequence_number(struct ldb_module *module, struct ldb_reque
uint64_t seq_number = 0;
uint64_t timestamp_sequence = 0;
uint64_t timestamp = 0;
struct partition_private_data *data = talloc_get_type(module->private_data,
struct partition_private_data *data = talloc_get_type(ldb_module_get_private(module),
struct partition_private_data);
struct ldb_seqnum_request *seq;
struct ldb_seqnum_result *seqr;
@ -1164,7 +1164,7 @@ static int partition_extended(struct ldb_module *module, struct ldb_request *req
struct partition_context *ac;
int ret;
data = talloc_get_type(module->private_data, struct partition_private_data);
data = talloc_get_type(ldb_module_get_private(module), struct partition_private_data);
if (!data) {
return ldb_next_request(module, req);
}

View File

@ -21,7 +21,6 @@
#include "lib/ldb/include/ldb.h"
#include "lib/ldb/include/ldb_errors.h"
#include "lib/ldb/include/ldb_module.h"
#include "lib/ldb/include/ldb_private.h"
#include "dsdb/samdb/samdb.h"
#include "dsdb/samdb/ldb_modules/util.h"
#include "system/locale.h"

View File

@ -32,6 +32,7 @@
#include "dsdb/samdb/ldb_modules/partition.h"
#include "lib/util/tsort.h"
#include "lib/ldb-samba/ldb_wrap.h"
#include "system/filesys.h"
static int partition_sort_compare(const void *v1, const void *v2)
{
@ -232,7 +233,7 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
}
(*partition)->backend_url = talloc_steal((*partition), backend_url);
if (!(ldb->flags & LDB_FLG_RDONLY)) {
if (!(ldb_module_flags(ldb) & LDB_FLG_RDONLY)) {
char *p;
char *backend_dir = talloc_strdup(*partition, backend_url);
@ -251,7 +252,7 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION;
ctrl->dn = talloc_steal(ctrl, dn);
ret = ldb_connect_backend(ldb, (*partition)->backend_url, NULL, &backend_module);
ret = ldb_module_connect_backend(ldb, (*partition)->backend_url, NULL, &backend_module);
if (ret != LDB_SUCCESS) {
return ret;
}
@ -264,7 +265,7 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
talloc_free(*partition);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
ret = ldb_load_modules_list(ldb, modules, backend_module, &module_chain);
ret = ldb_module_load_list(ldb, modules, backend_module, &module_chain);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb,
"partition_init: "
@ -273,7 +274,7 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
talloc_free(*partition);
return ret;
}
ret = ldb_init_module_chain(ldb, module_chain);
ret = ldb_module_init_chain(ldb, module_chain);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb,
"partition_init: "
@ -289,13 +290,13 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
talloc_free(*partition);
return ldb_oom(ldb);
}
(*partition)->module->next = talloc_steal((*partition)->module, module_chain);
ldb_module_set_next((*partition)->module, talloc_steal((*partition)->module, module_chain));
/* if we were in a transaction then we need to start a
transaction on this new partition, otherwise we'll get a
transaction mismatch when we end the transaction */
if (data->in_transaction) {
if (ldb->flags & LDB_FLG_ENABLE_TRACING) {
if (ldb_module_flags(ldb) & LDB_FLG_ENABLE_TRACING) {
ldb_debug(ldb, LDB_DEBUG_TRACE, "partition_start_trans() -> %s (new partition)",
ldb_dn_get_linearized((*partition)->ctrl->dn));
}
@ -685,7 +686,7 @@ int partition_create(struct ldb_module *module, struct ldb_request *req)
struct dsdb_create_partition_exop *ex_op = talloc_get_type(req->op.extended.data, struct dsdb_create_partition_exop);
struct ldb_dn *dn = ex_op->new_dn;
data = talloc_get_type(module->private_data, struct partition_private_data);
data = talloc_get_type(ldb_module_get_private(module), struct partition_private_data);
if (!data) {
/* We are not going to create a partition before we are even set up */
return LDB_ERR_UNWILLING_TO_PERFORM;
@ -830,7 +831,7 @@ int partition_init(struct ldb_module *module)
return ret;
}
module->private_data = talloc_steal(module, data);
ldb_module_set_private(module, talloc_steal(module, data));
talloc_free(mem_ctx);
ret = ldb_mod_register_control(module, LDB_CONTROL_DOMAIN_SCOPE_OID);

View File

@ -34,8 +34,6 @@
#include "lib/ldb/include/ldb.h"
#include "lib/ldb/include/ldb_errors.h"
#include "lib/ldb/include/ldb_module.h"
#include "lib/ldb/include/ldb_private.h"
#include "dsdb/samdb/ldb_modules/util.h"
#include "dsdb/samdb/samdb.h"
#include "librpc/ndr/libndr.h"
@ -341,13 +339,13 @@ static int samba_dsdb_init(struct ldb_module *module)
/* The backend (at least until the partitions module
* reconfigures things) is the next module in the currently
* loaded chain */
backend_module = module->next;
ret = ldb_load_modules_list(ldb, reverse_module_list, backend_module, &module_chain);
backend_module = ldb_module_next(module);
ret = ldb_module_load_list(ldb, reverse_module_list, backend_module, &module_chain);
CHECK_LDB_RET(ret);
talloc_free(tmp_ctx);
/* Set this as the 'next' module, so that we effectivly append it to module chain */
module->next = module_chain;
ldb_module_set_next(module, module_chain);
return ldb_next_init(module);
}

View File

@ -33,8 +33,6 @@
#include "lib/ldb/include/ldb.h"
#include "lib/ldb/include/ldb_errors.h"
#include "lib/ldb/include/ldb_module.h"
#include "lib/ldb/include/ldb_private.h"
#include "dsdb/samdb/ldb_modules/util.h"
#include "dsdb/samdb/samdb.h"
@ -78,8 +76,8 @@ static int samba_secrets_init(struct ldb_module *module)
/* The backend (at least until the partitions module
* reconfigures things) is the next module in the currently
* loaded chain */
backend_module = module->next;
ret = ldb_load_modules_list(ldb, reverse_module_list, backend_module, &module_chain);
backend_module = ldb_module_next(module);
ret = ldb_module_load_list(ldb, reverse_module_list, backend_module, &module_chain);
if (ret != LDB_SUCCESS) {
talloc_free(tmp_ctx);
return ret;
@ -87,7 +85,7 @@ static int samba_secrets_init(struct ldb_module *module)
talloc_free(tmp_ctx);
/* Set this as the 'next' module, so that we effectivly append it to module chain */
module->next = module_chain;
ldb_module_set_next(module, module_chain);
return ldb_next_init(module);
}

View File

@ -27,7 +27,7 @@
#include "dsdb/samdb/samdb.h"
#include "util.h"
#include "libcli/security/security.h"
#include "lib/ldb/include/ldb_private.h"
const struct dsdb_class * get_last_structural_class(const struct dsdb_schema *schema,const struct ldb_message_element *element)
{

View File

@ -27,7 +27,6 @@
#include "dsdb/samdb/samdb.h"
#include "util.h"
#include "libcli/security/security.h"
#include "lib/ldb/include/ldb_private.h"
#include "libcli/security/session.h"
/*
@ -1105,10 +1104,7 @@ bool dsdb_block_anonymous_ops(struct ldb_module *module,
*/
void dsdb_req_chain_debug(struct ldb_request *req, int level)
{
int i=0;
while (req && req->handle) {
DEBUG(level,("req[%u] %p : %s\n", i++, req, ldb_req_location(req)));
req = req->handle->parent;
}
char *s = ldb_module_call_chain(req, req);
DEBUG(level, ("%s\n", s));
talloc_free(s);
}

View File

@ -64,16 +64,6 @@ bld.SAMBA_MODULE('ldb_repl_meta_data',
)
bld.SAMBA_MODULE('ldb_dsdb_cache',
source='dsdb_cache.c',
subsystem='ldb',
init_function='ldb_dsdb_cache_module_init',
module_init_name='ldb_init_module',
internal_module=False,
deps='SAMDB talloc events'
)
bld.SAMBA_MODULE('ldb_schema_load',
source='schema_load.c',
subsystem='ldb',

View File

@ -24,7 +24,6 @@
#include "includes.h"
#include "ldb_module.h"
#include "ldb_private.h"
#include "lib/cmdline/popt_common.h"
#include "auth/gensec/gensec.h"
#include "auth/auth.h"
@ -62,18 +61,19 @@ static int extensions_hook(struct ldb_context *ldb, enum ldb_module_hook_type t)
switch (t) {
case LDB_MODULE_HOOK_CMDLINE_OPTIONS: {
unsigned len1, len2;
struct poptOption **popt_options = ldb_module_popt_options(ldb);
struct poptOption *new_array;
len1 = calculate_popt_array_length(ldb->popt_options);
len1 = calculate_popt_array_length(*popt_options);
len2 = calculate_popt_array_length(cmdline_extensions);
new_array = talloc_array(NULL, struct poptOption, len1+len2+1);
if (NULL == new_array) {
return ldb_oom(ldb);
}
memcpy(new_array, ldb->popt_options, len1*sizeof(struct poptOption));
memcpy(new_array, *popt_options, len1*sizeof(struct poptOption));
memcpy(new_array+len1, cmdline_extensions, (1+len2)*sizeof(struct poptOption));
ldb->popt_options = new_array;
(*popt_options) = new_array;
return LDB_SUCCESS;
}