diff options
author | Andrew Bartlett <abartlet@samba.org> | 2012-08-14 16:08:47 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2012-08-14 10:05:14 +0200 |
commit | 956678685325a79a315f4ef19c0d834fd1747e4c (patch) | |
tree | 62b89848fbf552187a07d1d520702112f3b4ac45 /source4/dsdb/samdb | |
parent | 0f2a87b547be43b4764c48350fd03ff22e086806 (diff) | |
download | samba-956678685325a79a315f4ef19c0d834fd1747e4c.tar.gz samba-956678685325a79a315f4ef19c0d834fd1747e4c.tar.bz2 samba-956678685325a79a315f4ef19c0d834fd1747e4c.zip |
s4-dsdb: Add mem_ctx argument to samdb_ntds_settings_dn
As this value is calculated new each time, we need to give it a context to live on.
If the value is the forced value during provision, a reference is taken.
This was responsible for the memory leak in the replication process. In the
example I was given, this DN appeared in memory 13596 times!
Andrew Bartlett
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Tue Aug 14 10:05:14 CEST 2012 on sn-devel-104
Diffstat (limited to 'source4/dsdb/samdb')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/objectclass.c | 2 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/ridalloc.c | 4 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/rootdse.c | 4 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/util.c | 7 |
4 files changed, 9 insertions, 8 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index d431367b5a..7d34b4e8c3 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -1298,7 +1298,7 @@ static int objectclass_do_delete(struct oc_context *ac) } /* DC's ntDSDSA object */ - if (ldb_dn_compare(ac->req->op.del.dn, samdb_ntds_settings_dn(ldb)) == 0) { + if (ldb_dn_compare(ac->req->op.del.dn, samdb_ntds_settings_dn(ldb, ac)) == 0) { ldb_asprintf_errstring(ldb, "objectclass: Cannot delete %s, it's the DC's ntDSDSA object!", ldb_dn_get_linearized(ac->req->op.del.dn)); return LDB_ERR_UNWILLING_TO_PERFORM; diff --git a/source4/dsdb/samdb/ldb_modules/ridalloc.c b/source4/dsdb/samdb/ldb_modules/ridalloc.c index 2cef1c445f..915248c440 100644 --- a/source4/dsdb/samdb/ldb_modules/ridalloc.c +++ b/source4/dsdb/samdb/ldb_modules/ridalloc.c @@ -407,7 +407,7 @@ static int ridalloc_create_own_rid_set(struct ldb_module *module, TALLOC_CTX *me return ret; } - if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), fsmo_role_dn) != 0) { + if (ldb_dn_compare(samdb_ntds_settings_dn(ldb, tmp_ctx), fsmo_role_dn) != 0) { ridalloc_poke_rid_manager(module); ldb_asprintf_errstring(ldb, "Remote RID Set allocation needs refresh"); talloc_free(tmp_ctx); @@ -448,7 +448,7 @@ static int ridalloc_new_own_pool(struct ldb_module *module, uint64_t *new_pool, return ret; } - if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), fsmo_role_dn) != 0) { + if (ldb_dn_compare(samdb_ntds_settings_dn(ldb, tmp_ctx), fsmo_role_dn) != 0) { ridalloc_poke_rid_manager(module); ldb_asprintf_errstring(ldb, "Remote RID Set allocation needs refresh"); talloc_free(tmp_ctx); diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c index 6859d04e59..9ae5b20eb1 100644 --- a/source4/dsdb/samdb/ldb_modules/rootdse.c +++ b/source4/dsdb/samdb/ldb_modules/rootdse.c @@ -197,7 +197,7 @@ static int dsdb_module_we_are_master(struct ldb_module *module, struct ldb_dn *d return LDB_SUCCESS; } - *master = (ldb_dn_compare(owner_dn, samdb_ntds_settings_dn(ldb_module_get_ctx(module))) == 0); + *master = (ldb_dn_compare(owner_dn, samdb_ntds_settings_dn(ldb_module_get_ctx(module), tmp_ctx)) == 0); talloc_free(tmp_ctx); return LDB_SUCCESS; } @@ -1073,7 +1073,7 @@ static int rootdse_enable_recycle_bin(struct ldb_module *module,struct ldb_conte } tmp_ctx = talloc_new(mem_ctx); - ntds_settings_dn = samdb_ntds_settings_dn(ldb); + ntds_settings_dn = samdb_ntds_settings_dn(ldb, tmp_ctx); if (!ntds_settings_dn) { talloc_free(tmp_ctx); return ldb_error(ldb, LDB_ERR_OPERATIONS_ERROR, "Failed to find NTDS settings DN"); diff --git a/source4/dsdb/samdb/ldb_modules/util.c b/source4/dsdb/samdb/ldb_modules/util.c index 0f1a61236f..253d5c1d2c 100644 --- a/source4/dsdb/samdb/ldb_modules/util.c +++ b/source4/dsdb/samdb/ldb_modules/util.c @@ -691,15 +691,16 @@ int dsdb_check_optional_feature(struct ldb_module *module, struct GUID op_featur struct ldb_message_element *el; struct ldb_dn *feature_dn; - feature_dn = samdb_ntds_settings_dn(ldb_module_get_ctx(module)); + tmp_ctx = talloc_new(ldb); + + feature_dn = samdb_ntds_settings_dn(ldb_module_get_ctx(module), tmp_ctx); if (feature_dn == NULL) { + talloc_free(tmp_ctx); return ldb_operr(ldb_module_get_ctx(module)); } *feature_enabled = false; - tmp_ctx = talloc_new(ldb); - ret = dsdb_module_search_dn(module, tmp_ctx, &res, feature_dn, attrs, DSDB_FLAG_NEXT_MODULE, NULL); if (ret != LDB_SUCCESS) { ldb_asprintf_errstring(ldb, |