diff options
author | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-09-18 20:42:18 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2010-09-24 09:25:42 +1000 |
commit | b6eb1b207222ef776d1e3ec6bdf807dbd1b85911 (patch) | |
tree | e611f1a42620b3daafa86e8162d19fda4b48860f /source4/torture | |
parent | 65ca9e691bb12d37de39e382c897d7b41d846c26 (diff) | |
download | samba-b6eb1b207222ef776d1e3ec6bdf807dbd1b85911.tar.gz samba-b6eb1b207222ef776d1e3ec6bdf807dbd1b85911.tar.bz2 samba-b6eb1b207222ef776d1e3ec6bdf807dbd1b85911.zip |
s4:torture/rpc/netlogon.c - remove the dependency on "samdb_server_site_name"
Since this one relies on the right server loadparm context which we aren't able
to provide over torture.
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/rpc/netlogon.c | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c index c2eb872462..9758185046 100644 --- a/source4/torture/rpc/netlogon.c +++ b/source4/torture/rpc/netlogon.c @@ -2357,6 +2357,55 @@ static bool test_netr_DsRGetDCNameEx2(struct torture_context *tctx, info->dc_site_name); } +/* This is a substitution for "samdb_server_site_name" which relies on the + * correct "lp_ctx" and therefore can't be used here. */ +static const char *server_site_name(struct torture_context *tctx, + struct ldb_context *ldb) +{ + TALLOC_CTX *tmp_ctx; + struct ldb_dn *dn, *server_dn; + const struct ldb_val *site_name_val; + const char *server_dn_str, *site_name; + + tmp_ctx = talloc_new(ldb); + if (tmp_ctx == NULL) { + goto failed; + } + + dn = ldb_dn_new(tmp_ctx, ldb, ""); + if (dn == NULL) { + goto failed; + } + + server_dn_str = samdb_search_string(ldb, tmp_ctx, dn, "serverName", + NULL); + if (server_dn_str == NULL) { + goto failed; + } + + server_dn = ldb_dn_new(tmp_ctx, ldb, server_dn_str); + if (server_dn == NULL) { + goto failed; + } + + /* CN=<Server name>, CN=Servers, CN=<Site name>, CN=Sites, ... */ + site_name_val = ldb_dn_get_component_val(server_dn, 2); + if (site_name_val == NULL) { + goto failed; + } + + site_name = (const char *) site_name_val->data; + + talloc_steal(tctx, site_name); + talloc_free(tmp_ctx); + + return site_name; + +failed: + talloc_free(tmp_ctx); + return NULL; +} + static bool test_netr_DsrGetDcSiteCoverageW(struct torture_context *tctx, struct dcerpc_pipe *p) { @@ -2392,7 +2441,7 @@ static bool test_netr_DsrGetDcSiteCoverageW(struct torture_context *tctx, "we should per default only get the default site"); if (sam_ctx != NULL) { torture_assert_casestr_equal(tctx, ctr->sites[0].string, - samdb_server_site_name(sam_ctx, tctx), + server_site_name(tctx, sam_ctx), "didn't return default site"); } @@ -2514,7 +2563,7 @@ static bool test_netr_DsRAddressToSitenamesW(struct torture_context *tctx, for (i = 0; i < 3; i++) { torture_assert_casestr_equal(tctx, ctr->sitename[i].string, - samdb_server_site_name(sam_ctx, tctx), + server_site_name(tctx, sam_ctx), "didn't return default site"); } for (i = 3; i < 6; i++) { @@ -2523,7 +2572,7 @@ static bool test_netr_DsRAddressToSitenamesW(struct torture_context *tctx, if (torture_setting_bool(tctx, "samba4", false)) { torture_assert_casestr_equal(tctx, ctr->sitename[i].string, - samdb_server_site_name(sam_ctx, tctx), + server_site_name(tctx, sam_ctx), "didn't return default site"); } } @@ -2691,7 +2740,7 @@ static bool test_netr_DsRAddressToSitenamesExW(struct torture_context *tctx, for (i = 0; i < 3; i++) { torture_assert_casestr_equal(tctx, ctr->sitename[i].string, - samdb_server_site_name(sam_ctx, tctx), + server_site_name(tctx, sam_ctx), "didn't return default site"); torture_assert(tctx, ctr->subnetname[i].string == NULL, "subnet should be null"); @@ -2702,7 +2751,7 @@ static bool test_netr_DsRAddressToSitenamesExW(struct torture_context *tctx, if (torture_setting_bool(tctx, "samba4", false)) { torture_assert_casestr_equal(tctx, ctr->sitename[i].string, - samdb_server_site_name(sam_ctx, tctx), + server_site_name(tctx, sam_ctx), "didn't return default site"); } torture_assert(tctx, ctr->subnetname[i].string == NULL, |