Repository navigation
fix: read symlinks on direct binds - #194
Merged
ferdingler merged 4 commits intoNov 6, 2026
Merged
Conversation
readlink on a path under a direct bind failed with "not a directory", because read_link only walked the in-memory tree. It now resolves the parent through the bind (with the same containment check as the other host operations) and reads the last component without following it, so it prints the stored link text, including relative and dangling targets.
Accept the last path component only when it is one ordinary host file name. Refuse a name that holds a path prefix, a separator, or a parent component, before it joins the checked parent. Test: bind_direct_readlink_reads_only_one_host_name_on_windows.
kevin-orellana
approved these changes
Nov 5, 2026
This was referenced Nov 5, 2026
3 tasks done
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.
Description
readlinkfailed on any path under a direct bind, even for a plain relative symlink sitting right inside it. It only looked in the in-memory filesystem, which can't see into a host-backed directory, so an agent working in a bound project couldn't tell where a link points.Now
readlinkreads the link on the host, with the same check the other host operations use to stay inside the bind, and prints the link text as is, so relative, absolute and dangling targets come back exactly like bash shows them. A non-link or a missing path still exits 1, and paths that aren't on a direct bind behave as before. Unlike bash, a parent directory that is a symlink pointing outside the bind is still refused.Evidence of how this is fixed in Box
Strands Box carries a vendored copy of Shell and already fixed this the same way, so this PR matches it completely: readlink on a bind, and the UPSTREAM.md note.
Related Issues
None.
Documentation PR
None.
Type of Change
Bug fix
Testing
I compared the output with bash for each kind of link target, a link read from a relative directory, a regular file and a missing path, and they all match now. The new tests fail on main and the full suites pass, and when I broke the containment on purpose the escape test caught it. I ran this on Linux only, and the tests are Unix-only because they create symlinks.
cargo test --workspace --all-targets,pytest tests/python,npm test)cargo fmtandcargo clippyChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.