summaryrefslogtreecommitdiff
path: root/source4/torture/rpc
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-08-28 19:03:08 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:03:03 -0500
commit3e7203d0b34a031e10aeaaf04f246a1de8376ab4 (patch)
treecb3b6303112f2b945650b2a778d2eb32cbba3e59 /source4/torture/rpc
parent53d10b44faa77293e380bd1cda6168acc05a5493 (diff)
downloadsamba-3e7203d0b34a031e10aeaaf04f246a1de8376ab4.tar.gz
samba-3e7203d0b34a031e10aeaaf04f246a1de8376ab4.tar.bz2
samba-3e7203d0b34a031e10aeaaf04f246a1de8376ab4.zip
r24755: Use common code for finding the RPC binding in the torture tests.
(This used to be commit e3310e773924ddd2129e8ca1a86e23d0f713c19c)
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r--source4/torture/rpc/bind.c4
-rw-r--r--source4/torture/rpc/mgmt.c9
-rw-r--r--source4/torture/rpc/rpc.c70
-rw-r--r--source4/torture/rpc/samlogon.c4
-rw-r--r--source4/torture/rpc/samsync.c7
-rw-r--r--source4/torture/rpc/scanner.c10
-rw-r--r--source4/torture/rpc/spoolss.c31
-rw-r--r--source4/torture/rpc/wkssvc.c4
8 files changed, 56 insertions, 83 deletions
diff --git a/source4/torture/rpc/bind.c b/source4/torture/rpc/bind.c
index 33885573e6..c7848f4a89 100644
--- a/source4/torture/rpc/bind.c
+++ b/source4/torture/rpc/bind.c
@@ -45,16 +45,14 @@ BOOL torture_multi_bind(struct torture_context *torture)
{
struct dcerpc_pipe *p;
struct dcerpc_binding *binding;
- const char *binding_string = torture_setting_string(torture, "binding", NULL);
TALLOC_CTX *mem_ctx;
NTSTATUS status;
BOOL ret;
mem_ctx = talloc_init("torture_multi_bind");
- status = dcerpc_parse_binding(mem_ctx, binding_string, &binding);
+ status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to parse dcerpc binding '%s'\n", binding_string);
talloc_free(mem_ctx);
return False;
}
diff --git a/source4/torture/rpc/mgmt.c b/source4/torture/rpc/mgmt.c
index ec3e390afa..6d0c3d56c9 100644
--- a/source4/torture/rpc/mgmt.c
+++ b/source4/torture/rpc/mgmt.c
@@ -196,21 +196,14 @@ BOOL torture_rpc_mgmt(struct torture_context *torture)
struct dcerpc_pipe *p;
TALLOC_CTX *mem_ctx, *loop_ctx;
BOOL ret = True;
- const char *binding = torture_setting_string(torture, "binding", NULL);
const struct ndr_interface_list *l;
struct dcerpc_binding *b;
mem_ctx = talloc_init("torture_rpc_mgmt");
- if (!binding) {
- printf("You must supply a ncacn binding string\n");
- return False;
- }
-
- status = dcerpc_parse_binding(mem_ctx, binding, &b);
+ status = torture_rpc_binding(torture, &b);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
- printf("Failed to parse binding '%s'\n", binding);
return False;
}
diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c
index 3d8a56ffba..af7e05a9f0 100644
--- a/source4/torture/rpc/rpc.c
+++ b/source4/torture/rpc/rpc.c
@@ -33,25 +33,45 @@ struct torture_rpc_tcase {
struct dcerpc_pipe *pipe;
};
+NTSTATUS torture_rpc_binding(struct torture_context *tctx,
+ struct dcerpc_binding **binding)
+{
+ NTSTATUS status;
+ const char *binding_string = torture_setting_string(tctx, "binding", NULL);
+
+ if (binding_string == NULL) {
+ torture_comment(tctx, "You must specify a ncacn binding string\n");
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ status = dcerpc_parse_binding(tctx, binding_string, binding);
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(0,("Failed to parse dcerpc binding '%s'\n", binding_string));
+ return status;
+ }
+
+ return NT_STATUS_OK;
+}
+
/* open a rpc connection to the chosen binding string */
_PUBLIC_ NTSTATUS torture_rpc_connection(struct torture_context *tctx,
struct dcerpc_pipe **p,
const struct ndr_interface_table *table)
{
NTSTATUS status;
- const char *binding = torture_setting_string(tctx, "binding", NULL);
+ struct dcerpc_binding *binding;
- if (!binding) {
- printf("You must specify a ncacn binding string\n");
- return NT_STATUS_INVALID_PARAMETER;
- }
+ status = torture_rpc_binding(tctx, &binding);
+ if (NT_STATUS_IS_ERR(status))
+ return status;
- status = dcerpc_pipe_connect(tctx,
+ status = dcerpc_pipe_connect_b(tctx,
p, binding, table,
cmdline_credentials, NULL);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to connect to remote server: %s %s\n", binding, nt_errstr(status));
+ if (NT_STATUS_IS_ERR(status)) {
+ printf("Failed to connect to remote server: %s %s\n",
+ dcerpc_binding_string(tctx, binding), nt_errstr(status));
}
return status;
@@ -64,28 +84,18 @@ NTSTATUS torture_rpc_connection_transport(struct torture_context *tctx,
enum dcerpc_transport_t transport,
uint32_t assoc_group_id)
{
- NTSTATUS status;
- const char *binding = torture_setting_string(tctx, "binding", NULL);
- struct dcerpc_binding *b;
+ NTSTATUS status;
+ struct dcerpc_binding *binding;
TALLOC_CTX *mem_ctx = talloc_named(tctx, 0, "torture_rpc_connection_smb");
- if (!binding) {
- printf("You must specify a ncacn binding string\n");
- talloc_free(mem_ctx);
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- status = dcerpc_parse_binding(mem_ctx, binding, &b);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("Failed to parse dcerpc binding '%s'\n", binding));
- talloc_free(mem_ctx);
+ status = torture_rpc_binding(tctx, &binding);
+ if (NT_STATUS_IS_ERR(status))
return status;
- }
- b->transport = transport;
- b->assoc_group_id = assoc_group_id;
+ binding->transport = transport;
+ binding->assoc_group_id = assoc_group_id;
- status = dcerpc_pipe_connect_b(mem_ctx, p, b, table,
+ status = dcerpc_pipe_connect_b(mem_ctx, p, binding, table,
cmdline_credentials, NULL);
if (NT_STATUS_IS_OK(status)) {
@@ -102,13 +112,17 @@ static bool torture_rpc_setup_anonymous(struct torture_context *tctx,
{
struct cli_credentials *anon_credentials;
NTSTATUS status;
- const char *binding = torture_setting_string(tctx, "binding", NULL);
+ struct dcerpc_binding *binding;
struct torture_rpc_tcase *tcase = talloc_get_type(
tctx->active_tcase, struct torture_rpc_tcase);
+ status = torture_rpc_binding(tctx, &binding);
+ if (NT_STATUS_IS_ERR(status))
+ return false;
+
anon_credentials = cli_credentials_init_anon(tctx);
- status = dcerpc_pipe_connect(tctx,
+ status = dcerpc_pipe_connect_b(tctx,
(struct dcerpc_pipe **)data,
binding,
tcase->table,
@@ -254,7 +268,7 @@ NTSTATUS torture_rpc_init(void)
torture_suite_add_suite(suite, torture_rpc_unixinfo());
torture_suite_add_suite(suite, torture_rpc_eventlog());
torture_suite_add_suite(suite, torture_rpc_atsvc());
- torture_suite_add_suite(suite, torture_rpc_wkssvc());
+ torture_suite_add_suite(suite, torture_rpc_wkssvc(suite));
torture_suite_add_suite(suite, torture_rpc_handles(suite));
torture_suite_add_suite(suite, torture_rpc_winreg(suite));
torture_suite_add_simple_test(suite, "SPOOLSS", torture_rpc_spoolss);
diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c
index 832bb68072..da74067336 100644
--- a/source4/torture/rpc/samlogon.c
+++ b/source4/torture/rpc/samlogon.c
@@ -1484,7 +1484,6 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
char *user_password, *user_password_wrong_wks, *user_password_wrong_time;
const char *old_user_password;
char *test_machine_account;
- const char *binding = torture_setting_string(torture, "binding", NULL);
const char *userdomain;
struct samr_SetUserInfo s;
union samr_UserInfo u;
@@ -1582,9 +1581,8 @@ BOOL torture_rpc_samlogon(struct torture_context *torture)
goto failed;
}
- status = dcerpc_parse_binding(mem_ctx, binding, &b);
+ status = torture_rpc_binding(torture, &b);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("Bad binding string %s\n", binding);
ret = False;
goto failed;
}
diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c
index 4b9392bf3c..358bf8791a 100644
--- a/source4/torture/rpc/samsync.c
+++ b/source4/torture/rpc/samsync.c
@@ -1409,7 +1409,6 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
struct test_join *user_ctx;
const char *machine_password;
const char *wksta_machine_password;
- const char *binding = torture_setting_string(torture, "binding", NULL);
struct dcerpc_binding *b;
struct dcerpc_binding *b_netlogon_wksta;
struct samr_Connect c;
@@ -1536,9 +1535,8 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
goto failed;
}
- status = dcerpc_parse_binding(mem_ctx, binding, &b);
+ status = torture_rpc_binding(torture, &b);
if (!NT_STATUS_IS_OK(status)) {
- printf("Bad binding string %s\n", binding);
ret = False;
goto failed;
}
@@ -1574,9 +1572,8 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
- status = dcerpc_parse_binding(mem_ctx, binding, &b_netlogon_wksta);
+ status = torture_rpc_binding(torture, &b_netlogon_wksta);
if (!NT_STATUS_IS_OK(status)) {
- printf("Bad binding string %s\n", binding);
ret = False;
goto failed;
}
diff --git a/source4/torture/rpc/scanner.c b/source4/torture/rpc/scanner.c
index da4fc84f6f..b2dd99fd66 100644
--- a/source4/torture/rpc/scanner.c
+++ b/source4/torture/rpc/scanner.c
@@ -100,21 +100,13 @@ BOOL torture_rpc_scanner(struct torture_context *torture)
TALLOC_CTX *mem_ctx, *loop_ctx;
BOOL ret = True;
const struct ndr_interface_list *l;
- const char *binding = torture_setting_string(torture, "binding", NULL);
struct dcerpc_binding *b;
mem_ctx = talloc_init("torture_rpc_scanner");
- if (!binding) {
- talloc_free(mem_ctx);
- printf("You must supply a ncacn binding string\n");
- return False;
- }
-
- status = dcerpc_parse_binding(mem_ctx, binding, &b);
+ status = torture_rpc_binding(torture, &b);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(mem_ctx);
- printf("Failed to parse binding '%s'\n", binding);
return False;
}
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index a9232f6df3..0bf0ee87a1 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -2080,19 +2080,15 @@ bool torture_rpc_spoolss(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
- TALLOC_CTX *mem_ctx;
BOOL ret = True;
struct test_spoolss_context *ctx;
- mem_ctx = talloc_init("torture_rpc_spoolss");
-
status = torture_rpc_connection(torture, &p, &ndr_table_spoolss);
if (!NT_STATUS_IS_OK(status)) {
- talloc_free(mem_ctx);
return False;
}
- ctx = talloc_zero(mem_ctx, struct test_spoolss_context);
+ ctx = talloc_zero(torture, struct test_spoolss_context);
ctx->p = p;
ret &= test_OpenPrinter_server(ctx);
@@ -2110,34 +2106,19 @@ bool torture_rpc_spoolss(struct torture_context *torture)
ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "OSVersion");
ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "OSVersionEx");
ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "DNSMachineName");
-
ret &= test_EnumForms(ctx->p, ctx, &ctx->server_handle, True);
-
ret &= test_AddForm(ctx->p, ctx, &ctx->server_handle, True);
-
ret &= test_EnumPorts(ctx);
-
ret &= test_GetPrinterDriverDirectory(ctx);
-
ret &= test_EnumPrinterDrivers(ctx);
-
ret &= test_EnumMonitors(ctx);
-
ret &= test_EnumPrintProcessors(ctx);
-
ret &= test_EnumPrinters(ctx);
-
- ret &= test_OpenPrinter_badnames(p, mem_ctx);
-
- ret &= test_AddPort(p, mem_ctx);
-
- ret &= test_EnumPorts_old(p, mem_ctx);
-
- ret &= test_EnumPrinters_old(p, mem_ctx);
-
- ret &= test_EnumPrinterDrivers_old(p, mem_ctx);
-
- talloc_free(mem_ctx);
+ ret &= test_OpenPrinter_badnames(p, torture);
+ ret &= test_AddPort(p, torture);
+ ret &= test_EnumPorts_old(p, torture);
+ ret &= test_EnumPrinters_old(p, torture);
+ ret &= test_EnumPrinterDrivers_old(p, torture);
return ret;
}
diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c
index 89be804b07..87eae78c06 100644
--- a/source4/torture/rpc/wkssvc.c
+++ b/source4/torture/rpc/wkssvc.c
@@ -77,12 +77,12 @@ static bool test_NetWkstaTransportEnum(struct torture_context *tctx,
return true;
}
-struct torture_suite *torture_rpc_wkssvc(void)
+struct torture_suite *torture_rpc_wkssvc(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite;
struct torture_rpc_tcase *tcase;
- suite = torture_suite_create(talloc_autofree_context(), "WKSSVC");
+ suite = torture_suite_create(mem_ctx, "WKSSVC");
tcase = torture_suite_add_rpc_iface_tcase(suite, "wkssvc",
&ndr_table_wkssvc);