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:
@@ -272,6 +272,41 @@ describe('resolveRemoteNodePath', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('uses -c (not -lc) for a csh login shell, which rejects combined -lc', async () => {
|
||||
// Why: csh/tcsh reject `-lc` and mis-handle `-l` here ("Bad : modifier",
|
||||
// issue #8701), so the login-shell probe must drop to plain `-c`.
|
||||
execCommandMock
|
||||
.mockResolvedValueOnce('\n') // path probe: empty
|
||||
.mockResolvedValueOnce('/bin/csh\n') // $SHELL
|
||||
.mockResolvedValueOnce('/usr/local/bin/node\n')
|
||||
.mockResolvedValueOnce('v20.0.0\n')
|
||||
|
||||
await expect(resolveRemoteNodePath(conn)).resolves.toBe('/usr/local/bin/node')
|
||||
expect(execCommandMock).toHaveBeenNthCalledWith(3, conn, `'/bin/csh' -c 'command -v node'`, {
|
||||
wrapCommand: false,
|
||||
timeoutMs: 8_000
|
||||
})
|
||||
})
|
||||
|
||||
it('uses -c (not -lc) for a tcsh login shell', async () => {
|
||||
execCommandMock
|
||||
.mockResolvedValueOnce('\n') // path probe: empty
|
||||
.mockResolvedValueOnce('/usr/bin/tcsh\n') // $SHELL
|
||||
.mockResolvedValueOnce('/usr/local/bin/node\n')
|
||||
.mockResolvedValueOnce('v20.0.0\n')
|
||||
|
||||
await expect(resolveRemoteNodePath(conn)).resolves.toBe('/usr/local/bin/node')
|
||||
expect(execCommandMock).toHaveBeenNthCalledWith(
|
||||
3,
|
||||
conn,
|
||||
`'/usr/bin/tcsh' -c 'command -v node'`,
|
||||
{
|
||||
wrapCommand: false,
|
||||
timeoutMs: 8_000
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
// ── Failure ───────────────────────────────────────────────────────────
|
||||
|
||||
it('throws when both strategies find no usable node', async () => {
|
||||
|
||||
Reference in New Issue
Block a user