On Wed Apr 26 14:49:02 2023 +0000, Joel Holdsworth wrote:
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?
I don't see anything in there that would require write access. The most obvious fix would be to support FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE, but opening the file read-only and faking the attributes setting could probably also be made to work.