Setting the mode from a file creation method will unset the 0x10 (public write) bit
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.3k
- 平均合并
- 4 天 2 小时
- 30 天内合并 PR
- 283
描述
Version
25.9.0
Platform
Linux [xxxx] 5.15.0-174-generic #184-Ubuntu SMP Fri Mar 13 18:41:50 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
fs
What steps will reproduce the bug?
Confirmed in 25.8.1, 25.9.0. Passing a 'mode' argument to at least the following methods:
fs.writeFile()
fs.promises.writeFile()
fs.promises.open()
Will set the supplied mode to the file, but with the bit at 0x10 unset (file writable by others, or S_IWOTH from the file mode constants being unset.) For example, setting the mode to 0o777 in these functions (R/W/X by user/group/public) results in a file with 0o775 being applied instead.
Setting the mode by filehandle.chmod(), fs.promises.chmod(), or fs.chmod() works as expected.
Setting the mode in a separate operation runs the risk of the mode not being properly set if the operation failed.
How often does it reproduce? Is there a required condition?
This applies at file creation. If the file already exists, then (as per expected behavior) the mode is not set at all.
What is the expected behavior? Why is that the expected behavior?
The expected behavior is for the supplied mode to be the actual mode at file creation.
What do you see instead?
The file is created with the supplied mode but without the bit at 0x10 being set.
Additional information
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先跟踪 fs.writeFile()、fs.promises.writeFile() 和 fs.promises.open() 的创建路径,然后将它们对 mode 的处理与 fs.chmod() 和 filehandle.chmod() 进行比较。在 Linux 上使用 mode 0o777 重现该问题,并验证新创建的文件会保留所提供的公共写入位,同时不改变现有文件的行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- operating-systems
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 68/100