Skip to content

Commit 157a8d0

Browse files
committed
Use setInput instead of escapeshellarg for command
1 parent b075e49 commit 157a8d0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Server/Remote/NativeSsh.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,21 @@ public function run($command)
8383
$sshOptions[] = '-t';
8484
}
8585

86-
$sshCommand = 'ssh ' . implode(' ', $sshOptions) . ' ' . escapeshellarg($username . $hostname) . ' ' . escapeshellarg($command);
86+
$sshCommand = 'ssh ' . implode(' ', $sshOptions) . ' ' . escapeshellarg($username . $hostname) . ' bash -s';
8787

8888
try {
8989
$process = new Process($sshCommand);
9090
$process
91+
->setInput($command)
9192
->setPty($serverConfig->getPty())
9293
->setTimeout(null)
9394
->setIdleTimeout(null)
94-
->mustRun();
95+
->start();
96+
97+
if (0 !== $process->wait()) {
98+
throw new ProcessFailedException($process);
99+
}
100+
95101
} catch (ProcessFailedException $exception) {
96102
$errorMessage = \Deployer\isDebug() ? $exception->getMessage() : $process->getErrorOutput();
97103
throw new \RuntimeException($errorMessage);

0 commit comments

Comments
 (0)