summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/librpc/rpc/dcerpc_util.c6
-rw-r--r--source4/torture/libnet/domain.c2
-rw-r--r--source4/torture/libnet/groupinfo.c2
-rw-r--r--source4/torture/libnet/libnet_domain.c33
-rw-r--r--source4/torture/libnet/libnet_group.c2
-rw-r--r--source4/torture/libnet/libnet_lookup.c9
-rw-r--r--source4/torture/libnet/libnet_rpc.c27
-rw-r--r--source4/torture/libnet/libnet_share.c11
-rw-r--r--source4/torture/libnet/libnet_user.c13
-rw-r--r--source4/torture/libnet/userinfo.c2
-rw-r--r--source4/torture/libnet/userman.c6
-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
19 files changed, 85 insertions, 167 deletions
diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c
index e1fb4c1d86..f097e53f20 100644
--- a/source4/librpc/rpc/dcerpc_util.c
+++ b/source4/librpc/rpc/dcerpc_util.c
@@ -301,7 +301,7 @@ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b)
NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out)
{
struct dcerpc_binding *b;
- char *options, *type;
+ char *options;
char *p;
int i, j, comma_count;
@@ -334,7 +334,7 @@ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_
if (p == NULL) {
b->transport = NCA_UNKNOWN;
} else {
- type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s));
+ char *type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s));
if (!type) {
return NT_STATUS_NO_MEMORY;
}
@@ -350,6 +350,8 @@ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_
DEBUG(0,("Unknown dcerpc transport '%s'\n", type));
return NT_STATUS_INVALID_PARAMETER;
}
+
+ talloc_free(type);
s = p+1;
}
diff --git a/source4/torture/libnet/domain.c b/source4/torture/libnet/domain.c
index 8eaca99dc9..17b8a94f42 100644
--- a/source4/torture/libnet/domain.c
+++ b/source4/torture/libnet/domain.c
@@ -72,7 +72,6 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
BOOL torture_domainopen(struct torture_context *torture)
{
NTSTATUS status;
- const char *binding;
struct libnet_context *net_ctx;
struct event_context *evt_ctx;
TALLOC_CTX *mem_ctx;
@@ -81,7 +80,6 @@ BOOL torture_domainopen(struct torture_context *torture)
struct lsa_String name;
mem_ctx = talloc_init("test_domain_open");
- binding = torture_setting_string(torture, "binding", NULL);
evt_ctx = event_context_find(torture);
net_ctx = libnet_context_init(evt_ctx);
diff --git a/source4/torture/libnet/groupinfo.c b/source4/torture/libnet/groupinfo.c
index 6e02d4f05d..0dca1519de 100644
--- a/source4/torture/libnet/groupinfo.c
+++ b/source4/torture/libnet/groupinfo.c
@@ -223,7 +223,6 @@ static BOOL test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
BOOL torture_groupinfo(struct torture_context *torture)
{
NTSTATUS status;
- const char *binding;
struct dcerpc_pipe *p;
TALLOC_CTX *mem_ctx;
BOOL ret = True;
@@ -233,7 +232,6 @@ BOOL torture_groupinfo(struct torture_context *torture)
uint32_t rid;
mem_ctx = talloc_init("test_userinfo");
- binding = torture_setting_string(torture, "binding", NULL);
status = torture_rpc_connection(torture,
&p,
diff --git a/source4/torture/libnet/libnet_domain.c b/source4/torture/libnet/libnet_domain.c
index 915054bf50..675ab9f099 100644
--- a/source4/torture/libnet/libnet_domain.c
+++ b/source4/torture/libnet/libnet_domain.c
@@ -179,17 +179,14 @@ BOOL torture_domain_close_lsa(struct torture_context *torture)
struct libnet_context *ctx;
struct lsa_String domain_name;
struct dcerpc_binding *binding;
- const char *bindstr;
uint32_t access_mask;
struct policy_handle h;
struct dcerpc_pipe *p;
struct libnet_DomainClose r;
- bindstr = torture_setting_string(torture, "binding", NULL);
- status = dcerpc_parse_binding(torture, bindstr, &binding);
+ status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to parse binding string\n");
- return False;
+ return false;
}
ctx = libnet_context_init(NULL);
@@ -202,11 +199,10 @@ BOOL torture_domain_close_lsa(struct torture_context *torture)
ctx->cred = cmdline_credentials;
mem_ctx = talloc_init("torture_domain_close_lsa");
- status = dcerpc_pipe_connect(mem_ctx, &p, bindstr, &ndr_table_lsarpc,
+ status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_lsarpc,
cmdline_credentials, NULL);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to connect to server %s: %s\n", bindstr,
- nt_errstr(status));
+ d_printf("failed to connect to server: %s\n", nt_errstr(status));
ret = False;
goto done;
}
@@ -247,7 +243,6 @@ done:
BOOL torture_domain_open_samr(struct torture_context *torture)
{
NTSTATUS status;
- const char *binding;
struct libnet_context *ctx;
struct event_context *evt_ctx=NULL;
TALLOC_CTX *mem_ctx;
@@ -258,7 +253,6 @@ BOOL torture_domain_open_samr(struct torture_context *torture)
BOOL ret = True;
mem_ctx = talloc_init("test_domainopen_lsa");
- binding = torture_setting_string(torture, "binding", NULL);
ctx = libnet_context_init(evt_ctx);
ctx->cred = cmdline_credentials;
@@ -314,18 +308,15 @@ BOOL torture_domain_close_samr(struct torture_context *torture)
struct libnet_context *ctx;
struct lsa_String domain_name;
struct dcerpc_binding *binding;
- const char *bindstr;
uint32_t access_mask;
struct policy_handle h;
struct dcerpc_pipe *p;
struct libnet_DomainClose r;
struct dom_sid *sid;
- bindstr = torture_setting_string(torture, "binding", NULL);
- status = dcerpc_parse_binding(torture, bindstr, &binding);
+ status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to parse binding string\n");
- return False;
+ return false;
}
ctx = libnet_context_init(NULL);
@@ -338,11 +329,10 @@ BOOL torture_domain_close_samr(struct torture_context *torture)
ctx->cred = cmdline_credentials;
mem_ctx = talloc_init("torture_domain_close_samr");
- status = dcerpc_pipe_connect(mem_ctx, &p, bindstr, &ndr_table_samr,
+ status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_samr,
ctx->cred, NULL);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to connect to server %s: %s\n", bindstr,
- nt_errstr(status));
+ d_printf("failed to connect to server: %s\n", nt_errstr(status));
ret = False;
goto done;
}
@@ -387,17 +377,14 @@ BOOL torture_domain_list(struct torture_context *torture)
BOOL ret = True;
NTSTATUS status;
TALLOC_CTX *mem_ctx = NULL;
- const char *bindstr;
struct dcerpc_binding *binding;
struct libnet_context *ctx;
struct libnet_DomainList r;
int i;
- bindstr = torture_setting_string(torture, "binding", NULL);
- status = dcerpc_parse_binding(torture, bindstr, &binding);
+ status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to parse binding string\n");
- return False;
+ return false;
}
ctx = libnet_context_init(NULL);
diff --git a/source4/torture/libnet/libnet_group.c b/source4/torture/libnet/libnet_group.c
index db2952e226..1f4725d6dd 100644
--- a/source4/torture/libnet/libnet_group.c
+++ b/source4/torture/libnet/libnet_group.c
@@ -204,7 +204,6 @@ static BOOL test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
BOOL torture_groupinfo_api(struct torture_context *torture)
{
const char *name = TEST_GROUPNAME;
- const char *binding;
BOOL ret = True;
NTSTATUS status;
TALLOC_CTX *mem_ctx = NULL, *prep_mem_ctx;
@@ -215,7 +214,6 @@ BOOL torture_groupinfo_api(struct torture_context *torture)
struct libnet_GroupInfo req;
prep_mem_ctx = talloc_init("prepare torture group info");
- binding = torture_setting_string(torture, "binding", NULL);
ctx = libnet_context_init(NULL);
ctx->cred = cmdline_credentials;
diff --git a/source4/torture/libnet/libnet_lookup.c b/source4/torture/libnet/libnet_lookup.c
index d4251bbdee..b48f7e7bac 100644
--- a/source4/torture/libnet/libnet_lookup.c
+++ b/source4/torture/libnet/libnet_lookup.c
@@ -24,6 +24,7 @@
#include "librpc/gen_ndr/nbt.h"
#include "librpc/rpc/dcerpc.h"
#include "libcli/libcli.h"
+#include "torture/rpc/rpc.h"
#include "torture/torture.h"
@@ -35,7 +36,6 @@ BOOL torture_lookup(struct torture_context *torture)
struct libnet_context *ctx;
struct libnet_Lookup lookup;
struct dcerpc_binding *bind;
- const char *bindstr;
mem_ctx = talloc_init("test_lookup");
@@ -44,8 +44,7 @@ BOOL torture_lookup(struct torture_context *torture)
lookup.in.hostname = torture_setting_string(torture, "host", NULL);
if (lookup.in.hostname == NULL) {
- bindstr = torture_setting_string(torture, "binding", NULL);
- status = dcerpc_parse_binding(mem_ctx, bindstr, &bind);
+ status = torture_rpc_binding(torture, &bind);
if (NT_STATUS_IS_OK(status)) {
lookup.in.hostname = bind->host;
}
@@ -81,7 +80,6 @@ BOOL torture_lookup_host(struct torture_context *torture)
struct libnet_context *ctx;
struct libnet_Lookup lookup;
struct dcerpc_binding *bind;
- const char *bindstr;
mem_ctx = talloc_init("test_lookup_host");
@@ -90,8 +88,7 @@ BOOL torture_lookup_host(struct torture_context *torture)
lookup.in.hostname = torture_setting_string(torture, "host", NULL);
if (lookup.in.hostname == NULL) {
- bindstr = torture_setting_string(torture, "binding", NULL);
- status = dcerpc_parse_binding(mem_ctx, bindstr, &bind);
+ status = torture_rpc_binding(torture, &bind);
if (NT_STATUS_IS_OK(status)) {
lookup.in.hostname = bind->host;
}
diff --git a/source4/torture/libnet/libnet_rpc.c b/source4/torture/libnet/libnet_rpc.c
index d751a8e423..07c586ebf3 100644
--- a/source4/torture/libnet/libnet_rpc.c
+++ b/source4/torture/libnet/libnet_rpc.c
@@ -28,6 +28,7 @@
#include "librpc/gen_ndr/ndr_samr.h"
#include "librpc/gen_ndr/ndr_srvsvc.h"
#include "librpc/rpc/dcerpc.h"
+#include "torture/rpc/rpc.h"
#include "torture/torture.h"
@@ -136,12 +137,9 @@ BOOL torture_rpc_connect_srv(struct torture_context *torture)
const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_SERVER;
NTSTATUS status;
struct dcerpc_binding *binding;
- const char *bindstr;;
- bindstr = torture_setting_string(torture, "binding", NULL);
- status = dcerpc_parse_binding(torture, bindstr, &binding);
+ status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to parse binding string\n");
return False;
}
@@ -154,13 +152,10 @@ BOOL torture_rpc_connect_pdc(struct torture_context *torture)
const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_PDC;
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);
+ status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to parse binding string\n");
return False;
}
@@ -177,13 +172,10 @@ BOOL torture_rpc_connect_dc(struct torture_context *torture)
const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_DC;
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);
+ status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to parse binding string\n");
return False;
}
@@ -200,13 +192,10 @@ BOOL torture_rpc_connect_dc_info(struct torture_context *torture)
const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_DC_INFO;
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);
+ status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to parse binding string\n");
return False;
}
@@ -225,12 +214,12 @@ BOOL torture_rpc_connect_binding(struct torture_context *torture)
struct dcerpc_binding *binding;
const char *bindstr;
- bindstr = torture_setting_string(torture, "binding", NULL);
- status = dcerpc_parse_binding(torture, bindstr, &binding);
+ status = torture_rpc_binding(torture, &binding);
if (!NT_STATUS_IS_OK(status)) {
- d_printf("failed to parse binding string\n");
return False;
}
+ bindstr = dcerpc_binding_string(torture, binding);
+
return torture_rpc_connect(torture, level, bindstr, NULL);
}
diff --git a/source4/torture/libnet/libnet_share.c b/source4/torture/libnet/libnet_share.c
index a4d94a6b9c..b6b0b37d01 100644
--- a/source4/torture/libnet/libnet_share.c
+++ b/source4/torture/libnet/libnet_share.c
@@ -121,15 +121,12 @@ BOOL torture_listshares(struct torture_context *torture)
int i;
BOOL ret = True;
struct libnet_context* libnetctx;
- const char *binding;
struct dcerpc_binding *bind;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init("test_listshares");
- binding = torture_setting_string(torture, "binding", NULL);
- status = dcerpc_parse_binding(mem_ctx, binding, &bind);
+ status = torture_rpc_binding(torture, &bind);
if (!NT_STATUS_IS_OK(status)) {
- printf("Error while parsing the binding string\n");
ret = False;
goto done;
}
@@ -203,7 +200,7 @@ BOOL torture_delshare(struct torture_context *torture)
struct dcerpc_pipe *p;
struct dcerpc_binding *bind;
struct libnet_context* libnetctx;
- const char *host, *binding;
+ const char *host;
TALLOC_CTX *mem_ctx;
NTSTATUS status;
BOOL ret = True;
@@ -211,10 +208,8 @@ BOOL torture_delshare(struct torture_context *torture)
mem_ctx = talloc_init("test_listshares");
host = torture_setting_string(torture, "host", NULL);
- binding = torture_setting_string(torture, "binding", NULL);
- status = dcerpc_parse_binding(mem_ctx, binding, &bind);
+ status = torture_rpc_binding(torture, &bind);
if (!NT_STATUS_IS_OK(status)) {
- printf("Error while parsing the binding string\n");
ret = False;
goto done;
}
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c
index f3371e07a7..7a3b9f19c1 100644
--- a/source4/torture/libnet/libnet_user.c
+++ b/source4/torture/libnet/libnet_user.c
@@ -233,14 +233,12 @@ static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
BOOL torture_createuser(struct torture_context *torture)
{
NTSTATUS status;
- const char *binding;
TALLOC_CTX *mem_ctx;
struct libnet_context *ctx;
struct libnet_CreateUser req;
BOOL ret = True;
mem_ctx = talloc_init("test_createuser");
- binding = torture_setting_string(torture, "binding", NULL);
ctx = libnet_context_init(NULL);
ctx->cred = cmdline_credentials;
@@ -277,7 +275,6 @@ done:
BOOL torture_deleteuser(struct torture_context *torture)
{
NTSTATUS status;
- const char *binding;
struct dcerpc_pipe *p;
TALLOC_CTX *prep_mem_ctx, *mem_ctx;
struct policy_handle h;
@@ -288,7 +285,6 @@ BOOL torture_deleteuser(struct torture_context *torture)
BOOL ret = True;
prep_mem_ctx = talloc_init("prepare test_deleteuser");
- binding = torture_setting_string(torture, "binding", NULL);
ctx = libnet_context_init(NULL);
ctx->cred = cmdline_credentials;
@@ -464,7 +460,6 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
BOOL torture_modifyuser(struct torture_context *torture)
{
NTSTATUS status;
- const char *binding;
struct dcerpc_binding *bind;
struct dcerpc_pipe *p;
TALLOC_CTX *prep_mem_ctx, *mem_ctx;
@@ -478,7 +473,6 @@ BOOL torture_modifyuser(struct torture_context *torture)
BOOL ret = True;
prep_mem_ctx = talloc_init("prepare test_deleteuser");
- binding = torture_setting_string(torture, "binding", NULL);
ctx = libnet_context_init(NULL);
ctx->cred = cmdline_credentials;
@@ -506,7 +500,7 @@ BOOL torture_modifyuser(struct torture_context *torture)
mem_ctx = talloc_init("test_modifyuser");
- status = dcerpc_parse_binding(mem_ctx, binding, &bind);
+ status = torture_rpc_binding(mem_ctx, &bind);
if (!NT_STATUS_IS_OK(status)) {
ret = False;
goto done;
@@ -608,7 +602,6 @@ done:
BOOL torture_userinfo_api(struct torture_context *torture)
{
const char *name = TEST_USERNAME;
- const char *binding;
BOOL ret = True;
NTSTATUS status;
TALLOC_CTX *mem_ctx = NULL, *prep_mem_ctx;
@@ -619,7 +612,6 @@ BOOL torture_userinfo_api(struct torture_context *torture)
struct libnet_UserInfo req;
prep_mem_ctx = talloc_init("prepare torture user info");
- binding = torture_setting_string(torture, "binding", NULL);
ctx = libnet_context_init(NULL);
ctx->cred = cmdline_credentials;
@@ -678,7 +670,6 @@ done:
BOOL torture_userlist(struct torture_context *torture)
{
- const char *binding;
BOOL ret = True;
NTSTATUS status;
TALLOC_CTX *mem_ctx = NULL;
@@ -687,8 +678,6 @@ BOOL torture_userlist(struct torture_context *torture)
struct libnet_UserList req;
int i;
- binding = torture_setting_string(torture, "binding", NULL);
-
ctx = libnet_context_init(NULL);
ctx->cred = cmdline_credentials;
diff --git a/source4/torture/libnet/userinfo.c b/source4/torture/libnet/userinfo.c
index a1603b4bfc..ad35e84861 100644
--- a/source4/torture/libnet/userinfo.c
+++ b/source4/torture/libnet/userinfo.c
@@ -302,7 +302,6 @@ static BOOL test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
BOOL torture_userinfo(struct torture_context *torture)
{
NTSTATUS status;
- const char *binding;
struct dcerpc_pipe *p;
TALLOC_CTX *mem_ctx;
BOOL ret = True;
@@ -312,7 +311,6 @@ BOOL torture_userinfo(struct torture_context *torture)
uint32_t rid;
mem_ctx = talloc_init("test_userinfo");
- binding = torture_setting_string(torture, "binding", NULL);
status = torture_rpc_connection(torture,
&p,
diff --git a/source4/torture/libnet/userman.c b/source4/torture/libnet/userman.c
index d70fb0bc77..90b3f41959 100644
--- a/source4/torture/libnet/userman.c
+++ b/source4/torture/libnet/userman.c
@@ -478,7 +478,6 @@ static BOOL test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
BOOL torture_useradd(struct torture_context *torture)
{
NTSTATUS status;
- const char *binding;
struct dcerpc_pipe *p;
struct policy_handle h;
struct lsa_String domain_name;
@@ -487,7 +486,6 @@ BOOL torture_useradd(struct torture_context *torture)
BOOL ret = True;
mem_ctx = talloc_init("test_useradd");
- binding = torture_setting_string(torture, "binding", NULL);
status = torture_rpc_connection(torture,
&p,
@@ -537,7 +535,6 @@ done:
BOOL torture_userdel(struct torture_context *torture)
{
NTSTATUS status;
- const char *binding;
struct dcerpc_pipe *p;
struct policy_handle h;
struct lsa_String domain_name;
@@ -546,7 +543,6 @@ BOOL torture_userdel(struct torture_context *torture)
BOOL ret = True;
mem_ctx = talloc_init("test_userdel");
- binding = torture_setting_string(torture, "binding", NULL);
status = torture_rpc_connection(torture,
&p,
@@ -581,7 +577,6 @@ done:
BOOL torture_usermod(struct torture_context *torture)
{
NTSTATUS status;
- const char *binding;
struct dcerpc_pipe *p;
struct policy_handle h;
struct lsa_String domain_name;
@@ -591,7 +586,6 @@ BOOL torture_usermod(struct torture_context *torture)
BOOL ret = True;
mem_ctx = talloc_init("test_userdel");
- binding = torture_setting_string(torture, "binding", NULL);
status = torture_rpc_connection(torture,
&p,
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);