`os.chmod` is missing validation for `dir_fd` and `follow_symlinks` when `path` is a file descriptor
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- 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