Added patch to fix failure to create anonymous file mapping after failed open_fd server call (fixes Wine Staging Bug #538).

This commit is contained in:
Sebastian Lackner 2015-08-30 05:05:58 +02:00
parent 4e0bdd2c9b
commit 38db7901d7
7 changed files with 112 additions and 17 deletions

View File

@ -39,9 +39,10 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
-----------------------------------
**Bug fixes and features included in the next upcoming release [3]:**
**Bug fixes and features included in the next upcoming release [4]:**
* Fix access violation in MSYS2 git when cloning repository
* Fix failure to create anonymous file mapping after failed open_fd server call
* Map EXDEV error code to STATUS_NOT_SAME_DEVICE
* Return a dummy BIOS name in Win32_BIOS record

2
debian/changelog vendored
View File

@ -7,6 +7,8 @@ wine-staging (1.7.51) UNRELEASED; urgency=low
Staging Bug #528).
* Added patch to fix compile failure in d3d11 with recent versions of gcc.
* Added patch to map EXDEV error code to STATUS_NOT_SAME_DEVICE.
* Added patch to fix failure to create anonymous file mapping after failed
open_fd server call (fixes Wine Staging Bug #538).
* Removed patch to fix bug in wineserver debug_children inheritance (accepted
upstream).
* Removed patch to use helper function for NtWaitForMultipleObjects and

View File

@ -232,6 +232,7 @@ patch_enable_all ()
enable_server_Shared_Memory="$1"
enable_server_Stored_ACLs="$1"
enable_server_Timestamp_Compat="$1"
enable_server_Working_Directory="$1"
enable_setupapi_SetupDiSelectBestCompatDrv="$1"
enable_setupapi_SetupDiSetDeviceInstallParamsW="$1"
enable_setupapi_SetupPromptForDisk="$1"
@ -775,6 +776,9 @@ patch_enable ()
server-Timestamp_Compat)
enable_server_Timestamp_Compat="$2"
;;
server-Working_Directory)
enable_server_Working_Directory="$2"
;;
setupapi-SetupDiSelectBestCompatDrv)
enable_setupapi_SetupDiSelectBestCompatDrv="$2"
;;
@ -1765,6 +1769,13 @@ if test "$enable_server_Stored_ACLs" -eq 1; then
enable_server_File_Permissions=1
fi
if test "$enable_server_Delete_On_Close" -eq 1; then
if test "$enable_server_Working_Directory" -gt 1; then
abort "Patchset server-Working_Directory disabled, but server-Delete_On_Close depends on that."
fi
enable_server_Working_Directory=1
fi
if test "$enable_nvencodeapi_Video_Encoder" -eq 1; then
if test "$enable_nvcuvid_CUDA_Video_Support" -gt 1; then
abort "Patchset nvcuvid-CUDA_Video_Support disabled, but nvencodeapi-Video_Encoder depends on that."
@ -4405,8 +4416,23 @@ if test "$enable_server_ClipCursor" -eq 1; then
) >> "$patchlist"
fi
# Patchset server-Working_Directory
# |
# | Modified files:
# | * server/fd.c
# |
if test "$enable_server_Working_Directory" -eq 1; then
patch_apply server-Working_Directory/0001-server-Switch-back-to-server-dir-when-open_fd-fails.patch
(
echo '+ { "Sebastian Lackner", "server: Switch back to server dir when open_fd fails.", 1 },';
) >> "$patchlist"
fi
# Patchset server-Delete_On_Close
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * server-Working_Directory
# |
# | This patchset fixes the following Wine bugs:
# | * [#38417] Fix handling of opening read-only files for FILE_DELETE_ON_CLOSE
# |

View File

@ -1,20 +1,20 @@
From d6491287dccc2e5cc97c160bce8c39555e478044 Mon Sep 17 00:00:00 2001
From 70bb2cad6678981c4690dcbb618d4cfaf4ec097d Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Fri, 17 Apr 2015 12:40:38 +0200
Subject: server: Fix handling of opening read-only files with
FILE_DELETE_ON_CLOSE.
---
dlls/kernel32/file.c | 3 +--
dlls/kernel32/tests/file.c | 6 ------
server/fd.c | 10 ++++++++++
3 files changed, 11 insertions(+), 8 deletions(-)
dlls/kernel32/file.c | 3 +--
dlls/kernel32/tests/file.c | 6 ------
server/fd.c | 9 +++++++++
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c
index 006db1c..d16a0a1 100644
index e43829e..d4111b9 100644
--- a/dlls/kernel32/file.c
+++ b/dlls/kernel32/file.c
@@ -1602,8 +1602,7 @@ BOOL WINAPI DeleteFileW( LPCWSTR path )
@@ -1664,8 +1664,7 @@ BOOL WINAPI DeleteFileW( LPCWSTR path )
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
@ -25,10 +25,10 @@ index 006db1c..d16a0a1 100644
FILE_OPEN, FILE_DELETE_ON_CLOSE | FILE_NON_DIRECTORY_FILE, NULL, 0);
if (status == STATUS_SUCCESS) status = NtClose(hFile);
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
index 9a6e972..d54b45d 100644
index dd64c91..3a950f1 100644
--- a/dlls/kernel32/tests/file.c
+++ b/dlls/kernel32/tests/file.c
@@ -355,17 +355,13 @@ static void test__lcreat( void )
@@ -361,17 +361,13 @@ static void test__lcreat( void )
status = NtCreateFile( &file, DELETE, &attr, &io, NULL, 0,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_OPEN, FILE_DELETE_ON_CLOSE | FILE_NON_DIRECTORY_FILE, NULL, 0 );
@ -46,7 +46,7 @@ index 9a6e972..d54b45d 100644
ok( DeleteFileA( filename ) != 0, "now it should be possible to delete the file\n" );
filehandle = _lcreat( filename, 2 );
@@ -1721,14 +1717,12 @@ static void test_DeleteFileA( void )
@@ -1784,14 +1780,12 @@ static void test_DeleteFileA( void )
SetLastError(0xdeadbeef);
ret = DeleteFileA(temp_file);
@ -62,26 +62,25 @@ index 9a6e972..d54b45d 100644
SetLastError(0xdeadbeef);
diff --git a/server/fd.c b/server/fd.c
index e3b722c..eeb3055 100644
index 6c78a0a..8d6067e 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1832,6 +1832,16 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
fd->cacheable = !inode->device->removable;
@@ -1837,6 +1837,15 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
list_add_head( &inode->open, &fd->inode_entry );
closed_fd = NULL;
+ /* can't unlink files we don't have permission to access */
+ if ((options & FILE_DELETE_ON_CLOSE) && S_ISREG(st.st_mode) &&
+ !(flags & O_CREAT) && !(st.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
+ {
+ /* FIXME: instead of checking for O_CREAT it should check if the file was created */
+ release_object( fd );
+ set_error( STATUS_CANNOT_DELETE );
+ return NULL;
+ goto error;
+ }
+
/* check directory options */
if ((options & FILE_DIRECTORY_FILE) && !S_ISDIR(st.st_mode))
{
--
2.3.5
2.5.0

View File

@ -1,2 +1,3 @@
Fixes: [38417] Fix handling of opening read-only files for FILE_DELETE_ON_CLOSE
Depends: server-Working_Directory
Category: stable

View File

@ -0,0 +1,65 @@
From 24571673d4012771550758af22526c334a7fbd9b Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 30 Aug 2015 04:57:38 +0200
Subject: server: Switch back to server dir when open_fd fails.
---
server/fd.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/server/fd.c b/server/fd.c
index fef4827..6c78a0a 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -1835,34 +1835,31 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
fd->closed = closed_fd;
fd->cacheable = !inode->device->removable;
list_add_head( &inode->open, &fd->inode_entry );
+ closed_fd = NULL;
/* check directory options */
if ((options & FILE_DIRECTORY_FILE) && !S_ISDIR(st.st_mode))
{
- release_object( fd );
set_error( STATUS_NOT_A_DIRECTORY );
- return NULL;
+ goto error;
}
if ((options & FILE_NON_DIRECTORY_FILE) && S_ISDIR(st.st_mode))
{
- release_object( fd );
set_error( STATUS_FILE_IS_A_DIRECTORY );
- return NULL;
+ goto error;
}
if ((err = check_sharing( fd, access, sharing, flags, options )))
{
- release_object( fd );
set_error( err );
- return NULL;
+ goto error;
}
- closed_fd->unlink = (options & FILE_DELETE_ON_CLOSE) != 0;
+ fd->closed->unlink = (options & FILE_DELETE_ON_CLOSE) != 0;
if (flags & O_TRUNC)
{
if (S_ISDIR(st.st_mode))
{
- release_object( fd );
set_error( STATUS_OBJECT_NAME_COLLISION );
- return NULL;
+ goto error;
}
ftruncate( fd->unix_fd, 0 );
}
@@ -1877,6 +1874,7 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
free( closed_fd );
fd->cacheable = 1;
}
+ if (root_fd != -1) fchdir( server_dir_fd ); /* go back to the server dir */
return fd;
error:
--
2.5.0

View File

@ -0,0 +1 @@
Fixes: Fix failure to create anonymous file mapping after failed open_fd server call