diff options
Diffstat (limited to 'includes/filetransfer/ssh.inc')
-rw-r--r-- | includes/filetransfer/ssh.inc | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/includes/filetransfer/ssh.inc b/includes/filetransfer/ssh.inc index e6148c8f0..774e136d6 100644 --- a/includes/filetransfer/ssh.inc +++ b/includes/filetransfer/ssh.inc @@ -7,7 +7,11 @@ class FileTransferSSH extends FileTransfer { function __construct($jail, $username, $password, $hostname = "localhost", $port = 22) { - parent::__construct($jail, $username, $password, $hostname, $port); + $this->username = $username; + $this->password = $password; + $this->hostname = $hostname; + $this->port = $port; + parent::__construct($jail); } function connect() { @@ -71,4 +75,24 @@ class FileTransferSSH extends FileTransfer { throw new FileTransferException('Cannot check @path.', NULL, array('@path' => $path)); } } + + public function isFile($path) { + $file = escapeshellarg($path); + $cmd = "[ -f {$file} ] && echo 'yes'"; + if ($output = @ssh2_exec($this->connection, $cmd)) { + if ($output == 'yes') { + return TRUE; + } + return FALSE; + } else { + throw new FileTransferException('Cannot check @path.', NULL, array('@path' => $path)); + } + } + + function chmodJailed($path, $mode, $recursive) { + $cmd = sprintf("chmod %s%o %s", $recursive ? '-R ' : '', $mode, escapeshellarg($path)); + if (@!ssh2_exec($this->connection, $cmd)) { + throw new FileTransferException('Cannot change permissions of @path.', NULL, array('@path' => $path)); + } + } } |