mirror of
https://github.com/samba-team/samba.git
synced 2025-07-07 12:59:08 +03:00
dsdb: Remove OpenLDAP backend complexity from partitions module
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Nadezhda Ivanova <nivanova@symas.com>
This commit is contained in:
@ -52,7 +52,6 @@ struct partition_private_data {
|
|||||||
struct partition_metadata *metadata;
|
struct partition_metadata *metadata;
|
||||||
|
|
||||||
struct partition_module **modules;
|
struct partition_module **modules;
|
||||||
const char *ldapBackend;
|
|
||||||
|
|
||||||
uint64_t metadata_seq;
|
uint64_t metadata_seq;
|
||||||
uint32_t in_transaction;
|
uint32_t in_transaction;
|
||||||
|
@ -138,7 +138,7 @@ static int partition_reload_metadata(struct ldb_module *module, struct partition
|
|||||||
struct ldb_message *msg, *module_msg;
|
struct ldb_message *msg, *module_msg;
|
||||||
struct ldb_result *res;
|
struct ldb_result *res;
|
||||||
struct ldb_context *ldb = ldb_module_get_ctx(module);
|
struct ldb_context *ldb = ldb_module_get_ctx(module);
|
||||||
const char *attrs[] = { "partition", "replicateEntries", "modules", "ldapBackend",
|
const char *attrs[] = { "partition", "replicateEntries", "modules",
|
||||||
"partialReplica", "backendStore", NULL };
|
"partialReplica", "backendStore", NULL };
|
||||||
/* perform search for @PARTITION, looking for module, replicateEntries and ldapBackend */
|
/* perform search for @PARTITION, looking for module, replicateEntries and ldapBackend */
|
||||||
ret = dsdb_module_search_dn(module, mem_ctx, &res,
|
ret = dsdb_module_search_dn(module, mem_ctx, &res,
|
||||||
@ -170,7 +170,6 @@ static int partition_reload_metadata(struct ldb_module *module, struct partition
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->ldapBackend = talloc_steal(data, ldb_msg_find_attr_as_string(msg, "ldapBackend", NULL));
|
|
||||||
if (_msg) {
|
if (_msg) {
|
||||||
*_msg = msg;
|
*_msg = msg;
|
||||||
} else {
|
} else {
|
||||||
@ -205,6 +204,7 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
|
|||||||
struct dsdb_partition **partition) {
|
struct dsdb_partition **partition) {
|
||||||
struct dsdb_control_current_partition *ctrl;
|
struct dsdb_control_current_partition *ctrl;
|
||||||
struct ldb_module *backend_module;
|
struct ldb_module *backend_module;
|
||||||
|
char *backend_path;
|
||||||
struct ldb_module *module_chain;
|
struct ldb_module *module_chain;
|
||||||
const char **modules;
|
const char **modules;
|
||||||
const char **options = NULL;
|
const char **options = NULL;
|
||||||
@ -221,38 +221,33 @@ static int new_partition_from_dn(struct ldb_context *ldb, struct partition_priva
|
|||||||
return ldb_oom(ldb);
|
return ldb_oom(ldb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See if an LDAP backend has been specified */
|
/* the backend LDB is the DN (base64 encoded if not 'plain') followed by .ldb */
|
||||||
if (data->ldapBackend) {
|
backend_path = ldb_relative_path(ldb,
|
||||||
(*partition)->backend_url = data->ldapBackend;
|
*partition,
|
||||||
} else {
|
filename);
|
||||||
/* the backend LDB is the DN (base64 encoded if not 'plain') followed by .ldb */
|
if (!backend_path) {
|
||||||
char *backend_path = ldb_relative_path(ldb,
|
ldb_asprintf_errstring(ldb,
|
||||||
*partition,
|
"partition_init: unable to determine an relative path for partition: %s",
|
||||||
filename);
|
filename);
|
||||||
if (!backend_path) {
|
talloc_free(*partition);
|
||||||
ldb_asprintf_errstring(ldb,
|
return LDB_ERR_OPERATIONS_ERROR;
|
||||||
"partition_init: unable to determine an relative path for partition: %s", filename);
|
}
|
||||||
talloc_free(*partition);
|
(*partition)->backend_url = talloc_asprintf(*partition, "%s://%s",
|
||||||
return LDB_ERR_OPERATIONS_ERROR;
|
backend_db_store,
|
||||||
}
|
backend_path);
|
||||||
(*partition)->backend_url = talloc_asprintf(*partition, "%s://%s",
|
|
||||||
backend_db_store,
|
if (!(ldb_module_flags(ldb) & LDB_FLG_RDONLY)) {
|
||||||
backend_path);
|
char *p;
|
||||||
|
char *backend_dir;
|
||||||
if (!(ldb_module_flags(ldb) & LDB_FLG_RDONLY)) {
|
|
||||||
char *p;
|
p = strrchr(backend_path, '/');
|
||||||
char *backend_dir;
|
if (p) {
|
||||||
|
p[0] = '\0';
|
||||||
p = strrchr(backend_path, '/');
|
|
||||||
if (p) {
|
|
||||||
p[0] = '\0';
|
|
||||||
}
|
|
||||||
backend_dir = backend_path;
|
|
||||||
|
|
||||||
/* Failure is quite reasonable, it might alredy exist */
|
|
||||||
mkdir(backend_dir, 0700);
|
|
||||||
}
|
}
|
||||||
|
backend_dir = backend_path;
|
||||||
|
|
||||||
|
/* Failure is quite reasonable, it might alredy exist */
|
||||||
|
mkdir(backend_dir, 0700);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION;
|
ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION;
|
||||||
@ -534,13 +529,6 @@ int partition_reload_if_required(struct ldb_module *module,
|
|||||||
talloc_free(partition->ctrl->dn);
|
talloc_free(partition->ctrl->dn);
|
||||||
partition->ctrl->dn = talloc_steal(partition->ctrl, dn_res->msgs[0]->dn);
|
partition->ctrl->dn = talloc_steal(partition->ctrl, dn_res->msgs[0]->dn);
|
||||||
talloc_free(dn_res);
|
talloc_free(dn_res);
|
||||||
if (data->ldapBackend) {
|
|
||||||
ret = dsdb_fix_dn_rdncase(ldb, partition->ctrl->dn);
|
|
||||||
if (ret) {
|
|
||||||
talloc_free(mem_ctx);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (ret != LDB_ERR_NO_SUCH_OBJECT) {
|
} else if (ret != LDB_ERR_NO_SUCH_OBJECT) {
|
||||||
ldb_asprintf_errstring(ldb,
|
ldb_asprintf_errstring(ldb,
|
||||||
"Failed to search for partition base %s in new partition at %s: %s",
|
"Failed to search for partition base %s in new partition at %s: %s",
|
||||||
|
Reference in New Issue
Block a user