diff options
author | Vincent Petry <pvince81@owncloud.com> | 2013-11-19 23:16:20 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-01-23 12:43:12 +0100 |
commit | 421f24868a8cd5bdf8ef52a96948ddd00a8abbef (patch) | |
tree | 13703c2c2421cdd714001cd08bb014a9b7b11a34 /apps/files_external/lib | |
parent | 0daabe5b6a2f96e8b754c2414bb83d00277a307a (diff) | |
download | nextcloud-server-421f24868a8cd5bdf8ef52a96948ddd00a8abbef.tar.gz nextcloud-server-421f24868a8cd5bdf8ef52a96948ddd00a8abbef.zip |
Now using SFTP stream wrapper from phpseclib
- Upgraded phpseclib to master version (post 0.3.5)
- Now using fopen() on sftp URL for both read and write
- Fixes #4063
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r-- | apps/files_external/lib/sftp.php | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index 95e0cefa398..e3689b751c2 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -10,6 +10,7 @@ namespace OC\Files\Storage; set_include_path(get_include_path() . PATH_SEPARATOR . \OC_App::getAppPath('files_external') . '/3rdparty/phpseclib/phpseclib'); require 'Net/SFTP.php'; +require 'Net/SFTP/Stream.php'; class SFTP extends \OC\Files\Storage\Common { private $host; @@ -205,16 +206,6 @@ class SFTP extends \OC\Files\Storage\Common { if ( !$this->file_exists($path)) { return false; } - - if (strrpos($path, '.')!==false) { - $ext=substr($path, strrpos($path, '.')); - } else { - $ext=''; - } - $tmp = \OC_Helper::tmpFile($ext); - $this->getFile($absPath, $tmp); - return fopen($tmp, $mode); - case 'w': case 'wb': case 'a': @@ -227,24 +218,8 @@ class SFTP extends \OC\Files\Storage\Common { case 'x+': case 'c': case 'c+': - if (strrpos($path, '.')!==false) { - $ext=substr($path, strrpos($path, '.')); - } else { - $ext=''; - } - - $tmpFile=\OC_Helper::tmpFile($ext); - \OC\Files\Stream\Close::registerCallback( - $tmpFile, - array($this, 'writeBack') - ); - - if ($this->file_exists($path)) { - $this->getFile($absPath, $tmpFile); - } - - self::$tempFiles[$tmpFile]=$absPath; - return fopen('close://'.$tmpFile, $mode); + // FIXME: make client login lazy to prevent it when using fopen() + return fopen($this->constructUrl($path), $mode); } } catch (\Exception $e) { } @@ -309,4 +284,9 @@ class SFTP extends \OC\Files\Storage\Common { return false; } } + + public function constructUrl($path) { + $url = 'sftp://'.$this->user.':'.$this->password.'@'.$this->host.$this->root.$path; + return $url; + } } |