Merge pull request #9720 from owncloud/sftp-stream-wrapper-new-connection
Pass existing Net_SFTP object into Net_SFTP_Stream.
This commit is contained in:
commit
c8a2418815
|
@ -17,6 +17,9 @@ class SFTP extends \OC\Files\Storage\Common {
|
||||||
private $password;
|
private $password;
|
||||||
private $root;
|
private $root;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Net_SFTP
|
||||||
|
*/
|
||||||
private $client;
|
private $client;
|
||||||
|
|
||||||
private static $tempFiles = array();
|
private static $tempFiles = array();
|
||||||
|
@ -231,8 +234,8 @@ class SFTP extends \OC\Files\Storage\Common {
|
||||||
case 'x+':
|
case 'x+':
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'c+':
|
case 'c+':
|
||||||
// FIXME: make client login lazy to prevent it when using fopen()
|
$context = stream_context_create(array('sftp' => array('session' => $this->client)));
|
||||||
return fopen($this->constructUrl($path), $mode);
|
return fopen($this->constructUrl($path), $mode, false, $context);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
}
|
}
|
||||||
|
@ -294,7 +297,10 @@ class SFTP extends \OC\Files\Storage\Common {
|
||||||
* @param string $path
|
* @param string $path
|
||||||
*/
|
*/
|
||||||
public function constructUrl($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;
|
return $url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue