[SCM] Samba Shared Repository - branch master updated
Andrew Bartlett
abartlet at samba.org
Thu Jul 1 19:07:41 MDT 2010
The branch, master has been updated
via c482798... s4:dsdb Ensure we free old schema copies
via 5a66edc... s4/dsdb: Assert DSDB_FLAG_*_MODULE is always passed in function call
via 7347499... s4-source4/dsdb/samdb/ldb_modules/util.c Use DSDB_FLAG_NEXT_MODULE flag
via 682f7a5... s4-source4/dsdb/samdb/ldb_modules/subtree_delete.c: Use DSDB_FLAG_NEXT_MODULE flag
via bf373d5... s4-source4/dsdb/samdb/ldb_modules/schema_load.c: Use DSDB_FLAG_NEXT_MODULE flag
via 7c653c4... s4-source4/dsdb/samdb/ldb_modules/samldb.c: Use DSDB_FLAG_NEXT_MODULE flag
via 0e023f2... s4-source4/dsdb/samdb/ldb_modules/samba3sid.c: Use DSDB_FLAG_NEXT_MODULE flag
via 30a69eb... s4-source4/dsdb/samdb/ldb_modules/rootdse.c: Use DSDB_FLAG_NEXT_MODULE flag
via 68c6e60... s4-source4/dsdb/samdb/ldb_modules/ridalloc.c: Use DSDB_FLAG_NEXT_MODULE flag
via f3f87e8... s4-source4/dsdb/samdb/ldb_modules/repl_meta_data.c: Use DSDB_FLAG_NEXT_MODULE flag
via b29921b... s4-dsdb/samdb/ldb_modules/linked_attributes.c: make use of DSDB_FLAG_NEXT_MODULE flag
via f570eec... s4/dsdb: Add DSDB_FLAG_NEXT_MODULE flag
from 3721161... s3:auth Fix switch statement referencing a uninitialized variable
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit c48279896d93ab8d4490cbf9d47eb6f763b43785
Author: Andrew Bartlett <abartlet at samba.org>
Date: Wed Jun 30 23:25:32 2010 +1000
s4:dsdb Ensure we free old schema copies
It was reported by aatanasov that we kept around one whole schema per
modification made. This does not fix that, but I hope moves us closer
to a fix
The most important part of the fix is that:
- if (schema_out != schema_in) {
- talloc_unlink(schema_in, ldb);
- }
was the wrong way around. This is now handled in the schema_set calls.
Andrew Bartlett
commit 5a66edc99ee782e36efa2fc64a7603247ba3abc1
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Thu Jul 1 23:47:02 2010 +0300
s4/dsdb: Assert DSDB_FLAG_*_MODULE is always passed in function call
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 73474998e167837002da495993fa75de17e3aecd
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon Jun 28 21:29:05 2010 +0300
s4-source4/dsdb/samdb/ldb_modules/util.c Use DSDB_FLAG_NEXT_MODULE flag
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 682f7a53383f1c72f53fc5238f4ca2db348f9df3
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon Jun 28 21:28:46 2010 +0300
s4-source4/dsdb/samdb/ldb_modules/subtree_delete.c: Use DSDB_FLAG_NEXT_MODULE flag
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit bf373d5c29737264724ae4f86e05a79d7b69b4ee
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon Jun 28 21:28:30 2010 +0300
s4-source4/dsdb/samdb/ldb_modules/schema_load.c: Use DSDB_FLAG_NEXT_MODULE flag
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 7c653c429a7d31d00620fc8cfda913a814c1048f
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon Jun 28 21:28:10 2010 +0300
s4-source4/dsdb/samdb/ldb_modules/samldb.c: Use DSDB_FLAG_NEXT_MODULE flag
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 0e023f23408df71aa3ad24f0a78cfead44d63d4b
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon Jun 28 21:27:51 2010 +0300
s4-source4/dsdb/samdb/ldb_modules/samba3sid.c: Use DSDB_FLAG_NEXT_MODULE flag
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 30a69eb4a0cf61cc21c11bbb71494aae57bfe139
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon Jun 28 21:27:32 2010 +0300
s4-source4/dsdb/samdb/ldb_modules/rootdse.c: Use DSDB_FLAG_NEXT_MODULE flag
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 68c6e607d9facd20ba792cd8f8e1a5e8740bf300
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon Jun 28 21:26:53 2010 +0300
s4-source4/dsdb/samdb/ldb_modules/ridalloc.c: Use DSDB_FLAG_NEXT_MODULE flag
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit f3f87e8deed86d066346e852269ae12d1966ea0a
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon Jun 28 21:26:07 2010 +0300
s4-source4/dsdb/samdb/ldb_modules/repl_meta_data.c: Use DSDB_FLAG_NEXT_MODULE flag
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit b29921b82ea34f307f04acb86afe64f33a69ab1e
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon Jun 28 21:25:28 2010 +0300
s4-dsdb/samdb/ldb_modules/linked_attributes.c: make use of DSDB_FLAG_NEXT_MODULE flag
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit f570eec26432a66d7fbc2a70017b3df8dbdd1e89
Author: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon Jun 28 21:07:51 2010 +0300
s4/dsdb: Add DSDB_FLAG_NEXT_MODULE flag
Although it is not currently used in implementation,
my intention is for callers to clearly state what
action they want to execute.
Currently when a caller wants to pass the call to the next
module in the chain, this flag is either omitted or 0 is used
(which is somewhat hacky, isn't it)
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source4/dsdb/samdb/ldb_modules/linked_attributes.c | 4 +-
source4/dsdb/samdb/ldb_modules/repl_meta_data.c | 9 +++--
source4/dsdb/samdb/ldb_modules/ridalloc.c | 2 +-
source4/dsdb/samdb/ldb_modules/rootdse.c | 5 ++-
source4/dsdb/samdb/ldb_modules/samba3sid.c | 4 ++-
source4/dsdb/samdb/ldb_modules/samldb.c | 9 +++--
source4/dsdb/samdb/ldb_modules/schema_load.c | 3 +-
source4/dsdb/samdb/ldb_modules/subtree_delete.c | 4 ++-
source4/dsdb/samdb/ldb_modules/util.c | 10 +++++-
source4/dsdb/samdb/ldb_modules/util.h | 1 +
source4/dsdb/schema/schema_set.c | 31 ++++++++++++++++----
11 files changed, 58 insertions(+), 24 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c
index c204571..8648ab3 100644
--- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c
+++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c
@@ -684,7 +684,7 @@ static int linked_attributes_fix_links(struct ldb_module *module,
return ret;
}
- ret = dsdb_module_modify(module, msg, DSDB_MODIFY_RELAX);
+ ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE | DSDB_MODIFY_RELAX);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb, "Linked attribute %s->%s between %s and %s - update failed - %s",
el->name, target->lDAPDisplayName,
@@ -978,7 +978,7 @@ static int la_do_op_request(struct ldb_module *module, struct la_context *ac, st
ldb_ldif_message_string(ldb, op, LDB_CHANGETYPE_MODIFY, new_msg)));
}
- ret = dsdb_module_modify(module, new_msg, 0);
+ ret = dsdb_module_modify(module, new_msg, DSDB_FLAG_NEXT_MODULE);
if (ret != LDB_SUCCESS) {
ldb_debug(ldb, LDB_DEBUG_WARNING, "Failed to apply linked attribute change '%s'\n%s\n",
ldb_errstring(ldb),
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index 1e4d5ac..8668b5e 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -246,7 +246,7 @@ static int replmd_process_backlink(struct ldb_module *module, struct la_backlink
}
msg->elements[0].flags = bl->active?LDB_FLAG_MOD_ADD:LDB_FLAG_MOD_DELETE;
- ret = dsdb_module_modify(module, msg, 0);
+ ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb, "Failed to %s backlink from %s to %s - %s",
bl->active?"add":"remove",
@@ -2662,7 +2662,7 @@ static int replmd_delete(struct ldb_module *module, struct ldb_request *req)
if (deletion_state == OBJECT_NOT_DELETED) {
/* now rename onto the new DN */
- ret = dsdb_module_rename(module, old_dn, new_dn, 0);
+ ret = dsdb_module_rename(module, old_dn, new_dn, DSDB_FLAG_NEXT_MODULE);
if (ret != LDB_SUCCESS){
DEBUG(0,(__location__ ": Failed to rename object from '%s' to '%s' - %s\n",
ldb_dn_get_linearized(old_dn),
@@ -2899,7 +2899,7 @@ static int replmd_replicated_apply_merge(struct replmd_replicated_request *ar)
* so it doesn't appear as an originating update */
ret = dsdb_module_rename(ar->module,
ar->search_msg->dn, msg->dn,
- 0);
+ DSDB_FLAG_NEXT_MODULE);
if (ret != LDB_SUCCESS) {
ldb_debug(ldb, LDB_DEBUG_FATAL,
"replmd_replicated_request rename %s => %s failed - %s\n",
@@ -3723,6 +3723,7 @@ linked_attributes[0]:
this GUID, returning attribute being modified. We will then
use this msg as the basis for a modify call */
ret = dsdb_module_search(module, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE, attrs,
+ DSDB_FLAG_NEXT_MODULE |
DSDB_SEARCH_SEARCH_ALL_PARTITIONS |
DSDB_SEARCH_SHOW_DELETED |
DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT |
@@ -3914,7 +3915,7 @@ linked_attributes[0]:
return ret;
}
- ret = dsdb_module_modify(module, msg, DSDB_MODIFY_RELAX);
+ ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE | DSDB_MODIFY_RELAX);
if (ret != LDB_SUCCESS) {
ldb_debug(ldb, LDB_DEBUG_WARNING, "Failed to apply linked attribute change '%s'\n%s\n",
ldb_errstring(ldb),
diff --git a/source4/dsdb/samdb/ldb_modules/ridalloc.c b/source4/dsdb/samdb/ldb_modules/ridalloc.c
index 6fc04fd..c14a679 100644
--- a/source4/dsdb/samdb/ldb_modules/ridalloc.c
+++ b/source4/dsdb/samdb/ldb_modules/ridalloc.c
@@ -266,7 +266,7 @@ static int ridalloc_create_rid_set_ntds(struct ldb_module *module, TALLOC_CTX *m
}
msg->elements[0].flags = LDB_FLAG_MOD_ADD;
- ret = dsdb_module_modify(module, msg, 0);
+ ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb, "Failed to add rIDSetReferences to %s - %s",
ldb_dn_get_linearized(msg->dn),
diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index 2b0e449..0cb0f3f 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -773,6 +773,7 @@ static int dsdb_find_optional_feature(struct ldb_module *module, struct ldb_cont
ret = dsdb_module_search(module, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE,
NULL,
+ DSDB_FLAG_NEXT_MODULE |
DSDB_SEARCH_SEARCH_ALL_PARTITIONS,
"(&(objectClass=msDS-OptionalFeature)"
"(msDS-OptionalFeatureGUID=%s))",GUID_string(tmp_ctx, &op_feature_guid));
@@ -841,7 +842,7 @@ static int rootdse_enable_recycle_bin(struct ldb_module *module,struct ldb_conte
ldb_msg_add_linearized_dn(msg, "msDS-EnabledFeature", op_feature_msg->dn);
msg->elements[el_count++].flags = LDB_FLAG_MOD_ADD;
- ret = dsdb_module_modify(module, msg, 0);
+ ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb,
"rootdse_enable_recycle_bin: Failed to modify object %s - %s",
@@ -852,7 +853,7 @@ static int rootdse_enable_recycle_bin(struct ldb_module *module,struct ldb_conte
}
msg->dn = op_feature_scope_dn;
- ret = dsdb_module_modify(module, msg, 0);
+ ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb,
"rootdse_enable_recycle_bin: Failed to modify object %s - %s",
diff --git a/source4/dsdb/samdb/ldb_modules/samba3sid.c b/source4/dsdb/samdb/ldb_modules/samba3sid.c
index 76848eb..b4dbd4a 100644
--- a/source4/dsdb/samdb/ldb_modules/samba3sid.c
+++ b/source4/dsdb/samdb/ldb_modules/samba3sid.c
@@ -52,7 +52,9 @@ static int samba3sid_next_sid(struct ldb_module *module,
const char *sambaSID;
ret = dsdb_module_search(module, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE,
- attrs, DSDB_SEARCH_SEARCH_ALL_PARTITIONS,
+ attrs,
+ DSDB_FLAG_NEXT_MODULE |
+ DSDB_SEARCH_SEARCH_ALL_PARTITIONS,
"(&(objectClass=sambaDomain)(sambaDomainName=%s))",
lp_sam_name(ldb_get_opaque(ldb, "loadparm")));
if (ret != LDB_SUCCESS) {
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 5b7e4be..70a6fd2 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -635,7 +635,8 @@ static int samldb_add_handle_msDS_IntId(struct samldb_ctx *ac)
ret = dsdb_module_search(ac->module, ac,
&ldb_res,
- schema_dn, LDB_SCOPE_ONELEVEL, NULL, 0,
+ schema_dn, LDB_SCOPE_ONELEVEL, NULL,
+ DSDB_FLAG_NEXT_MODULE,
"(msDS-IntId=%d)", msds_intid);
if (ret != LDB_SUCCESS) {
ldb_debug_set(ldb, LDB_DEBUG_ERROR,
@@ -1020,7 +1021,7 @@ static int samldb_schema_info_update(struct samldb_ctx *ac)
return LDB_ERR_OPERATIONS_ERROR;
}
- werr = dsdb_module_schema_info_update(ac->module, schema, 0);
+ werr = dsdb_module_schema_info_update(ac->module, schema, DSDB_FLAG_NEXT_MODULE);
if (!W_ERROR_IS_OK(werr)) {
ldb_debug_set(ldb, LDB_DEBUG_FATAL,
"samldb_schema_info_update: "
@@ -1118,7 +1119,7 @@ static int samldb_prim_group_change(struct samldb_ctx *ac)
return ret;
}
- ret = dsdb_module_modify(ac->module, msg, 0);
+ ret = dsdb_module_modify(ac->module, msg, DSDB_FLAG_NEXT_MODULE);
if (ret != LDB_SUCCESS) {
return ret;
}
@@ -1133,7 +1134,7 @@ static int samldb_prim_group_change(struct samldb_ctx *ac)
return ret;
}
- ret = dsdb_module_modify(ac->module, msg, 0);
+ ret = dsdb_module_modify(ac->module, msg, DSDB_FLAG_NEXT_MODULE);
if (ret != LDB_SUCCESS) {
return ret;
}
diff --git a/source4/dsdb/samdb/ldb_modules/schema_load.c b/source4/dsdb/samdb/ldb_modules/schema_load.c
index 4df6f1e..cffe529 100644
--- a/source4/dsdb/samdb/ldb_modules/schema_load.c
+++ b/source4/dsdb/samdb/ldb_modules/schema_load.c
@@ -191,7 +191,7 @@ static int dsdb_schema_from_db(struct ldb_module *module, struct ldb_dn *schema_
*/
ret = dsdb_module_search(module, tmp_ctx, &a_res,
schema_dn, LDB_SCOPE_ONELEVEL, NULL,
- 0,
+ DSDB_FLAG_NEXT_MODULE,
"(objectClass=attributeSchema)");
if (ret != LDB_SUCCESS) {
ldb_asprintf_errstring(ldb,
@@ -205,6 +205,7 @@ static int dsdb_schema_from_db(struct ldb_module *module, struct ldb_dn *schema_
*/
ret = dsdb_module_search(module, tmp_ctx, &c_res,
schema_dn, LDB_SCOPE_ONELEVEL, NULL,
+ DSDB_FLAG_NEXT_MODULE |
DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT,
"(objectClass=classSchema)");
if (ret != LDB_SUCCESS) {
diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
index a29de8e..4782702 100644
--- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c
+++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
@@ -52,7 +52,9 @@ static int subtree_delete(struct ldb_module *module, struct ldb_request *req)
/* see if we have any children */
ret = dsdb_module_search(module, req, &res, req->op.del.dn,
LDB_SCOPE_ONELEVEL, attrs,
- DSDB_SEARCH_SHOW_DELETED, "(objectClass=*)");
+ DSDB_FLAG_NEXT_MODULE |
+ DSDB_SEARCH_SHOW_DELETED,
+ "(objectClass=*)");
if (ret != LDB_SUCCESS) {
talloc_free(res);
return ret;
diff --git a/source4/dsdb/samdb/ldb_modules/util.c b/source4/dsdb/samdb/ldb_modules/util.c
index ec07350..ae08c00 100644
--- a/source4/dsdb/samdb/ldb_modules/util.c
+++ b/source4/dsdb/samdb/ldb_modules/util.c
@@ -159,6 +159,7 @@ int dsdb_module_search(struct ldb_module *module,
} else if (dsdb_flags & DSDB_FLAG_TOP_MODULE) {
ret = ldb_request(ldb_module_get_ctx(module), req);
} else {
+ SMB_ASSERT(dsdb_flags & DSDB_FLAG_NEXT_MODULE);
ret = ldb_next_request(module, req);
}
if (ret == LDB_SUCCESS) {
@@ -186,6 +187,7 @@ int dsdb_module_dn_by_guid(struct ldb_module *module, TALLOC_CTX *mem_ctx,
ret = dsdb_module_search(module, tmp_ctx, &res, NULL, LDB_SCOPE_SUBTREE,
attrs,
+ DSDB_FLAG_NEXT_MODULE |
DSDB_SEARCH_SHOW_DELETED |
DSDB_SEARCH_SEARCH_ALL_PARTITIONS |
DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT,
@@ -286,6 +288,7 @@ int dsdb_module_modify(struct ldb_module *module,
} else if (dsdb_flags & DSDB_FLAG_TOP_MODULE) {
ret = ldb_request(ldb_module_get_ctx(module), mod_req);
} else {
+ SMB_ASSERT(dsdb_flags & DSDB_FLAG_NEXT_MODULE);
ret = ldb_next_request(module, mod_req);
}
if (ret == LDB_SUCCESS) {
@@ -343,6 +346,7 @@ int dsdb_module_rename(struct ldb_module *module,
} else if (dsdb_flags & DSDB_FLAG_TOP_MODULE) {
ret = ldb_request(ldb_module_get_ctx(module), req);
} else {
+ SMB_ASSERT(dsdb_flags & DSDB_FLAG_NEXT_MODULE);
ret = ldb_next_request(module, req);
}
if (ret == LDB_SUCCESS) {
@@ -397,6 +401,7 @@ int dsdb_module_add(struct ldb_module *module,
} else if (dsdb_flags & DSDB_FLAG_TOP_MODULE) {
ret = ldb_request(ldb_module_get_ctx(module), req);
} else {
+ SMB_ASSERT(dsdb_flags & DSDB_FLAG_NEXT_MODULE);
ret = ldb_next_request(module, req);
}
if (ret == LDB_SUCCESS) {
@@ -451,6 +456,7 @@ int dsdb_module_del(struct ldb_module *module,
} else if (dsdb_flags & DSDB_FLAG_TOP_MODULE) {
ret = ldb_request(ldb_module_get_ctx(module), req);
} else {
+ SMB_ASSERT(dsdb_flags & DSDB_FLAG_NEXT_MODULE);
ret = ldb_next_request(module, req);
}
if (ret == LDB_SUCCESS) {
@@ -663,7 +669,7 @@ int dsdb_module_constrainted_update_integer(struct ldb_module *module, struct ld
}
v2 = data_blob_string_const(vstring);
- ret = dsdb_module_modify(module, msg, 0);
+ ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
talloc_free(msg);
return ret;
}
@@ -699,7 +705,7 @@ int dsdb_module_set_integer(struct ldb_module *module, struct ldb_dn *dn,
}
msg->elements[0].flags = LDB_FLAG_MOD_REPLACE;
- ret = dsdb_module_modify(module, msg, 0);
+ ret = dsdb_module_modify(module, msg, DSDB_FLAG_NEXT_MODULE);
talloc_free(msg);
return ret;
}
diff --git a/source4/dsdb/samdb/ldb_modules/util.h b/source4/dsdb/samdb/ldb_modules/util.h
index 9ba2e33..8634f76 100644
--- a/source4/dsdb/samdb/ldb_modules/util.h
+++ b/source4/dsdb/samdb/ldb_modules/util.h
@@ -30,6 +30,7 @@ struct dsdb_fsmo_extended_op;
/* extend the dsdb_request_add_controls() flags for module
specific functions */
+#define DSDB_FLAG_NEXT_MODULE 0x00100000
#define DSDB_FLAG_OWN_MODULE 0x00400000
#define DSDB_FLAG_TOP_MODULE 0x00800000
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index b5d8ae4..da5ad3c 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -366,6 +366,7 @@ int dsdb_setup_schema_inversion(struct ldb_context *ldb, struct dsdb_schema *sch
int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
{
+ struct dsdb_schema *old_schema;
int ret;
ret = dsdb_setup_sorted_accessors(ldb, schema);
@@ -378,10 +379,17 @@ int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
return ret;
}
+ old_schema = ldb_get_opaque(ldb, "dsdb_schema");
+
ret = ldb_set_opaque(ldb, "dsdb_schema", schema);
if (ret != LDB_SUCCESS) {
return ret;
}
+ /* Remove the refernece to the schema we just overwrote - if there was none, NULL is harmless here */
+ if (old_schema != schema) {
+ talloc_unlink(ldb, old_schema);
+ talloc_steal(ldb, schema);
+ }
ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", NULL);
if (ret != LDB_SUCCESS) {
@@ -394,8 +402,6 @@ int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
return ret;
}
- talloc_steal(ldb, schema);
-
return LDB_SUCCESS;
}
@@ -411,11 +417,16 @@ int dsdb_reference_schema(struct ldb_context *ldb, struct dsdb_schema *schema,
bool write_attributes)
{
int ret;
+ struct dsdb_schema *old_schema;
+ old_schema = ldb_get_opaque(ldb, "dsdb_schema");
ret = ldb_set_opaque(ldb, "dsdb_schema", schema);
if (ret != LDB_SUCCESS) {
return ret;
}
+ /* Remove the refernece to the schema we just overwrote - if there was none, NULL is harmless here */
+ talloc_unlink(ldb, old_schema);
+
if (talloc_reference(ldb, schema) == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -438,7 +449,6 @@ int dsdb_set_global_schema(struct ldb_context *ldb)
if (!global_schema) {
return LDB_SUCCESS;
}
-
ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", use_global_schema);
if (ret != LDB_SUCCESS) {
return ret;
@@ -468,6 +478,10 @@ struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb, TALLOC_CTX *referen
struct dsdb_schema *schema_out;
struct dsdb_schema *schema_in;
bool use_global_schema;
+ TALLOC_CTX *tmp_ctx = talloc_new(reference_ctx);
+ if (!tmp_ctx) {
+ return NULL;
+ }
/* see if we have a cached copy */
use_global_schema = (ldb_get_opaque(ldb, "dsdb_use_global_schema") != NULL);
@@ -478,24 +492,29 @@ struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb, TALLOC_CTX *referen
schema_in = talloc_get_type(p, struct dsdb_schema);
if (!schema_in) {
+ talloc_free(tmp_ctx);
return NULL;
}
}
if (schema_in->refresh_fn && !schema_in->refresh_in_progress) {
+ if (!talloc_reference(tmp_ctx, schema_in)) {
+ /* ensure that the schema_in->refresh_in_progress remains valid for the right amount of time */
+ talloc_free(tmp_ctx);
+ return NULL;
+ }
schema_in->refresh_in_progress = true;
/* This may change schema, if it needs to reload it from disk */
schema_out = schema_in->refresh_fn(schema_in->loaded_from_module,
schema_in,
use_global_schema);
schema_in->refresh_in_progress = false;
- if (schema_out != schema_in) {
- talloc_unlink(schema_in, ldb);
- }
} else {
schema_out = schema_in;
}
+ /* This removes the extra reference above */
+ talloc_free(tmp_ctx);
if (!reference_ctx) {
return schema_out;
} else {
--
Samba Shared Repository
More information about the samba-cvs
mailing list