On Wed Apr 26 13:40:24 2023 +0000, Alexandre Julliard wrote:
Fair enough. So do you believe we should remove the usage of POSIX
file-access flags to represent `FILE_ATTRIBUTE_READONLY` entirely? Not without seeing more evidence that this is necessary. It's not clear from the original report that opening for write is actually required to fix the bug.
I wrote a bit more information about it in my commit message here:
https://gitlab.winehq.org/wine/wine/-/merge_requests/1895/diffs?commit_id=ce...
The Msys2 port of the pacman package manager creates a read-only lock file during package
installation. When it is time to delete this file, pacman calls the Msys2 implementation of unlink(2). This function is implemented in msys2-runtime:
https://github.com/msys2/msys2-runtime/blob/msys2-3.4.3/winsup/cygwin/syscal...
A similar implementation exists in Cygwin:
https://www.cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/sysca...
The implementation works by first opening the file using NtOpenFile with FILE_WRITE_ATTRIBUTES
permissions only, it then clears the FILE_ATTRIBUTE_READONLY flag using NtSetAttributesFile, then repoens the file with DELETE permissions.
Wine uses POSIX file permissions as one its possible methods of storing the READONLY DOS attribute
in addition to storing attributes in Samba-formatted user extentded attributes.
Files that are opened with FILE_WRITE_ATTRIBUTES must be opened with O_WRONLY or O_RDWR, because
write access is required to modify the extended attribute. However, this will fail if the POSIX file permissions are set to read-only.
What do you think?