diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-07-18 19:19:33 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-07-18 19:19:33 +0200 |
commit | c8a24188158b12f22b271a8cca8a1cc547434183 (patch) | |
tree | 5110c9238ebca31a513457c8d47f977255222666 | |
parent | 1d520108c5012d2923aac7a6d98bd10bd80ff13a (diff) | |
parent | a27753dd80fad3bdd4706d691b4d03a449047110 (diff) | |
download | nextcloud-server-c8a24188158b12f22b271a8cca8a1cc547434183.tar.gz nextcloud-server-c8a24188158b12f22b271a8cca8a1cc547434183.zip |
Merge pull request #9720 from owncloud/sftp-stream-wrapper-new-connection
Pass existing Net_SFTP object into Net_SFTP_Stream.
-rw-r--r-- | apps/files_external/lib/sftp.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index 0cec250778f..e0655cc8d3d 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -17,6 +17,9 @@ class SFTP extends \OC\Files\Storage\Common { private $password; private $root; + /** + * @var \Net_SFTP + */ private $client; private static $tempFiles = array(); @@ -231,8 +234,8 @@ class SFTP extends \OC\Files\Storage\Common { case 'x+': case 'c': case 'c+': - // FIXME: make client login lazy to prevent it when using fopen() - return fopen($this->constructUrl($path), $mode); + $context = stream_context_create(array('sftp' => array('session' => $this->client))); + return fopen($this->constructUrl($path), $mode, false, $context); } } catch (\Exception $e) { } @@ -294,7 +297,10 @@ class SFTP extends \OC\Files\Storage\Common { * @param string $path */ public function constructUrl($path) { - $url = 'sftp://'.$this->user.':'.$this->password.'@'.$this->host.$this->root.$path; + // Do not pass the password here. We want to use the Net_SFTP object + // supplied via stream context or fail. We only supply username and + // hostname because this might show up in logs (they are not used). + $url = 'sftp://'.$this->user.'@'.$this->host.$this->root.$path; return $url; } } |