r24755: Use common code for finding the RPC binding in the torture tests.
authorJelmer Vernooij <jelmer@samba.org>
Tue, 28 Aug 2007 19:03:08 +0000 (19:03 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 20:03:03 +0000 (15:03 -0500)
(This used to be commit e3310e773924ddd2129e8ca1a86e23d0f713c19c)

19 files changed:
source4/librpc/rpc/dcerpc_util.c
source4/torture/libnet/domain.c
source4/torture/libnet/groupinfo.c
source4/torture/libnet/libnet_domain.c
source4/torture/libnet/libnet_group.c
source4/torture/libnet/libnet_lookup.c
source4/torture/libnet/libnet_rpc.c
source4/torture/libnet/libnet_share.c
source4/torture/libnet/libnet_user.c
source4/torture/libnet/userinfo.c
source4/torture/libnet/userman.c
source4/torture/rpc/bind.c
source4/torture/rpc/mgmt.c
source4/torture/rpc/rpc.c
source4/torture/rpc/samlogon.c
source4/torture/rpc/samsync.c
source4/torture/rpc/scanner.c
source4/torture/rpc/spoolss.c
source4/torture/rpc/wkssvc.c

index e1fb4c1d86c1afdbb7b9b7e38c466df7ca1a321a..f097e53f20ac19068b91a0111f4e8ec88b461046 100644 (file)
@@ -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;
        }
index 8eaca99dc9e119cde26d65fb4b7a5ca7095cbbf3..17b8a94f42978d2fc78a944f95cfafc74e1e1185 100644 (file)
@@ -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);
index 6e02d4f05d316d9dce29f44a7adc47c01a5f4c30..0dca1519ded24c59c2d1b6d71ed5cf992bb8d6c0 100644 (file)
@@ -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,
index 915054bf508aa1084e6055e50d614bf5e88b0637..675ab9f0996fe97b3e028bd81304bf5778fdc1ef 100644 (file)
@@ -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);
index db2952e226413da6e8444dff3465458be8481ad2..1f4725d6dd1dc6d2fafd36b69782df5938cefa60 100644 (file)
@@ -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;
index d4251bbdee262047113a11d4a03bdc8b174d8a9e..b48f7e7bac3f3879a190a20e369bf113d3edcb05 100644 (file)
@@ -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;
                }
index d751a8e4235f329216b0ef610b2acdd4b0c2eefc..07c586ebf370c4bb44e0465bda258bbb61e17ecf 100644 (file)
@@ -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);
 }
index a4d94a6b9c4d4664a721bb61d0c0bac01b4938e6..b6b0b37d016fc443f774f81398b58843e4c5973f 100644 (file)
@@ -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;
        }
index f3371e07a7ba8d9890769a14b0e3238c7128a92d..7a3b9f19c150e3ae54ddd0a120df2436eb4315cf 100644 (file)
@@ -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;
 
index a1603b4bfc7f68fd48e95b000dfbf83942b85643..ad35e8486145fdaf20ec86ac8ccfc8be98279b4b 100644 (file)
@@ -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,
index d70fb0bc77b0ec79e07d3785e971706f80eed810..90b3f41959fe4adde8ad82e292b78bfd6ec377ed 100644 (file)
@@ -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,
index 33885573e66d0eff155d07f145fce5b7fa9ff764..c7848f4a89774fae7415347a6186de09e3fc715a 100644 (file)
@@ -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;
        }
index ec3e390afa175030fef11fd6202b5e385628c987..6d0c3d56c90d37b7c06e64bbbc734638b2494b34 100644 (file)
@@ -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;
        }
 
index 3d8a56ffba38c89ad3622f3a5540b7ee0041b040..af7e05a9f0b1929017c6397b8b08222239e04a99 100644 (file)
@@ -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);
index 832bb68072d78bf7a28f4200bb75cc0179d1de91..da74067336f989db83740b9becacec438b53fcec 100644 (file)
@@ -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;
        }
index 4b9392bf3c95503aacfac24cd6f1216815a994d7..358bf8791a6ce734c9c82045bce870b9946b7352 100644 (file)
@@ -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;
        }
index da4fc84f6f154d4585d8394b2e4c54b97d202a2b..b2dd99fd662f777c013b61a88fe50866058d8302 100644 (file)
@@ -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;
        }
 
index a9232f6df383430bc068641c0b0239e37cfa1744..0bf0ee87a1876c7b8f48b9d4544833983e4acd19 100644 (file)
@@ -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;
 }
index 89be804b07c841c2165fe806299355d967cbeae3..87eae78c06f3893d7f0307ea01625fcf17929124 100644 (file)
@@ -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);