s4:torture/rpc: make use of dcerpc_binding_[g|s]et_transport()
authorStefan Metzmacher <metze@samba.org>
Thu, 30 Jan 2014 18:05:06 +0000 (19:05 +0100)
committerG√ľnther Deschner <gd@samba.org>
Thu, 13 Feb 2014 10:54:17 +0000 (11:54 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source4/torture/rpc/lsa.c
source4/torture/rpc/lsa_lookup.c
source4/torture/rpc/scanner.c
source4/torture/rpc/schannel.c

index 7385ad4b91123710015d40457ee1c3860578234a..ed618b7a64acf4925bf67685c1bc6b6512fb2f72 100644 (file)
@@ -948,6 +948,7 @@ bool test_many_LookupSids(struct dcerpc_pipe *p,
        struct lsa_SidArray sids;
        int i;
        struct dcerpc_binding_handle *b = p->binding_handle;
+       enum dcerpc_transport_t transport = dcerpc_binding_get_transport(p->binding);
 
        torture_comment(tctx, "\nTesting LookupSids with lots of SIDs\n");
 
@@ -993,14 +994,14 @@ bool test_many_LookupSids(struct dcerpc_pipe *p,
                }
        }
 
-       if (p->binding->transport == NCACN_NP) {
+       if (transport == NCACN_NP) {
                if (!test_LookupSids3_fail(b, tctx, &sids)) {
                        return false;
                }
                if (!test_LookupNames4_fail(b, tctx)) {
                        return false;
                }
-       } else if (p->binding->transport == NCACN_IP_TCP) {
+       } else if (transport == NCACN_IP_TCP) {
                struct lsa_TransNameArray2 names;
 
                names.count = 0;
@@ -3303,15 +3304,17 @@ bool torture_rpc_lsa(struct torture_context *tctx)
        struct test_join *join = NULL;
        struct cli_credentials *machine_creds;
        struct dcerpc_binding_handle *b;
+       enum dcerpc_transport_t transport;
 
        status = torture_rpc_connection(tctx, &p, &ndr_table_lsarpc);
        if (!NT_STATUS_IS_OK(status)) {
                return false;
        }
        b = p->binding_handle;
+       transport = dcerpc_binding_get_transport(p->binding);
 
        /* Test lsaLookupSids3 and lsaLookupNames4 over tcpip */
-       if (p->binding->transport == NCACN_IP_TCP) {
+       if (transport == NCACN_IP_TCP) {
                if (!test_OpenPolicy_fail(b, tctx)) {
                        ret = false;
                }
@@ -3394,14 +3397,16 @@ bool torture_rpc_lsa_get_user(struct torture_context *tctx)
         struct dcerpc_pipe *p;
        bool ret = true;
        struct dcerpc_binding_handle *b;
+       enum dcerpc_transport_t transport;
 
        status = torture_rpc_connection(tctx, &p, &ndr_table_lsarpc);
        if (!NT_STATUS_IS_OK(status)) {
                return false;
        }
        b = p->binding_handle;
+       transport = dcerpc_binding_get_transport(p->binding);
 
-       if (p->binding->transport == NCACN_IP_TCP) {
+       if (transport == NCACN_IP_TCP) {
                if (!test_GetUserName_fail(b, tctx)) {
                        ret = false;
                }
@@ -3423,9 +3428,9 @@ static bool testcase_LookupNames(struct torture_context *tctx,
        struct lsa_TransNameArray tnames;
        struct lsa_TransNameArray2 tnames2;
        struct dcerpc_binding_handle *b = p->binding_handle;
+       enum dcerpc_transport_t transport = dcerpc_binding_get_transport(p->binding);
 
-       if (p->binding->transport != NCACN_NP &&
-           p->binding->transport != NCALRPC) {
+       if (transport != NCACN_NP && transport != NCALRPC) {
                torture_comment(tctx, "testcase_LookupNames is only available "
                                "over NCACN_NP or NCALRPC");
                return true;
@@ -3514,9 +3519,9 @@ static bool testcase_TrustedDomains(struct torture_context *tctx,
        struct lsa_trustdom_state *state =
                talloc_get_type_abort(data, struct lsa_trustdom_state);
        struct dcerpc_binding_handle *b = p->binding_handle;
+       enum dcerpc_transport_t transport = dcerpc_binding_get_transport(p->binding);
 
-       if (p->binding->transport != NCACN_NP &&
-           p->binding->transport != NCALRPC) {
+       if (transport != NCACN_NP && transport != NCALRPC) {
                torture_comment(tctx, "testcase_TrustedDomains is only available "
                                "over NCACN_NP or NCALRPC");
                return true;
@@ -3581,9 +3586,9 @@ static bool testcase_Privileges(struct torture_context *tctx,
 {
        struct policy_handle *handle;
        struct dcerpc_binding_handle *b = p->binding_handle;
+       enum dcerpc_transport_t transport = dcerpc_binding_get_transport(p->binding);
 
-       if (p->binding->transport != NCACN_NP &&
-           p->binding->transport != NCALRPC) {
+       if (transport != NCACN_NP && transport != NCALRPC) {
                torture_skip(tctx, "testcase_Privileges is only available "
                                "over NCACN_NP or NCALRPC");
        }
index 587ab630bd7049b6de0a32477829c348e6a5cec3..59decda17106ac64b045c73718018e3555164ab1 100644 (file)
@@ -221,15 +221,16 @@ bool torture_rpc_lsa_lookup(struct torture_context *torture)
        struct dom_sid *trusted_sid = NULL;
        struct dom_sid *sids[NUM_SIDS];
        struct dcerpc_binding_handle *b;
+       enum dcerpc_transport_t transport;
 
        status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc);
        if (!NT_STATUS_IS_OK(status)) {
                torture_fail(torture, "unable to connect to table");
        }
        b = p->binding_handle;
+       transport = dcerpc_binding_get_transport(p->binding);
 
-       if (p->binding->transport != NCACN_NP &&
-           p->binding->transport != NCALRPC) {
+       if (transport != NCACN_NP && transport != NCALRPC) {
                torture_comment(torture,
                                "torture_rpc_lsa_lookup is only available "
                                "over NCACN_NP or NCALRPC");
@@ -343,9 +344,9 @@ static bool test_LookupSidsReply(struct torture_context *tctx,
        const char *dom_sid = "S-1-5-21-1111111111-2222222222-3333333333";
        const char *dom_admin_sid;
        struct dcerpc_binding_handle *b = p->binding_handle;
+       enum dcerpc_transport_t transport = dcerpc_binding_get_transport(p->binding);
 
-       if (p->binding->transport != NCACN_NP &&
-           p->binding->transport != NCALRPC) {
+       if (transport != NCACN_NP && transport != NCALRPC) {
                torture_comment(tctx,
                                "test_LookupSidsReply is only available "
                                "over NCACN_NP or NCALRPC");
index 5edd5040351200193531e3192a28745cc4f610be..e910bddedc504826a76376b2003fc38417117f4d 100644 (file)
@@ -122,11 +122,13 @@ bool torture_rpc_scanner(struct torture_context *torture)
        bool ret = true;
        const struct ndr_interface_list *l;
        struct dcerpc_binding *b;
+       enum dcerpc_transport_t transport;
 
        status = torture_rpc_binding(torture, &b);
        if (!NT_STATUS_IS_OK(status)) {
                return false;
        }
+       transport = dcerpc_binding_get_transport(b);
 
        for (l=ndr_table_list();l;l=l->next) {          
                loop_ctx = talloc_named(torture, 0, "torture_rpc_scanner loop context");
@@ -139,7 +141,7 @@ bool torture_rpc_scanner(struct torture_context *torture)
 
                printf("\nTesting pipe '%s'\n", l->table->name);
 
-               if (b->transport == NCACN_IP_TCP) {
+               if (transport == NCACN_IP_TCP) {
                        status = dcerpc_epm_map_binding(torture, b, l->table,
                                                        torture->ev,
                                                        torture->lp_ctx);
index 0098dcf648db1134f73e8f81b5797efc56e9b10c..a1856c13f6e247daf25c42d122dfdef3152cf845 100644 (file)
@@ -426,8 +426,9 @@ static bool test_schannel(struct torture_context *tctx,
                "Failed to process schannel secured NETLOGON EX ops");
 
        /* we *MUST* use ncacn_np for openpolicy etc. */
-       transport = b->transport;
-       b->transport = NCACN_NP;
+       transport = dcerpc_binding_get_transport(b);
+       status = dcerpc_binding_set_transport(b, NCACN_NP);
+       torture_assert_ntstatus_ok(tctx, status, "set transport");
 
        /* Swap the binding details from SAMR to LSARPC */
        status = dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, tctx->ev, tctx->lp_ctx);
@@ -444,11 +445,9 @@ static bool test_schannel(struct torture_context *tctx,
        talloc_free(p_lsa);
        p_lsa = NULL;
 
-       b->transport = transport;
-
        /* we *MUST* use ncacn_ip_tcp for lookupsids3/lookupnames4 */
-       transport = b->transport;
-       b->transport = NCACN_IP_TCP;
+       status = dcerpc_binding_set_transport(b, NCACN_IP_TCP);
+       torture_assert_ntstatus_ok(tctx, status, "set transport");
 
        torture_assert_ntstatus_ok(tctx,
                dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, tctx->ev, tctx->lp_ctx),
@@ -463,7 +462,9 @@ static bool test_schannel(struct torture_context *tctx,
                test_many_LookupSids(p_lsa, tctx, NULL),
                "LsaLookupSids3 failed!\n");
 
-       b->transport = transport;
+       status = dcerpc_binding_set_transport(b, transport);
+       torture_assert_ntstatus_ok(tctx, status, "set transport");
+
 
        /* Drop the socket, we want to start from scratch */
        talloc_free(p);