The branch, master has been updated via 17caf63... s3 selftest: Add RAW-SFILEINFO-END-OF-FILE to selftest via af610a6... s3 setfileinfo: Open with FILE_WRITE_DATA when setting the file size via b6f9722... s4 torture: Change RAW-OPLOCK to use the documented version of SET_END_OF_FILE_INFO via 98f5950... s4 torture: Allow onefs to be checked like samba3 and samba4 via 6074a05... s4 torture: Add two new setfileinfo tests via ce9ac3a... s4 torture: Split up the torture suite setup for RAW-SFILEINFO from 56eca75... The start of a WHATSNEW for Samba4 alpha9
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 17caf63640b344aec304eca9cc527f32f88ae308 Author: Tim Prouty <tpro...@samba.org> Date: Wed Nov 25 08:15:31 2009 -0800 s3 selftest: Add RAW-SFILEINFO-END-OF-FILE to selftest commit af610a6f263994e7a0ded8acf0fa9237d5b7d366 Author: Tim Prouty <tpro...@samba.org> Date: Tue Nov 24 16:48:16 2009 -0800 s3 setfileinfo: Open with FILE_WRITE_DATA when setting the file size This matches what is outlined here: http://msdn.microsoft.com/en-us/library/ms804363.aspx This is also inline with how winXP/win7 handle this. See RAW-SFILEINFO-END-OF-FILE* in smbtorture4. commit b6f972222f271263f68cf5ead8bb0daca08158fa Author: Tim Prouty <tpro...@samba.org> Date: Wed Nov 25 08:03:36 2009 -0800 s4 torture: Change RAW-OPLOCK to use the documented version of SET_END_OF_FILE_INFO The passtrhough version of SET_END_OF_FILE_INFO is tested in RAW-SFILEINFO-END-OF-FILE. Additionally, the first opener is changed to use SHARE_WRITE for the share mode since SET_END_OF_FILE_INFO actually writes data to the file via truncating/extending. commit 98f595036e196dd61340fef0faf63ca762a25307 Author: Tim Prouty <tpro...@samba.org> Date: Wed Nov 25 08:17:13 2009 -0800 s4 torture: Allow onefs to be checked like samba3 and samba4 This is needed for the new RAW-SFILEINFO-END-OF-FILE test to differentiate what appears to be a windows bug. commit 6074a058df3e637ad5eb333b278d89cd1be5a8c0 Author: Tim Prouty <tpro...@samba.org> Date: Tue Nov 24 16:29:19 2009 -0800 s4 torture: Add two new setfileinfo tests These tests expose a potential bug in winXP, win7, and likely others. There is also a bug in samba where share modes aren't being enforced where they should. For more details see: http://lists.samba.org/archive/cifs-protocol/2009-November/001130.html commit ce9ac3a685e2a23b30952bf20dbe3f9bf24dfaaa Author: Tim Prouty <tpro...@samba.org> Date: Tue Nov 24 16:25:02 2009 -0800 s4 torture: Split up the torture suite setup for RAW-SFILEINFO A side effect of this change is that RAW-SFILEINFO now runs the whole suite instead of just the first test. I changed the name of the first test to RAW-SFILEINFO-BASE and changed all of the selftest scripts that call it. ----------------------------------------------------------------------- Summary of changes: source3/script/tests/test_posix_s3.sh | 6 +- source3/smbd/trans2.c | 2 +- source4/selftest/test_w2k3_file.sh | 2 +- source4/selftest/win/wintest_raw.sh | 2 +- source4/torture/raw/oplock.c | 8 +- source4/torture/raw/raw.c | 5 +- source4/torture/raw/setfileinfo.c | 217 ++++++++++++++++++++++++++++++++- source4/torture/smbtorture.c | 1 + 8 files changed, 223 insertions(+), 20 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/script/tests/test_posix_s3.sh b/source3/script/tests/test_posix_s3.sh index 11fe247..60ed3e4 100755 --- a/source3/script/tests/test_posix_s3.sh +++ b/source3/script/tests/test_posix_s3.sh @@ -32,10 +32,10 @@ base="$base BASE-XCOPY BASE-SAMBA3ERROR" raw="RAW-ACLS RAW-CHKPATH RAW-CLOSE RAW-COMPOSITE RAW-CONTEXT RAW-EAS" raw="$raw RAW-IOCTL RAW-LOCK RAW-MKDIR RAW-MUX RAW-NOTIFY RAW-OPEN RAW-OPLOCK" raw="$raw RAW-QFILEINFO RAW-QFSINFO RAW-READ RAW-RENAME RAW-SEARCH RAW-SEEK" -raw="$raw RAW-SFILEINFO RAW-SFILEINFO-BUG RAW-STREAMS RAW-UNLINK RAW-WRITE" +raw="$raw RAW-SFILEINFO-BASE RAW-SFILEINFO-BUG RAW-STREAMS RAW-UNLINK RAW-WRITE" raw="$raw RAW-SAMBA3HIDE RAW-SAMBA3BADPATH RAW-SFILEINFO-RENAME" raw="$raw RAW-SAMBA3CASEINSENSITIVE RAW-SAMBA3POSIXTIMEDLOCK" -raw="$raw RAW-SAMBA3ROOTDIRFID" +raw="$raw RAW-SAMBA3ROOTDIRFID RAW-SFILEINFO-END-OF-FILE" rpc="RPC-AUTHCONTEXT RPC-BINDSAMBA3 RPC-SAMBA3-SRVSVC RPC-SAMBA3-SHARESEC" rpc="$rpc RPC-SAMBA3-SPOOLSS RPC-SAMBA3-WKSSVC" @@ -67,7 +67,7 @@ skipped="BASE-CHARSET BASE-TCONDEV" skipped="$skipped RAW-ACLS RAW-COMPOSITE RAW-CONTEXT" skipped="$skipped RAW-IOCTL" skipped="$skipped RAW-QFILEINFO RAW-QFSINFO" -skipped="$skipped RAW-SFILEINFO" +skipped="$skipped RAW-SFILEINFO-BASE" echo "WARNING: Skipping tests $skipped" diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 17ebd81..2892e26 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -5578,7 +5578,7 @@ static NTSTATUS smb_set_file_size(connection_struct *conn, req, /* req */ 0, /* root_dir_fid */ smb_fname_tmp, /* fname */ - FILE_WRITE_ATTRIBUTES, /* access_mask */ + FILE_WRITE_DATA, /* access_mask */ (FILE_SHARE_READ | FILE_SHARE_WRITE | /* share_access */ FILE_SHARE_DELETE), FILE_OPEN, /* create_disposition*/ diff --git a/source4/selftest/test_w2k3_file.sh b/source4/selftest/test_w2k3_file.sh index d59d2b4..27714c2 100755 --- a/source4/selftest/test_w2k3_file.sh +++ b/source4/selftest/test_w2k3_file.sh @@ -27,7 +27,7 @@ tests="$tests BASE-DENY3 BASE-XCOPY BASE-OPEN BASE-DENYDOS" tests="$tests BASE-DELETE BASE-PROPERTIES BASE-MANGLE" tests="$tests BASE-CHKPATH BASE-SECLEAK BASE-TRANS2" tests="$tests BASE-NTDENY1 BASE-NTDENY2 BASE-RENAME BASE-OPENATTR" -tests="$tests RAW-QFILEINFO RAW-SFILEINFO-BUG RAW-SFILEINFO" +tests="$tests RAW-QFILEINFO RAW-SFILEINFO-BUG RAW-SFILEINFO-BASE" tests="$tests RAW-LOCK RAW-MKDIR RAW-SEEK RAW-CONTEXT RAW-MUX RAW-OPEN RAW-WRITE" tests="$tests RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-CHKPATH RAW-RENAME" tests="$tests RAW-EAS RAW-STREAMS RAW-OPLOCK RAW-NOTIFY BASE-DELAYWRITE" diff --git a/source4/selftest/win/wintest_raw.sh b/source4/selftest/win/wintest_raw.sh index 541e198..d1bece2 100755 --- a/source4/selftest/win/wintest_raw.sh +++ b/source4/selftest/win/wintest_raw.sh @@ -22,7 +22,7 @@ shift 4 export SMBTORTURE_REMOTE_HOST=$server -raw_tests="RAW-QFILEINFO RAW-SFILEINFO RAW-MKDIR RAW-SEEK RAW-OPEN RAW-WRITE RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-RENAME RAW-EAS RAW-STREAMS" +raw_tests="RAW-QFILEINFO RAW-SFILEINFO-BASE RAW-MKDIR RAW-SEEK RAW-OPEN RAW-WRITE RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-RENAME RAW-EAS RAW-STREAMS" # This test fails: RAW-QFSINFO all_errs=0 diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 63f5ee5..0ebbb38 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -444,7 +444,7 @@ static bool test_raw_oplock_exclusive3(struct torture_context *tctx, struct smbc 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.share_access = NTCREATEX_SHARE_ACCESS_WRITE; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; io.ntcreatex.in.create_options = 0; io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; @@ -463,7 +463,7 @@ static bool test_raw_oplock_exclusive3(struct torture_context *tctx, struct smbc torture_comment(tctx, "setpathinfo EOF should trigger a break to none\n"); ZERO_STRUCT(sfi); - sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; + sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFO; sfi.generic.in.file.path = fname; sfi.end_of_file_info.in.size = 100; @@ -1501,7 +1501,7 @@ static bool test_raw_oplock_batch11(struct torture_context *tctx, struct smbcli_ 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.share_access = NTCREATEX_SHARE_ACCESS_WRITE; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF; io.ntcreatex.in.create_options = 0; io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; @@ -1530,7 +1530,7 @@ static bool test_raw_oplock_batch11(struct torture_context *tctx, struct smbcli_ CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN); ZERO_STRUCT(sfi); - sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; + sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFO; sfi.generic.in.file.path = fname; sfi.end_of_file_info.in.size = 100; diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c index 138f263..ada290f 100644 --- a/source4/torture/raw/raw.c +++ b/source4/torture/raw/raw.c @@ -41,10 +41,7 @@ NTSTATUS torture_raw_init(void) torture_suite_add_1smb_test(suite, "QFSINFO", torture_raw_qfsinfo); torture_suite_add_1smb_test(suite, "QFILEINFO", torture_raw_qfileinfo); torture_suite_add_1smb_test(suite, "QFILEINFO-IPC", torture_raw_qfileinfo_pipe); - torture_suite_add_1smb_test(suite, "SFILEINFO", torture_raw_sfileinfo); - torture_suite_add_1smb_test(suite, "SFILEINFO-BUG", torture_raw_sfileinfo_bug); - torture_suite_add_1smb_test(suite, "SFILEINFO-RENAME", - torture_raw_sfileinfo_rename); + torture_suite_add_suite(suite, torture_raw_sfileinfo(suite)); torture_suite_add_suite(suite, torture_raw_search(suite)); torture_suite_add_1smb_test(suite, "CLOSE", torture_raw_close); torture_suite_add_1smb_test(suite, "OPEN", torture_raw_open); diff --git a/source4/torture/raw/setfileinfo.c b/source4/torture/raw/setfileinfo.c index 31c7533..0aa1f38 100644 --- a/source4/torture/raw/setfileinfo.c +++ b/source4/torture/raw/setfileinfo.c @@ -29,8 +29,8 @@ for each call we test that it succeeds, and where possible test for consistency between the calls. */ -bool torture_raw_sfileinfo(struct torture_context *torture, - struct smbcli_state *cli) +static bool +torture_raw_sfileinfo_base(struct torture_context *torture, struct smbcli_state *cli) { bool ret = true; int fnum = -1; @@ -442,8 +442,9 @@ done: /* * basic testing of all RAW_SFILEINFO_RENAME call */ -bool torture_raw_sfileinfo_rename(struct torture_context *torture, - struct smbcli_state *cli) +static bool +torture_raw_sfileinfo_rename(struct torture_context *torture, + struct smbcli_state *cli) { bool ret = true; int fnum_saved, d_fnum, fnum2, fnum = -1; @@ -669,8 +670,8 @@ done: /* look for the w2k3 setpathinfo STANDARD bug */ -bool torture_raw_sfileinfo_bug(struct torture_context *torture, - struct smbcli_state *cli) +static bool torture_raw_sfileinfo_bug(struct torture_context *torture, + struct smbcli_state *cli) { const char *fname = "\\bug3.txt"; union smb_setfileinfo sfinfo; @@ -698,3 +699,207 @@ bool torture_raw_sfileinfo_bug(struct torture_context *torture, return true; } + +static bool +torture_raw_sfileinfo_eof(struct torture_context *tctx, struct smbcli_state *cli1, + struct smbcli_state *cli2) +{ + const char *fname = BASEDIR "\\test_sfileinfo_end_of_file.dat"; + NTSTATUS status; + bool ret = true; + union smb_open io; + union smb_setfileinfo sfi; + union smb_fileinfo qfi; + uint16_t fnum = 0; + + if (!torture_setup_dir(cli1, BASEDIR)) { + return false; + } + + /* cleanup */ + smbcli_unlink(cli1->tree, fname); + + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid.fnum = 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 = fname; + io.ntcreatex.in.flags = 0; + + /* Open the file sharing none. */ + status = smb_raw_open(cli1->tree, tctx, &io); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); + fnum = io.ntcreatex.out.file.fnum; + + /* Try to sfileinfo to extend the file. */ + ZERO_STRUCT(sfi); + sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFO; + sfi.generic.in.file.path = fname; + sfi.end_of_file_info.in.size = 100; + status = smb_raw_setpathinfo(cli2->tree, &sfi); + + /* There should be share mode contention in this case. */ + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_SHARING_VIOLATION, ret, done, "Status should be " + "SHARING_VIOLATION"); + + /* Make sure the size is still 0. */ + ZERO_STRUCT(qfi); + qfi.generic.level = RAW_FILEINFO_STANDARD_INFO; + qfi.generic.in.file.path = fname; + status = smb_raw_pathinfo(cli2->tree, tctx, &qfi); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); + + torture_assert_u64_equal(tctx, qfi.standard_info.out.size, 0, + "alloc_size should be 0 since the setpathinfo failed."); + + /* Try again with the pass through instead of documented version. */ + ZERO_STRUCT(sfi); + sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; + sfi.generic.in.file.path = fname; + sfi.end_of_file_info.in.size = 100; + status = smb_raw_setpathinfo(cli2->tree, &sfi); + + /* + * Looks like a windows bug: + * http://lists.samba.org/archive/cifs-protocol/2009-November/001130.html + */ + if (torture_setting_bool(tctx, "samba3", false) || + torture_setting_bool(tctx, "samba4", false) || + torture_setting_bool(tctx, "onefs", false)) { + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_SHARING_VIOLATION, ret, done, "Status should be " + "SHARING_VIOLATION"); + goto done; + } else { + /* It succeeds! This is just weird! */ + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); + } + + /* Verify that the file was actually extended to 100. */ + ZERO_STRUCT(qfi); + qfi.generic.level = RAW_FILEINFO_STANDARD_INFO; + qfi.generic.in.file.path = fname; + status = smb_raw_pathinfo(cli2->tree, tctx, &qfi); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); + + torture_assert_u64_equal(tctx, qfi.standard_info.out.size, 100, + "alloc_size should be 100 since the setpathinfo succeeded."); + + /* + * Try another open with just write to mimic what setpathinfo should + * be doing under the covers. + */ + io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA; + status = smb_raw_open(cli2->tree, tctx, &io); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_SHARING_VIOLATION, ret, done, "Status should be " + "SHARING_VIOLATION"); + + 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 +torture_raw_sfileinfo_eof_access(struct torture_context *tctx, + struct smbcli_state *cli1, struct smbcli_state *cli2) +{ + const char *fname = BASEDIR "\\test_exclusive3.dat"; + NTSTATUS status, expected_status; + bool ret = true; + union smb_open io; + union smb_setfileinfo sfi; + uint16_t fnum=0; + uint32_t access_mask = 0; + + if (!torture_setup_dir(cli1, BASEDIR)) { + return false; + } + + /* cleanup */ + smbcli_unlink(cli1->tree, fname); + + /* + * base ntcreatex parms + */ + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.root_fid.fnum = 0; + 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_OVERWRITE_IF; + io.ntcreatex.in.create_options = 0; + io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.fname = fname; + io.ntcreatex.in.flags = 0; + + + for (access_mask = 1; access_mask <= 0x00001FF; access_mask++) { + io.ntcreatex.in.access_mask = access_mask; + + status = smb_raw_open(cli1->tree, tctx, &io); + if (!NT_STATUS_IS_OK(status)) { + continue; + } + + fnum = io.ntcreatex.out.file.fnum; + + ZERO_STRUCT(sfi); + sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFO; + sfi.generic.in.file.fnum = fnum; + sfi.end_of_file_info.in.size = 100; + + status = smb_raw_setfileinfo(cli1->tree, &sfi); + + expected_status = (access_mask & SEC_FILE_WRITE_DATA) ? + NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; + + if (!NT_STATUS_EQUAL(expected_status, status)) { + torture_comment(tctx, "0x%x wrong\n", access_mask); + } + + torture_assert_ntstatus_equal_goto(tctx, status, + expected_status, ret, done, "Status Wrong"); + + smbcli_close(cli1->tree, fnum); + } + +done: + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + smbcli_deltree(cli1->tree, BASEDIR); + return ret; +} + +struct torture_suite *torture_raw_sfileinfo(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite = torture_suite_create(mem_ctx, + "SFILEINFO"); + + torture_suite_add_1smb_test(suite, "BASE", torture_raw_sfileinfo_base); + torture_suite_add_1smb_test(suite, "RENAME", + torture_raw_sfileinfo_rename); + torture_suite_add_1smb_test(suite, "BUG", torture_raw_sfileinfo_bug); + torture_suite_add_2smb_test(suite, "END-OF-FILE", + torture_raw_sfileinfo_eof); + torture_suite_add_2smb_test(suite, "END-OF-FILE-ACCESS", + torture_raw_sfileinfo_eof_access); + + return suite; +} diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index b9ed521..51d82ae 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -535,6 +535,7 @@ int main(int argc,char *argv[]) "0x00010000"); } else if (strcmp(target, "onefs") == 0) { lp_set_cmdline(cmdline_lp_ctx, "torture:sacl_support", "false"); + lp_set_cmdline(cmdline_lp_ctx, "torture:onefs", "true"); } if (max_runtime) { -- Samba Shared Repository