Repository navigation
fix(file): restore extended attributes before the final mode (#324) - #350
Closed
WeiLinCool wants to merge 1 commit into
Closed
WeiLinCool wants to merge 1 commit into
WeiLinCool wants to merge 1 commit into
Conversation
) A read-only replacement is no longer writable when the final mode is applied, so a 0400 target lost every captured xattr. Apply the attributes while the replacement is still writable; the mode stays after chown and the ACL last. The mode matrix now seeds a user attribute and asserts it comes back, so the order is covered on every host rather than only through macOS's com.apple.provenance.
Contributor
Author
|
按 贡献指南 的"先 issue,后 PR"流程,PR 必须关联 issue 并先在 issue 认领,以防止重复。#324 已指派给 @Richeir,且 #325 是在途实现;本 PR 属于重复提交,先关闭,不占用评审带宽。 重做到 v0.4.1 的工作保留在 fork 分支 (fork 内镜像 PR 已关闭:GitHub 对新 fork 默认不启用 workflow。) |
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #324
What was wrong
ops_replace的发布是"捕获旧 inode 元数据 → 写新 inode → rename",而PreservedMetadata::restore的顺序是 chown → fchmod(最终模式)→ ACL → xattrs。当最终模式是0400时,替换文件在fchmod之后已经不可写,末尾的fsetxattr返回EACCES。macOS 26+ 会给每个新建文件自动打上
com.apple.provenance,所以在 macOS 27.0.1 上这个缺陷对0400必现;同一顺序在任何平台都会静默丢掉目标携带的user.*属性,只是别的系统没有这个"人人都有"的属性把它暴露出来:其余五种模式通过,说明不是权限模型的问题,而是恢复顺序。
The change
native/crates/ops-files/src/file.rs:扩展属性改在fchmod之前重放(此时替换文件仍可写)。fchmod仍在chown之后(成功的 chown 会清除 setuid/setgid),ACL 仍在最后(chmod会重写 ACL 的 mask 项)。test/file-metadata.test.mjs:模式矩阵在最终chmod之前挂一个user.dsh-ops属性,并断言它被原样恢复;这样这条顺序在所有平台都受断言约束,而不只依赖 macOS 免费提供的属性。docs/CHANGELOG.md:## [Unreleased]双语条目。刻意没做:严重性分级一字未动——模式仍是"不可恢复即失败、不发布任何东西",ACL 仍不可选,属主与其余扩展属性仍是尽力而为并在
metadataWarnings里报告。本次只移动顺序。基于 v0.4.1(
a9ff940)重做。#325 携带同一诊断与修复,但当前与 main 冲突;本 PR 将其重放到当前主干,原始诊断与修复归 @Richeir。Validation
行为级 A/B(同一主机、同一工具链;撤掉实现即红):
完整门禁(macOS arm64,Rust 1.97.1):
CI(由本 PR 的
pull_request事件触发):Environment
a9ff940(v0.4.1)npm ci --ignore-scripts);worker 由npm run build:ptc本地构建