diff options
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r-- | source4/torture/rpc/frsapi.c | 18 | ||||
-rw-r--r-- | source4/torture/rpc/lsa.c | 532 | ||||
-rw-r--r-- | source4/torture/rpc/object_uuid.c | 1 | ||||
-rw-r--r-- | source4/torture/rpc/rpc.c | 3 | ||||
-rw-r--r-- | source4/torture/rpc/spoolss.c | 1082 |
5 files changed, 1374 insertions, 262 deletions
diff --git a/source4/torture/rpc/frsapi.c b/source4/torture/rpc/frsapi.c index c8e421a674..e9a19bcf96 100644 --- a/source4/torture/rpc/frsapi.c +++ b/source4/torture/rpc/frsapi.c @@ -114,15 +114,15 @@ static bool test_IsPathReplicated_err(struct torture_context *tctx, { struct frsapi_IsPathReplicated r; struct GUID guid; - uint32_t unknown1, unknown2, unknown3 = 0; + uint32_t replicated, primary, root; ZERO_STRUCT(r); r.in.path = path; r.in.replica_set_type = type; - r.out.unknown1 = &unknown1; - r.out.unknown2 = &unknown2; - r.out.unknown3 = &unknown3; + r.out.replicated = &replicated; + r.out.primary = &primary; + r.out.root = &root; r.out.replica_set_guid = &guid; torture_assert_ntstatus_ok(tctx, @@ -191,11 +191,11 @@ static bool test_ForceReplication(struct torture_context *tctx, ZERO_STRUCT(r); - r.in.guid1 = NULL; - r.in.guid2 = NULL; - r.in.replica_set = talloc_asprintf(tctx, "%s", - lp_realm(tctx->lp_ctx)); - r.in.partner_name = dcerpc_server_name(p); + r.in.replica_set_guid = NULL; + r.in.connection_guid = NULL; + r.in.replica_set_name = talloc_asprintf(tctx, "%s", + lp_realm(tctx->lp_ctx)); + r.in.partner_dns_name = dcerpc_server_name(p); torture_assert_ntstatus_ok(tctx, dcerpc_frsapi_ForceReplication(p, tctx, &r), diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c index 7d03e7ef9e..b45b565452 100644 --- a/source4/torture/rpc/lsa.c +++ b/source4/torture/rpc/lsa.c @@ -47,7 +47,7 @@ static bool test_OpenPolicy(struct dcerpc_pipe *p, NTSTATUS status; uint16_t system_name = '\\'; - printf("\nTesting OpenPolicy\n"); + torture_comment(tctx, "\nTesting OpenPolicy\n"); qos.len = 0; qos.impersonation_level = 2; @@ -70,10 +70,10 @@ static bool test_OpenPolicy(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) || NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) { - printf("not considering %s to be an error\n", nt_errstr(status)); + torture_comment(tctx, "not considering %s to be an error\n", nt_errstr(status)); return true; } - printf("OpenPolicy failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "OpenPolicy failed - %s\n", nt_errstr(status)); return false; } @@ -90,7 +90,7 @@ bool test_lsa_OpenPolicy2(struct dcerpc_pipe *p, struct lsa_OpenPolicy2 r; NTSTATUS status; - printf("\nTesting OpenPolicy2\n"); + torture_comment(tctx, "\nTesting OpenPolicy2\n"); *handle = talloc(tctx, struct policy_handle); if (!*handle) { @@ -118,12 +118,12 @@ bool test_lsa_OpenPolicy2(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) || NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) { - printf("not considering %s to be an error\n", nt_errstr(status)); + torture_comment(tctx, "not considering %s to be an error\n", nt_errstr(status)); talloc_free(*handle); *handle = NULL; return true; } - printf("OpenPolicy2 failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "OpenPolicy2 failed - %s\n", nt_errstr(status)); return false; } @@ -161,7 +161,7 @@ static bool test_LookupNames(struct dcerpc_pipe *p, NTSTATUS status; int i; - printf("\nTesting LookupNames with %d names\n", tnames->count); + torture_comment(tctx, "\nTesting LookupNames with %d names\n", tnames->count); sids.count = 0; sids.sids = NULL; @@ -187,30 +187,30 @@ static bool test_LookupNames(struct dcerpc_pipe *p, NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) { for (i=0;i< tnames->count;i++) { if (i < count && sids.sids[i].sid_type == SID_NAME_UNKNOWN) { - printf("LookupName of %s was unmapped\n", + torture_comment(tctx, "LookupName of %s was unmapped\n", tnames->names[i].name.string); } else if (i >=count) { - printf("LookupName of %s failed to return a result\n", + torture_comment(tctx, "LookupName of %s failed to return a result\n", tnames->names[i].name.string); } } - printf("LookupNames failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "LookupNames failed - %s\n", nt_errstr(status)); return false; } else if (!NT_STATUS_IS_OK(status)) { - printf("LookupNames failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "LookupNames failed - %s\n", nt_errstr(status)); return false; } for (i=0;i< tnames->count;i++) { if (i < count && sids.sids[i].sid_type != tnames->names[i].sid_type) { - printf("LookupName of %s got unexpected name type: %s\n", + torture_comment(tctx, "LookupName of %s got unexpected name type: %s\n", tnames->names[i].name.string, sid_type_lookup(sids.sids[i].sid_type)); } else if (i >=count) { - printf("LookupName of %s failed to return a result\n", + torture_comment(tctx, "LookupName of %s failed to return a result\n", tnames->names[i].name.string); } } - printf("\n"); + torture_comment(tctx, "\n"); return true; } @@ -235,7 +235,7 @@ static bool test_LookupNames_bogus(struct dcerpc_pipe *p, name[0].name.string = "NT AUTHORITY\\BOGUS"; name[1].name.string = NULL; - printf("\nTesting LookupNames with bogus names\n"); + torture_comment(tctx, "\nTesting LookupNames with bogus names\n"); sids.count = 0; sids.sids = NULL; @@ -257,11 +257,11 @@ static bool test_LookupNames_bogus(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupNames(p, tctx, &r); if (!NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) { - printf("LookupNames failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "LookupNames failed - %s\n", nt_errstr(status)); return false; } - printf("\n"); + torture_comment(tctx, "\n"); return true; } @@ -274,7 +274,7 @@ static bool test_LookupNames_wellknown(struct dcerpc_pipe *p, struct lsa_TransNameArray tnames; bool ret = true; - printf("Testing LookupNames with well known names\n"); + torture_comment(tctx, "Testing LookupNames with well known names\n"); tnames.names = &name; tnames.count = 1; @@ -330,7 +330,7 @@ static bool test_LookupNames2(struct dcerpc_pipe *p, NTSTATUS status; int i; - printf("\nTesting LookupNames2 with %d names\n", tnames->count); + torture_comment(tctx, "\nTesting LookupNames2 with %d names\n", tnames->count); sids.count = 0; sids.sids = NULL; @@ -354,7 +354,7 @@ static bool test_LookupNames2(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupNames2(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("LookupNames2 failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "LookupNames2 failed - %s\n", nt_errstr(status)); return false; } @@ -366,7 +366,7 @@ static bool test_LookupNames2(struct dcerpc_pipe *p, } } - printf("\n"); + torture_comment(tctx, "\n"); return true; } @@ -386,7 +386,7 @@ static bool test_LookupNames3(struct dcerpc_pipe *p, NTSTATUS status; int i; - printf("\nTesting LookupNames3 with %d names\n", tnames->count); + torture_comment(tctx, "\nTesting LookupNames3 with %d names\n", tnames->count); sids.count = 0; sids.sids = NULL; @@ -410,7 +410,7 @@ static bool test_LookupNames3(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupNames3(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("LookupNames3 failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "LookupNames3 failed - %s\n", nt_errstr(status)); return false; } @@ -422,7 +422,7 @@ static bool test_LookupNames3(struct dcerpc_pipe *p, } } - printf("\n"); + torture_comment(tctx, "\n"); return true; } @@ -440,7 +440,7 @@ static bool test_LookupNames4(struct dcerpc_pipe *p, NTSTATUS status; int i; - printf("\nTesting LookupNames4 with %d names\n", tnames->count); + torture_comment(tctx, "\nTesting LookupNames4 with %d names\n", tnames->count); sids.count = 0; sids.sids = NULL; @@ -463,7 +463,7 @@ static bool test_LookupNames4(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupNames4(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("LookupNames4 failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "LookupNames4 failed - %s\n", nt_errstr(status)); return false; } @@ -475,7 +475,7 @@ static bool test_LookupNames4(struct dcerpc_pipe *p, } } - printf("\n"); + torture_comment(tctx, "\n"); return true; } @@ -492,7 +492,7 @@ static bool test_LookupSids(struct dcerpc_pipe *p, uint32_t count = sids->num_sids; NTSTATUS status; - printf("\nTesting LookupSids\n"); + torture_comment(tctx, "\nTesting LookupSids\n"); names.count = 0; names.names = NULL; @@ -508,11 +508,11 @@ static bool test_LookupSids(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupSids(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("LookupSids failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "LookupSids failed - %s\n", nt_errstr(status)); return false; } - printf("\n"); + torture_comment(tctx, "\n"); if (!test_LookupNames(p, tctx, handle, &names)) { return false; @@ -533,7 +533,7 @@ static bool test_LookupSids2(struct dcerpc_pipe *p, uint32_t count = sids->num_sids; NTSTATUS status; - printf("\nTesting LookupSids2\n"); + torture_comment(tctx, "\nTesting LookupSids2\n"); names.count = 0; names.names = NULL; @@ -551,11 +551,11 @@ static bool test_LookupSids2(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupSids2(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("LookupSids2 failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "LookupSids2 failed - %s\n", nt_errstr(status)); return false; } - printf("\n"); + torture_comment(tctx, "\n"); if (!test_LookupNames2(p, tctx, handle, &names, false)) { return false; @@ -578,7 +578,7 @@ static bool test_LookupSids3(struct dcerpc_pipe *p, uint32_t count = sids->num_sids; NTSTATUS status; - printf("\nTesting LookupSids3\n"); + torture_comment(tctx, "\nTesting LookupSids3\n"); names.count = 0; names.names = NULL; @@ -597,15 +597,15 @@ static bool test_LookupSids3(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) || NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) { - printf("not considering %s to be an error\n", nt_errstr(status)); + torture_comment(tctx, "not considering %s to be an error\n", nt_errstr(status)); return true; } - printf("LookupSids3 failed - %s - not considered an error\n", + torture_comment(tctx, "LookupSids3 failed - %s - not considered an error\n", nt_errstr(status)); return false; } - printf("\n"); + torture_comment(tctx, "\n"); if (!test_LookupNames4(p, tctx, &names, false)) { return false; @@ -623,7 +623,7 @@ bool test_many_LookupSids(struct dcerpc_pipe *p, struct lsa_SidArray sids; int i; - printf("\nTesting LookupSids with lots of SIDs\n"); + torture_comment(tctx, "\nTesting LookupSids with lots of SIDs\n"); sids.num_sids = 100; @@ -654,11 +654,11 @@ bool test_many_LookupSids(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupSids(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("LookupSids failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "LookupSids failed - %s\n", nt_errstr(status)); return false; } - printf("\n"); + torture_comment(tctx, "\n"); if (!test_LookupNames(p, tctx, handle, &names)) { return false; @@ -672,7 +672,7 @@ bool test_many_LookupSids(struct dcerpc_pipe *p, names.count = 0; names.names = NULL; - printf("\nTesting LookupSids3\n"); + torture_comment(tctx, "\nTesting LookupSids3\n"); r.in.sids = &sids; r.in.names = &names; @@ -688,10 +688,10 @@ bool test_many_LookupSids(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) || NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) { - printf("not considering %s to be an error\n", nt_errstr(status)); + torture_comment(tctx, "not considering %s to be an error\n", nt_errstr(status)); return true; } - printf("LookupSids3 failed - %s\n", + torture_comment(tctx, "LookupSids3 failed - %s\n", nt_errstr(status)); return false; } @@ -700,7 +700,7 @@ bool test_many_LookupSids(struct dcerpc_pipe *p, } } - printf("\n"); + torture_comment(tctx, "\n"); @@ -742,7 +742,7 @@ static bool test_LookupSids_async(struct dcerpc_pipe *p, names = talloc_array(tctx, struct lsa_TransNameArray, num_async_requests); r = talloc_array(tctx, struct lsa_LookupSids, num_async_requests); - printf("\nTesting %d async lookupsids request\n", num_async_requests); + torture_comment(tctx, "\nTesting %d async lookupsids request\n", num_async_requests); req = talloc_array(tctx, struct rpc_request *, num_async_requests); @@ -804,7 +804,7 @@ static bool test_LookupPrivValue(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupPrivValue(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("\nLookupPrivValue failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "\nLookupPrivValue failed - %s\n", nt_errstr(status)); return false; } @@ -826,7 +826,7 @@ static bool test_LookupPrivName(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupPrivName(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("\nLookupPrivName failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "\nLookupPrivName failed - %s\n", nt_errstr(status)); return false; } @@ -844,7 +844,7 @@ static bool test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p, struct lsa_PrivilegeSet privs; bool ret = true; - printf("\nTesting RemovePrivilegesFromAccount\n"); + torture_comment(tctx, "\nTesting RemovePrivilegesFromAccount\n"); r.in.handle = acct_handle; r.in.remove_all = 0; @@ -868,7 +868,7 @@ static bool test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupPrivName(p, tctx, &r_name); if (!NT_STATUS_IS_OK(status)) { - printf("\nLookupPrivName failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "\nLookupPrivName failed - %s\n", nt_errstr(status)); return false; } /* Windows 2008 does not allow this to be removed */ @@ -876,7 +876,7 @@ static bool test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p, return ret; } - printf("RemovePrivilegesFromAccount failed to remove %s - %s\n", + torture_comment(tctx, "RemovePrivilegesFromAccount failed to remove %s - %s\n", name->string, nt_errstr(status)); return false; @@ -895,7 +895,7 @@ static bool test_AddPrivilegesToAccount(struct dcerpc_pipe *p, struct lsa_PrivilegeSet privs; bool ret = true; - printf("\nTesting AddPrivilegesToAccount\n"); + torture_comment(tctx, "\nTesting AddPrivilegesToAccount\n"); r.in.handle = acct_handle; r.in.privs = &privs; @@ -908,7 +908,7 @@ static bool test_AddPrivilegesToAccount(struct dcerpc_pipe *p, status = dcerpc_lsa_AddPrivilegesToAccount(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("AddPrivilegesToAccount failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "AddPrivilegesToAccount failed - %s\n", nt_errstr(status)); return false; } @@ -925,14 +925,14 @@ static bool test_EnumPrivsAccount(struct dcerpc_pipe *p, struct lsa_PrivilegeSet *privs = NULL; bool ret = true; - printf("\nTesting EnumPrivsAccount\n"); + torture_comment(tctx, "\nTesting EnumPrivsAccount\n"); r.in.handle = acct_handle; r.out.privs = &privs; status = dcerpc_lsa_EnumPrivsAccount(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("EnumPrivsAccount failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "EnumPrivsAccount failed - %s\n", nt_errstr(status)); return false; } @@ -961,46 +961,46 @@ static bool test_GetSystemAccessAccount(struct dcerpc_pipe *p, uint32_t access_mask; struct lsa_GetSystemAccessAccount r; - printf("\nTesting GetSystemAccessAccount\n"); + torture_comment(tctx, "\nTesting GetSystemAccessAccount\n"); r.in.handle = acct_handle; r.out.access_mask = &access_mask; status = dcerpc_lsa_GetSystemAccessAccount(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("GetSystemAccessAccount failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "GetSystemAccessAccount failed - %s\n", nt_errstr(status)); return false; } if (r.out.access_mask != NULL) { - printf("Rights:"); + torture_comment(tctx, "Rights:"); if (*(r.out.access_mask) & LSA_POLICY_MODE_INTERACTIVE) - printf(" LSA_POLICY_MODE_INTERACTIVE"); + torture_comment(tctx, " LSA_POLICY_MODE_INTERACTIVE"); if (*(r.out.access_mask) & LSA_POLICY_MODE_NETWORK) - printf(" LSA_POLICY_MODE_NETWORK"); + torture_comment(tctx, " LSA_POLICY_MODE_NETWORK"); if (*(r.out.access_mask) & LSA_POLICY_MODE_BATCH) - printf(" LSA_POLICY_MODE_BATCH"); + torture_comment(tctx, " LSA_POLICY_MODE_BATCH"); if (*(r.out.access_mask) & LSA_POLICY_MODE_SERVICE) - printf(" LSA_POLICY_MODE_SERVICE"); + torture_comment(tctx, " LSA_POLICY_MODE_SERVICE"); if (*(r.out.access_mask) & LSA_POLICY_MODE_PROXY) - printf(" LSA_POLICY_MODE_PROXY"); + torture_comment(tctx, " LSA_POLICY_MODE_PROXY"); if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_INTERACTIVE) - printf(" LSA_POLICY_MODE_DENY_INTERACTIVE"); + torture_comment(tctx, " LSA_POLICY_MODE_DENY_INTERACTIVE"); if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_NETWORK) - printf(" LSA_POLICY_MODE_DENY_NETWORK"); + torture_comment(tctx, " LSA_POLICY_MODE_DENY_NETWORK"); if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_BATCH) - printf(" LSA_POLICY_MODE_DENY_BATCH"); + torture_comment(tctx, " LSA_POLICY_MODE_DENY_BATCH"); if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_SERVICE) - printf(" LSA_POLICY_MODE_DENY_SERVICE"); + torture_comment(tctx, " LSA_POLICY_MODE_DENY_SERVICE"); if (*(r.out.access_mask) & LSA_POLICY_MODE_REMOTE_INTERACTIVE) - printf(" LSA_POLICY_MODE_REMOTE_INTERACTIVE"); + torture_comment(tctx, " LSA_POLICY_MODE_REMOTE_INTERACTIVE"); if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_REMOTE_INTERACTIVE) - printf(" LSA_POLICY_MODE_DENY_REMOTE_INTERACTIVE"); + torture_comment(tctx, " LSA_POLICY_MODE_DENY_REMOTE_INTERACTIVE"); if (*(r.out.access_mask) & LSA_POLICY_MODE_ALL) - printf(" LSA_POLICY_MODE_ALL"); + torture_comment(tctx, " LSA_POLICY_MODE_ALL"); if (*(r.out.access_mask) & LSA_POLICY_MODE_ALL_NT4) - printf(" LSA_POLICY_MODE_ALL_NT4"); - printf("\n"); + torture_comment(tctx, " LSA_POLICY_MODE_ALL_NT4"); + torture_comment(tctx, "\n"); } return true; @@ -1013,12 +1013,12 @@ static bool test_Delete(struct dcerpc_pipe *p, NTSTATUS status; struct lsa_Delete r; - printf("\nTesting Delete\n"); + torture_comment(tctx, "\nTesting Delete\n"); r.in.handle = handle; status = dcerpc_lsa_Delete(p, tctx, &r); if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { - printf("Delete should have failed NT_STATUS_NOT_SUPPORTED - %s\n", nt_errstr(status)); + torture_comment(tctx, "Delete should have failed NT_STATUS_NOT_SUPPORTED - %s\n", nt_errstr(status)); return false; } @@ -1032,13 +1032,13 @@ static bool test_DeleteObject(struct dcerpc_pipe *p, NTSTATUS status; struct lsa_DeleteObject r; - printf("\nTesting DeleteObject\n"); + torture_comment(tctx, "\nTesting DeleteObject\n"); r.in.handle = handle; r.out.handle = handle; status = dcerpc_lsa_DeleteObject(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("DeleteObject failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "DeleteObject failed - %s\n", nt_errstr(status)); return false; } @@ -1057,7 +1057,7 @@ static bool test_CreateAccount(struct dcerpc_pipe *p, newsid = dom_sid_parse_talloc(tctx, "S-1-5-12349876-4321-2854"); - printf("\nTesting CreateAccount\n"); + torture_comment(tctx, "\nTesting CreateAccount\n"); r.in.handle = handle; r.in.sid = newsid; @@ -1074,11 +1074,11 @@ static bool test_CreateAccount(struct dcerpc_pipe *p, status = dcerpc_lsa_OpenAccount(p, tctx, &r_o); if (!NT_STATUS_IS_OK(status)) { - printf("OpenAccount failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "OpenAccount failed - %s\n", nt_errstr(status)); return false; } } else if (!NT_STATUS_IS_OK(status)) { - printf("CreateAccount failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "CreateAccount failed - %s\n", nt_errstr(status)); return false; } @@ -1109,7 +1109,7 @@ static bool test_DeleteTrustedDomain(struct dcerpc_pipe *p, status = dcerpc_lsa_OpenTrustedDomainByName(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("OpenTrustedDomainByName failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "OpenTrustedDomainByName failed - %s\n", nt_errstr(status)); return false; } @@ -1137,7 +1137,7 @@ static bool test_DeleteTrustedDomainBySid(struct dcerpc_pipe *p, status = dcerpc_lsa_DeleteTrustedDomain(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("DeleteTrustedDomain failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "DeleteTrustedDomain failed - %s\n", nt_errstr(status)); return false; } @@ -1183,7 +1183,7 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, secname[GLOBAL] = talloc_asprintf(tctx, "G$torturesecret-%u", (uint_t)random()); for (i=0; i< 2; i++) { - printf("\nTesting CreateSecret of %s\n", secname[i]); + torture_comment(tctx, "\nTesting CreateSecret of %s\n", secname[i]); init_lsa_String(&r.in.name, secname[i]); @@ -1193,7 +1193,7 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_CreateSecret(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("CreateSecret failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "CreateSecret failed - %s\n", nt_errstr(status)); return false; } @@ -1203,7 +1203,7 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_CreateSecret(p, tctx, &r); if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { - printf("CreateSecret should have failed OBJECT_NAME_COLLISION - %s\n", nt_errstr(status)); + torture_comment(tctx, "CreateSecret should have failed OBJECT_NAME_COLLISION - %s\n", nt_errstr(status)); return false; } @@ -1212,17 +1212,17 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, r2.in.name = r.in.name; r2.out.sec_handle = &sec_handle2; - printf("Testing OpenSecret\n"); + torture_comment(tctx, "Testing OpenSecret\n"); status = dcerpc_lsa_OpenSecret(p, tctx, &r2); if (!NT_STATUS_IS_OK(status)) { - printf("OpenSecret failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "OpenSecret failed - %s\n", nt_errstr(status)); return false; } status = dcerpc_fetch_session_key(p, &session_key); if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_fetch_session_key failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "dcerpc_fetch_session_key failed - %s\n", nt_errstr(status)); return false; } @@ -1235,11 +1235,11 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, r3.in.new_val->length = enc_key.length; r3.in.new_val->size = enc_key.length; - printf("Testing SetSecret\n"); + torture_comment(tctx, "Testing SetSecret\n"); status = dcerpc_lsa_SetSecret(p, tctx, &r3); if (!NT_STATUS_IS_OK(status)) { - printf("SetSecret failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "SetSecret failed - %s\n", nt_errstr(status)); return false; } @@ -1253,11 +1253,11 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, /* break the encrypted data */ enc_key.data[0]++; - printf("Testing SetSecret with broken key\n"); + torture_comment(tctx, "Testing SetSecret with broken key\n"); status = dcerpc_lsa_SetSecret(p, tctx, &r3); if (!NT_STATUS_EQUAL(status, NT_STATUS_UNKNOWN_REVISION)) { - printf("SetSecret should have failed UNKNOWN_REVISION - %s\n", nt_errstr(status)); + torture_comment(tctx, "SetSecret should have failed UNKNOWN_REVISION - %s\n", nt_errstr(status)); ret = false; } @@ -1275,14 +1275,14 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, bufp1.buf = NULL; - printf("Testing QuerySecret\n"); + torture_comment(tctx, "Testing QuerySecret\n"); status = dcerpc_lsa_QuerySecret(p, tctx, &r4); if (!NT_STATUS_IS_OK(status)) { - printf("QuerySecret failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QuerySecret failed - %s\n", nt_errstr(status)); ret = false; } else { if (r4.out.new_val == NULL || r4.out.new_val->buf == NULL) { - printf("No secret buffer returned\n"); + torture_comment(tctx, "No secret buffer returned\n"); ret = false; } else { blob1.data = r4.out.new_val->buf->data; @@ -1294,7 +1294,7 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, &blob1, &session_key); if (strcmp(secret1, secret2) != 0) { - printf("Returned secret (r4) '%s' doesn't match '%s'\n", + torture_comment(tctx, "Returned secret (r4) '%s' doesn't match '%s'\n", secret2, secret1); ret = false; } @@ -1312,11 +1312,11 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, msleep(200); - printf("Testing SetSecret (existing value should move to old)\n"); + torture_comment(tctx, "Testing SetSecret (existing value should move to old)\n"); status = dcerpc_lsa_SetSecret(p, tctx, &r5); if (!NT_STATUS_IS_OK(status)) { - printf("SetSecret failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "SetSecret failed - %s\n", nt_errstr(status)); ret = false; } @@ -1337,14 +1337,14 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_QuerySecret(p, tctx, &r6); if (!NT_STATUS_IS_OK(status)) { - printf("QuerySecret failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QuerySecret failed - %s\n", nt_errstr(status)); ret = false; secret4 = NULL; } else { if (r6.out.new_val->buf == NULL || r6.out.old_val->buf == NULL || r6.out.new_mtime == NULL || r6.out.old_mtime == NULL) { - printf("Both secret buffers and both times not returned\n"); + torture_comment(tctx, "Both secret buffers and both times not returned\n"); ret = false; secret4 = NULL; } else { @@ -1357,7 +1357,7 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, &blob1, &session_key); if (strcmp(secret3, secret4) != 0) { - printf("Returned NEW secret %s doesn't match %s\n", secret4, secret3); + torture_comment(tctx, "Returned NEW secret %s doesn't match %s\n", secret4, secret3); ret = false; } @@ -1370,12 +1370,12 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, &blob1, &session_key); if (strcmp(secret1, secret2) != 0) { - printf("Returned OLD secret %s doesn't match %s\n", secret2, secret1); + torture_comment(tctx, "Returned OLD secret %s doesn't match %s\n", secret2, secret1); ret = false; } if (*r6.out.new_mtime == *r6.out.old_mtime) { - printf("Returned secret (r6-%d) %s must not have same mtime for both secrets: %s != %s\n", + torture_comment(tctx, "Returned secret (r6-%d) %s must not have same mtime for both secrets: %s != %s\n", i, secname[i], nt_time_string(tctx, *r6.out.old_mtime), @@ -1394,11 +1394,11 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, r7.in.old_val->size = enc_key.length; r7.in.new_val = NULL; - printf("Testing SetSecret of old Secret only\n"); + torture_comment(tctx, "Testing SetSecret of old Secret only\n"); status = dcerpc_lsa_SetSecret(p, tctx, &r7); if (!NT_STATUS_IS_OK(status)) { - printf("SetSecret failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "SetSecret failed - %s\n", nt_errstr(status)); ret = false; } @@ -1416,20 +1416,20 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_QuerySecret(p, tctx, &r8); if (!NT_STATUS_IS_OK(status)) { - printf("QuerySecret failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QuerySecret failed - %s\n", nt_errstr(status)); ret = false; } else { if (!r8.out.new_val || !r8.out.old_val) { - printf("in/out pointers not returned, despite being set on in for QuerySecret\n"); + torture_comment(tctx, "in/out pointers not returned, despite being set on in for QuerySecret\n"); ret = false; } else if (r8.out.new_val->buf != NULL) { - printf("NEW secret buffer must not be returned after OLD set\n"); + torture_comment(tctx, "NEW secret buffer must not be returned after OLD set\n"); ret = false; } else if (r8.out.old_val->buf == NULL) { - printf("OLD secret buffer was not returned after OLD set\n"); + torture_comment(tctx, "OLD secret buffer was not returned after OLD set\n"); ret = false; } else if (r8.out.new_mtime == NULL || r8.out.old_mtime == NULL) { - printf("Both times not returned after OLD set\n"); + torture_comment(tctx, "Both times not returned after OLD set\n"); ret = false; } else { blob1.data = r8.out.old_val->buf->data; @@ -1441,12 +1441,12 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, &blob1, &session_key); if (strcmp(secret5, secret6) != 0) { - printf("Returned OLD secret %s doesn't match %s\n", secret5, secret6); + torture_comment(tctx, "Returned OLD secret %s doesn't match %s\n", secret5, secret6); ret = false; } if (*r8.out.new_mtime != *r8.out.old_mtime) { - printf("Returned secret (r8) %s did not had same mtime for both secrets: %s != %s\n", + torture_comment(tctx, "Returned secret (r8) %s did not had same mtime for both secrets: %s != %s\n", secname[i], nt_time_string(tctx, *r8.out.old_mtime), nt_time_string(tctx, *r8.out.new_mtime)); @@ -1467,15 +1467,15 @@ static bool test_CreateSecret(struct dcerpc_pipe *p, d_o.out.handle = &sec_handle2; status = dcerpc_lsa_DeleteObject(p, tctx, &d_o); if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) { - printf("Second delete expected INVALID_HANDLE - %s\n", nt_errstr(status)); + torture_comment(tctx, "Second delete expected INVALID_HANDLE - %s\n", nt_errstr(status)); ret = false; } else { - printf("Testing OpenSecret of just-deleted secret\n"); + torture_comment(tctx, "Testing OpenSecret of just-deleted secret\n"); status = dcerpc_lsa_OpenSecret(p, tctx, &r2); if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { - printf("OpenSecret expected OBJECT_NAME_NOT_FOUND - %s\n", nt_errstr(status)); + torture_comment(tctx, "OpenSecret expected OBJECT_NAME_NOT_FOUND - %s\n", nt_errstr(status)); ret = false; } } @@ -1495,7 +1495,7 @@ static bool test_EnumAccountRights(struct dcerpc_pipe *p, struct lsa_EnumAccountRights r; struct lsa_RightSet rights; - printf("\nTesting EnumAccountRights\n"); + torture_comment(tctx, "\nTesting EnumAccountRights\n"); r.in.handle = acct_handle; r.in.sid = sid; @@ -1503,7 +1503,7 @@ static bool test_EnumAccountRights(struct dcerpc_pipe *p, status = dcerpc_lsa_EnumAccountRights(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("EnumAccountRights of %s failed - %s\n", + torture_comment(tctx, "EnumAccountRights of %s failed - %s\n", dom_sid_string(tctx, sid), nt_errstr(status)); return false; } @@ -1522,19 +1522,21 @@ static bool test_QuerySecurity(struct dcerpc_pipe *p, struct sec_desc_buf *sdbuf = NULL; if (torture_setting_bool(tctx, "samba4", false)) { - printf("\nskipping QuerySecurity test against Samba4\n"); + torture_comment(tctx, "\nskipping QuerySecurity test against Samba4\n"); return true; } - printf("\nTesting QuerySecurity\n"); + torture_comment(tctx, "\nTesting QuerySecurity\n"); r.in.handle = acct_handle; - r.in.sec_info = 7; + r.in.sec_info = SECINFO_OWNER | + SECINFO_GROUP | + SECINFO_DACL; r.out.sdbuf = &sdbuf; status = dcerpc_lsa_QuerySecurity(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("QuerySecurity failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QuerySecurity failed - %s\n", nt_errstr(status)); return false; } @@ -1550,7 +1552,7 @@ static bool test_OpenAccount(struct dcerpc_pipe *p, struct lsa_OpenAccount r; struct policy_handle acct_handle; - printf("\nTesting OpenAccount\n"); + torture_comment(tctx, "\nTesting OpenAccount\n"); r.in.handle = handle; r.in.sid = sid; @@ -1559,7 +1561,7 @@ static bool test_OpenAccount(struct dcerpc_pipe *p, status = dcerpc_lsa_OpenAccount(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("OpenAccount failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "OpenAccount failed - %s\n", nt_errstr(status)); return false; } @@ -1589,7 +1591,7 @@ static bool test_EnumAccounts(struct dcerpc_pipe *p, int i; bool ret = true; - printf("\nTesting EnumAccounts\n"); + torture_comment(tctx, "\nTesting EnumAccounts\n"); r.in.handle = handle; r.in.resume_handle = &resume_handle; @@ -1604,7 +1606,7 @@ static bool test_EnumAccounts(struct dcerpc_pipe *p, break; } if (!NT_STATUS_IS_OK(status)) { - printf("EnumAccounts failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "EnumAccounts failed - %s\n", nt_errstr(status)); return false; } @@ -1620,31 +1622,31 @@ static bool test_EnumAccounts(struct dcerpc_pipe *p, * be on schannel, or we would not be able to do the * rest */ - printf("Testing all accounts\n"); + torture_comment(tctx, "Testing all accounts\n"); for (i=0;i<sids1.num_sids;i++) { ret &= test_OpenAccount(p, tctx, handle, sids1.sids[i].sid); ret &= test_EnumAccountRights(p, tctx, handle, sids1.sids[i].sid); } - printf("\n"); + torture_comment(tctx, "\n"); } if (sids1.num_sids < 3) { return ret; } - printf("Trying EnumAccounts partial listing (asking for 1 at 2)\n"); + torture_comment(tctx, "Trying EnumAccounts partial listing (asking for 1 at 2)\n"); resume_handle = 2; r.in.num_entries = 1; r.out.sids = &sids2; status = dcerpc_lsa_EnumAccounts(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("EnumAccounts failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "EnumAccounts failed - %s\n", nt_errstr(status)); return false; } if (sids2.num_sids != 1) { - printf("Returned wrong number of entries (%d)\n", sids2.num_sids); + torture_comment(tctx, "Returned wrong number of entries (%d)\n", sids2.num_sids); return false; } @@ -1664,7 +1666,7 @@ static bool test_LookupPrivDisplayName(struct dcerpc_pipe *p, uint16_t returned_language_id = 0; struct lsa_StringLarge *disp_name = NULL; - printf("\nTesting LookupPrivDisplayName(%s)\n", priv_name->string); + torture_comment(tctx, "\nTesting LookupPrivDisplayName(%s)\n", priv_name->string); r.in.handle = handle; r.in.name = priv_name; @@ -1675,10 +1677,10 @@ static bool test_LookupPrivDisplayName(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupPrivDisplayName(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("LookupPrivDisplayName failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "LookupPrivDisplayName failed - %s\n", nt_errstr(status)); return false; } - printf("%s -> \"%s\" (language 0x%x/0x%x)\n", + torture_comment(tctx, "%s -> \"%s\" (language 0x%x/0x%x)\n", priv_name->string, disp_name->string, r.in.language_id, *r.out.returned_language_id); @@ -1696,7 +1698,7 @@ static bool test_EnumAccountsWithUserRight(struct dcerpc_pipe *p, ZERO_STRUCT(sids); - printf("\nTesting EnumAccountsWithUserRight(%s)\n", priv_name->string); + torture_comment(tctx, "\nTesting EnumAccountsWithUserRight(%s)\n", priv_name->string); r.in.handle = handle; r.in.name = priv_name; @@ -1710,7 +1712,7 @@ static bool test_EnumAccountsWithUserRight(struct dcerpc_pipe *p, } if (!NT_STATUS_IS_OK(status)) { - printf("EnumAccountsWithUserRight failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "EnumAccountsWithUserRight failed - %s\n", nt_errstr(status)); return false; } @@ -1729,7 +1731,7 @@ static bool test_EnumPrivs(struct dcerpc_pipe *p, int i; bool ret = true; - printf("\nTesting EnumPrivs\n"); + torture_comment(tctx, "\nTesting EnumPrivs\n"); r.in.handle = handle; r.in.resume_handle = &resume_handle; @@ -1740,7 +1742,7 @@ static bool test_EnumPrivs(struct dcerpc_pipe *p, resume_handle = 0; status = dcerpc_lsa_EnumPrivs(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("EnumPrivs failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "EnumPrivs failed - %s\n", nt_errstr(status)); return false; } @@ -1766,10 +1768,10 @@ static bool test_QueryForestTrustInformation(struct dcerpc_pipe *p, struct lsa_String string; struct lsa_ForestTrustInformation info, *info_ptr; - printf("\nTesting lsaRQueryForestTrustInformation\n"); + torture_comment(tctx, "\nTesting lsaRQueryForestTrustInformation\n"); if (torture_setting_bool(tctx, "samba4", false)) { - printf("skipping QueryForestTrustInformation against Samba4\n"); + torture_comment(tctx, "skipping QueryForestTrustInformation against Samba4\n"); return true; } @@ -1789,7 +1791,7 @@ static bool test_QueryForestTrustInformation(struct dcerpc_pipe *p, status = dcerpc_lsa_lsaRQueryForestTrustInformation(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("lsaRQueryForestTrustInformation of %s failed - %s\n", trusted_domain_name, nt_errstr(status)); + torture_comment(tctx, "lsaRQueryForestTrustInformation of %s failed - %s\n", trusted_domain_name, nt_errstr(status)); ret = false; } @@ -1824,7 +1826,7 @@ static bool test_query_each_TrustDom(struct dcerpc_pipe *p, int i,j; bool ret = true; - printf("\nTesting OpenTrustedDomain, OpenTrustedDomainByName and QueryInfoTrustedDomain\n"); + torture_comment(tctx, "\nTesting OpenTrustedDomain, OpenTrustedDomainByName and QueryInfoTrustedDomain\n"); for (i=0; i< domains->count; i++) { struct lsa_OpenTrustedDomain trust; struct lsa_OpenTrustedDomainByName trust_by_name; @@ -1844,7 +1846,7 @@ static bool test_query_each_TrustDom(struct dcerpc_pipe *p, status = dcerpc_lsa_OpenTrustedDomain(p, tctx, &trust); if (!NT_STATUS_IS_OK(status)) { - printf("OpenTrustedDomain failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "OpenTrustedDomain failed - %s\n", nt_errstr(status)); return false; } @@ -1862,11 +1864,11 @@ static bool test_query_each_TrustDom(struct dcerpc_pipe *p, q.out.info = &info; status = dcerpc_lsa_QueryTrustedDomainInfo(p, tctx, &q); if (!NT_STATUS_IS_OK(status) && ok[j]) { - printf("QueryTrustedDomainInfo level %d failed - %s\n", + torture_comment(tctx, "QueryTrustedDomainInfo level %d failed - %s\n", levels[j], nt_errstr(status)); ret = false; } else if (NT_STATUS_IS_OK(status) && !ok[j]) { - printf("QueryTrustedDomainInfo level %d unexpectedly succeeded - %s\n", + torture_comment(tctx, "QueryTrustedDomainInfo level %d unexpectedly succeeded - %s\n", levels[j], nt_errstr(status)); ret = false; } @@ -1874,7 +1876,7 @@ static bool test_query_each_TrustDom(struct dcerpc_pipe *p, status = dcerpc_lsa_CloseTrustedDomainEx(p, tctx, &c_trust); if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) { - printf("Expected CloseTrustedDomainEx to return NT_STATUS_NOT_IMPLEMENTED, instead - %s\n", nt_errstr(status)); + torture_comment(tctx, "Expected CloseTrustedDomainEx to return NT_STATUS_NOT_IMPLEMENTED, instead - %s\n", nt_errstr(status)); return false; } @@ -1883,7 +1885,7 @@ static bool test_query_each_TrustDom(struct dcerpc_pipe *p, status = dcerpc_lsa_Close(p, tctx, &c); if (!NT_STATUS_IS_OK(status)) { - printf("Close of trusted domain failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "Close of trusted domain failed - %s\n", nt_errstr(status)); return false; } @@ -1902,11 +1904,11 @@ static bool test_query_each_TrustDom(struct dcerpc_pipe *p, status = dcerpc_lsa_QueryTrustedDomainInfoBySid(p, tctx, &q); if (!NT_STATUS_IS_OK(status) && ok[j]) { - printf("QueryTrustedDomainInfoBySid level %d failed - %s\n", + torture_comment(tctx, "QueryTrustedDomainInfoBySid level %d failed - %s\n", levels[j], nt_errstr(status)); ret = false; } else if (NT_STATUS_IS_OK(status) && !ok[j]) { - printf("QueryTrustedDomainInfoBySid level %d unexpectedly succeeded - %s\n", + torture_comment(tctx, "QueryTrustedDomainInfoBySid level %d unexpectedly succeeded - %s\n", levels[j], nt_errstr(status)); ret = false; } @@ -1921,7 +1923,7 @@ static bool test_query_each_TrustDom(struct dcerpc_pipe *p, status = dcerpc_lsa_OpenTrustedDomainByName(p, tctx, &trust_by_name); if (!NT_STATUS_IS_OK(status)) { - printf("OpenTrustedDomainByName failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "OpenTrustedDomainByName failed - %s\n", nt_errstr(status)); return false; } @@ -1933,11 +1935,11 @@ static bool test_query_each_TrustDom(struct dcerpc_pipe *p, q.out.info = &info; status = dcerpc_lsa_QueryTrustedDomainInfo(p, tctx, &q); if (!NT_STATUS_IS_OK(status) && ok[j]) { - printf("QueryTrustedDomainInfo level %d failed - %s\n", + torture_comment(tctx, "QueryTrustedDomainInfo level %d failed - %s\n", levels[j], nt_errstr(status)); ret = false; } else if (NT_STATUS_IS_OK(status) && !ok[j]) { - printf("QueryTrustedDomainInfo level %d unexpectedly succeeded - %s\n", + torture_comment(tctx, "QueryTrustedDomainInfo level %d unexpectedly succeeded - %s\n", levels[j], nt_errstr(status)); ret = false; } @@ -1948,7 +1950,7 @@ static bool test_query_each_TrustDom(struct dcerpc_pipe *p, status = dcerpc_lsa_Close(p, tctx, &c); if (!NT_STATUS_IS_OK(status)) { - printf("Close of trusted domain failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "Close of trusted domain failed - %s\n", nt_errstr(status)); return false; } @@ -1965,11 +1967,11 @@ static bool test_query_each_TrustDom(struct dcerpc_pipe *p, q.out.info = &info; status = dcerpc_lsa_QueryTrustedDomainInfoByName(p, tctx, &q); if (!NT_STATUS_IS_OK(status) && ok[j]) { - printf("QueryTrustedDomainInfoByName level %d failed - %s\n", + torture_comment(tctx, "QueryTrustedDomainInfoByName level %d failed - %s\n", levels[j], nt_errstr(status)); ret = false; } else if (NT_STATUS_IS_OK(status) && !ok[j]) { - printf("QueryTrustedDomainInfoByName level %d unexpectedly succeeded - %s\n", + torture_comment(tctx, "QueryTrustedDomainInfoByName level %d unexpectedly succeeded - %s\n", levels[j], nt_errstr(status)); ret = false; } @@ -1990,7 +1992,7 @@ static bool test_EnumTrustDom(struct dcerpc_pipe *p, struct lsa_DomainListEx domains_ex; bool ret = true; - printf("\nTesting EnumTrustDom\n"); + torture_comment(tctx, "\nTesting EnumTrustDom\n"); r.in.handle = handle; r.in.resume_handle = &resume_handle; @@ -2002,11 +2004,11 @@ static bool test_EnumTrustDom(struct dcerpc_pipe *p, if (NT_STATUS_IS_OK(enum_status)) { if (domains.count == 0) { - printf("EnumTrustDom failed - should have returned 'NT_STATUS_NO_MORE_ENTRIES' for 0 trusted domains\n"); + torture_comment(tctx, "EnumTrustDom failed - should have returned 'NT_STATUS_NO_MORE_ENTRIES' for 0 trusted domains\n"); return false; } } else if (!(NT_STATUS_EQUAL(enum_status, STATUS_MORE_ENTRIES) || NT_STATUS_EQUAL(enum_status, NT_STATUS_NO_MORE_ENTRIES))) { - printf("EnumTrustDom of zero size failed - %s\n", nt_errstr(enum_status)); + torture_comment(tctx, "EnumTrustDom of zero size failed - %s\n", nt_errstr(enum_status)); return false; } @@ -2027,24 +2029,24 @@ static bool test_EnumTrustDom(struct dcerpc_pipe *p, if (domains.count == 0) { return true; } - printf("EnumTrustDom failed - should have returned 0 trusted domains with 'NT_STATUS_NO_MORE_ENTRIES'\n"); + torture_comment(tctx, "EnumTrustDom failed - should have returned 0 trusted domains with 'NT_STATUS_NO_MORE_ENTRIES'\n"); return false; } else if (NT_STATUS_EQUAL(enum_status, STATUS_MORE_ENTRIES)) { /* Windows 2003 gets this off by one on the first run */ if (r.out.domains->count < 3 || r.out.domains->count > 4) { - printf("EnumTrustDom didn't fill the buffer we " + torture_comment(tctx, "EnumTrustDom didn't fill the buffer we " "asked it to (got %d, expected %d / %d == %d entries)\n", r.out.domains->count, LSA_ENUM_TRUST_DOMAIN_MULTIPLIER * 3, LSA_ENUM_TRUST_DOMAIN_MULTIPLIER, r.in.max_size); ret = false; } } else if (!NT_STATUS_IS_OK(enum_status)) { - printf("EnumTrustDom failed - %s\n", nt_errstr(enum_status)); + torture_comment(tctx, "EnumTrustDom failed - %s\n", nt_errstr(enum_status)); return false; } if (domains.count == 0) { - printf("EnumTrustDom failed - should have returned 'NT_STATUS_NO_MORE_ENTRIES' for 0 trusted domains\n"); + torture_comment(tctx, "EnumTrustDom failed - should have returned 'NT_STATUS_NO_MORE_ENTRIES' for 0 trusted domains\n"); return false; } @@ -2052,7 +2054,7 @@ static bool test_EnumTrustDom(struct dcerpc_pipe *p, } while ((NT_STATUS_EQUAL(enum_status, STATUS_MORE_ENTRIES))); - printf("\nTesting EnumTrustedDomainsEx\n"); + torture_comment(tctx, "\nTesting EnumTrustedDomainsEx\n"); r_ex.in.handle = handle; r_ex.in.resume_handle = &resume_handle; @@ -2063,7 +2065,7 @@ static bool test_EnumTrustDom(struct dcerpc_pipe *p, enum_status = dcerpc_lsa_EnumTrustedDomainsEx(p, tctx, &r_ex); if (!(NT_STATUS_EQUAL(enum_status, STATUS_MORE_ENTRIES) || NT_STATUS_EQUAL(enum_status, NT_STATUS_NO_MORE_ENTRIES))) { - printf("EnumTrustedDomainEx of zero size failed - %s\n", nt_errstr(enum_status)); + torture_comment(tctx, "EnumTrustedDomainEx of zero size failed - %s\n", nt_errstr(enum_status)); return false; } @@ -2082,12 +2084,12 @@ static bool test_EnumTrustDom(struct dcerpc_pipe *p, if (domains_ex.count == 0) { return true; } - printf("EnumTrustDomainsEx failed - should have returned 0 trusted domains with 'NT_STATUS_NO_MORE_ENTRIES'\n"); + torture_comment(tctx, "EnumTrustDomainsEx failed - should have returned 0 trusted domains with 'NT_STATUS_NO_MORE_ENTRIES'\n"); return false; } else if (NT_STATUS_EQUAL(enum_status, STATUS_MORE_ENTRIES)) { /* Windows 2003 gets this off by one on the first run */ if (r_ex.out.domains->count < 3 || r_ex.out.domains->count > 4) { - printf("EnumTrustDom didn't fill the buffer we " + torture_comment(tctx, "EnumTrustDom didn't fill the buffer we " "asked it to (got %d, expected %d / %d == %d entries)\n", r_ex.out.domains->count, r_ex.in.max_size, @@ -2095,12 +2097,12 @@ static bool test_EnumTrustDom(struct dcerpc_pipe *p, r_ex.in.max_size / LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER); } } else if (!NT_STATUS_IS_OK(enum_status)) { - printf("EnumTrustedDomainEx failed - %s\n", nt_errstr(enum_status)); + torture_comment(tctx, "EnumTrustedDomainEx failed - %s\n", nt_errstr(enum_status)); return false; } if (domains_ex.count == 0) { - printf("EnumTrustDomainEx failed - should have returned 'NT_STATUS_NO_MORE_ENTRIES' for 0 trusted domains\n"); + torture_comment(tctx, "EnumTrustDomainEx failed - should have returned 'NT_STATUS_NO_MORE_ENTRIES' for 0 trusted domains\n"); return false; } @@ -2125,7 +2127,7 @@ static bool test_CreateTrustedDomain(struct dcerpc_pipe *p, union lsa_TrustedDomainInfo *info = NULL; int i; - printf("\nTesting CreateTrustedDomain for 12 domains\n"); + torture_comment(tctx, "\nTesting CreateTrustedDomain for 12 domains\n"); if (!test_EnumTrustDom(p, tctx, handle)) { ret = false; @@ -2151,7 +2153,7 @@ static bool test_CreateTrustedDomain(struct dcerpc_pipe *p, status = dcerpc_lsa_CreateTrustedDomain(p, tctx, &r); } if (!NT_STATUS_IS_OK(status)) { - printf("CreateTrustedDomain failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "CreateTrustedDomain failed - %s\n", nt_errstr(status)); ret = false; } else { @@ -2160,28 +2162,28 @@ static bool test_CreateTrustedDomain(struct dcerpc_pipe *p, q.out.info = &info; status = dcerpc_lsa_QueryTrustedDomainInfo(p, tctx, &q); if (!NT_STATUS_IS_OK(status)) { - printf("QueryTrustedDomainInfo level 1 failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QueryTrustedDomainInfo level 1 failed - %s\n", nt_errstr(status)); ret = false; } else if (!q.out.info) { ret = false; } else { if (strcmp(info->info_ex.netbios_name.string, trustinfo.name.string) != 0) { - printf("QueryTrustedDomainInfo returned inconsistant short name: %s != %s\n", + torture_comment(tctx, "QueryTrustedDomainInfo returned inconsistant short name: %s != %s\n", info->info_ex.netbios_name.string, trustinfo.name.string); ret = false; } if (info->info_ex.trust_type != LSA_TRUST_TYPE_DOWNLEVEL) { - printf("QueryTrustedDomainInfo of %s returned incorrect trust type %d != %d\n", + torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust type %d != %d\n", trust_name, info->info_ex.trust_type, LSA_TRUST_TYPE_DOWNLEVEL); ret = false; } if (info->info_ex.trust_attributes != 0) { - printf("QueryTrustedDomainInfo of %s returned incorrect trust attributes %d != %d\n", + torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust attributes %d != %d\n", trust_name, info->info_ex.trust_attributes, 0); ret = false; } if (info->info_ex.trust_direction != LSA_TRUST_DIRECTION_OUTBOUND) { - printf("QueryTrustedDomainInfo of %s returned incorrect trust direction %d != %d\n", + torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust direction %d != %d\n", trust_name, info->info_ex.trust_direction, LSA_TRUST_DIRECTION_OUTBOUND); ret = false; } @@ -2222,11 +2224,11 @@ static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p, enum ndr_err_code ndr_err; int i; - printf("\nTesting CreateTrustedDomainEx2 for 12 domains\n"); + torture_comment(tctx, "\nTesting CreateTrustedDomainEx2 for 12 domains\n"); status = dcerpc_fetch_session_key(p, &session_key); if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_fetch_session_key failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "dcerpc_fetch_session_key failed - %s\n", nt_errstr(status)); return false; } @@ -2263,7 +2265,7 @@ static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p, ndr_err = ndr_push_struct_blob(&auth_blob, tctx, lp_iconv_convenience(tctx->lp_ctx), &auth_struct, (ndr_push_flags_fn_t)ndr_push_trustDomainPasswords); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { - printf("ndr_push_struct_blob of trustDomainPasswords structure failed"); + torture_comment(tctx, "ndr_push_struct_blob of trustDomainPasswords structure failed"); ret = false; } @@ -2284,7 +2286,7 @@ static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p, status = dcerpc_lsa_CreateTrustedDomainEx2(p, tctx, &r); } if (!NT_STATUS_IS_OK(status)) { - printf("CreateTrustedDomainEx failed2 - %s\n", nt_errstr(status)); + torture_comment(tctx, "CreateTrustedDomainEx failed2 - %s\n", nt_errstr(status)); ret = false; } else { @@ -2293,29 +2295,29 @@ static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p, q.out.info = &info; status = dcerpc_lsa_QueryTrustedDomainInfo(p, tctx, &q); if (!NT_STATUS_IS_OK(status)) { - printf("QueryTrustedDomainInfo level 1 failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QueryTrustedDomainInfo level 1 failed - %s\n", nt_errstr(status)); ret = false; } else if (!q.out.info) { - printf("QueryTrustedDomainInfo level 1 failed to return an info pointer\n"); + torture_comment(tctx, "QueryTrustedDomainInfo level 1 failed to return an info pointer\n"); ret = false; } else { if (strcmp(info->info_ex.netbios_name.string, trustinfo.netbios_name.string) != 0) { - printf("QueryTrustedDomainInfo returned inconsistant short name: %s != %s\n", + torture_comment(tctx, "QueryTrustedDomainInfo returned inconsistant short name: %s != %s\n", info->info_ex.netbios_name.string, trustinfo.netbios_name.string); ret = false; } if (info->info_ex.trust_type != trustinfo.trust_type) { - printf("QueryTrustedDomainInfo of %s returned incorrect trust type %d != %d\n", + torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust type %d != %d\n", trust_name, info->info_ex.trust_type, trustinfo.trust_type); ret = false; } if (info->info_ex.trust_attributes != LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION) { - printf("QueryTrustedDomainInfo of %s returned incorrect trust attributes %d != %d\n", + torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust attributes %d != %d\n", trust_name, info->info_ex.trust_attributes, LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION); ret = false; } if (info->info_ex.trust_direction != trustinfo.trust_direction) { - printf("QueryTrustedDomainInfo of %s returned incorrect trust direction %d != %d\n", + torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust direction %d != %d\n", trust_name, info->info_ex.trust_direction, trustinfo.trust_direction); ret = false; } @@ -2325,13 +2327,13 @@ static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p, /* now that we have some domains to look over, we can test the enum calls */ if (!test_EnumTrustDom(p, tctx, handle)) { - printf("test_EnumTrustDom failed\n"); + torture_comment(tctx, "test_EnumTrustDom failed\n"); ret = false; } for (i=0; i<12; i++) { if (!test_DeleteTrustedDomainBySid(p, tctx, handle, domsid[i])) { - printf("test_DeleteTrustedDomainBySid failed\n"); + torture_comment(tctx, "test_DeleteTrustedDomainBySid failed\n"); ret = false; } } @@ -2349,14 +2351,14 @@ static bool test_QueryDomainInfoPolicy(struct dcerpc_pipe *p, int i; bool ret = true; - printf("\nTesting QueryDomainInformationPolicy\n"); + torture_comment(tctx, "\nTesting QueryDomainInformationPolicy\n"); for (i=2;i<4;i++) { r.in.handle = handle; r.in.level = i; r.out.info = &info; - printf("\nTrying QueryDomainInformationPolicy level %d\n", i); + torture_comment(tctx, "\nTrying QueryDomainInformationPolicy level %d\n", i); status = dcerpc_lsa_QueryDomainInformationPolicy(p, tctx, &r); @@ -2364,7 +2366,7 @@ static bool test_QueryDomainInfoPolicy(struct dcerpc_pipe *p, if (i == LSA_DOMAIN_INFO_POLICY_EFS && NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { continue; } else if (!NT_STATUS_IS_OK(status)) { - printf("QueryDomainInformationPolicy failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QueryDomainInformationPolicy failed - %s\n", nt_errstr(status)); ret = false; continue; } @@ -2386,9 +2388,9 @@ static bool test_QueryInfoPolicyCalls( bool version2, bool ret = true; if (version2) - printf("\nTesting QueryInfoPolicy2\n"); + torture_comment(tctx, "\nTesting QueryInfoPolicy2\n"); else - printf("\nTesting QueryInfoPolicy\n"); + torture_comment(tctx, "\nTesting QueryInfoPolicy\n"); for (i=1;i<=14;i++) { r.in.handle = handle; @@ -2396,9 +2398,9 @@ static bool test_QueryInfoPolicyCalls( bool version2, r.out.info = &info; if (version2) - printf("\nTrying QueryInfoPolicy2 level %d\n", i); + torture_comment(tctx, "\nTrying QueryInfoPolicy2 level %d\n", i); else - printf("\nTrying QueryInfoPolicy level %d\n", i); + torture_comment(tctx, "\nTrying QueryInfoPolicy level %d\n", i); if (version2) /* We can perform the cast, because both types are @@ -2413,7 +2415,7 @@ static bool test_QueryInfoPolicyCalls( bool version2, case LSA_POLICY_INFO_AUDIT_FULL_SET: case LSA_POLICY_INFO_AUDIT_FULL_QUERY: if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { - printf("Server should have failed level %u: %s\n", i, nt_errstr(status)); + torture_comment(tctx, "Server should have failed level %u: %s\n", i, nt_errstr(status)); ret = false; } break; @@ -2430,9 +2432,9 @@ static bool test_QueryInfoPolicyCalls( bool version2, case LSA_POLICY_INFO_PD: if (!NT_STATUS_IS_OK(status)) { if (version2) - printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); else - printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QueryInfoPolicy failed - %s\n", nt_errstr(status)); ret = false; } break; @@ -2441,16 +2443,16 @@ static bool test_QueryInfoPolicyCalls( bool version2, /* Other levels not implemented yet */ if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) { if (version2) - printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); else - printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QueryInfoPolicy failed - %s\n", nt_errstr(status)); ret = false; } } else if (!NT_STATUS_IS_OK(status)) { if (version2) - printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); else - printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "QueryInfoPolicy failed - %s\n", nt_errstr(status)); ret = false; } break; @@ -2522,7 +2524,7 @@ static bool test_GetUserName(struct dcerpc_pipe *p, struct lsa_String *authority_name_p = NULL; struct lsa_String *account_name_p = NULL; - printf("\nTesting GetUserName\n"); + torture_comment(tctx, "\nTesting GetUserName\n"); r.in.system_name = "\\"; r.in.account_name = &account_name_p; @@ -2532,7 +2534,7 @@ static bool test_GetUserName(struct dcerpc_pipe *p, status = dcerpc_lsa_GetUserName(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("GetUserName failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "GetUserName failed - %s\n", nt_errstr(status)); ret = false; } @@ -2544,7 +2546,7 @@ static bool test_GetUserName(struct dcerpc_pipe *p, status = dcerpc_lsa_GetUserName(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("GetUserName failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "GetUserName failed - %s\n", nt_errstr(status)); ret = false; } @@ -2559,25 +2561,25 @@ bool test_lsa_Close(struct dcerpc_pipe *p, struct lsa_Close r; struct policy_handle handle2; - printf("\nTesting Close\n"); + torture_comment(tctx, "\nTesting Close\n"); r.in.handle = handle; r.out.handle = &handle2; status = dcerpc_lsa_Close(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("Close failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "Close failed - %s\n", nt_errstr(status)); return false; } status = dcerpc_lsa_Close(p, tctx, &r); /* its really a fault - we need a status code for rpc fault */ if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - printf("Close failed - %s\n", nt_errstr(status)); + torture_comment(tctx, "Close failed - %s\n", nt_errstr(status)); return false; } - printf("\n"); + torture_comment(tctx, "\n"); return true; } @@ -2625,28 +2627,9 @@ bool torture_rpc_lsa(struct torture_context *tctx) ret = false; } - if (!test_CreateAccount(p, tctx, handle)) { - ret = false; - } - if (!test_CreateSecret(p, tctx, handle)) { ret = false; } - if (!test_CreateTrustedDomain(p, tctx, handle)) { - ret = false; - } - - if (!test_CreateTrustedDomainEx2(p, tctx, handle)) { - ret = false; - } - - if (!test_EnumAccounts(p, tctx, handle)) { - ret = false; - } - - if (!test_EnumPrivs(p, tctx, handle)) { - ret = false; - } if (!test_QueryInfoPolicy(p, tctx, handle)) { ret = false; @@ -2766,3 +2749,104 @@ struct torture_suite *torture_rpc_lsa_lookup_names(TALLOC_CTX *mem_ctx) return suite; } + +static bool testcase_TrustedDomains(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + bool ret = true; + struct policy_handle *handle; + + if (!test_OpenPolicy(p, tctx)) { + ret = false; + } + + if (!test_lsa_OpenPolicy2(p, tctx, &handle)) { + ret = false; + } + + if (!handle) { + ret = false; + } + + if (!test_CreateTrustedDomain(p, tctx, handle)) { + ret = false; + } + + if (!test_CreateTrustedDomainEx2(p, tctx, handle)) { + ret = false; + } + + if (!test_lsa_Close(p, tctx, handle)) { + ret = false; + } + + return ret; +} + +struct torture_suite *torture_rpc_lsa_trusted_domains(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite; + struct torture_rpc_tcase *tcase; + + suite = torture_suite_create(mem_ctx, "LSA-TRUSTED-DOMAINS"); + + tcase = torture_suite_add_rpc_iface_tcase(suite, "lsa", + &ndr_table_lsarpc); + torture_rpc_tcase_add_test(tcase, "TrustedDomains", + testcase_TrustedDomains); + + return suite; +} + +static bool testcase_Privileges(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + bool ret = true; + struct policy_handle *handle; + + if (!test_OpenPolicy(p, tctx)) { + ret = false; + } + + if (!test_lsa_OpenPolicy2(p, tctx, &handle)) { + ret = false; + } + + if (!handle) { + ret = false; + } + + if (!test_CreateAccount(p, tctx, handle)) { + ret = false; + } + + if (!test_EnumAccounts(p, tctx, handle)) { + ret = false; + } + + if (!test_EnumPrivs(p, tctx, handle)) { + ret = false; + } + + if (!test_lsa_Close(p, tctx, handle)) { + ret = false; + } + + return ret; +} + + +struct torture_suite *torture_rpc_lsa_privileges(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite; + struct torture_rpc_tcase *tcase; + + suite = torture_suite_create(mem_ctx, "LSA-PRIVILEGES"); + + tcase = torture_suite_add_rpc_iface_tcase(suite, "lsa", + &ndr_table_lsarpc); + torture_rpc_tcase_add_test(tcase, "Privileges", + testcase_Privileges); + + return suite; +} diff --git a/source4/torture/rpc/object_uuid.c b/source4/torture/rpc/object_uuid.c index a70266697e..53d03a3ce9 100644 --- a/source4/torture/rpc/object_uuid.c +++ b/source4/torture/rpc/object_uuid.c @@ -35,7 +35,6 @@ static bool test_random_uuid(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p1, *p2; - struct rpc_request *req; struct GUID uuid; struct dssetup_DsRoleGetPrimaryDomainInformation r1; struct lsa_GetUserName r2; diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c index 4043562ab5..ffdd748470 100644 --- a/source4/torture/rpc/rpc.c +++ b/source4/torture/rpc/rpc.c @@ -431,6 +431,8 @@ NTSTATUS torture_rpc_init(void) torture_suite_add_suite(suite, torture_rpc_lsa_lookup_sids(suite)); torture_suite_add_suite(suite, torture_rpc_lsa_lookup_names(suite)); torture_suite_add_suite(suite, torture_rpc_lsa_secrets(suite)); + torture_suite_add_suite(suite, torture_rpc_lsa_trusted_domains(suite)); + torture_suite_add_suite(suite, torture_rpc_lsa_privileges(suite)); torture_suite_add_suite(suite, torture_rpc_echo(suite)); torture_suite_add_simple_test(suite, "DFS", torture_rpc_dfs); torture_suite_add_suite(suite, torture_rpc_frsapi(suite)); @@ -444,6 +446,7 @@ NTSTATUS torture_rpc_init(void) torture_suite_add_simple_test(suite, "SPOOLSS", torture_rpc_spoolss); torture_suite_add_suite(suite, torture_rpc_spoolss_notify(suite)); torture_suite_add_suite(suite, torture_rpc_spoolss_win(suite)); + torture_suite_add_suite(suite, torture_rpc_spoolss_printer(suite)); torture_suite_add_simple_test(suite, "SAMR", torture_rpc_samr); torture_suite_add_simple_test(suite, "SAMR-USERS", torture_rpc_samr_users); torture_suite_add_simple_test(suite, "SAMR-PASSWORDS", torture_rpc_samr_passwords); diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 10e18e1531..ddc14f33a2 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -26,6 +26,11 @@ #include "torture/rpc/rpc.h" #include "librpc/gen_ndr/ndr_spoolss_c.h" +#define TORTURE_WELLKNOWN_PRINTER "torture_wkn_printer" +#define TORTURE_PRINTER "torture_printer" +#define TORTURE_WELLKNOWN_PRINTER_EX "torture_wkn_printer_ex" +#define TORTURE_PRINTER_EX "torture_printer_ex" + struct test_spoolss_context { /* print server handle */ struct policy_handle server_handle; @@ -75,20 +80,22 @@ struct test_spoolss_context { #define COMPARE_STRING_ARRAY(tctx, c,r,e) -static bool test_OpenPrinter_server(struct torture_context *tctx, struct dcerpc_pipe *p, struct test_spoolss_context *ctx) +static bool test_OpenPrinter_server(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *server_handle) { NTSTATUS status; struct spoolss_OpenPrinter op; - op.in.printername = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p)); + op.in.printername = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); op.in.datatype = NULL; op.in.devmode_ctr.devmode= NULL; op.in.access_mask = 0; - op.out.handle = &ctx->server_handle; + op.out.handle = server_handle; torture_comment(tctx, "Testing OpenPrinter(%s)\n", op.in.printername); - status = dcerpc_spoolss_OpenPrinter(p, ctx, &op); + status = dcerpc_spoolss_OpenPrinter(p, tctx, &op); torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_OpenPrinter failed"); torture_assert_werr_ok(tctx, op.out.result, "dcerpc_spoolss_OpenPrinter failed"); @@ -810,6 +817,564 @@ static bool test_GetPrinter(struct torture_context *tctx, return true; } +static bool test_SetPrinter_errors(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) +{ + struct spoolss_SetPrinter r; + uint16_t levels[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + int i; + + struct spoolss_SetPrinterInfoCtr info_ctr; + struct spoolss_DevmodeContainer devmode_ctr; + struct sec_desc_buf secdesc_ctr; + + info_ctr.level = 0; + info_ctr.info.info0 = NULL; + + ZERO_STRUCT(devmode_ctr); + ZERO_STRUCT(secdesc_ctr); + + r.in.handle = handle; + r.in.info_ctr = &info_ctr; + r.in.devmode_ctr = &devmode_ctr; + r.in.secdesc_ctr = &secdesc_ctr; + r.in.command = 0; + + torture_comment(tctx, "Testing SetPrinter all zero\n"); + + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_SetPrinter(p, tctx, &r), + "failed to call SetPrinter"); + torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_PARAM, + "failed to call SetPrinter"); + + again: + for (i=0; i < ARRAY_SIZE(levels); i++) { + + struct spoolss_SetPrinterInfo0 info0; + struct spoolss_SetPrinterInfo1 info1; + struct spoolss_SetPrinterInfo2 info2; + struct spoolss_SetPrinterInfo3 info3; + struct spoolss_SetPrinterInfo4 info4; + struct spoolss_SetPrinterInfo5 info5; + struct spoolss_SetPrinterInfo6 info6; + struct spoolss_SetPrinterInfo7 info7; + struct spoolss_DeviceModeInfo info8; + struct spoolss_DeviceModeInfo info9; + + + info_ctr.level = levels[i]; + switch (levels[i]) { + case 0: + ZERO_STRUCT(info0); + info_ctr.info.info0 = &info0; + break; + case 1: + ZERO_STRUCT(info1); + info_ctr.info.info1 = &info1; + break; + case 2: + ZERO_STRUCT(info2); + info_ctr.info.info2 = &info2; + break; + case 3: + ZERO_STRUCT(info3); + info_ctr.info.info3 = &info3; + break; + case 4: + ZERO_STRUCT(info4); + info_ctr.info.info4 = &info4; + break; + case 5: + ZERO_STRUCT(info5); + info_ctr.info.info5 = &info5; + break; + case 6: + ZERO_STRUCT(info6); + info_ctr.info.info6 = &info6; + break; + case 7: + ZERO_STRUCT(info7); + info_ctr.info.info7 = &info7; + break; + case 8: + ZERO_STRUCT(info8); + info_ctr.info.info8 = &info8; + break; + case 9: + ZERO_STRUCT(info9); + info_ctr.info.info9 = &info9; + break; + } + + torture_comment(tctx, "Testing SetPrinter level %d, command %d\n", + info_ctr.level, r.in.command); + + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_SetPrinter(p, tctx, &r), + "failed to call SetPrinter"); + + switch (r.in.command) { + case SPOOLSS_PRINTER_CONTROL_UNPAUSE: /* 0 */ + /* is ignored for all levels other then 0 */ + if (info_ctr.level > 0) { + /* ignored then */ + break; + } + case SPOOLSS_PRINTER_CONTROL_PAUSE: /* 1 */ + case SPOOLSS_PRINTER_CONTROL_RESUME: /* 2 */ + case SPOOLSS_PRINTER_CONTROL_PURGE: /* 3 */ + if (info_ctr.level > 0) { + /* is invalid for all levels other then 0 */ + torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_PRINTER_COMMAND, + "unexpected error code returned"); + continue; + } else { + torture_assert_werr_ok(tctx, r.out.result, + "failed to call SetPrinter with non 0 command"); + continue; + } + break; + + case SPOOLSS_PRINTER_CONTROL_SET_STATUS: /* 4 */ + /* FIXME: gd needs further investigation */ + default: + torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_PRINTER_COMMAND, + "unexpected error code returned"); + continue; + } + + switch (info_ctr.level) { + case 1: + torture_assert_werr_equal(tctx, r.out.result, WERR_UNKNOWN_LEVEL, + "unexpected error code returned"); + break; + case 2: + torture_assert_werr_equal(tctx, r.out.result, WERR_UNKNOWN_PRINTER_DRIVER, + "unexpected error code returned"); + break; + case 3: + case 4: + case 5: + case 7: + torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_PARAM, + "unexpected error code returned"); + break; + case 9: + torture_assert_werr_equal(tctx, r.out.result, WERR_NOT_SUPPORTED, + "unexpected error code returned"); + break; + default: + torture_assert_werr_ok(tctx, r.out.result, + "failed to call SetPrinter"); + break; + } + } + + if (r.in.command < 5) { + r.in.command++; + goto again; + } + + return true; +} + +static void clear_info2(struct spoolss_SetPrinterInfoCtr *r) +{ + if ((r->level == 2) && (r->info.info2)) { + r->info.info2->secdesc = NULL; + r->info.info2->devmode = NULL; + } +} + +static bool test_PrinterInfo(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) +{ + NTSTATUS status; + struct spoolss_SetPrinter s; + struct spoolss_GetPrinter q; + struct spoolss_GetPrinter q0; + struct spoolss_SetPrinterInfoCtr info_ctr; + union spoolss_PrinterInfo info; + struct spoolss_DevmodeContainer devmode_ctr; + struct sec_desc_buf secdesc_ctr; + uint32_t needed; + bool ret = true; + int i; + + uint32_t status_list[] = { + /* these do not stick + PRINTER_STATUS_PAUSED, + PRINTER_STATUS_ERROR, + PRINTER_STATUS_PENDING_DELETION, */ + PRINTER_STATUS_PAPER_JAM, + PRINTER_STATUS_PAPER_OUT, + PRINTER_STATUS_MANUAL_FEED, + PRINTER_STATUS_PAPER_PROBLEM, + PRINTER_STATUS_OFFLINE, + PRINTER_STATUS_IO_ACTIVE, + PRINTER_STATUS_BUSY, + PRINTER_STATUS_PRINTING, + PRINTER_STATUS_OUTPUT_BIN_FULL, + PRINTER_STATUS_NOT_AVAILABLE, + PRINTER_STATUS_WAITING, + PRINTER_STATUS_PROCESSING, + PRINTER_STATUS_INITIALIZING, + PRINTER_STATUS_WARMING_UP, + PRINTER_STATUS_TONER_LOW, + PRINTER_STATUS_NO_TONER, + PRINTER_STATUS_PAGE_PUNT, + PRINTER_STATUS_USER_INTERVENTION, + PRINTER_STATUS_OUT_OF_MEMORY, + PRINTER_STATUS_DOOR_OPEN, + PRINTER_STATUS_SERVER_UNKNOWN, + PRINTER_STATUS_POWER_SAVE, + /* these do not stick + 0x02000000, + 0x04000000, + 0x08000000, + 0x10000000, + 0x20000000, + 0x40000000, + 0x80000000 */ + }; + uint32_t default_attribute = PRINTER_ATTRIBUTE_LOCAL; + uint32_t attribute_list[] = { + PRINTER_ATTRIBUTE_QUEUED, + /* fails with WERR_INVALID_DATATYPE: + PRINTER_ATTRIBUTE_DIRECT, */ + /* does not stick + PRINTER_ATTRIBUTE_DEFAULT, */ + PRINTER_ATTRIBUTE_SHARED, + /* does not stick + PRINTER_ATTRIBUTE_NETWORK, */ + PRINTER_ATTRIBUTE_HIDDEN, + PRINTER_ATTRIBUTE_LOCAL, + PRINTER_ATTRIBUTE_ENABLE_DEVQ, + PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS, + PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST, + PRINTER_ATTRIBUTE_WORK_OFFLINE, + /* does not stick + PRINTER_ATTRIBUTE_ENABLE_BIDI, */ + /* fails with WERR_INVALID_DATATYPE: + PRINTER_ATTRIBUTE_RAW_ONLY, */ + /* these do not stick + PRINTER_ATTRIBUTE_PUBLISHED, + PRINTER_ATTRIBUTE_FAX, + PRINTER_ATTRIBUTE_TS, + 0x00010000, + 0x00020000, + 0x00040000, + 0x00080000, + 0x00100000, + 0x00200000, + 0x00400000, + 0x00800000, + 0x01000000, + 0x02000000, + 0x04000000, + 0x08000000, + 0x10000000, + 0x20000000, + 0x40000000, + 0x80000000 */ + }; + + ZERO_STRUCT(devmode_ctr); + ZERO_STRUCT(secdesc_ctr); + + s.in.handle = handle; + s.in.command = 0; + s.in.info_ctr = &info_ctr; + s.in.devmode_ctr = &devmode_ctr; + s.in.secdesc_ctr = &secdesc_ctr; + + q.in.handle = handle; + q.out.info = &info; + q0 = q; + +#define TESTGETCALL(call, r) \ + r.in.buffer = NULL; \ + r.in.offered = 0;\ + r.out.needed = &needed; \ + status = dcerpc_spoolss_ ##call(p, tctx, &r); \ + if (!NT_STATUS_IS_OK(status)) { \ + torture_comment(tctx, #call " level %u failed - %s (%s)\n", \ + r.in.level, nt_errstr(status), __location__); \ + ret = false; \ + break; \ + }\ + if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {\ + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); \ + data_blob_clear(&blob); \ + r.in.buffer = &blob; \ + r.in.offered = needed; \ + }\ + status = dcerpc_spoolss_ ##call(p, tctx, &r); \ + if (!NT_STATUS_IS_OK(status)) { \ + torture_comment(tctx, #call " level %u failed - %s (%s)\n", \ + r.in.level, nt_errstr(status), __location__); \ + ret = false; \ + break; \ + } \ + if (!W_ERROR_IS_OK(r.out.result)) { \ + torture_comment(tctx, #call " level %u failed - %s (%s)\n", \ + r.in.level, win_errstr(r.out.result), __location__); \ + ret = false; \ + break; \ + } + + +#define TESTSETCALL_EXP(call, r, err) \ + clear_info2(&info_ctr);\ + status = dcerpc_spoolss_ ##call(p, tctx, &r); \ + if (!NT_STATUS_IS_OK(status)) { \ + torture_comment(tctx, #call " level %u failed - %s (%s)\n", \ + r.in.info_ctr->level, nt_errstr(status), __location__); \ + ret = false; \ + break; \ + } \ + if (!W_ERROR_IS_OK(err)) { \ + if (!W_ERROR_EQUAL(err, r.out.result)) { \ + torture_comment(tctx, #call " level %u failed - %s, expected %s (%s)\n", \ + r.in.info_ctr->level, win_errstr(r.out.result), win_errstr(err), __location__); \ + ret = false; \ + } \ + break; \ + } \ + if (!W_ERROR_IS_OK(r.out.result)) { \ + torture_comment(tctx, #call " level %u failed - %s (%s)\n", \ + r.in.info_ctr->level, win_errstr(r.out.result), __location__); \ + ret = false; \ + break; \ + } + +#define TESTSETCALL(call, r) \ + TESTSETCALL_EXP(call, r, WERR_OK) + +#define STRING_EQUAL(s1, s2, field) \ + if ((s1 && !s2) || (s2 && !s1) || strcmp(s1, s2)) { \ + torture_comment(tctx, "Failed to set %s to '%s' (%s)\n", \ + #field, s2, __location__); \ + ret = false; \ + break; \ + } + +#define MEM_EQUAL(s1, s2, length, field) \ + if ((s1 && !s2) || (s2 && !s1) || memcmp(s1, s2, length)) { \ + torture_comment(tctx, "Failed to set %s to '%s' (%s)\n", \ + #field, (const char *)s2, __location__); \ + ret = false; \ + break; \ + } + +#define INT_EQUAL(i1, i2, field) \ + if (i1 != i2) { \ + torture_comment(tctx, "Failed to set %s to 0x%llx - got 0x%llx (%s)\n", \ + #field, (unsigned long long)i2, (unsigned long long)i1, __location__); \ + ret = false; \ + break; \ + } + +#define TEST_PRINTERINFO_STRING_EXP_ERR(lvl1, field1, lvl2, field2, value, err) do { \ + torture_comment(tctx, "field test %d/%s vs %d/%s\n", lvl1, #field1, lvl2, #field2); \ + q.in.level = lvl1; \ + TESTGETCALL(GetPrinter, q) \ + info_ctr.level = lvl1; \ + info_ctr.info.info ## lvl1 = (struct spoolss_SetPrinterInfo ## lvl1 *)&q.out.info->info ## lvl1; \ + info_ctr.info.info ## lvl1->field1 = value;\ + TESTSETCALL_EXP(SetPrinter, s, err) \ + info_ctr.info.info ## lvl1->field1 = ""; \ + TESTGETCALL(GetPrinter, q) \ + info_ctr.info.info ## lvl1->field1 = value; \ + STRING_EQUAL(info_ctr.info.info ## lvl1->field1, value, field1); \ + q.in.level = lvl2; \ + TESTGETCALL(GetPrinter, q) \ + info_ctr.info.info ## lvl2 = (struct spoolss_SetPrinterInfo ## lvl2 *)&q.out.info->info ## lvl2; \ + STRING_EQUAL(info_ctr.info.info ## lvl2->field2, value, field2); \ + } while (0) + +#define TEST_PRINTERINFO_STRING(lvl1, field1, lvl2, field2, value) do { \ + TEST_PRINTERINFO_STRING_EXP_ERR(lvl1, field1, lvl2, field2, value, WERR_OK); \ + } while (0); + +#define TEST_PRINTERINFO_INT_EXP(lvl1, field1, lvl2, field2, value, exp_value) do { \ + torture_comment(tctx, "field test %d/%s vs %d/%s\n", lvl1, #field1, lvl2, #field2); \ + q.in.level = lvl1; \ + TESTGETCALL(GetPrinter, q) \ + info_ctr.level = lvl1; \ + info_ctr.info.info ## lvl1 = (struct spoolss_SetPrinterInfo ## lvl1 *)&q.out.info->info ## lvl1; \ + info_ctr.info.info ## lvl1->field1 = value; \ + TESTSETCALL(SetPrinter, s) \ + info_ctr.info.info ## lvl1->field1 = 0; \ + TESTGETCALL(GetPrinter, q) \ + info_ctr.info.info ## lvl1 = (struct spoolss_SetPrinterInfo ## lvl1 *)&q.out.info->info ## lvl1; \ + INT_EQUAL(info_ctr.info.info ## lvl1->field1, exp_value, field1); \ + q.in.level = lvl2; \ + TESTGETCALL(GetPrinter, q) \ + info_ctr.info.info ## lvl2 = (struct spoolss_SetPrinterInfo ## lvl2 *)&q.out.info->info ## lvl2; \ + INT_EQUAL(info_ctr.info.info ## lvl2->field2, exp_value, field1); \ + } while (0) + +#define TEST_PRINTERINFO_INT(lvl1, field1, lvl2, field2, value) do { \ + TEST_PRINTERINFO_INT_EXP(lvl1, field1, lvl2, field2, value, value); \ + } while (0) + + q0.in.level = 0; + do { TESTGETCALL(GetPrinter, q0) } while (0); + + TEST_PRINTERINFO_STRING(2, comment, 1, comment, "xx2-1 comment"); + TEST_PRINTERINFO_STRING(2, comment, 2, comment, "xx2-2 comment"); + + /* level 0 printername does not stick */ +/* TEST_PRINTERINFO_STRING(2, printername, 0, printername, "xx2-0 printer"); */ + TEST_PRINTERINFO_STRING(2, printername, 1, name, "xx2-1 printer"); + TEST_PRINTERINFO_STRING(2, printername, 2, printername, "xx2-2 printer"); + TEST_PRINTERINFO_STRING(2, printername, 4, printername, "xx2-4 printer"); + TEST_PRINTERINFO_STRING(2, printername, 5, printername, "xx2-5 printer"); +/* TEST_PRINTERINFO_STRING(4, printername, 0, printername, "xx4-0 printer"); */ + TEST_PRINTERINFO_STRING(4, printername, 1, name, "xx4-1 printer"); + TEST_PRINTERINFO_STRING(4, printername, 2, printername, "xx4-2 printer"); + TEST_PRINTERINFO_STRING(4, printername, 4, printername, "xx4-4 printer"); + TEST_PRINTERINFO_STRING(4, printername, 5, printername, "xx4-5 printer"); +/* TEST_PRINTERINFO_STRING(5, printername, 0, printername, "xx5-0 printer"); */ + TEST_PRINTERINFO_STRING(5, printername, 1, name, "xx5-1 printer"); + TEST_PRINTERINFO_STRING(5, printername, 2, printername, "xx5-2 printer"); + TEST_PRINTERINFO_STRING(5, printername, 4, printername, "xx5-4 printer"); + TEST_PRINTERINFO_STRING(5, printername, 5, printername, "xx5-5 printer"); + + /* servername can be set but does not stick + TEST_PRINTERINFO_STRING(2, servername, 0, servername, "xx2-0 servername"); + TEST_PRINTERINFO_STRING(2, servername, 2, servername, "xx2-2 servername"); + TEST_PRINTERINFO_STRING(2, servername, 4, servername, "xx2-4 servername"); + */ + + /* passing an invalid port will result in WERR_UNKNOWN_PORT */ + TEST_PRINTERINFO_STRING_EXP_ERR(2, portname, 2, portname, "xx2-2 portname", WERR_UNKNOWN_PORT); + TEST_PRINTERINFO_STRING_EXP_ERR(2, portname, 5, portname, "xx2-5 portname", WERR_UNKNOWN_PORT); + TEST_PRINTERINFO_STRING_EXP_ERR(5, portname, 2, portname, "xx5-2 portname", WERR_UNKNOWN_PORT); + TEST_PRINTERINFO_STRING_EXP_ERR(5, portname, 5, portname, "xx5-5 portname", WERR_UNKNOWN_PORT); + + TEST_PRINTERINFO_STRING(2, sharename, 2, sharename, "xx2-2 sharename"); + /* passing an invalid driver will result in WERR_UNKNOWN_PRINTER_DRIVER */ + TEST_PRINTERINFO_STRING_EXP_ERR(2, drivername, 2, drivername, "xx2-2 drivername", WERR_UNKNOWN_PRINTER_DRIVER); + TEST_PRINTERINFO_STRING(2, location, 2, location, "xx2-2 location"); + /* passing an invalid sepfile will result in WERR_INVALID_SEPARATOR_FILE */ + TEST_PRINTERINFO_STRING_EXP_ERR(2, sepfile, 2, sepfile, "xx2-2 sepfile", WERR_INVALID_SEPARATOR_FILE); + /* passing an invalid printprocessor will result in WERR_UNKNOWN_PRINTPROCESSOR */ + TEST_PRINTERINFO_STRING_EXP_ERR(2, printprocessor, 2, printprocessor, "xx2-2 printprocessor", WERR_UNKNOWN_PRINTPROCESSOR); + TEST_PRINTERINFO_STRING(2, datatype, 2, datatype, "xx2-2 datatype"); + TEST_PRINTERINFO_STRING(2, parameters, 2, parameters, "xx2-2 parameters"); + + for (i=0; i < ARRAY_SIZE(attribute_list); i++) { +/* TEST_PRINTERINFO_INT_EXP(2, attributes, 1, flags, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); */ + TEST_PRINTERINFO_INT_EXP(2, attributes, 2, attributes, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); + TEST_PRINTERINFO_INT_EXP(2, attributes, 4, attributes, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); + TEST_PRINTERINFO_INT_EXP(2, attributes, 5, attributes, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); +/* TEST_PRINTERINFO_INT_EXP(4, attributes, 1, flags, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); */ + TEST_PRINTERINFO_INT_EXP(4, attributes, 2, attributes, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); + TEST_PRINTERINFO_INT_EXP(4, attributes, 4, attributes, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); + TEST_PRINTERINFO_INT_EXP(4, attributes, 5, attributes, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); +/* TEST_PRINTERINFO_INT_EXP(5, attributes, 1, flags, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); */ + TEST_PRINTERINFO_INT_EXP(5, attributes, 2, attributes, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); + TEST_PRINTERINFO_INT_EXP(5, attributes, 4, attributes, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); + TEST_PRINTERINFO_INT_EXP(5, attributes, 5, attributes, + attribute_list[i], + (attribute_list[i] | default_attribute) + ); + } + + for (i=0; i < ARRAY_SIZE(status_list); i++) { + /* level 2 sets do not stick + TEST_PRINTERINFO_INT(2, status, 0, status, status_list[i]); + TEST_PRINTERINFO_INT(2, status, 2, status, status_list[i]); + TEST_PRINTERINFO_INT(2, status, 6, status, status_list[i]); */ + TEST_PRINTERINFO_INT(6, status, 0, status, status_list[i]); + TEST_PRINTERINFO_INT(6, status, 2, status, status_list[i]); + TEST_PRINTERINFO_INT(6, status, 6, status, status_list[i]); + } + + /* priorities need to be between 0 and 99 + passing an invalid priority will result in WERR_INVALID_PRIORITY */ + TEST_PRINTERINFO_INT(2, priority, 2, priority, 0); + TEST_PRINTERINFO_INT(2, priority, 2, priority, 1); + TEST_PRINTERINFO_INT(2, priority, 2, priority, 99); + /* TEST_PRINTERINFO_INT(2, priority, 2, priority, 100); */ + TEST_PRINTERINFO_INT(2, defaultpriority,2, defaultpriority, 0); + TEST_PRINTERINFO_INT(2, defaultpriority,2, defaultpriority, 1); + TEST_PRINTERINFO_INT(2, defaultpriority,2, defaultpriority, 99); + /* TEST_PRINTERINFO_INT(2, defaultpriority,2, defaultpriority, 100); */ + + TEST_PRINTERINFO_INT(2, starttime, 2, starttime, __LINE__); + TEST_PRINTERINFO_INT(2, untiltime, 2, untiltime, __LINE__); + + /* does not stick + TEST_PRINTERINFO_INT(2, cjobs, 2, cjobs, __LINE__); + TEST_PRINTERINFO_INT(2, averageppm, 2, averageppm, __LINE__); */ + + /* does not stick + TEST_PRINTERINFO_INT(5, device_not_selected_timeout, 5, device_not_selected_timeout, __LINE__); + TEST_PRINTERINFO_INT(5, transmission_retry_timeout, 5, transmission_retry_timeout, __LINE__); */ + + /* FIXME: gd also test devmode and secdesc behavior */ + + { + /* verify composition of level 1 description field */ + const char *description; + const char *tmp; + + q0.in.level = 1; + do { TESTGETCALL(GetPrinter, q0) } while (0); + + description = talloc_strdup(tctx, q0.out.info->info1.description); + + q0.in.level = 2; + do { TESTGETCALL(GetPrinter, q0) } while (0); + + tmp = talloc_asprintf(tctx, "%s,%s,%s", + q0.out.info->info2.printername, + q0.out.info->info2.drivername, + q0.out.info->info2.location); + + do { STRING_EQUAL(description, tmp, "description")} while (0); + } + + return ret; +} + static bool test_ClosePrinter(struct torture_context *tctx, struct dcerpc_pipe *p, @@ -1972,12 +2537,45 @@ static bool test_EnumPrinters_old(struct torture_context *tctx, struct dcerpc_pi return ret; } -#if 0 -static bool test_GetPrinterDriver2(struct dcerpc_pipe *p, +static bool test_GetPrinterDriver(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle, + const char *driver_name) +{ + struct spoolss_GetPrinterDriver r; + uint32_t needed; + + r.in.handle = handle; + r.in.architecture = "W32X86"; + r.in.level = 1; + r.in.buffer = NULL; + r.in.offered = 0; + r.out.needed = &needed; + + torture_comment(tctx, "Testing GetPrinterDriver level %d\n", r.in.level); + + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_GetPrinterDriver(p, tctx, &r), + "failed to call GetPrinterDriver"); + if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); + data_blob_clear(&blob); + r.in.buffer = &blob; + r.in.offered = needed; + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_GetPrinterDriver(p, tctx, &r), + "failed to call GetPrinterDriver"); + } + + torture_assert_werr_ok(tctx, r.out.result, + "failed to call GetPrinterDriver"); + + return true; +} + +static bool test_GetPrinterDriver2(struct torture_context *tctx, + struct dcerpc_pipe *p, struct policy_handle *handle, const char *driver_name) { - NTSTATUS status; struct spoolss_GetPrinterDriver2 r; uint32_t needed; uint32_t server_major_version; @@ -1994,34 +2592,24 @@ static bool test_GetPrinterDriver2(struct dcerpc_pipe *p, r.out.server_major_version = &server_major_version; r.out.server_minor_version = &server_minor_version; - printf("Testing GetPrinterDriver2\n"); - - status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("GetPrinterDriver2 failed - %s\n", nt_errstr(status)); - return false; - } + torture_comment(tctx, "Testing GetPrinterDriver2 level %d\n", r.in.level); + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_GetPrinterDriver2(p, tctx, &r), + "failed to call GetPrinterDriver2"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); + data_blob_clear(&blob); + r.in.buffer = &blob; r.in.offered = needed; - status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &r); - } - - if (!NT_STATUS_IS_OK(status)) { - printf("GetPrinterDriver2 failed - %s\n", - nt_errstr(status)); - return false; + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_GetPrinterDriver2(p, tctx, &r), + "failed to call GetPrinterDriver2"); } - if (!W_ERROR_IS_OK(r.out.result)) { - printf("GetPrinterDriver2 failed - %s\n", - win_errstr(r.out.result)); - return false; - } + torture_assert_werr_ok(tctx, r.out.result, + "failed to call GetPrinterDriver2"); return true; } -#endif static bool test_EnumPrinterDrivers_old(struct torture_context *tctx, struct dcerpc_pipe *p) @@ -2073,6 +2661,432 @@ static bool test_EnumPrinterDrivers_old(struct torture_context *tctx, return true; } +static bool test_DeletePrinter(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) +{ + struct spoolss_DeletePrinter r; + + torture_comment(tctx, "Testing DeletePrinter\n"); + + r.in.handle = handle; + + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_DeletePrinter(p, tctx, &r), + "failed to delete printer"); + torture_assert_werr_ok(tctx, r.out.result, + "failed to delete printer"); + + return true; +} + +static bool test_EnumPrinters_findname(struct torture_context *tctx, + struct dcerpc_pipe *p, + uint32_t flags, + uint32_t level, + const char *name, + bool *found) +{ + struct spoolss_EnumPrinters e; + uint32_t count; + union spoolss_PrinterInfo *info; + uint32_t needed; + int i; + + *found = false; + + e.in.flags = flags; + e.in.server = NULL; + e.in.level = level; + e.in.buffer = NULL; + e.in.offered = 0; + e.out.count = &count; + e.out.info = &info; + e.out.needed = &needed; + + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinters(p, tctx, &e), + "failed to enum printers"); + + if (W_ERROR_EQUAL(e.out.result, WERR_INSUFFICIENT_BUFFER)) { + DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed); + data_blob_clear(&blob); + e.in.buffer = &blob; + e.in.offered = needed; + + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinters(p, tctx, &e), + "failed to enum printers"); + } + + torture_assert_werr_ok(tctx, e.out.result, + "failed to enum printers"); + + for (i=0; i < count; i++) { + + const char *current = NULL; + + switch (level) { + case 1: + current = info[i].info1.name; + break; + } + + if (strequal(current, name)) { + *found = true; + break; + } + } + + return true; +} + +static bool test_AddPrinter_wellknown(struct torture_context *tctx, + struct dcerpc_pipe *p, + const char *printername, + bool ex) +{ + WERROR result; + struct spoolss_AddPrinter r; + struct spoolss_AddPrinterEx rex; + struct spoolss_SetPrinterInfoCtr info_ctr; + struct spoolss_SetPrinterInfo1 info1; + struct spoolss_DevmodeContainer devmode_ctr; + struct sec_desc_buf secdesc_ctr; + struct spoolss_UserLevelCtr userlevel_ctr; + struct policy_handle handle; + bool found = false; + + ZERO_STRUCT(devmode_ctr); + ZERO_STRUCT(secdesc_ctr); + ZERO_STRUCT(userlevel_ctr); + ZERO_STRUCT(info1); + + torture_comment(tctx, "Testing AddPrinter%s level 1\n", ex ? "Ex":""); + + /* try to add printer to wellknown printer list (level 1) */ + + userlevel_ctr.level = 1; + + info_ctr.info.info1 = &info1; + info_ctr.level = 1; + + rex.in.server = NULL; + rex.in.info_ctr = &info_ctr; + rex.in.devmode_ctr = &devmode_ctr; + rex.in.secdesc_ctr = &secdesc_ctr; + rex.in.userlevel_ctr = &userlevel_ctr; + rex.out.handle = &handle; + + r.in.server = NULL; + r.in.info_ctr = &info_ctr; + r.in.devmode_ctr = &devmode_ctr; + r.in.secdesc_ctr = &secdesc_ctr; + r.out.handle = &handle; + + torture_assert_ntstatus_ok(tctx, ex ? dcerpc_spoolss_AddPrinterEx(p, tctx, &rex) : + dcerpc_spoolss_AddPrinter(p, tctx, &r), + "failed to add printer"); + result = ex ? rex.out.result : r.out.result; + torture_assert_werr_equal(tctx, result, WERR_INVALID_PRINTER_NAME, + "unexpected result code"); + + info1.name = printername; + info1.flags = PRINTER_ATTRIBUTE_SHARED; + + torture_assert_ntstatus_ok(tctx, ex ? dcerpc_spoolss_AddPrinterEx(p, tctx, &rex) : + dcerpc_spoolss_AddPrinter(p, tctx, &r), + "failed to add printer"); + result = ex ? rex.out.result : r.out.result; + torture_assert_werr_equal(tctx, result, WERR_PRINTER_ALREADY_EXISTS, + "unexpected result code"); + + /* bizarre protocol, WERR_PRINTER_ALREADY_EXISTS means success here, + better do a real check to see the printer is really there */ + + torture_assert(tctx, test_EnumPrinters_findname(tctx, p, + PRINTER_ENUM_NETWORK, 1, + printername, + &found), + "failed to enum printers"); + + torture_assert(tctx, found, "failed to find newly added printer"); + + info1.flags = 0; + + torture_assert_ntstatus_ok(tctx, ex ? dcerpc_spoolss_AddPrinterEx(p, tctx, &rex) : + dcerpc_spoolss_AddPrinter(p, tctx, &r), + "failed to add printer"); + result = ex ? rex.out.result : r.out.result; + torture_assert_werr_equal(tctx, result, WERR_PRINTER_ALREADY_EXISTS, + "unexpected result code"); + + /* bizarre protocol, WERR_PRINTER_ALREADY_EXISTS means success here, + better do a real check to see the printer has really been removed + from the well known printer list */ + + found = false; + + torture_assert(tctx, test_EnumPrinters_findname(tctx, p, + PRINTER_ENUM_NETWORK, 1, + printername, + &found), + "failed to enum printers"); +#if 0 + torture_assert(tctx, !found, "printer still in well known printer list"); +#endif + return true; +} + +static bool test_AddPrinter_normal(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle_p, + const char *printername, + const char *drivername, + const char *portname, + bool ex) +{ + WERROR result; + struct spoolss_AddPrinter r; + struct spoolss_AddPrinterEx rex; + struct spoolss_SetPrinterInfoCtr info_ctr; + struct spoolss_SetPrinterInfo2 info2; + struct spoolss_DevmodeContainer devmode_ctr; + struct sec_desc_buf secdesc_ctr; + struct spoolss_UserLevelCtr userlevel_ctr; + struct policy_handle handle; + bool found = false; + + ZERO_STRUCT(devmode_ctr); + ZERO_STRUCT(secdesc_ctr); + ZERO_STRUCT(userlevel_ctr); + + torture_comment(tctx, "Testing AddPrinter%s level 2\n", ex ? "Ex":""); + + userlevel_ctr.level = 1; + + rex.in.server = NULL; + rex.in.info_ctr = &info_ctr; + rex.in.devmode_ctr = &devmode_ctr; + rex.in.secdesc_ctr = &secdesc_ctr; + rex.in.userlevel_ctr = &userlevel_ctr; + rex.out.handle = &handle; + + r.in.server = NULL; + r.in.info_ctr = &info_ctr; + r.in.devmode_ctr = &devmode_ctr; + r.in.secdesc_ctr = &secdesc_ctr; + r.out.handle = &handle; + + again: + + /* try to add printer to printer list (level 2) */ + + ZERO_STRUCT(info2); + + info_ctr.info.info2 = &info2; + info_ctr.level = 2; + + torture_assert_ntstatus_ok(tctx, ex ? dcerpc_spoolss_AddPrinterEx(p, tctx, &rex) : + dcerpc_spoolss_AddPrinter(p, tctx, &r), + "failed to add printer"); + result = ex ? rex.out.result : r.out.result; + torture_assert_werr_equal(tctx, result, WERR_INVALID_PRINTER_NAME, + "unexpected result code"); + + info2.printername = printername; + + torture_assert_ntstatus_ok(tctx, ex ? dcerpc_spoolss_AddPrinterEx(p, tctx, &rex) : + dcerpc_spoolss_AddPrinter(p, tctx, &r), + "failed to add printer"); + result = ex ? rex.out.result : r.out.result; + + if (W_ERROR_EQUAL(result, WERR_PRINTER_ALREADY_EXISTS)) { + struct policy_handle printer_handle; + + torture_assert(tctx, call_OpenPrinterEx(tctx, p, printername, &printer_handle), + "failed to open printer handle"); + + torture_assert(tctx, test_DeletePrinter(tctx, p, &printer_handle), + "failed to delete printer"); + + torture_assert(tctx, test_ClosePrinter(tctx, p, &printer_handle), + "failed to close server handle"); + + goto again; + } + + torture_assert_werr_equal(tctx, result, WERR_UNKNOWN_PORT, + "unexpected result code"); + + info2.portname = portname; + + torture_assert_ntstatus_ok(tctx, ex ? dcerpc_spoolss_AddPrinterEx(p, tctx, &rex) : + dcerpc_spoolss_AddPrinter(p, tctx, &r), + "failed to add printer"); + result = ex ? rex.out.result : r.out.result; + torture_assert_werr_equal(tctx, result, WERR_UNKNOWN_PRINTER_DRIVER, + "unexpected result code"); + + info2.drivername = drivername; + + torture_assert_ntstatus_ok(tctx, ex ? dcerpc_spoolss_AddPrinterEx(p, tctx, &rex) : + dcerpc_spoolss_AddPrinter(p, tctx, &r), + "failed to add printer"); + result = ex ? rex.out.result : r.out.result; + torture_assert_werr_equal(tctx, result, WERR_UNKNOWN_PRINTPROCESSOR, + "unexpected result code"); + + info2.printprocessor = "winprint"; + + torture_assert_ntstatus_ok(tctx, ex ? dcerpc_spoolss_AddPrinterEx(p, tctx, &rex) : + dcerpc_spoolss_AddPrinter(p, tctx, &r), + "failed to add printer"); + result = ex ? rex.out.result : r.out.result; + torture_assert_werr_ok(tctx, result, + "failed to add printer"); + + *handle_p = handle; + + /* we are paranoid, really check if the printer is there now */ + + torture_assert(tctx, test_EnumPrinters_findname(tctx, p, + PRINTER_ENUM_LOCAL, 1, + printername, + &found), + "failed to enum printers"); + torture_assert(tctx, found, "failed to find newly added printer"); + + torture_assert_ntstatus_ok(tctx, ex ? dcerpc_spoolss_AddPrinterEx(p, tctx, &rex) : + dcerpc_spoolss_AddPrinter(p, tctx, &r), + "failed to add printer"); + result = ex ? rex.out.result : r.out.result; + torture_assert_werr_equal(tctx, result, WERR_PRINTER_ALREADY_EXISTS, + "unexpected result code"); + + return true; +} + +static bool test_AddPrinterEx(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle_p, + const char *printername, + const char *drivername, + const char *portname) +{ + bool ret = true; + + if (!torture_setting_bool(tctx, "samba3", false)) { + if (!test_AddPrinter_wellknown(tctx, p, TORTURE_WELLKNOWN_PRINTER_EX, true)) { + torture_comment(tctx, "failed to add printer to well known list\n"); + ret = false; + } + } + + if (!test_AddPrinter_normal(tctx, p, handle_p, + printername, drivername, portname, + true)) { + torture_comment(tctx, "failed to add printer to printer list\n"); + ret = false; + } + + return ret; +} + +static bool test_AddPrinter(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle_p, + const char *printername, + const char *drivername, + const char *portname) +{ + bool ret = true; + + if (!torture_setting_bool(tctx, "samba3", false)) { + if (!test_AddPrinter_wellknown(tctx, p, TORTURE_WELLKNOWN_PRINTER, false)) { + torture_comment(tctx, "failed to add printer to well known list\n"); + ret = false; + } + } + + if (!test_AddPrinter_normal(tctx, p, handle_p, + printername, drivername, portname, + false)) { + torture_comment(tctx, "failed to add printer to printer list\n"); + ret = false; + } + + return ret; +} + +static bool test_printer_info(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) +{ + bool ret = true; + + if (!test_PrinterInfo(tctx, p, handle)) { + ret = false; + } + + if (!test_SetPrinter_errors(tctx, p, handle)) { + ret = false; + } + + return ret; +} + +static bool test_printer(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + bool ret = true; + struct policy_handle handle[2]; + bool found = false; + const char *drivername = "Microsoft XPS Document Writer"; + const char *portname = "LPT1:"; + + /* test printer created via AddPrinter */ + + if (!test_AddPrinter(tctx, p, &handle[0], TORTURE_PRINTER, drivername, portname)) { + return false; + } + + if (!test_printer_info(tctx, p, &handle[0])) { + ret = false; + } + + if (!test_DeletePrinter(tctx, p, &handle[0])) { + ret = false; + } + + if (!test_EnumPrinters_findname(tctx, p, PRINTER_ENUM_LOCAL, 1, + TORTURE_PRINTER, &found)) { + ret = false; + } + + torture_assert(tctx, !found, "deleted printer still there"); + + /* test printer created via AddPrinterEx */ + + if (!test_AddPrinterEx(tctx, p, &handle[1], TORTURE_PRINTER_EX, drivername, portname)) { + return false; + } + + if (!test_printer_info(tctx, p, &handle[1])) { + ret = false; + } + + if (!test_DeletePrinter(tctx, p, &handle[1])) { + ret = false; + } + + if (!test_EnumPrinters_findname(tctx, p, PRINTER_ENUM_LOCAL, 1, + TORTURE_PRINTER_EX, &found)) { + ret = false; + } + + torture_assert(tctx, !found, "deleted printer still there"); + + return ret; +} + bool torture_rpc_spoolss(struct torture_context *torture) { NTSTATUS status; @@ -2087,7 +3101,7 @@ bool torture_rpc_spoolss(struct torture_context *torture) ctx = talloc_zero(torture, struct test_spoolss_context); - ret &= test_OpenPrinter_server(torture, p, ctx); + ret &= test_OpenPrinter_server(torture, p, &ctx->server_handle); ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "W3SvcInstalled"); ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "BeepEnabled"); @@ -2129,3 +3143,15 @@ bool torture_rpc_spoolss(struct torture_context *torture) return ret; } + +struct torture_suite *torture_rpc_spoolss_printer(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite = torture_suite_create(mem_ctx, "SPOOLSS-PRINTER"); + + struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite, + "printer", &ndr_table_spoolss); + + torture_rpc_tcase_add_test(tcase, "printer", test_printer); + + return suite; +} |