`os.chmod` is missing validation for `dir_fd` and `follow_symlinks` when `path` is a file descriptor
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
The documentation for os.chmod says it is not correct to use dir_fd or follow_symlinks when path is an open file descriptor...
... but os_chmod_impl never checks it.
When path->is_fd is true it takes the fchmod path and returns success, so both keywords are ignored altogether:
Other os utils (I checked os.stat, os.chown, and os.utime) reject this combination with dir_fd_and_fd_invalid / fd_and_follow_symlinks_invalid before the syscall. os.chown for example:
(The Windows path also has the same problem with: path->is_fd going directly to win32_fchmod.)
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-156265
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Modules/posixmodule.c 中的 os_chmod_impl 开始,检查 POSIX 和 Windows 的 path->is_fd 分支。将它们的处理方式与 os.chown、os.stat 和 os.utime 使用的验证进行比较。当 path 是文件描述符时,拒绝无效的 dir_fd 和 follow_symlinks 组合,并且相关 os 测试覆盖了这一行为,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- operating-systems
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100