Repository navigation
fix(executor): open exec-face FIFO redirects via the cwd anchor in a deleted cwd (Refs #3286) - #3867
Merged
Merged
Conversation
…deleted cwd (Refs #3286) Absorbs the two trap_exec.rs residuals of PR #3363 after #3735 landed the command-attached faces: bare `exec > fifo` / `exec >> fifo` (persistent bind) and `exec <cmd> >> fifo` (replacement spawn) still died ENOENT from a deleted cwd. Root cause: the redirect machine's probe/bind split classifies an existing FIFO by anchor fstatat/faccessat and keeps no File for it, so the bind performs the one real open — but the two exec-face binds opened by dead joined string path instead of the cwd anchor: `set_fd_output_file` did a plain `FileFd::open_write`, and `exec_spawn_open_output`'s append arm did a raw `open_redirect_append`, bypassing the registry (rubash#1964) and the anchor. GNU anchors (audit tree `build-gnu/bash-5.3/redir.c`): :237 `do_redirections` (one `do_redirection_internal` per entry), :790 `do_redirection_internal`, :725 `redir_open` (the single open per redirect entry). (`redir.c:348` is inside `heredoc_expand`'s doc comment, not the dispatcher.) Changes (`src/executor/trap_exec.rs` only): - `set_fd_output_file`: for a relative operand, try `open_via_cwd_anchor` with O_WRONLY|O_CREAT|(O_TRUNC|O_APPEND) first; fall back to the plain open when the anchor does not apply (live cwd / non-unix). For an existing FIFO this is the rendezvous open. - `exec_spawn_open_output`: the append arm now calls `open_append_target_for(Some(redirect), target)` — the redirect-aware classified open whose Filesystem arm opens via the anchor — instead of the raw `open_redirect_append`. Regression pins (`tests/issue3286_deleted_cwd_fifo_redirect.rs`, unix only, 3 tests): bare `exec > ../fifo`, bare `exec >> ../fifo`, and `exec echo hello >> ../fifo` from a deleted cwd, each with a background reader; the command-attached faces and the missing-target control already live in `tests/issue3286_deleted_cwd_fifo_redirect_regressions.rs` (#3735) and are not duplicated here. ## 本 PR 删除了什么 - 无文件删除,无公开面删除,无行为删除。 - 唯一移除的调用点是 `exec_spawn_open_output` 追加臂里的 `open_redirect_append(&self.session_path(...))` 原始打开, 由等价的分类打开 `open_append_target_for` 替代(同一 O_WRONLY|O_CREAT|O_APPEND 语义,另加分类与锚路由)。 - PR #3363 的钉 1–4、7 未随附:已由 #3735 的 `issue3286_deleted_cwd_fifo_redirect_regressions.rs` 覆盖, 不重复。 UNVERIFIED-BY-CAPTAIN
Member
Author
|
【WIN-AGENT-AUDIT】PR #3867 第1轮(m1 审计)— 建议:FAIL 机制核查:
腿:
F 点:
未跑/VOID 的腿:fail-first、lib 双边、-D warnings、marker/utf8 卫生、CI 逐项核查(判词已定,未展开)。 |
…3286) external_exec_process set current_dir(cwd) unconditionally, so an 'exec <cmd> >> fifo' replacement spawn from a deleted session cwd failed the child's chdir with ENOENT (127 'cannot execute'). Carry stamp_spawn_cwd's three-outcome decision on ChildFdSetup and replay it in the exec Command builder: resolving cwd keeps current_dir, a dead cwd the anchor names becomes the same pre_exec fchdir the Command faces register, and a dead cwd no anchor names stays unstamped.
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.
fix(executor): open exec-face FIFO redirects via the cwd anchor in a deleted cwd (Refs #3286)
Absorbs the two trap_exec.rs residuals of PR #3363 after #3735
landed the command-attached faces: bare
exec > fifo/exec >> fifo(persistent bind) andexec <cmd> >> fifo(replacement spawn) still died ENOENT from a deleted cwd.
Root cause: the redirect machine's probe/bind split classifies an
existing FIFO by anchor fstatat/faccessat and keeps no File for it,
so the bind performs the one real open — but the two exec-face binds
opened by dead joined string path instead of the cwd anchor:
set_fd_output_filedid a plainFileFd::open_write, andexec_spawn_open_output's append arm did a rawopen_redirect_append, bypassing the registry (rubash#1964) andthe anchor.
GNU anchors (audit tree
build-gnu/bash-5.3/redir.c): :237do_redirections(onedo_redirection_internalper entry), :790do_redirection_internal, :725redir_open(the single open perredirect entry). (
redir.c:348is insideheredoc_expand's doccomment, not the dispatcher.)
Changes (
src/executor/trap_exec.rsonly):set_fd_output_file: for a relative operand, tryopen_via_cwd_anchorwith O_WRONLY|O_CREAT|(O_TRUNC|O_APPEND)first; fall back to the plain open when the anchor does not
apply (live cwd / non-unix). For an existing FIFO this is the
rendezvous open.
exec_spawn_open_output: the append arm now callsopen_append_target_for(Some(redirect), target)— theredirect-aware classified open whose Filesystem arm opens via
the anchor — instead of the raw
open_redirect_append.Regression pins (
tests/issue3286_deleted_cwd_fifo_redirect.rs,unix only, 3 tests): bare
exec > ../fifo, bareexec >> ../fifo, andexec echo hello >> ../fifofrom a deletedcwd, each with a background reader; the command-attached faces
and the missing-target control already live in
tests/issue3286_deleted_cwd_fifo_redirect_regressions.rs(#3735)and are not duplicated here.
本 PR 删除了什么
exec_spawn_open_output追加臂里的open_redirect_append(&self.session_path(...))原始打开,由等价的分类打开
open_append_target_for替代(同一O_WRONLY|O_CREAT|O_APPEND 语义,另加分类与锚路由)。
issue3286_deleted_cwd_fifo_redirect_regressions.rs覆盖,不重复。
UNVERIFIED-BY-CAPTAIN