Skip to content

File overwrites drop alternate data streams on Windows and ownership, ACLs and attributes on POSIX #1242

Open

Description

@Vasanthdev2004

Summary

Since #1214 the file tools publish an overwrite by renaming a new file over the target. #1236 covers the access control list that this lost on Windows, and #1241 fixes it. Two other things belong to the old file and do not follow the rename. They are split out here so they are not closed along with #1236.

1. Alternate data streams on Windows (measured)

A file with a named stream keeps it across a write_file overwrite on b32f7ce4 (the parent of #1214) and has none afterwards on main 8288ae81:

commit a.txt:tag after the overwrite
b32f7ce4 still stream
8288ae81 gone

The stream that matters in practice is the mark of the web (Zone.Identifier) on a downloaded file: after Zero edits such a file it no longer carries it.

2. Ownership, POSIX ACLs and extended attributes on Linux and macOS (read, not run)

writeRootedSideFile in internal/tools/file_commit.go gives the staged file the target's permission bits and nothing else. I have not run this on a POSIX host, so treat it as a reading of the code: a file owned by another user, or one carrying a POSIX ACL, a SELinux label or a user.* attribute, would come out of an overwrite with the writer's ownership and none of the rest.

Direction

Each needs a decision, not just a patch: carry it to the staged file before the rename, or accept the loss and document it. For streams, copying every stream is the faithful answer and copying only the mark of the web is the small one. For POSIX, #941 has code that carries attributes, ACLs and ownership across the rename and could be rebuilt on top of main's file_commit.go.

Whatever is chosen should fail the way #1241 does for the list: if something that was going to be carried cannot be, refuse the write and leave the old file in place.

Activity

  1. added
    bug
    on Nov 20, 2026
  2. Vasanthdev2004 commented on Nov 23, 2026

    @Vasanthdev2004
    CollaboratorAuthor

    More on Windows, all measured unless marked. I ran the same overwrite through write_file and edit_file on a file prepared each way, on the parent of #1214 and on main.

    the file had b32f7ce4 main 8288ae81
    Hidden kept cleared
    System kept cleared
    Hidden and System kept cleared
    Not content indexed kept cleared
    NTFS compression kept gone
    a Low integrity label, S:(ML;;NW;;;LW) kept gone

    Both tools give the same result in every row. After the overwrite on main the attributes read 0x20 (Archive alone) and the label query returns an empty descriptor.

    So a file someone had hidden shows up in listings again after Zero edits it, a compressed file is stored uncompressed, and a file labelled Low loses the label. For the label I measured the label and not the access, but with no label a file is treated as Medium, so a low integrity process that could write it before should be refused afterwards.

    Not measured: encryption. Compression and EFS encryption are both per-file state that a new file takes from its directory, so I expect a file that was encrypted on its own, in a directory that is not, to come out of an overwrite in plain text on disk. I did not run it, because encrypting a file here would create an EFS key in my profile. If someone already uses EFS, it is a two-minute check, and it is the row I would most like to see filled in.

    #1241 at 533dc3b7 gives the same results as main for the rows I ran there (attributes and label). It carries the discretionary list and nothing else, which is what it says, so this is not a gap in that PR.

    On direction:

    • Attributes need no decision that I can see. They can be read from the handle that is already validated and set on the side file before the rename. It is the same function fix(tools): keep a file's access control when an overwrite replaces it on Windows #1241 changes, so I will send it once that has landed instead of stacking a conflict on top.
    • The label can travel the way the list does in fix(tools): keep a file's access control when an overwrite replaces it on Windows #1241, including the refusal when it cannot be carried.
    • Compression, encryption and streams are where carrying things one at a time starts to look like the wrong shape. The list of what belongs to the old file keeps growing, and each item needs its own call. Win32 has ReplaceFileW for this job, and its documentation says it keeps the replaced file's list, streams, compression and encryption. I have not tried it here, and it is not a drop-in for two reasons its own page gives. It takes paths, which does not fit the handle-relative way these tools stay inside the workspace. And it has documented failure states that the rename does not: with no backup name, ERROR_UNABLE_TO_MOVE_REPLACEMENT leaves the replaced file gone, which is the outcome fix(tools): publish file writes atomically instead of truncating in place #1214 was written to rule out. The page also says nothing about hidden or system attributes or the label, so it would not cover the whole table either. It is the alternative to weigh against carrying each item ourselves.

    So the decision for this issue is one question: what does an overwrite promise to keep on Windows. Everything above then either gets carried or gets written down as dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions