fix(installer): normalize a trailing slash or dot before the managed-root check - #38
Merged
Merged
Conversation
The kernel resolves a symlink when the path ends in "/" or "/.", so a managed root given as "link/" or "link/." was inspected as the link target and passed the ordinary-directory check. Strip both trailing forms before any inspection. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Supersedes #35.
What changed
ensure_managed_rootstrips a trailing/or/.fromINSTALL_ROOTbefore anything inspects it.Why
The kernel resolves a symlink when the path ends in
/or/., so the ordinary-directory check ran against the link target:Severity is low on its own:
CHATMUX_INSTALL_ROOTis user-supplied, and the owner check, the 0700 enforcement, and the dev/inode replacement detection all still apply. But rejecting a symlinked root is the stated purpose of that check, so it should hold for every spelling of the path.Relationship to #35
#35 fixes only the trailing-
/half and rewrites the check fromLC_ALL=C stat %Fto-dplus! -L. That rewrite is not needed — #33 already made the check locale-independent — and it splits one atomicstatinto a separate type test and metadata read. This change keeps the existing singlestatand closes both spellings, so #35 is being closed in favour of it.link/..still resolves through the link. That points at the target's parent, a different object rather than a disguised one, and full normalization would needcd -P, which would rewrite the root whenever$HOMEitself is a symlink. Left alone deliberately.Tests
symlink-trailing-slashandsymlink-trailing-dotadded to the unsafe-root table inserver/install-bootstrap.test.tssh -n install.sh,bash -n install.shcleannpm run typecheck,npm run lint,npm run check:identity,npm test(server 907, client 262) all green