private $password;
private $root;
+ /**
+ * @var \Net_SFTP
+ */
private $client;
private static $tempFiles = array();
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) {
}
* @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;
}
}