Repository navigation
test: add fail-first regression pins for hash/type accepting non-executable PATH files (Refs #3825) - #3830
Merged
Conversation
…utable PATH files (Refs #3825) GNU anchors: hash.def:214-230 add_hashed_command (executable_file post-check on the find_user_command result) + type.def:381 describe_command (type -a enumerates via user_command_matches with FS_EXEC_ONLY). command -v and plain type stay lenient (controls). UNVERIFIED-BY-CAPTAIN
…efs #3824) GNU findcmd.c:214-223 executable_file requires FS_EXECABLE and not a directory; the unix is_executable_file was a bare access(X_OK), which admits directories (search permission). That made phash_search_spelling return "./" for a stored empty hash -p path: hash -t printed "./" and running the entry failed "./: Is a directory" (rc 126) instead of GNU's ": No such file or directory" (rc 127). Shared fix commit for #3825 (same commit cherry-picked onto the #3825 branch): the #3825 hash/type post-checks call this predicate. UNVERIFIED-BY-CAPTAIN
…efs #3825) GNU hash.def:214-230 add_hashed_command applies an executable_file post-check on the find_user_command result; GNU type.def:381 describe_command enumerates type -a via user_command_matches with FS_EXEC_ONLY. The PATH walk stays FS_EXEC_PREFERRED (correct for execution — the exec then fails EACCES — and for the lenient faces), so the strict gate lives at the two consumption points: - hash bare-name loop: a non-executable hit is not stored; the builtin reports "hash: <name>: not found", rc 1. - command_paths (-a enumeration, sole caller describe_name_all_with_io): unix side pushes only executable candidates. command -v and plain type stay lenient (controls in the pins). Depends on the shared is_executable_file fix (53acd68, cherry-picked from the #3824 branch). UNVERIFIED-BY-CAPTAIN
Formatting only (server rustfmt --edition 2021); no semantic change.
Member
Author
|
PR #3830 第1轮 — 建议:PASS 机制核查:
腿(逐项给数字与名字):
F 点:无 续作记录:无(只审未改) 未跑/VOID 的腿:无 |
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.
摘要
hash mycmd与type -a mycmd不应接受经 PATH 找到的非可执行文件;GNU 报not found(rc 1)。当前 rubash 两处皆接受。修法已落盘:
86599fef(共享原语修法,自 #3824 分支 cherry-pick)+40f83bd4(两处后验)。回归钉42b5c09a(9 cells)+ 格式修复50e1aef5。根因
PATH 查找本身是 FS_EXEC_PREFERRED(
find_in_path_walk_unix,src/executor/path.rs:1283+):无可执行文件时返回首个已存在文件作file_to_lose_on回退。该回退对执行面正确(随后 exec 报 EACCES rc 126),对command -v与普通type的宽容面也正确(GNU 同样宽容),但hash与type -a两个消费点缺少 GNU 的严格后验:hash(裸名循环,src/builtins/hash.rs:355+):GNUhash.def:214-230add_hashed_command对find_user_command结果做executable_file后验,不过则sh_notfound。type -a(command_paths,src/executor/lookup_paths.rs:284+):GNUtype.def:381用user_command_matches(command, FS_EXEC_ONLY, ...)枚举,只列可执行文件;此前实现以anchored.is_file()为准,只验存在。GNU 锚点
hash.def:214-230、findcmd.c:214-223、type.def:381(见上)。type.def:379:普通type用find_user_command(FS_EXEC_PREFERRED),故保持宽容——本 PR 不动find_user_command本身。修法
与 #3824 共享同一原语修法:unix
is_executable_file排除目录(共享修法提交53acd684,见 #3824 的 PR #3829,本分支 cherry-pick 为86599fef)。在此之上(40f83bd4):hash裸名循环:find_user_command返回后做目录排除的可执行性后验,不过则删条目、报hash: <name>: not found、rc 1。command_paths(-a枚举,唯一调用方是describe_name_all_with_io):unix 侧只推可执行候选。本 PR 删除了什么
无删除(新增回归钉
tests/issue3825_hash_type_nonexec_path.rs,9 个 cells,含command -v/ 普通type宽容面守卫)。验证(车道腿,UNVERIFIED-BY-CAPTAIN)
command -v与普通type宽容面)全过。type_a_empty_path_element_visit_counts,[bug] type -a reports the cwd match once per empty PATH element; GNU collapses adjacent empty elements #2943)在 test: add fail-first regression pins for empty hash -p path (Refs #3824) #3829(其 diff 不含 command_paths 改动)上同样红,属基线/抖动,非本修法回归。-D warningscheck 0、lib 双边 1368/1/4 两侧完全一致(唯一红 cell 为已知 Windows 基线 issue2084)、hygiene 三项全 0;钉 stems 为 unix-gated,Windows 上 0 tests。type宽容面对照);钉 cells 即种子断言的测试化。