Skip to content

Commit

Permalink
RemoteCommandFile: Don't close stdin to support transmitting multiple…
Browse files Browse the repository at this point in the history
… commands
  • Loading branch information
lippserd committed Jun 9, 2016
1 parent 6d68c0e commit 64e2668
Showing 1 changed file with 2 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,24 +341,6 @@ protected function sendCommandString($commandString)
'Failed to write the whole command to the remote command pipe'
);
}
fclose($this->sshPipes[0]);
$readBuffer = $read = array($this->sshPipes[2]);
$write = null;
$except = null;
$stderr = '';
while (
false !== (stream_select($readBuffer, $write, $exceptBuffer, 0, 20000))
&& $this->getSshProcessStatus('running')
) {
if (! empty($readBuffer)) {
$stderr .= stream_get_contents($readBuffer[0]);
}
// Reset buffer
$readBuffer = $read;
}
if (! empty($stderr)) {
throw new CommandTransportException('Can\'t send external Icinga command: %s', trim($stderr));
}
} else {
$this->throwSshFailure();
}
Expand Down Expand Up @@ -436,7 +418,7 @@ protected function forkSsh()

if (! is_resource($this->sshProcess)) {
throw new CommandTransportException(
'Can\'t send external Icinga command, failed to fork SSH'
'Can\'t send external Icinga command: Failed to fork SSH'
);
}
}
Expand Down Expand Up @@ -473,9 +455,7 @@ protected function throwSshFailure($msg = 'Can\'t send external Icinga command')
public function __destruct()
{
if (is_resource($this->sshProcess)) {
if (is_resource($this->sshPipes[0])) {
fclose($this->sshPipes[0]);
}
fclose($this->sshPipes[0]);
fclose($this->sshPipes[1]);
fclose($this->sshPipes[2]);

Expand Down

0 comments on commit 64e2668

Please sign in to comment.