Repository navigation
WIP: fix(exec,net): quoted procsub targets are literal on exec redirects; serve /dev/tcp in read + external fd-0 <> (rubash#2090, rubash#2091) - #2097
Merged
Conversation
…teral filenames
The exec persistent-redirect arms (execute_stdio_only_exec_redirect
and execute_dynamic_fd_var_redirect) admitted a process substitution
from the quote-stripped target VALUE alone: strip_prefix("<(") /
strip_prefix(">(") with no recorded-span check. GNU
expand_word_internal (subst.c:11365-11372) refuses the span when the
'<' was quoted (Q_DOUBLE_QUOTES), so exec {fd}< "<(touch MARKER)"
is a literal open — ENOENT diagnostic, body never runs. rubash
spawned the body (MARKER created) and the materialized 'success'
swallowed the diagnostic whole; the same value-only admission made
exec {fd}<> / {fd}> / {fd}>> and the plain exec > / < arms spawn
quoted spans or read a span instead of an existing literal file.
Gate every procsub admission in the exec persistent path on the
recorded-span check every other materialization arm uses since
rubash#1931 (external_setup redirect_target_span_is_recorded). A
quoted target now falls through to the literal open: '<' reports
ENOENT, '>'/'>>'/'<>' create the literal file, and an existing
literal is read as-is. Unquoted spans are admitted exactly as
before (recorded), so streaming binds are unchanged.
Regression pins: tests/issue2090_exec_quoted_procsub_regressions.rs
(6 pins; 5 fail on the pre-fix tree, the unquoted control passes on
both). Verified against GNU bash 5.3.20 with script files: the seed
plus a/b/b2/c2/d controls and the wider {fd} class are byte-equal.
Fixes #2090
…0 <> arm Two residual #1964 faces, re-measured on current master (the append faces and the `: <>` cell from the filing were already settled — one connection, delivery intact — and are pinned here as controls only): 1. `read x <> /dev/tcp/...` (and the plain `<` twin): the read builtin's serve ladder hand-rolled filesystem path translation and never classified the net spelling, so it served a silent EOF — x empty, read status 1, ZERO connections, no diagnostic. GNU do_redirections connects via redir.c netopen and read serves the greeting. The serve ladder now classifies the shell spelling through the special-paths registry before path translation: open_net_redirect performs the one connect (a refused connect's first line is emitted inside connect_net_stream, as on every other face), the socket is bound transiently as fd 0 and served by read_virtual_fd_stdin like the fifo/device branches; a connect error is reported as the redirection's failure in the serve, per the rubash#721 precedent. 2. External `cat <<EOF <> /dev/tcp/...` (and plain `cat <>`, piped or not): the external fd-0 ReadWrite arm raw-opened the translated pseudo-path and failed with a bare `No such file or directory` naming no target, before any connection. Net targets now route through open_net_redirect before that branch, so the socket serves `<>` in both directions and a refused connect names the target with both diagnostic lines, rc=1. In both faces the probe performs no connection of its own and the bind reuses the single connect — the same settlement shape as the rubash#1967 `>` face. Regression pins: tests/issue2091_devtcp_residual_regressions.rs (7 pins, hermetic in-process loopback listener on 127.0.0.1:0; the 6 fix pins fail on the pre-fix tree, the append control passes on both). Verified against GNU bash 5.3.20 with script files and -c. Fixes #2091
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.
fd 批两单:#2090(exec 引号 procsub 目标被物化执行)+ #2091(#1964 残余 /dev/tcp 三格复测后两格实修、一格已覆盖记账)。
#2090 — exec 持久重定向的引号 procsub 目标是字面文件名
execute_stdio_only_exec_redirect与execute_dynamic_fd_var_redirect仅凭去引号后的目标值(strip_prefix("<(")/strip_prefix(">("))准入 procsub,无 recorded-span 检查。GNUexpand_word_internal(subst.c:11365-11372)在<被引号(Q_DOUBLE_QUOTES)时拒绝该 span,故exec {fd}< "<(touch MARKER)"是字面打开——ENOENT 诊断、body 永不运行。rubash 却 spawn 了 body(MARKER 被建)且物化「成功」把诊断整个吞掉;同一值准入还使exec {fd}<>/{fd}>/{fd}>>与普通exec >/<臂 spawn 引号 span、或拿 span 顶替已存在的字面文件来读。修法:exec 持久路径的全部 procsub 准入点统一过 #1931 起其他物化臂共用的 recorded-span 检查(
external_setup::redirect_target_span_is_recorded)。引号目标落回字面打开:<报 ENOENT、>/>>/<>建字面文件、已存在的字面按原样读。未引号 span(有记录)准入不变,流式绑定无回归。钉:
tests/issue2090_exec_quoted_procsub_regressions.rs6 钉(修复前树恰 5 钉红、未引号对照两树皆绿)。GNU bash 5.3.20 脚本文件逐字节对照:seed + a/b/b2/c2/d 对照形 + 更宽 {fd} 类 20/22 SAME;余 2 格(u-rw、out2u)经基线 A/B 证明为修复前既存分歧(GNU 在 RDWR procsub 管道 EOF 形状上挂起、RW 伴随账本两构建都建空文件、持久输出 procsub body 时序),非本单面,记工区 REPORT。#2091 — #1964 残余 net 格:复测后两格实修
立案三格在当前 master 复测:
: >>、echo hi >>、/bin/echo hi >>/dev/tcp)与: <>:已覆盖(各恰 1 连接、投递完好,立案后已结算)——不硬修,本批钉为对照防回退。read x <> /dev/tcp/...(含 plain<孪生格)实修:read 内建的 serve 阶梯手搓文件路径翻译、从不分类 net 拼写,喂出静默 EOF(x 空、0 连接、无诊断)。现按 shell 拼写过 special-paths 注册表分类 →open_net_redirect一次连接(拒绝连接的首行由connect_net_stream内发出,与其他面一致)→ socket 瞬时绑 fd 0 由read_virtual_fd_stdin服务(同 fifo/device 分支形态);连接错误按 read < /dev/fd/N with closed N: silent rc=1 instead of GNU error, /proc/self/fd/N same #721 先例在 serve 内报为重定向失败。GNU 依据 redir.c netopen。cat <<EOF <> /dev/tcp/...(及 plaincat <>、管道形)实修:外部 fd-0 ReadWrite 臂裸开翻译后的伪路径,报不带目标名的裸 ENOENT、连接从未发生。现 net 目标先走open_net_redirect再入该臂;拒绝连接时双行诊断带目标名、rc=1。两面均为:探针自身不带连接副作用、探针与 bind 共用同一次连接结算,与 #1967 已修
>面口径一致。钉:
tests/issue2091_devtcp_residual_regressions.rs7 钉(hermetic:进程内 TcpListener 绑 127.0.0.1:0 随机端口、问候+字节记录、#1968 式结算计数;修复前树恰 6 修复钉红、append 对照两树皆绿)。与 #2042 的边界
#2091 立案三格中 append 已结算、
: <>已覆盖;本批实修的两面(read serve 阶梯、外部 fd-0 RW 臂)均在 #2042 所列五面之外,未触其「内建面 loopback 双开」子面——无双修。另有一相邻发现(外部命令上非胜出 fd-0 net 重定向从不执行其 open:输出正确但 0 连接 vs GNU 1),根因在 winner 探针环的纯度设计(#1950),本批未修,建议归宿 = 外部重定向探针/bind 架构批(#2042 姊妹批),详见工区 REPORT。门
cargo check --locked --all-targets(RUSTFLAGS="-C debuginfo=0 -D warnings")净;lib 套 961/1/3(唯一红 = 基线 ownership 钉,基线同红);相关钉批槽外直跑全绿(issue1820/1963/1964/1966/2024/2090/2091);issue1968 的 3 钉在基线与修复树同红(Linux 环境依赖、其判官为 Windows CI),非回归。fd 敏感钉按纪律在构建槽外执行(槽以 fd 9 持 flock)。Fixes #2090
Fixes #2091