fix(ssh): make POSIX relay wrapper survive csh/tcsh login shells (#8709)

Reconstruct remote POSIX commands with bounded printf arguments so non-POSIX SSH login shells can forward them without requiring remote base64. Preserve relay and system-SSH stdin, and centralize login-shell flag selection for csh/tcsh compatibility.\n\nValidated against real csh and tcsh OpenSSH targets with built-in and system SSH, including cold relay deployment, stdin upload, PTY I/O, file mutation, and reconnect.
This commit is contained in:
Haohan Lin
2026-07-15 02:38:40 -07:00
committed by GitHub
parent c12ade54d6
commit 190ed7d4ed
7 changed files with 198 additions and 18 deletions
+11
View File
@@ -0,0 +1,11 @@
import { shellEscape } from './ssh-connection-utils'
const COMMAND_ONLY_SHELLS = new Set(['sh', 'dash', 'csh', 'tcsh'])
/** Build a command using the startup mode supported by the configured login shell. */
export function buildSshLoginShellCommand(shell: string, command: string): string {
const shellName = shell.split('/').at(-1)
// Why: csh/tcsh reject combined -lc, while sh/dash do not need login mode here.
const mode = shellName && COMMAND_ONLY_SHELLS.has(shellName) ? '-c' : '-lc'
return `${shellEscape(shell)} ${mode} ${shellEscape(command)}`
}