Skip to content

fix: omit SSH_AUTH_SOCK from forward.env when symlinking - #453

Open
RobinLassonde wants to merge 1 commit into
shell-pool:masterfrom
RobinLassonde:fix/forward-env-ssh-auth-sock
Open

RobinLassonde wants to merge 1 commit into
shell-pool:masterfrom
RobinLassonde:fix/forward-env-ssh-auth-sock

Conversation

@RobinLassonde

Copy link
Copy Markdown

Issue Link

N/A

AI Policy Ack

Please ack that you have read the AI Policy
and explain your use of AI to generate this PR.

This PR was:

  • mostly or completely vibe coded
  • mostly or completely meat coded
  • bit of both

Description

When SSH_AUTH_SOCK symlinking is active (the default), build_shell_env initializes SSH_AUTH_SOCK to the stable per-session symlink ($SHPOOL_SESSION_DIR/ssh-auth-sock.socket) and link_ssh_auth_sock updates that symlink on every attach.

However, populate_session_env_file was also writing the client's raw SSH_AUTH_SOCK path from header.local_env into forward.env. On the next prompt cycle, the shell's prompt hook sourced forward.env and overwrote SSH_AUTH_SOCK with the ephemeral client socket path. After disconnecting and reattaching with a new agent socket, the first command run before a subsequent prompt cycle saw the stale socket path instead of the updated symlink.

Skip SSH_AUTH_SOCK in format_forward_env when
nosymlink_ssh_auth_sock is false/unset so forward.env leaves the per-session symlink untouched, while preserving existing behavior when nosymlink_ssh_auth_sock = true.

Add a unit test for format_forward_env filtering and an integration test verifying SSH_AUTH_SOCK resolves to the updated symlink target on the first command after reattach.

When SSH_AUTH_SOCK symlinking is active (the default), build_shell_env
initializes SSH_AUTH_SOCK to the stable per-session symlink
($SHPOOL_SESSION_DIR/ssh-auth-sock.socket) and link_ssh_auth_sock updates
that symlink on every attach.

However, populate_session_env_file was also writing the client's raw
SSH_AUTH_SOCK path from header.local_env into forward.env. On the next
prompt cycle, the shell's prompt hook sourced forward.env and overwrote
SSH_AUTH_SOCK with the ephemeral client socket path. After disconnecting
and reattaching with a new agent socket, the first command run before a
subsequent prompt cycle saw the stale socket path instead of the updated
symlink.

Skip SSH_AUTH_SOCK in format_forward_env when
nosymlink_ssh_auth_sock is false/unset so forward.env leaves the
per-session symlink untouched, while preserving existing behavior when
nosymlink_ssh_auth_sock = true.

Add a unit test for format_forward_env filtering and an integration test
verifying SSH_AUTH_SOCK resolves to the updated symlink target on the
first command after reattach.

AI usage: used AI to generate the entire PR, including tests.
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