Open AcidZealot opened 2 weeks ago
Tagging subscribers to this area: @dotnet/area-system-io See info in area-owners.md if you want to be subscribed.
2. Open file with other methods (interop?) and pass SafeFileHandle with WRITE_DACL rights to FileStream constructor.
FileSystemAclExtensions also has public static FileStream Create(FileInfo, FileMode, FileSystemRights, FileShare, int, FileOptions, FileSecurity?), to which you can pass FileSystemRights.ChangePermissions.
(A bit surprising that FileStreamOptions supports UnixCreateMode but not Windows ACLs.)
Description
Under Windows FileStream.SetAccessControl() always fails with ACCESS_DENIED due to missing WRITE_DACL rights for the file handle. There are no such flags in FileAccess enum - so, runtime can't pass WRITE_DACL to CreateFile().
Reproduction Steps
Expected behavior
File security is updated: added rights for all users
Actual behavior
Regression?
No response
Known Workarounds
1) use FileSystemAclExtensions.SetAccessControl() method 2) Open file with other methods (interop?) and pass SafeFileHandle with WRITE_DACL rights to FileStream constructor.
Configuration
.net 8.0
Other information
No response