From 98c7228aad2c038eb9d544194562efde1b3025a6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 20 Oct 2016 13:33:09 -0700 Subject: [PATCH 1/3] s3: torture: vfstest. unlink cmd must be stream aware. Otherwise the following patch breaks vfstest stream-depot test. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12384 Signed-off-by: Jeremy Allison Reviewed-by: Uri Simchoni (cherry picked from commit 4e93ea2340b7589769d55085aaa71070a2d7e416) --- source3/torture/cmd_vfs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 12610cf..b57a061 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -442,6 +442,14 @@ static NTSTATUS cmd_pathfunc(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg ret = SMB_VFS_RMDIR(vfs->conn, smb_fname); TALLOC_FREE(smb_fname); } else if (strcmp("unlink", argv[0]) == 0 ) { + TALLOC_FREE(smb_fname); + /* unlink can be a stream:name */ + smb_fname = synthetic_smb_fname_split(talloc_tos(), + argv[1], + lp_posix_pathnames()); + if (smb_fname == NULL) { + return NT_STATUS_NO_MEMORY; + } ret = SMB_VFS_UNLINK(vfs->conn, smb_fname); TALLOC_FREE(smb_fname); } else if (strcmp("chdir", argv[0]) == 0 ) { -- 2.8.0.rc3.226.g39d4020 From 83caab95b5e90837b5d6bba1301751a6a7d5ac00 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 19 Oct 2016 11:56:49 -0700 Subject: [PATCH 2/3] s3: vfs: Remove files/directories after the streams are deleted. By the time we get to SMB_VFS_UNLINK/SMB_VFS_RMDIR the ACL checks have already been done. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12384 Signed-off-by: Jeremy Allison Reviewed-by: Uri Simchoni (cherry picked from commit b17c9fdc51c10313eed32d6e078ed7050a342d0f) --- source3/modules/vfs_streams_depot.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 83c9d97..d874514 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -725,8 +725,12 @@ static int streams_depot_unlink(vfs_handle_struct *handle, return -1; } - ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname); - if (ret == 0) { + /* + * We know the unlink should succeed as the ACL + * check is already done in the caller. Remove the + * file *after* the streams. + */ + { char *dirname = stream_dir(handle, smb_fname_base, &smb_fname_base->st, false); @@ -749,6 +753,7 @@ static int streams_depot_unlink(vfs_handle_struct *handle, TALLOC_FREE(dirname); } + ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname); TALLOC_FREE(smb_fname_base); return ret; } @@ -787,8 +792,12 @@ static int streams_depot_rmdir(vfs_handle_struct *handle, return -1; } - ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base); - if (ret == 0) { + /* + * We know the rmdir should succeed as the ACL + * check is already done in the caller. Remove the + * directory *after* the streams. + */ + { char *dirname = stream_dir(handle, smb_fname_base, &smb_fname_base->st, false); @@ -811,6 +820,7 @@ static int streams_depot_rmdir(vfs_handle_struct *handle, TALLOC_FREE(dirname); } + ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname_base); TALLOC_FREE(smb_fname_base); return ret; } -- 2.8.0.rc3.226.g39d4020 From 0a1eecfea7e31cd3c1127d038ddc553da572f622 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 19 Oct 2016 16:33:52 -0700 Subject: [PATCH 3/3] s3: selftest: Add test for orphan 'lost-XXX' directories in streams_depot. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12384 Signed-off-by: Jeremy Allison Reviewed-by: Uri Simchoni Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Fri Oct 21 04:48:52 CEST 2016 on sn-devel-144 (cherry picked from commit ad60b8cc48b1095ce97170eed3d09fca7181a3bc) --- source3/script/tests/test_smbclient_s3.sh | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index 5e3db5d..22849bd 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -1060,6 +1060,43 @@ EOF fi } +# Test creating then deleting a stream file doesn't leave a lost-XXXXX directory. +test_streams_depot_delete() +{ + tmpfile=$PREFIX/smbclient_interactive_prompt_commands + rm -rf "$LOCAL_PATH/lost-*" + + cat > $tmpfile <