[Pkg-owncloud-commits] [owncloud] 08/23: Pass existing Net_SFTP object into Net_SFTP_Stream.

David Prévot taffit at moszumanska.debian.org
Tue Jul 22 15:21:35 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 740347648913aa409b2127cf59928c132170e8bf
Author: Andreas Fischer <bantu at owncloud.com>
Date:   Sat Jul 12 22:45:53 2014 +0200

    Pass existing Net_SFTP object into Net_SFTP_Stream.
---
 apps/files_external/lib/sftp.php | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php
index 0cec250..e0655cc 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;
 	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list