From 7a6fc7cdbf07db49b3ba72bf4a0d1e41ebb76759 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 7 Aug 2018 15:11:22 +0200 Subject: [PATCH 1/2] torture: Make sure that fruit_ftruncate only unlinks streams Follow-up to Bug: https://bugzilla.samba.org/show_bug.cgi?id=13441 Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme (cherry picked from commit c39ec64231b261fe4ada02f1f1b9aa344cf35bb5) --- selftest/knownfail.d/samba3.vfs.fruit | 1 + source4/torture/vfs/fruit.c | 45 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/selftest/knownfail.d/samba3.vfs.fruit b/selftest/knownfail.d/samba3.vfs.fruit index 8df25bccb79..d858452eb52 100644 --- a/selftest/knownfail.d/samba3.vfs.fruit +++ b/selftest/knownfail.d/samba3.vfs.fruit @@ -1 +1,2 @@ ^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion\(nt4_dc\) +^samba3.vfs.fruit .*.setinfo eof stream\(nt4_dc\) diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c index fc1760e02e0..a9ae891a23f 100644 --- a/source4/torture/vfs/fruit.c +++ b/source4/torture/vfs/fruit.c @@ -4773,6 +4773,51 @@ static bool test_setinfo_stream_eof(struct torture_context *tctx, tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, ret, done, "Unexpected status\n"); + torture_comment( + tctx, "Setting main file EOF to 1 to force 0-truncate\n"); + + status = torture_smb2_testfile_access( + tree, + fname, + &h1, + SEC_FILE_WRITE_DATA); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "torture_smb2_testfile failed\n"); + + ZERO_STRUCT(sfinfo); + sfinfo.generic.in.file.handle = h1; + sfinfo.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION; + sfinfo.position_information.in.position = 1; + status = smb2_setinfo_file(tree, &sfinfo); + torture_assert_ntstatus_ok_goto( + tctx, + status, + ret, + done, + "set eof 1 failed\n"); + + sfinfo.position_information.in.position = 0; + status = smb2_setinfo_file(tree, &sfinfo); + torture_assert_ntstatus_ok_goto( + tctx, + status, + ret, + done, + "set eof 0 failed\n"); + + smb2_util_close(tree, h1); + + ZERO_STRUCT(create); + create.in.desired_access = SEC_FILE_READ_ATTRIBUTE; + create.in.share_access = NTCREATEX_SHARE_ACCESS_MASK; + create.in.file_attributes = FILE_ATTRIBUTE_NORMAL; + create.in.create_disposition = NTCREATEX_DISP_OPEN; + create.in.fname = fname; + + status = smb2_create(tree, tctx, &create); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "torture_smb2_testfile failed\n"); + smb2_util_close(tree, h1); done: smb2_util_unlink(tree, fname); smb2_util_rmdir(tree, BASEDIR); -- 2.13.6 From 0d36f7b37fe5cfbba5af974f37134b19450dcd88 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 7 Aug 2018 15:10:31 +0200 Subject: [PATCH 2/2] vfs_fruit: Don't unlink the main file The original fix for bug 13441 was missing a check that verifies that fruit_ftruncate() is actually called on a stream. Follow-up to Bug: https://bugzilla.samba.org/show_bug.cgi?id=13441 Pair-Programmed-With: Volker Lendecke Signed-off-by: Ralph Boehme Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Thu Aug 23 15:28:48 CEST 2018 on sn-devel-144 (cherry picked from commit 8c14234871820eacde46670d722a676fb5f3a46c) --- selftest/knownfail.d/samba3.vfs.fruit | 1 - source3/modules/vfs_fruit.c | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/selftest/knownfail.d/samba3.vfs.fruit b/selftest/knownfail.d/samba3.vfs.fruit index d858452eb52..8df25bccb79 100644 --- a/selftest/knownfail.d/samba3.vfs.fruit +++ b/selftest/knownfail.d/samba3.vfs.fruit @@ -1,2 +1 @@ ^samba3.vfs.fruit streams_depot.OS X AppleDouble file conversion\(nt4_dc\) -^samba3.vfs.fruit .*.setinfo eof stream\(nt4_dc\) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index ebf0f9842f0..1102059bbee 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -5570,7 +5570,11 @@ static int fruit_ftruncate(struct vfs_handle_struct *handle, (intmax_t)offset); if (fio == NULL) { - if (offset == 0 && global_fruit_config.nego_aapl) { + if (offset == 0 && + global_fruit_config.nego_aapl && + is_ntfs_stream_smb_fname(fsp->fsp_name) && + !is_ntfs_default_stream_smb_fname(fsp->fsp_name)) + { return SMB_VFS_NEXT_UNLINK(handle, fsp->fsp_name); } return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset); -- 2.13.6