The branch, master has been updated via ae64978... s3: Fix smbd to correctly return INVALID_LEVEL on set_file_end_of_file_info for paths via 4e8b6c5... s4 torture: Change oplock to use passthrough for exclusive3/batch11 via 5035a90... s4 torture: Update RAW-SFILEINFO-END-OF-FILE to test some additional corner cases via 5a934fd... Revert "s4 torture: Allow onefs to be checked like samba3 and samba4" via 66bf780... s4 torture: Change RAW-SFILEINFO-END-OF-FILE to check for share modes by default via 2738e31... s4 torture: Move target macros to a common header instead of redefining them in multiple files from 9d8867f... s3:build: fix detection of CTDB headers on systems without system-libtalloc
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit ae649782df6e22c8e1922aaa03c248e5af68a036 Author: Tim Prouty <tpro...@samba.org> Date: Tue Dec 1 10:47:08 2009 -0800 s3: Fix smbd to correctly return INVALID_LEVEL on set_file_end_of_file_info for paths This allows smbd to pass the freshly updated RAW-SFILEINFO-END-OF-FILE torture test. commit 4e8b6c5992494e1177cd98e47d96498a259b9056 Author: Tim Prouty <tpro...@samba.org> Date: Mon Nov 30 16:43:00 2009 -0800 s4 torture: Change oplock to use passthrough for exclusive3/batch11 In light of the INVALID_LEVEL that is seen for RAW_SFILEINFO_END_OF_FILE_INFO requests on a path, I'm changing these back to using the passthrough RAW_SFILEINFO_END_OF_FILE_INFORMATION to test the oplock break behavior as originally intended commit 5035a900051c7946346d4e8b32e8f13f802ce5be Author: Tim Prouty <tpro...@samba.org> Date: Mon Nov 30 11:59:19 2009 -0800 s4 torture: Update RAW-SFILEINFO-END-OF-FILE to test some additional corner cases It turns out setting the end-of-file with Trans2SetPathInfo using the snia spec's info level will attempt to open the file, enforcing share modes, but then subsequentlys fail the setpathinfo with a dos error of INVALID_LEVEL. Doing a Trans2SetFileInfo with either end-of-file info level succeeds as expected. commit 5a934fd8da61196d829a601a85b9871b226239d4 Author: Tim Prouty <tpro...@samba.org> Date: Wed Nov 25 14:26:18 2009 -0800 Revert "s4 torture: Allow onefs to be checked like samba3 and samba4" This reverts commit 98f595036e196dd61340fef0faf63ca762a25307. No longer necessary commit 66bf780e6edac110b85d2a0d08d01274fe7417bd Author: Tim Prouty <tpro...@samba.org> Date: Wed Nov 25 14:40:54 2009 -0800 s4 torture: Change RAW-SFILEINFO-END-OF-FILE to check for share modes by default Since the windows behavior appears to be a bug, only check for the windows-style share mode bug if target=<windows variant> is specified commit 2738e316746b078899dd30e07665d8e7b515581e Author: Tim Prouty <tpro...@samba.org> Date: Wed Nov 25 14:38:55 2009 -0800 s4 torture: Move target macros to a common header instead of redefining them in multiple files ----------------------------------------------------------------------- Summary of changes: source3/smbd/trans2.c | 31 ++++++++-- source4/torture/raw/lock.c | 5 -- source4/torture/raw/oplock.c | 4 +- source4/torture/raw/setfileinfo.c | 129 ++++++++++++++++++++++++++++++------- source4/torture/smb2/create.c | 2 - source4/torture/smbtorture.c | 1 - source4/torture/util.h | 8 ++ 7 files changed, 142 insertions(+), 38 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 2892e26..5f50b64 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -5538,7 +5538,8 @@ static NTSTATUS smb_set_file_size(connection_struct *conn, files_struct *fsp, const struct smb_filename *smb_fname, const SMB_STRUCT_STAT *psbuf, - SMB_OFF_T size) + SMB_OFF_T size, + bool fail_after_createfile) { NTSTATUS status = NT_STATUS_OK; struct smb_filename *smb_fname_tmp = NULL; @@ -5598,6 +5599,12 @@ static NTSTATUS smb_set_file_size(connection_struct *conn, return status; } + /* See RAW-SFILEINFO-END-OF-FILE */ + if (fail_after_createfile) { + close_file(req, new_fsp,NORMAL_CLOSE); + return NT_STATUS_INVALID_LEVEL; + } + if (vfs_set_filelen(new_fsp, size) == -1) { status = map_nt_error_from_unix(errno); close_file(req, new_fsp,NORMAL_CLOSE); @@ -6474,7 +6481,8 @@ static NTSTATUS smb_set_file_end_of_file_info(connection_struct *conn, const char *pdata, int total_data, files_struct *fsp, - const struct smb_filename *smb_fname) + const struct smb_filename *smb_fname, + bool fail_after_createfile) { SMB_OFF_T size; @@ -6499,7 +6507,8 @@ static NTSTATUS smb_set_file_end_of_file_info(connection_struct *conn, fsp, smb_fname, &smb_fname->st, - size); + size, + fail_after_createfile); } /**************************************************************************** @@ -6785,7 +6794,8 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn, fsp, smb_fname, &sbuf, - size); + size, + false); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -7381,11 +7391,22 @@ NTSTATUS smbd_do_setfilepathinfo(connection_struct *conn, case SMB_FILE_END_OF_FILE_INFORMATION: case SMB_SET_FILE_END_OF_FILE_INFO: { + /* + * XP/Win7 both fail after the createfile with + * SMB_SET_FILE_END_OF_FILE_INFO but not + * SMB_FILE_END_OF_FILE_INFORMATION (pass-through). + * The level is known here, so pass it down + * appropriately. + */ + bool should_fail = + (info_level == SMB_SET_FILE_END_OF_FILE_INFO); + status = smb_set_file_end_of_file_info(conn, req, pdata, total_data, fsp, - smb_fname); + smb_fname, + should_fail); break; } diff --git a/source4/torture/raw/lock.c b/source4/torture/raw/lock.c index 1ccba61..610cac9 100644 --- a/source4/torture/raw/lock.c +++ b/source4/torture/raw/lock.c @@ -69,11 +69,6 @@ }} while (0) #define BASEDIR "\\testlock" -#define TARGET_IS_W2K8(_tctx) (torture_setting_bool(_tctx, "w2k8", false)) -#define TARGET_IS_WIN7(_tctx) (torture_setting_bool(_tctx, "win7", false)) -#define TARGET_IS_SAMBA3(_tctx) (torture_setting_bool(_tctx, "samba3", false)) -#define TARGET_IS_SAMBA4(_tctx) (torture_setting_bool(_tctx, "samba4", false)) - /* test SMBlock and SMBunlock ops */ diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 0ebbb38..283fed2 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -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_INFO; + sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; sfi.generic.in.file.path = fname; sfi.end_of_file_info.in.size = 100; @@ -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_INFO; + sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; sfi.generic.in.file.path = fname; sfi.end_of_file_info.in.size = 100; diff --git a/source4/torture/raw/setfileinfo.c b/source4/torture/raw/setfileinfo.c index 0aa1f38..42f4f32 100644 --- a/source4/torture/raw/setfileinfo.c +++ b/source4/torture/raw/setfileinfo.c @@ -700,9 +700,14 @@ static bool torture_raw_sfileinfo_bug(struct torture_context *torture, return true; } +/** + * Test both the snia cifs RAW_SFILEINFO_END_OF_FILE_INFO and the undocumented + * pass-through RAW_SFILEINFO_END_OF_FILE_INFORMATION in the context of + * trans2setpathinfo. + */ static bool -torture_raw_sfileinfo_eof(struct torture_context *tctx, struct smbcli_state *cli1, - struct smbcli_state *cli2) +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; @@ -772,43 +777,121 @@ torture_raw_sfileinfo_eof(struct torture_context *tctx, struct smbcli_state *cli * 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)) { + if (TARGET_IS_W2K8(tctx) || TARGET_IS_WIN7(tctx)) { + /* 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."); + } else { torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_SHARING_VIOLATION, ret, done, "Status should be " "SHARING_VIOLATION"); - goto done; + } + + /* close the first file. */ + smbcli_close(cli1->tree, fnum); + fnum = 0; + + /* Try to sfileinfo to extend the file again (non-pass-through). */ + 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 = 200; + status = smb_raw_setpathinfo(cli2->tree, &sfi); + + /* This should cause the client to retun invalid level. */ + if (TARGET_IS_W2K8(tctx) || TARGET_IS_WIN7(tctx)) { + /* + * Windows sends back an invalid packet that smbclient sees + * and returns INTERNAL_ERROR. + */ + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_INTERNAL_ERROR, ret, done, "Status should be " + "INTERNAL_ERROR"); } else { - /* It succeeds! This is just weird! */ - torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, - done, "Status should be OK"); + torture_assert_ntstatus_equal_goto(tctx, status, + NT_STATUS_INVALID_LEVEL, ret, done, "Status should be " + "INVALID_LEVEL"); } - /* Verify that the file was actually extended to 100. */ + /* Try to extend the file now with the passthrough level. */ + sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; + status = smb_raw_setpathinfo(cli2->tree, &sfi); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); + + /* Verify that the file was actually extended to 200. */ 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, 200, + "alloc_size should be 200 since the setpathinfo succeeded."); - torture_assert_u64_equal(tctx, qfi.standard_info.out.size, 100, - "alloc_size should be 100 since the setpathinfo succeeded."); + /* Open the file so end of file can be set by handle. */ + io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_WRITE; + 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 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"); + /* Try sfileinfo to extend the file by handle (non-pass-through). */ + 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 = 300; + status = smb_raw_setfileinfo(cli1->tree, &sfi); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); - smbcli_close(cli1->tree, fnum); + /* Verify that the file was actually extended to 300. */ + ZERO_STRUCT(qfi); + qfi.generic.level = RAW_FILEINFO_STANDARD_INFO; + qfi.generic.in.file.path = fname; + status = smb_raw_pathinfo(cli1->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, 300, + "alloc_size should be 300 since the setpathinfo succeeded."); + + /* Try sfileinfo to extend the file by handle (pass-through). */ + ZERO_STRUCT(sfi); + sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; + sfi.generic.in.file.fnum = fnum; + sfi.end_of_file_info.in.size = 400; + status = smb_raw_setfileinfo(cli1->tree, &sfi); + torture_assert_ntstatus_equal_goto(tctx, status, NT_STATUS_OK, ret, + done, "Status should be OK"); + + /* Verify that the file was actually extended to 300. */ + ZERO_STRUCT(qfi); + qfi.generic.level = RAW_FILEINFO_STANDARD_INFO; + qfi.generic.in.file.path = fname; + status = smb_raw_pathinfo(cli1->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, 400, + "alloc_size should be 400 since the setpathinfo succeeded."); + done: + if (fnum > 0) { + smbcli_close(cli1->tree, fnum); + fnum = 0; + } -done: smb_raw_exit(cli1->session); smb_raw_exit(cli2->session); smbcli_deltree(cli1->tree, BASEDIR); diff --git a/source4/torture/smb2/create.c b/source4/torture/smb2/create.c index f93567f..b006047 100644 --- a/source4/torture/smb2/create.c +++ b/source4/torture/smb2/create.c @@ -126,8 +126,6 @@ __location__, sattrib, fname); \ }} while (0) -#define TARGET_IS_WIN7(_tctx) (torture_setting_bool(_tctx, "win7", false)) - /* test some interesting combinations found by gentest */ diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index 51d82ae..b9ed521 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -535,7 +535,6 @@ 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) { diff --git a/source4/torture/util.h b/source4/torture/util.h index 501d14d..3566241 100644 --- a/source4/torture/util.h +++ b/source4/torture/util.h @@ -26,6 +26,14 @@ struct smbcli_state; struct smbcli_tree; /** + * Useful target macros for handling server bugs in torture tests. + */ +#define TARGET_IS_W2K8(_tctx) (torture_setting_bool(_tctx, "w2k8", false)) +#define TARGET_IS_WIN7(_tctx) (torture_setting_bool(_tctx, "win7", false)) +#define TARGET_IS_SAMBA3(_tctx) (torture_setting_bool(_tctx, "samba3", false)) +#define TARGET_IS_SAMBA4(_tctx) (torture_setting_bool(_tctx, "samba4", false)) + +/** setup a directory ready for a test */ _PUBLIC_ bool torture_setup_dir(struct smbcli_state *cli, const char *dname); -- Samba Shared Repository