The branch, master has been updated
       via  1d37a8171ca712ef11c12bde3b1fa9837c602ec2 (commit)
       via  a915575158485debaa0d417d5566c46a0dd77004 (commit)
       via  29040344105988cb9674c0f450ef9e739e9ece2a (commit)
       via  899fc0ddde8307e7af218b37a21404e4285da7e6 (commit)
       via  d078d2efe8c58adb6f1ed93c06797588ce361bd5 (commit)
       via  5e3759d122aac95fd3a99898e37f64d76e4eeee8 (commit)
      from  0ed467ac0c2b8854445662650b3066aa1be236f5 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1d37a8171ca712ef11c12bde3b1fa9837c602ec2
Author: Andrew Bartlett <[email protected]>
Date:   Tue Sep 8 20:21:38 2009 +1000

    s4:idl Add generated code for netlogon.idl changes

commit a915575158485debaa0d417d5566c46a0dd77004
Author: Matthieu Patou <[email protected]>
Date:   Tue Sep 8 12:21:09 2009 +0400

    Return a correct value for Supported Encryption Type
    
    Vista and upper version use this value to check wether they should ask the 
DC
     to change the msDS-SupportedEncryptionTypes attribute or not.
     Declare the different value as a bitmap in Netlogon idl

commit 29040344105988cb9674c0f450ef9e739e9ece2a
Author: Kamen Mazdrashki <[email protected]>
Date:   Fri Aug 28 18:35:31 2009 +0300

    tort: RPC-CRACKNAMES test case refactored

commit 899fc0ddde8307e7af218b37a21404e4285da7e6
Author: Kamen Mazdrashki <[email protected]>
Date:   Fri Aug 28 18:34:40 2009 +0300

    tort: DsCrackNames - propagate torture context to all tests.

commit d078d2efe8c58adb6f1ed93c06797588ce361bd5
Author: Kamen Mazdrashki <[email protected]>
Date:   Fri Aug 28 18:19:54 2009 +0300

    tort: Helper function to get DC info for testing

commit 5e3759d122aac95fd3a99898e37f64d76e4eeee8
Author: Kamen Mazdrashki <[email protected]>
Date:   Fri Aug 28 15:42:48 2009 +0300

    tort: Implement 'setup' and 'teardown' for DRSUAPI test cases.

-----------------------------------------------------------------------

Summary of changes:
 librpc/gen_ndr/ndr_netlogon.c                 |   32 +++-
 librpc/gen_ndr/ndr_netlogon.h                 |    3 +
 librpc/gen_ndr/netlogon.h                     |    7 +
 librpc/idl/netlogon.idl                       |   10 +-
 source4/rpc_server/netlogon/dcerpc_netlogon.c |    7 +-
 source4/torture/rpc/drsuapi.c                 |  120 +++++++---
 source4/torture/rpc/drsuapi.h                 |    1 +
 source4/torture/rpc/drsuapi_cracknames.c      |  331 +++++++++++++------------
 source4/torture/rpc/rpc.c                     |    2 +-
 9 files changed, 317 insertions(+), 196 deletions(-)


Changeset truncated at 500 lines:

diff --git a/librpc/gen_ndr/ndr_netlogon.c b/librpc/gen_ndr/ndr_netlogon.c
index 7337d26..daba526 100644
--- a/librpc/gen_ndr/ndr_netlogon.c
+++ b/librpc/gen_ndr/ndr_netlogon.c
@@ -8141,6 +8141,32 @@ _PUBLIC_ void ndr_print_netr_OneDomainInfo(struct 
ndr_print *ndr, const char *na
        ndr->depth--;
 }
 
+_PUBLIC_ enum ndr_err_code ndr_push_netr_SupportedEncTypes(struct ndr_push 
*ndr, int ndr_flags, uint32_t r)
+{
+       NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_netr_SupportedEncTypes(struct ndr_pull 
*ndr, int ndr_flags, uint32_t *r)
+{
+       uint32_t v;
+       NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
+       *r = v;
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_netr_SupportedEncTypes(struct ndr_print *ndr, const 
char *name, uint32_t r)
+{
+       ndr_print_uint32(ndr, name, r);
+       ndr->depth++;
+       ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "ENC_CRC32", ENC_CRC32, r);
+       ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "ENC_RSA_MD5", 
ENC_RSA_MD5, r);
+       ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "ENC_RC4_HMAC_MD5", 
ENC_RC4_HMAC_MD5, r);
+       ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "ENC_HMAC_SHA1_96_AES128", 
ENC_HMAC_SHA1_96_AES128, r);
+       ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "ENC_HMAC_SHA1_96_AES256", 
ENC_HMAC_SHA1_96_AES256, r);
+       ndr->depth--;
+}
+
 static enum ndr_err_code ndr_push_netr_DomainInformation(struct ndr_push *ndr, 
int ndr_flags, const struct netr_DomainInformation *r)
 {
        uint32_t cntr_trusted_domains_1;
@@ -8155,7 +8181,7 @@ static enum ndr_err_code 
ndr_push_netr_DomainInformation(struct ndr_push *ndr, i
                NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, 
&r->dummy_string3));
                NDR_CHECK(ndr_push_lsa_String(ndr, NDR_SCALARS, 
&r->dummy_string4));
                NDR_CHECK(ndr_push_netr_WorkstationFlags(ndr, NDR_SCALARS, 
r->workstation_flags));
-               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 
r->supported_enc_types));
+               NDR_CHECK(ndr_push_netr_SupportedEncTypes(ndr, NDR_SCALARS, 
r->supported_enc_types));
                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->dummy_long3));
                NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->dummy_long4));
        }
@@ -8201,7 +8227,7 @@ static enum ndr_err_code 
ndr_pull_netr_DomainInformation(struct ndr_pull *ndr, i
                NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, 
&r->dummy_string3));
                NDR_CHECK(ndr_pull_lsa_String(ndr, NDR_SCALARS, 
&r->dummy_string4));
                NDR_CHECK(ndr_pull_netr_WorkstationFlags(ndr, NDR_SCALARS, 
&r->workstation_flags));
-               NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, 
&r->supported_enc_types));
+               NDR_CHECK(ndr_pull_netr_SupportedEncTypes(ndr, NDR_SCALARS, 
&r->supported_enc_types));
                NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dummy_long3));
                NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->dummy_long4));
        }
@@ -8263,7 +8289,7 @@ _PUBLIC_ void ndr_print_netr_DomainInformation(struct 
ndr_print *ndr, const char
        ndr_print_lsa_String(ndr, "dummy_string3", &r->dummy_string3);
        ndr_print_lsa_String(ndr, "dummy_string4", &r->dummy_string4);
        ndr_print_netr_WorkstationFlags(ndr, "workstation_flags", 
r->workstation_flags);
-       ndr_print_uint32(ndr, "supported_enc_types", r->supported_enc_types);
+       ndr_print_netr_SupportedEncTypes(ndr, "supported_enc_types", 
r->supported_enc_types);
        ndr_print_uint32(ndr, "dummy_long3", r->dummy_long3);
        ndr_print_uint32(ndr, "dummy_long4", r->dummy_long4);
        ndr->depth--;
diff --git a/librpc/gen_ndr/ndr_netlogon.h b/librpc/gen_ndr/ndr_netlogon.h
index 63e9c71..7b6f9a1 100644
--- a/librpc/gen_ndr/ndr_netlogon.h
+++ b/librpc/gen_ndr/ndr_netlogon.h
@@ -222,6 +222,9 @@ void ndr_print_netr_WorkstationInfo(struct ndr_print *ndr, 
const char *name, con
 void ndr_print_netr_trust_extension(struct ndr_print *ndr, const char *name, 
const struct netr_trust_extension *r);
 void ndr_print_netr_trust_extension_container(struct ndr_print *ndr, const 
char *name, const struct netr_trust_extension_container *r);
 void ndr_print_netr_OneDomainInfo(struct ndr_print *ndr, const char *name, 
const struct netr_OneDomainInfo *r);
+enum ndr_err_code ndr_push_netr_SupportedEncTypes(struct ndr_push *ndr, int 
ndr_flags, uint32_t r);
+enum ndr_err_code ndr_pull_netr_SupportedEncTypes(struct ndr_pull *ndr, int 
ndr_flags, uint32_t *r);
+void ndr_print_netr_SupportedEncTypes(struct ndr_print *ndr, const char *name, 
uint32_t r);
 void ndr_print_netr_DomainInformation(struct ndr_print *ndr, const char *name, 
const struct netr_DomainInformation *r);
 void ndr_print_netr_DomainInfo(struct ndr_print *ndr, const char *name, const 
union netr_DomainInfo *r);
 void ndr_print_netr_CryptPassword(struct ndr_print *ndr, const char *name, 
const struct netr_CryptPassword *r);
diff --git a/librpc/gen_ndr/netlogon.h b/librpc/gen_ndr/netlogon.h
index 931222f..0a314e1 100644
--- a/librpc/gen_ndr/netlogon.h
+++ b/librpc/gen_ndr/netlogon.h
@@ -1006,6 +1006,13 @@ struct netr_OneDomainInfo {
        uint32_t dummy_long4;
 };
 
+/* bitmap netr_SupportedEncTypes */
+#define ENC_CRC32 ( 0x00000001 )
+#define ENC_RSA_MD5 ( 0x00000002 )
+#define ENC_RC4_HMAC_MD5 ( 0x00000004 )
+#define ENC_HMAC_SHA1_96_AES128 ( 0x00000008 )
+#define ENC_HMAC_SHA1_96_AES256 ( 0x00000010 )
+
 struct netr_DomainInformation {
        struct netr_OneDomainInfo primary_domain;
        uint32_t trusted_domain_count;
diff --git a/librpc/idl/netlogon.idl b/librpc/idl/netlogon.idl
index 736a0fd..34081e2 100644
--- a/librpc/idl/netlogon.idl
+++ b/librpc/idl/netlogon.idl
@@ -1372,6 +1372,14 @@ interface netlogon
                uint32 dummy_long4;
        } netr_OneDomainInfo;
 
+ typedef [public,bitmap32bit] bitmap {
+               ENC_CRC32 = 0x00000001,
+               ENC_RSA_MD5 = 0x00000002,
+               ENC_RC4_HMAC_MD5 = 0x00000004,
+               ENC_HMAC_SHA1_96_AES128  = 0x00000008,
+               ENC_HMAC_SHA1_96_AES256  = 0x00000010
+       } netr_SupportedEncTypes;
+
        typedef struct {
                netr_OneDomainInfo primary_domain;
                uint32 trusted_domain_count;
@@ -1382,7 +1390,7 @@ interface netlogon
                lsa_String dummy_string3;
                lsa_String dummy_string4;
                netr_WorkstationFlags workstation_flags;
-               uint32 supported_enc_types;
+               netr_SupportedEncTypes supported_enc_types;
                uint32 dummy_long3;
                uint32 dummy_long4;
        } netr_DomainInformation;
diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c 
b/source4/rpc_server/netlogon/dcerpc_netlogon.c
index d597ca6..e349df0 100644
--- a/source4/rpc_server/netlogon/dcerpc_netlogon.c
+++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c
@@ -1130,6 +1130,8 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct 
dcesrv_call_state *dce_cal
        struct netr_LsaPolicyInformation *lsa_policy_info;
        struct netr_OsVersionInfoEx *os_version;
        int ret1, ret2, i;
+       uint32_t client_supported_enc;
+       uint32_t default_supported_enc = ENC_CRC32|ENC_RSA_MD5|ENC_RC4_HMAC_MD5;
        NTSTATUS status;
 
        status = dcesrv_netr_creds_server_step_check(dce_call,
@@ -1176,6 +1178,9 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct 
dcesrv_call_state *dce_cal
                                                        "dNSHostName",
                                                        NULL);
 
+               client_supported_enc = samdb_search_int64(sam_ctx, mem_ctx, 
default_supported_enc,
+                                                      workstation_dn,  
"msDS-SupportedEncryptionTypes", 
+                                                      NULL);
                /* Gets host informations and put them in our directory */
                new_msg = ldb_msg_new(mem_ctx);
                NT_STATUS_HAVE_NO_MEMORY(new_msg);
@@ -1321,7 +1326,7 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct 
dcesrv_call_state *dce_cal
                domain_info->dns_hostname.string = old_dns_hostname;
                domain_info->workstation_flags =
                        r->in.query->workstation_info->workstation_flags;
-               domain_info->supported_enc_types = 0; /* w2008 gives this 0 */
+               domain_info->supported_enc_types = client_supported_enc;
 
                r->out.info->domain_info = domain_info;
        break;
diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c
index da6ce2b..2075fa7 100644
--- a/source4/torture/rpc/drsuapi.c
+++ b/source4/torture/rpc/drsuapi.c
@@ -57,7 +57,7 @@ bool test_DsBind(struct dcerpc_pipe *p, struct 
torture_context *tctx,
        return true;
 }
 
-static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct 
torture_context *torture, 
+static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct 
torture_context *torture,
                      struct DsPrivate *priv)
 {
        NTSTATUS status;
@@ -747,13 +747,16 @@ bool torture_rpc_drsuapi(struct torture_context *torture)
                torture_fail(torture, "Unable to connect to DRSUAPI pipe");
        }
 
+       /* cache pipe handle */
+       priv.pipe = p;
+
        ret &= test_DsBind(p, torture, &priv);
 #if 0
        ret &= test_QuerySitesByCost(p, torture, &priv);
 #endif
        ret &= test_DsGetDomainControllerInfo(p, torture, &priv);
 
-       ret &= test_DsCrackNames(torture, p, torture, &priv);
+       ret &= test_DsCrackNames(torture, &priv);
 
        ret &= test_DsWriteAccountSpn(p, torture, &priv);
 
@@ -772,46 +775,105 @@ bool torture_rpc_drsuapi(struct torture_context *torture)
        return ret;
 }
 
+/**
+ * Helper func to collect DC information for testing purposes.
+ * This function is almost identical to test_DsGetDomainControllerInfo
+ */
+bool torture_rpc_drsuapi_get_dcinfo(struct torture_context *torture,
+                                   struct DsPrivate *priv)
+{
+       NTSTATUS status;
+       int32_t level_out = 0;
+       struct drsuapi_DsGetDomainControllerInfo r;
+       union drsuapi_DsGetDCInfoCtr ctr;
+       int j, k;
+       const char *names[] = {
+                               torture_join_dom_netbios_name(priv->join),
+                               torture_join_dom_dns_name(priv->join)};
+
+       for (j=0; j < ARRAY_SIZE(names); j++) {
+               union drsuapi_DsGetDCInfoRequest req;
+               r.in.bind_handle = &priv->bind_handle;
+               r.in.level = 1;
+               r.in.req = &req;
+
+               r.in.req->req1.domain_name = names[j];
+               r.in.req->req1.level = 2;
+
+               r.out.ctr = &ctr;
+               r.out.level_out = &level_out;
 
-bool torture_rpc_drsuapi_cracknames(struct torture_context *torture)
+               status = dcerpc_drsuapi_DsGetDomainControllerInfo(priv->pipe, 
torture, &r);
+               if (!NT_STATUS_IS_OK(status)) {
+                       continue;
+               }
+               if (!W_ERROR_IS_OK(r.out.result)) {
+                       /* If this was an error, we can't read the result 
structure */
+                       continue;
+               }
+
+               for (k=0; k < r.out.ctr->ctr2.count; k++) {
+                       if (strcasecmp_m(r.out.ctr->ctr2.array[k].netbios_name,
+                                        torture_join_netbios_name(priv->join)) 
== 0) {
+                               priv->dcinfo    = r.out.ctr->ctr2.array[k];
+                               return true;
+                       }
+               }
+       }
+
+       return false;
+}
+
+/**
+ * Common test case setup function to be used
+ * in DRS suit of test when appropriate
+ */
+bool torture_rpc_drsuapi_tcase_setup(struct torture_context *tctx, void **data)
 {
         NTSTATUS status;
-        struct dcerpc_pipe *p;
-       bool ret = true;
-       struct DsPrivate priv;
+       struct DsPrivate *priv;
        struct cli_credentials *machine_credentials;
 
-       torture_comment(torture, "Connected to DRSUAPI pipe\n");
+       *data = priv = talloc_zero(tctx, struct DsPrivate);
+       torture_assert(tctx, priv, "Not enough memory");
 
-       ZERO_STRUCT(priv);
+       torture_comment(tctx, "Create DRSUAPI pipe");
+       status = torture_rpc_connection(tctx,
+                                       &priv->pipe,
+                                       &ndr_table_drsuapi);
+       torture_assert(tctx, NT_STATUS_IS_OK(status), "Unable to connect to 
DRSUAPI pipe");
 
-       priv.join = torture_join_domain(torture, TEST_MACHINE_NAME, 
ACB_SVRTRUST, 
-                                      &machine_credentials);
-       if (!priv.join) {
-               torture_fail(torture, "Failed to join as BDC\n");
-       }
+       torture_comment(tctx, "Connected to DRSUAPI pipe\n");
+       priv->join = torture_join_domain(tctx, TEST_MACHINE_NAME, ACB_SVRTRUST,
+                                        &machine_credentials);
+       torture_assert(tctx, priv->join, "Failed to join as BDC");
 
-       status = torture_rpc_connection(torture, 
-                                       &p, 
-                                       &ndr_table_drsuapi);
-       if (!NT_STATUS_IS_OK(status)) {
-               torture_leave_domain(torture, priv.join);
-               torture_fail(torture, "Unable to connect to DRSUAPI pipe");
+       if (!test_DsBind(priv->pipe, tctx, priv)) {
+               /* clean up */
+               torture_rpc_drsuapi_tcase_teardown(tctx, priv);
+               torture_fail(tctx, "Failed execute test_DsBind()");
        }
 
-       ret &= test_DsBind(p, torture, &priv);
+       /* try collect some information for testing */
+       torture_rpc_drsuapi_get_dcinfo(tctx, priv);
 
-       if (ret) {
-               /* We don't care if this fails, we just need some info from it 
*/
-               test_DsGetDomainControllerInfo(p, torture, &priv);
-               
-               ret &= test_DsCrackNames(torture, p, torture, &priv);
-               
-               ret &= test_DsUnbind(p, torture, &priv);
+       return true;
+}
+
+/**
+ * Common test case teardown function to be used
+ * in DRS suit of test when appropriate
+ */
+bool torture_rpc_drsuapi_tcase_teardown(struct torture_context *tctx, void 
*data)
+{
+       struct DsPrivate *priv = (struct DsPrivate *)data;
+
+       if (priv->join) {
+               torture_leave_domain(tctx, priv->join);
        }
 
-       torture_leave_domain(torture, priv.join);
+       talloc_free(priv);
 
-       return ret;
+       return true;
 }
 
diff --git a/source4/torture/rpc/drsuapi.h b/source4/torture/rpc/drsuapi.h
index 98438cc..e9a7dd5 100644
--- a/source4/torture/rpc/drsuapi.h
+++ b/source4/torture/rpc/drsuapi.h
@@ -24,6 +24,7 @@
 #include "librpc/gen_ndr/drsuapi.h"
 
 struct DsPrivate {
+       struct dcerpc_pipe *pipe;
        struct policy_handle bind_handle;
        struct GUID bind_guid;
        const char *domain_obj_dn;
diff --git a/source4/torture/rpc/drsuapi_cracknames.c 
b/source4/torture/rpc/drsuapi_cracknames.c
index 65a15c9..5377882 100644
--- a/source4/torture/rpc/drsuapi_cracknames.c
+++ b/source4/torture/rpc/drsuapi_cracknames.c
@@ -28,18 +28,18 @@
 #include "ldb/include/ldb.h"
 #include "libcli/security/security.h"
 
-static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX 
*mem_ctx, 
+static bool test_DsCrackNamesMatrix(struct torture_context *tctx,
                                    struct DsPrivate *priv, const char *dn,
                                    const char *user_principal_name, const char 
*service_principal_name)
 {
-       
-
        NTSTATUS status;
-       bool ret = true;
+       const char *err_msg;
        struct drsuapi_DsCrackNames r;
        union drsuapi_DsNameRequest req;
        int32_t level_out;
        union drsuapi_DsNameCtr ctr;
+       struct dcerpc_pipe *p = priv->pipe;
+       TALLOC_CTX *mem_ctx = priv;
 
        enum drsuapi_DsNameFormat formats[] = {
                DRSUAPI_DS_NAME_FORMAT_UNKNOWN,
@@ -85,52 +85,52 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, 
TALLOC_CTX *mem_ctx,
                        if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) 
{
                                errstr = dcerpc_errstr(mem_ctx, 
p->last_fault_code);
                        }
-                       printf("testing DsCrackNames (matrix prep) with name 
'%s' from format: %d desired format:%d ",
-                              names[0].str, r.in.req->req1.format_offered, 
r.in.req->req1.format_desired);
-               
-                       printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", 
errstr);
-                       ret = false;
+                       err_msg = talloc_asprintf(mem_ctx,
+                                       "testing DsCrackNames (matrix prep) 
with name '%s' from format: %d desired format:%d failed - %s",
+                                       names[0].str, 
r.in.req->req1.format_offered, r.in.req->req1.format_desired, errstr);
+                       torture_fail(tctx, err_msg);
                } else if (!W_ERROR_IS_OK(r.out.result)) {
-                       printf("testing DsCrackNames (matrix prep) with name 
'%s' from format: %d desired format:%d ",
-                              names[0].str, r.in.req->req1.format_offered, 
r.in.req->req1.format_desired);
-               
-                       printf("DsCrackNames failed - %s\n", 
win_errstr(r.out.result));
-                       ret = false;
+                       err_msg = talloc_asprintf(mem_ctx,
+                                       "testing DsCrackNames (matrix prep) 
with name '%s' from format: %d desired format:%d failed - %s",
+                              names[0].str, r.in.req->req1.format_offered, 
r.in.req->req1.format_desired, win_errstr(r.out.result));
+                       torture_fail(tctx, err_msg);
                }
                        
-               if (!ret) {
-                       return ret;
-               }
                switch (formats[i]) {
                case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL:  
                        if (r.out.ctr->ctr1->array[0].status != 
DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE) {
-                               printf(__location__ ": Unexpected error (%d): 
This name lookup should fail\n", 
-                                      r.out.ctr->ctr1->array[0].status);
-                               return false;
+                               err_msg = talloc_asprintf(mem_ctx,
+                                               "Unexpected error (%d): This 
name lookup should fail",
+                                               
r.out.ctr->ctr1->array[0].status);
+                               torture_fail(tctx, err_msg);
                        }
-                       printf ("(expected) error\n");
+                       torture_comment(tctx, __location__ ": (expected) 
error\n");
                        break;
                case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL:
                        if (r.out.ctr->ctr1->array[0].status != 
DRSUAPI_DS_NAME_STATUS_NO_MAPPING) {
-                               printf(__location__ ": Unexpected error (%d): 
This name lookup should fail\n", 
-                                      r.out.ctr->ctr1->array[0].status);
-                               return false;
+                               err_msg = talloc_asprintf(mem_ctx,
+                                               "Unexpected error (%d): This 
name lookup should fail",
+                                               
r.out.ctr->ctr1->array[0].status);
+                               torture_fail(tctx, err_msg);
                        }
-                       printf ("(expected) error\n");
+                       torture_comment(tctx, __location__ ": (expected) 
error\n");
                        break;
                case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN: 
                case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY: 
                        if (r.out.ctr->ctr1->array[0].status != 
DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR) {
-                               printf(__location__ ": Unexpected error (%d): 
This name lookup should fail\n", 
-                                      r.out.ctr->ctr1->array[0].status);
-                               return false;
+                               err_msg = talloc_asprintf(mem_ctx,
+                                               "Unexpected error (%d): This 
name lookup should fail",
+                                               
r.out.ctr->ctr1->array[0].status);
+                               torture_fail(tctx, err_msg);
                        }
-                       printf ("(expected) error\n");
+                       torture_comment(tctx, __location__ ": (expected) 
error\n");
                        break;
                default:
                        if (r.out.ctr->ctr1->array[0].status != 
DRSUAPI_DS_NAME_STATUS_OK) {
-                               printf("Error: %d\n", 
r.out.ctr->ctr1->array[0].status);
-                               return false;
+                               err_msg = talloc_asprintf(mem_ctx,
+                                               "DsCrackNames error: %d",
+                                               
r.out.ctr->ctr1->array[0].status);
+                               torture_fail(tctx, err_msg);
                        }
                }
 
@@ -166,19 +166,18 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe 
*p, TALLOC_CTX *mem_ctx,
                                if (NT_STATUS_EQUAL(status, 
NT_STATUS_NET_WRITE_FAULT)) {
                                        errstr = dcerpc_errstr(mem_ctx, 
p->last_fault_code);
                                }
-                               printf("testing DsCrackNames (matrix) with name 
'%s' from format: %d desired format:%d failed - %s",
-                                      names[0].str, 
r.in.req->req1.format_offered, r.in.req->req1.format_desired, errstr);
-                               ret = false;
+                               err_msg = talloc_asprintf(mem_ctx,
+                                               "testing DsCrackNames (matrix) 
with name '%s' from format: %d desired format:%d failed - %s",
+                                               names[0].str, 
r.in.req->req1.format_offered, r.in.req->req1.format_desired, errstr);
+                               torture_fail(tctx, err_msg);
                        } else if (!W_ERROR_IS_OK(r.out.result)) {
-                               printf("testing DsCrackNames (matrix) with name 
'%s' from format: %d desired format:%d failed - %s",
-                                      names[0].str, 
r.in.req->req1.format_offered, r.in.req->req1.format_desired,
-                                      win_errstr(r.out.result));
-                               ret = false;
+                               err_msg = talloc_asprintf(mem_ctx,
+                                               "testing DsCrackNames (matrix) 
with name '%s' from format: %d desired format:%d failed - %s",
+                                               names[0].str, 
r.in.req->req1.format_offered, r.in.req->req1.format_desired,
+                                               win_errstr(r.out.result));
+                               torture_fail(tctx, err_msg);
                        }
                        
-                       if (!ret) {
-                               return ret;
-                       }
                        if (r.out.ctr->ctr1->array[0].status == 
DRSUAPI_DS_NAME_STATUS_OK) {
                                n_matrix[i][j] = 
r.out.ctr->ctr1->array[0].result_name;
                        } else {
@@ -198,31 +197,37 @@ static bool test_DsCrackNamesMatrix(struct dcerpc_pipe 
*p, TALLOC_CTX *mem_ctx,
                        } else if (n_matrix[i][j] == NULL && formats[j] == 
DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL) {
                        } else if (n_matrix[i][j] == NULL && formats[j] == 
DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL) {
                        } else if (n_matrix[i][j] == NULL && n_from[j] != NULL) 
{
-                               printf("dcerpc_drsuapi_DsCrackNames mismatch - 
from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], 
n_from[j]);
-                               ret = false;
+                               err_msg = talloc_asprintf(mem_ctx,
+                                               "dcerpc_drsuapi_DsCrackNames 
mismatch - from %d to %d: %s should be %s",
+                                               formats[i], formats[j], 
n_matrix[i][j], n_from[j]);
+                               torture_fail(tctx, err_msg);
                        } else if (n_matrix[i][j] != NULL && n_from[j] == NULL) 
{
-                               printf("dcerpc_drsuapi_DsCrackNames mismatch - 
from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], 
n_from[j]);
-                               ret = false;
+                               err_msg = talloc_asprintf(mem_ctx,
+                                               "dcerpc_drsuapi_DsCrackNames 
mismatch - from %d to %d: %s should be %s",
+                                               formats[i], formats[j], 
n_matrix[i][j], n_from[j]);
+                               torture_fail(tctx, err_msg);
                        } else if (strcmp(n_matrix[i][j], n_from[j]) != 0) {
-                               printf("dcerpc_drsuapi_DsCrackNames mismatch - 
from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], 
n_from[j]);
-                               ret = false;
+                               err_msg = talloc_asprintf(mem_ctx,
+                                               "dcerpc_drsuapi_DsCrackNames 
mismatch - from %d to %d: %s should be %s",
+                                               formats[i], formats[j], 
n_matrix[i][j], n_from[j]);
+                               torture_fail(tctx, err_msg);
                        }
                }
        }
-       return ret;
+
+       return true;
 }
 


-- 
Samba Shared Repository

Reply via email to