Bug #75261 [Com]: cURL sftp regression

From: Date: Tue, 26 Sep 2017 14:42:22 +0000
Subject: Bug #75261 [Com]: cURL sftp regression
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211365@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 Comment by: spam2 at rhsoft dot net Reported by: b dot collin at immanens dot com Summary: cURL sftp regression Status: Open Type: Bug Package: cURL related Operating System: Windows PHP Version: 7.1.9 Block user comment: N Private report: N New Comment: 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; } } Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#211365) next »