From de4a4954383584b349f9fd1605a88851dc5d261c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Mar 2008 10:21:09 -0700 Subject: Test trans2 renames with oplocks. It looks like trans2 renames ignore share modes and oplock breaks :-(. Jeremy. (This used to be commit a8a5339cf2ca218668f888eced5ffe7ce059553c) --- source4/torture/raw/oplock.c | 106 +++++++++++++++++++++++++++++++++++++++++++ source4/torture/raw/rename.c | 4 ++ 2 files changed, 110 insertions(+) (limited to 'source4/torture') diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 1926b12128..d1ae8fced5 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -2136,6 +2136,112 @@ done: return ret; } +/**************************************************** + Called from raw-rename - we need oplock handling for + this test so this is why it's in oplock.c, not rename.c +****************************************************/ + +bool test_trans2rename(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + const char *fname1 = BASEDIR "\\test_trans2rename_1.dat"; + const char *fname2 = BASEDIR "\\test_trans2rename_2.dat"; + const char *fname3 = BASEDIR "\\test_trans2rename_3.dat"; + NTSTATUS status; + bool ret = true; + union smb_open io; + union smb_fileinfo qfi; + union smb_setfileinfo sfi; + uint16_t fnum=0; + + if (torture_setting_bool(tctx, "samba3", false)) { + torture_skip(tctx, "trans2rename disabled against samba3\n"); + } + + if (!torture_setup_dir(cli1, BASEDIR)) { + return false; + } + + /* cleanup */ + smbcli_unlink(cli1->tree, fname1); + smbcli_unlink(cli1->tree, fname2); + smbcli_unlink(cli1->tree, fname3); + + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + + /* + base ntcreatex parms + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + io.ntcreatex.in.create_options = 0; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = fname1; + + torture_comment(tctx, "open a file with an exclusive oplock (share mode: none)\n"); + ZERO_STRUCT(break_info); + io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | + NTCREATEX_FLAGS_REQUEST_OPLOCK; + status = smb_raw_open(cli1->tree, tctx, &io); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); + + torture_comment(tctx, "setpathinfo rename info should not trigger a break nor a violation\n"); + ZERO_STRUCT(sfi); + sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION; + sfi.generic.in.file.path = fname1; + sfi.rename_information.in.overwrite = 0; + sfi.rename_information.in.root_fid = 0; + sfi.rename_information.in.new_name = fname2+strlen(BASEDIR)+1; + + status = smb_raw_setpathinfo(cli2->tree, &sfi); + + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_VAL(break_info.count, 0); + + ZERO_STRUCT(qfi); + qfi.generic.level = RAW_FILEINFO_ALL_INFORMATION; + qfi.generic.in.file.fnum = fnum; + + status = smb_raw_fileinfo(cli1->tree, tctx, &qfi); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_STRMATCH(qfi.all_info.out.fname.s, fname2); + + torture_comment(tctx, "setfileinfo rename info should not trigger a break nor a violation\n"); + ZERO_STRUCT(sfi); + sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION; + sfi.generic.in.file.fnum = fnum; + sfi.rename_information.in.overwrite = 0; + sfi.rename_information.in.root_fid = 0; + sfi.rename_information.in.new_name = fname3+strlen(BASEDIR)+1; + + status = smb_raw_setfileinfo(cli1->tree, &sfi); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_VAL(break_info.count, 0); + + ZERO_STRUCT(qfi); + qfi.generic.level = RAW_FILEINFO_ALL_INFORMATION; + qfi.generic.in.file.fnum = fnum; + + status = smb_raw_fileinfo(cli1->tree, tctx, &qfi); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_STRMATCH(qfi.all_info.out.fname.s, fname3); + + smbcli_close(cli1->tree, fnum); + +done: + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + smbcli_deltree(cli1->tree, BASEDIR); + return ret; +} + static bool test_raw_oplock_batch20(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { const char *fname1 = BASEDIR "\\test_batch20_1.dat"; diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c index 4b0d986659..308bd7f8dc 100644 --- a/source4/torture/raw/rename.c +++ b/source4/torture/raw/rename.c @@ -434,6 +434,7 @@ done: return ret; } +extern bool test_trans2rename(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2); /* basic testing of rename calls @@ -443,6 +444,9 @@ struct torture_suite *torture_raw_rename(TALLOC_CTX *mem_ctx) struct torture_suite *suite = torture_suite_create(mem_ctx, "RENAME"); torture_suite_add_1smb_test(suite, "mv", test_mv); + /* test_trans2rename is actually in torture/raw/oplock.c to + use the handlers and macros there. */ + torture_suite_add_2smb_test(suite, "trans2rename", test_trans2rename); torture_suite_add_1smb_test(suite, "ntrename", test_ntrename); return suite; -- cgit From fe3316431e157f6fe5fc1092927d1d03f29b9bbd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Mar 2008 12:37:20 -0700 Subject: Samba3 now passes the test_raw_oplock_exclusive3 test. Jeremy. (This used to be commit b2007956aa4534f22ad7fd85b0aee0be769548ae) --- source4/torture/raw/oplock.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index d1ae8fced5..7571a8006c 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -363,7 +363,6 @@ static bool test_raw_oplock_exclusive3(struct torture_context *tctx, struct smbc union smb_open io; union smb_setfileinfo sfi; uint16_t fnum=0; - bool s3 = torture_setting_bool(tctx, "samba3", false); if (!torture_setup_dir(cli1, BASEDIR)) { return false; @@ -389,15 +388,10 @@ static bool test_raw_oplock_exclusive3(struct torture_context *tctx, struct smbc io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open a file with an exclusive oplock (share mode: %s)\n", - s3?"all":"none"); + torture_comment(tctx, "open a file with an exclusive oplock (share mode: none)\n"); + ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; - if (s3) { - io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ| - NTCREATEX_SHARE_ACCESS_WRITE| - NTCREATEX_SHARE_ACCESS_DELETE; - } status = smb_raw_open(cli1->tree, tctx, &io); CHECK_STATUS(tctx, status, NT_STATUS_OK); -- cgit From 333870d5a08c2badb7c4f415ba2decc64f3f842c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Mar 2008 13:39:04 -0700 Subject: Samba3.2 now passes a lot more tests - remove the S3 specific exemptions. Jeremy. (This used to be commit a70719d579a7eefbfd973267b95a87aaa6b649b0) --- source4/torture/raw/oplock.c | 99 ++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 67 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 7571a8006c..ab23ee78c0 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -229,7 +229,7 @@ static bool test_raw_oplock_exclusive1(struct torture_context *tctx, struct smbc io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open a file with an exclusive oplock (share mode: none)\n"); + torture_comment(tctx, "EXCLUSIVE1: open a file with an exclusive oplock (share mode: none)\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; @@ -294,7 +294,7 @@ static bool test_raw_oplock_exclusive2(struct torture_context *tctx, struct smbc io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open a file with an exclusive oplock (share mode: all)\n"); + torture_comment(tctx, "EXCLUSIVE2: open a file with an exclusive oplock (share mode: all)\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ| @@ -388,7 +388,7 @@ static bool test_raw_oplock_exclusive3(struct torture_context *tctx, struct smbc io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open a file with an exclusive oplock (share mode: none)\n"); + torture_comment(tctx, "EXCLUSIVE3: open a file with an exclusive oplock (share mode: none)\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; @@ -452,7 +452,7 @@ static bool test_raw_oplock_exclusive4(struct torture_context *tctx, struct smbc io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open with exclusive oplock\n"); + torture_comment(tctx, "EXCLUSIVE4: open with exclusive oplock\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); @@ -517,7 +517,7 @@ static bool test_raw_oplock_exclusive5(struct torture_context *tctx, struct smbc io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open with exclusive oplock\n"); + torture_comment(tctx, "EXCLUSIVE5: open with exclusive oplock\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); @@ -564,7 +564,6 @@ static bool test_raw_oplock_exclusive6(struct torture_context *tctx, struct smbc union smb_open io; union smb_rename rn; uint16_t fnum=0; - bool s3 = torture_setting_bool(tctx, "samba3", false); if (!torture_setup_dir(cli1, BASEDIR)) { return false; @@ -591,16 +590,9 @@ static bool test_raw_oplock_exclusive6(struct torture_context *tctx, struct smbc io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname1; - /* we should use no share mode, when samba3 passes this */ - torture_comment(tctx, "open a file with an exclusive oplock (share mode: %s)\n", - s3?"all":"none"); + torture_comment(tctx, "EXCLUSIVE6: open a file with an exclusive oplock (share mode: none)\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK; - if (s3) { - io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ| - NTCREATEX_SHARE_ACCESS_WRITE| - NTCREATEX_SHARE_ACCESS_DELETE; - } status = smb_raw_open(cli1->tree, tctx, &io); CHECK_STATUS(tctx, status, NT_STATUS_OK); @@ -667,7 +659,7 @@ static bool test_raw_oplock_batch1(struct torture_context *tctx, struct smbcli_s /* with a batch oplock we get a break */ - torture_comment(tctx, "open with batch oplock\n"); + torture_comment(tctx, "BATCH1: open with batch oplock\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -748,7 +740,7 @@ static bool test_raw_oplock_batch2(struct torture_context *tctx, struct smbcli_s io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open with batch oplock\n"); + torture_comment(tctx, "BATCH2: open with batch oplock\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -826,7 +818,7 @@ static bool test_raw_oplock_batch3(struct torture_context *tctx, struct smbcli_s io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "if we close on break then the unlink can succeed\n"); + torture_comment(tctx, "BATCH3: if we close on break then the unlink can succeed\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | @@ -890,7 +882,7 @@ static bool test_raw_oplock_batch4(struct torture_context *tctx, struct smbcli_s io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "a self read should not cause a break\n"); + torture_comment(tctx, "BATCH4: a self read should not cause a break\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); @@ -953,7 +945,7 @@ static bool test_raw_oplock_batch5(struct torture_context *tctx, struct smbcli_s io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "a 2nd open should give a break\n"); + torture_comment(tctx, "BATCH5: a 2nd open should give a break\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); @@ -1018,7 +1010,7 @@ static bool test_raw_oplock_batch6(struct torture_context *tctx, struct smbcli_s io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "a 2nd open should give a break to level II if the first open allowed shared read\n"); + torture_comment(tctx, "BATCH6: a 2nd open should give a break to level II if the first open allowed shared read\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree); @@ -1098,7 +1090,7 @@ static bool test_raw_oplock_batch7(struct torture_context *tctx, struct smbcli_s io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "a 2nd open should get an oplock when we close instead of ack\n"); + torture_comment(tctx, "BATCH7: a 2nd open should get an oplock when we close instead of ack\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree); @@ -1168,7 +1160,7 @@ static bool test_raw_oplock_batch8(struct torture_context *tctx, struct smbcli_s io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open with batch oplock\n"); + torture_comment(tctx, "BATCH8: open with batch oplock\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); @@ -1237,7 +1229,7 @@ static bool test_raw_oplock_batch9(struct torture_context *tctx, struct smbcli_s io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open with attributes only can create file\n"); + torture_comment(tctx, "BATCH9: open with attributes only can create file\n"); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -1342,7 +1334,7 @@ static bool test_raw_oplock_batch10(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "Open with oplock after a non-oplock open should grant level2\n"); + torture_comment(tctx, "BATCH10: Open with oplock after a non-oplock open should grant level2\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; @@ -1452,7 +1444,7 @@ static bool test_raw_oplock_batch11(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.fname = fname; /* Test if a set-eof on pathname breaks an exclusive oplock. */ - torture_comment(tctx, "Test if setpathinfo set EOF breaks oplocks.\n"); + torture_comment(tctx, "BATCH11: Test if setpathinfo set EOF breaks oplocks.\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); @@ -1527,7 +1519,7 @@ static bool test_raw_oplock_batch12(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.fname = fname; /* Test if a set-allocation size on pathname breaks an exclusive oplock. */ - torture_comment(tctx, "Test if setpathinfo allocation size breaks oplocks.\n"); + torture_comment(tctx, "BATCH12: Test if setpathinfo allocation size breaks oplocks.\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); @@ -1601,7 +1593,7 @@ static bool test_raw_oplock_batch13(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open with batch oplock\n"); + torture_comment(tctx, "BATCH13: open with batch oplock\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); @@ -1678,7 +1670,7 @@ static bool test_raw_oplock_batch14(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open with batch oplock\n"); + torture_comment(tctx, "BATCH14: open with batch oplock\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); @@ -1755,7 +1747,7 @@ static bool test_raw_oplock_batch15(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.fname = fname; /* Test if a qpathinfo all info on pathname breaks a batch oplock. */ - torture_comment(tctx, "Test if qpathinfo all info breaks a batch oplock (should not).\n"); + torture_comment(tctx, "BATCH15: Test if qpathinfo all info breaks a batch oplock (should not).\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); @@ -1827,7 +1819,7 @@ static bool test_raw_oplock_batch16(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "open with batch oplock\n"); + torture_comment(tctx, "BATCH16: open with batch oplock\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); @@ -1881,7 +1873,6 @@ static bool test_raw_oplock_batch17(struct torture_context *tctx, struct smbcli_ union smb_open io; union smb_rename rn; uint16_t fnum=0; - bool s3 = torture_setting_bool(tctx, "samba3", false); if (!torture_setup_dir(cli1, BASEDIR)) { return false; @@ -1908,18 +1899,12 @@ static bool test_raw_oplock_batch17(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname1; - /* we should use no share mode, when samba3 passes this */ - torture_comment(tctx, "open a file with an batch oplock (share mode: %s)\n", - s3?"all":"none"); + torture_comment(tctx, "BATCH17: open a file with an batch oplock (share mode: none)\n"); + ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; - if (s3) { - io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ| - NTCREATEX_SHARE_ACCESS_WRITE| - NTCREATEX_SHARE_ACCESS_DELETE; - } status = smb_raw_open(cli1->tree, tctx, &io); CHECK_STATUS(tctx, status, NT_STATUS_OK); @@ -1959,7 +1944,6 @@ static bool test_raw_oplock_batch18(struct torture_context *tctx, struct smbcli_ union smb_open io; union smb_rename rn; uint16_t fnum=0; - bool s3 = torture_setting_bool(tctx, "samba3", false); if (!torture_setup_dir(cli1, BASEDIR)) { return false; @@ -1986,18 +1970,12 @@ static bool test_raw_oplock_batch18(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname1; - /* we should use no share mode, when samba3 passes this */ - torture_comment(tctx, "open a file with an batch oplock (share mode: %s)\n", - s3?"all":"none"); + torture_comment(tctx, "BATCH18: open a file with an batch oplock (share mode: none)\n"); + ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; - if (s3) { - io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ| - NTCREATEX_SHARE_ACCESS_WRITE| - NTCREATEX_SHARE_ACCESS_DELETE; - } status = smb_raw_open(cli1->tree, tctx, &io); CHECK_STATUS(tctx, status, NT_STATUS_OK); @@ -2040,10 +2018,6 @@ static bool test_raw_oplock_batch19(struct torture_context *tctx, struct smbcli_ union smb_setfileinfo sfi; uint16_t fnum=0; - if (torture_setting_bool(tctx, "samba3", false)) { - torture_skip(tctx, "BACHT19 disabled against samba3\n"); - } - if (!torture_setup_dir(cli1, BASEDIR)) { return false; } @@ -2070,7 +2044,7 @@ static bool test_raw_oplock_batch19(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname1; - torture_comment(tctx, "open a file with an batch oplock (share mode: none)\n"); + torture_comment(tctx, "BATCH19: open a file with an batch oplock (share mode: none)\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -2147,10 +2121,6 @@ bool test_trans2rename(struct torture_context *tctx, struct smbcli_state *cli1, union smb_setfileinfo sfi; uint16_t fnum=0; - if (torture_setting_bool(tctx, "samba3", false)) { - torture_skip(tctx, "trans2rename disabled against samba3\n"); - } - if (!torture_setup_dir(cli1, BASEDIR)) { return false; } @@ -2248,10 +2218,6 @@ static bool test_raw_oplock_batch20(struct torture_context *tctx, struct smbcli_ union smb_setfileinfo sfi; uint16_t fnum=0,fnum2=0; - if (torture_setting_bool(tctx, "samba3", false)) { - torture_skip(tctx, "BACHT20 disabled against samba3\n"); - } - if (!torture_setup_dir(cli1, BASEDIR)) { return false; } @@ -2278,7 +2244,7 @@ static bool test_raw_oplock_batch20(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname1; - torture_comment(tctx, "open a file with an batch oplock (share mode: all)\n"); + torture_comment(tctx, "BATCH20: open a file with an batch oplock (share mode: all)\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -2312,7 +2278,6 @@ static bool test_raw_oplock_batch20(struct torture_context *tctx, struct smbcli_ CHECK_STATUS(tctx, status, NT_STATUS_OK); CHECK_STRMATCH(qfi.all_info.out.fname.s, fname2); - /* we should use no share mode, when samba3 passes this */ torture_comment(tctx, "open a file with the new name an batch oplock (share mode: all)\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | @@ -2407,7 +2372,7 @@ static bool test_raw_oplock_batch21(struct torture_context *tctx, struct smbcli_ /* with a batch oplock we get a break */ - torture_comment(tctx, "open with batch oplock\n"); + torture_comment(tctx, "BATCH21: open with batch oplock\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -2480,7 +2445,7 @@ static bool test_raw_oplock_batch22(struct torture_context *tctx, struct smbcli_ /* with a batch oplock we get a break */ - torture_comment(tctx, "open with batch oplock\n"); + torture_comment(tctx, "BATCH22: open with batch oplock\n"); ZERO_STRUCT(break_info); io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK | @@ -2570,7 +2535,7 @@ static bool test_raw_oplock_batch23(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "a open and ask for a batch oplock\n"); + torture_comment(tctx, "BATCH23: a open and ask for a batch oplock\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree); @@ -2657,7 +2622,7 @@ static bool test_raw_oplock_batch24(struct torture_context *tctx, struct smbcli_ io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; - torture_comment(tctx, "a open without level support and ask for a batch oplock\n"); + torture_comment(tctx, "BATCH24: a open without level support and ask for a batch oplock\n"); ZERO_STRUCT(break_info); smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree); -- cgit From fdd7f68660256f7047f01b6fba12b2ab497d571a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 11 Mar 2008 21:58:29 +0100 Subject: RAW-SEARCH: skip RESUME_KEY tests against samba3 metze (This used to be commit ca5b37747107bd2941f7415fe609c8293a6b5f7c) --- source4/torture/raw/search.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/torture') diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c index 0242b9c545..725ed261aa 100644 --- a/source4/torture/raw/search.c +++ b/source4/torture/raw/search.c @@ -708,6 +708,16 @@ static bool test_many_files(struct torture_context *tctx, for (t=0;t Date: Tue, 11 Mar 2008 15:27:08 -0700 Subject: Added test_nttransrename() to test Metze's new code. Jeremy. (This used to be commit 4556fafede8691c6a12670695ff108e9e59aff98) --- source4/torture/raw/oplock.c | 89 ++++++++++++++++++++++++++++++++++++++++++++ source4/torture/raw/rename.c | 4 +- 2 files changed, 92 insertions(+), 1 deletion(-) (limited to 'source4/torture') diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index ab23ee78c0..89f3607ecd 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -2206,6 +2206,95 @@ done: return ret; } +/**************************************************** + Called from raw-rename - we need oplock handling for + this test so this is why it's in oplock.c, not rename.c +****************************************************/ + +bool test_nttransrename(struct torture_context *tctx, struct smbcli_state *cli1) +{ + const char *fname1 = BASEDIR "\\test_nttransrename_1.dat"; + const char *fname2 = BASEDIR "\\test_nttransrename_2.dat"; + NTSTATUS status; + bool ret = true; + union smb_open io; + union smb_fileinfo qfi; + union smb_rename rn; + uint16_t fnum=0; + + if (!torture_setup_dir(cli1, BASEDIR)) { + return false; + } + + /* cleanup */ + smbcli_unlink(cli1->tree, fname1); + smbcli_unlink(cli1->tree, fname2); + + smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree); + + /* + base ntcreatex parms + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + io.ntcreatex.in.create_options = 0; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = fname1; + + torture_comment(tctx, "nttrans_rename: open a file with an exclusive oplock (share mode: none)\n"); + ZERO_STRUCT(break_info); + io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | + NTCREATEX_FLAGS_REQUEST_OPLOCK; + status = smb_raw_open(cli1->tree, tctx, &io); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); + + torture_comment(tctx, "nttrans_rename should not trigger a break nor a share mode violation\n"); + ZERO_STRUCT(rn); + rn.generic.level = RAW_RENAME_NTTRANS; + rn.nttrans.in.file.fnum = fnum; + rn.nttrans.in.flags = 0; + rn.nttrans.in.new_name = fname2+strlen(BASEDIR)+1; + + status = smb_raw_rename(cli1->tree, &rn); + + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_VAL(break_info.count, 0); + + /* Seems name is only updated on close. */ + smbcli_close(cli1->tree, fnum); + + /* Check if we can open with the new name. */ + io.ntcreatex.in.fname = fname2; + status = smb_raw_open(cli1->tree, tctx, &io); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + fnum = io.ntcreatex.out.file.fnum; + CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); + + ZERO_STRUCT(qfi); + qfi.generic.level = RAW_FILEINFO_ALL_INFORMATION; + qfi.generic.in.file.fnum = fnum; + + status = smb_raw_fileinfo(cli1->tree, tctx, &qfi); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_STRMATCH(qfi.all_info.out.fname.s, fname2); + + smbcli_close(cli1->tree, fnum); + +done: + smb_raw_exit(cli1->session); + smbcli_deltree(cli1->tree, BASEDIR); + return ret; +} + + static bool test_raw_oplock_batch20(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { const char *fname1 = BASEDIR "\\test_batch20_1.dat"; diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c index 308bd7f8dc..9765c04101 100644 --- a/source4/torture/raw/rename.c +++ b/source4/torture/raw/rename.c @@ -435,6 +435,7 @@ done: } extern bool test_trans2rename(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2); +extern bool test_nttransrename(struct torture_context *tctx, struct smbcli_state *cli1); /* basic testing of rename calls @@ -444,9 +445,10 @@ struct torture_suite *torture_raw_rename(TALLOC_CTX *mem_ctx) struct torture_suite *suite = torture_suite_create(mem_ctx, "RENAME"); torture_suite_add_1smb_test(suite, "mv", test_mv); - /* test_trans2rename is actually in torture/raw/oplock.c to + /* test_trans2rename and test_nttransrename are actually in torture/raw/oplock.c to use the handlers and macros there. */ torture_suite_add_2smb_test(suite, "trans2rename", test_trans2rename); + torture_suite_add_1smb_test(suite, "nttransrename", test_nttransrename); torture_suite_add_1smb_test(suite, "ntrename", test_ntrename); return suite; -- cgit From 6e9d25157d896763ea16520ba9cc44099b62ce72 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 12 Mar 2008 14:21:21 +0100 Subject: RAW-STREAMS: do what the comments say metze (This used to be commit eb68a8ed4fa214ad2e858a7fbdf9b5376cda6e04) --- source4/torture/raw/streams.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c index ca6b488af5..b6680e081e 100644 --- a/source4/torture/raw/streams.c +++ b/source4/torture/raw/streams.c @@ -356,22 +356,24 @@ static bool test_stream_sharemodes(struct torture_context *tctx, * A different stream does not give a sharing violation */ + io.ntcreatex.in.fname = sname2; + status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); - fnum1 = io.ntcreatex.out.file.fnum; + fnum2 = io.ntcreatex.out.file.fnum; /* * ... whereas the same stream does with unchanged access/share_access * flags */ + io.ntcreatex.in.fname = sname1; io.ntcreatex.in.open_disposition = 0; status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); io.ntcreatex.in.fname = sname2; status = smb_raw_open(cli->tree, mem_ctx, &io); - CHECK_STATUS(status, NT_STATUS_OK); - fnum2 = io.ntcreatex.out.file.fnum; + CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); done: if (fnum1 != -1) smbcli_close(cli->tree, fnum1); -- cgit From 2801b6a522c772cb4d53a7ab0349607ad20d3e64 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 12 Mar 2008 14:21:50 +0100 Subject: RAW-STREAMS: do a exit on the session after each sub tests metze (This used to be commit 3f7fef8b8c567379649611637d69c89d77d11d6c) --- source4/torture/raw/streams.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/torture') diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c index b6680e081e..1dab36c28b 100644 --- a/source4/torture/raw/streams.c +++ b/source4/torture/raw/streams.c @@ -560,7 +560,9 @@ bool torture_raw_streams(struct torture_context *torture, } ret &= test_stream_io(torture, cli, torture); + smb_raw_exit(cli->session); ret &= test_stream_sharemodes(torture, cli, torture); + smb_raw_exit(cli->session); if (!torture_setting_bool(torture, "samba4", false)) { ret &= test_stream_delete(torture, cli, torture); } -- cgit From 23ab56cd80239bc7d31917cfca4488ef9f633992 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 12 Mar 2008 15:10:57 +0100 Subject: RAW-RENAME: w2k3 just ignores a NTTRANS-RENAME! metze (This used to be commit cd1b8efc5d8dc1eec03fe1bf1eb58dbded9584eb) --- source4/torture/raw/oplock.c | 65 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 15 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 89f3607ecd..5ab43d5e78 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -2218,7 +2218,7 @@ bool test_nttransrename(struct torture_context *tctx, struct smbcli_state *cli1) NTSTATUS status; bool ret = true; union smb_open io; - union smb_fileinfo qfi; + union smb_fileinfo qfi, qpi; union smb_rename rn; uint16_t fnum=0; @@ -2237,7 +2237,7 @@ bool test_nttransrename(struct torture_context *tctx, struct smbcli_state *cli1) */ io.generic.level = RAW_OPEN_NTCREATEX; io.ntcreatex.in.root_fid = 0; - io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; + io.ntcreatex.in.access_mask = 0;/* ask for no access at all */; io.ntcreatex.in.alloc_size = 0; io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; @@ -2256,7 +2256,7 @@ bool test_nttransrename(struct torture_context *tctx, struct smbcli_state *cli1) fnum = io.ntcreatex.out.file.fnum; CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); - torture_comment(tctx, "nttrans_rename should not trigger a break nor a share mode violation\n"); + torture_comment(tctx, "nttrans_rename: should not trigger a break nor a share mode violation\n"); ZERO_STRUCT(rn); rn.generic.level = RAW_RENAME_NTTRANS; rn.nttrans.in.file.fnum = fnum; @@ -2268,25 +2268,60 @@ bool test_nttransrename(struct torture_context *tctx, struct smbcli_state *cli1) CHECK_STATUS(tctx, status, NT_STATUS_OK); CHECK_VAL(break_info.count, 0); - /* Seems name is only updated on close. */ - smbcli_close(cli1->tree, fnum); - - /* Check if we can open with the new name. */ - io.ntcreatex.in.fname = fname2; - status = smb_raw_open(cli1->tree, tctx, &io); - CHECK_STATUS(tctx, status, NT_STATUS_OK); - fnum = io.ntcreatex.out.file.fnum; - CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN); - + /* w2k3 does nothing, it doesn't rename the file */ + torture_comment(tctx, "nttrans_rename: the server should have done nothing\n"); ZERO_STRUCT(qfi); qfi.generic.level = RAW_FILEINFO_ALL_INFORMATION; qfi.generic.in.file.fnum = fnum; status = smb_raw_fileinfo(cli1->tree, tctx, &qfi); CHECK_STATUS(tctx, status, NT_STATUS_OK); - CHECK_STRMATCH(qfi.all_info.out.fname.s, fname2); + CHECK_STRMATCH(qfi.all_info.out.fname.s, fname1); - smbcli_close(cli1->tree, fnum); + ZERO_STRUCT(qpi); + qpi.generic.level = RAW_FILEINFO_ALL_INFORMATION; + qpi.generic.in.file.path = fname1; + + status = smb_raw_pathinfo(cli1->tree, tctx, &qpi); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_STRMATCH(qpi.all_info.out.fname.s, fname1); + + ZERO_STRUCT(qpi); + qpi.generic.level = RAW_FILEINFO_ALL_INFORMATION; + qpi.generic.in.file.path = fname2; + + status = smb_raw_pathinfo(cli1->tree, tctx, &qpi); + CHECK_STATUS(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + + torture_comment(tctx, "nttrans_rename: after closing the file the file is still not renamed\n"); + status = smbcli_close(cli1->tree, fnum); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + + ZERO_STRUCT(qpi); + qpi.generic.level = RAW_FILEINFO_ALL_INFORMATION; + qpi.generic.in.file.path = fname1; + + status = smb_raw_pathinfo(cli1->tree, tctx, &qpi); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_STRMATCH(qpi.all_info.out.fname.s, fname1); + + ZERO_STRUCT(qpi); + qpi.generic.level = RAW_FILEINFO_ALL_INFORMATION; + qpi.generic.in.file.path = fname2; + + status = smb_raw_pathinfo(cli1->tree, tctx, &qpi); + CHECK_STATUS(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + + torture_comment(tctx, "nttrans_rename: rename with an invalid handle gives NT_STATUS_INVALID_HANDLE\n"); + ZERO_STRUCT(rn); + rn.generic.level = RAW_RENAME_NTTRANS; + rn.nttrans.in.file.fnum = fnum+1; + rn.nttrans.in.flags = 0; + rn.nttrans.in.new_name = fname2+strlen(BASEDIR)+1; + + status = smb_raw_rename(cli1->tree, &rn); + + CHECK_STATUS(tctx, status, NT_STATUS_INVALID_HANDLE); done: smb_raw_exit(cli1->session); -- cgit From 39f03829a626388e8396a14c265d2f95520b0e98 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 14 Mar 2008 10:11:03 +1100 Subject: Check for Administrator as a Alias (copy&paste bug) Andrew Bartlett (This used to be commit e7afb31df1f12a3cd39ed9b95d76edc6ff0d6a70) --- source4/torture/rpc/lsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture') diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c index 60d022fbea..04d13a97c1 100644 --- a/source4/torture/rpc/lsa.c +++ b/source4/torture/rpc/lsa.c @@ -295,8 +295,8 @@ static bool test_LookupNames_wellknown(struct dcerpc_pipe *p, ret &= test_LookupNames(p, mem_ctx, handle, &tnames); name.name.string = "BUILTIN\\Administrators"; - ret &= test_LookupNames(p, mem_ctx, handle, &tnames); name.sid_type = SID_NAME_ALIAS; + ret &= test_LookupNames(p, mem_ctx, handle, &tnames); name.name.string = "SYSTEM"; name.sid_type = SID_NAME_WKN_GRP; -- cgit From 9a6422b6954242e5298653eef0d12a584f0d2811 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 14 Mar 2008 12:26:03 +1100 Subject: Rework our SAMR test and SAMR server. Now that we don't create users/domain groups/aliases in the builtin domain, we hit some bugs in the server-side implementation of the enumeration functions. In essence, it turns out to be: don't treat 0 as a special case. Also, fix up the PDC name to always be returned. I'm sure nothing actually uses it, particularly for BUILTIN... Andrew Bartlett (This used to be commit 353bb79f568f20c8469cb9458f7b14c24612ad23) --- source4/torture/rpc/samr.c | 87 +++++++++++++++++++++++++++++++++------------- 1 file changed, 62 insertions(+), 25 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c index 1d6ec43399..55c75ba270 100644 --- a/source4/torture/rpc/samr.c +++ b/source4/torture/rpc/samr.c @@ -2332,9 +2332,15 @@ static bool test_CreateAlias(struct dcerpc_pipe *p, struct torture_context *tctx status = dcerpc_samr_CreateDomAlias(p, tctx, &r); - if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { - printf("Server refused create of '%s'\n", r.in.alias_name->string); - return true; + if (dom_sid_equal(domain_sid, dom_sid_parse_talloc(tctx, SID_BUILTIN))) { + if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + printf("Server correctly refused create of '%s'\n", r.in.alias_name->string); + return true; + } else { + printf("Server should have refused create of '%s', got %s instead\n", r.in.alias_name->string, + nt_errstr(status)); + return false; + } } if (NT_STATUS_EQUAL(status, NT_STATUS_ALIAS_EXISTS)) { @@ -2515,7 +2521,8 @@ static bool test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, static bool test_CreateUser(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle *domain_handle, - struct policy_handle *user_handle_out, + struct policy_handle *user_handle_out, + struct dom_sid *domain_sid, enum torture_samr_choice which_ops) { @@ -2546,10 +2553,15 @@ static bool test_CreateUser(struct dcerpc_pipe *p, struct torture_context *tctx, status = dcerpc_samr_CreateUser(p, user_ctx, &r); - if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { - printf("Server refused create of '%s': %s\n", r.in.account_name->string, nt_errstr(status)); - talloc_free(user_ctx); - return true; + if (dom_sid_equal(domain_sid, dom_sid_parse_talloc(tctx, SID_BUILTIN))) { + if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + printf("Server correctly refused create of '%s'\n", r.in.account_name->string); + return true; + } else { + printf("Server should have refused create of '%s', got %s instead\n", r.in.account_name->string, + nt_errstr(status)); + return false; + } } if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { @@ -2610,7 +2622,9 @@ static bool test_CreateUser(struct dcerpc_pipe *p, struct torture_context *tctx, static bool test_CreateUser2(struct dcerpc_pipe *p, struct torture_context *tctx, - struct policy_handle *domain_handle, enum torture_samr_choice which_ops) + struct policy_handle *domain_handle, + struct dom_sid *domain_sid, + enum torture_samr_choice which_ops) { NTSTATUS status; struct samr_CreateUser2 r; @@ -2663,12 +2677,19 @@ static bool test_CreateUser2(struct dcerpc_pipe *p, struct torture_context *tctx status = dcerpc_samr_CreateUser2(p, user_ctx, &r); - if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { - talloc_free(user_ctx); - printf("Server refused create of '%s'\n", r.in.account_name->string); - continue; + if (dom_sid_equal(domain_sid, dom_sid_parse_talloc(tctx, SID_BUILTIN))) { + if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + printf("Server correctly refused create of '%s'\n", r.in.account_name->string); + continue; + } else { + printf("Server should have refused create of '%s', got %s instead\n", r.in.account_name->string, + nt_errstr(status)); + ret = false; + continue; + } + } - } else if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { if (!test_DeleteUser_byname(p, user_ctx, domain_handle, r.in.account_name->string)) { talloc_free(user_ctx); ret = false; @@ -3893,6 +3914,7 @@ static bool test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } if (!q1.out.sam) { + printf("EnumDomainGroups failed to return q1.out.sam\n"); return false; } @@ -4138,7 +4160,9 @@ static bool test_AddGroupMember(struct dcerpc_pipe *p, struct torture_context *t static bool test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *domain_handle, struct policy_handle *group_handle) + struct policy_handle *domain_handle, + struct policy_handle *group_handle, + struct dom_sid *domain_sid) { NTSTATUS status; struct samr_CreateDomainGroup r; @@ -4158,15 +4182,19 @@ static bool test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r); - if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { - printf("Server refused create of '%s'\n", r.in.name->string); - ZERO_STRUCTP(group_handle); - return true; + if (dom_sid_equal(domain_sid, dom_sid_parse_talloc(mem_ctx, SID_BUILTIN))) { + if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { + printf("Server correctly refused create of '%s'\n", r.in.name->string); + return true; + } else { + printf("Server should have refused create of '%s', got %s instead\n", r.in.name->string, + nt_errstr(status)); + return false; + } } if (NT_STATUS_EQUAL(status, NT_STATUS_GROUP_EXISTS)) { if (!test_DeleteGroup_byname(p, mem_ctx, domain_handle, r.in.name->string)) { - printf("CreateDomainGroup failed: Could not delete domain group %s - %s\n", r.in.name->string, nt_errstr(status)); return false; @@ -4244,7 +4272,7 @@ static bool test_OpenDomain(struct dcerpc_pipe *p, struct torture_context *tctx, ZERO_STRUCT(group_handle); ZERO_STRUCT(domain_handle); - printf("Testing OpenDomain\n"); + printf("Testing OpenDomain of %s\n", dom_sid_string(tctx, sid)); r.in.connect_handle = handle; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -4264,17 +4292,23 @@ static bool test_OpenDomain(struct dcerpc_pipe *p, struct torture_context *tctx, switch (which_ops) { case TORTURE_SAMR_USER_ATTRIBUTES: case TORTURE_SAMR_PASSWORDS: - ret &= test_CreateUser2(p, tctx, &domain_handle, which_ops); - ret &= test_CreateUser(p, tctx, &domain_handle, &user_handle, which_ops); + ret &= test_CreateUser2(p, tctx, &domain_handle, sid, which_ops); + ret &= test_CreateUser(p, tctx, &domain_handle, &user_handle, sid, which_ops); /* This test needs 'complex' users to validate */ ret &= test_QueryDisplayInfo(p, tctx, &domain_handle); + if (!ret) { + printf("Testing PASSWORDS or ATTRIBUTES on domain %s failed!\n", dom_sid_string(tctx, sid)); + } break; case TORTURE_SAMR_OTHER: - ret &= test_CreateUser(p, tctx, &domain_handle, &user_handle, which_ops); + ret &= test_CreateUser(p, tctx, &domain_handle, &user_handle, sid, which_ops); + if (!ret) { + printf("Failed to CreateUser in SAMR-OTHER on domain %s!\n", dom_sid_string(tctx, sid)); + } ret &= test_QuerySecurity(p, tctx, &domain_handle); ret &= test_RemoveMemberFromForeignDomain(p, tctx, &domain_handle); ret &= test_CreateAlias(p, tctx, &domain_handle, &alias_handle, sid); - ret &= test_CreateDomainGroup(p, tctx, &domain_handle, &group_handle); + ret &= test_CreateDomainGroup(p, tctx, &domain_handle, &group_handle, sid); ret &= test_QueryDomainInfo(p, tctx, &domain_handle); ret &= test_QueryDomainInfo2(p, tctx, &domain_handle); ret &= test_EnumDomainUsers(p, tctx, &domain_handle); @@ -4295,6 +4329,9 @@ static bool test_OpenDomain(struct dcerpc_pipe *p, struct torture_context *tctx, ret &= test_TestPrivateFunctionsDomain(p, tctx, &domain_handle); ret &= test_RidToSid(p, tctx, sid, &domain_handle); ret &= test_GetBootKeyInformation(p, tctx, &domain_handle); + if (!ret) { + printf("Testing SAMR-OTHER on domain %s failed!\n", dom_sid_string(tctx, sid)); + } break; } -- cgit From b65ad8966a7ffba15b64b837610a65694336f80a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 17 Mar 2008 09:59:30 +0100 Subject: RAW-BENCH-OPEN: fix the output and calculate the total operations metze (This used to be commit c84e3abae9781c0cbea5fee00bafe70967fb6468) --- source4/torture/raw/openbench.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c index 87b27d0728..8f4558e732 100644 --- a/source4/torture/raw/openbench.c +++ b/source4/torture/raw/openbench.c @@ -37,7 +37,7 @@ static int nprocs; static int open_failed; -static int open_retries; +static int close_failed; static char **fnames; static int num_connected; static struct timed_event *report_te; @@ -55,6 +55,7 @@ struct benchopen_state { int count; int lastcount; union smb_open open_parms; + int open_retries; union smb_close close_parms; struct smbcli_request *req_open; struct smbcli_request *req_close; @@ -228,7 +229,7 @@ static void open_completed(struct smbcli_request *req) if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { DEBUG(2,("[%d] retrying open\n", state->client_num)); - open_retries++; + state->open_retries++; state->req_open = smb_raw_open_send(state->tree, &state->open_parms); state->req_open->async.fn = open_completed; state->req_open->async.private = state; @@ -280,7 +281,7 @@ static void close_completed(struct smbcli_request *req) } if (!NT_STATUS_IS_OK(status)) { - open_failed++; + close_failed++; DEBUG(0,("close failed - %s\n", nt_errstr(status))); return; } @@ -352,7 +353,9 @@ bool torture_bench_open(struct torture_context *torture) struct timeval tv; struct event_context *ev = event_context_find(mem_ctx); struct benchopen_state *state; - int total = 0, minops=0; + int total = 0; + int total_retries = 0; + int minops = 0; bool progress=false; progress = torture_setting_bool(torture, "progress", true); @@ -420,17 +423,24 @@ bool torture_bench_open(struct torture_context *torture) DEBUG(0,("open failed\n")); goto failed; } + if (close_failed) { + DEBUG(0,("open failed\n")); + goto failed; + } } talloc_free(report_te); - printf("%.2f ops/second (%d retries)\n", - total/timeval_elapsed(&tv), open_retries); minops = state[0].count; for (i=0;i Date: Mon, 17 Mar 2008 12:11:44 +0100 Subject: RAW-BENCH-OPEN: avoid sync calls before the main loop On multi cpu machines the server may reply to the first requests while the test is still in setup mode. Now we setup the first opens, but send them all together when entering the main loop. metze (This used to be commit 3f2d12c61e95475009baf77c3e0fbea2abecc17a) --- source4/torture/raw/openbench.c | 88 +++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 33 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c index 8f4558e732..e8b2f56813 100644 --- a/source4/torture/raw/openbench.c +++ b/source4/torture/raw/openbench.c @@ -49,9 +49,12 @@ struct benchopen_state { struct smbcli_state *cli; struct smbcli_tree *tree; int client_num; - int old_fnum; - int fnum; - int file_num; + int close_fnum; + int open_fnum; + int close_file_num; + int open_file_num; + int pending_file_num; + int next_file_num; int count; int lastcount; union smb_open open_parms; @@ -96,11 +99,11 @@ static void reopen_connection_complete(struct composite_context *ctx) num_connected++; - DEBUG(0,("reconnect to %s finished (%u connected)\n", state->dest_host, - num_connected)); + DEBUG(0,("[%u] reconnect to %s finished (%u connected)\n", + state->client_num, state->dest_host, num_connected)); - state->fnum = -1; - state->old_fnum = -1; + state->open_fnum = -1; + state->close_fnum = -1; next_open(state); } @@ -137,7 +140,8 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te, /* kill off the remnants of the old connection */ talloc_free(state->tree); state->tree = NULL; - state->fnum = -1; + state->open_fnum = -1; + state->close_fnum = -1; ctx = smb_composite_connect_send(io, state->mem_ctx, lp_resolve_context(state->tctx->lp_ctx), @@ -159,9 +163,10 @@ static void next_open(struct benchopen_state *state) { state->count++; - state->file_num = (state->file_num+1) % (3*nprocs); + state->pending_file_num = state->next_file_num; + state->next_file_num = (state->next_file_num+1) % (3*nprocs); - DEBUG(2,("[%d] opening %u\n", state->client_num, state->file_num)); + DEBUG(2,("[%d] opening %u\n", state->client_num, state->pending_file_num)); state->open_parms.ntcreatex.level = RAW_OPEN_NTCREATEX; state->open_parms.ntcreatex.in.flags = 0; state->open_parms.ntcreatex.in.root_fid = 0; @@ -173,7 +178,7 @@ static void next_open(struct benchopen_state *state) state->open_parms.ntcreatex.in.create_options = 0; state->open_parms.ntcreatex.in.impersonation = 0; state->open_parms.ntcreatex.in.security_flags = 0; - state->open_parms.ntcreatex.in.fname = fnames[state->file_num]; + state->open_parms.ntcreatex.in.fname = fnames[state->pending_file_num]; state->req_open = smb_raw_open_send(state->tree, &state->open_parms); state->req_open->async.fn = open_completed; @@ -183,18 +188,18 @@ static void next_open(struct benchopen_state *state) static void next_close(struct benchopen_state *state) { - DEBUG(2,("[%d] closing %d\n", state->client_num, state->old_fnum)); - if (state->old_fnum == -1) { + if (state->close_fnum == -1) { return; } + DEBUG(2,("[%d] closing %d (fnum[%d])\n", + state->client_num, state->close_file_num, state->close_fnum)); state->close_parms.close.level = RAW_CLOSE_CLOSE; - state->close_parms.close.in.file.fnum = state->old_fnum; + state->close_parms.close.in.file.fnum = state->close_fnum; state->close_parms.close.in.write_time = 0; state->req_close = smb_raw_close_send(state->tree, &state->close_parms); state->req_close->async.fn = close_completed; state->req_close->async.private = state; - state->old_fnum = -1; } /* @@ -219,7 +224,8 @@ static void open_completed(struct smbcli_request *req) state->tree = NULL; state->cli = NULL; num_connected--; - DEBUG(0,("reopening connection to %s\n", state->dest_host)); + DEBUG(0,("[%u] reopening connection to %s\n", + state->client_num, state->dest_host)); talloc_free(state->te); state->te = event_add_timed(state->ev, state->mem_ctx, timeval_current_ofs(1,0), @@ -228,7 +234,8 @@ static void open_completed(struct smbcli_request *req) } if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { - DEBUG(2,("[%d] retrying open\n", state->client_num)); + DEBUG(2,("[%d] retrying open %d\n", + state->client_num, state->pending_file_num)); state->open_retries++; state->req_open = smb_raw_open_send(state->tree, &state->open_parms); state->req_open->async.fn = open_completed; @@ -238,17 +245,21 @@ static void open_completed(struct smbcli_request *req) if (!NT_STATUS_IS_OK(status)) { open_failed++; - DEBUG(0,("open failed - %s\n", nt_errstr(status))); + DEBUG(0,("[%u] open failed %d - %s\n", + state->client_num, state->pending_file_num, + nt_errstr(status))); return; } - state->old_fnum = state->fnum; - state->fnum = state->open_parms.ntcreatex.out.file.fnum; + state->close_file_num = state->open_file_num; + state->close_fnum = state->open_fnum; + state->open_file_num = state->pending_file_num; + state->open_fnum = state->open_parms.ntcreatex.out.file.fnum; - DEBUG(2,("[%d] open completed: fnum=%d old_fnum=%d\n", - state->client_num, state->fnum, state->old_fnum)); + DEBUG(2,("[%d] open completed %d (fnum[%d])\n", + state->client_num, state->open_file_num, state->open_fnum)); - if (state->old_fnum != -1) { + if (state->close_fnum != -1) { next_close(state); } @@ -272,7 +283,8 @@ static void close_completed(struct smbcli_request *req) state->tree = NULL; state->cli = NULL; num_connected--; - DEBUG(0,("reopening connection to %s\n", state->dest_host)); + DEBUG(0,("[%u] reopening connection to %s\n", + state->client_num, state->dest_host)); talloc_free(state->te); state->te = event_add_timed(state->ev, state->mem_ctx, timeval_current_ofs(1,0), @@ -282,12 +294,16 @@ static void close_completed(struct smbcli_request *req) if (!NT_STATUS_IS_OK(status)) { close_failed++; - DEBUG(0,("close failed - %s\n", nt_errstr(status))); + DEBUG(0,("[%u] close failed %d (fnum[%d]) - %s\n", + state->client_num, state->close_file_num, + state->close_fnum, + nt_errstr(status))); return; } - DEBUG(2,("[%d] close completed: fnum=%d old_fnum=%d\n", - state->client_num, state->fnum, state->old_fnum)); + DEBUG(2,("[%d] close completed %d (fnum[%d])\n", + state->client_num, state->close_file_num, + state->close_fnum)); } static void echo_completion(struct smbcli_request *req) @@ -299,7 +315,8 @@ static void echo_completion(struct smbcli_request *req) talloc_free(state->tree); state->tree = NULL; num_connected--; - DEBUG(0,("reopening connection to %s\n", state->dest_host)); + DEBUG(0,("[%u] reopening connection to %s\n", + state->client_num, state->dest_host)); talloc_free(state->te); state->te = event_add_timed(state->ev, state->mem_ctx, timeval_current_ofs(1,0), @@ -400,11 +417,10 @@ bool torture_bench_open(struct torture_context *torture) } for (i=0;ifile_num], - O_RDWR|O_CREAT, DENY_ALL); - state[i].old_fnum = -1; + /* all connections start with the same file */ + state[i].next_file_num = 0; + state[i].open_fnum = -1; + state[i].close_fnum = -1; next_open(&state[i]); } @@ -430,6 +446,12 @@ bool torture_bench_open(struct torture_context *torture) } talloc_free(report_te); + if (progress) { + for (i=0;i Date: Tue, 18 Mar 2008 13:02:32 +0100 Subject: smbtorture: fix typos in RAW-OPLOCK output. Michael (This used to be commit 9fa4b53b61064c910b8f5c9c676c971023b8670c) --- source4/torture/raw/oplock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 5ab43d5e78..8b2e4fb177 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -2539,7 +2539,7 @@ static bool test_raw_oplock_batch22(struct torture_context *tctx, struct smbcli_ int te; if (torture_setting_bool(tctx, "samba3", false)) { - torture_skip(tctx, "BACHT22 disabled against samba3\n"); + torture_skip(tctx, "BATCH22 disabled against samba3\n"); } if (!torture_setup_dir(cli1, BASEDIR)) { @@ -2629,7 +2629,7 @@ static bool test_raw_oplock_batch23(struct torture_context *tctx, struct smbcli_ struct smbcli_state *cli3 = NULL; if (torture_setting_bool(tctx, "samba3", false)) { - torture_skip(tctx, "BACHT23 disabled against samba3\n"); + torture_skip(tctx, "BATCH23 disabled against samba3\n"); } if (!torture_setup_dir(cli1, BASEDIR)) { -- cgit From 1c9fe1157cda484e6d450de9b2fe49ff57663a2e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Mar 2008 21:10:39 +0100 Subject: Fix a warning Without this patch I get ./libcli/security/proto.h:45: warning: 'struct auth_session_info' declared inside parameter list (This used to be commit 078a6fdb3f8e389102a07b81b6b8d87fa8bf17c3) --- source4/torture/rpc/samba3rpc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture') diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index 95252e7397..d881fbfc8b 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -47,6 +47,7 @@ #include "libcli/smb_composite/smb_composite.h" #include "libcli/auth/libcli_auth.h" #include "lib/crypto/crypto.h" +#include "auth/ntlmssp/ntlmssp.h" #include "libcli/security/proto.h" #include "param/param.h" #include "lib/registry/registry.h" -- cgit From 21c7afd9b0aa4c32d42b5f6acd042bf833e9e9b6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Mar 2008 21:11:49 +0100 Subject: Add the workstation to the anon sessetup credentials Without this patch the RPC-SAMBA3SESSIONKEY against W2k3 gives INVALID_PARAMETER for the anonymous session setup (This used to be commit eb459be878e98cb58c6b5779584e187cdcbf4f91) --- source4/torture/rpc/samba3rpc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/torture') diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index d881fbfc8b..c5f91cf4ea 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -1322,6 +1322,8 @@ bool torture_samba3_sessionkey(struct torture_context *torture) goto done; } + cli_credentials_set_workstation(anon_creds, wks_name, CRED_SPECIFIED); + ret = true; if (!torture_setting_bool(torture, "samba3", false)) { -- cgit From ce98599c14ffe9db5e86f9706fb9fa7a71c5998d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Mar 2008 21:59:46 +0100 Subject: Prove that a setuserinfo level 25 does set the pwdlastset field Very likely this is not the full story, but as it happens so often this proof is needed to fix a direct s3 bug. (This used to be commit 16b4a3685bf59faee22882ee14ddb95918f64e22) --- source4/torture/rpc/samba3rpc.c | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'source4/torture') diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index c5f91cf4ea..204a9f2865 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -683,6 +683,7 @@ static bool join3(struct smbcli_state *cli, struct dcerpc_pipe *samr_pipe; struct policy_handle *wks_handle; bool ret = false; + NTTIME last_password_change; if ((mem_ctx = talloc_init("join3")) == NULL) { d_printf("talloc_init failed\n"); @@ -702,6 +703,22 @@ static bool join3(struct smbcli_state *cli, goto done; } + { + struct samr_QueryUserInfo q; + + q.in.user_handle = wks_handle; + q.in.level = 21; + + status = dcerpc_samr_QueryUserInfo(samr_pipe, mem_ctx, &q); + if (!NT_STATUS_IS_OK(status)) { + d_printf("(%s) QueryUserInfo failed: %s\n", + __location__, nt_errstr(status)); + goto done; + } + + last_password_change = q.out.info->info21.last_password_change; + } + cli_credentials_set_domain(wks_creds, dom_name, CRED_SPECIFIED); if (use_level25) { @@ -795,6 +812,39 @@ static bool join3(struct smbcli_state *cli, } } + { + struct samr_QueryUserInfo q; + + q.in.user_handle = wks_handle; + q.in.level = 21; + + status = dcerpc_samr_QueryUserInfo(samr_pipe, mem_ctx, &q); + if (!NT_STATUS_IS_OK(status)) { + d_printf("(%s) QueryUserInfo failed: %s\n", + __location__, nt_errstr(status)); + goto done; + } + + if (use_level25) { + if (last_password_change + == q.out.info->info21.last_password_change) { + d_printf("(%s) last_password_change unchanged " + "during join, level25 must change " + "it\n", __location__); + goto done; + } + } + else { + if (last_password_change + != q.out.info->info21.last_password_change) { + d_printf("(%s) last_password_change changed " + "during join, level24 doesn't " + "change it\n", __location__); + goto done; + } + } + } + ret = true; done: -- cgit