mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
dsdb: Create rootdse_get_private_data()
This will get the private data on the first call, allowing that not to be the init() hook. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13379 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
parent
18d4a1cc3f
commit
6395611632
@ -863,11 +863,46 @@ static int rootdse_search(struct ldb_module *module, struct ldb_request *req)
|
||||
return ldb_next_request(module, down_req);
|
||||
}
|
||||
|
||||
static struct rootdse_private_data *rootdse_get_private_data(struct ldb_module *module)
|
||||
{
|
||||
void *priv = ldb_module_get_private(module);
|
||||
struct rootdse_private_data *data = NULL;
|
||||
|
||||
if (priv != NULL) {
|
||||
data = talloc_get_type_abort(priv,
|
||||
struct rootdse_private_data);
|
||||
}
|
||||
|
||||
if (data != NULL) {
|
||||
return data;
|
||||
}
|
||||
|
||||
data = talloc_zero(module, struct rootdse_private_data);
|
||||
if (data == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data->num_controls = 0;
|
||||
data->controls = NULL;
|
||||
data->num_partitions = 0;
|
||||
data->partitions = NULL;
|
||||
data->block_anonymous = true;
|
||||
|
||||
ldb_module_set_private(module, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static int rootdse_register_control(struct ldb_module *module, struct ldb_request *req)
|
||||
{
|
||||
struct rootdse_private_data *priv = talloc_get_type(ldb_module_get_private(module), struct rootdse_private_data);
|
||||
struct rootdse_private_data *priv =
|
||||
rootdse_get_private_data(module);
|
||||
char **list;
|
||||
|
||||
if (priv == NULL) {
|
||||
return ldb_module_oom(module);
|
||||
}
|
||||
|
||||
list = talloc_realloc(priv, priv->controls, char *, priv->num_controls + 1);
|
||||
if (!list) {
|
||||
return ldb_oom(ldb_module_get_ctx(module));
|
||||
@ -886,9 +921,14 @@ static int rootdse_register_control(struct ldb_module *module, struct ldb_reques
|
||||
|
||||
static int rootdse_register_partition(struct ldb_module *module, struct ldb_request *req)
|
||||
{
|
||||
struct rootdse_private_data *priv = talloc_get_type(ldb_module_get_private(module), struct rootdse_private_data);
|
||||
struct rootdse_private_data *priv =
|
||||
rootdse_get_private_data(module);
|
||||
struct ldb_dn **list;
|
||||
|
||||
if (priv == NULL) {
|
||||
return ldb_module_oom(module);
|
||||
}
|
||||
|
||||
list = talloc_realloc(priv, priv->partitions, struct ldb_dn *, priv->num_partitions + 1);
|
||||
if (!list) {
|
||||
return ldb_oom(ldb_module_get_ctx(module));
|
||||
@ -924,28 +964,21 @@ static int rootdse_request(struct ldb_module *module, struct ldb_request *req)
|
||||
static int rootdse_init(struct ldb_module *module)
|
||||
{
|
||||
int ret;
|
||||
struct ldb_context *ldb;
|
||||
struct ldb_result *res;
|
||||
struct rootdse_private_data *data;
|
||||
const char *attrs[] = { "msDS-Behavior-Version", NULL };
|
||||
const char *ds_attrs[] = { "dsServiceName", NULL };
|
||||
TALLOC_CTX *mem_ctx;
|
||||
|
||||
ldb = ldb_module_get_ctx(module);
|
||||
struct ldb_context *ldb
|
||||
= ldb_module_get_ctx(module);
|
||||
|
||||
struct rootdse_private_data *data
|
||||
= rootdse_get_private_data(module);
|
||||
|
||||
data = talloc_zero(module, struct rootdse_private_data);
|
||||
if (data == NULL) {
|
||||
return ldb_oom(ldb);
|
||||
return ldb_module_oom(module);
|
||||
}
|
||||
|
||||
data->num_controls = 0;
|
||||
data->controls = NULL;
|
||||
data->num_partitions = 0;
|
||||
data->partitions = NULL;
|
||||
data->block_anonymous = true;
|
||||
|
||||
ldb_module_set_private(module, data);
|
||||
|
||||
ldb_set_default_dns(ldb);
|
||||
|
||||
ret = ldb_next_init(module);
|
||||
|
Loading…
Reference in New Issue
Block a user