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:
@@ -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)}`
|
||||
}
|
||||
Reference in New Issue
Block a user