Skip to content

fix(installer): normalize a trailing slash or dot before the managed-root check - #38

Merged
devswha merged 1 commit into
mainfrom
fix/install-root-trailing-component
Aug 13, 2026
Merged

fix(installer): normalize a trailing slash or dot before the managed-root check#38
devswha merged 1 commit into
mainfrom
fix/install-root-trailing-component

Conversation

@devswha

@devswha devswha commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Supersedes #35.

What changed

ensure_managed_root strips a trailing / or /. from INSTALL_ROOT before 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:

link    -> rejected
link/   -> ACCEPTED   <-- bypass
link/.  -> ACCEPTED   <-- bypass

Severity is low on its own: CHATMUX_INSTALL_ROOT is 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 from LC_ALL=C stat %F to -d plus ! -L. That rewrite is not needed — #33 already made the check locale-independent — and it splits one atomic stat into a separate type test and metadata read. This change keeps the existing single stat and 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 need cd -P, which would rewrite the root whenever $HOME itself is a symlink. Left alone deliberately.

Tests

  • symlink-trailing-slash and symlink-trailing-dot added to the unsafe-root table in server/install-bootstrap.test.ts
  • removing the normalization loop makes that test fail, so the cases are not vacuous
  • sh -n install.sh, bash -n install.sh clean
  • npm run typecheck, npm run lint, npm run check:identity, npm test (server 907, client 262) all green

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>
@devswha
devswha merged commit 2efc54c into main Aug 13, 2026
2 checks passed
@devswha
devswha deleted the fix/install-root-trailing-component branch August 13, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant