feat(runtime): Unix domain socket natives #430
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/428-unix-socket-natives"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #428
Step 1 of #119: two natives of
std/network,networkListenUnix(path, backlog)andnetworkConnectUnix(path)(torb_network_listen_unix,torb_network_connect_unixinruntime/io.c), with hooks inruntime/os/posix_io.candruntime/os/iocp.c.torb_io_addressstays IP-only; the path crosses as text on the socket record / operation. Empty, NUL byte or longer thansun_path(terminating zero included) isinvalid argument, never truncated; no abstract names.invalid argumenton a Unix stream.torb_sandbox_check_unix(verb, path)inruntime/sandbox.c, called by both natives; listed in the header comment.unrestrictedpasses.AcceptExgets a third slot forAF_UNIX.ConnectExneeds a bound socket andAF_UNIXhas no unnamed address to bind to, so the connect runs on the core's helper thread (torb_io_system_unix_connect_blocks). Not run on Windows yet.networkEntries()(Ready); twokeep/networkrows indocs/design/NATIVES.md(counts 178/533);NETWORK.mdsection 4 "Unix domain sockets, as built (step 1)" and section 10 namestorb_sandbox_check_unix.runtime/tests/io_test.c(round trip, path in use, nobody listening, invalid paths, replaced file kept, close wakes receive, sandbox refusal; POSIX only) andruntime/tests/sandbox_test.c.Notes for review:
torbbinary and no C compiler were available where this was written, sotorb_natives.handmachine_natives.cwere regenerated with a script that mimicstorb natives --header(sorted by symbol, thunks renumbered, count 307 to 309), and nothing was compiled locally. CI's generated-file check andruntime/build.share the first real run; I fix on the same branch if they are red.std/change here); the seed refresh is not part of this PR.Approved. CI is green on this exact head (generated-file check, bootstrap linux-x64, tier A and B, pdisc, gates); Windows/arm64/macOS jobs are skipped by the repo's own selection.
io_test.c(round trip, path in use keeps the first file, no file vs stale file, empty/NUL/abstract/too-long paths, replaced file survives close, close wakes receive, sandbox refusal) plus two insandbox_test.c.torb_io_unix_path); the operation path is calloc'ed, so the terminator is present; a failed bind leavespathNULL so nothing foreign is unlinked; after a successful bind a failinglistenstill cleans up via close; unlink is guarded bylstat+S_ISSOCK+ dev/inode. TCP options and IP address queries are rejected on Unix streams.torb_sandbox_check_unix, which fails closed under a sandbox (onlyunrestrictedpasses), as the sandbox header requires for new socket natives. No secrets, no new ports or dependencies.std/change.torb_natives.h/machine_natives.cwere hand-regenerated but the CI generated-file check is green.Non-blocking:
AF_UNIXAcceptEx slot, helper-thread connect, file-identity unlink) has not been compiled or run anywhere; the PR body says so. Please check it on the first Windows CI run that covers it.EAGAINas a plain failure rather than waiting; fine for step 1, worth a note in NETWORK.md or a follow-up if it shows up in practice.