diff --git a/frontend/classes/class.node.php b/frontend/classes/class.node.php index 92e8efc..54d847e 100644 --- a/frontend/classes/class.node.php +++ b/frontend/classes/class.node.php @@ -15,7 +15,7 @@ if(!isset($_CVM)) { die("Unauthorized."); } class Node extends CPHPDatabaseRecordClass { - + public $ssh = null; } ?> diff --git a/frontend/classes/class.sshconnector.php b/frontend/classes/class.sshconnector.php index 7cfeab4..d7e1200 100644 --- a/frontend/classes/class.sshconnector.php +++ b/frontend/classes/class.sshconnector.php @@ -26,6 +26,8 @@ class SshConnector extends CPHPBaseClass public $pubkey = ""; public $keytype = "ssh-rsa"; + public $helper = "~/runhelper"; + public function RunCommand($command) { if($this->connected == false && $this->authenticated == false) @@ -99,12 +101,16 @@ class SshConnector extends CPHPBaseClass private function DoCommand($command) { + $command = str_replace("'", "\'", $command); + $command = "{$this->helper} '{$command}'"; + $stream = ssh2_exec($this->connection, $command); stream_set_blocking($stream, true); - $returndata = stream_get_contents($stream); + $returndata = json_decode(stream_get_contents($stream)); fclose($stream); + return $returndata; } } diff --git a/frontend/test.php b/frontend/test.php index 4a5083b..95cb143 100644 --- a/frontend/test.php +++ b/frontend/test.php @@ -7,5 +7,5 @@ $ssh->host = "cvm-vz.cryto.net"; $ssh->key = "/etc/cvm/key"; $ssh->pubkey = "/etc/cvm/key.pub"; -var_dump($ssh->RunCommand("df -h")); +var_dump($ssh->RunCommand("cp derp2 derp")); ?>