mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-01-28 22:04:43 -08:00
Added patch to fix handling of opening read-only files for FILE_DELETE_ON_CLOSE.
This commit is contained in:
parent
178d669519
commit
4befe663b8
@ -39,11 +39,12 @@ Wine. All those differences are also documented on the
|
||||
Included bug fixes and improvements
|
||||
-----------------------------------
|
||||
|
||||
**Bug fixes and features included in the next upcoming release [7]:**
|
||||
**Bug fixes and features included in the next upcoming release [8]:**
|
||||
|
||||
* Add support for process specific debug channels
|
||||
* Add support for wbemprox Win32_SystemEnclosure table
|
||||
* Calculate msvcrt exponential math operations with higher precision ([Wine Bug #37149](https://bugs.winehq.org/show_bug.cgi?id=37149))
|
||||
* Fix handling of opening read-only files for FILE_DELETE_ON_CLOSE ([Wine Bug #38417](https://bugs.winehq.org/show_bug.cgi?id=38417))
|
||||
* Fix regression caused by blacklisting supported OpenGL extensions ([Wine Bug #38264](https://bugs.winehq.org/show_bug.cgi?id=38264))
|
||||
* Properly handle closing sockets during a select call ([Wine Bug #38399](https://bugs.winehq.org/show_bug.cgi?id=38399))
|
||||
* Recognize localhost as local machine in wbemprox
|
||||
|
1
debian/changelog
vendored
1
debian/changelog
vendored
@ -12,6 +12,7 @@ wine-staging (1.7.41) UNRELEASED; urgency=low
|
||||
* Added patch for support of process specific debug channels.
|
||||
* Added patch to recognize localhost as local machine in wbemprox.
|
||||
* Added patch to implement support for wbemprox Win32_SystemEnclosure table.
|
||||
* Added patch to fix handling of opening read-only files for FILE_DELETE_ON_CLOSE.
|
||||
* Added tests for RtlIpv6AddressToString and RtlIpv6AddressToStringEx.
|
||||
* Removed patches to fix invalid memory access in get_registry_locale_info (accepted upstream).
|
||||
* Removed patches to avoid repeated FIXMEs in PsLookupProcessByProcessId stub (accepted upstream).
|
||||
|
@ -177,6 +177,7 @@ patch_enable_all ()
|
||||
enable_server_Address_List_Change="$1"
|
||||
enable_server_ClipCursor="$1"
|
||||
enable_server_CreateProcess_ACLs="$1"
|
||||
enable_server_Delete_On_Close="$1"
|
||||
enable_server_File_Permissions="$1"
|
||||
enable_server_Inherited_ACLs="$1"
|
||||
enable_server_JobObjects="$1"
|
||||
@ -602,6 +603,9 @@ patch_enable ()
|
||||
server-CreateProcess_ACLs)
|
||||
enable_server_CreateProcess_ACLs="$2"
|
||||
;;
|
||||
server-Delete_On_Close)
|
||||
enable_server_Delete_On_Close="$2"
|
||||
;;
|
||||
server-File_Permissions)
|
||||
enable_server_File_Permissions="$2"
|
||||
;;
|
||||
@ -3902,6 +3906,23 @@ if test "$enable_server_CreateProcess_ACLs" -eq 1; then
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset server-Delete_On_Close
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
# | * [#38417] Fix handling of opening read-only files for FILE_DELETE_ON_CLOSE
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/kernel32/file.c, dlls/kernel32/tests/file.c, server/fd.c
|
||||
# |
|
||||
if test "$enable_server_Delete_On_Close" -eq 1; then
|
||||
patch_apply server-Delete_On_Close/0001-kernel32-tests-Add-tests-for-deleting-readonly-files.patch
|
||||
patch_apply server-Delete_On_Close/0002-server-Fix-handling-of-opening-read-only-files-with-.patch
|
||||
(
|
||||
echo '+ { "Sebastian Lackner", "kernel32/tests: Add tests for deleting readonly files with NtCreateFile.", 1 },';
|
||||
echo '+ { "Sebastian Lackner", "server: Fix handling of opening read-only files with FILE_DELETE_ON_CLOSE.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset server-Misc_ACL
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
|
@ -0,0 +1,146 @@
|
||||
From a3dc138dc397db75243c20acae021106731e2b07 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Fri, 17 Apr 2015 11:22:51 +0200
|
||||
Subject: kernel32/tests: Add tests for deleting readonly files with
|
||||
NtCreateFile.
|
||||
|
||||
---
|
||||
dlls/kernel32/tests/file.c | 74 +++++++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 73 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
|
||||
index 99fffab..3a82364 100644
|
||||
--- a/dlls/kernel32/tests/file.c
|
||||
+++ b/dlls/kernel32/tests/file.c
|
||||
@@ -28,10 +28,13 @@
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
+#include "ntstatus.h"
|
||||
+#define WIN32_NO_STATUS
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
+#include "winternl.h"
|
||||
#include "winnls.h"
|
||||
#include "fileapi.h"
|
||||
|
||||
@@ -48,6 +51,10 @@ static HRESULT (WINAPI *pCopyFile2)(PCWSTR,PCWSTR,COPYFILE2_EXTENDED_PARAMETERS*
|
||||
static HANDLE (WINAPI *pCreateFile2)(LPCWSTR, DWORD, DWORD, DWORD, CREATEFILE2_EXTENDED_PARAMETERS*);
|
||||
static DWORD (WINAPI *pGetFinalPathNameByHandleA)(HANDLE, LPSTR, DWORD, DWORD);
|
||||
static DWORD (WINAPI *pGetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, DWORD);
|
||||
+static NTSTATUS (WINAPI *pNtCreateFile)(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK,
|
||||
+ PLARGE_INTEGER, ULONG, ULONG, ULONG, ULONG, PVOID, ULONG);
|
||||
+static BOOL (WINAPI *pRtlDosPathNameToNtPathName_U)(LPCWSTR, PUNICODE_STRING, PWSTR*, CURDIR*);
|
||||
+static NTSTATUS (WINAPI *pRtlAnsiStringToUnicodeString)(PUNICODE_STRING, PCANSI_STRING, BOOLEAN);
|
||||
|
||||
static const char filename[] = "testfile.xxx";
|
||||
static const char sillytext[] =
|
||||
@@ -72,8 +79,13 @@ struct test_list {
|
||||
|
||||
static void InitFunctionPointers(void)
|
||||
{
|
||||
+ HMODULE hntdll = GetModuleHandleA("ntdll");
|
||||
HMODULE hkernel32 = GetModuleHandleA("kernel32");
|
||||
|
||||
+ pNtCreateFile = (void *)GetProcAddress(hntdll, "NtCreateFile");
|
||||
+ pRtlDosPathNameToNtPathName_U = (void *)GetProcAddress(hntdll, "RtlDosPathNameToNtPathName_U");
|
||||
+ pRtlAnsiStringToUnicodeString = (void *)GetProcAddress(hntdll, "RtlAnsiStringToUnicodeString");
|
||||
+
|
||||
pFindFirstFileExA=(void*)GetProcAddress(hkernel32, "FindFirstFileExA");
|
||||
pReplaceFileA=(void*)GetProcAddress(hkernel32, "ReplaceFileA");
|
||||
pReplaceFileW=(void*)GetProcAddress(hkernel32, "ReplaceFileW");
|
||||
@@ -243,15 +255,36 @@ static void test__lclose( void )
|
||||
ok( ret != 0, "DeleteFile failed (%d)\n", GetLastError( ) );
|
||||
}
|
||||
|
||||
+/* helper function for test__lcreat */
|
||||
+static void get_nt_pathW(const char *name, UNICODE_STRING *nameW)
|
||||
+{
|
||||
+ UNICODE_STRING strW;
|
||||
+ ANSI_STRING str;
|
||||
+ NTSTATUS status;
|
||||
+ BOOLEAN ret;
|
||||
+ RtlInitAnsiString(&str, name);
|
||||
+
|
||||
+ status = pRtlAnsiStringToUnicodeString(&strW, &str, TRUE);
|
||||
+ ok(!status, "RtlAnsiStringToUnicodeString failed with %08x\n", status);
|
||||
+
|
||||
+ ret = pRtlDosPathNameToNtPathName_U(strW.Buffer, nameW, NULL, NULL);
|
||||
+ ok(ret, "RtlDosPathNameToNtPathName_U failed\n");
|
||||
+
|
||||
+ RtlFreeUnicodeString(&strW);
|
||||
+}
|
||||
|
||||
static void test__lcreat( void )
|
||||
{
|
||||
+ UNICODE_STRING filenameW;
|
||||
+ OBJECT_ATTRIBUTES attr;
|
||||
+ IO_STATUS_BLOCK io;
|
||||
HFILE filehandle;
|
||||
char buffer[10000];
|
||||
WIN32_FIND_DATAA search_results;
|
||||
char slashname[] = "testfi/";
|
||||
int err;
|
||||
- HANDLE find;
|
||||
+ HANDLE find, file;
|
||||
+ NTSTATUS status;
|
||||
BOOL ret;
|
||||
|
||||
filehandle = _lcreat( filename, 0 );
|
||||
@@ -287,12 +320,51 @@ static void test__lcreat( void )
|
||||
ok( INVALID_HANDLE_VALUE != find, "should be able to find file\n" );
|
||||
FindClose( find );
|
||||
|
||||
+ SetLastError( 0xdeadbeef );
|
||||
ok( 0 == DeleteFileA( filename ), "shouldn't be able to delete a readonly file\n" );
|
||||
+ ok( GetLastError() == ERROR_ACCESS_DENIED, "expected ERROR_ACCESS_DENIED, got %d\n", GetLastError() );
|
||||
|
||||
ok( SetFileAttributesA(filename, FILE_ATTRIBUTE_NORMAL ) != 0, "couldn't change attributes on file\n" );
|
||||
|
||||
ok( DeleteFileA( filename ) != 0, "now it should be possible to delete the file!\n" );
|
||||
|
||||
+ filehandle = _lcreat( filename, 1 ); /* readonly */
|
||||
+ ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)\n", filename, GetLastError() );
|
||||
+ ok( HFILE_ERROR != _hwrite( filehandle, sillytext, strlen(sillytext) ),
|
||||
+ "_hwrite shouldn't be able to write never the less\n" );
|
||||
+ ok( HFILE_ERROR != _lclose(filehandle), "_lclose complains\n" );
|
||||
+
|
||||
+ find = FindFirstFileA( filename, &search_results );
|
||||
+ ok( INVALID_HANDLE_VALUE != find, "should be able to find file\n" );
|
||||
+ FindClose( find );
|
||||
+
|
||||
+ get_nt_pathW(filename, &filenameW);
|
||||
+ attr.Length = sizeof(attr);
|
||||
+ attr.RootDirectory = 0;
|
||||
+ attr.Attributes = OBJ_CASE_INSENSITIVE;
|
||||
+ attr.ObjectName = &filenameW;
|
||||
+ attr.SecurityDescriptor = NULL;
|
||||
+ attr.SecurityQualityOfService = NULL;
|
||||
+
|
||||
+ status = NtCreateFile( &file, GENERIC_READ | GENERIC_WRITE | 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 );
|
||||
+ ok( status == STATUS_ACCESS_DENIED, "expected STATUS_ACCESS_DENIED, got %08x\n", status );
|
||||
+ ok( GetFileAttributesA( filename ) != INVALID_FILE_ATTRIBUTES, "file was deleted\n" );
|
||||
+
|
||||
+ 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 );
|
||||
+ todo_wine
|
||||
+ ok( status == STATUS_CANNOT_DELETE, "expected STATUS_CANNOT_DELETE, got %08x\n", status );
|
||||
+ if (!status) CloseHandle( file );
|
||||
+ todo_wine
|
||||
+ ok( GetFileAttributesA( filename ) != INVALID_FILE_ATTRIBUTES, "file was deleted\n" );
|
||||
+ todo_wine
|
||||
+ ok( SetFileAttributesA(filename, FILE_ATTRIBUTE_NORMAL ) != 0, "couldn't change attributes on file\n" );
|
||||
+ todo_wine
|
||||
+ ok( DeleteFileA( filename ) != 0, "now it should be possible to delete the file!\n" );
|
||||
+
|
||||
filehandle = _lcreat( filename, 2 );
|
||||
ok( HFILE_ERROR != filehandle, "couldn't create file \"%s\" (err=%d)\n", filename, GetLastError( ) );
|
||||
|
||||
--
|
||||
2.3.5
|
||||
|
@ -0,0 +1,84 @@
|
||||
From 6f4c5f44d93d38b4b71aa56fe2ad0eb4b31fbe7f 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(-)
|
||||
|
||||
diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c
|
||||
index 006db1c..d16a0a1 100644
|
||||
--- a/dlls/kernel32/file.c
|
||||
+++ b/dlls/kernel32/file.c
|
||||
@@ -1602,8 +1602,7 @@ BOOL WINAPI DeleteFileW( LPCWSTR path )
|
||||
attr.SecurityDescriptor = NULL;
|
||||
attr.SecurityQualityOfService = NULL;
|
||||
|
||||
- status = NtCreateFile(&hFile, GENERIC_READ | GENERIC_WRITE | DELETE,
|
||||
- &attr, &io, NULL, 0,
|
||||
+ status = NtCreateFile(&hFile, 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);
|
||||
if (status == STATUS_SUCCESS) status = NtClose(hFile);
|
||||
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
|
||||
index 3a82364..0f5ac52 100644
|
||||
--- a/dlls/kernel32/tests/file.c
|
||||
+++ b/dlls/kernel32/tests/file.c
|
||||
@@ -355,14 +355,10 @@ 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 );
|
||||
- todo_wine
|
||||
ok( status == STATUS_CANNOT_DELETE, "expected STATUS_CANNOT_DELETE, got %08x\n", status );
|
||||
if (!status) CloseHandle( file );
|
||||
- todo_wine
|
||||
ok( GetFileAttributesA( filename ) != INVALID_FILE_ATTRIBUTES, "file was deleted\n" );
|
||||
- todo_wine
|
||||
ok( SetFileAttributesA(filename, FILE_ATTRIBUTE_NORMAL ) != 0, "couldn't change attributes on file\n" );
|
||||
- todo_wine
|
||||
ok( DeleteFileA( filename ) != 0, "now it should be possible to delete the file!\n" );
|
||||
|
||||
filehandle = _lcreat( filename, 2 );
|
||||
@@ -1718,14 +1714,12 @@ static void test_DeleteFileA( void )
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = DeleteFileA(temp_file);
|
||||
-todo_wine
|
||||
ok(ret, "DeleteFile error %d\n", GetLastError());
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = CloseHandle(hfile);
|
||||
ok(ret, "CloseHandle error %d\n", GetLastError());
|
||||
ret = DeleteFileA(temp_file);
|
||||
-todo_wine
|
||||
ok(!ret, "DeleteFile should fail\n");
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
diff --git a/server/fd.c b/server/fd.c
|
||||
index 9a4aac4..ca68e49 100644
|
||||
--- a/server/fd.c
|
||||
+++ b/server/fd.c
|
||||
@@ -1858,6 +1858,16 @@ struct fd *open_fd( struct fd *root, const char *name, int flags, mode_t *mode,
|
||||
fd->cacheable = !inode->device->removable;
|
||||
list_add_head( &inode->open, &fd->inode_entry );
|
||||
|
||||
+ /* 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;
|
||||
+ }
|
||||
+
|
||||
/* check directory options */
|
||||
if ((options & FILE_DIRECTORY_FILE) && !S_ISDIR(st.st_mode))
|
||||
{
|
||||
--
|
||||
2.3.5
|
||||
|
1
patches/server-Delete_On_Close/definition
Normal file
1
patches/server-Delete_On_Close/definition
Normal file
@ -0,0 +1 @@
|
||||
Fixes: [38417] Fix handling of opening read-only files for FILE_DELETE_ON_CLOSE
|
Loading…
x
Reference in New Issue
Block a user