From: Joel Holdsworth joel@airwebreathe.org.uk
Co-authored-by: Bernhard Übelacker bernhardu@mailbox.org Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56925 --- dlls/ntdll/tests/file.c | 2 +- server/fd.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c index 62ea9447d43..7b48f7b694d 100644 --- a/dlls/ntdll/tests/file.c +++ b/dlls/ntdll/tests/file.c @@ -5889,7 +5889,7 @@ static void test_file_readonly_access(void)
/* NtOpenFile FILE_{READ,WRITE}_ATTRIBUTES */ status = pNtOpenFile(&handle, FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, &attr, &io, default_sharing, FILE_NON_DIRECTORY_FILE); - todo_wine ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx.\n", status); + ok(status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#lx.\n", status); CloseHandle(handle);
/* NtOpenFile DELETE without FILE_DELETE_ON_CLOSE */ diff --git a/server/fd.c b/server/fd.c index bb0e90d99d0..6813cd02ab1 100644 --- a/server/fd.c +++ b/server/fd.c @@ -1944,11 +1944,11 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
if ((fd->unix_fd = open( name, rw_mode | (flags & ~O_TRUNC), *mode )) == -1) { - /* if we tried to open a directory for write access, retry read-only */ - if (errno == EISDIR) + /* if we tried to open a read-only file or a directory for write access, retry read-only */ + if (((errno == EACCES) && ((access & FILE_READ_ATTRIBUTES) && !(options & FILE_DIRECTORY_FILE))) || + ((errno == EISDIR) && ((access & FILE_UNIX_WRITE_ACCESS) || (flags & O_CREAT)))) { - if ((access & FILE_UNIX_WRITE_ACCESS) || (flags & O_CREAT)) - fd->unix_fd = open( name, O_RDONLY | (flags & ~(O_TRUNC | O_CREAT | O_EXCL)), *mode ); + fd->unix_fd = open( name, O_RDONLY | (flags & ~(O_TRUNC | O_CREAT | O_EXCL)), *mode ); }
if (fd->unix_fd == -1)