Skip to content

Follow a symlinked temporary directory to the TUI socket - #424

Open
jeremy wants to merge 1 commit into
mainfrom
fanB-394
Open

Follow a symlinked temporary directory to the TUI socket#424
jeremy wants to merge 1 commit into
mainfrom
fanB-394

Conversation

@jeremy

@jeremy jeremy commented Sep 9, 2026

Copy link
Copy Markdown
Member

Fixes #394

Repro

hey tui places its open-request socket under a per-user directory in the temp root when XDG_RUNTIME_DIR is unset, and tuiRuntimeDir refused a temp root that is a symlink. On macOS /tmp is a symlink to /private/tmp, and /tmp is exactly what os.TempDir() answers whenever TMPDIR is unset — an ssh session, a launchd job, a shell started outside the login environment, or a fresh machine where the terminal was not launched from a session that exports it. Every other command works because only the TUI touches the socket path; hey tui fails with Error: temporary directory is not a directory.

Reproduced on this Mac on main with TMPDIR cleared: tuiSocketPath("") returns that error. TestTopicRemoteFallbackFollowsSymlinkedTemporaryDirectory pins the same shape portably (a TMPDIR that is a symlink to a real directory) and fails on main.

Fix

Resolve the temp root with filepath.EvalSymlinks and inspect the directory it names. The sticky-bit/world-writable check now runs against the real directory (/private/tmp is 1777, so it passes), and the per-user hey-cli-<uid> directory is created and validated under the resolved path exactly as before — the symlink rejection on that directory is unchanged, since it is the one an attacker in a shared temp root could swap.


Summary by cubic

Fixes hey tui failing on macOS when the temporary directory is a symlink (as /tmp is to /private/tmp). The runtime-dir fallback now resolves symlinks before validating the directory, so the socket path works when TMPDIR is unset. The per-user directory is still created and validated as before, and a test covers this case.

Written for commit 4e97da7. Summary will update on new commits.

Review in cubic

macOS's /tmp is a symlink to /private/tmp, and it is what os.TempDir
answers whenever TMPDIR is unset — an ssh session, a launchd job, a shell
started outside the login environment. The runtime-directory fallback
refused any symlink there, so hey tui failed with "temporary directory is
not a directory" while every other command worked. Resolve the link and
inspect the directory it names; the per-user directory under it is still
created and validated as before.
Copilot AI balanced review requested due to automatic review settings September 9, 2026 23:21
@jeremy
jeremy requested a review from a team as a code owner September 9, 2026 23:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-09T23:24:11.018027Z 4e97da7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix preserves private-directory validation and includes appropriate regression coverage.

Pull request overview

Fixes TUI startup on macOS when the temporary directory is symlinked.

Changes:

  • Resolves the temporary root before validating it.
  • Adds portable regression coverage for symlinked temporary directories.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File summaries
File Description
internal/tui/open_remote_unix.go Resolves and validates the real temporary directory.
internal/tui/open_remote_unix_test.go Tests symlinked temporary-root fallback.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hey tui won't start on fresh macos install

2 participants