You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
write_file overwrite resets the file's ACL on Windows since #1214 #1236
Since #1214, overwriting an existing file with write_file replaces it with a new file by rename. On Windows the new file takes the folder's inherited ACL, so whatever was set on the original file is gone. A file the user had locked down ends up readable by everyone the folder allows, after Zero edits it.
Reproduction
Windows 11, NTFS. Same test on both commits: create a.txt, change its ACL with icacls, overwrite it through NewScopedWriteFileTool(root, nil).Run with overwrite: true, read the ACL back.
inheritance removed, owner only (1 explicit entry, 0 inherited)
unchanged
0 explicit, 11 inherited
The content is written correctly in every case. Only the security descriptor changes.
Cause
commitRootedFileOverwrite in internal/tools/file_commit.go stages the new bytes in a side file and publishes it with root.Rename. The side file is created fresh, so it carries the directory's inherited ACL, and the rename puts that file in the target's place. The staged file is given the target's permission bits, which on Windows is only the read-only attribute. Before #1214 the tool wrote into the existing file, which kept its descriptor.
edit_file publishes through the same function (commitRootedFileContents), so I expect the same there, but I only ran write_file.
I read the POSIX side and did not run it: the permission bits are copied, and nothing copies ownership, POSIX ACLs or extended attributes.
Direction
internal/fsutil already publishes config files on Windows with ReplaceFileW, which keeps the destination's DACL. Using that for the tool overwrite, or copying the target's security descriptor onto the staged file before the rename, would restore the old behaviour. #941 carries attributes, ACLs and ownership across the rename and could be rebuilt on top of main's file_commit.go for this.
A regression test on Windows can use the second row above: a file with inheritance removed must still have no inherited entries after an overwrite.
The other things the same rename loses are now tracked in #1242, so they stay open when this one closes: alternate data streams on Windows (measured, kept before #1214 and gone on main) and ownership, POSIX ACLs and extended attributes on Linux and macOS (read from the code, not run).
Activity
Vasanthdev2004 commentedon Nov 20, 2026
#1241 fixes the access control list on Windows.
The other things the same rename loses are now tracked in #1242, so they stay open when this one closes: alternate data streams on Windows (measured, kept before #1214 and gone on main) and ownership, POSIX ACLs and extended attributes on Linux and macOS (read from the code, not run).
fix(tools): keep a file's access control when an overwrite replaces i…