Repository navigation
🐛 fix(terminal): find default tmux socket under arbitrary container UID - #14791
Conversation
With no per-agent UID map every hive-<agent> session lives on the default
tmux server of the UID the container runs as. ttyd-tmux.sh's fallback
assumed that was dev's passwd uid (/tmp/tmux-1001/default). Under
OpenShift's restricted SCC the container runs as an arbitrary uid with no
passwd entry, so the helper polled the wrong socket for 900s while every
session was alive.
Walk a deduplicated candidate list instead: the current uid's default
socket, dev's, then any ${TMUX_TMPDIR:-/tmp}/tmux-*/default, and use the
first that is a socket and holds the requested session. The
available-sessions hint lists sessions from every default server found
and no longer reports the socket name 'default' as a session.
Adds test_ttyd_default_socket_uid.sh (id stubbed, real tmux servers at
each layout's path) and wires it into v2-ci.
Fixes #14789
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@clubanderson is auto-promoted for contributor-lane merging on this PR: the last 5 merged PRs by this author in this hive's repositories have no revert or sentinel-alert evidence. CI, reviewer verdict, diff fences, soak, holds and branch protection still apply. |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Read src/deploy/ttyd-tmux.sh at f566ea9 against the v5 tree. This looks correct to me.
default_socket_candidates()(ttyd-tmux.sh:80-98) emits current-uid →id -u dev→ glob, deduplicated via theseenlist, and the unmatched-glob literal is discarded by[ -S ]soset -u/pipefailare not tripped. Both callers (list_available_sessions,ttyd-tmux.sh:49-72;find_tmux_socket,ttyd-tmux.sh:112-137) consume it throughread -r, so a socket path with no session falls through to the next candidate rather than attaching to the wrong server.socket_has_session(ttyd-tmux.sh:98-110) is unchanged and still routes throughsu-execwhen the socket owner differs from the current uid, so the per-agent-UID path keeps working.- No other place hard-codes
/tmp/tmux-1001: the only remainingid -u devinsrc/deploy/entrypoint.sh:380is the token-ownership check, not a socket path, and I found no Go code insrc/pkg/src/cmdcomputing a default tmux socket path — the fix is complete in the script. - The
v2-ci.ymlchange only adds a test step next to the existingtest_ttyd_url_arg.shone; no permissions or triggers change.
One note, not a defect: test_ttyd_default_socket_uid.sh skips the whole suite when su-exec is on PATH (it printed SKIP: su-exec is on PATH / 0 passed, 0 failed on this host). That is fine on the ubuntu runners, but it means the suite is a no-op inside the hive image itself if anyone runs it there.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Looks correct to me.
Read src/deploy/ttyd-tmux.sh at v5 @ 4fc7d11 against the diff:
- The tree had five sites that assumed
/tmpand dev's passwd UID (ttyd-tmux.sh:39,:44-45,:55,:76,:88-89); the diff replaces all of them, so no stale/tmp/tmux-1001/defaultlookup remains after this lands. default_socket_candidatesordersid -ufirst, thenid -u dev || 1001, then the glob — the Compose/Podman case (both equal) dedupes to one probe, and the OpenShift arbitrary-UID case finds the right socket on the first probe. The-Stest discards the unmatched literal glob, so not settingnullglobis fine.find_tmux_socketstill requiressocket_has_sessionon each candidate (ttyd-tmux.sh:58-71), so the boot-time "bare default socket, session not yet created" guard this fallback originally protected is preserved for every candidate, not just the first.- The
.github/workflows/v2-ci.ymlhunk only adds a test step aftertest_ttyd_url_arg.sh; no permission or trigger changes. The new test self-skips whensu-execis on PATH, which matches the helper's real behaviour (ttyd-tmux.sh:66,:251) rather than hiding it.
Nothing blocking from me.
— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
f566ea9
ℹ️ Sentinel notice — informational; author is trusted (owner), merge is not blockedHive flagged this PR (author @clubanderson, head
Hive did not add the |
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at f566ea9. |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Fixes #14789
Problem
On an OpenShift spoke under the restricted SCC (container UID
1000840000), the dashboard terminal showedwaiting for agent 'X' to start (tmux session not created yet); polling up to 900s...for every agent, whiletmux lsshowed everyhive-<agent>session alive.With no per-agent UID map all sessions live on the default tmux server,
/tmp/tmux-$(id -u)/default.ttyd-tmux.sh's fallback for that layout computed the socket as/tmp/tmux-$(id -u dev || 1001)/default— dev's passwd uid, not the uid the process runs as. On Compose/Podman they coincide; under an arbitrary OpenShift uid they never do.Fix (
src/deploy/ttyd-tmux.sh)default_socket_candidates(): deduplicated, likelihood-ordered list —${TMUX_TMPDIR:-/tmp}/tmux-$(id -u)/default,…/tmux-$(id -u dev || 1001)/default, then any…/tmux-*/defaultpresent (unmatched glob discarded by-S, soset -euo pipefailstays happy).find_tmux_socket()walks the candidates and takes the first that is a socket and has the requested session (socket_has_session, which keeps the su-exec path for sockets owned by another uid).list_available_sessions()lists sessions from every default server found, and no longer reports the socket namedefaultas if it were a session.TMUX_TMPDIR(tmux's own convention), which is also what lets the test point the lookup at a scratch dir.entrypoint.shwas checked: its1001/id -u devreferences are ownership and privilege-drop checks, not tmux socket paths, so nothing to change there.Tests
New
src/deploy/test_ttyd_default_socket_uid.sh(wired intov2-ci.yml, verified bytest_deploy_suites_wired.sh).idis stubbed on PATH; real tmux servers are started withtmux -Sat the exact path each layout would use; the helper is run for real and attachment is asserted positively via the wheel rebind it leaves on the server:id -u dev= 1001 but server on current uid → resolves (the reporting spoke's exact state)defaultavailable sessions: none, noset -utripWorkaround currently on the spoke (can be removed after upgrade)
ln -s /tmp/tmux-$(id -u) /tmp/tmux-1001