Fix SSH CommandPipe transport. Did anyone ever test this?
This commit is contained in:
parent
ea473cf08a
commit
292ce6e12b
|
@ -29,9 +29,9 @@
|
||||||
|
|
||||||
namespace Icinga\Protocol\Commandpipe\Transport;
|
namespace Icinga\Protocol\Commandpipe\Transport;
|
||||||
|
|
||||||
use \RuntimeException;
|
use RuntimeException;
|
||||||
use \Zend_Config;
|
use Zend_Config;
|
||||||
use \Icinga\Logger\Logger;
|
use Icinga\Logger\Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command pipe transport class that uses ssh for connecting to a remote filesystem with the icinga.cmd pipe
|
* Command pipe transport class that uses ssh for connecting to a remote filesystem with the icinga.cmd pipe
|
||||||
|
@ -103,24 +103,18 @@ class SecureShell implements Transport
|
||||||
$this->path
|
$this->path
|
||||||
);
|
);
|
||||||
$hostConnector = $this->user ? $this->user . "@" . $this->host : $this->host;
|
$hostConnector = $this->user ? $this->user . "@" . $this->host : $this->host;
|
||||||
exec(
|
$command = escapeshellarg('['. time() .'] ' . $command);
|
||||||
'ssh -o BatchMode=yes -o KbdInteractiveAuthentication=no'
|
$sshCommand = sprintf(
|
||||||
. $hostConnector.' -p'.$this->port.' "echo \'['. time() .'] '
|
'ssh -o BatchMode=yes -o KbdInteractiveAuthentication=no %s -p %d'
|
||||||
. escapeshellcmd(
|
. ' "echo %s > %s" 2>&1',
|
||||||
$command
|
$hostConnector,
|
||||||
)
|
$this->port,
|
||||||
. '\' > '.$this->path.'" > /dev/null 2> /dev/null & ',
|
$command,
|
||||||
$output,
|
$this->path
|
||||||
$retCode
|
|
||||||
);
|
);
|
||||||
Logger::debug(
|
|
||||||
'ssh '.$hostConnector.' -p'.$this->port.' "echo \'['. time() .'] '
|
exec($sshCommand, $output, $retCode);
|
||||||
. escapeshellcmd(
|
Logger::debug("Command '%s' exited with %d: %s", $sshCommand, $retCode, $output);
|
||||||
$command
|
|
||||||
)
|
|
||||||
. '\' > '.$this->path.'"'
|
|
||||||
);
|
|
||||||
Logger::debug("Return code %s: %s ", $retCode, $output);
|
|
||||||
|
|
||||||
if ($retCode != 0) {
|
if ($retCode != 0) {
|
||||||
$msg = 'Could not send command to remote Icinga host: '
|
$msg = 'Could not send command to remote Icinga host: '
|
||||||
|
|
Loading…
Reference in New Issue