diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 83c9d9743ae..d874514bf22 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; }