Skip to content

fix: apply unix permissions at creation - #1104

Merged
Pr0methean merged 9 commits into
masterfrom
apply-permissions
Oct 24, 2026
Merged

Pr0methean merged 9 commits into
masterfrom
apply-permissions

Conversation

@Its-Just-Nans

Copy link
Copy Markdown
Member

@Its-Just-Nans

Copy link
Copy Markdown
Member Author

@Pr0methean The branch protection on master is gone ?

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR applies Unix permissions at file-creation time via OpenOptions::mode(), which closes the race window where a newly-created file is temporarily accessible with the process's default umask permissions before the subsequent set_permissions call. The intent and approach are correct.

One blocking issue must be fixed before merge:

The new use std::os::unix::fs::OpenOptionsExt; import on line 7 is unconditional and will cause a compilation failure on Windows and any other non-Unix target, breaking the existing cross-platform build matrix required by CI. It needs a #[cfg(unix)] attribute (see inline comment).


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment thread src/read/extract.rs Resolved

@Pr0methean Pr0methean left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Its-Just-Nans Is there any reason to still have lines 573-577 (which set the permissions after writing the file) with this change?

@Pr0methean Pr0methean added this to the 9.1.0 milestone Oct 19, 2026
@Its-Just-Nans

Its-Just-Nans commented Oct 19, 2026 •

Copy link
Copy Markdown
Member Author

What did you mean by #1105 (comment)

specify that it doesn't apply to owner-writable normal files (the most common case). Otherwise this will become misleading almost as soon as it's merged.

Also, on windows, the permissions are still deferred

@Pr0methean

Copy link
Copy Markdown
Member

I mean that it only applies to normal files, i.e. files that aren't folders or symlinks. (The "owner-writable" detail was wrong; I hadn't yet had a chance to look up whether creating a file while opening it for writing, but also making it impossible to open for writing again, was allowed.)

@Its-Just-Nans

Copy link
Copy Markdown
Member Author

I mean that it only applies to normal files, i.e. files that aren't folders or symlinks. (The "owner-writable" detail was wrong; I hadn't yet had a chance to look up whether creating a file while opening it for writing, but also making it impossible to open for writing again, was allowed.)

Yes you're right. The mode with OpenOptions only apply with file that have a mode on unix. In all the other case, a time delay exists between creation and permissions. That's the goal of the comment, to explain that their is a delay*.

*Specifically on:

  • folders
  • symlinks
  • files that don't have mode
  • files on other OS than linux

Clarify that permission issues during extraction apply only to directories and symlinks on Unix.

Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com>
Pr0methean
Pr0methean previously approved these changes Oct 19, 2026
@Pr0methean
Pr0methean enabled auto-merge October 19, 2026 21:10
@Pr0methean

Copy link
Copy Markdown
Member

@Its-Just-Nans One pre-existing quirk I noticed while testing this change is that if an archive contains two files with equivalent paths, and the first is read-only, we won't be allowed to overwrite it and extraction will return an error. In old versions where permissions were set in a second pass, that wouldn't have happened. Is this likely to be the behavior everyone wants? If we were going to change file permissions to overwrite them, we'd first have to make sure the overwritten file came from the archive, so it'd be a complicated change.

@Its-Just-Nans

Copy link
Copy Markdown
Member Author

@Its-Just-Nans One pre-existing quirk I noticed while testing this change is that if an archive contains two files with equivalent paths, and the first is read-only, we won't be allowed to overwrite it and extraction will return an error. In old versions where permissions were set in a second pass, that wouldn't have happened. Is this likely to be the behavior everyone wants? If we were going to change file permissions to overwrite them, we'd first have to make sure the overwritten file came from the archive, so it'd be a complicated change.

Yes you're right. you're commit is good

@Pr0methean
Pr0methean disabled auto-merge October 22, 2026 00:18
@Pr0methean
Pr0methean added this pull request to the merge queue Oct 22, 2026
@Pr0methean
Pr0methean removed this pull request from the merge queue due to a manual request Oct 22, 2026
@Pr0methean
Pr0methean added this pull request to the merge queue Oct 23, 2026
@Pr0methean
Pr0methean removed this pull request from the merge queue due to a manual request Oct 23, 2026
@Pr0methean
Pr0methean added this pull request to the merge queue Oct 23, 2026
Merged via the queue into master with commit 4b3d6f0 Oct 24, 2026
130 checks passed
@Pr0methean
Pr0methean deleted the apply-permissions branch October 24, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants