Bug #75261 [Opn->Csd]: cURL sftp regression
| From: | b dot collin at immanens dot com | Date: | Tue, 26 Sep 2017 15:01:14 +0000 |
| Subject: | Bug #75261 [Opn->Csd]: cURL sftp regression | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211367@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75261&edit=1
ID: 75261
User updated by: b dot collin at immanens dot com
Reported by: b dot collin at immanens dot com
Summary: cURL sftp regression
-Status: Open
+Status: Closed
Type: Bug
Package: cURL related
Operating System: Windows
PHP Version: 7.1.9
Block user comment: N
Private report: N
New Comment:
It has to be done with a new way
Previous Comments:
------------------------------------------------------------------------
[2017-09-26 14:59:44] b dot collin at immanens dot com
Ok.
I have test with CURLOPT_USERPWD, but don't change the CURLOPT_PORT...
It work now. Either I fail my test, or the host:port syntax is not yet supported too.
The change seem to happen between 7.0.4 and 7.0.18
The new way work in 7.1.x
Thank you
------------------------------------------------------------------------
[2017-09-26 14:42:12] spam2 at rhsoft dot net
why don#t you use CURLOPT_USERPWD which is excatly designed for that usecase and leave curl_init()
alone? that below is a snippet from a with 5.6, 7.0, 7.1 and 7.2 working wrapper library written
long ago to replace pecl-ssh2
public function connect(): bool
{
try
{
$options =
[
CURLOPT_PROTOCOLS => CURLPROTO_SFTP,
CURLOPT_PORT => $this->port,
CURLOPT_USERPWD => "$this->user:$this->pwd",
CURLOPT_RETURNTRANSFER => 1,
];
$this->curl = curl_init();
curl_setopt_array($this->curl, $options);
if($this->curl)
{
return true;
}
else
{
return false;
}
}
catch(Throwable $e)
{
return false;
}
}
------------------------------------------------------------------------
[2017-09-26 14:37:33] b dot collin at immanens dot com
Description:
------------
I think that php 7.1 introduce a curl regression with the sftp protocol.
Below, a short script that work in php until 7.0.x, and produce an error message "Could not
resolve host: xxxxx" where xxxxx is the username and not the host !
I check several version, php <= 7.0.x seem to be ok.
php 7.1.9, 7.1.10RC1 and 7.2.0RC2 are ko.
Test script:
---------------
$host = 'myhost.sftphost.test:22';
$user = 'myuser';
$password = 'mypassword';
$path = '/path/toexplore/';
$c = curl_init('sftp://'.$user.':'.$password.'@'.$host.$path);
curl_setopt($c, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
curl_setopt($c, CURLOPT_FTPLISTONLY, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($c);
print "curl message : ".curl_error($c)."\n";
print "data : ".var_dump($data);
Expected result:
----------------
If the config is ok, we should obtain the list of file from the sftp server whithout error.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75261&edit=1