Open socram8888 opened 2 months ago
If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
Attached logs: WslLogs-2024-09-18_13-47-58.zip
For the record, this current behaviour breaks Git, which uses this file mode for the database, as evidenced by multiple issues reported elsewhere:
The log file doesn't contain any WSL traces. Please make sure that you reproduced the issue while the log collection was running.
Again, restarting the LxssManager service beforehand just in case: WslLogs-2024-09-18_13-59-31.zip
Seems the cause is WSL1 settings the Read-only bit while opening. If the file is first open
ed with write permissions (eg 0600) and then chmod
to 0444, it works.
We got informed about this on the Git list. This is a common error in a variety of file systems, including some NFS servers. POSIX says this:
The argument following the oflag argument does not affect whether the file is open for reading, writing, or for both.
That is, POSIX forbids failing to open a file for writing because the permissions are 0444, and as such this is not POSIX compliant. Linux also does not have this bug, and follows the standard in this regard, so this is definitely a WSL bug.
Windows Version
Microsoft Windows [Versión 10.0.19044.4894]
WSL Version
0.0.0.0
Are you using WSL 1 or WSL 2?
Kernel Version
Linux version 4.4.0-19041-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #4355-Microsoft Thu Apr 12 17:37:00 PST 2024
Distro Version
Debian Bookworm
Other Software
No response
Repro Steps
Mount any network drive like so:
Create a test executable that will write create and write to a file with 0444 permissions:
Expected Behavior
The file should be created and the handle is returned. This works in real Linux, and also when outside a SMB share.
Actual Behavior
The file gets actually created, but returns a -1 EACCESS. Furthermore, the file can not be deleted using "rm" (not even as root) unless the permissions are changed via a chmod. Despite metadata not being enabled, permissions are somehow still applied:
create-strace.log rm-strace.log
Diagnostic Logs
No response