Repository navigation
WIP: fix(executor): rubash#1968 - buffered builtin route validates registry-class input redirects - #2051
Merged
Conversation
…y-class input redirects before flushing route_builtin_buffered_output's ordered walk ignores Input and ReadWrite redirects entirely, and the reject gate's input probes exempt every special-path registry class — so a buffered builtin (echo/printf) executed and flushed even when its input redirect was a net target that could not connect: 'echo hi < /dev/tcp/<refused>' printed hi with status 0, and the open form never connected at all. (The filed fd-alias shapes were settled by the #1963 gate fix in #2015; the net/synthetic residue is this change.) The flush funnel now settles the registry classes the gate exempts — net and synthetic targets via the classified probes — before writing: on failure the diagnostic routes through the command's own fd 2, both buffers are discarded, and status 1 joins the builtin's return. GNU suppresses the command when do_redirections fails (execute_cmd.c:5606 execute_builtin_or_function rides the same redirect settlement); a successful net input open connects exactly once and the builtin runs.
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.
WIP: #1968 follow-up — the buffered builtin route validates registry-class input redirects before flushing.
Scope note: this cluster originally covered #1963/#1964/#1966/#1968. PR #2015 (fd registry family) landed first and closed #1963, #1964 and #1966; this PR is the narrowed remainder for the one issue still open.
What remains broken on master (measured against GNU bash 5.3.20, loopback listener):
echo hi < /dev/tcp/<refused>— GNU suppresses with status 1 and a Connection refused diagnostic; master printshi, status 0, silent.echo hi <> /dev/tcp/<refused>— same silent execution.echo hi < /dev/tcp/<open>— GNU performs the input netopen (1 connection); master never attempts it (0 connections).Root cause: the buffered route's ordered walk ignores Input/ReadWrite redirects entirely, and the reject gate's input probes exempt every special-path registry class, so net/synthetic input redirects on echo/printf are never attempted and never settled. (The filed fd-alias shapes were settled by the #1963 gate fix in #2015.)
Change: the flush funnel (
write_buffered_builtin_output_ordered) settles the registry classes the gate exempts — Net/SyntheticProc/SyntheticLink via the classified probes — before writing anything. On failure the diagnostic routes through the command's own fd 2, both buffers are discarded, and status 1 joins the builtin's return. Plain/null/fd-alias targets are not re-probed (the gate settled them). GNU: do_redirections precedes the builtin body (execute_cmd.c:5606); failure is redirection_error (redir.c:149-176).Regression pins:
tests/issue1968_builtin_input_redirect_validation_regressions.rs(8 pins: alias/plain/null controls plus refused</<>suppression and exactly-one-connection on the open form, counted by an in-process listener).Local verification note: lib and pin target compile clean (
cargo check); the full test-binary build was OOM-killed twice on the shared dev box (7 GB, many concurrent cluster builds), so the pin run itself is delegated to this PR's CI.Fixes #1968