Repository navigation
fix(cd): refuse chdir into directories without the search bit (Refs #3788) - #3797
Merged
Merged
Conversation
…3788) Root cause: the session-cwd moves (G-02) never chdir the process; their probe was canonicalize + is_dir, and both succeed on a directory without the search (execute) bit -- path resolution needs search permission only on the PARENT components, while only chdir itself checks the target. cd/pushd therefore reported success (rc 0, PWD/DIRSTACK updated) for a move that never happened. GNU builtins/cd.def change_to_directory performs a real chdir (cd.def:600/641) and refuses with EACCES, leaving the cwd unchanged. Fix: one shared probe, executor::path::probe_directory_for_chdir (canonicalize + directory + access(2) X_OK on the resolved target), used by cd's move probe, the CDPATH hit test (a no-x candidate now falls through to the next unit, cd.def:353-388), the cdable_vars guard (a no-x operand no longer blocks the variable step, cd.def:397-405), pushd's operand gate + error text, popd's inner cd, pushd swap/rotation (GNU pushd.def change_to_temp -> cd_to_string -> cd_builtin), and the $(cd X && pwd) fast path. Regression nails in tests/issue3788_cd_no_search_permission_regressions.rs cover cd and pushd, modes 000/222/444 (refuse) vs 100/111/555 (succeed), relative/absolute/symlink/nested paths, CDPATH fallthrough, cdable_vars, the comsub fast path, and pushd rotation/swap onto a no-x entry; probes run as an unprivileged user (root bypasses the bits) and skip when no such user is available. UNVERIFIED-BY-CAPTAIN 本 PR 删除了什么: - 无产品行为删除:仅把 cd/pushd 的移动探针从 canonicalize + is_dir 收紧为等价于 chdir 的判定;无 API、无公开面、无文件 删除。 - 删除了两处重复的 not_a_directory_error 小函数(cd.rs、pushd.rs), 其职责并入 executor::path::probe_directory_for_chdir。
caomengxuan666
added a commit
that referenced
this pull request
Nov 16, 2026
The 4 pins (funsub comment/heredoc x3, nested comsub in brace expansion x1) need the REAL lexer layer: no-alias isolation probes show base and fixed binaries behave identically on all four, so the alias pre-scan fix in this PR cannot turn them green. They now live in rubash #3823 (pin definitions + GNU anchors + the #3808/#3797 merge gate). This stem now holds the 11 pre-scan-layer pins only (11/11 green on X299, two rounds consistent). Refs #3813, #3823
caomengxuan666
added a commit
that referenced
this pull request
Nov 17, 2026
… as opaque (Refs #3813) (#3821) * test: add fail-first regression pins for alias comsub comment quote (Refs #3813) Alias T='{ f() {' + $(...) holding a #-comment with an odd number of apostrophes fails to parse (rc=2, unexpected end of file from `{'); GNU is rc=0. Pins cover the issue parity table (p0-p4), comment after $(, nested/dquoted/case comsub, alias-after-comment, heredoc in comsub, nested comsub in ${...}, funsub comment/heredoc faces, and the literal-$# / mid-word-# / ${...}-# controls that must keep passing. Fail-first: expected red on base 969230b; fix follows. * fix(parser): alias pre-pass treats quotes in comsub comments/heredocs as opaque (Refs #3813) skip_dollar_paren delegated to skip_parenthesized_unit_corrected (comments at token boundaries and heredoc bodies opaque, case `)\`' resolved like the body parser); skip_dollar_brace delegates nested $(...) the same way; skip_funsub_body gains a #-comment arm (token-boundary gated) and a << heredoc arm. GNU: parse.y:3631 shell_getc, parse.y:4451 parse_comsub, make_cmd.c:512. Same defect class as #2033's pre-pass walkers; these three helpers were the residual. * style: rustfmt alias_stream.rs + issue3813 nails (Refs #3813) rustfmt --check (X299 leg) flagged 4 hunks; whitespace-only, no semantic change: one guard join, one assert! join, one let split, two control tuples expanded (trailing commas per rustfmt). * test: move 4 real-lexer pins out of issue3813 stem to #3823 (Refs #3813) The 4 pins (funsub comment/heredoc x3, nested comsub in brace expansion x1) need the REAL lexer layer: no-alias isolation probes show base and fixed binaries behave identically on all four, so the alias pre-scan fix in this PR cannot turn them green. They now live in rubash #3823 (pin definitions + GNU anchors + the #3808/#3797 merge gate). This stem now holds the 11 pre-scan-layer pins only (11/11 green on X299, two rounds consistent). Refs #3813, #3823 --------- Co-authored-by: 曹梦轩 <[email protected]>
Member
Author
|
【Y3-AUDIT】续作记录(第1轮进行中)
|
Member
Author
|
【Y3-AUDIT】续作记录 第2轮 — 钉期望修正(产品代码未动)
|
Member
Author
|
【Y3-AUDIT】PR #3797 第1轮 — 建议:PASS(含两轮续作:609f24abc 编译修复 + e17a218 钉期望修正) 机制核查:
腿:
续作记录:
F 点:无(原 head 两处 CI 编译错与两处钉期望错均已续作消除,census 实跑 6/6 绿) 未跑/VOID 的腿:fail-first 独立 base 构建(unix-only 钉,本地无法跑 unix;以 Linux census head 实跑 + GNU 对照为证) |
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.
Refs #3788
根因:会话 cwd 移动(G-02)从不 chdir 进程本体,探针是 canonicalize + is_dir;两者对缺 search 位的目录都成功——路径解析只要求父分量有 search 位,只有 chdir 本身才查目标位。于是 cd/pushd 对一次从未发生的移动报成功(rc 0、PWD/DIRSTACK 已更新)。GNU builtins/cd.def change_to_directory 做真正的 chdir(cd.def:600/641),以 EACCES 拒绝且 cwd 不变;失败尾用 chdir 的 errno 报(cd.def:427)。
修法:一个共享探针
executor::path::probe_directory_for_chdir(canonicalize + 目录判定 + 对解析后目标的 access(2) X_OK),用于:cd 移动探针;CDPATH 命中判定(无 search 位的候选落到下一单元,cd.def:353-388);cdable_vars 守卫(无 search 位的操作数不再挡住变量步,cd.def:397-405);pushd 操作数门与错误文本;popd 的内层 cd;pushd 换位/旋转(GNU pushd.def change_to_temp -> cd_to_string -> cd_builtin);$(cd X && pwd) 快捷路径。回归钉:tests/issue3788_cd_no_search_permission_regressions.rs,覆盖 cd 与 pushd、模式 000/222/444(拒绝)与 100/111/555(成功)、相对/绝对/symlink/嵌套路径、CDPATH 落空、cdable_vars、comsub 快捷路径、pushd 旋转/换位到无 search 位条目;探针以非特权用户跑(root 会绕过权限位),无可用非特权用户时跳过。
UNVERIFIED-BY-CAPTAIN
本 PR 删除了什么: