Repository navigation
built-in read-only rsh server improvements - #271
Merged
Merged
Conversation
Writes each rsh request and how it ended (bytes, ms, complete / cut short / never sent a whole request) to stderr in any build, for diagnosing slow or hung network installs. Off unless the variable is set. Standalone rsh.rs tests pass (20); the full crate is still unbuilt here. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJtD8EfBuugQ7a2pv4vhsU
With IRIS_RSH_TRACE set, report each guest connection to port 514 and whether the built-in server answered it or it was relayed to the host (rsh_dir unset, or not the gateway address), and the stderr connect-back. Print a startup line when rsh_dir is on. "No trace" now distinguishes "never reached the server" from "no requests". Not built in full here (no crates.io access); rsh.rs tests pass standalone. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJtD8EfBuugQ7a2pv4vhsU
BSD rcmd sends only the stderr port, then blocks accepting the connection back, and sends the user names and command only after that. The server waited for the whole request before connecting back, so both sides waited until the client's timeout (inst: 120 s) and the guest then closed with nothing sent. Request the connection back when the first field is complete. Also stop the trace calling such a session "complete". Standalone rsh.rs tests pass (23); the full crate is not built here, so the updated testnet.rs test is unrun. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJtD8EfBuugQ7a2pv4vhsU
…mands inst runs 'exec /bin/sh' and drives it over stdin. Shell mode runs each stdin line (with ';', 2>/dev/null) against the read-only built-ins and logs every line under IRIS_RSH_TRACE. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJtD8EfBuugQ7a2pv4vhsU
inst sends each command as one line ending in ( status=$? ; trap '' 2 ; echo 'MARK\c' ; echo 'MARK'$status'\c' 1>&2 ). Run the commands, then write the marker to stdout and, with the exit status, to the stderr connection. Add trap (no-op), echo X | dd, dd | fgrep and the IRIX ls -inld[L] / /bin/ls -a formats, as the reference server does. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJtD8EfBuugQ7a2pv4vhsU
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.
Add a built-in read-only rsh server to the NAT gateway (network install source for IRIX
inst)Summary
Adds a built-in rsh server at the NAT gateway (TCP 514). With
[network] rsh_dir = "DIR"(or--rsh-dir DIR), the guest can runrsh 192.168.0.1 <command>against a host directory without a hostrshd. That makes DIR usable as a network installation source for IRIXinst, including the miniroot, which sendsexec /bin/shand drives it over stdin.It is read-only and runs nothing on the host. A small set of commands is emulated, and every path is sandboxed to DIR.
What's included
Protocol (
src/net/rsh.rs, new)rcmd/rshd: headerport\0luser\0ruser\0command\0,\0accept or\1 msg\nreject.rcmdsends it alone and waits for the connect-back before sending the rest.cat,dd(if= bs= ibs= count= iseek=/skip=, records summary on stderr),ls [-1alinLd],echo,pwd. Unknown commands printX: Command not found.exec /bin/sh,sh,/bin/shand similar. Stdin is run line by line against the same commands:;,2>/dev/nullandcd/export/trap/exit(no-ops or exit) are handled.instwaits for is implemented:( status=$? ; trap '' 2 ; echo 'MARK\c' ; echo 'MARK'$status'\c' 1>&2 ).MARKgoes to stdout, andMARK<status>goes to the stderr connection with a real exit status (0, 1, or 127).echo X | dd(theiseekprobe) anddd … | fgrep STR(IRIX 6.5.idbscans) are supported.ls -inld[L]prints the IRIX format: inode, mode, links, uid, gid, size,Mon D HH:MM, name. The time is UTC.$, redirects andif/testare refused with an error on stderr...and symlink escapes are rejected. The TOCTOU window between check and open is documented in the module docs.Engine (
src/net/)TcpServicegainspull(max)(streamed output instead of buffering whole files) andside_connect()(a service asks for a connection to the guest). The gateway's own outbound connection to the guest usesalloc_sport(guest_port, reserved), split out ofalloc_fwd_sport.rsh_diris set. Otherwise they are relayed to the host as before.Diagnostics
IRIS_RSH_TRACE=1logs, in any build, each connection (built-in or relayed), the stderr connect-back, each request, each shell stdin line, and how every session ended (bytes, ms, complete or abandoned).Config and docs
[network] rsh_dir,--rsh-dir, and the GUI machine path handling (iris-gui).HELP.md(rsh section and both trace variables),FEATURES.md,CHANGELOG.md,docs/net-stack.md.Testing
instthroughrsh).src/net/rsh.rs(27, covering parsing, sandbox,cat/dd/ls, the split-request handshake, shell mode, the marker protocol,ls -inld,echo | ddanddd | fgrep) pass. I ran them in a standalone harness.src/net/testnet.rshas end-to-end engine tests (stderr connect-back, no-stderr-port, split request with a small window, malformed request). These were written but have not been run: the full crate could not be built in the environment where this was developed. Please runcargo test --workspacein CI before merging.Notes for reviewers
dd of=other than stdout is rejected.instmarker carries one.instor another client sends something unsupported, it fails with a clear stderr message, andIRIS_RSH_TRACEshows the exact line.🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01NJtD8EfBuugQ7a2pv4vhsU