summaryrefslogtreecommitdiff
path: root/source4/torture/libnet
diff options
context:
space:
mode:
authorRafal Szczesniak <mimir@samba.org>2007-05-11 21:48:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:52:19 -0500
commita4e4ff927353e63b0dffb0d45dbd394b1938cadb (patch)
treeb024e2dd6d51866c5fc40b3c6774b0c0b22fe89e /source4/torture/libnet
parent945cb016a444a2170685e15e427167d8305542d2 (diff)
downloadsamba-a4e4ff927353e63b0dffb0d45dbd394b1938cadb.tar.gz
samba-a4e4ff927353e63b0dffb0d45dbd394b1938cadb.tar.bz2
samba-a4e4ff927353e63b0dffb0d45dbd394b1938cadb.zip
r22810: when a test runs against domain controller use domain name
instead of target host name specified in binding string. metze: this fixes the problem with passing name resolution down the socket wrapper calls. NET tests now run against $SERVER flawlessly. rafal (This used to be commit 44eacd8654a26dbd473050705f28966ce08ccd70)
Diffstat (limited to 'source4/torture/libnet')
-rw-r--r--source4/torture/libnet/libnet_domain.c55
-rw-r--r--source4/torture/libnet/libnet_rpc.c21
2 files changed, 58 insertions, 18 deletions
diff --git a/source4/torture/libnet/libnet_domain.c b/source4/torture/libnet/libnet_domain.c
index beeafa3753..9d5d9972c8 100644
--- a/source4/torture/libnet/libnet_domain.c
+++ b/source4/torture/libnet/libnet_domain.c
@@ -129,16 +129,13 @@ BOOL torture_domain_open_lsa(struct torture_context *torture)
struct libnet_context *ctx;
struct libnet_DomainOpen r;
struct lsa_Close lsa_close;
- struct dcerpc_binding *binding;
struct policy_handle h;
- const char *bindstr;
-
- bindstr = torture_setting_string(torture, "binding", NULL);
- status = dcerpc_parse_binding(torture, bindstr, &binding);
- if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to parse binding string\n");
- return False;
- }
+ const char *domain_name;
+
+ /* we're accessing domain controller so the domain name should be
+ passed (it's going to be resolved to dc name and address) instead
+ of specific server name. */
+ domain_name = lp_workgroup();
ctx = libnet_context_init(NULL);
if (ctx == NULL) {
@@ -150,7 +147,7 @@ BOOL torture_domain_open_lsa(struct torture_context *torture)
ZERO_STRUCT(r);
r.in.type = DOMAIN_LSA;
- r.in.domain_name = binding->host;
+ r.in.domain_name = domain_name;
r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
status = libnet_DomainOpen(ctx, torture, &r);
@@ -229,7 +226,7 @@ BOOL torture_domain_close_lsa(struct torture_context *torture)
ctx->lsa.access_mask = access_mask;
ctx->lsa.handle = h;
/* we have to use pipe's event context, otherwise the call will
- hang indefinately */
+ hang indefinitely */
ctx->event_ctx = p->conn->event_ctx;
ZERO_STRUCT(r);
@@ -257,9 +254,9 @@ BOOL torture_domain_open_samr(struct torture_context *torture)
struct event_context *evt_ctx=NULL;
TALLOC_CTX *mem_ctx;
struct policy_handle domain_handle, handle;
- struct lsa_String name;
struct libnet_DomainOpen io;
struct samr_Close r;
+ const char *domain_name;
BOOL ret = True;
mem_ctx = talloc_init("test_domainopen_lsa");
@@ -268,7 +265,10 @@ BOOL torture_domain_open_samr(struct torture_context *torture)
ctx = libnet_context_init(evt_ctx);
ctx->cred = cmdline_credentials;
- name.string = lp_workgroup();
+ /* we're accessing domain controller so the domain name should be
+ passed (it's going to be resolved to dc name and address) instead
+ of specific server name. */
+ domain_name = lp_workgroup();
/*
* Testing synchronous version
@@ -276,7 +276,7 @@ BOOL torture_domain_open_samr(struct torture_context *torture)
printf("opening domain\n");
io.in.type = DOMAIN_SAMR;
- io.in.domain_name = name.string;
+ io.in.domain_name = domain_name;
io.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
status = libnet_DomainOpen(ctx, mem_ctx, &io);
@@ -411,6 +411,31 @@ BOOL torture_domain_list(struct torture_context *torture)
mem_ctx = talloc_init("torture_domain_close_samr");
+ /*
+ * querying the domain list using default buffer size
+ */
+
+ ZERO_STRUCT(r);
+ r.in.hostname = binding->host;
+
+ status = libnet_DomainList(ctx, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ ret = False;
+ goto done;
+ }
+
+ d_printf("Received list or domains (everything in one piece):\n");
+
+ for (i = 0; i < r.out.count; i++) {
+ d_printf("Name[%d]: %s\n", i, r.out.domains[i].name);
+ }
+
+ /*
+ * querying the domain list using specified (much smaller) buffer size
+ */
+
+ ctx->samr.buf_size = 32;
+
ZERO_STRUCT(r);
r.in.hostname = binding->host;
@@ -420,7 +445,7 @@ BOOL torture_domain_list(struct torture_context *torture)
goto done;
}
- d_printf("Received list or domains:\n");
+ d_printf("Received list or domains (collected in more than one round):\n");
for (i = 0; i < r.out.count; i++) {
d_printf("Name[%d]: %s\n", i, r.out.domains[i].name);
diff --git a/source4/torture/libnet/libnet_rpc.c b/source4/torture/libnet/libnet_rpc.c
index 19802df72d..8082572e7b 100644
--- a/source4/torture/libnet/libnet_rpc.c
+++ b/source4/torture/libnet/libnet_rpc.c
@@ -156,6 +156,7 @@ BOOL torture_rpc_connect_pdc(struct torture_context *torture)
NTSTATUS status;
struct dcerpc_binding *binding;
const char *bindstr;
+ const char *domain_name;
bindstr = torture_setting_string(torture, "binding", NULL);
status = dcerpc_parse_binding(torture, bindstr, &binding);
@@ -164,7 +165,11 @@ BOOL torture_rpc_connect_pdc(struct torture_context *torture)
return False;
}
- return torture_rpc_connect(torture, level, NULL, binding->host);
+ /* we're accessing domain controller so the domain name should be
+ passed (it's going to be resolved to dc name and address) instead
+ of specific server name. */
+ domain_name = lp_workgroup();
+ return torture_rpc_connect(torture, level, NULL, domain_name);
}
@@ -174,6 +179,7 @@ BOOL torture_rpc_connect_dc(struct torture_context *torture)
NTSTATUS status;
struct dcerpc_binding *binding;
const char *bindstr;
+ const char *domain_name;
bindstr = torture_setting_string(torture, "binding", NULL);
status = dcerpc_parse_binding(torture, bindstr, &binding);
@@ -182,7 +188,11 @@ BOOL torture_rpc_connect_dc(struct torture_context *torture)
return False;
}
- return torture_rpc_connect(torture, level, NULL, binding->host);
+ /* we're accessing domain controller so the domain name should be
+ passed (it's going to be resolved to dc name and address) instead
+ of specific server name. */
+ domain_name = lp_workgroup();
+ return torture_rpc_connect(torture, level, NULL, domain_name);
}
@@ -192,6 +202,7 @@ BOOL torture_rpc_connect_dc_info(struct torture_context *torture)
NTSTATUS status;
struct dcerpc_binding *binding;
const char *bindstr;
+ const char *domain_name;
bindstr = torture_setting_string(torture, "binding", NULL);
status = dcerpc_parse_binding(torture, bindstr, &binding);
@@ -200,7 +211,11 @@ BOOL torture_rpc_connect_dc_info(struct torture_context *torture)
return False;
}
- return torture_rpc_connect(torture, level, NULL, binding->host);
+ /* we're accessing domain controller so the domain name should be
+ passed (it's going to be resolved to dc name and address) instead
+ of specific server name. */
+ domain_name = lp_workgroup();
+ return torture_rpc_connect(torture, level, NULL, domain_name);
}